local UIBattleCombo = UIViewClass() local PlayComboAimMinTime = 0.2 local function GetComboTypeByCount(count) --根据连击数量显示对应资源 local comboType = 0 if count >=1000 then comboType = 5 elseif count >=500 then comboType = 4 elseif count >=300 then comboType = 3 elseif count >=150 then comboType = 2 elseif count >= 50 then comboType = 1 end return comboType end function UIBattleCombo:OnCreated() UIUtils.SetLocalizationImage(self.img_KillNum, "3v3_msz_zhan.png") self.img_KillNum:SetNativeSize() self.img_Lv:SetState(0) self.img_Combo:SetState(0) self.img_Kill:SetState(0) end function UIBattleCombo:OnOpened(content) if content.isShowComboType == LuaConst.ComboType.Default then self:RegistSystemEvent(EventID.Level_UpdateComboNum, self.UpdateComboNum) -- 连击 self:RegistSystemEvent(EventID.Level_UpdateKillNum, self.UpdateKillNum) -- “X破” - 通用击杀数量,小兵、boss、武将等都计数 elseif content.isShowComboType == LuaConst.ComboType.IsKillHero then self:RegistSystemEvent(EventID.Level_UpdateKillHeroNum, self.UpdateKillHeroNum) -- “X斩” - 专指击杀了武将 elseif content.isShowComboType == LuaConst.ComboType.IsKillHeroAndAssist then self:RegistSystemEvent(EventID.Level_UpdateKillHeroNum, self.UpdateKillHeroNum) -- “X斩”+ "X助" - 专指击杀了武将 self:RegistSystemEvent(EventID.Level_HeroDead, self.UpdateAssistNum) end self.ComboType = 0 self.PlayComboAimTimestamp = UTL.Time.GetServerTimestamp() self:UpdateKillNum(0) self:UpdateKillHeroNum(LogicUpdateManager._curEntity,0) self:UpdateComboNum(0) end function UIBattleCombo:OnUpdateFun(deltaTime, timeSineUpdate) -- X斩特效 self.effect_HeroKill:PlayUIEffect() CTL.Sound.PlayKillSound(self.killHeroCount) self:StopRepeatFunc(self.OnUpdateFun) end -- 击杀数量 “X破” function UIBattleCombo:UpdateKillNum(count) if count>0 then if self.showKill == nil or self.showKill == false then UIUtils.SetActive(self.KillBg.gameObject, true) self.showKill = true end if self.ID_BattleCombo then self:PlayUIAnimation(self.ID_BattleCombo) else self.ID_BattleCombo = self:PlayUIAnimation("BattleCombo") end UIUtils.SetLabel(self.lab_Kill,count) else self.showKill = false UIUtils.SetActive(self.KillBg.gameObject, false) end end -- 击杀数量 “X斩” -- 使用场景:世界boss、军团战 function UIBattleCombo:UpdateKillHeroNum(killer, count, relaxKillPlayerIDList) if BattleDataGetter.IsCurEntity(killer) then self:StopRepeatFunc(self.OnUpdateFun) if count and count > 0 then if self.showKill == nil or self.showKill == false then UIUtils.SetActive(self.KillNumBg.gameObject, true) self.showKill = true end if self.Anim_KillNum then self:PlayUIAnimation(self.Anim_KillNum) else self.Anim_KillNum = self:PlayUIAnimation("KillNum") end self.killHeroCount = count UIUtils.SetLabel(self.lab_KillNum, count) self:StartRepeatFunc(self.OnUpdateFun, 0.1) else self.showKill = false UIUtils.SetActive(self.KillNumBg.gameObject, false) end else if relaxKillPlayerIDList then local myPlayerID = BattleDataGetter.GetCurPlayerID() for _,playerID in ipairs(relaxKillPlayerIDList) do if playerID == myPlayerID then local killNum = BattleDataGetter.GetGuildWar_HeroRelaxKillNum(playerID) self:UpdateKillHeroNum(LogicUpdateManager._curEntity, killNum) break end end end end end -- 连击数量 function UIBattleCombo:UpdateComboNum(count) if BattleDataGetter.IsInReconnectFastPlay() then return end local curTimestamp = UTL.Time.GetServerTimestamp() local showAim = curTimestamp - self.PlayComboAimTimestamp > PlayComboAimMinTime if showAim then self.PlayComboAimTimestamp = curTimestamp end --根据连击数量显示对应资源 local comboType = GetComboTypeByCount(count) if comboType > 0 then if self.ComboType == comboType then if self.ID_KillLvShow2 then self:StopUIAnimation(self.ID_KillLvShow2, true) end if self.ID_KillLvShow1 then if showAim then self:PlayUIAnimation(self.ID_KillLvShow1) end else self.ID_KillLvShow1 = self:PlayUIAnimation("KillLvShow1") end else self.LvBg:SetState(comboType-1) self.img_Lv:SetState(comboType-1) self.img_ComboBg:SetState(comboType-1) self.img_Combo:SetState(comboType-1) self.img_BgKill:SetState(comboType-1) self.img_Kill:SetState(comboType-1) self.combo_txt_state:SetState(comboType-1) self.kill_txt_state:SetState(comboType-1) if self.ID_KillLvShow2 then if showAim then self:PlayUIAnimation(self.ID_KillLvShow2) end else self.ID_KillLvShow2 = self:PlayUIAnimation("KillLvShow2") end self.ComboType = comboType end end if count > 0 then self.txt_Combo.text = count if self.ID_BattleHit then if showAim then self:PlayUIAnimation(self.ID_BattleHit) end else self.ID_BattleHit = self:PlayUIAnimation("BattleHit") end else self.ComboType = 0 UIUtils.SetLabel(self.txt_Combo,"") end end function UIBattleCombo:UpdateAssistNum(killer, deadEntity, assistPlayerIDList, assistHeroEntityIDList, relaxAssistPlayerIDList) local isAssist = false if not killer._logicInitData.IsPlayerSelf then local myPlayerID = BattleDataGetter.GetCurPlayerID() for i,v in ipairs(relaxAssistPlayerIDList) do if v == myPlayerID then isAssist = true break end end end if isAssist then -- k:击杀数 d:死亡数 a:助攻数 local assistNum = BattleDataGetter.GetGuildWar_MySelfHeroRelaxAssist() if assistNum then self:ShowSelfAssist(assistNum) end end end function UIBattleCombo:ShowSelfAssist(value) self.group_Support.gameObject:SetActive(true) self.txt_Num.text = value self:StartRepeatFunc(self.CloseAssist, 5, 1) end function UIBattleCombo:CloseAssist() self.group_Support.gameObject:SetActive(false) end return UIBattleCombo