626 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			626 lines
		
	
	
		
			21 KiB
		
	
	
	
		
			Lua
		
	
FightPointPassManager = {};
 | 
						||
local this = FightPointPassManager
 | 
						||
local mainLevelConfig = ConfigManager.GetConfig(ConfigName.MainLevelConfig)
 | 
						||
-- 火洞吊裸
 | 
						||
local Huo_Dong_Diao_Luo = ConfigManager.GetConfig(ConfigName.ActivityDropReward)
 | 
						||
local rewardGroupConfig = ConfigManager.GetConfig(ConfigName.RewardGroup)
 | 
						||
this.talkingTime = 0   --对话时间
 | 
						||
-- 挂机物品栏位对应vip数值加成特权
 | 
						||
 | 
						||
-- 战斗胜利后是否已经更新过ID
 | 
						||
local hadUpdate = false
 | 
						||
 | 
						||
local CHATER_OPEN = 1
 | 
						||
local CHATER_CLOSE = 0
 | 
						||
local CHATER_STATE = "CHATER_STATE"
 | 
						||
 | 
						||
local OLD_ID = "OLD_ID"
 | 
						||
local isOpenRewardUpTip = false
 | 
						||
 | 
						||
this.randomNum = 1
 | 
						||
function this.Initialize()
 | 
						||
    this.curOpenFight = 1011 -- 当前开启的关卡
 | 
						||
    this.lastPassFightId = 1011  -- 上一关的ID
 | 
						||
    this.isBattleBack = false
 | 
						||
    this.HangOnTime = 0 -- 关卡挂机时长
 | 
						||
    this.curFightState = 0
 | 
						||
    this.oldLevel = 0 -- 玩家关卡战斗之前的等级
 | 
						||
    this.curFightMapId = 1011 -- 当前关卡对应的地图背景ID
 | 
						||
    this.isOutFight = false
 | 
						||
	this.isOpenNewChapter = false -- 是否开启新章节
 | 
						||
    this.isMaxChapter=false --是否最大章节
 | 
						||
    this.maxChapterNum=15 --最大章节数
 | 
						||
    this.isBeginFight = false
 | 
						||
    this.enterFightBattle = false -- 进入关卡战斗
 | 
						||
    this.ShowBtnJumpTime = ConfigManager.GetConfig(ConfigName.GameSetting)[1].JumpLevelTime
 | 
						||
    this.boxState = 0 -- 当前需要显示的宝箱
 | 
						||
 | 
						||
    Game.GlobalEvent:AddEvent(GameEvent.Player.OnLevelChange, this.CheckFightRP)
 | 
						||
    -- Game.GlobalEvent:AddEvent(GameEvent.Mission.OnOpenEnableFight, this.CheckFightRP)
 | 
						||
    Game.GlobalEvent:AddEvent(GameEvent.Mission.OnOpenFight, this.CheckFightRP)
 | 
						||
 | 
						||
end
 | 
						||
 | 
						||
function this.CheckFightRP()
 | 
						||
    CheckRedPointStatus(RedPointType.SecretTer_IsCanFight)
 | 
						||
end
 | 
						||
 | 
						||
-- 初始化关卡状态, state , 1 已开启未通过 2 :已通过 -1 已开启等级未解锁
 | 
						||
function this.InitAllFightPointState(msg)
 | 
						||
    Log("当前关卡ID " .. tostring(msg.fightId).." 当前关卡的状态:" ..tostring(msg.state).." 当前已经挂机的时长:" .. tostring(msg.duration).."   挂机奖励:"..tostring(msg.reward))
 | 
						||
    if msg.duration  < 0 then
 | 
						||
        Log("服务器返回的挂机时长是负数,是不是调时间??")
 | 
						||
    end
 | 
						||
 | 
						||
    this.HangOnTime = msg.duration
 | 
						||
    this.curOpenFight = msg.fightId
 | 
						||
    if mainLevelConfig[this.curOpenFight].SortId-1 > 0 then
 | 
						||
        this.lastPassFightId = ConfigManager.GetConfigDataByKey(ConfigName.MainLevelConfig,"SortId", mainLevelConfig[this.curOpenFight].SortId-1).Id
 | 
						||
    end
 | 
						||
    this.curFightState = msg.state
 | 
						||
    this.adventrueEnemyList=msg.adventureBossInfo
 | 
						||
    this.HangOnReward=msg.reward
 | 
						||
    Log()
 | 
						||
    this.maxChapterNum = LengthOfTable(GameDataBase.SheetBase.GetKeys(ConfigManager.GetConfig(ConfigName.MainLevelSettingConfig)))
 | 
						||
end
 | 
						||
 | 
						||
-- 获取某一关卡的状态, 小于当前关卡必定已通关,大于必定未解锁
 | 
						||
function this.GetFightStateById(fightId)
 | 
						||
    local curDiff = mainLevelConfig[this.curOpenFight].Difficulty
 | 
						||
    local judgeDiff = mainLevelConfig[fightId].Difficulty
 | 
						||
    if curDiff == judgeDiff then
 | 
						||
        if fightId < this.curOpenFight then
 | 
						||
            return FIGHT_POINT_STATE.PASS
 | 
						||
        elseif fightId == this.curOpenFight then
 | 
						||
            if this.curFightState == 1 then
 | 
						||
                return FIGHT_POINT_STATE.OPEN_NOT_PASS
 | 
						||
            elseif this.curFightState == -1 then
 | 
						||
                return FIGHT_POINT_STATE.OPEN_LOW_LEVEL
 | 
						||
            elseif this.curFightState == 2 then
 | 
						||
                return FIGHT_POINT_STATE.PASS
 | 
						||
            end
 | 
						||
        elseif fightId > this.curOpenFight then
 | 
						||
            return FIGHT_POINT_STATE.LOCK
 | 
						||
        end
 | 
						||
    elseif curDiff > judgeDiff then
 | 
						||
        return FIGHT_POINT_STATE.PASS
 | 
						||
    elseif curDiff < judgeDiff then
 | 
						||
        return FIGHT_POINT_STATE.LOCK
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
-- 获取某一关卡是否开启
 | 
						||
function this.GetFightIsOpenById(fightId)
 | 
						||
    local curDiff = mainLevelConfig[this.curOpenFight].Difficulty
 | 
						||
    local judgeDiff = mainLevelConfig[fightId].Difficulty
 | 
						||
    if curDiff == judgeDiff then
 | 
						||
        return fightId <= this.curOpenFight
 | 
						||
    elseif judgeDiff < curDiff then
 | 
						||
        return true
 | 
						||
    else
 | 
						||
        return false
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
-- 获取某一关卡是否通关
 | 
						||
function this.IsFightPointPass(fightId)
 | 
						||
    local isPass = false
 | 
						||
    local curDiff = mainLevelConfig[this.curOpenFight].Difficulty
 | 
						||
    local judgeDiff = mainLevelConfig[fightId].Difficulty
 | 
						||
    if curDiff == judgeDiff then
 | 
						||
 | 
						||
        if fightId < this.curOpenFight then
 | 
						||
            isPass = true
 | 
						||
        elseif fightId == this.curOpenFight then
 | 
						||
            if this.curFightState == 2 then -- 最后一章的最后一关
 | 
						||
                isPass = true
 | 
						||
            else
 | 
						||
                isPass = false
 | 
						||
            end
 | 
						||
        else
 | 
						||
            isPass = false
 | 
						||
        end
 | 
						||
    elseif curDiff > judgeDiff then
 | 
						||
        isPass = true
 | 
						||
    else
 | 
						||
        isPass = false
 | 
						||
    end
 | 
						||
 | 
						||
    return isPass
 | 
						||
end
 | 
						||
 | 
						||
-- 战斗胜利后,刷新当前关卡的ID
 | 
						||
function this.RefreshFightId(msg)
 | 
						||
    --local data = mainLevelConfig[this.curOpenFight]
 | 
						||
    --if data then
 | 
						||
    local oldFight = this.curOpenFight
 | 
						||
    this.lastPassFightId = oldFight
 | 
						||
    PlayerPrefs.SetInt(PlayerManager.uid .. OLD_ID, oldFight)
 | 
						||
    -- 最后一关更新
 | 
						||
    --if data.NextLevel ~= -1 then
 | 
						||
    Game.GlobalEvent:DispatchEvent(GameEvent.Mission.OnPassFight, oldFight)
 | 
						||
 | 
						||
    -- 服务器更新关卡状态
 | 
						||
    this.curOpenFight = msg.fightId
 | 
						||
    this.curFightState = msg.state
 | 
						||
 | 
						||
 | 
						||
    if this.curFightState == 1 then
 | 
						||
        -- 解锁一个可以打的新关卡, 发送新关卡ID
 | 
						||
        Game.GlobalEvent:DispatchEvent(GameEvent.Mission.OnOpenEnableFight, msg.fightId)
 | 
						||
    end
 | 
						||
 | 
						||
    -- 章节开启
 | 
						||
    local isOpen = mainLevelConfig[this.curOpenFight].PicShow == 1
 | 
						||
    --开启新章节的表现处理
 | 
						||
    if isOpen then
 | 
						||
        this.SetChapterOpenState(true)
 | 
						||
    end
 | 
						||
 | 
						||
    Game.GlobalEvent:DispatchEvent(GameEvent.Mission.OnOpenFight, oldFight)
 | 
						||
 | 
						||
    --判断是否需要弹估计奖励提升界面
 | 
						||
    local oldLevelConFig = ConfigManager.GetConfigData(ConfigName.MainLevelConfig,this.lastPassFightId)
 | 
						||
    local cirLevelConFig = ConfigManager.GetConfigData(ConfigName.MainLevelConfig,this.curOpenFight)
 | 
						||
    for i = 1, #cirLevelConFig.RewardShowMin do
 | 
						||
        local oldsinglePro = oldLevelConFig.RewardShowMin[i]
 | 
						||
        local cursinglePro = cirLevelConFig.RewardShowMin[i]
 | 
						||
        if not isOpenRewardUpTip and cursinglePro[2] > oldsinglePro[2] then
 | 
						||
            this.SetIsOpenRewardUpTip(true)
 | 
						||
        end
 | 
						||
    end
 | 
						||
 | 
						||
 | 
						||
    Log("          更新关卡ID   "  .. this.curOpenFight)
 | 
						||
    Log("          关卡状态     "  .. this.curFightState)
 | 
						||
    -- 判断新解锁关卡的状态
 | 
						||
    --if PlayerManager.level >= data.LevelLimit then
 | 
						||
    --    this.curFightState = 1
 | 
						||
    --if this.curFightState == 1 then
 | 
						||
    --    -- 解锁一个可以打的新关卡, 发送新关卡ID
 | 
						||
    --    Game.GlobalEvent:DispatchEvent(GameEvent.Mission.OnOpenEnableFight, data.NextLevel)
 | 
						||
    --end
 | 
						||
    --else
 | 
						||
    --    this.curFightState = -1
 | 
						||
    --end
 | 
						||
 | 
						||
 | 
						||
    ---- 章节开启
 | 
						||
    --local isOpen = mainLevelConfig[this.curOpenFight].PicShow == 1
 | 
						||
    ----开启新章节的表现处理
 | 
						||
    --if isOpen then
 | 
						||
    --    this.SetChapterOpenState(true)
 | 
						||
    --end
 | 
						||
 | 
						||
 | 
						||
    --Log("~关卡已通关,id = "..oldFight)
 | 
						||
    -- 发送关卡通关事件
 | 
						||
--[[    Game.GlobalEvent:DispatchEvent(GameEvent.Mission.OnOpenFight, oldFight)]]
 | 
						||
    --else
 | 
						||
    --    this.curFightState = 2
 | 
						||
    --end
 | 
						||
    --end
 | 
						||
end
 | 
						||
function this.GetIsOpenRewardUpTip()
 | 
						||
    return isOpenRewardUpTip
 | 
						||
end
 | 
						||
function this.SetIsOpenRewardUpTip(_isOpenRewardUpTip)
 | 
						||
    isOpenRewardUpTip = _isOpenRewardUpTip
 | 
						||
end
 | 
						||
function this.SetChapterOpenState(state)
 | 
						||
    this.isOpenNewChapter = state
 | 
						||
    local value = state and CHATER_OPEN or CHATER_CLOSE
 | 
						||
    PlayerPrefs.SetInt(PlayerManager.uid .. CHATER_STATE, value)
 | 
						||
end
 | 
						||
 | 
						||
function this.IsChapterClossState()
 | 
						||
    if this.curOpenFight == 1011 then
 | 
						||
        return true
 | 
						||
    end
 | 
						||
 | 
						||
    this.isOpenNewChapter = PlayerPrefs.GetInt(PlayerManager.uid .. CHATER_STATE) < 1
 | 
						||
    return this.isOpenNewChapter
 | 
						||
end
 | 
						||
 | 
						||
-- 获取当前关卡的ID
 | 
						||
function this.GetCurFightId()
 | 
						||
    return this.curOpenFight
 | 
						||
end
 | 
						||
--当前关卡是否是首领关卡
 | 
						||
function this.GetCurOpenFightIdIsBoss()
 | 
						||
    local offset = 1
 | 
						||
    offset = mainLevelConfig[this.curOpenFight].Difficulty
 | 
						||
    local newFightId = (tonumber(this.curOpenFight) - offset) / 10
 | 
						||
    return (newFightId % 5) == 0
 | 
						||
end
 | 
						||
function this.GetLastFightID()
 | 
						||
    if PlayerPrefs.GetInt(PlayerManager.uid .. OLD_ID) > 0 then
 | 
						||
        this.lastPassFightId = PlayerPrefs.GetInt(PlayerManager.uid .. OLD_ID)
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
-- 获取挂机奖励vip加成
 | 
						||
function this.GetItemVipValue(itemId)
 | 
						||
    local privilege = _ItemIdToVipPrivilege[itemId]
 | 
						||
    if not privilege then return 0 end
 | 
						||
    local value = PrivilegeManager.GetPrivilegeNumber(privilege)
 | 
						||
    return value
 | 
						||
end
 | 
						||
 | 
						||
-- 点击按钮是判断是否可以挑战
 | 
						||
function this.IsCanFight(fightId)
 | 
						||
    -- 是否有数据
 | 
						||
    if not mainLevelConfig[this.curOpenFight] then
 | 
						||
        Log("没有这个关卡")
 | 
						||
        return false, Language[10616]
 | 
						||
    end
 | 
						||
 | 
						||
    --章节解锁优先
 | 
						||
    if this.IsChapterClossState() then
 | 
						||
 | 
						||
        -- 以防后端不校验,再来一次
 | 
						||
        local isOk, tip = this.CheckFightOpenRule(this.curOpenFight)
 | 
						||
        if not isOk then
 | 
						||
            Log("等级不足,无法挑战关卡")
 | 
						||
            return false, tip
 | 
						||
        else -- 等级不足未通关时设置一下
 | 
						||
            if this.curFightState == -1 then
 | 
						||
                this.curFightState = 1
 | 
						||
            end
 | 
						||
        end
 | 
						||
 | 
						||
 | 
						||
        local state = this.GetFightStateById(fightId)
 | 
						||
        if state == FIGHT_POINT_STATE.OPEN_NOT_PASS then
 | 
						||
            Log("关卡开启,未通关")
 | 
						||
            return true, Language[10617]
 | 
						||
        elseif state == FIGHT_POINT_STATE.OPEN_LOW_LEVEL then
 | 
						||
            Log("等级不足,无法挑战关卡")
 | 
						||
            return false, "关卡未满足解锁条件"--tostring(mainLevelConfig[this.curOpenFight].LevelLimit .. Language[10056])
 | 
						||
        elseif state == FIGHT_POINT_STATE.PASS then   -- 最后一关
 | 
						||
            Log("已经通关")
 | 
						||
            return false, Language[10618]
 | 
						||
        end
 | 
						||
    else
 | 
						||
        return true, Language[10619]
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
-- 检测其他关卡条件
 | 
						||
function this.CheckFightOpenRule(fightId)
 | 
						||
    if not fightId or not mainLevelConfig[fightId] then
 | 
						||
        return false, "没有这个关卡"
 | 
						||
    end
 | 
						||
 | 
						||
    if PlayerManager.level < mainLevelConfig[this.curOpenFight].LevelLimit then
 | 
						||
        local tip = tostring(mainLevelConfig[this.curOpenFight].LevelLimit .. Language[10056])
 | 
						||
        LogRed(tip .. "  当前:"..PlayerManager.level)
 | 
						||
        return false, tip
 | 
						||
    end
 | 
						||
 | 
						||
    local openRule = mainLevelConfig[fightId].OpenRule
 | 
						||
    if openRule then
 | 
						||
        local states = {}
 | 
						||
        local tips = {}
 | 
						||
        for index, rule in ipairs(openRule) do
 | 
						||
            if not rule[1] or rule[1] == 0 then
 | 
						||
                LogRed("当前:没有限制条件1")
 | 
						||
                states[index] = true
 | 
						||
            elseif rule[1] == 1 then 
 | 
						||
                local star =  FightLevelManager.GetAllChapterStars()
 | 
						||
                if star < rule[2] then
 | 
						||
                    states[index] = false
 | 
						||
                    tips[index] = string.format("山河社稷图星数达%s", rule[2])
 | 
						||
                    LogRed(tips[index]..", 当前:"..star)
 | 
						||
                end
 | 
						||
            elseif rule[1] == 2 then
 | 
						||
                local wave = MonsterCampManager.GetMonsterCampCurWave()
 | 
						||
                if wave <= rule[2] then
 | 
						||
                    states[index] = false
 | 
						||
                    tips[index] = string.format("心魔试炼通关%s层", rule[2])
 | 
						||
                    LogRed(tips[index]..", 当前:"..wave)
 | 
						||
                end
 | 
						||
            elseif rule[1] == 3 then
 | 
						||
                local lv = HarmonyManager.GetSingleAdditions(HarmonyAddType.AddLv)
 | 
						||
                if lv < rule[2] then
 | 
						||
                    states[index] = false
 | 
						||
                    tips[index] = string.format("鸿蒙阵共鸣等级达%s", rule[2])
 | 
						||
                    LogRed(tips[index]..", 当前:"..lv)
 | 
						||
                end
 | 
						||
            elseif rule[1] == 4 then
 | 
						||
                -- 指定星级(运算星级)装备数量(初始可用)
 | 
						||
                local num = EquipManager.GetLimitStarEquipNum(rule[2])
 | 
						||
                if num < rule[3] then
 | 
						||
                    local equipStarConfig = ConfigManager.GetConfigData(ConfigName.EquipStarsConfig, rule[2])
 | 
						||
                    states[index] = false
 | 
						||
                    tips[index] = string.format("拥有%s个%s%s星装备", rule[3], QualityNameDef[equipStarConfig.Quality], equipStarConfig.Stars)
 | 
						||
                    LogRed(tips[index]..", 当前:"..num)
 | 
						||
                end
 | 
						||
            elseif rule[1] == 5 then
 | 
						||
                local _, tlv, _ = LikabilityManager.GetTotalHeroLikeLv(-1)
 | 
						||
                if tlv < rule[2] then
 | 
						||
                    states[index] = false
 | 
						||
                    tips[index] = string.format("神将总好感度等级达%s", rule[2])
 | 
						||
                    LogRed(tips[index]..", 当前:"..tlv)
 | 
						||
                end
 | 
						||
            elseif rule[1] == 6 then
 | 
						||
                -- 逍遥游通关次数
 | 
						||
                local xyPassTimes = XiaoYaoManager.GetCurPassTimes()
 | 
						||
                if xyPassTimes < rule[2] then
 | 
						||
                    states[index] = false
 | 
						||
                    tips[index] = string.format("通关逍遥游%s次", rule[2])
 | 
						||
                    LogRed(tips[index]..", 当前:"..xyPassTimes)
 | 
						||
                end
 | 
						||
            elseif rule[1] == 7 then
 | 
						||
                local c_lv = rule[2]
 | 
						||
                local c_num = rule[3]
 | 
						||
                local num = #HeroManager.GetAllHeroDatas(c_lv)
 | 
						||
                if num < c_num then
 | 
						||
                    states[index] = false
 | 
						||
                    tips[index] = string.format("拥有%s个等级%s以上的神将", c_num, c_lv)
 | 
						||
                    LogRed(tips[index]..", 当前:"..num)
 | 
						||
                end
 | 
						||
            end
 | 
						||
        end
 | 
						||
        local tip = ""
 | 
						||
        local isOk = true
 | 
						||
        for index, state in pairs(states) do
 | 
						||
            if not state then
 | 
						||
                isOk = false
 | 
						||
                if tip ~= "" then
 | 
						||
                    tip = tip..string.format(",且%s", tips[index])
 | 
						||
                else
 | 
						||
                    tip = tips[index]
 | 
						||
                end
 | 
						||
            end
 | 
						||
        end
 | 
						||
        return isOk, tip.."解锁"
 | 
						||
    end
 | 
						||
    LogRed("当前:没有限制条件2")
 | 
						||
    return true
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
-- 判断是否显示关卡按钮红点
 | 
						||
function this.IsShowFightRP()
 | 
						||
    return this.IsCanFight(this.curOpenFight)
 | 
						||
end
 | 
						||
 | 
						||
-- 挑战按钮的文字显示
 | 
						||
function this.GetBtnText()
 | 
						||
    -- 解锁新章节优先
 | 
						||
    if this.IsChapterClossState() then
 | 
						||
        -- 先判断等级
 | 
						||
        local limitLevel = mainLevelConfig[this.curOpenFight].LevelLimit
 | 
						||
        if PlayerManager.level < limitLevel then
 | 
						||
            return limitLevel .. Language[10056]
 | 
						||
        end
 | 
						||
        -- 
 | 
						||
        if not this.CheckFightOpenRule(this.curOpenFight) then
 | 
						||
            return "条件未达成"
 | 
						||
        end
 | 
						||
 | 
						||
        local offset = 1
 | 
						||
        offset = mainLevelConfig[this.curOpenFight].Difficulty
 | 
						||
        local newFightId = (tonumber(this.curOpenFight) - offset) / 10
 | 
						||
        local isBoss = (newFightId % 5) == 0
 | 
						||
        local str = isBoss and Language[10531] or Language[10620]
 | 
						||
 | 
						||
        -- 最后一关
 | 
						||
        local state = this.GetFightStateById(this.curOpenFight)
 | 
						||
        if state == FIGHT_POINT_STATE.PASS then   -- 最后一关
 | 
						||
            str = Language[10621]
 | 
						||
        end
 | 
						||
        return str
 | 
						||
    else
 | 
						||
        return Language[10619]
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
-- 是不是首领关卡
 | 
						||
function this.IsFightBoss()
 | 
						||
    local offset = 1
 | 
						||
    offset = mainLevelConfig[this.curOpenFight].Difficulty
 | 
						||
    local newFightId = (tonumber(this.curOpenFight) - offset) / 10
 | 
						||
    local isBoss = (newFightId % 5) == 0
 | 
						||
    return isBoss
 | 
						||
end
 | 
						||
 | 
						||
-- 某一章节是否通关
 | 
						||
function this.IsChapterPass(areaId)
 | 
						||
    -- 当前关卡难度
 | 
						||
    local curFightDiff = mainLevelConfig[this.curOpenFight].Difficulty
 | 
						||
    -- 当前章节难度
 | 
						||
    local curChapterId = math.floor(this.curOpenFight / 1000)
 | 
						||
    if curFightDiff > 1 then
 | 
						||
        return true
 | 
						||
    elseif curFightDiff == 1 then
 | 
						||
        return areaId < curChapterId
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
--- =====================  战力相关的  =============================
 | 
						||
---- 请求战斗
 | 
						||
function this.ExecuteFightBattle(monsterGroupId, fightId, callBack)
 | 
						||
    Log("---------执行关卡战斗---------"..fightId)
 | 
						||
    NetManager.LevelStarFightDataRequest(monsterGroupId, fightId, function (msg)
 | 
						||
        hadUpdate = false
 | 
						||
        local fightData = BattleManager.GetBattleServerData(msg)
 | 
						||
        UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.STORY_FIGHT, callBack, fightId)
 | 
						||
    end)
 | 
						||
end
 | 
						||
-- 剧情关卡
 | 
						||
function this.ExecuteFightStory(fightId, func)
 | 
						||
    NetManager.LevelStarFightDataRequest("", fightId, function (msg)
 | 
						||
        NetManager.MapFightResultRequest(10000, "", fightId, BATTLE_TYPE.STORY_FIGHT, function (msg)
 | 
						||
            -- this.lastBattleResult.drop = msg.enventDrop
 | 
						||
            if func then
 | 
						||
                func(msg.enventDrop)
 | 
						||
            end
 | 
						||
        end)
 | 
						||
    end)
 | 
						||
end
 | 
						||
 | 
						||
-- 获取当前章节数
 | 
						||
function this.GetCurChapterIndex()
 | 
						||
    local curChapterId = math.floor(this.curOpenFight / 1000)
 | 
						||
    if not FightPointPassManager.isOpenNewChapter then
 | 
						||
        curChapterId = curChapterId-1
 | 
						||
        if curChapterId == 0 then
 | 
						||
            curChapterId = 1
 | 
						||
        end
 | 
						||
    end
 | 
						||
    return curChapterId
 | 
						||
end
 | 
						||
 | 
						||
-- 战斗胜利
 | 
						||
function this.OnBattleEnd(battleEnd)
 | 
						||
    if not hadUpdate then
 | 
						||
        hadUpdate = true
 | 
						||
        if battleEnd.result == 0 then
 | 
						||
            Log("关卡战斗失败!")
 | 
						||
        else
 | 
						||
            this.isBattleBack = true
 | 
						||
            --this.RefreshFightId()
 | 
						||
        end
 | 
						||
    end
 | 
						||
end
 | 
						||
 | 
						||
-- 关卡战斗结束
 | 
						||
function this.FightBattleEnd()
 | 
						||
    this.enterFightBattle = false
 | 
						||
end
 | 
						||
 | 
						||
function this.GetBattleMonsterGroup()
 | 
						||
    return mainLevelConfig[this.curOpenFight].MonsterGroup
 | 
						||
end
 | 
						||
--通过难度和章节获取该章节是否通过
 | 
						||
function this.GetDifficultAndChapter(Difficult,Chapter)
 | 
						||
    -- 当前关卡难度
 | 
						||
    local curFightDiff = mainLevelConfig[this.curOpenFight].Difficulty
 | 
						||
    -- 当前章节难度
 | 
						||
    local curChapterId = math.floor(this.curOpenFight / 1000)
 | 
						||
    local state = 0--1 未开启 2 已开启 3 未通关 4 已通关
 | 
						||
    if Difficult > curFightDiff then
 | 
						||
        state = 1
 | 
						||
    elseif Difficult == curFightDiff then
 | 
						||
        if Chapter > curChapterId then
 | 
						||
            state = 1
 | 
						||
        elseif Chapter == curChapterId then
 | 
						||
            state = 3
 | 
						||
        elseif Chapter < curChapterId then
 | 
						||
            state = 4
 | 
						||
        end
 | 
						||
    elseif Difficult < curFightDiff then
 | 
						||
        state = 4
 | 
						||
    end
 | 
						||
    return state
 | 
						||
end
 | 
						||
 | 
						||
 | 
						||
--获取立绘角色奔跑方向
 | 
						||
function this.GetRoleDirection()
 | 
						||
    local data={}
 | 
						||
    if not FightPointPassManager.IsChapterClossState() then
 | 
						||
        data=ConfigManager.GetConfigData(ConfigName.MainLevelConfig,this.lastPassFightId)
 | 
						||
    else
 | 
						||
        data=ConfigManager.GetConfigData(ConfigName.MainLevelConfig,this.curOpenFight)
 | 
						||
    end
 | 
						||
    return data.RoleDirection
 | 
						||
end
 | 
						||
 | 
						||
--获取当前关卡位置坐标
 | 
						||
function this.GetLevelPointPosition()
 | 
						||
    local data={}
 | 
						||
    if not FightPointPassManager.IsChapterClossState() then
 | 
						||
        data=ConfigManager.GetConfigData(ConfigName.MainLevelConfig,this.lastPassFightId)
 | 
						||
    else
 | 
						||
        data=ConfigManager.GetConfigData(ConfigName.MainLevelConfig,this.curOpenFight)
 | 
						||
    end
 | 
						||
    return data.LevelPointPosition
 | 
						||
end
 | 
						||
 | 
						||
--计算小地图节点坐标
 | 
						||
function this.CalculateMapPointPos(parentPoint,sonPoint)
 | 
						||
    local scaleValueX=parentPoint.localScale.x
 | 
						||
    local scaleValueY=parentPoint.localScale.y
 | 
						||
    --Log(tostring(sonPoint[1]*(-1)*scaleValueX).."  "..tostring(sonPoint[2]*(-1)*scaleValueY))
 | 
						||
    local x= math.floor(sonPoint[1]*(-1)*scaleValueX)
 | 
						||
    local y= math.floor(sonPoint[2]*(-1)*scaleValueY)
 | 
						||
    return x,y
 | 
						||
end
 | 
						||
 | 
						||
-- 活动期间关卡的总奖励预览
 | 
						||
function this.GetExtralReward()
 | 
						||
    local fightRewardId = 0
 | 
						||
    local openNum = 0
 | 
						||
    local rewardShow = {}
 | 
						||
    local rewardGroupId = {}
 | 
						||
 | 
						||
    if mainLevelConfig[this.curOpenFight] then
 | 
						||
        fightRewardId = mainLevelConfig[this.curOpenFight].RandomReward[1]
 | 
						||
    end
 | 
						||
 | 
						||
    local ids = ActivityGiftManager.GetExpertActiveisAllOpenIds()
 | 
						||
 | 
						||
    --local ids = {30, 31}
 | 
						||
 | 
						||
    if #ids > 0 then
 | 
						||
        for i = 1, #ids do
 | 
						||
            for k, v in ConfigPairs(Huo_Dong_Diao_Luo) do
 | 
						||
                if v.RewardGroup[1] == fightRewardId and v.ActivityId == ids[i] then
 | 
						||
 | 
						||
                    rewardGroupId[#rewardGroupId + 1] = v.ActivityReward[1]
 | 
						||
                end
 | 
						||
            end
 | 
						||
        end
 | 
						||
 | 
						||
        for i = 1, #rewardGroupId do
 | 
						||
            Log("活动组ID  -----  " .. rewardGroupId[i])
 | 
						||
        end
 | 
						||
        for i = 1, #rewardGroupId do
 | 
						||
            --Log("rewardGroupId  ==== " .. rewardGroupId[i])
 | 
						||
            local shows = rewardGroupConfig[rewardGroupId[i]].ShowItem
 | 
						||
            if shows then
 | 
						||
                for j = 1, #shows do
 | 
						||
                    rewardShow[#rewardShow + 1] = shows[j]
 | 
						||
                end
 | 
						||
            else
 | 
						||
                Log(string.format("奖励组Id%s对应的前端显示字段ShowItem为空", rewardGroupId[i]))
 | 
						||
            end
 | 
						||
        end
 | 
						||
 | 
						||
        --Log("活动奖励数量  === " .. #rewardShow)
 | 
						||
        return 1, rewardShow
 | 
						||
    else
 | 
						||
        return openNum, nil
 | 
						||
    end
 | 
						||
 | 
						||
end
 | 
						||
 | 
						||
function this.SetBoxState(state)
 | 
						||
    this.boxState = state
 | 
						||
end
 | 
						||
 | 
						||
function this.GetBoxState()
 | 
						||
    return this.boxState
 | 
						||
end
 | 
						||
 | 
						||
-- 是否在关卡里屏蔽暂停按钮
 | 
						||
function this.GetStopBtnState()
 | 
						||
    local isShow = true
 | 
						||
    if not this.enterFightBattle then
 | 
						||
        return true
 | 
						||
    else
 | 
						||
        if this.curOpenFight == 1011 or this.curOpenFight == 1021 or this.curOpenFight == 1031
 | 
						||
                or this.curOpenFight == 1041 or this.curOpenFight == 1051 then
 | 
						||
            isShow = false
 | 
						||
        else
 | 
						||
            isShow = true
 | 
						||
        end
 | 
						||
    end
 | 
						||
    return isShow
 | 
						||
end
 | 
						||
 | 
						||
return this |