diff --git a/Assets/ManagedResources/~Lua/Modules/Fight/FightPointPassMainPanel.lua b/Assets/ManagedResources/~Lua/Modules/Fight/FightPointPassMainPanel.lua index 3af421d403..31f7f6c5b1 100644 --- a/Assets/ManagedResources/~Lua/Modules/Fight/FightPointPassMainPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Fight/FightPointPassMainPanel.lua @@ -57,9 +57,8 @@ local fightAnim = { function FightPointPassMainPanel:InitComponent() invadeMonster:InitComponent(self.gameObject, this) - fightMap:InitComponent(self.gameObject, this) isAnimActive = false - + fightMap:InitComponent(self.gameObject, this) -- 通关豪礼入口 this.pgBtn=Util.GetGameObject(self.gameObject,"LeftUp/box/passGift") this.pgFrame=Util.GetGameObject(this.pgBtn,"frame"):GetComponent("Image") @@ -300,13 +299,12 @@ function this.SetInitAnim() -- count = 1 -- this.GuideEffectGo:SetActive(false) -- this.GuideJumpEffectGo:SetActive(false) - - fightMap.StopAction() -- this.swicthPanel:SetActive(true) -- this.SetAnimPanelState(true) -- fightSkeleton.AnimationState:SetAnimation(0, fightAnim[2], false) -- isAnimActive = true -- chooseAnim = FightPointPassManager.IsFightBoss() and 4 or 3 + fightMap.StopAction() UIManager.OpenPanel(UIName.FightLevelSwitchPopup, true) end @@ -394,6 +392,7 @@ function FightPointPassMainPanel:OnShow() isCounting = false -- 加载地图数据 + fightMap:InitComponent(self.gameObject, this) fightMap:Init() FightPointPassManager.isBattleBack = false @@ -403,7 +402,7 @@ function FightPointPassMainPanel:OnShow() if callBack then callBack() - callBack = nil + callBack = nils end end this.BtnsIsOpen() @@ -616,7 +615,7 @@ function FightPointPassMainPanel:OnClose() PlayerManager.StopBattleUpLvTipTime() hasLoad = false invadeMonster:OnClose() - fightMap:Dispose() + fightMap:OnClose() if this.animTimer then this.animTimer:Stop() diff --git a/Assets/ManagedResources/~Lua/Modules/Fight/View/FightPointMapView.lua b/Assets/ManagedResources/~Lua/Modules/Fight/View/FightPointMapView.lua index e9386aa5c2..93642791ab 100644 --- a/Assets/ManagedResources/~Lua/Modules/Fight/View/FightPointMapView.lua +++ b/Assets/ManagedResources/~Lua/Modules/Fight/View/FightPointMapView.lua @@ -59,10 +59,6 @@ local startUV = { [5004] = {u = 15, v = 10}, } - - - -local isPanelClose = false --是否关闭界面 -- 允许出现的事件点的图标数量 local iconNum = 9 -- 地图图标的上限值 @@ -73,12 +69,11 @@ local effectPath = "c_xy_0012_skeff_slidesk_ballistic" -- 当前关卡地图编号 local m_curMapId = 1011 -local m_orginLayer +local m_orginLayer = 0 local m_parent - +this.isClose = false --root FightPointPassMainPanel.gameObject FightPointPassMainPanel脚本 function this:InitComponent(root, parent) - m_orginLayer = 0 m_parent = parent -- 地图点击拖动 this.root = root @@ -97,8 +92,6 @@ function this:InitComponent(root, parent) end end - - function this:AddListener() end @@ -108,7 +101,8 @@ function this:RemoveListener() end function this:Init() - isPanelClose = false + this.isClose = false + this.isCanUseIconList = 0 -- 初始化加载地图块数据 this:LoadMapData() -- 加载一个小人 @@ -197,7 +191,7 @@ end function this.LoadMapIcon() this.iconList = {} this.selectIconList = {} - FightPointPassManager.isBeginFight = false + --FightPointPassManager.isBeginFight = false for i = 1, iconNum do this.LoadPointIcon(false) end @@ -218,8 +212,10 @@ end this.isCanUseIconList = 0 function this.RequestIconList() + LogGreen(" this.isCanUseIconList:".. tostring(this.isCanUseIconList)) if this.isCanUseIconList == 0 then this.isCanUseIconList = 1 + LogGreen(" this.iconList:".. tostring(this.iconList)) return this.iconList end return nil @@ -233,7 +229,13 @@ function this.AsideTriggerJudge(data,isSelf,_userData) --LogGreen("data:"..tostring(data).." pos:"..tostring(Map_UV2Pos(data.u - 1, data.v))) local isGetIconList = false local iconList = this.iconList - coroutine.start(function() + if not this.threads then + this.threads = {} + end + if this.isClose then + return + end + this.threads[_userData.userId] = coroutine.start(function() while(not isGetIconList) do --LogGreen("没有得到访问权") iconList = this.RequestIconList() @@ -264,14 +266,16 @@ function this.AsideTriggerJudge(data,isSelf,_userData) this.AddSelectIconList(pos,_userData.userId) --LogGreen("发送了消息") Game.GlobalEvent:DispatchEvent(GameEvent.GuaJi.getEvent,{goData = _userData, event = iconList[pos], pos = pos}) + coroutine.stop(this.threads[_userData.userId]) this.ReleaseIconList() return elseif FightPointPassManager.talkingTime == 0 or (GetTimeStamp() - FightPointPassManager.talkingTime >= 60) then - if isSelf and this.playerViews and LengthOfTable(this.playerViews) > 2 then + if isSelf and this.playerViews and LengthOfTable(this.playerViews) > 1 then for k,v in pairs(this.playerViews) do - if not v.isSelf and Map_UV2Pos(v.roleCurPos.u, v.roleCurPos.v) == pos and (v.state == 0) then + if not v.isSelf and Map_UV2Pos(v.roleCurPos.u, v.roleCurPos.v) == pos and v.state == 0 then FightPointPassManager.talkingTime = GetTimeStamp() Game.GlobalEvent:DispatchEvent(GameEvent.GuaJi.getEvent,{goData = _userData,event = v,pos = pos}) + coroutine.stop(this.threads[_userData.userId]) this.ReleaseIconList() return end @@ -279,6 +283,7 @@ function this.AsideTriggerJudge(data,isSelf,_userData) end end end + coroutine.stop(this.threads[_userData.userId]) this.ReleaseIconList() end) end @@ -420,6 +425,24 @@ function this.OnClickTile(u, v) --Log(string.format("转换后的屏幕坐标是(%s, %s)", v2.x, v2.y)) end + +-- 停止一切该死的行为 +function this.StopAction() + for k,v in pairs(this.playerViews) do + v:StopAction() + end + this.moneyEffect.gameObject:SetActive(false) + if this.threads then + for k,v in pairs(this.threads) do + coroutine.stop(v) + this.threads[k] = nil + end + end + this.threads = {} + this.ReleaseIconList() + this.isClose = true +end + --- ====================================================================== function this.OnGameOver() for i, v in pairs(this.playerViews) do @@ -437,7 +460,6 @@ function this.OnGameOver() if this.mapRoot then -- 避免不是主动退出 --Log("注销一次地图资源") poolManager:UnLoadAsset(mapCtrl, this.mapRoot, PoolManager.AssetType.GameObject) - poolManager:UnLoadAsset(roleRootPath, this.role, PoolManager.AssetType.GameObject) poolManager:UnLoadAsset(effectPath, this.moneyEffect, PoolManager.AssetType.GameObject) UIManager.camera.clearFlags = CameraClearFlags.Skybox TileMapView.Exit() @@ -446,20 +468,23 @@ function this.OnGameOver() this.mapRoot = nil this.moneyEffect = nil - end function this:OnClose() - -end - -function this:Dispose() - isPanelClose = true - FightPointPassManager.enterFightBattle = false if this.startTimer then this.startTimer:Stop() end this.startTimer = nil + this.StopAction() + this.OnGameOver() +end + +function this:Dispose() + if this.startTimer then + this.startTimer:Stop() + end + this.startTimer = nil + this.StopAction() this.OnGameOver() end diff --git a/Assets/ManagedResources/~Lua/View/SingleFightPlayerView.lua b/Assets/ManagedResources/~Lua/View/SingleFightPlayerView.lua index bda1255fab..5dfad71e70 100644 --- a/Assets/ManagedResources/~Lua/View/SingleFightPlayerView.lua +++ b/Assets/ManagedResources/~Lua/View/SingleFightPlayerView.lua @@ -23,7 +23,7 @@ function SingleFightPlayerView:ReciveData(data) self.state = 1 self:RoleWalkEnd(data) elseif (data.event and data.event.userId and data.event.userId == self.userId) then - self.eventPointPos = data.event + self.eventPointPos = data.goData self.state = 1 self:RoleWalkEnd(data) end @@ -230,7 +230,12 @@ end -- 随机一个位置给大爷走走 function SingleFightPlayerView:SetRoleHitTarget() - coroutine.start(function() + if self.thread then + coroutine.stop(self.thread) + self.thread=nil + end + self.thread = coroutine.start(function() + LogGreen("随机一个位置给大爷走走") --local eventPoint = self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf) --self.parent.AsideTriggerJudge(self.roleCurPos,self.isSelf) local pos @@ -247,7 +252,9 @@ end -- 选择一个目标位置, 就近原则 function SingleFightPlayerView:SelectTargetPos() local iconList = self.parent.RequestIconList() + LogGreen("iconList:"..tostring(iconList)) if iconList and LengthOfTable(iconList) > 0 then + LogGreen("iconList:"..tostring(LengthOfTable(iconList))) local selectIconList = {} local minDis = 999 for i, v in pairs(iconList) do @@ -389,14 +396,10 @@ end function SingleFightPlayerView:RoleWalkEnd(eventPoint) self.callList:Clear() self:PlayerIdle() - if eventPoint then - local iconType = eventPoint.event.iconId or -1 + if self.eventPointPos then + local iconType = self.eventPointPos.iconId or -1 if iconType == -1 then - if self.isSelf then - self.selectPointPos = eventPoint.pos - else - self.selectPointPos = Map_UV2Pos(eventPoint.goData.roleCurPos.u,eventPoint.goData.roleCurPos.v) - end + self.selectPointPos = Map_UV2Pos(self.eventPointPos.roleCurPos.u,self.eventPointPos.roleCurPos.v) else self.selectPointPos = eventPoint.pos end @@ -489,8 +492,7 @@ end -- 设置遇到图标时的表现 function SingleFightPlayerView:SetIconShow(_eventpoint) - local eventpoint = _eventpoint.event - local iconType = eventpoint.iconId or -1 + local iconType = self.eventPointPos.iconId or -1 LogGreen("iconType:"..iconType) local index = (self.eventpoint == 4 or self.eventpoint == 1) and 4 or 3 if iconType == -1 then @@ -547,9 +549,9 @@ function SingleFightPlayerView:SetIconShow(_eventpoint) -- 设置老头 local oldManAngle = Vector3.New(0, m_oldManTextPos[index].angleOffset, 0) - eventpoint:SetDialogueDir(m_oldManTextPos[index].pos, oldManAngle) - eventpoint:ShowDialogue(true) - eventpoint:SetDialogueStr(strList1[num]) + self.eventPointPos:SetDialogueDir(m_oldManTextPos[index].pos, oldManAngle) + self.eventPointPos:ShowDialogue(true) + self.eventPointPos:SetDialogueStr(strList1[num]) end self:NotBattleShow() else -- 战斗 @@ -575,18 +577,13 @@ function SingleFightPlayerView:SetEffect(pos) local tartPos = boxEffectPos[boxState] LogGreen("boxState:" ..boxState) - LogGreen("isBeginFight:"..tostring(FightPointPassManager.isBeginFight)) if self.parent.moneyEffect then self.parent.moneyEffect:GetComponent("RectTransform").anchoredPosition = SetObjPosByUV(pos) Util.ClearTrailRender(self.parent.moneyEffect) self:SetBoxEffect(false, Vector3.zero) - if not FightPointPassManager.isBeginFight then self.parent.moneyEffect:SetActive(true) - end self.parent.moneyEffect:GetComponent("RectTransform"):DOAnchorPos(Vector2.New(tartPos.x + 88, tartPos.y + 359), 0.6, false):OnComplete(function () - if not FightPointPassManager.isBeginFight then self:SetBoxEffect(true, boxState) - end end) end SoundManager.PlaySound(SoundConfig.Sound_FightArea_Gold) @@ -669,11 +666,7 @@ function SingleFightPlayerView:private_BloodBlood(objPos, index, iconType, isMon go:GetComponent("RectTransform").anchoredPosition3D = Vector3.New(v2.x, v2.y, 0) + Vector3.New(0, 120, 0) Util.GetGameObject(go, "anim/Image"):SetActive(false) Util.GetGameObject(go, "anim/anim"):GetComponent("Text").text = iconAction.DecodeHurt(hurtNum, isCritical, showType) - if not FightPointPassManager.isBeginFight then - go:SetActive(true) - else - go:SetActive(false) - end + go:SetActive(true) self.hurtNumTimer = nil self.hurtNumTimer = Timer.New(function() @@ -721,11 +714,7 @@ function SingleFightPlayerView:pravite_PlayHitEffect(pos) --v2 = v2 / math.min(Screen.width/1080, Screen.height/1920) LogGreen("self.hitEffect:") self.hitEffect.transform.localPosition = SetObjPosByUV(pos) - if not FightPointPassManager.isBeginFight then - self.hitEffect:SetActive(true) - else - self.hitEffect:SetActive(false) - end + self.hitEffect:SetActive(true) end @@ -761,12 +750,12 @@ function SingleFightPlayerView:EnterBattle() self:SetBattleState(true) end - -function SingleFightPlayerView:OnClose() - self.buffTipList = {} - if self.playerLiveView then - self.playerLiveView:OnClose() - self.playerLiveView = nil +function SingleFightPlayerView:StopAction() + self.callList:Clear() + self:SetWalkDir(WALK_DIR.IDLE_FRONT) + self.hitEffect:SetActive(false) + for i = 1, #self.hurtNum do + self.hurtNum[i].gameObject:SetActive(false) end if self.targetTimer then self.targetTimer:Stop() @@ -784,6 +773,22 @@ function SingleFightPlayerView:OnClose() self.battleTimer:Stop() self.battleTimer = nil end + + LogGreen("停止协程") + if self.thread then + coroutine.stop(self.thread) + self.thread = nil + end +end + +function SingleFightPlayerView:OnClose() + self:StopAction() + self.buffTipList = {} + if self.playerLiveView then + self.playerLiveView:OnClose() + self.playerLiveView = nil + end + --角色当前方向 self.curDir = nil --当前选中点的位置