------------------------------------------------ -- 作者: 王圣 -- 日期: 2019-09-23 -- 文件: BaJiJuDianData.lua -- 模块: BaJiJuDianData -- 描述: 八级阵图据点数据 ------------------------------------------------ -- 引用 local BaJiJuDianData = { -- 配置表ID CfgId = 0, -- 出生服务器ID BornServerId = 0, -- 对应的副本ID CopyId = 0, -- 占领的服务器ID OwnerServerId = 0, -- 服务器名字 Name = nil, -- 据点名字 JuDianName = nil, -- 当前据点状态 JuDianState = nil, -- 据点boss总血量 TBlood = 0, -- 当前boss血量 CurBlood = 0, -- bossID BossId = 0, -- 可占攻打点列表连线 ListCanFight = List:New(), -- 关联据点 ListRelationJuDian = List:New(), -- 各个服务器所占比例 DicPercent = Dictionary:New(), -- 各个服务器伤害比例 DicDamagePercent = Dictionary:New(), -- 奖励道具字符串 RewardStr = nil, ColorId = 0 } function BaJiJuDianData:New(cfgId) local _m = Utils.DeepCopy(self) _m.CfgId = cfgId return _m end function BaJiJuDianData:Parase(msg) self.CfgId = msg.cityID self.BornServerId = msg.birthSid self.CopyId = msg.modelID self.OwnerServerId = msg.curSid self.ColorId = msg.colorCamp local sdata = GameCenter.ServerListSystem:FindServer(msg.curSid) if sdata ~= nil then self.Name = UIUtils.CSFormat("S{0}_{1}", sdata.ShowServerId, sdata.Name) end if self.OwnerServerId == 0 then -- 表示当前据点没有被占领 self.JuDianState = BaJiJuDianState.NoneServer self.Name = DataConfig.DataMessageString.Get("Fighting") elseif self.OwnerServerId == GameCenter.BaJiZhenSystem.OwnServerId then -- 表示被本服占领 self.JuDianState = BaJiJuDianState.LocalServer else -- 表示被其他服务器占领 self.JuDianState = BaJiJuDianState.OtherServer end self.CurBlood = msg.curHp self.TBlood = msg.maxHp self.BossId = msg.bossID for i = 1, BaJiColor.Count do -- 设置人数 self.DicPercent[i] = 0 -- 设置伤害 self.DicDamagePercent[i] = 0 end if msg.cityBattleInfoList ~= nil then for i = 1, #msg.cityBattleInfoList do if msg.cityBattleInfoList[i].sid == GameCenter.BaJiZhenSystem.OwnServerId then GameCenter.BaJiZhenSystem.DicColorServer[msg.cityBattleInfoList[i].colorCamp] = DataConfig.DataMessageString.Get("MyServer") else local sdata1 = GameCenter.ServerListSystem:FindServer(msg.cityBattleInfoList[i].sid) if sdata1 ~= nil then GameCenter.BaJiZhenSystem.DicColorServer[msg.cityBattleInfoList[i].colorCamp] = UIUtils.CSFormat("S{0}_{1}", sdata1.ShowServerId, sdata1.Name) end -- GameCenter.BaJiZhenSystem.DicColorServer[msg.cityBattleInfoList[i].colorCamp] = msg.cityBattleInfoList[i].sid end GameCenter.BaJiZhenSystem.DicColorServerId[msg.cityBattleInfoList[i].colorCamp] = msg.cityBattleInfoList[i].sid -- 设置人数 self.DicPercent[msg.cityBattleInfoList[i].colorCamp] = msg.cityBattleInfoList[i].playerNum -- 设置伤害 self.DicDamagePercent[msg.cityBattleInfoList[i].colorCamp] = msg.cityBattleInfoList[i].bossHurt end end -- 初始化连线id self.ListCanFight:Clear() local cfg = DataConfig.DataEightCity[self.CfgId] if cfg ~= nil then local list = Utils.SplitStr(cfg.CanAttackCityLine, '_') if list ~= nil then for i = 1, #list do self.ListCanFight:Add(tonumber(list[i])) end end self.JuDianName = cfg.Name self.RewardStr = cfg.Reward self.ListRelationJuDian:Clear() list = Utils.SplitStr(cfg.CanAttackCity, '_') if list ~= nil then for i = 1, #list do self.ListRelationJuDian:Add(tonumber(list[i])) end end end end function BaJiJuDianData:GetServerName() local name = nil if self.JuDianState == BaJiJuDianState.LocalServer then name = DataConfig.DataMessageString.Get("MyServer") elseif self.JuDianState == BaJiJuDianState.OtherServer then name = self.Name elseif self.JuDianState == BaJiJuDianState.NoneServer then -- 判断是否有玩家 local tNum = 0 for i = 1, BaJiColor.Count do local num = self:GetServerRoleNumByColorId(i) tNum = tNum + num end if tNum > 0 then name = DataConfig.DataMessageString.Get("Fighting") else name = "" end end return name end function BaJiJuDianData:IsLocalServer() return self.JuDianState == BaJiJuDianState.LocalServer end function BaJiJuDianData:IsFight() return self.JuDianState == BaJiJuDianState.NoneServer end -- 获取血量百分比 function BaJiJuDianData:GetBloodPercent() if self.TBlood == 0 then return 0 end return self.CurBlood / self.TBlood end -- 获取当前据点状态 function BaJiJuDianData:GetState() return self.JuDianState end -- 获取关联据点Ids function BaJiJuDianData:GetRelationIds() return self.ListCanFight end -- 获取关联的据点Ids function BaJiJuDianData:GetRelationJudian() return self.ListRelationJuDian end -- 获取服务人数占比 function BaJiJuDianData:GetServerRoleNumByColorId(id) if self.DicPercent:ContainsKey(id) then return self.DicPercent[id] end return 0 end -- 获取服务器伤害占比 function BaJiJuDianData:GetServerDamageByColorId(id) if self.DicDamagePercent:ContainsKey(id) then return self.DicDamagePercent[id] end return 0 end -- 通过当前据点和目标据点id获取之间连线Id function BaJiJuDianData:GetPathId(sourceId, destId) local pathId = 0 return pathId end return BaJiJuDianData