806 lines
31 KiB
Lua
806 lines
31 KiB
Lua
PlayerManager = {}
|
|
local this = PlayerManager
|
|
local gameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
|
|
this.userLevelData = ConfigManager.GetConfig(ConfigName.PlayerLevelConfig)
|
|
this.globalSystemConfig = ConfigManager.GetConfig(ConfigName.GlobalSystemConfig)
|
|
this.serverTime = 0
|
|
this.maxEnergy = 0
|
|
this.singleAddEnergy = gameSetting[1].EnergyRecoverSpeed[1]
|
|
this.singleAddTimeGap = gameSetting[1].EnergyRecoverSpeed[2]
|
|
this.exp = 0
|
|
this.level = 0
|
|
this.maxForce = 0
|
|
-- 每次重置的时间
|
|
this.startTime = 0
|
|
-- 已经计时的时间
|
|
this.durationTime = 0
|
|
-- 设置计时状态
|
|
this.isStart = false
|
|
--图鉴
|
|
this.heroHandBook = {}
|
|
this.equipHandBook = {}
|
|
this.talismanHandBook={}
|
|
this.heroHandBookListData={}
|
|
--移动速度 和 视野范围
|
|
this.MapSpeed = 0
|
|
this.MapView = 0
|
|
this.IsGetFiveStarHero = false
|
|
|
|
this.headBookListTag = 1
|
|
|
|
this.now_index = 0
|
|
|
|
--头像框数据
|
|
this.headFrameList = {}
|
|
this.MainPanelRoleMonveState = false
|
|
|
|
--激活的称号 时装 坐骑
|
|
this.isRefreshMainPanelNpc = true
|
|
this.userSkinList = {}--[id] = {skinId , overTime}
|
|
this.userTitleList = {}--[id] = {titleId , overTime}
|
|
this.userMountList = {}--[id] = {mountId , overTime}
|
|
|
|
local update = function()
|
|
local dt = Time.unscaledDeltaTime
|
|
this.serverTime = this.serverTime + dt
|
|
this.UpdateEnergyData()
|
|
end
|
|
function this.Initialize()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Network.OnReceiveHeartBeat, function(network, time)
|
|
if network.type == SocketType.LOGIN then
|
|
--Log("刷新心跳时间--------------"..time)
|
|
this.serverTime = time
|
|
end
|
|
end)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Player.OnGoldChange, this.OnGoldChange)
|
|
end
|
|
|
|
function this.InitServerTime()
|
|
UpdateBeat:Add(update, this)
|
|
end
|
|
|
|
function this.ResetLocalData(var)--初始化所有本地的每日一刷--1是五点推送、2是登陆检测
|
|
local func1 = function ()
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..RecruitType.Ten,0)
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..RecruitType.TimeLimitTen,0)
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..RecruitType.QianKunBoxTen,0)
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..RecruitType.LingShowTen,0)
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..RecruitType.XiangYaoTen,0)
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."GeneralPopup_RecruitConfirm"..RecruitType.BaoGeTen,0)
|
|
end
|
|
|
|
if var == 1 then
|
|
func1()
|
|
MapTrialManager.TrialRedCheck()
|
|
elseif var == 2 then
|
|
local text1 =PlayerManager.uid.."fiveTime"
|
|
local curTime = GetTimeStamp()
|
|
if not PlayerPrefs.HasKey(text1) then
|
|
func1()
|
|
PlayerPrefs.SetInt(text1,Today_N_OClockTimeStamp(5))
|
|
end
|
|
if PlayerPrefs.GetInt(text1) < curTime then
|
|
func1()
|
|
PlayerPrefs.SetInt(text1,Today_N_OClockTimeStamp(5)+86400)
|
|
end
|
|
end
|
|
end
|
|
|
|
function this.OnGoldChange()
|
|
|
|
end
|
|
|
|
--每间隔一段时间恢复精力
|
|
function this.UpdateEnergyData()
|
|
-- 一个计时器
|
|
|
|
if MapManager.isOpen then
|
|
local dt = this.serverTime - this.startTime
|
|
dt = math.floor(dt)
|
|
if dt ~= this.durationTime then
|
|
-- 数值更新
|
|
this.durationTime = dt
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Mission.OnTimeChange, this.durationTime)
|
|
end
|
|
end
|
|
|
|
-- 截取服务器时间
|
|
ActTimeCtrlManager.Updata()
|
|
ActTimeCtrlManager.serTime = math.floor(this.serverTime)
|
|
-- 刷新需要刷新的道具
|
|
-- this.RefreshItemNumBySerTime()
|
|
end
|
|
local needRefreshItemTabs = {1,44, 53,54}
|
|
local isAddItem = {
|
|
[1] = true,
|
|
--[2] = true,
|
|
[44] = true,
|
|
[53] = true,
|
|
[54]=true,
|
|
}
|
|
-- 刷新需要刷新的道具
|
|
function this.RefreshItemNumBySerTime()
|
|
for i, itemId in pairs(needRefreshItemTabs) do
|
|
--一些类型的特殊判断
|
|
if itemId == 1 then--行动力
|
|
if not EndLessMapManager.isTrigger and not EndLessMapManager.EnergyEnough() then-- 已经是行动力的上限不再刷新-- 正在正在触发事件不刷新
|
|
this.RefreshItemNumById(itemId)
|
|
end
|
|
elseif itemId == 44 then--外敌挑战券
|
|
if BagManager.GetItemCountById(itemId) then
|
|
this.RefreshItemNumById(itemId)
|
|
end
|
|
elseif itemId == 53 then--兽潮入场券
|
|
this.RefreshItemNumById(itemId)
|
|
elseif itemId == 54 then-- 召唤外敌次数
|
|
this.RefreshItemNumById(itemId)
|
|
|
|
end
|
|
end
|
|
end
|
|
local nextRefreshTime = 0
|
|
function this.RefreshItemNumById(itemId)
|
|
if not BagManager.bagDatas[itemId] then return end
|
|
nextRefreshTime = BagManager.bagDatas[itemId].nextFlushTime
|
|
if(nextRefreshTime) then
|
|
if this.serverTime >= nextRefreshTime and nextRefreshTime ~= 0 then
|
|
if isAddItem[itemId] then
|
|
isAddItem[itemId] = false
|
|
--地图里需要特殊处理 其他正常
|
|
if itemId == 1 and CarbonManager.difficulty == CARBON_TYPE.ENDLESS and MapManager.Mapping then
|
|
if #MapManager.stepList > 0 then
|
|
MapManager.MapUpdateEvent(-1000, function ()
|
|
NetManager.RefreshEnergyRequest({itemId},function()
|
|
isAddItem[itemId] = true
|
|
EndLessMapManager.isUpdateOnClose = true
|
|
Log("地图,同步,刷新")
|
|
end)
|
|
end)
|
|
else
|
|
NetManager.RefreshEnergyRequest({itemId},function()
|
|
isAddItem[itemId] = true
|
|
EndLessMapManager.isUpdateOnClose = true
|
|
Log("地图,刷新")
|
|
end)
|
|
end
|
|
else
|
|
Log("请求刷新 "..itemId.." "..this.serverTime.." "..nextRefreshTime)
|
|
NetManager.RefreshEnergyRequest({itemId},function()
|
|
isAddItem[itemId] = true
|
|
end)
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
this.curLevelAndExp = {}
|
|
function this.BcakUpdateUserExp(_msg)
|
|
if not UIManager.IsOpen(UIName.FightMopUpEndPanel) then
|
|
Log("后端更新玩家等级 和 经验 ".._msg.level.." ".._msg.exp)
|
|
|
|
this.exp = _msg.exp
|
|
local oldLevel = this.level
|
|
this.level = _msg.level
|
|
|
|
if this.level > oldLevel then
|
|
CheckRedPointStatus(RedPointType.HeroExplore_OpenMap)
|
|
CheckRedPointStatus(RedPointType.EpicExplore_OpenCarbon)
|
|
--FightManager.SetAndGetSingleFightState3(this.level)
|
|
RedPointManager.SetExploreRedPoint({ level = this.level })
|
|
-- 打点数据
|
|
TapDBManager.SetLevel(this.level)
|
|
--发送埋点数据
|
|
CustomEventManager.SendCustomEvents(FBSDKCustomEventType.RoleLv,this.level)
|
|
CheckRedPointStatus(RedPointType.OrdinaryExplore)
|
|
CheckRedPointStatus(RedPointType.HeroExplore)
|
|
CheckRedPointStatus(RedPointType.LegendExplore)
|
|
CheckRedPointStatus(RedPointType.People_Mirror)
|
|
|
|
end
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnPlayerLvChange)
|
|
if this.userLevelData and this.userLevelData[this.level] then
|
|
this.maxEnergy = this.userLevelData[this.level].MaxEnergy
|
|
else
|
|
this.maxEnergy = 0
|
|
end
|
|
else
|
|
this.curLevelAndExp = _msg
|
|
end
|
|
end
|
|
--跟具经验进行升级
|
|
function this.PromoteLevel(exp)
|
|
--Log("增加经验值 " .. exp)
|
|
local maxPlayerLv = GameDataBase.SheetBase.GetKeys(this.userLevelData)
|
|
this.exp = this.exp + exp
|
|
while this.exp >= this.userLevelData[this.level].Exp and this.level < #maxPlayerLv do
|
|
this.exp = this.exp - this.userLevelData[this.level].Exp
|
|
this.level = this.level + 1
|
|
this.level = this.level >= #maxPlayerLv and #maxPlayerLv or this.level
|
|
CheckRedPointStatus(RedPointType.HeroExplore_OpenMap)
|
|
CheckRedPointStatus(RedPointType.EpicExplore_OpenCarbon)
|
|
CheckRedPointStatus(RedPointType.SecretTer_NewHourseOpen)
|
|
--Log("¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥ 玩家升级增加经验"..this.userLevelData[this.level].AddEnergy.." "..BagManager.GetItemCountById(2))
|
|
--FightManager.SetAndGetSingleFightState3(this.level)
|
|
RedPointManager.SetExploreRedPoint({ level = this.level })
|
|
CheckRedPointStatus(RedPointType.OrdinaryExplore)
|
|
CheckRedPointStatus(RedPointType.HeroExplore)
|
|
CheckRedPointStatus(RedPointType.LegendExplore)
|
|
CheckRedPointStatus(RedPointType.People_Mirror)
|
|
end
|
|
this.maxEnergy = this.userLevelData[this.level].MaxEnergy
|
|
|
|
-- 看看这个玩家是否升级了
|
|
--if PlayerManager.level > FightManager.oldLevel then
|
|
-- Log("玩家升级成功!")
|
|
-- Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnLevelChange)
|
|
--end
|
|
-- ThinkingAnalyticsManager.SetSuperProperties({
|
|
|
|
-- })
|
|
end
|
|
function this.SetMaxEnergy()
|
|
this.maxEnergy = this.userLevelData[this.level].MaxEnergy
|
|
end
|
|
--获取单个英雄装备被动技能累计评分
|
|
function this.GetSingHeroAllEquipSkillListScore(_curHeroData)
|
|
local Score = 0
|
|
local curHeroData = _curHeroData
|
|
if curHeroData and curHeroData.equipIdList then
|
|
for i = 1, #curHeroData.equipIdList do
|
|
local curEquip = EquipManager.GetSingleEquipData(curHeroData.equipIdList[i])
|
|
if curEquip then
|
|
--if curEquip.skillId and curEquip.skillId > 0 then
|
|
Score = Score + curEquip.equipConfig.Score
|
|
--end
|
|
end
|
|
end
|
|
end
|
|
return Score
|
|
end
|
|
|
|
--图鉴更新
|
|
function this.InitHandBookData(heroHandBook,talismanHandBook)
|
|
--根据后端传的有过的所有英雄的数据更新本地英雄图鉴数据
|
|
if heroHandBook and #heroHandBook > 0 then
|
|
for n,m in ipairs(heroHandBook) do
|
|
if not PlayerManager.heroHandBook then
|
|
PlayerManager.heroHandBook={}
|
|
end
|
|
if not PlayerManager.heroHandBook[m.heroId] then
|
|
PlayerManager.heroHandBook[m.heroId]={maxStar=0}
|
|
end
|
|
PlayerManager.heroHandBook[m.heroId].maxStar = m.maxStar
|
|
end
|
|
end
|
|
--根据后端传的有过的所有装备的数据更新本地装备图鉴数据
|
|
Log("手册"..#talismanHandBook)
|
|
if talismanHandBook and #talismanHandBook > 0 then
|
|
for i = 1, #talismanHandBook do
|
|
PlayerManager.talismanHandBook[talismanHandBook[i]] = talismanHandBook[i]
|
|
end
|
|
end
|
|
TianShuMiJuanManger.CheckFetterStatus(1)
|
|
end
|
|
|
|
function this.SetHeroHandBookListData(heroSId,heroStar)
|
|
local isCheck = false
|
|
if this.heroHandBook[heroSId] == nil then
|
|
isCheck = true
|
|
this.heroHandBook[heroSId]={maxStar=0}
|
|
this.heroHandBook[heroSId].maxStar=heroStar
|
|
else
|
|
if this.heroHandBook[heroSId].maxStar<heroStar then
|
|
this.heroHandBook[heroSId].maxStar=heroStar
|
|
end
|
|
end
|
|
if isCheck then
|
|
TianShuMiJuanManger.CheckFetterStatus(1)
|
|
end
|
|
end
|
|
function this.SetEquipHandBookListData(equipSId)
|
|
if this.equipHandBook[equipSId] == nil then
|
|
this.equipHandBook[equipSId] = equipSId
|
|
end
|
|
end
|
|
--------------------------------------------
|
|
|
|
-- 切磋
|
|
function this.RequestPlayWithSomeOne(uid, teamId, tname, func)
|
|
if uid == PlayerManager.uid then
|
|
PopupTipPanel.ShowTip(Language[11398])
|
|
return
|
|
end
|
|
NetManager.RequestPlayWithSomeOne(uid, teamId, function(msg)
|
|
local fightData = BattleManager.GetBattleServerData({fightData = msg.fightData}, 1)
|
|
if tname then
|
|
tname = PlayerManager.nickName .."|" .. tname
|
|
end
|
|
BattleRecordManager.SetBattleRecord(fightData)
|
|
BattleRecordManager.SetBattleBothNameStr(tname)
|
|
|
|
local record = BattleRecordManager.GetBattleRecord()
|
|
local battlePanel = UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.BACK, func)
|
|
battlePanel:SetResult(record.result)
|
|
|
|
end)
|
|
end
|
|
-----------------------------------玩家坐骑 皮肤 称号
|
|
--设置玩家称号
|
|
function this.SetPlayerDesignation(value)
|
|
PlayerManager.designation = value
|
|
end
|
|
--设置玩家皮肤
|
|
function this.SetPlayerSkin(value)
|
|
PlayerManager.skin = value
|
|
end
|
|
--设置玩家坐骑
|
|
function this.SetPlayerRide(value)
|
|
PlayerManager.ride = value
|
|
end
|
|
function this.GetPlayerDesignation()
|
|
--加判断是否到时间 卸掉
|
|
local curTitleData = this.userTitleList[PlayerManager.designation]
|
|
if curTitleData then
|
|
if curTitleData.overTime > GetTimeStamp() or curTitleData.overTime == 0 then
|
|
return PlayerManager.designation
|
|
end
|
|
else
|
|
return PlayerManager.designation
|
|
end
|
|
NetManager.RequestChangeModifyDecoration(2,0)
|
|
this.SetPlayerDesignation(0)
|
|
PlayerManager.SetisRefreshMainPanelNpc(true)
|
|
return PlayerManager.designation
|
|
end
|
|
--设置玩家皮肤
|
|
function this.GetPlayerSkin()
|
|
--刷新所有时装 坐骑 称号 集合 检查是否有限时到时间的并删除
|
|
this.RefreshAllSkinRideTitle()
|
|
--加判断是否到时间 卸掉
|
|
local curSkinData = this.userSkinList[PlayerManager.skin]
|
|
if curSkinData then
|
|
if curSkinData.overTime > GetTimeStamp() or curSkinData.overTime == 0 then
|
|
return PlayerManager.skin
|
|
end
|
|
else
|
|
return PlayerManager.skin
|
|
end
|
|
NetManager.RequestChangeModifyDecoration(4,0)
|
|
this.SetPlayerSkin(0)
|
|
PlayerManager.SetisRefreshMainPanelNpc(true)
|
|
return PlayerManager.skin
|
|
end
|
|
--设置玩家坐骑
|
|
function this.GetPlayerRide()
|
|
--加判断是否到时间 卸掉
|
|
local currideData = this.userMountList[PlayerManager.ride]
|
|
if currideData then
|
|
if currideData.overTime > GetTimeStamp() or currideData.overTime == 0 then
|
|
return PlayerManager.ride
|
|
end
|
|
else
|
|
return PlayerManager.ride
|
|
end
|
|
NetManager.RequestChangeModifyDecoration(3,0)
|
|
this.SetPlayerRide(0)
|
|
PlayerManager.SetisRefreshMainPanelNpc(true)
|
|
return PlayerManager.ride
|
|
end
|
|
function this.SetisRefreshMainPanelNpc(state)
|
|
LogBlue("isRefreshMainPanelNpc "..tostring(this.isRefreshMainPanelNpc))
|
|
this.isRefreshMainPanelNpc = state
|
|
end
|
|
function this.GetisRefreshMainPanelNpc()
|
|
return this.isRefreshMainPanelNpc
|
|
end
|
|
--初始化所以激活的称号 时装 坐骑
|
|
function this.InitSkinTitleMountData(userSkinList,userTitleList,userMountList)
|
|
this.userSkinList = {}--[id] = {skinId , overTime}
|
|
LogBlue("#userSkinList "..#userSkinList.." #userTitleList "..#userTitleList.." #userMountList "..#userMountList)
|
|
for i = 1, #userSkinList do
|
|
local singData = {}
|
|
singData.skinId = userSkinList[i].skinId
|
|
singData.overTime = userSkinList[i].overTime
|
|
this.userSkinList[singData.skinId] = singData
|
|
end
|
|
this.userTitleList = {}--[id] = {titleId , overTime}
|
|
for i = 1, #userTitleList do
|
|
local singData = {}
|
|
singData.titleId = userTitleList[i].titleId
|
|
singData.overTime = userTitleList[i].overTime
|
|
this.userTitleList[singData.titleId] = singData
|
|
end
|
|
this.userMountList = {}--[id] = {mountId , overTime}
|
|
for i = 1, #userMountList do
|
|
local singData = {}
|
|
singData.mountId = userMountList[i].mountId
|
|
singData.overTime = userMountList[i].overTime
|
|
this.userMountList[singData.mountId] = singData
|
|
end
|
|
end
|
|
--设置称号 时装 坐骑 的限时时间
|
|
function this.SetPlayerSkinTime(id,validTime)
|
|
if this.userSkinList then
|
|
if validTime then--不为空时是设置时间 没有会新加数据
|
|
if this.userSkinList[id] then
|
|
this.userSkinList[id].overTime = validTime
|
|
else
|
|
local singData = {}
|
|
singData.skinId = id
|
|
singData.overTime = validTime
|
|
this.userSkinList[singData.skinId] = singData
|
|
end
|
|
else--为空时是删除数据 倒计时结束时
|
|
if this.userSkinList[id] then
|
|
this.userSkinList[id] = nil
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function this.SetPlayerTitleTime(id,validTime)
|
|
if this.userTitleList then
|
|
if validTime then--不为空时是设置时间 没有会新加数据
|
|
if this.userTitleList[id] then
|
|
this.userTitleList[id].overTime = validTime
|
|
else
|
|
local singData = {}
|
|
singData.titleId = id
|
|
singData.overTime = validTime
|
|
this.userTitleList[singData.titleId] = singData
|
|
end
|
|
else--为空时是删除数据 倒计时结束时
|
|
if this.userTitleList[id] then
|
|
this.userTitleList[id] = nil
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function this.SetPlayerMountTime(id,validTime)
|
|
if this.userMountList then
|
|
if validTime then--不为空时是设置时间 没有会新加数据
|
|
if this.userMountList[id] then
|
|
this.userMountList[id].overTime = validTime
|
|
else
|
|
local singData = {}
|
|
singData.mountId = id
|
|
singData.overTime = validTime
|
|
this.userMountList[singData.mountId] = singData
|
|
this.SetPlayerRideRedPoint(PlayerTitleRideSkinRedPointTypeStr.Ride,1)
|
|
-- FormationManager.UserPowerChanged()
|
|
NetManager.RequestUserForceChange(FormationTypeDef.FORMATION_NORMAL)
|
|
end
|
|
else--为空时是删除数据 倒计时结束时
|
|
if this.userMountList[id] then
|
|
this.userMountList[id] = nil
|
|
end
|
|
end
|
|
end
|
|
end
|
|
function this.RefreshAllSkinRideTitle()
|
|
for key, value in pairs(this.userMountList) do
|
|
if value and value.overTime > 0 and value.overTime < GetTimeStamp() then
|
|
--过期
|
|
table.remove(this.userMountList,key)
|
|
end
|
|
end
|
|
for key, value in pairs(this.userTitleList) do
|
|
if value and value.overTime > 0 and value.overTime < GetTimeStamp() then
|
|
--过期
|
|
table.remove(this.userTitleList,key)
|
|
end
|
|
end
|
|
for key, value in pairs(this.userSkinList) do
|
|
if value and value.overTime > 0 and value.overTime < GetTimeStamp() then
|
|
--过期
|
|
table.remove(this.userSkinList,key)
|
|
end
|
|
end
|
|
end
|
|
--设置当前玩家 视野范围 和 移动速度
|
|
function this.SetMoveSpeedAndMapView()
|
|
if PlayerManager.ride > 0 then
|
|
local playerMountLevelUpConFig = ConfigManager.GetConfigData(ConfigName.PlayerMountLevelUp,PlayerManager.rideLevel)
|
|
if playerMountLevelUpConFig then
|
|
this.MapSpeed = playerMountLevelUpConFig.MapSpeed
|
|
this.MapView = playerMountLevelUpConFig.MapView
|
|
end
|
|
end
|
|
end
|
|
--计算 称号 皮肤 坐骑战力加成
|
|
function this.CalculatePlayerDcorateProAddVal()
|
|
local addAllProVal = {}
|
|
--称号 皮肤 坐骑 当前玩家正穿戴的加成
|
|
local allPlayerUpConfig = {}
|
|
if PlayerManager.designation and PlayerManager.designation > 0 then
|
|
local PlayerHeadIcon = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,PlayerManager.designation)
|
|
if PlayerHeadIcon and PlayerHeadIcon.WearProperty and #PlayerHeadIcon.WearProperty > 0 then
|
|
table.insert(allPlayerUpConfig,PlayerHeadIcon)
|
|
end
|
|
end
|
|
if PlayerManager.skin and PlayerManager.skin > 0 then
|
|
local PlayerHeadIcon = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,PlayerManager.skin)
|
|
if PlayerHeadIcon and PlayerHeadIcon.WearProperty and #PlayerHeadIcon.WearProperty > 0 then
|
|
table.insert(allPlayerUpConfig,PlayerHeadIcon)
|
|
end
|
|
end
|
|
if PlayerManager.ride and PlayerManager.ride > 0 then
|
|
local PlayerHeadIcon = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,PlayerManager.ride)
|
|
if PlayerHeadIcon and PlayerHeadIcon.WearProperty and #PlayerHeadIcon.WearProperty > 0 then
|
|
table.insert(allPlayerUpConfig,PlayerHeadIcon)
|
|
end
|
|
end
|
|
for i = 1, #allPlayerUpConfig do
|
|
for j = 1, #allPlayerUpConfig[i].WearProperty do
|
|
local curAddProInfo = allPlayerUpConfig[i].WearProperty[j]
|
|
if addAllProVal[curAddProInfo[1]] then
|
|
addAllProVal[curAddProInfo[1]] = addAllProVal[curAddProInfo[1]] + curAddProInfo[2]
|
|
else
|
|
addAllProVal[curAddProInfo[1]] = curAddProInfo[2]
|
|
end
|
|
end
|
|
end
|
|
--称号 皮肤 坐骑 当前玩家解锁的加成
|
|
local allActiveConfig = {}
|
|
for key, value in pairs(this.userSkinList) do
|
|
local PlayerHeadIcon = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,value.skinId)
|
|
if PlayerHeadIcon and PlayerHeadIcon.UnlockProperty and #PlayerHeadIcon.UnlockProperty > 0 then
|
|
table.insert(allActiveConfig,PlayerHeadIcon)
|
|
end
|
|
end
|
|
for key, value in pairs(this.userTitleList) do
|
|
local PlayerHeadIcon = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,value.titleId)
|
|
if PlayerHeadIcon and PlayerHeadIcon.UnlockProperty and #PlayerHeadIcon.UnlockProperty > 0 then
|
|
table.insert(allActiveConfig,PlayerHeadIcon)
|
|
end
|
|
end
|
|
for key, value in pairs(this.userMountList) do
|
|
local PlayerHeadIcon = ConfigManager.GetConfigData(ConfigName.PlayerHeadIcon,value.mountId)
|
|
if PlayerHeadIcon and PlayerHeadIcon.UnlockProperty and #PlayerHeadIcon.UnlockProperty > 0 then
|
|
table.insert(allActiveConfig,PlayerHeadIcon)
|
|
end
|
|
end
|
|
for i = 1, #allActiveConfig do
|
|
if allActiveConfig[i].UnlockProperty then
|
|
for j = 1, #allActiveConfig[i].UnlockProperty do
|
|
local curAddProInfo = allActiveConfig[i].UnlockProperty[j]
|
|
if addAllProVal[curAddProInfo[1]] then
|
|
addAllProVal[curAddProInfo[1]] = addAllProVal[curAddProInfo[1]] + curAddProInfo[2]
|
|
else
|
|
addAllProVal[curAddProInfo[1]] = curAddProInfo[2]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return addAllProVal
|
|
end
|
|
function this.SetPlayerRideRedPoint(str,val)
|
|
PlayerPrefs.SetInt(PlayerManager.uid..PlayerManager.serverInfo.server_id..PlayerTitleRideSkinRedPointTypeStr.Ride, val)
|
|
CheckRedPointStatus(RedPointType.Setting_Ride)
|
|
end
|
|
function this.GetPlayerRideRedPoint(str)
|
|
local redPointState = PlayerPrefs.GetInt(PlayerManager.uid..PlayerManager.serverInfo.server_id..PlayerTitleRideSkinRedPointTypeStr.Ride)
|
|
return redPointState == 1
|
|
end
|
|
-----------------------------------玩家坐骑 皮肤 称号结束
|
|
function this.GetHeroDataByStar(star,staticid)
|
|
if PlayerManager.heroHandBook and PlayerManager.heroHandBook[staticid] and PlayerManager.heroHandBook[staticid].maxStar >= star then
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
|
|
--主城停留弹气泡
|
|
local level_bubble_config = string.split(ConfigManager.GetConfigData(ConfigName.SpecialConfig,88).Value,"|")
|
|
local battleUpLvTipTime = Timer.New()
|
|
local curMianPanleLoginShowTipNum = 0
|
|
local curLevelPanleLoginShowTipNum = 0
|
|
local noShowBattleUpLvTipMaxLv = tonumber(level_bubble_config[3])
|
|
local noShowBattleUpLvTipMaxNum = tonumber(level_bubble_config[2])
|
|
local showBattleUpLvTipMaxTime = tonumber(level_bubble_config[1])
|
|
|
|
function this.StarBattleUpLvTipTime(type)
|
|
local curSecound = 0
|
|
if PlayerManager.level >= noShowBattleUpLvTipMaxLv then
|
|
return
|
|
end
|
|
if not FightPointPassManager.IsShowFightRP() then
|
|
return
|
|
end
|
|
if GuideManager.IsInMainGuide() then
|
|
return
|
|
end
|
|
if battleUpLvTipTime then
|
|
battleUpLvTipTime:Stop()
|
|
battleUpLvTipTime = nil
|
|
end
|
|
if type == 1 and curMianPanleLoginShowTipNum < noShowBattleUpLvTipMaxNum then--主界面
|
|
battleUpLvTipTime = Timer.New(function()
|
|
curSecound = curSecound + 1
|
|
-- LogGreen("主界面停留 "..curSecound)
|
|
if curSecound >= showBattleUpLvTipMaxTime then
|
|
if battleUpLvTipTime then
|
|
battleUpLvTipTime:Stop()
|
|
battleUpLvTipTime = nil
|
|
end
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnShowBattleUpLvTip)
|
|
curMianPanleLoginShowTipNum = curMianPanleLoginShowTipNum + 1
|
|
end
|
|
end, 1, -1, true)
|
|
battleUpLvTipTime:Start()
|
|
elseif type == 2 and curLevelPanleLoginShowTipNum < noShowBattleUpLvTipMaxNum then--关卡界面
|
|
battleUpLvTipTime = Timer.New(function()
|
|
curSecound = curSecound + 1
|
|
-- LogGreen("关卡界面停留 "..curSecound)
|
|
if curSecound >= showBattleUpLvTipMaxTime then
|
|
if battleUpLvTipTime then
|
|
battleUpLvTipTime:Stop()
|
|
battleUpLvTipTime = nil
|
|
end
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnShowBattleUpLvTip)
|
|
curLevelPanleLoginShowTipNum = curLevelPanleLoginShowTipNum + 1
|
|
end
|
|
end, 1, -1, true)
|
|
battleUpLvTipTime:Start()
|
|
end
|
|
end
|
|
|
|
function this.RefreshWorldLeveData(worldLeve)
|
|
this.worldLeve = worldLeve
|
|
-- Game.GlobalEvent:DispatchEvent(GameEvent.JumpServerHeightLadder.UpdateWordLv)
|
|
end
|
|
|
|
function this.StopBattleUpLvTipTime()
|
|
if battleUpLvTipTime then
|
|
battleUpLvTipTime:Stop()
|
|
battleUpLvTipTime = nil
|
|
end
|
|
end
|
|
|
|
------- 主城NPC 选择star ----------
|
|
---先去好友里 或 公会成员 去取needNum 个 再去排行榜里去取needAllNum - 去取needNum 个 最后不足自己造NPC 信息
|
|
local needNum = 5--7
|
|
local needAllNum = 10--14
|
|
local rankNPCList = {}
|
|
local friendNPCList = {}
|
|
function this.GetMainPlayerNPCData(fun)
|
|
rankNPCList = {}
|
|
friendNPCList = {}
|
|
local friendRandomNum = math.random(1, 2)
|
|
if friendRandomNum == 2 and PlayerManager.familyId == 0 then
|
|
friendRandomNum = 1
|
|
end
|
|
-- LogGreen("friendRandomNum "..friendRandomNum)
|
|
local curfriendAllList = {}
|
|
if friendRandomNum == 1 then
|
|
NetManager.RequestGetFriendInfo(1,function(msg)
|
|
for i = 1, #msg.Friends do
|
|
if msg.Friends[i].id ~= PlayerManager.uid then
|
|
LogBlue("msg.Friends[i] "..msg.Friends[i].userSkin.." "..msg.Friends[i].userTitle.." "..msg.Friends[i].userMount.." "..msg.Friends[i].sex)
|
|
table.insert(curfriendAllList,msg.Friends[i])
|
|
end
|
|
end
|
|
if #curfriendAllList > needNum then
|
|
for i = 1, needNum do
|
|
this.RandomFirendNPC(curfriendAllList)
|
|
end
|
|
else
|
|
for i = 1, #curfriendAllList do
|
|
friendNPCList[i] = curfriendAllList[i]
|
|
-- LogGreen("friend "..msg.Friends[i].name)
|
|
end
|
|
end
|
|
-- LogGreen("#friendNPCList "..#friendNPCList)
|
|
this.GetMainPlayerNPCData2(fun)
|
|
end)
|
|
else
|
|
MyGuildManager.RequestMyGuildMembers(function()
|
|
local MyGuildMemList = MyGuildManager.GetMyGuildMemList()
|
|
for i = 1, #MyGuildMemList do
|
|
if MyGuildMemList[i].roleUid ~= PlayerManager.uid then
|
|
LogBlue("MyGuildMemList[i] "..MyGuildMemList[i].userSkin.." "..MyGuildMemList[i].userTitle.." "..MyGuildMemList[i].userMount.." "..MyGuildMemList[i].sex)
|
|
table.insert(curfriendAllList,MyGuildMemList[i])
|
|
end
|
|
end
|
|
if #curfriendAllList > needNum then
|
|
for i = 1, needNum do
|
|
this.RandomFirendNPC(curfriendAllList)
|
|
end
|
|
else
|
|
for i = 1, #curfriendAllList do
|
|
friendNPCList[i] = curfriendAllList[i]
|
|
-- LogGreen("MyGuildMemList "..MyGuildMemList[i].userName)
|
|
end
|
|
end
|
|
-- LogGreen("#MyGuildMemList "..#friendNPCList)
|
|
this.GetMainPlayerNPCData2(fun)
|
|
end)
|
|
end
|
|
end
|
|
function this.GetMainPlayerNPCData2(fun)
|
|
local rankRandomNum = math.random(1, 4)
|
|
if rankRandomNum == 3 then rankRandomNum = 2 end--如果是公会排行 改成战力排行 (公会排行展示的是公会名字)
|
|
local curAddNum = needNum - LengthOfTable(friendNPCList)
|
|
curAddNum = needNum + curAddNum
|
|
-- LogGreen("rankRandomNum "..rankRandomNum)
|
|
RankingManager.InitData(rankKingList[rankRandomNum].rankType, function()
|
|
local rankAllList = RankingManager.GetRankingInfo()
|
|
local currankAllList = {}
|
|
for i = 1, 25 do
|
|
if rankAllList[i] and rankAllList[i].uid ~= PlayerManager.uid then
|
|
-- LogBlue("rankAllList[i] "..rankAllList[i].userSkin.." "..rankAllList[i].userTitle.." "..rankAllList[i].userMount.." "..rankAllList[i].sex)
|
|
table.insert(currankAllList,rankAllList[i])
|
|
end
|
|
end
|
|
if #currankAllList > curAddNum then
|
|
for i = 1, curAddNum do
|
|
this.RandomRankNPC(currankAllList)
|
|
end
|
|
else
|
|
for i = 1, #currankAllList do
|
|
rankNPCList[i] = currankAllList[i]
|
|
-- LogGreen("rank "..currankAllList[i].userName)
|
|
end
|
|
end
|
|
-- LogGreen("#rankNPCList "..#rankNPCList)
|
|
this.GetMainPlayerNPCData3(fun)
|
|
end)
|
|
end
|
|
function this.GetMainPlayerNPCData3(fun)
|
|
local upList = {}
|
|
for key,val in pairs(friendNPCList) do
|
|
table.insert(upList,val)
|
|
end
|
|
for key,val in pairs(rankNPCList) do
|
|
-- 去重
|
|
local isRepetition = false
|
|
for ke2y,val2 in pairs(upList) do
|
|
local curUid = val2.roleUid or val2.id
|
|
if val.uid == curUid then
|
|
isRepetition = true
|
|
end
|
|
end
|
|
if not isRepetition then
|
|
table.insert(upList,val)
|
|
end
|
|
end
|
|
if #upList < needAllNum then
|
|
for i = 1, needAllNum - #upList do
|
|
local singleUserData = {}
|
|
singleUserData.userName = NameManager.GetLocalRandomName()
|
|
singleUserData.sex = math.random(0,1)
|
|
singleUserData.uid = 1000 + i
|
|
singleUserData.userSkin = PlayerManager.GetPlayerSkin()
|
|
singleUserData.userTitle = 0
|
|
singleUserData.userMount = 0
|
|
table.insert(upList,singleUserData)
|
|
end
|
|
end
|
|
-- LogGreen("#upList "..#upList)
|
|
if fun then
|
|
fun(upList)
|
|
end
|
|
end
|
|
function this.RandomRankNPC(currankAllList)
|
|
local playerRandomNum = math.random(1, #currankAllList)
|
|
if rankNPCList[playerRandomNum] then
|
|
this.RandomRankNPC(currankAllList)
|
|
else
|
|
rankNPCList[playerRandomNum] = currankAllList[playerRandomNum]
|
|
-- LogGreen("rank "..currankAllList[playerRandomNum].userName)
|
|
end
|
|
end
|
|
|
|
function this.RandomFirendNPC(currankAllList)
|
|
local playerRandomNum = math.random(1, #currankAllList)
|
|
if friendNPCList[playerRandomNum] then
|
|
this.RandomFirendNPC(currankAllList)
|
|
else
|
|
friendNPCList[playerRandomNum] = currankAllList[playerRandomNum]
|
|
-- LogGreen("friend "..currankAllList[playerRandomNum].userName)
|
|
end
|
|
end
|
|
---------- 主城NPC 选择 end----------
|
|
return this |