local EventSystem = require('Event/EventSystem') local Base = require("Battle/Logic/Level/LevelFunction/SyncGuildWarBaseLevelFunction") local SyncGuildWarMapResourcesLevelFunction = class("SyncGuildWarMapResourcesLevelFunction",Base) local EStatisticType = LuaConst.EStatisticType local DROP_PLAYER_RESOURCE_BUFF = 100106 function SyncGuildWarMapResourcesLevelFunction:GetExpClass() return require "Battle/Expression/ExpLevel/ExpLevelFunction/ExpSyncGuildWarMapResourcesLevelFunction" end function SyncGuildWarMapResourcesLevelFunction:GetDropResourceInfoList() return self.dropResInfoList end function SyncGuildWarMapResourcesLevelFunction:GetMaxDropResBoxOnceCount() return self.maxDropResBoxOnceCount end function SyncGuildWarMapResourcesLevelFunction:GetDropResBoxStride() return self.dropResBoxStride end function SyncGuildWarMapResourcesLevelFunction:InitLevel() Base.InitLevel(self) -- local regularResConst = DataSheetManager.ConstData:GetDataByID("FrameIncreaseGuildResources") -- if regularResConst then -- self.regularResAddFrameInterval = regularResConst.IntValue -- self.regularResAddAmount = math.floor(FP.tonumberV1(regularResConst.FloatValue)) -- else -- logging.error(LTAG.ERROR, "HYW : 策划注意!! ConstData表里没有配置FrameIncreaseGuildResources,军团战资源战场无法运行!!") -- end self.maxDropResBoxOnceCount = DataSheetManager.ConstData:GetDataByID("GuildWarMaxResDropCountOnce").IntValue self.dropResBoxStride = DataSheetManager.ConstData:GetDataByID("GuildWarResDropStride").FloatValue self.dropResInfoList = {} local maxAmountList = DataSheetManager.ConstData:GetDataByID("GuildWarResDropBox").IntListValue local monsterIDList = DataSheetManager.ConstData:GetDataByID("GuildWarResDropBoxId").IntListValue for i,_maxAmount in ipairs(maxAmountList) do self.dropResInfoList[i] = {maxAmount = _maxAmount, monsterID = monsterIDList[i]} end table.sort(self.dropResInfoList, function(a, b) return a.maxAmount > b.maxAmount end) self.frameElaSinceLastRegularResourceAdd = 0 self.playerResourceAmountDic = {} -- key是playerID, value是玩家资源数(玩家资源数:可掉落,可上交) end function SyncGuildWarMapResourcesLevelFunction:OnCreatePlayer(playerID) Base.OnCreatePlayer(self, playerID) self.playerResourceAmountDic[playerID] = 0 end function SyncGuildWarMapResourcesLevelFunction:GetReviveTime() return 2000 end function SyncGuildWarMapResourcesLevelFunction:IsEntityResAmountReachLimit(entity, withTips) local resAmount = self:GetResourceAmountOfPlayer(entity:GetPlayerID()) local value = self:IsResAmountReachLimit(resAmount) if withTips and value then ExpLevelManager.ShowTips(entity, "IDS_GuildWar_CannotCarryMoreResources") EventSystem.Dispatch(EventID.UI_GuildWarTips_Help,"IDS_GuildWar_BattleHelpText9") end return value end function SyncGuildWarMapResourcesLevelFunction:IsResAmountReachLimit(resAmount) return resAmount >= LuaConst.GuildWarMaxPlayerResource end --返回number function SyncGuildWarMapResourcesLevelFunction:GetResourceAmountOfPlayer(playerID) return self.playerResourceAmountDic[playerID] or 0 end function SyncGuildWarMapResourcesLevelFunction:GetHandInResourceAmountOfPlayer(playerID) local amount = 0 if self.PlayerStatisticDic[playerID] then amount = self.PlayerStatisticDic[playerID][EStatisticType.PlayerContributeResourceCount] end return amount end -- 掉落玩家的 delta是变化量,为负数 function SyncGuildWarMapResourcesLevelFunction:DropResourceAmountOfPlayer(entity, playerID, delta) self:ChangeResourceAmountOfPlayer(entity, playerID, delta) self.exp:OnDropResourceAmountOfPlayer(entity, playerID, delta) end function SyncGuildWarMapResourcesLevelFunction:ChangeResourceAmountOfPlayer(entity, playerID, delta, eventEntityType) self.playerResourceAmountDic[playerID] = self.playerResourceAmountDic[playerID] + delta self.exp:OnPlayerResourceAmountChange(entity, delta, eventEntityType) end function SyncGuildWarMapResourcesLevelFunction:OnHeroBorn(entity) Base.OnHeroBorn(self, entity) --添加10秒无敌buff local buffCtrl = RuntimeDataManager.New_BuffCtrl() buffCtrl.ForceDuration:Reset(10) --技能全程buff强制设置时间为无限长 SystemManager.AddBuff(entity, 500001, entity, nil, buffCtrl) SystemManager.AddBuff(entity, DROP_PLAYER_RESOURCE_BUFF, entity) end function SyncGuildWarMapResourcesLevelFunction:HandInResourceOfEntity(entity) local playerID = entity:GetPlayerID() local amount = self.playerResourceAmountDic[playerID] if amount > 0 then self:ChangeResourceAmountOfPlayer(entity, playerID, -amount) self:ChangeResourceAmountOfCamp(entity:GetCampID(), amount, entity) self.exp:OnHandInResource(entity, amount) end end -- function SyncGuildWarMapResourcesLevelFunction:OnUpdate() -- Base.OnUpdate(self) -- self.frameElaSinceLastRegularResourceAdd = self.frameElaSinceLastRegularResourceAdd + 1 -- if self.frameElaSinceLastRegularResourceAdd >= self.regularResAddFrameInterval then -- self.frameElaSinceLastRegularResourceAdd = self.frameElaSinceLastRegularResourceAdd - self.regularResAddFrameInterval -- self:ChangeResourceAmountOfCamp(1, self.regularResAddAmount) -- self:ChangeResourceAmountOfCamp(2, self.regularResAddAmount) -- end -- end function SyncGuildWarMapResourcesLevelFunction:OnHpChange(entity,caster,delta,op) -- 不使用base.OnHpChange ;不要统计城墙掉血量 if op == "sub" and delta < FP.Const.Zero then -- 先不考虑加血的情况 ,如果有 ,需要改下面代码 if entity:IsBoss() or entity:IsHero() or entity:IsElite()then local dmgDealer = caster:GetOriginEntity() if dmgDealer:IsHero() then self:RefreshDamageTimestampRecord(entity.EntityID, dmgDealer) end end end self.exp:OnHpChange(entity, caster, delta, op) end -- 获取玩家的战斗信息(客户端自己用) function SyncGuildWarMapResourcesLevelFunction:GetPlayerBattleInfo(playerID) local statisticInfo = self.PlayerStatisticDic[playerID] local killNum = statisticInfo[EStatisticType.RelaxHeroKillNum] -- 击杀数 local continuousKilling = self:GetPlayerComboKillNum(playerID) -- 连杀数 local assistNum = statisticInfo[EStatisticType.AssistHeroKillNum] -- 助攻数 local seriousInjury = statisticInfo[EStatisticType.DeadCount] -- 重伤数 (即玩家死亡主将数量) local occupycamp = statisticInfo[EStatisticType.CampsiteOccupyCount] -- 占领营地 local killBoss = statisticInfo[EStatisticType.BossKillNum] -- 击杀boss local wallDemage = 0 -- 城墙伤害 (向下取整) local handInResource = self:GetHandInResourceAmountOfPlayer(playerID) --上交物资 return killNum, continuousKilling, assistNum, seriousInjury, occupycamp, killBoss, wallDemage, handInResource end return SyncGuildWarMapResourcesLevelFunction