源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

739 line
23 KiB

  1. SceneDropObj = SceneDropObj or BaseClass(EventDispatcher)
  2. local SceneDropObj = SceneDropObj
  3. local GameMath_GetDistance = GameMath.GetDistance
  4. function SceneDropObj:__init()
  5. self.obj_type = SceneBaseType.Drop
  6. self.drop_mgr = SceneDropManager:getInstance()
  7. self.guild_model = GuildModel:getInstance()
  8. self.scene_mgr = SceneManager:getInstance()
  9. self.scene = Scene.getInstance()
  10. self.nameboard_Manager = NameBoardManager.getInstance()
  11. self.nameboard_index = false
  12. self.name_board = false
  13. self.not_fly_float = false--不需要飞飘字
  14. --根父容器
  15. -- local view_path = "root/Canvas/SceneDropObj"
  16. -- local go = GameObject.Find(view_path)
  17. -- if go then
  18. -- local item = newObject(go)
  19. -- item.gameObject:SetActive(true)
  20. -- self.gameObject = item.gameObject
  21. -- item.transform:SetParent(panelMgr:GetParent("SceneObjContainer").transform)
  22. -- item.transform.localScale = Vector3.one
  23. -- item.transform.localPosition = Vector3.zero
  24. -- end
  25. self.gameObject = UiFactory.createChild(panelMgr:GetParent("SceneObjContainer").transform,UIType.SceneDropObj) --先用uifactory来创建该容器吧 日后再调整
  26. self.transform = self.gameObject.transform
  27. self.item_parent = self.transform:Find("ItemCon")
  28. self.effect_parent = self.transform:Find("EffectCon")
  29. self.obj_parent = self.transform:Find("ItemCon/obj").transform
  30. self.item_icon_con = self.transform:Find("ItemCon/Icon").gameObject
  31. self.item_parent.localScale = Vector3.one * SceneModelScale
  32. self.icon_render = self.item_icon_con:GetComponent("SpriteRenderer")
  33. self.animator = self.item_parent.gameObject:GetComponent("Animator")
  34. self.effect_parent.localPosition = Vector3(0,-0.1,0)
  35. self.obj_parent.localPosition = Vector3(0,-0.1,0)
  36. --特效数组
  37. self.particle_list = {}
  38. self.max_scale = 1
  39. self.create_time = 0 --记录掉落创建时间
  40. self.every_time = 30 --多少秒后其他人可以拾取归属掉落
  41. self.state = 0 -- 1 作为抛物线 2 静止地面 3 等待发送协议 4 缩小 5 飞到角色身上 5 从角色身上飞到背包 9 变透明 10抛物线之后的第二个动画
  42. self.step_start_time = 0 -- 步骤的开始时间
  43. self.can_not_pick = false --服务端返回掉落不能拾取,就标记一下
  44. self.last_pick_time = 0 --捡取时间
  45. self.sound_id = 0
  46. self.no_smooth_height = true
  47. self.effect_gameObject = false
  48. self.drop_model_gameObject = false
  49. self.add_effect_type = 0 -- 1通过缓存 2 通过接口
  50. self.scene = Scene.Instance
  51. self.res_use_ref = {}
  52. self:InitEvents()
  53. end
  54. function SceneDropObj:GetDropVo()
  55. return self.vo
  56. end
  57. function SceneDropObj:InitEvents()
  58. local function onCanNotPickSceneDropItem(drop_id)
  59. --标记为不能拾取, 自动挂机不去捡, 但手动走过去还是会捡的
  60. if self.drop_id == drop_id then
  61. self.can_not_pick = true
  62. self.state = 2
  63. end
  64. end
  65. self.can_not_pick_up_id = GlobalEventSystem:Bind(SceneEventType.CAN_NOT_PICK_SCENE_DROP_ITEM, onCanNotPickSceneDropItem)
  66. local function onPickSceneDropItem(vo)
  67. if self.drop_id == vo.drop_id then
  68. self.can_pick = true
  69. end
  70. end
  71. self.pick_up_id = GlobalEventSystem:Bind(SceneEventType.PICK_SCENE_DROP_ITEM, onPickSceneDropItem)
  72. --掉落消失,相对于其他队友 --所有的人都会收到
  73. local function onDismissDropItem(drop_id)
  74. local onCall = function ( )
  75. if self.drop_id == drop_id and not self:IsPicking() then
  76. self.step_start_time = Status.NowTime
  77. self.state = 9
  78. end
  79. end
  80. if SceneManager.Instance:IsBossMoneyScene() then
  81. onCall()
  82. else
  83. setTimeout(onCall, 0.5) --15053返回后再判断是否被自己拾取,如果是则不消失,进入状态4
  84. end
  85. end
  86. self.dismiss_item_id = GlobalEventSystem:Bind(SceneEventType.DISMiSS_SCENE_DROP_ITEM, onDismissDropItem)
  87. -- 社团boss拾取特殊处理相关逻辑
  88. -- 社团boss开始进入拾取进度
  89. -- local function onStartPickGBossDrop(vo)
  90. -- if vo.drop_id == self.drop_id then
  91. -- local function delay_finish_pick()
  92. -- if self.drop_id and self.state == 2 or self.state == 3 then
  93. -- self.guild_model:Fire(GuildModel.PICK_UP_BOSS_DROP_ITEM, GuildModel.GBossPickOpty.Succeed, self.vo.drop_id)
  94. -- end
  95. -- end
  96. -- self:CancelGuildBossPickDelayId()
  97. -- self.gboss_pickup_delay_id = setTimeout(delay_finish_pick, 3 + 1) -- 多延迟1秒,方便采集界面的效果表现完整
  98. -- end
  99. -- end
  100. -- self.on_start_pick_gboss_drop_id = GlobalEventSystem:Bind(SceneEventType.GBOSS_PICK_START, onStartPickGBossDrop)
  101. -- 社团boss假采集中断
  102. -- local function onCancelGbossPick(drop_id)
  103. -- if self.drop_id == drop_id then
  104. -- self:CancelGuildBossPickDelayId()
  105. -- self.guild_model:Fire(GuildModel.PICK_UP_BOSS_DROP_ITEM,GuildModel.GBossPickOpty.Cancel, self.vo.drop_id)
  106. -- end
  107. -- end
  108. -- self.on_cancel_gboss_pick = GlobalEventSystem:Bind(SceneEventType.GBOSS_PICK_CANCEL, onCancelGbossPick)
  109. local function onRefeshDropItem()
  110. if self.gboss_need_refresh then
  111. self:InitDropVo(self.vo, self.center_x, self.center_y)
  112. self.gboss_need_refresh = false
  113. end
  114. end
  115. self.need_refresh_boss_info = self.guild_model:Bind(GuildModel.UPDATE_GUILD_BOSS_INFO, onRefeshDropItem)
  116. end
  117. function SceneDropObj:InitDropVo(vo,center_x,center_y)
  118. self.vo = vo
  119. self.center_x = center_x
  120. self.center_y = center_y
  121. self.drop_id = vo.drop_id
  122. self.compress_id = Scene.CompressObjId(SceneBaseType.Drop, self.drop_id)
  123. self.can_pick = vo.can_pick or false --是否能捡起,只有推送 15053 才能自己捡起 -- 遗忘之境默认自己能捡起来
  124. self.fake_pick = vo.fake_pick or false--假掉落或直接拾取
  125. -- 这个变量的作用是保证在社团场景中能等社团boss协议数据到达之后再次刷新掉落物品,防止掉落物信息和采集流程出错和重登掉落物的状态问题
  126. self.gboss_need_refresh = false
  127. local is_in_gboss_event = false
  128. if self.scene_mgr:IsGuildScene() then
  129. is_in_gboss_event = self.guild_model:GetSepcialPickLogicOfGBoss()
  130. if not is_in_gboss_event then
  131. self.gboss_need_refresh = true
  132. end
  133. end
  134. if vo then
  135. local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(vo.drop_type, vo.type_id)
  136. self.goods_basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
  137. if self.goods_basic then
  138. self.color = color or self.goods_basic.color or 1
  139. local goods_icon = self.goods_basic.goods_icon
  140. self.item_name = self.goods_basic.goods_name
  141. if self.goods_basic.type == 11 and (self.goods_basic.subtype == 10 or self.goods_basic.subtype == 11)then --装备鉴定物, 碎片,显示鉴定物对应的装备图标
  142. local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(self.goods_basic.type_id, RoleManager.Instance.mainRoleInfo.career, self.goods_basic.color)
  143. goods_icon = icon
  144. self.item_name = _name
  145. end
  146. if not self.nameboard_index then
  147. self.nameboard_index,self.name_board = self.nameboard_Manager:CreateNameBoard()
  148. end
  149. if self.name_board then
  150. self.name_board:SetGameObjectName(self.item_name)
  151. self.name_board:SetGoodsConVisible(true)
  152. self.name_board:SetGoodsName(Language.substitute("<color={0}>{1}</color>", WordManager.GetGoodsColor(self.goods_basic.color, true), Trim(self.goods_basic.goods_name)))
  153. self.name_board:SetHpVisible(false)
  154. end
  155. local abName = ""
  156. local resName = ""
  157. local drop_icon = tonumber(vo.drop_icon) or 1
  158. if not drop_icon or drop_icon == 0 then
  159. abName = "model_dropmodel_" .. 1
  160. resName = "model_dropmodel_" .. 1
  161. else
  162. abName = "model_dropmodel_" .. drop_icon
  163. resName = "model_dropmodel_" .. drop_icon
  164. end
  165. local loadDropModelCallBack = function(objs)
  166. if self.drop_model_gameObject then
  167. destroy(self.drop_model_gameObject, true)
  168. self.drop_model_gameObject = false
  169. end
  170. if self._use_delete_method then
  171. return
  172. end
  173. if not objs or not objs[0] then
  174. logWarn("cannot find drop res = "..drop_icon)
  175. return
  176. end
  177. self.drop_model_gameObject = newObject(objs[0])
  178. self.drop_model_gameObject:SetActive(true)
  179. self.drop_model_gameObject.transform:SetParent(self.obj_parent)
  180. self.drop_model_gameObject.transform.localPosition = Vector3.zero
  181. self.drop_model_gameObject.transform.localRotation = Quaternion.identity
  182. self.drop_model_gameObject.transform.localScale = Vector3.one
  183. end
  184. if self.obj_parent and abName and resName then
  185. LuaResManager:getInstance():loadPrefab(self,abName,resName, loadDropModelCallBack, true)
  186. end
  187. -- print("Saber:SceneDropObj [165] self.vo.expire_time_stamp: ",self.vo.expire_time_stamp)
  188. if self.vo.expire_time_stamp and self.vo.expire_time_stamp ~= 0 then
  189. self:CancelTimer()
  190. local free_loot_time = TimeUtil:getServerTime() + self.every_time -- 可以自由拾取的时间戳
  191. local cur_time = TimeUtil:getServerTime()
  192. local timer_func = function ()
  193. cur_time = TimeUtil:getServerTime()
  194. -- print("Saber:SceneDropObj [172] cur_time: ",cur_time)
  195. if cur_time >= self.vo.expire_time_stamp then -- 道具超时,销毁
  196. self:CancelTimer()
  197. if not self.can_pick and self.state ~= 9 then
  198. --消失
  199. self.step_start_time = Status.NowTime
  200. self.state = 9
  201. end
  202. elseif cur_time >= free_loot_time then
  203. --变成可拾取状态
  204. if not self.can_pick and self.state ~= 9 then
  205. -- self:CancelTimer()
  206. self.step_start_time = Status.NowTime
  207. self.state = 2
  208. end
  209. end
  210. end
  211. if not self.timer then
  212. self.timer = GlobalTimerQuest:AddPeriodQuest(timer_func, 1, -1)
  213. end
  214. else
  215. self:CancelTimer()
  216. end
  217. end
  218. self.create_time = Status.NowTime
  219. self.step_start_time = Status.NowTime
  220. if vo.no_anim then
  221. self:SetRealPos(vo.pos_x,vo.pos_y)
  222. self.state = 2
  223. else
  224. self:SetRealPos(vo.pos_x,vo.pos_y)
  225. self.state = 10
  226. self.animator:Play("drop_anim_1",-1,0.0)
  227. self.animator:Update(0)
  228. end
  229. self:SetAlpha(1)
  230. end
  231. self:SetItemScale(self.max_scale)
  232. self.effect_parent.gameObject:SetActive(false)
  233. --添加物品光效
  234. local onDelay = function ( )
  235. self.effect_parent.gameObject:SetActive(true)
  236. self:ClearShiquEffect()
  237. local effect_res = self:GetColorEffect()
  238. local gameObject = self.drop_mgr:GetObjFormPool(self,effect_res,effect_res)
  239. if gameObject then
  240. self.add_effect_type = 1
  241. local gameObject_transform = gameObject.transform
  242. gameObject_transform:SetParent(self.effect_parent)
  243. SetLocalPosition(gameObject_transform,0,0,0)
  244. SetLocalRotation(gameObject_transform)
  245. self.effect_gameObject = gameObject
  246. else
  247. self.add_effect_type = 2
  248. self.particle_id = ParticleManager:getInstance():AddTargetEffect( effect_res, self.compress_id, true, nil, nil, 7,nil,nil,1)
  249. end
  250. --播放声音
  251. if self.vo.drop_type ~= 3 then
  252. self:PlaySound("epicitem_drop")--Epicitem_drop
  253. end
  254. end
  255. self:CancelDelayTimer()
  256. -- 判断是否使用掉落物的光效特效
  257. if (vo.effect and vo.effect~="") or is_in_gboss_event then
  258. self.show_effect = true
  259. self.timer_id = setTimeout(onDelay, 0.4)
  260. end
  261. if self.vo.drop_type == 3 then
  262. self:PlaySound("gold_drop")
  263. end
  264. end
  265. function SceneDropObj:CancelDelayTimer( )
  266. if self.timer_id then
  267. GlobalTimerQuest:CancelQuest(self.timer_id)
  268. self.timer_id = nil
  269. end
  270. end
  271. function SceneDropObj:PlaySound(res)
  272. if not self:CanPlaySound() then
  273. return
  274. end
  275. if lua_viewM.is_lock_screen then
  276. return
  277. end
  278. if lua_soundM then
  279. lua_soundM:StopEffect(self, LuaSoundManager.SOUND_TYPE.DROP, self.sound_id)
  280. self.sound_id = lua_soundM:PlayEffect(self, res,false,LuaSoundManager.SOUND_TYPE.DROP)
  281. end
  282. end
  283. function SceneDropObj:CancelTimer( )
  284. if self.timer then
  285. GlobalTimerQuest:CancelQuest(self.timer)
  286. self.timer = nil
  287. end
  288. end
  289. --主动添加挂在自己身上的例子特效
  290. function SceneDropObj:AddParticle(id,particle_tranform)
  291. particle_tranform.parent = self.effect_parent
  292. SetLocalPosition(particle_tranform)
  293. SetLocalScale(particle_tranform)
  294. self.particle_list[id] = particle_tranform
  295. end
  296. --删除挂在自己身上的特效
  297. --is_acive = false 被动删除挂在自己身上的粒子特效 由特效播放完来调用
  298. --is_acive = true 主动删除挂在自己身上的特效 会通知particlemanager去删除 默认false
  299. function SceneDropObj:RemoveParticle(id,is_acive)
  300. self.particle_list[id] = nil
  301. if is_acive then
  302. ParticleManager:getInstance():DelEffect(id)
  303. end
  304. end
  305. --主动删除挂在自己身上的所有粒子特效 通常是角色死亡 移除角色之类的
  306. function SceneDropObj:RemoveAllParticle()
  307. for id,_ in pairs(self.particle_list) do
  308. ParticleManager:getInstance():DelEffect(id)
  309. end
  310. self.particle_list = {}
  311. end
  312. function SceneDropObj:Update(now_time, elapse_time)
  313. if self.state == 10 then
  314. self:DropFlyStep(now_time, elapse_time)
  315. elseif self.state == 2 then
  316. self:ExcuteStaticStep()
  317. elseif self.state == 3 then
  318. self:WaitForServerStep()
  319. elseif self.state == 4 then
  320. self:ScaleItemStep()
  321. elseif self.state == 9 then
  322. self:TransparentStep()
  323. end
  324. end
  325. function SceneDropObj:__delete()
  326. if self.pick_up_id then
  327. GlobalEventSystem:UnBind(self.pick_up_id)
  328. self.pick_up_id = nil
  329. end
  330. if self.dismiss_item_id then
  331. GlobalEventSystem:UnBind(self.dismiss_item_id)
  332. self.dismiss_item_id = nil
  333. end
  334. if self.fail_pick_up_id then
  335. GlobalEventSystem:UnBind(self.fail_pick_up_id)
  336. self.fail_pick_up_id = nil
  337. end
  338. if self.can_not_pick_up_id then
  339. GlobalEventSystem:UnBind(self.can_not_pick_up_id)
  340. self.can_not_pick_up_id = nil
  341. end
  342. if self.nameboard_index then
  343. self.nameboard_Manager:RemoveNameBoard(self.nameboard_index)
  344. self.nameboard_index = nil
  345. end
  346. if self.name_board then
  347. self.name_board:DeleteMe()
  348. self.name_board = nil
  349. end
  350. self:ClearShiquEffect()
  351. self:RemoveAllParticle()
  352. self:CancelTimer()
  353. self:CancelDelayTimer()
  354. lua_resM:clearReference(self.res_use_ref)
  355. lua_resM:clearReference(self)
  356. if self.drop_model_gameObject then
  357. destroy(self.drop_model_gameObject, true)
  358. self.drop_model_gameObject = false
  359. end
  360. if self.gameObject then
  361. destroy(self.gameObject, true)
  362. self.gameObject = nil
  363. end
  364. end
  365. function SceneDropObj:Show()
  366. return self.gameObject:SetActive(true)
  367. end
  368. function SceneDropObj:Hide()
  369. self.show_effect = false
  370. self.item_parent.localPosition = Vector3.zero
  371. if self.gameObject.activeSelf and self.vo.fake_pick then--如果是假掉落 要拾取到背包
  372. local type_id = GoodsModel:getInstance():GetMappingTypeId(self.vo.drop_type, self.vo.type_id)
  373. local goods_list = {type_id}
  374. MainUIModel:getInstance():PlayGoodsFlyList(goods_list)
  375. if not self.not_fly_float then
  376. local float_list = {{goods_type_id = type_id,num = self.vo.drop_num}}
  377. MainUIModel:getInstance():AddFloatInfo(float_list,true)
  378. end
  379. end
  380. return self.gameObject:SetActive(false)
  381. end
  382. function SceneDropObj:GetState()
  383. return self.state
  384. end
  385. function SceneDropObj:SetRealPos(posx, posy)
  386. if self.real_pos == nil then
  387. self.real_pos = co.TableXY(posx,posy)
  388. else
  389. self.real_pos.x = posx
  390. self.real_pos.y = posy
  391. end
  392. self:UpdateModelPos(self.real_pos.x,self.real_pos.y) --更新位置到模型
  393. end
  394. function SceneDropObj:GetRealPos()
  395. return self.real_pos.x, self.real_pos.y
  396. end
  397. function SceneDropObj:UpdateModelPos(posx, posy)
  398. if self.transform and not IsNull(self.transform) then
  399. local newHeight = self.scene:GetZoneHeight(posx/SceneObj.LogicRealRatio.x,posy/SceneObj.LogicRealRatio.y)
  400. --newHeight = newHeight + 0.7 --这里图片是中心点对其 所以要加上一半图片高度 图片是 74 像素
  401. SetGlobalPosition3D(self.transform,posx/MainCamera.PixelsToUnits, posy/MainCamera.PixelsToUnits,SceneObjHeight.Obj + newHeight)
  402. if self.name_board then
  403. self.name_board:UpdatePos(posx, posy,SceneObjHeight.Obj + newHeight - 0.8)
  404. end
  405. end
  406. end
  407. function SceneDropObj:SetItemScale(scale)
  408. if scale > self.max_scale then
  409. scale = self.max_scale
  410. end
  411. self.item_parent.localScale = Vector3.one * scale * SceneModelScale
  412. end
  413. --设置身体的位置 真实坐标不变
  414. function SceneDropObj:SetBodyXY(x,y)
  415. if self.item_parent.transform then
  416. SetLocalPosition(self.item_parent.transform, x / MainCamera.PixelsToUnits,y / MainCamera.PixelsToUnits,0)
  417. end
  418. if self.effect_parent.transform then
  419. SetLocalPosition(self.effect_parent.transform, x / MainCamera.PixelsToUnits,y / MainCamera.PixelsToUnits,0)
  420. end
  421. end
  422. function SceneDropObj:DropFlyStep()
  423. if self.state == 10 then
  424. local t = Status.NowTime - self.step_start_time
  425. if t > 0.5 then
  426. self.step_start_time = Status.NowTime
  427. self.state = 2
  428. end
  429. end
  430. end
  431. function SceneDropObj:ExcuteStaticStep()
  432. if self.state == 2 then
  433. if self.can_pick == true then
  434. self.state=4 --野外掉落,服务端先通知已经捡了,这里播放完抛物线后直接进入4,掉落消失
  435. return
  436. end
  437. local t = Status.NowTime - self.step_start_time
  438. local role_pos_x,role_pos_y
  439. local role_list = {} --守护或者人物都可以捡,所以用列表去判断
  440. local main_role = self.scene:GetMainRole()
  441. if not main_role then
  442. return
  443. end
  444. table.insert(role_list, main_role) --主角
  445. if not self.scene.only_main_role_pick and ItemUseModel:getInstance():HasWearEvil() and not self.guild_model:GetSepcialPickLogicOfGBoss() then
  446. if main_role and main_role.evil then
  447. table.insert(role_list, main_role.evil) --守护
  448. end
  449. end
  450. if #role_list > 0 then
  451. -- local role_pos_x,role_pos_y = role:GetRealPos()
  452. for i,role in ipairs(role_list) do
  453. role_pos_x,role_pos_y = role:GetRealPos()
  454. local distance = GameMath_GetDistance(role_pos_x, role_pos_y, self.real_pos.x, self.real_pos.y,false)
  455. if t > 0.05 and distance < 75*75 then
  456. if self.fake_pick then
  457. if distance < 1000 then
  458. self.state = 4
  459. GlobalEventSystem:DelayFire(EventName.EVIL_AUTO_PICK)
  460. return
  461. end
  462. end
  463. self.step_start_time = Status.NowTime
  464. --发送协议
  465. if self.vo and not self.fake_pick then
  466. local time = Status.NowTime-self.last_pick_time
  467. if (self.vo.role_id == nil or self.vo.role_id == 0 or self.vo.role_id == RoleManager.Instance:GetMainRoleId()
  468. or self:IsOutTime() ) and time>2 then
  469. --社团boss击杀后5分钟内执行特殊拾取逻辑(模拟采集逻辑)
  470. if self.guild_model:GetSepcialPickLogicOfGBoss() then
  471. if role:IsInState(PoseState.MOVE) or role:IsInState(PoseState.JUMP) or (not role.GetIsCollecting or role:GetIsCollecting()) then
  472. else
  473. self.guild_model:Fire(GuildModel.PICK_UP_BOSS_DROP_ITEM, GuildModel.GBossPickOpty.Start, self.vo.drop_id)
  474. --如果是守护,则去重新检测,是否有东西可以拾取
  475. break
  476. end
  477. else
  478. self.last_pick_time = Status.NowTime
  479. --如果处于一键拾取状态就不要协议拾取了
  480. --如果在拾取的过程中,切换了场景,那就不发协议了(守护有可能还在捡)
  481. if not self.scene:IsInPickAllDropState() and self.vo.map_id == self.scene_mgr:GetSceneId() and not self.scene_mgr:IsReqChangeScene() then
  482. GoodsModel:getInstance():Fire(GoodsModel.PICK_UP_SCENE_DROP_ITEM, self.vo.drop_id)
  483. end
  484. self.state = 3
  485. GlobalEventSystem:DelayFire(EventName.EVIL_AUTO_PICK)
  486. break
  487. end
  488. end
  489. end
  490. end
  491. end
  492. end
  493. end
  494. end
  495. --超过15秒, 其他人可拾取归属掉落
  496. function SceneDropObj:IsOutTime( )
  497. return Status.NowTime-self.create_time>=self.every_time
  498. end
  499. --等待服务器返回
  500. function SceneDropObj:WaitForServerStep()
  501. if self.state == 3 then
  502. local t = Status.NowTime - self.step_start_time
  503. --有可能没有收到协议,那么十秒后就自动消失
  504. if self.can_pick then
  505. self.step_start_time = Status.NowTime
  506. self.state = 4
  507. end
  508. if t > 200 then
  509. self.step_start_time = Status.NowTime
  510. self.state = 9
  511. end
  512. end
  513. end
  514. --飞到主角身上
  515. function SceneDropObj:ScaleItemStep()
  516. if self.state == 4 then
  517. local t = Status.NowTime - self.step_start_time
  518. local scale = self.max_scale - t / 0.4
  519. if scale < 0 then
  520. self.item_parent.gameObject:SetActive(false)
  521. self:ClearShiquEffect()
  522. self:ShowDropTip()
  523. self.step_start_time = Status.NowTime
  524. self.state = 7
  525. end
  526. --self:SetItemScale(scale)
  527. end
  528. end
  529. --主角身上
  530. function SceneDropObj:GetDropId()
  531. return self.drop_id
  532. end
  533. --主角身上
  534. function SceneDropObj:CanPlaySound()
  535. return not self.no_anim
  536. end
  537. function SceneDropObj:IsFinishState()
  538. return self.state == 7
  539. end
  540. function SceneDropObj:ReleaseObj()
  541. self:Hide()
  542. self:CancelTimer()
  543. self:CancelDelayTimer()
  544. self.last_pick_time = 0
  545. self.no_anim = false
  546. self.can_not_pick = false
  547. self:ClearShiquEffect()
  548. self.item_parent.gameObject:SetActive(true)
  549. self.icon_render.sprite = nil
  550. if self.nameboard_index then
  551. self.nameboard_Manager:RemoveNameBoard(self.nameboard_index)
  552. self.nameboard_index = nil
  553. end
  554. if self.name_board then
  555. self.name_board:DeleteMe()
  556. self.name_board = nil
  557. end
  558. lua_resM:clearReference(self.res_use_ref)
  559. end
  560. function SceneDropObj:ClearShiquEffect( )
  561. local effect_res = self:GetColorEffect()
  562. if self.particle_id then
  563. ParticleManager:getInstance():DelEffectByResName(effect_res, self.compress_id)
  564. self.particle_id = nil
  565. end
  566. if self.effect_gameObject and self.vo then
  567. self.drop_mgr:AddObjToPool(self,effect_res,effect_res,self.effect_gameObject)
  568. end
  569. self.effect_gameObject = false
  570. self.add_effect_type = 0
  571. end
  572. function SceneDropObj:ResetObj()
  573. self:Show()
  574. end
  575. --state为2才能拾取,其他状态要么已拾取,要么还没播放抛物线
  576. function SceneDropObj:IsCanPickUp()
  577. if self.vo then
  578. return (self.vo.role_id == 0 or self.vo.role_id == RoleManager.Instance:GetMainRoleId()
  579. or self:IsOutTime() ) and (self.state==2 or self.state == 10) and not self.can_not_pick
  580. end
  581. return false
  582. end
  583. --是否为自己的掉落物
  584. function SceneDropObj:IsSelfDrop()
  585. if self.vo then
  586. return self.vo.role_id == RoleManager.Instance:GetMainRoleId()
  587. end
  588. return false
  589. end
  590. --正在被拾取中
  591. function SceneDropObj:IsPicking( )
  592. return self.can_pick
  593. end
  594. --飞到主角身上
  595. function SceneDropObj:TransparentStep()
  596. if self.state == 9 then
  597. local t = Status.NowTime - self.step_start_time
  598. local alpha = 1 - t / 1
  599. if alpha < 0 then
  600. alpha = 0
  601. self.state = 7
  602. end
  603. self:SetAlpha(alpha)
  604. end
  605. end
  606. function SceneDropObj:SetAlpha(alpha)
  607. if self.icon_render then
  608. self.icon_render.color = Color(1,1,1,alpha)
  609. end
  610. end
  611. function SceneDropObj:GetPickItemTip( )
  612. local str = ""
  613. if self.vo and self.item_name then
  614. str = "获得 "..self.item_name .." x " .. self.vo.drop_num
  615. end
  616. return str
  617. end
  618. function SceneDropObj:ShowDropTip( )
  619. -- local tip = self:GetPickItemTip()
  620. -- if tip ~= "" then
  621. -- Message.show(tip)
  622. -- end
  623. if self.vo and self.item_name then
  624. local goods_id = 0
  625. local drop_num = self.vo.drop_num
  626. if self.vo.drop_type == 0 then --物品
  627. goods_id = self.vo.type_id
  628. elseif self.vo.drop_type == 3 then --金币
  629. goods_id = GoodsModel:getInstance():GetMappingTypeId(self.vo.drop_type)
  630. MainUIModel:getInstance():PlayGoodsFlyList({goods_id})
  631. end
  632. end
  633. end
  634. function SceneDropObj:CancelGuildBossPickDelayId( )
  635. if self.gboss_pickup_delay_id then
  636. TimerQuest.CancelQuest(GlobalTimerQuest,self.gboss_pickup_delay_id)
  637. self.gboss_pickup_delay_id = nil
  638. end
  639. end
  640. function SceneDropObj:GetColorEffect()
  641. if not self.goods_basic then return "" end
  642. local color = self.goods_basic.color
  643. local effect_res = ""
  644. if color == 5 then
  645. effect_res = "droppillar_1"
  646. elseif color == 4 then
  647. effect_res = "droppillar_2"
  648. elseif color == 3 then
  649. effect_res = "droppillar_3"
  650. end
  651. return effect_res
  652. end