整理一下

This commit is contained in:
chenxi 2023-04-07 15:22:56 +08:00
parent ccdd6a778b
commit 2698e4044b
64 changed files with 2237 additions and 1511 deletions

View File

@ -363,8 +363,6 @@ function table.shuffle(t)
end end
---查找一个满足条件的元素 ---查找一个满足条件的元素
---@param t table
---@param predict fun(item):boolean
function table.find(t, predict) function table.find(t, predict)
for k, v in pairs(t) do for k, v in pairs(t) do
if predict(v) then if predict(v) then
@ -374,8 +372,6 @@ function table.find(t, predict)
end end
---浅拷贝 ---浅拷贝
---@param t table
---@return table
function table.refCopy(t) function table.refCopy(t)
if not t then return nil end if not t then return nil end
local copy = {} local copy = {}

View File

@ -1,4 +1,3 @@
---@class LuaComponent
local Component = class("Component") local Component = class("Component")
function Component:ctor() function Component:ctor()

View File

@ -1,4 +1,3 @@
---@class BaseObject
local BaseObject = class("GameObject") local BaseObject = class("GameObject")
local Vector2 = BF.Vector2(0, 0) local Vector2 = BF.Vector2(0, 0)

View File

@ -1,5 +1,4 @@
local BaseObject = require "app/bf/unity/base_object" local BaseObject = require "app/bf/unity/base_object"
---@class UISpineObject : BaseObject
local UISpineObject = class("SpineObject", BaseObject) local UISpineObject = class("SpineObject", BaseObject)
local BF_UI_TOUCH_EVENT = GConst.TYPEOF_UNITY_CLASS.BF_UI_TOUCH_EVENT local BF_UI_TOUCH_EVENT = GConst.TYPEOF_UNITY_CLASS.BF_UI_TOUCH_EVENT

View File

@ -1,10 +1,8 @@
---@type BaseObject
local BaseObject = require "app/bf/unity/base_object" local BaseObject = require "app/bf/unity/base_object"
local EffectObject = require "app/bf/unity/effect_object" local EffectObject = require "app/bf/unity/effect_object"
local CharacterObject = require "app/bf/unity/character_object" local CharacterObject = require "app/bf/unity/character_object"
local UISpineObject = require "app/bf/unity/ui_spine_object" local UISpineObject = require "app/bf/unity/ui_spine_object"
local MeshSpineObject = require "app/bf/unity/mesh_spine_object" local MeshSpineObject = require "app/bf/unity/mesh_spine_object"
---@class UIPrefabObject : BaseObject
local UIPrefabObject = class("UIPrefabObject", BaseObject) local UIPrefabObject = class("UIPrefabObject", BaseObject)
local BF_PREFAB_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_PREFAB_HELPER local BF_PREFAB_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_PREFAB_HELPER
@ -711,7 +709,6 @@ function UIPrefabObject:addRedPoint(offsetX, offsetY, scale, iconName, count, na
if not self.loadRpOver then if not self.loadRpOver then
self.loadRpOver = true self.loadRpOver = true
UIPrefabManager:loadUIWidgetAsync("assets/prefabs/ui/common/red_point_cell.prefab", self, function(prefabObject) UIPrefabManager:loadUIWidgetAsync("assets/prefabs/ui/common/red_point_cell.prefab", self, function(prefabObject)
---@type UIPrefabObject
self.redPoint = prefabObject self.redPoint = prefabObject
prefabObject:initPrefabHelper() prefabObject:initPrefabHelper()
local uiMap = prefabObject:genAllChildren() local uiMap = prefabObject:genAllChildren()

View File

@ -349,6 +349,23 @@ function BIReport:postTutorialStep(id)
self:report(EVENT_NAME_TUTORIAL, args) self:report(EVENT_NAME_TUTORIAL, args)
end end
-- 首页按钮点击
function BIReport:postHomeBtnCilck(clickType)
-- -- Type 点击位置 点击首页按钮时 String "Shop=商店、Equip=装备界面、Home=首页、Level=关卡按钮、ChangeLevel=切换关卡、
-- -- Talent=天赋界面、LevelBox=关卡宝箱"
-- -- IsNew 是否是新用户 Boolean 是否为当天新用户True = 是False = 否
-- -- MaxChapter 最大章节 Int 已解锁的最大章节
-- -- Chapter 章节id Int 当前停留的章节id
-- local chapterId = DataManager.StageData:getChapterId()
-- local args = {
-- type = clickType, -- 宝箱类型
-- chapter = chapterId, -- 章节
-- max_chapter = DataManager.StageData:getNewChapterId(),
-- }
-- self:report(EVENT_NAME_CLICK_HOME_BTN, args)
-- BIReport:printArgsStr(EVENT_NAME_CLICK_HOME_BTN, args)
end
-- Lua crash -- Lua crash
function BIReport:postLuaCrash(logString, stackTrace) function BIReport:postLuaCrash(logString, stackTrace)
local msg = logString .. stackTrace local msg = logString .. stackTrace

View File

@ -61,46 +61,46 @@ function ConfigManager:reloadAllConfig()
end end
function ConfigManager:preLoadConfig() function ConfigManager:preLoadConfig()
local monsterBase = self:_getConfig("monster_base") -- local monsterBase = self:_getConfig("monster_base")
self:clearConfigCache("monster_base") -- self:clearConfigCache("monster_base")
local baseData = monsterBase.data -- local baseData = monsterBase.data
local monsterFullData = {} -- local monsterFullData = {}
local count = 0 -- local count = 0
local function handleMonsterGrow(name) -- local function handleMonsterGrow(name)
local monsterGrowConfig = self:_getConfig(name) -- local monsterGrowConfig = self:_getConfig(name)
local growData = monsterGrowConfig.data -- local growData = monsterGrowConfig.data
for k, v in pairs(growData) do -- for k, v in pairs(growData) do
monsterFullData[k] = v -- monsterFullData[k] = v
local data = baseData[v.monster_baseid] -- local data = baseData[v.monster_baseid]
if data then -- if data then
monsterFullData[k].collision_radius = data.collision_radius -- monsterFullData[k].collision_radius = data.collision_radius
monsterFullData[k].model_id = data.model_id -- monsterFullData[k].model_id = data.model_id
monsterFullData[k].model_fight = data.model_fight -- monsterFullData[k].model_fight = data.model_fight
monsterFullData[k].fx_fight = data.fx_fight -- monsterFullData[k].fx_fight = data.fx_fight
monsterFullData[k].size = data.size -- monsterFullData[k].size = data.size
-- else -- -- else
-- Logger.logHighlight("not data monster_baseid = " .. v.monster_baseid) -- -- Logger.logHighlight("not data monster_baseid = " .. v.monster_baseid)
end -- end
count = count + 1 -- count = count + 1
end -- end
self:clearConfigCache(name) -- self:clearConfigCache(name)
end -- end
handleMonsterGrow("monster_stage") -- handleMonsterGrow("monster_stage")
self.configs["monster"] = { -- self.configs["monster"] = {
data = monsterFullData, -- data = monsterFullData,
count = count -- count = count
} -- }
if EDITOR_MODE then -- if EDITOR_MODE then
local realCount = 0 -- local realCount = 0
for k, v in pairs(monsterFullData) do -- for k, v in pairs(monsterFullData) do
realCount = realCount + 1 -- realCount = realCount + 1
end -- end
if count ~= realCount then -- if count ~= realCount then
Logger.logFatal("same id in monster config") -- Logger.logFatal("same id in monster config")
end -- end
end -- end
end end
function ConfigManager:getChapterConfig(id) function ConfigManager:getChapterConfig(id)

View File

@ -1,4 +1,3 @@
---@class DataManager
local DataManager = { local DataManager = {
initByServer = false initByServer = false
} }
@ -8,6 +7,9 @@ function DataManager:init()
self._cacheManager = {} self._cacheManager = {}
-- self:initManager("BagData", "app/userdata/bag/bag_data") -- self:initManager("BagData", "app/userdata/bag/bag_data")
-- self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data") -- self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
self:initManager("PlayerData", "app/userdata/player/player_data")
self:initManager("StageData", "app/userdata/stage/stage_data")
self:initManager("HeroData", "app/userdata/hero/hero_data")
self:initManager("BattleData", "app/userdata/battle/battle_data") self:initManager("BattleData", "app/userdata/battle/battle_data")
end end
@ -65,6 +67,7 @@ function DataManager:clear()
self.cdCallBack = {} self.cdCallBack = {}
-- self.BagData:clear() -- self.BagData:clear()
-- self.TutorialData:clear() -- self.TutorialData:clear()
self.PlayerData:clear()
self.BattleData:clear() self.BattleData:clear()
ModuleManager.TaskManager:clear() ModuleManager.TaskManager:clear()
@ -75,24 +78,12 @@ function DataManager:initWithServerData(data)
Logger.logHighlight("------------------initWithServerData-----------------------") Logger.logHighlight("------------------initWithServerData-----------------------")
Logger.printTable(data) Logger.printTable(data)
Time:setServerTimeZone(0) Time:setServerTimeZone(0)
Time:updateServerTime(data.now_ts)
Time:updateServerTimeToday(data.today_ts)
self.initWithServer = true self.initWithServer = true
self.signInfo = data.sign
self.todayFirstLogin = data.today_first_login
self.serverAttr = data.attrs
self.registerTs = (data.stat.register_ts or 0) // 1000
data.heros = {
{cfg_id = 60001, lv = 4, curHid = 60001}
}
-- self.BagData:init(data.bag) self.PlayerData:init(data.PlayerData)
self:scheduleGlobal() self:scheduleGlobal()
self:checkDataBind() self:checkDataBind()
-- 检查属性是否和服务器一致
GFunc.checkAttrWhitServerAttr()
end end
function DataManager:onServerTimeBack(serverTime, loginCount, loginTime) function DataManager:onServerTimeBack(serverTime, loginCount, loginTime)

View File

@ -38,9 +38,7 @@ function DOTweenManager:createSeqWithGameObject(gameObject)
return seq return seq
end end
---@param trans UnityEngine.Transform
function DOTweenManager:doScale(trans,endValue, duration,onComplete) function DOTweenManager:doScale(trans,endValue, duration,onComplete)
---@type DG.Tweening.Tweener
local tween = trans:DOScale(endValue, duration) local tween = trans:DOScale(endValue, duration)
tween.onComplete = function() tween.onComplete = function()
if onComplete then if onComplete then

View File

@ -25,6 +25,7 @@ local LOCAL_DATA_KEY = {
SHAKE_MODE = "SHAKE_MODE", -- 震动模式 SHAKE_MODE = "SHAKE_MODE", -- 震动模式
SAVE_POWER_MODE = "SAVE_POWER_MODE", -- 省电模式 SAVE_POWER_MODE = "SAVE_POWER_MODE", -- 省电模式
LAST_MAIL_ID = "LAST_MAIL_ID", LAST_MAIL_ID = "LAST_MAIL_ID",
IS_NEW_PLAYER = "IS_NEW_PLAYER",
} }
LocalData.KEYS = LOCAL_DATA_KEY LocalData.KEYS = LOCAL_DATA_KEY
@ -310,4 +311,12 @@ function LocalData:getLastLoginIp()
return self:getString(LOCAL_DATA_KEY.LAST_LOGIN_IP, "") return self:getString(LOCAL_DATA_KEY.LAST_LOGIN_IP, "")
end end
function LocalData:getIsNewPlayer()
return self:getInt(LOCAL_DATA_KEY.IS_NEW_PLAYER, 0) == 0
end
function LocalData:setNotNewPlayer()
return self:setInt(LOCAL_DATA_KEY.IS_NEW_PLAYER, 1)
end
return LocalData return LocalData

View File

@ -83,6 +83,8 @@ function Game:initOther()
BF.exports.SafeAreaManager = require "app/common/safe_area_manager" BF.exports.SafeAreaManager = require "app/common/safe_area_manager"
BF.exports.BaseModule = require "app/module/base_module" BF.exports.BaseModule = require "app/module/base_module"
BF.exports.ModuleManager = require "app/common/module_manager" BF.exports.ModuleManager = require "app/common/module_manager"
BF.exports.ServerBaseData = require "app/server/data/server_base_data"
BF.exports.ServerDataManager = require "app/server/server_data_manager"
BF.exports.DataManager = require "app/common/data_manager" BF.exports.DataManager = require "app/common/data_manager"
BF.exports.DOTweenManager = require "app/common/dotween_manager" BF.exports.DOTweenManager = require "app/common/dotween_manager"
BF.exports.FSMManager = require "app/common/state_machine_manager" BF.exports.FSMManager = require "app/common/state_machine_manager"
@ -90,12 +92,12 @@ function Game:initOther()
BF.exports.SDKManager = require "app/common/sdk_manager" BF.exports.SDKManager = require "app/common/sdk_manager"
BF.exports.DeviceHelper = require "app/common/device_helper" BF.exports.DeviceHelper = require "app/common/device_helper"
BF.exports.PayManager = require "app/common/pay_manager" BF.exports.PayManager = require "app/common/pay_manager"
BF.exports.BigNumOpt = require "app/tools/big_num_opt"
CameraManager:init() CameraManager:init()
WebRequestManager:init() WebRequestManager:init()
NetManager:init() NetManager:init()
I18N:init() I18N:init()
ServerDataManager:init()
DataManager:init() DataManager:init()
DOTweenManager:init() DOTweenManager:init()
ModuleManager:init() ModuleManager:init()
@ -151,6 +153,8 @@ function Game:specialForIdea()
SafeAreaManager = SafeAreaManager or require "app/common/safe_area_manager" SafeAreaManager = SafeAreaManager or require "app/common/safe_area_manager"
BaseModule = BaseModule or require "app/module/base_module" BaseModule = BaseModule or require "app/module/base_module"
ModuleManager = ModuleManager or require "app/common/module_manager" ModuleManager = ModuleManager or require "app/common/module_manager"
ServerBaseData = ServerBaseData or require "app/server/data/server_base_data"
ServerDataManager = ServerDataManager or require "app/server/server_data_manager"
DataManager = DataManager or require "app/common/data_manager" DataManager = DataManager or require "app/common/data_manager"
DOTweenManager = DOTweenManager or require "app/common/dotween_manager" DOTweenManager = DOTweenManager or require "app/common/dotween_manager"
FSMManager = FSMManager or require "app/common/state_machine_manager" FSMManager = FSMManager or require "app/common/state_machine_manager"
@ -158,7 +162,6 @@ function Game:specialForIdea()
SDKManager = SDKManager or require "app/common/sdk_manager" SDKManager = SDKManager or require "app/common/sdk_manager"
DeviceHelper = DeviceHelper or require "app/common/device_helper" DeviceHelper = DeviceHelper or require "app/common/device_helper"
PayManager = PayManager or require "app/common/pay_manager" PayManager = PayManager or require "app/common/pay_manager"
BigNumOpt = BigNumOpt or require "app/tools/big_num_opt"
end end
end end

View File

@ -1,6 +1,8 @@
local GConst = {} local GConst = {}
local CONST_PATHS = { local CONST_PATHS = {
ServerDataConst = "app/server/server_data_const",
StageConst = "app/module/stage/stage_const",
ItemConst = "app/module/item/item_const", ItemConst = "app/module/item/item_const",
TaskConst = "app/module/task/task_const", TaskConst = "app/module/task/task_const",
MainCityConst = "app/module/maincity/maincity_const", MainCityConst = "app/module/maincity/maincity_const",

View File

@ -402,52 +402,6 @@ end
-- end -- end
-- end -- end
function GFunc.getFinalAttr(key, value)
if key == GConst.ATTR_TYPE.crit or
key == GConst.ATTR_TYPE.crit_time or
-- key == GConst.ATTR_TYPE.atk_range or
key == GConst.ATTR_TYPE.atkp_1 or
key == GConst.ATTR_TYPE.atkp_2 or
key == GConst.ATTR_TYPE.atkp_3 or
key == GConst.ATTR_TYPE.atkp_4 or
key == GConst.ATTR_TYPE.atkp_5 or
key == GConst.ATTR_TYPE.atkp_6 or
key == GConst.ATTR_TYPE.hpp_1 or
key == GConst.ATTR_TYPE.hpp_2 or
key == GConst.ATTR_TYPE.hpp_3 or
key == GConst.ATTR_TYPE.hpp_4 or
key == GConst.ATTR_TYPE.hpp_5 or
key == GConst.ATTR_TYPE.hpp_6 or
key == GConst.ATTR_TYPE.hpp_7 or
key == GConst.ATTR_TYPE.atkp_7 or
key == GConst.ATTR_TYPE.atkp_8 or
key == GConst.ATTR_TYPE.atkp_9 or
-- key == GConst.ATTR_TYPE.spdp or
key == GConst.ATTR_TYPE.gold_gain or
key == GConst.ATTR_TYPE.dmg_addition_skill or
key == GConst.ATTR_TYPE.dmg_addition_normal or
key == GConst.ATTR_TYPE.pickaxe_recover_spd or
key == GConst.ATTR_TYPE.mineral_gain or
key == GConst.ATTR_TYPE.research_spd or
key == GConst.ATTR_TYPE.dmg_addition or
key == GConst.ATTR_TYPE.dmg_addition_poicon or
-- key == GConst.ATTR_TYPE.atkp_0 or
key == GConst.ATTR_TYPE.airborne_damage or
-- key == GConst.ATTR_TYPE.skill_all_damage or
-- key == GConst.ATTR_TYPE.skill_1_damage or
-- key == GConst.ATTR_TYPE.skill_2_damage or
-- key == GConst.ATTR_TYPE.skill_3_damage or
-- key == GConst.ATTR_TYPE.attack_damage or
key == GConst.ATTR_TYPE.miss or
key == GConst.ATTR_TYPE.dmg_dec_all or
key == GConst.ATTR_TYPE.idle_income
then
return BigNumOpt.bigNumDiv(value, {value = 100, unit = 0})
else
return BigNumOpt.bigNumDiv(value, {value = 10000, unit = 0})
end
end
function GFunc.getPerStr(key, str) function GFunc.getPerStr(key, str)
if key == GConst.ATTR_TYPE.crit or if key == GConst.ATTR_TYPE.crit or
key == GConst.ATTR_TYPE.crit_time or key == GConst.ATTR_TYPE.crit_time or
@ -493,32 +447,10 @@ function GFunc.getPerStr(key, str)
return str return str
end end
function GFunc.getFinalPerStr(typeId, bigNum)
return GFunc.getPerStr(typeId, BigNumOpt.bigNum2Str(GFunc.getFinalAttr(typeId, bigNum)))
end
function GFunc.getAttrName(key) function GFunc.getAttrName(key)
return I18N:getText("attr", key, "name") return I18N:getText("attr", key, "name")
end end
function GFunc.getAttrNameAndValue(attrStruct, colorCode)
local finalStr = BigNumOpt.bigNumCfgAttr2FinalValueStr(attrStruct)
if colorCode then
finalStr = string.format("<color=%s>%s</color>", colorCode, finalStr)
end
local str = GFunc.getAttrName(GConst.ATTR_TYPE[attrStruct.type]) .. "+" .. finalStr
return str
end
function GFunc.getAttrNameAndValue2(attrType, attrBigNum, colorCode)
local finalStr = BigNumOpt.bigNumCfgAttr2FinalValueStr2(GConst.ATTR_TYPE[attrType], attrBigNum)
if colorCode then
finalStr = string.format("<color=%s>%s</color>", colorCode, finalStr)
end
local str = GFunc.getAttrName(GConst.ATTR_TYPE[attrType]) .. "+" .. finalStr
return str
end
function GFunc.getTimeStrWithMS(time) function GFunc.getTimeStrWithMS(time)
local m = math.floor(time/60) local m = math.floor(time/60)
local s = time%60 local s = time%60
@ -679,22 +611,6 @@ function GFunc.showJewelryNotEnough(itemId)
end end
end end
function GFunc.checkCost(id, num, showToast, giftType)
if num.value <= 0 then
BIReport:postDataException(id, num.value, giftType)
return false
end
local bigNum = DataManager.BagData.ItemData:getItemBigNumById(id)
if BigNumOpt.bigNumCompare(bigNum, num) < 0 then
if showToast then
GFunc.showItemNotEnough(id)
end
return false
else
return true
end
end
function GFunc.checkCostNum(id, num, giftType) function GFunc.checkCostNum(id, num, giftType)
if num <= 0 then if num <= 0 then
BIReport:postDataException(id, num, giftType) BIReport:postDataException(id, num, giftType)
@ -794,27 +710,6 @@ function GFunc.showRewardBox(rewards, extParams, callback)
ModuleManager.TipsManager:showRewardsBox(params) ModuleManager.TipsManager:showRewardsBox(params)
end end
function GFunc.mergeRewards2(rewards, newRewards)
local items = {}
for i,v in ipairs(rewards) do
if v.type == GConst.REWARD_TYPE.ITEM then
if not items[v.item.id] then
items[v.item.id] = BigNumOpt.num2BigNum(0)
end
items[v.item.id] = BigNumOpt.bigNumAdd(items[v.item.id], v.item.count)
elseif v.type == GConst.REWARD_TYPE.EQUIP then
table.insert(newRewards, v)
elseif v.type == GConst.REWARD_TYPE.LEGACY then
table.insert(newRewards, v)
elseif v.type == GConst.REWARD_TYPE.RUNES then
table.insert(newRewards, v)
end
end
for k,v in pairs(items) do
table.insert(newRewards, {type = GConst.REWARD_TYPE.ITEM, item = {id = k, count = v}})
end
end
-- reward 结构为 type id num 配置中结构 -- reward 结构为 type id num 配置中结构
function GFunc.mergeRewards(rewards) function GFunc.mergeRewards(rewards)
local items = {} local items = {}
@ -941,7 +836,6 @@ function GFunc.getShakeSeq2(obj, onlyKill, originScale, notForcerefresh)
return obj.shakeSeq return obj.shakeSeq
end end
---@param obj UIPrefabObject
function GFunc.getShakeSeqRotate(obj, onlyKill, notForcerefresh) function GFunc.getShakeSeqRotate(obj, onlyKill, notForcerefresh)
if obj.shakeSeq then if obj.shakeSeq then
if notForcerefresh then if notForcerefresh then
@ -954,7 +848,6 @@ function GFunc.getShakeSeqRotate(obj, onlyKill, notForcerefresh)
if onlyKill then if onlyKill then
return return
end end
---@type UnityEngine.Transform
local objTrans = obj:getTransform() local objTrans = obj:getTransform()
obj.shakeSeq = obj:createBindTweenSequence() obj.shakeSeq = obj:createBindTweenSequence()
obj.shakeSeq:AppendInterval(2) obj.shakeSeq:AppendInterval(2)
@ -976,7 +869,6 @@ function GFunc.getScaleQueueAni(root, rewardList, listCell, callBack)
root.aniSeq = nil root.aniSeq = nil
end end
root.aniSeq = root:createBindTweenSequence() root.aniSeq = root:createBindTweenSequence()
---@type DG.Tweening.Sequence
local seq = root.aniSeq local seq = root.aniSeq
local groupCell = {} local groupCell = {}
local index = 1 local index = 1
@ -993,12 +885,10 @@ function GFunc.getScaleQueueAni(root, rewardList, listCell, callBack)
table.insert(groupCell[index], cell) table.insert(groupCell[index], cell)
end) end)
---@type UnityEngine.Transform
local rewardListTrans = rewardList:getTransform() local rewardListTrans = rewardList:getTransform()
-- ani -- ani
table.foreach(groupCell, function(row, cells) table.foreach(groupCell, function(row, cells)
table.foreach(cells, function(k, cell) table.foreach(cells, function(k, cell)
---@type SummonRewardCell
local summonRewardCell = cell local summonRewardCell = cell
local rewardType, id = summonRewardCell:getReward() local rewardType, id = summonRewardCell:getReward()
summonRewardCell:showMask() summonRewardCell:showMask()
@ -1027,7 +917,6 @@ function GFunc.getScaleQueueAni(root, rewardList, listCell, callBack)
return seq return seq
end end
---@param obj UIPrefabObject
function GFunc.miningTipsMovePosY(obj, delay,callBack) function GFunc.miningTipsMovePosY(obj, delay,callBack)
if obj.seq then if obj.seq then
obj.seq:Kill() obj.seq:Kill()
@ -1035,11 +924,9 @@ function GFunc.miningTipsMovePosY(obj, delay,callBack)
end end
obj.seq = obj:createBindTweenSequence() obj.seq = obj:createBindTweenSequence()
---@type UnityEngine.Transform
local trans = obj:getTransform() local trans = obj:getTransform()
local localPosY = trans.localPosition.y local localPosY = trans.localPosition.y
---@type DG.Tweening.Sequence
local seq = obj.seq local seq = obj.seq
seq:AppendInterval(delay) seq:AppendInterval(delay)
seq:Append(trans:DOLocalMoveY(localPosY + 200, 1.2)) seq:Append(trans:DOLocalMoveY(localPosY + 200, 1.2))
@ -1462,11 +1349,7 @@ function GFunc.doScaleQuickZoom(img,callback)
if img.aniSeq then if img.aniSeq then
img.aniSeq:Kill() img.aniSeq:Kill()
end end
---@type UnityEngine.Transform
local transform = img:getTransform() local transform = img:getTransform()
local localScale = transform.localScale
local scale = 1
---@type DG.Tweening.Sequence
local aniSeq = img:createBindTweenSequence() local aniSeq = img:createBindTweenSequence()
aniSeq:Append(transform:DOScale(1.4, 0.1)) aniSeq:Append(transform:DOScale(1.4, 0.1))
aniSeq:Append(transform:DOScale(1, 0.06)) aniSeq:Append(transform:DOScale(1, 0.06))
@ -1572,9 +1455,6 @@ function GFunc.getCostContentWithColor(key)
return content return content
end end
---@param txtObj UIPrefabObject 文本对象
---@param icon UIPrefabObject 图片对象
---@param bgImg UIPrefabObject 背景图片
---设置图片和文本居中, 文本需要左右居中对齐 ---设置图片和文本居中, 文本需要左右居中对齐
function GFunc.setMiddlePosX(txtObj, icon, bgImg) function GFunc.setMiddlePosX(txtObj, icon, bgImg)
local txtRectWidth = txtObj:getTransform().rect.width local txtRectWidth = txtObj:getTransform().rect.width
@ -1674,21 +1554,6 @@ function GFunc.getServerRewardTable(type, id, count)
end end
end end
function GFunc.getServerItemRewardTable(id, count)
local reward = {
type = GConst.REWARD_TYPE.ITEM,
item = {
id = id,
count = {
unit = count.unit,
value = count.value,
}
},
}
BigNumOpt.adjustRealBigNum(reward.item.count)
return reward
end
function GFunc.getServerRuneRewardTable(id, level) function GFunc.getServerRuneRewardTable(id, level)
return { return {
type = GConst.REWARD_TYPE.RUNES, type = GConst.REWARD_TYPE.RUNES,
@ -1736,18 +1601,6 @@ function GFunc.checkTableValueSame(standardTable, compareTable, debug)
return true return true
end end
function GFunc.getRealItemAddChange(itemId, bigNum)
local hadBigNum = DataManager.BagData.ItemData:getItemBigNumById(itemId)
local addBigNum = BigNumOpt.bigNumAdd(hadBigNum, bigNum)
return BigNumOpt.bigNumSub(addBigNum, hadBigNum)
end
function GFunc.getRealItemSubChange(itemId, bigNum)
local hadBigNum = DataManager.BagData.ItemData:getItemBigNumById(itemId)
local subBigNum = BigNumOpt.bigNumSub(hadBigNum, bigNum)
return BigNumOpt.bigNumSub(hadBigNum, subBigNum)
end
-- 获取挖矿研究得到的属性加成 -- 获取挖矿研究得到的属性加成
function GFunc.getMainHeroAttributeVal(key) function GFunc.getMainHeroAttributeVal(key)
local mainEntity = DataManager.HeroData:getMainHeroEntity() local mainEntity = DataManager.HeroData:getMainHeroEntity()
@ -1756,27 +1609,6 @@ function GFunc.getMainHeroAttributeVal(key)
return result return result
end end
function GFunc.checkAttrWhitServerAttr()
if not DataManager.serverAttr or (not DataManager.serverAttr.attr_set) then
return
end
table.foreach(DataManager.serverAttr.attr_set, function(id, val)
local playerAttr = GFunc.getMainHeroAttributeVal(id)
if not playerAttr then
Logger.logHighlight("玩家没有属性:"..id)
return
end
--playerAttr = BigNumOpt.bigNumDivNum(playerAttr, 10000)
if BigNumOpt.bigNumCompare(playerAttr, val) ~= 0 then
Logger.logError("属性不一致ID"..id.." PlayerVal:"..BigNumOpt.bigNum2Str(playerAttr).." ServerVal:"..BigNumOpt.bigNum2Str(val))
else
Logger.logHighlight("属性一致ID"..id.." val: "..BigNumOpt.bigNum2Str(val))
end
end)
end
function GFunc.showCurrencyFlyAction(rewards, pos) function GFunc.showCurrencyFlyAction(rewards, pos)
local flyPos = {} local flyPos = {}
if not pos then if not pos then
@ -1799,14 +1631,6 @@ function GFunc.showCurrencyFlyAction(rewards, pos)
UIManager:showCurrencyAction(flyPos) UIManager:showCurrencyAction(flyPos)
end end
function GFunc.getItemRewardNum(reward)
local type = ConfigManager:getConfig("item")[reward.id].type
if type == 6 then
return BigNumOpt.bigNum2Num(reward.count)
end
return BigNumOpt.bigNum2Str(reward.count)
end
function GFunc.getSkillEffectStr(id, lv) function GFunc.getSkillEffectStr(id, lv)
local str = I18N:getText("skill", id, "desc") local str = I18N:getText("skill", id, "desc")
local cfg = ConfigManager:getConfig("skill")[id] local cfg = ConfigManager:getConfig("skill")[id]
@ -1825,6 +1649,51 @@ function GFunc.getSkillEffectStr(id, lv)
return str return str
end end
function GFunc.goTargetElasticityY(obj, onlyKill, offset, punchY, callBack)
if obj.shakeSeq then
obj.shakeSeq:Kill()
obj.shakeSeq = nil
end
if onlyKill then
return
end
local curPosY = obj:getAnchoredPositionY()
local objTrans = obj:getTransform()
obj.shakeSeq = obj:createBindTweenSequence()
obj.shakeSeq:Append(objTrans:DOLocalMoveY(curPosY - offset / 2,0.1))
obj.shakeSeq:Append(objTrans:DOLocalMoveY(curPosY + offset * 2 ,0.1))
obj.shakeSeq:Join(objTrans:DOPunchScale({x=0,y=punchY,z = 0},0.2, 6))
obj.shakeSeq:AppendCallback(function()
if callBack then
callBack()
end
end)
return obj.shakeSeq
end
function GFunc.goTargetPosXShake(obj, onlyKill, targetX, offset, callBack)
if obj.shakeSeq then
obj.shakeSeq:Kill()
obj.shakeSeq = nil
end
if onlyKill then
return
end
obj.shakeSeq = obj:createBindTweenSequence()
local objTrans = obj:getTransform()
local seq = obj.shakeSeq
seq:Append(objTrans:DOLocalMoveX(targetX,0.12))
seq:Append(objTrans:DOLocalMoveX(targetX + offset,0.1))
seq:Append(objTrans:DOLocalMoveX(targetX - offset / 3,0.05))
seq:Append(objTrans:DOLocalMoveX(targetX, 0.1))
seq:AppendCallback(function()
if callBack then
callBack()
end
end)
return obj.shakeSeq
end
--[[ --[[
tabLe只速 Lua error tabLe只速 Lua error
locaL readOnlyCfg = GFunc.readOnlyTab(cfg) return readOnlyCfg locaL readOnlyCfg = GFunc.readOnlyTab(cfg) return readOnlyCfg
@ -1869,13 +1738,4 @@ function GFunc.readOnlyTab(inputTable)
return _read_only(inputTable) return _read_only(inputTable)
end end
function GFunc.getItemNumStr(itemID)
local bigNum = DataManager.BagData.ItemData:getItemBigNumById(itemID)
local itemCfg = ConfigManager:getConfig("item")[itemID]
if itemCfg.type == 6 then
return BigNumOpt.bigNum2Num(bigNum)
end
return BigNumOpt.bigNum2Str(bigNum)
end
return GFunc return GFunc

View File

@ -1,4 +1,3 @@
---@class BaseModule
local BaseModule = class("BaseModule") local BaseModule = class("BaseModule")
function BaseModule:scheduleGlobal(func, inter) function BaseModule:scheduleGlobal(func, inter)

View File

@ -1,4 +1,3 @@
---@class LoginManager : BaseModule
local LoginManager = class("LoginManager", BaseModule) local LoginManager = class("LoginManager", BaseModule)
LoginManager.TRY_LOGIN_TIME = 5 LoginManager.TRY_LOGIN_TIME = 5
@ -20,7 +19,20 @@ end
---- 登录界面资源加载完毕后调用 ---- 登录界面资源加载完毕后调用
function LoginManager:loginGame() function LoginManager:loginGame()
BIReport:postAdjustSimpleTrackEvent("modt3z", {}) BIReport:postAdjustSimpleTrackEvent("modt3z", {})
CS.BF.BFMain.IsGotServerTime = true
ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA, GConst.EMPTY_TABLE, function(msgData)
DataManager:initWithServerData(msgData)
ConfigManager:preLoadConfig()
ModuleManager.MaincityManager:firstEnterMainCity() ModuleManager.MaincityManager:firstEnterMainCity()
-- local data = {}
-- data.max_chapter = DataManager.StageData:getNewChapterId()
-- data.ads_num = DataManager.PlayerData:getAdCount()
-- data.pay_money = DataManager.PlayerData:getPaymentCount()
-- data.play_days = DataManager:getLoginCount()
-- data.now_version = Platform:getClientVersion()
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
end)
end end
function LoginManager:goToLoginScene() function LoginManager:goToLoginScene()

View File

@ -1,6 +1,8 @@
local MainCityConst = {} local MainCityConst = {}
MainCityConst.BOTTOM_PAGE = { MainCityConst.BOTTOM_PAGE = {
MAIN = 1,
HERO = 2,
} }
MainCityConst.BOTTOM_ICON = { MainCityConst.BOTTOM_ICON = {
@ -12,6 +14,6 @@ MainCityConst.BOTTOM_CLOSE_ICON = {
MainCityConst.BOTTOM_MODULE_KEY = { MainCityConst.BOTTOM_MODULE_KEY = {
} }
MainCityConst.BOTTOM_COUNT = 5 MainCityConst.BOTTOM_COUNT = 2
return MainCityConst return MainCityConst

View File

@ -1,10 +1,7 @@
---@class MaincityManager : BaseModule
local MaincityManager = class("MaincityManager", BaseModule) local MaincityManager = class("MaincityManager", BaseModule)
function MaincityManager:showMainCityUI(isFirstEnter, targetIndex) function MaincityManager:showMainCityUI(isFirstEnter, targetIndex)
-- local uiObj = UIManager:showUI(UIManager.UI_PATH.MAINCITY_UI, {isFirstEnter = isFirstEnter, targetIndex = targetIndex}) UIManager:showUI(UIManager.UI_PATH.MAINCITY_UI, {isFirstEnter = isFirstEnter, targetIndex = targetIndex})
-- return uiObj
ModuleManager.BattleManager:playBattle()
end end
-- 从登录界面第一次进入主城 -- 从登录界面第一次进入主城

View File

@ -0,0 +1,10 @@
local StageConst = {}
StageConst.CHAPTER_PATTERN = {
NORMAL = 1,
HARD = 2
}
StageConst.SHOW_RATE_CHAPTER_ID = 101
return StageConst

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 921daa56364e033428a006b33acc2f0f guid: 84f4fb969e00f714e87581c4d9a63b9d
ScriptedImporter: ScriptedImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}

View File

@ -1,4 +1,3 @@
---@class TipsManager : BaseModule
local TipsManager = class("TipsManager", BaseModule) local TipsManager = class("TipsManager", BaseModule)
TipsManager.ALIGN_TYPE = { TipsManager.ALIGN_TYPE = {

8
lua/app/server.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 62ee7f8438dd807449866595e04c6600
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
lua/app/server/data.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f37c247985544954bbcd2f09de7728d8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,76 @@
local ServerBaseData = class("ServerBaseData")
function ServerBaseData:ctor(...)
self.data = {}
self.data.__parent = self
local innerData = nil
innerData = {
__index = function (t, key)
return innerData[key]
end,
__newindex = function (t, key, value)
innerData[key] = value
end
}
setmetatable(self.data, innerData)
end
function ServerBaseData:_loadLocalData()
local data = LocalData:getString("ServerBaseData_" .. self.__cname, "")
local innerData = getmetatable(self.data)
local dataObj = nil
if data and data ~= "" then
dataObj = json.decode(data)
end
for k, v in pairs(innerData) do
innerData[k] = nil
end
if dataObj then
for k, v in pairs(dataObj) do
innerData[k] = v
end
end
end
function ServerBaseData:_loadNewPlayerData()
local innerData = getmetatable(self.data)
for k, v in pairs(innerData) do
innerData[k] = nil
end
local dataObj = self:getNewPlayerData()
if dataObj then
for k, v in pairs(dataObj) do
innerData[k] = v
end
end
end
function ServerBaseData:getNewPlayerData()
return nil
end
function ServerBaseData:getCloneData()
local cloneData = {}
local function _copy(object)
if type(object) ~= "table" then
return object
elseif cloneData[object] then
return cloneData[object]
end
local newObject = {}
cloneData[object] = newObject
for key, value in pairs(object) do
newObject[_copy(key)] = _copy(value)
end
return newObject
end
local innerData = getmetatable(self.data)
return _copy(innerData)
end
function ServerBaseData:clone()
end
return ServerBaseData

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 11acdf377de3ae442bbe3d89ecc1a549 guid: 8b88996eb5328d742b2a198434cabef1
ScriptedImporter: ScriptedImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}

View File

@ -0,0 +1,3 @@
local ServerPlayerData = class("ServerPlayerData", ServerBaseData)
return ServerPlayerData

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: f716e0ddf57b1b849b187b434b31f4dc guid: e1a04f57465c5be4882f1efdec828dc2
ScriptedImporter: ScriptedImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}

View File

@ -0,0 +1,9 @@
local ServerDataConst = {}
ServerDataConst.DATA_OP_BEHAVIOR = {
SYNC_DATA = "SYNC_DATA",
CROSS_DAY = "CROSS_DAY",
}
return ServerDataConst

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 8af3001c06ad5ab44ba95cb6a2486229
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,34 @@
local ServerGameData = require "app/server/server_game_data"
local ServerDataManager = {}
function ServerDataManager:init()
end
function ServerDataManager:dataOperate(behavior, params, callback)
local opFunc = ServerDataManager.OP_FUNC[behavior]
if opFunc then
opFunc(params, function(result)
if callback then
callback(result)
end
end)
else
Logger.logError("Undefined data operation function, please check :%s", behavior)
end
end
function ServerDataManager:onSyncData(params, callback)
-- 初始化本地数据
ServerGameData:initData()
local data = ServerGameData:getData()
if callback then
callback(data)
end
end
ServerDataManager.OP_FUNC = {
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA] = function (...) ServerDataManager:onSyncData(...) end,
}
return ServerDataManager

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 46cc0de161cb26d4f901f3475f83927a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,42 @@
local ServerGameData = {}
function ServerGameData:init()
if self.isInit then
return
end
self.isInit = true
self:initServerData("PlayerData", "app/server/data/server_player_data")
end
function ServerGameData:initData()
self:init()
local isNewPlayer = LocalData:getIsNewPlayer()
if isNewPlayer then
for k, v in pairs(self.dataMap) do
v:_loadNewPlayerData()
end
LocalData:setNotNewPlayer()
else
for k, v in pairs(self.dataMap) do
v:_loadLocalData()
end
end
end
function ServerGameData:initServerData(name, path)
self[name] = require(path):create()
if self.dataMap == nil then
self.dataMap = {}
end
self.dataMap[name] = self[name]
end
function ServerGameData:getData()
local data = {}
for k, v in pairs(self.dataMap) do
data[k] = v:getCloneData()
end
return data
end
return ServerGameData

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 341e1d539fc4d7a45a47ebb7a3376088
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,532 +0,0 @@
local BigNumOpt = {}
local MAX_CHAR = 26
local CHAR_NUM = 64
local DIGIT_UNIT = 1000
local DIGIT_ONE = 1000
local DIGIT_TWO = 1000000
local DIGIT_THREE = 1000000000
local DIGIT_FOUR = 1000000000000
-- local MAX_INTEGER = math.maxinteger
local MAX_INTEGER = 999999999999999
local MIN_INTEGER = 1000000
function BigNumOpt.cloneBigNum(bigBum)
return {value = bigBum.value, unit = bigBum.unit}
end
function BigNumOpt.getRemainder(unit)
return ((unit -1)%MAX_CHAR + 1)
end
function BigNumOpt.getEmptyBigNum()
local data = {}
data.value = math.tointeger(0)
data.unit = math.tointeger(0)
return data
end
function BigNumOpt.unitToNum(unit)
if unit == 1 then
return DIGIT_ONE
elseif unit == 2 then
return DIGIT_TWO
elseif unit == 3 then
return DIGIT_THREE
elseif unit == 4 then
return DIGIT_FOUR
else
return DIGIT_UNIT^unit
end
end
function BigNumOpt.numToTargetUnit(value, unit, targetUnit)
while true do
if unit == targetUnit or value == 0 then
break
end
if unit > targetUnit then
value = value * DIGIT_UNIT
unit = unit - 1
elseif unit < targetUnit then
if math.abs(value) < DIGIT_UNIT then
value = 0
else
value = value // DIGIT_UNIT
end
unit = unit + 1
end
end
return value, unit
end
function BigNumOpt.adjustDisplayBigNum(data)
if not BigNumOpt.checkDisplayBigNumData(data) then
return data
end
while true do
if data.unit >= 0 then
break
end
data.value = data.value / DIGIT_UNIT
data.unit = data.unit + 1
end
while true do
if data.unit <= 0 or data.value >= 1 then
break
end
data.value = data.value * DIGIT_UNIT
data.unit = data.unit - 1
end
while true do
if data.value < DIGIT_UNIT then
break
end
data.value = data.value / DIGIT_UNIT
data.unit = data.unit + 1
end
while true do
if data.value > -DIGIT_UNIT then
break
end
data.value = data.value / DIGIT_UNIT
data.unit = data.unit + 1
end
if data.value == 0 then
data.unit = 0
end
return data
end
function BigNumOpt.adjustRealBigNum(data)
if data.value > 0 then
while true do
if data.value <= MAX_INTEGER then
break
end
data.value = data.value // DIGIT_UNIT
data.unit = data.unit + 1
end
while true do
if data.value >= MIN_INTEGER then
break
end
data.value = data.value * DIGIT_UNIT
data.unit = data.unit - 1
end
elseif data.value < 0 then
while true do
if data.value >= -MAX_INTEGER then
break
end
data.value = data.value // DIGIT_UNIT
data.unit = data.unit + 1
end
while true do
if data.value <= -MIN_INTEGER then
break
end
data.value = data.value * DIGIT_UNIT
data.unit = data.unit - 1
end
end
if data.value == 0 then
data.unit = 0
end
return data
end
function BigNumOpt.getValidValue4Power(value)
local finalValue = 0
if value >= 100 then
finalValue = math.ceil(value)
elseif value >= 10 then
finalValue = math.ceil(value*10)/10
elseif value >= 0 then
finalValue = math.ceil(value*100)/100
elseif value >= -10 then
finalValue = math.floor(value*100)/100
elseif value >= -100 then
finalValue = math.floor(value*10)/10
else
finalValue = math.floor(value)
end
if finalValue == math.ceil(finalValue) then
return math.ceil(finalValue)
else
return finalValue
end
end
function BigNumOpt.getValidValue(value)
local finalValue = 0
if value >= 100 then
finalValue = math.floor(value)
elseif value >= 10 then
finalValue = math.floor(value*10)/10
elseif value >= 0 then
finalValue = math.floor(value*100)/100
elseif value >= -10 then
finalValue = math.ceil(value*100)/100
elseif value >= -100 then
finalValue = math.ceil(value*10)/10
else
finalValue = math.ceil(value)
end
if finalValue == math.floor(finalValue) then
return math.floor(finalValue)
else
return finalValue
end
end
function BigNumOpt.bigNum2Str4Power(bigNum)
local data = BigNumOpt.cloneBigNum(bigNum)
local tmp = BigNumOpt.adjustDisplayBigNum(data)
return BigNumOpt.getValidValue4Power(tmp.value) .. BigNumOpt.getBigNumUnit(tmp.unit)
end
-- 大数字转换
function BigNumOpt.bigNum2Str(bigNum)
local data = BigNumOpt.cloneBigNum(bigNum)
local tmp = BigNumOpt.adjustDisplayBigNum(data)
return BigNumOpt.getValidValue(tmp.value) .. BigNumOpt.getBigNumUnit(tmp.unit)
end
function BigNumOpt.bigNum2Num(bigNum)
--@TODO 2023-03-20 23:36:11
return math.floor(bigNum.value * (BigNumOpt.unitToNum(bigNum.unit)))
end
function BigNumOpt.num2BigNum(num)
local data = BigNumOpt.getEmptyBigNum()
data.value = num
BigNumOpt.adjustRealBigNum(data)
return data
end
function BigNumOpt.checkDisplayBigNumData(data)
if not data or not data.value or not data.unit then
return false
end
if not data.value then
return false
end
return true
end
function BigNumOpt.checkBigNumData(data)
if not data or not data.value or not data.unit then
return false
end
if math.type(data.value) ~= "integer" then
local value = math.floor(data.value)
data.value = math.tointeger(value)
end
if not data.value then
return false
end
return true
end
function BigNumOpt.bigNumAdd(data1, data2)
local data = BigNumOpt.getEmptyBigNum()
if not BigNumOpt.checkBigNumData(data1) or not BigNumOpt.checkBigNumData(data2) then
return data
end
local value1 = data1.value
local value2 = data2.value
local unit1 = data1.unit
local unit2 = data2.unit
if unit1 > unit2 then
-- data.value = value1*(BigNumOpt.unitToNum(unit1 - unit2)) + value2
-- data.unit = unit2
local value, unit = BigNumOpt.numToTargetUnit(value2, unit2, unit1)
data.value = value1 + value
data.unit = unit1
elseif unit1 < unit2 then
-- data.value = value1 + value2*(BigNumOpt.unitToNum(unit2 - unit1))
-- data.unit = unit1
local value, unit = BigNumOpt.numToTargetUnit(value1, unit1, unit2)
data.value = value + value2
data.unit = unit2
else
data.value = value1 + value2
data.unit = unit1
end
BigNumOpt.adjustRealBigNum(data)
return data
end
function BigNumOpt.bigNumSub(data1, data2)
local data = BigNumOpt.getEmptyBigNum()
if not BigNumOpt.checkBigNumData(data1) or not BigNumOpt.checkBigNumData(data2) then
return data
end
local value1 = data1.value
local value2 = data2.value
local unit1 = data1.unit
local unit2 = data2.unit
if unit1 > unit2 then
-- data.value = value1*(BigNumOpt.unitToNum(unit1 - unit2)) - value2
local value, unit = BigNumOpt.numToTargetUnit(value2, unit2, unit1)
data.value = value1 - value
data.unit = unit1
elseif unit1 < unit2 then
-- data.value = value1 - value2*(BigNumOpt.unitToNum(unit2 - unit1))
local value, unit = BigNumOpt.numToTargetUnit(value1, unit1, unit2)
data.value = value - value2
data.unit = unit2
else
data.value = value1 - value2
data.unit = unit1
end
BigNumOpt.adjustRealBigNum(data)
return data
end
function BigNumOpt.bigNumMultBigNum(data1, data2)
local data = BigNumOpt.getEmptyBigNum()
if not BigNumOpt.checkBigNumData(data1) or not BigNumOpt.checkBigNumData(data2) then
return data
end
local value1 = data1.value
local value2 = data2.value
local unit1 = data1.unit
local unit2 = data2.unit
if value1 > 0 then
while true do
if value1 <= MIN_INTEGER then
break
end
value1 = value1 // DIGIT_UNIT
unit1 = unit1 + 1
end
elseif value1 < 0 then
while true do
if value1 >= -MIN_INTEGER then
break
end
value1 = value1 // DIGIT_UNIT
unit1 = unit1 + 1
end
end
if value2 > 0 then
while true do
if value2 <= MIN_INTEGER then
break
end
value2 = value2 // DIGIT_UNIT
unit2 = unit2 + 1
end
elseif value2 < 0 then
while true do
if value2 >= -MIN_INTEGER then
break
end
value2 = value2 // DIGIT_UNIT
unit2 = unit2 + 1
end
end
data.value = value1*value2
data.unit = unit1 + unit2
BigNumOpt.adjustRealBigNum(data)
return data
end
function BigNumOpt.bigNumMultNum(bigNum, num)
local data = BigNumOpt.getEmptyBigNum()
if not BigNumOpt.checkBigNumData(bigNum) then
return data
end
local value = bigNum.value
data.unit = bigNum.unit
data.value = value*num
BigNumOpt.adjustRealBigNum(data)
return data
end
function BigNumOpt.bigNumDiv2Float(data1, data2)
if not BigNumOpt.checkBigNumData(data1) or not BigNumOpt.checkBigNumData(data2) then
return 0
end
local value1 = data1.value
local value2 = data2.value
local unit1 = data1.unit
local unit2 = data2.unit
if unit1 > unit2 then
return value1*(BigNumOpt.unitToNum(unit1 - unit2)) / value2
elseif unit1 < unit2 then
return value1 / (value2*(BigNumOpt.unitToNum(unit2 - unit1)))
else
return value1 / value2
end
end
-- 大数除以很小的数 用整除
function BigNumOpt.bigNumDivExactly(data1, num)
local data = BigNumOpt.getEmptyBigNum()
data.value = data1.value // num
data.unit = data1.unit
return data
end
function BigNumOpt.bigNumDiv(data1, data2)
local data = BigNumOpt.getEmptyBigNum()
if not BigNumOpt.checkBigNumData(data1) or not BigNumOpt.checkBigNumData(data2) then
return data
end
local value1 = data1.value
local value2 = data2.value
local unit1 = data1.unit
local unit2 = data2.unit
if value1 == 0 then
return data
end
local value = value1 / value2
if value >= MIN_INTEGER then
local value = math.floor(value)
data.value = math.tointeger(value)
data.unit = unit1 - unit2
else
local value = math.floor(value * DIGIT_TWO)
data.value = math.tointeger(value)
data.unit = unit1 - unit2 - 2
end
-- if data.unit < 0 then
-- local value = BigNumOpt.numToTargetUnit(data.value, data.unit, 0)
-- data.value = math.tointeger(math.floor(value))
-- data.unit = 0
-- end
-- if unit1 > unit2 then
-- data.value = value1*(BigNumOpt.unitToNum(unit1 - unit2)) // value2
-- data.unit = 0
-- elseif unit1 < unit2 then
-- data.value = value1 // (value2*(BigNumOpt.unitToNum(unit2 - unit1)))
-- data.unit = 0
-- else
-- data.value = value1 // value2
-- data.unit = 0
-- end
if EDITOR_MODE then
if value1 > 0 and value2 > 0 and data.value < 0 then
Logger.logFatal("the value is out of range")
end
end
BigNumOpt.adjustRealBigNum(data)
return data
end
function BigNumOpt.bigNumDivNum(data1, num)
local value = data1.value / num
if math.floor(value) == value then
local data = BigNumOpt.getEmptyBigNum()
data.value = data1.value // num
data.unit = data1.unit
BigNumOpt.adjustRealBigNum(data)
return data
end
local data2 = BigNumOpt.num2BigNum(num)
return BigNumOpt.bigNumDiv(data1, data2)
end
function BigNumOpt.bigNumCompare(data1, data2)
local data = BigNumOpt.getEmptyBigNum()
if not BigNumOpt.checkBigNumData(data1) or not BigNumOpt.checkBigNumData(data2) then
return
end
local value1 = data1.value
local value2 = data2.value
local unit1 = data1.unit
local unit2 = data2.unit
local data = BigNumOpt.bigNumSub(data1, data2)
if data.value > 0 then
return 1
elseif data.value < 0 then
return -1
else
return 0
end
end
function BigNumOpt.bigNumSqrt(data1)
if not BigNumOpt.checkBigNumData(data1) then
return data1
end
local data = BigNumOpt.getEmptyBigNum()
local value = data1.value
local unit = data1.unit
if value == 0 then
return data
end
if unit % 2 == 0 then
value = math.sqrt(value)
unit = unit / 2
else
value = math.sqrt(value*DIGIT_ONE)
unit = (unit - 1) / 2
end
if value >= MIN_INTEGER then
value = math.floor(value)
data.value = math.tointeger(value)
data.unit = unit
else
value = math.floor(value * DIGIT_TWO)
data.value = math.tointeger(value)
data.unit = unit - 2
end
return data
end
-- 单位转字符
function BigNumOpt.getBigNumUnit(unit)
if unit <= 0 then
return ""
end
local curDigit = 0
local unitStr = ""
while true do
local re = BigNumOpt.getRemainder(unit)
unitStr = string.char(re + CHAR_NUM) .. unitStr
if unit <= MAX_CHAR then
break
else
unit = (unit - re)/MAX_CHAR
end
end
return unitStr
end
--attr转str
-- function BigNumOpt.bigNumCfgAttr2FinalStr(cfgAttr)
-- local finalValueStr = BigNumOpt.bigNumCfgAttr2FinalValueStr(cfgAttr)
-- return GFunc.getPerStr(GConst.ATTR_TYPE[cfgAttr.type], finalValueStr)
-- end
function BigNumOpt.bigNumCfgAttr2FinalValueStr(cfgAttr)
local attrStr = GFunc.getPerStr(GConst.ATTR_TYPE[cfgAttr.type], BigNumOpt.bigNum2Str(GFunc.getFinalAttr(GConst.ATTR_TYPE[cfgAttr.type], cfgAttr.bignum)))
return attrStr
end
function BigNumOpt.bigNumCfgAttr2FinalValueStr2(type, attrValue)
local attrStr = GFunc.getPerStr(type, BigNumOpt.bigNum2Str(GFunc.getFinalAttr(type, attrValue)))
return attrStr
end
return BigNumOpt

View File

@ -2,7 +2,6 @@
local BF_UI_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_UI_HELPER local BF_UI_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_UI_HELPER
local BF_BASE_SORTING_ORDER_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_BASE_SORTING_ORDER_HELPER local BF_BASE_SORTING_ORDER_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_BASE_SORTING_ORDER_HELPER
---@class BaseUI
local BaseUI = { local BaseUI = {
_baseAlreadyClosed = false, _baseAlreadyClosed = false,
_baseUIOrder = 0 _baseUIOrder = 0

View File

@ -1,5 +1,4 @@
---@class BaseCell : LuaComponent
local BaseCell = class("BaseCell", LuaComponent) local BaseCell = class("BaseCell", LuaComponent)
function BaseCell:init() function BaseCell:init()

View File

@ -1,4 +1,3 @@
---@class RewardCell : BaseCell
local RewardCell = class("RewardCell", BaseCell) local RewardCell = class("RewardCell", BaseCell)
function RewardCell:init() function RewardCell:init()

View File

@ -1,5 +1,4 @@
local UIPrefabObject = require "app/bf/unity/uiprefab_object" local UIPrefabObject = require "app/bf/unity/uiprefab_object"
---@class ScrollRectBase
local ScrollRectBase = class("ScrollRectBase", LuaComponent) local ScrollRectBase = class("ScrollRectBase", LuaComponent)
function ScrollRectBase:init() function ScrollRectBase:init()

View File

@ -16,59 +16,59 @@ function ResourceCell:init()
end end
function ResourceCell:show(itemId, hideAddImg) function ResourceCell:show(itemId, hideAddImg)
hideAddImg = hideAddImg or false -- hideAddImg = hideAddImg or false
self:hide() -- self:hide()
if not itemId then -- if not itemId then
return -- return
end -- end
self.baseObject:setActive(true) -- self.baseObject:setActive(true)
self.num = nil -- self.num = nil
local obj = DataManager.BagData.ItemData:getItemById(itemId) -- local obj = DataManager.BagData.ItemData:getItemById(itemId)
self.resImg:setSprite(obj:getIconRes()) -- self.resImg:setSprite(obj:getIconRes())
self:unBindAll() -- self:unBindAll()
self:bind(obj, "isDirty", function(binder, value) -- self:bind(obj, "isDirty", function(binder, value)
self:refreshTextRightNow() -- self:refreshTextRightNow()
end) -- end)
self.baseObject:removeClickListener() -- self.baseObject:removeClickListener()
self.timeTx:setVisible(false) -- self.timeTx:setVisible(false)
self.itemId = itemId -- self.itemId = itemId
if itemId == GConst.ItemConst.ITEM_ID_GEM then -- if itemId == GConst.ItemConst.ITEM_ID_GEM then
self.baseObject:addClickListener(function() -- self.baseObject:addClickListener(function()
if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true) then -- if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true) then
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = 5, storeIdx = 4}) -- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = 5, storeIdx = 4})
end -- end
end) -- end)
self.addImg:setVisible(not hideAddImg) -- self.addImg:setVisible(not hideAddImg)
elseif itemId == GConst.ItemConst.ITEM_ID_GOLD then -- elseif itemId == GConst.ItemConst.ITEM_ID_GOLD then
if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true) then -- if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true) then
self.baseObject:addClickListener(function() -- self.baseObject:addClickListener(function()
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = 5, storeIdx = 2}) -- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = 5, storeIdx = 2})
end) -- end)
end -- end
self.addImg:setVisible(not hideAddImg) -- self.addImg:setVisible(not hideAddImg)
else -- else
self.addImg:setVisible(not hideAddImg) -- self.addImg:setVisible(not hideAddImg)
end -- end
self:refreshCurrencyAddTx(itemId, nil) -- self:refreshCurrencyAddTx(itemId, nil)
end end
function ResourceCell:refreshCurrencyAddTx(itemId, bigNum) function ResourceCell:refreshCurrencyAddTx(itemId, bigNum)
if self.itemId == itemId then -- if self.itemId == itemId then
if bigNum then -- if bigNum then
local obj = DataManager.BagData.ItemData:getItemById(self.itemId) -- local obj = DataManager.BagData.ItemData:getItemById(self.itemId)
if obj:getItemType() == 6 then -- if obj:getItemType() == 6 then
self.addTx:setText("+" .. tostring(BigNumOpt.bigNum2Num(bigNum))) -- self.addTx:setText("+" .. tostring(BigNumOpt.bigNum2Num(bigNum)))
else -- else
self.addTx:setText("+" .. BigNumOpt.bigNum2Str(bigNum)) -- self.addTx:setText("+" .. BigNumOpt.bigNum2Str(bigNum))
end -- end
else -- else
self.addTx:setText(nil) -- self.addTx:setText(nil)
end -- end
end -- end
end end
function ResourceCell:updateTime() function ResourceCell:updateTime()
@ -95,18 +95,18 @@ function ResourceCell:getAnchoredPosition()
end end
function ResourceCell:refreshTextRightNow() function ResourceCell:refreshTextRightNow()
if not self.itemId then -- if not self.itemId then
return -- return
end -- end
local obj = DataManager.BagData.ItemData:getItemById(self.itemId) -- local obj = DataManager.BagData.ItemData:getItemById(self.itemId)
local bigNum = obj:getBigNum() -- local bigNum = obj:getBigNum()
if bigNum.value < 0 then -- if bigNum.value < 0 then
self.numTx:setText(0) -- self.numTx:setText(0)
elseif obj:getItemType() == 6 then -- elseif obj:getItemType() == 6 then
self.numTx:setText(BigNumOpt.bigNum2Num(bigNum)) -- self.numTx:setText(BigNumOpt.bigNum2Num(bigNum))
else -- else
self.numTx:setText(BigNumOpt.bigNum2Str(bigNum)) -- self.numTx:setText(BigNumOpt.bigNum2Str(bigNum))
end -- end
end end
function ResourceCell:refreshText() function ResourceCell:refreshText()

View File

@ -0,0 +1,6 @@
local HeroComp = class("HeroComp", LuaComponent)
function HeroComp:refresh()
end
return HeroComp

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 978e56ab9e7fa7d44aff38dc136af744
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,34 +1,30 @@
local BottomBtnCell = class("BottomBtnCell", BaseCell) local BottomBtnCell = class("BottomBtnCell", BaseCell)
function BottomBtnCell:refresh(index, selected, iconName, iconCloseName, isOpen) function BottomBtnCell:refresh(desc, selected)
self.selected = selected
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
local icon = uiMap["bottom_btn_cell.icon"]
local bg = uiMap["bottom_btn_cell.bg"] local descObj = uiMap["bottom_btn_cell.desc"]
local icon = uiMap["bottom_btn_cell.icon_img"] local iconScale = 1
local descTx = uiMap["bottom_btn_cell.desc_tx"] local descContent = selected and desc or GConst.EMPTY_STRING
local leftLine = uiMap["bottom_btn_cell.l_line"] descObj:setText(descContent)
local rightLing = uiMap["bottom_btn_cell.r_line"] local pos = -64
local selectBg = uiMap["bottom_btn_cell.select_bg"] icon:setLocalPositionY(pos)
local closeIcon = uiMap["bottom_btn_cell.close_img"] if selected then
GFunc.goTargetElasticityY(icon,nil, 12,0.6)
icon:setSprite(GConst.ATLAS_PATH.MAIN, isOpen and iconName or iconCloseName) else
bg:setVisible(not selected) icon:setLocalScale(iconScale, iconScale, iconScale)
icon:setVisible(not selected) end
selectBg:setVisible(selected)
closeIcon:setVisible(selected)
leftLine:setVisible(index > 1)
rightLing:setVisible(index < GConst.MainCityConst.BOTTOM_COUNT)
-- TODO 动画效果
end end
function BottomBtnCell:addClickListener(func) function BottomBtnCell:addClickListener(func)
self:getBaseObject():addClickListener(func) self:getBaseObject():addClickListener(func, GConst.CLICK_SOUND.NORMAL)
end end
function BottomBtnCell:getAnchoredPositionX() function BottomBtnCell:getCurLocalPosX()
return self:getBaseObject():getAnchoredPositionX() local obj = self.baseObject
return obj:getAnchoredPositionX()
end end
return BottomBtnCell return BottomBtnCell

View File

@ -1,120 +0,0 @@
local ChapterSliderComp = class("ChapterSliderComp", LuaComponent)
local SLIDER_WIDTH = 266
local DEFAULT_MONSTER_POINT_X = 0 -- 25
local NOT_SHOW_BEST_MAX_CUR_SLIDER_VALUE = 0.8 -- cur距离end的最近距离
local SHOW_BEST_MAX_CUR_SLIDER_VALUE = 0.6
local MIN_BEST_2_CUR_VALUE = 0.2 -- best距离cur的最近距离
local MAX_BEST_SLIDER_VALUE = 0.8 -- best距离end的最近距离
function ChapterSliderComp:refresh()
local uiMap = self.baseObject:genAllChildren()
if not self.heroPoint then
self.heroPoint = uiMap["chapter_slider_comp.hero_point"]
end
if not self.heroAvatarCell then
self.heroAvatarCell = CellManager:addCellComp(uiMap["chapter_slider_comp.hero_point.avatar_cell"], GConst.TYPEOF_LUA_CLASS.AVATAR_CELL)
end
if not self.heroInfoTx then
self.heroInfoTx = uiMap["chapter_slider_comp.hero_point.info_tx"]
end
if not self.bestPoint then
self.bestPoint = uiMap["chapter_slider_comp.best_point"]
end
if not self.bestInfoTx then
self.bestInfoTx = uiMap["chapter_slider_comp.best_point.info_tx"]
end
if not self.monsterPoint then
self.monsterPoint = uiMap["chapter_slider_comp.monster_point"]
end
if not self.monsterInfoTx then
self.monsterInfoTx = uiMap["chapter_slider_comp.monster_point.info_tx"]
end
if not self.monsterAvatarCell then
self.monsterAvatarCell = CellManager:addCellComp(uiMap["chapter_slider_comp.monster_point.avatar_cell"], GConst.TYPEOF_LUA_CLASS.AVATAR_CELL)
self.monsterAvatarCell:addClickListener(function()
-- ModuleManager.ChapterManager:showChapterRewardListUI() -- 屏蔽
end)
end
if not self.sliderBest then
self.sliderBest = uiMap["chapter_slider_comp.slider_best"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
end
if not self.sliderCur then
self.sliderCur = uiMap["chapter_slider_comp.slider_cur"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
end
if not self.leftMonsterTitleTx then
self.leftMonsterTitleTx = uiMap["chapter_slider_comp.hero_point.monster_bg.title_tx"]
self.leftMonsterTitleTx:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_LEFT))
end
if not self.leftMonsterTx then
self.leftMonsterTx = uiMap["chapter_slider_comp.hero_point.monster_bg.num_tx"]
end
-- 固定内容
local bestTx = uiMap["chapter_slider_comp.best_point.best_tx"]
bestTx:setText(I18N:getGlobalText(I18N.GlobalConst.BEST_DESC))
local curFlag = uiMap["chapter_slider_comp.hero_point.info_tx.flag"]
-- 设置位置与内容
local curChapterId = DataManager.ChapterData:getCurChapterId() + 1
local historyChapterId = DataManager.ChapterData:getHistoryChapterId() + 1
local nextRewardChapterId = DataManager.ChapterData:getNextFirstRewardChapter(math.max(historyChapterId, curChapterId))
local isReachMaxChapter = DataManager.ChapterData:isReachMaxChapter()
local showBest = curChapterId < historyChapterId
if isReachMaxChapter or nextRewardChapterId == nil then
nextRewardChapterId = DataManager.ChapterData:getMaxChapterId() -- 容错按最后章来处理
end
local sliderValue = (curChapterId) / (nextRewardChapterId)
if showBest then
sliderValue = math.clamp(sliderValue, 0, SHOW_BEST_MAX_CUR_SLIDER_VALUE)
else
sliderValue = math.clamp(sliderValue, 0, NOT_SHOW_BEST_MAX_CUR_SLIDER_VALUE)
end
local sliderBestValue = (historyChapterId) / (nextRewardChapterId)
if showBest then
sliderBestValue = math.clamp(sliderBestValue, (sliderValue + MIN_BEST_2_CUR_VALUE), MAX_BEST_SLIDER_VALUE)
curFlag:setVisible(false)
else
sliderBestValue = math.clamp(sliderBestValue, sliderBestValue , math.min(sliderValue, sliderBestValue))
curFlag:setVisible(true)
end
self.sliderCur.value = sliderValue
self.heroPoint:setAnchoredPositionX(sliderValue * SLIDER_WIDTH)
self.heroAvatarCell:refresh()
self.heroInfoTx:setText(I18N:getGlobalText(I18N.GlobalConst.TRAIN_DESC_15, curChapterId))
local txW = self.heroInfoTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
self.heroInfoTx:setSizeDeltaX(txW)
self.bestPoint:setVisible(showBest)
self.sliderBest.value = sliderBestValue
self.bestPoint:setAnchoredPositionX(sliderBestValue * SLIDER_WIDTH)
self.bestInfoTx:setText(I18N:getGlobalText(I18N.GlobalConst.TRAIN_DESC_15, historyChapterId))
-- 找到怪物头像
local monsterBaseId = DataManager.ChapterData:getFirstRewardMonsterBaseId(nextRewardChapterId)
if monsterBaseId then
self.monsterAvatarCell:refreshMonster(monsterBaseId)
else
self.monsterAvatarCell:refresh(2, 2)
end
self.monsterPoint:setAnchoredPositionX(DEFAULT_MONSTER_POINT_X)
self.monsterInfoTx:setText(I18N:getGlobalText(I18N.GlobalConst.TRAIN_DESC_15, nextRewardChapterId))
self:refreshLeftMonster()
end
function ChapterSliderComp:refreshLeftMonster()
if not self.leftMonsterTx then
self.leftMonsterTx = self.uiMap["chapter_slider_comp.hero_point.monster_bg.num_tx"]
end
self.leftMonsterTx:setText(string.format("X %s", DataManager.ChapterData:getCacheStageLeftMonsterNum()))
end
return ChapterSliderComp

View File

@ -0,0 +1,507 @@
local MainComp = class("MainComp", LuaComponent)
local BG_PREFIX = "assets/arts/textures/background/chapter/%s.png"
local PATTERN_ICON = {
[GConst.StageConst.CHAPTER_PATTERN.HARD] = {"common_menu_6", "common_decoration_16"},
[GConst.StageConst.CHAPTER_PATTERN.NORMAL] = {"common_menu_7", "common_decoration_15"}
}
function MainComp:refresh(childPage)
self.childPage = childPage
self.showLeftRed = false
self.showRightRed = false
self.showLeftSideBar = true
self.showRightSideBar = true
-- self:_display()
self:_addListeners()
end
function MainComp:_display()
local uiMap = self:getBaseObject():genAllChildren()
self.rightSideBarBg = uiMap["main_comp.right_node"]
self.leftSideBarBg = uiMap["main_comp.left_node"]
self.leftArrow = uiMap["main_comp.left_node.arrow"]
self.rightArrow = uiMap["main_comp.right_node.arrow"]
-- 宝箱相关
self.boxImg = uiMap["main_comp.box_touch_1"]
self.boxImgShadow = uiMap["main_comp.box_touch_1_shadow"]
self.boxShakeImg = uiMap["main_comp.box_touch_1.box_shakeImg"]
self.boxTx = uiMap["main_comp.box_tx"]
self.boxImgShadow:setActive(false)
self.boxImgShadow:setLocalScale(0.8,0.8,0.8)
self:refreshBoxShakeEff(true)
self.btnGM = uiMap["main_comp.gm_btn"]
self.btnGM:setVisible(not Platform:getIsPublishChannel(),2)
self.btnGM:addClickListener(function()
ModuleManager.DevToolManager:showOrHideDevListUI()
end)
-- self:refreshChapter()
-- self:refreshRedPoint()
end
function MainComp:_addListeners()
local uiMap = self:getBaseObject():genAllChildren()
-- 战斗按钮
uiMap["main_comp.hang_up_node.fight_btn"]:addClickListener(function()
self:onFightBtnClick()
end)
end
function MainComp:onFightBtnClick()
ModuleManager.BattleManager:playBattle()
end
function MainComp:onClickPattern()
local chapterId = DataManager.StageData:getChapterId()
local pattern = DataManager.StageData:getChapterPattern(chapterId)
if self.childPage then
pattern = self.childPage
self.childPage = nil
elseif pattern == GConst.StageConst.CHAPTER_PATTERN.HARD then
pattern = GConst.StageConst.CHAPTER_PATTERN.NORMAL
else
pattern = GConst.StageConst.CHAPTER_PATTERN.HARD
end
local maxId = DataManager.StageData:getMaxChapterId(pattern)
local maxCfg = ConfigManager:getConfig("chapter")[maxId]
if maxCfg and maxCfg.next_chapter then
maxId = maxCfg.next_chapter
elseif not maxCfg and pattern == GConst.StageConst.CHAPTER_PATTERN.HARD then
maxId = DataManager.StageData:getDefaultHardId()
elseif not maxCfg then
maxId = DataManager.StageData:getDefaultId()
end
DataManager.StageData:changeChapterId(maxId)
self:_display()
end
function MainComp:refreshChapter()
local curId = DataManager.StageData:getChapterId()
local pattern = DataManager.StageData:getChapterPattern(curId)
local cfg = ConfigManager:getConfig("chapter")[curId]
local uiMap = self:getBaseObject():genAllChildren()
self:initHardChapterUI(uiMap, pattern, cfg)
self:initFightBtn(uiMap, cfg.cost)
self:setChapterTxtUI(uiMap, curId)
uiMap["main_comp.box_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_BOX_TITLE))
uiMap["main_comp.chapter_img"]:setTexture(string.format(BG_PREFIX, cfg.scenes.."_main"))
self:refreshBoxShakeEff()
end
--endregion
--region UI初始化
function MainComp:refreshBoxShakeEff(onlyKill)
self.boxShakeImg:setLocalRotation(0,0,0)
-- GFunc.getShakeSeqRotate(self.boxShakeImg,nil)
end
function MainComp:initFightBtn(uiMap,cost)
local btnTx = I18N:getGlobalText(I18N.GlobalConst.CONTINUE_DESC)
uiMap["main_comp.hang_up_node.fight_btn.desc"]:setText(btnTx)
uiMap["main_comp.hang_up_node.fight_btn.desc_2"]:setText(cost)
end
function MainComp:initHardChapterUI(uiMap, pattern, cfg)
--暂时屏蔽困难按钮
if true then
uiMap["main_comp.hard_btn"]:setVisible(false)
return
end
local hardBtn = uiMap["main_comp.hard_btn"]
local atmosphereNode = uiMap["main_comp.atmosphere_node"]
atmosphereNode:setVisible(false)
if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.HARD_STAGE, true) then
hardBtn:setVisible(true)
local text = uiMap["main_comp.hard_btn.desc"]
local kulou = uiMap["main_comp.hard_btn.kulo_img"]
if pattern == GConst.StageConst.CHAPTER_PATTERN.NORMAL then
atmosphereNode:setVisible(false)
text:setText(I18N:getGlobalText(I18N.GlobalConst.HARD_DESC))
elseif pattern == GConst.StageConst.CHAPTER_PATTERN.HARD then
atmosphereNode:setVisible(true)
text:setText(I18N:getGlobalText(I18N.GlobalConst.SIMPLY_DESC))
if cfg and cfg.scenes_a then
uiMap["main_comp.atmosphere_node.top"]:setTexture("assets/arts/textures/background/main/" .. cfg.scenes_a .. ".png")
end
end
if PATTERN_ICON[pattern] then
hardBtn:setSprite(GConst.ATLAS_PATH.COMMON, PATTERN_ICON[pattern][1])
kulou:setSprite(GConst.ATLAS_PATH.COMMON, PATTERN_ICON[pattern][2])
end
else
hardBtn:setVisible(false)
end
end
function MainComp:setChapterTxtUI(uiMap,curChapterId)
uiMap["main_comp.chapter_name"]:setText(I18N:getConfig("chapter")[curChapterId].name)
local chapterPassedTx = uiMap["main_comp.chapter_passed"]
local info = DataManager.StageData:getChapterInfo(curChapterId)
local content = ""
if info.passed then
content = I18N:getGlobalText(I18N.GlobalConst.ALREADY_PASS_DESC)
else
local wave = info.bestWave or 0
content = I18N:getGlobalText(I18N.GlobalConst.PASS_DESC_2, wave.."/"..self:getMaxWave())
end
chapterPassedTx:setText(content)
end
function MainComp:getMaxWave()
local chapterId = DataManager.StageData:getChapterId()
self.generateSteps = DataManager.StageData:getChapterGenMonsterSteps(chapterId) or GConst.EMPTY_TABLE
self.generateChapterCfg = ConfigManager:getConfig("chapter")[chapterId]
self.generateStageCfg = ConfigManager:getConfig("story_stage")
local maxWave = 0
for i,v in ipairs(self.generateChapterCfg.stage) do
local stageCfg = self.generateStageCfg[v]
if stageCfg and stageCfg.wave_type ~= GConst.BattleConst.STEP_TYPE.ROUGE and not stageCfg.is_tutorial then
maxWave = maxWave + 1
end
end
return maxWave
end
function MainComp:calcLeftBarIconPos(leftNum)
local maxColumnNum = self:getMaxColumnNum()
local w = 104
local h = 0
local showArrow = false--leftNum > 2
if leftNum <= maxColumnNum then
if showArrow then
h = 104 * leftNum + 84
else
h = 104 * leftNum + 28
end
else
w = 208
h = 104 * maxColumnNum
end
self.leftArrow:removeRedPoint()
if not self.showLeftSideBar then
if leftNum > 2 then
h = 104 + 84
else
h = 104 + 28
end
if self.showLeftRed then
self.leftArrow:addRedPoint(12, 8, 0.5)
end
end
self.leftArrow:setAnchoredPositionX(47)
if leftNum <= maxColumnNum or not self.showLeftSideBar then
self.leftArrow:setAnchoredPositionX(0)
end
self.leftArrow:setActive(showArrow)
self.leftSideBarBg:setSizeDelta(w, h)
if leftNum <= 0 then
self.leftSideBarBg:setVisible(false)
else
self.leftSideBarBg:setVisible(true)
end
end
function MainComp:calcRightBarIconPos(rightNum)
local maxColumnNum = self:getMaxColumnNum()
local w = 104
local h = 0
local showArrow = false--rightNum > 2
if rightNum <= maxColumnNum then
if showArrow then
h = 104 * rightNum + 84
else
h = 104 * rightNum + 28
end
else
w = 208
h = 104 * maxColumnNum
end
self.rightArrow:removeRedPoint()
if not self.showRightSideBar then
w = 104
if rightNum > 2 then
h = 104 + 84
else
h = 104 + 28
end
if self.showRightRed then
self.rightArrow:addRedPoint(12, 8, 0.5)
end
end
self.rightArrow:setAnchoredPositionX(-47)
if rightNum <= maxColumnNum or not self.showRightSideBar then
self.rightArrow:setAnchoredPositionX(0)
end
self.rightArrow:setVisible(showArrow)
self.rightSideBarBg:setSizeDelta(w, h)
if rightNum <= 0 then
self.rightSideBarBg:setVisible(false)
else
self.rightSideBarBg:setVisible(true)
end
end
function MainComp:getMaxColumnNum()
if not self.maxColumnNum then
local screenOffsetY = GFunc.calculateFitSizeY()
self.maxColumnNum = 5 + screenOffsetY // 104
end
return self.maxColumnNum
end
function MainComp:getSideBtnPos(btnNum, offsetY, isRight)
local x = 0
local y = offsetY
local maxColumnNum = self:getMaxColumnNum()
btnNum = btnNum + 1
if btnNum < maxColumnNum then
offsetY = offsetY - 104
else
local num = btnNum - maxColumnNum
if num > 0 then
if not isRight then
x = 99
else
x = -99
end
end
offsetY = -47.5 - num * 104
end
return offsetY, btnNum, x, y
end
function MainComp:initFirstRechargeUI(offsetLy, leftNum, x, y)
-- 首充礼包
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FIRST_CHARGE, true) or DataManager.ActivityGiftData:isFirstGiftClaimed() then
GFunc.getShakeSeq(self.firstRechargeBtn, true)
self.firstRechargeBtn:setVisible(false)
else
if (not DataManager.ActivityGiftData:getCheckUI(GConst.ActivityConst.CHECK_UI.firstRecharge)) and self.showLeftSideBar then
GFunc.getShakeSeq(self.firstRechargeBtn, nil, 1, true)
else
GFunc.getShakeSeq(self.firstRechargeBtn, true)
end
offsetLy, leftNum, x, y = self:getSideBtnPos(leftNum, offsetLy)
self.firstRechargeBtn:setVisible(true)
if (not self.showLeftSideBar) and leftNum > 1 then
self.firstRechargeBtn:setVisible(false)
end
self.firstRechargeBtn:setAnchoredPosition(x, y)
end
return offsetLy, leftNum, x, y
end
function MainComp:initDcBtnUI(offsetLy, leftNum, x, y)
if CS.BF.BFMain.IsShenhe then
return offsetLy, leftNum, x, y
end
offsetLy, leftNum, x, y = self:getSideBtnPos(leftNum, offsetLy)
self.dcBtn:setVisible(true)
if (not self.showLeftSideBar) and leftNum > 1 then
GFunc.getShakeSeqRotate(self.dcIcon,true)
self.dcBtn:setVisible(false)
else
GFunc.getShakeSeqRotate(self.dcIcon,nil, true)
end
self.dcBtn:setAnchoredPosition(x, y)
return offsetLy, leftNum, x, y
end
--endregion
--region 右侧按钮排版
function MainComp:initLvCardUI(offsetY, rightNum, x, y)
-- 成长基金
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ACT_LEVEL_GIFT, true) or DataManager.ActivityGiftData:isLvGiftFinish() then
GFunc.getShakeSeq(self.lvGiftBtn, true)
self.lvGiftBtn:setVisible(false)
else
if (not DataManager.ActivityGiftData:isLvGiftOpen()) and self.showRightSideBar then
if not DataManager.ActivityGiftData:getCheckUI(GConst.ActivityConst.CHECK_UI.lvGift) then
GFunc.getShakeSeq(self.lvGiftBtn, nil, 1, true)
else
GFunc.getShakeSeq(self.lvGiftBtn, true)
end
else
if DataManager.ActivityGiftData:showLvGiftRedPoint() and self.showRightSideBar then
GFunc.getShakeSeq(self.lvGiftBtn, nil, 1, true)
else
GFunc.getShakeSeq(self.lvGiftBtn, true)
end
end
offsetY, rightNum, x, y = self:getSideBtnPos(rightNum, offsetY, true)
self.lvGiftBtn:setVisible(true)
if (not self.showRightSideBar) and rightNum > 1 then
self.lvGiftBtn:setVisible(false)
end
self.lvGiftBtn:setAnchoredPosition(x, y)
end
return offsetY, rightNum, x, y
end
function MainComp:initTaskUI(offsetY, rightNum, x, y)
if CS.BF.BFMain.IsShenhe then
self.taskBtn:setActive(false)
self.boxImg:setAnchoredPositionX(0)
self.boxTx:setAnchoredPositionX(0)
self.boxImgShadow:setAnchoredPositionX(0)
return offsetY, rightNum, x, y
end
-- 任务 开启后常驻
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.TASK, true) then
GFunc.getShakeSeq(self.taskBtn, true)
self.taskBtn:setVisible(false)
else
if DataManager.TaskData:showRedPoint() and self.showRightSideBar then
GFunc.getShakeSeq(self.taskBtn, nil, 1, true)
else
GFunc.getShakeSeq(self.taskBtn, true)
end
offsetY, rightNum, x, y = self:getSideBtnPos(rightNum, offsetY, true)
self.taskBtn:setVisible(true)
if (not self.showRightSideBar) and rightNum > 1 then
self.taskBtn:setVisible(false)
end
self.taskBtn:setAnchoredPosition(x, y)
end
return offsetY, rightNum, x, y
end
function MainComp:initPopGiftUI(offsetY, rightNum, x, y)
if #self.popData <= 0 then
GFunc.getShakeSeq(self.popGiftBtn, true)
self.popGiftBtn:setVisible(false)
else
self.popGiftBtn:setVisible(true)
self.popGiftBtn:setAnchoredPositionY(offsetY)
if #self.popData > 0 then
GFunc.getShakeSeq(self.popGiftBtn, nil, 1, true)
else
GFunc.getShakeSeq(self.popGiftBtn, true)
end
offsetY, rightNum, x, y = self:getSideBtnPos(rightNum, offsetY, true)
end
return offsetY, rightNum, x, y
end
function MainComp:updateTime()
self:refreshPopUI()
self:refreshRedPoint()
end
function MainComp:refreshPopUI()
if self.popData and #self.popData > 0 then
local data = self.popData[1]
local nowTime = Time:getServerTime()
local endTime = data.endTime or 0
if nowTime > endTime then
self.popData = DataManager.ActivityGiftData:getPopGiftData()
self.popGiftCd:setText("")
return
end
self.popGiftCd:setText(GFunc.getTimeStrWithHMS(endTime - nowTime))
end
end
--region 红点
function MainComp:refreshRedPoint()
-- self.boxRedPoint = self:chapterBoxRedPoint()
-- -- 两侧按钮
-- self.showLeftRed = self:showLeftRedPoint()
-- self.showRightRed = self:showRightRedPoint()
end
function MainComp:getIsShowRedPoint()
return self.boxRedPoint or self.showLeftRed or self.showRightRed
end
function MainComp:showLeftRedPoint()
local sevenDayRed = self:showSevenDayRedPoint()
local rechargeRed = self:refreshFirstRechargeRedPoint()
return sevenDayRed or rechargeRed
end
function MainComp:showRightRedPoint()
local lvGiftRedPoint = self:refreshLvGiftRedPoint()
local taskRedPoint = self:refreshTaskRedPoint()
return lvGiftRedPoint or taskRedPoint
end
function MainComp:showSevenDayRedPoint()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ACT_SEVENDAY, true) then
return false
end
return DataManager.SevenDayData:getRedPoint()
end
function MainComp:chapterBoxRedPoint()
-- local showRedPoint = DataManager.StageData:showMainCompRedPoint()
-- if showRedPoint then
-- self.boxImg:addRedPoint(58, 46, 0.8)
-- GFunc.getShakeSeqRotate(self.boxShakeImg,nil, true)
-- else
-- self.boxImg:removeRedPoint()
-- GFunc.getShakeSeqRotate(self.boxShakeImg,true)
-- end
-- return showRedPoint
end
function MainComp:refreshLvGiftRedPoint()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ACT_LEVEL_GIFT, true) then
return false
end
local giftHallNeedRp = false
if DataManager.ActivityGiftData:showLvGiftRedPoint() then
self.lvGiftBtn:addRedPoint(30, 30, 0.6)
giftHallNeedRp = true
else
self.lvGiftBtn:removeRedPoint()
end
return giftHallNeedRp
end
function MainComp:refreshFirstRechargeRedPoint()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.FIRST_CHARGE, true) then
return false
end
if DataManager.ActivityGiftData:canClaimFirstGift() then
self.firstRechargeBtn:addRedPoint(30, 30, 0.6)
return true
else
self.firstRechargeBtn:removeRedPoint()
end
end
function MainComp:refreshTaskRedPoint()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.TASK, true) then
return false
end
if DataManager.TaskData:showRedPoint() then
self.taskBtn:addRedPoint(30, 30, 0.6)
return true
else
self.taskBtn:removeRedPoint()
end
return false
end
--endregion
return MainComp

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e19c38aee4a8e1e458390ea9d8d8de74
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,88 +0,0 @@
local TutorialTaskComp = class("TutorialTaskComp", LuaComponent)
function TutorialTaskComp:refresh()
local uiMap = self.baseObject:genAllChildren()
if not self.titleTx then
self.titleTx = uiMap["tutorial_task_comp.title_tx"]
end
if not self.infoTx then
self.infoTx = uiMap["tutorial_task_comp.info_tx"]
end
if not self.progressTx then
self.progressTx = uiMap["tutorial_task_comp.progress_tx"]
end
if not self.rewardIcon then
self.rewardIcon = uiMap["tutorial_task_comp.reward_icon"]
end
if not self.rewardTx then
self.rewardTx = uiMap["tutorial_task_comp.reward_tx"]
end
if not self.fingerObj then
self.fingerObj = uiMap["tutorial_task_comp.tutorial_finger"]
end
self.titleTx:setText(string.format("<color=#FFD556>%s</color>", I18N:getGlobalText(I18N.GlobalConst.TASK_DESC) .. DataManager.TutorialTaskData:getCurTutorialId()))
self.infoTx:setText(string.format("<color=#ffffff>%s</color>", DataManager.TutorialTaskData:getTaskDesc()))
local reward = DataManager.TutorialTaskData:getTaskReward()
if reward then
self.rewardIcon:setSprite(ModuleManager.ItemManager:getItemIcon(reward.id))
if ModuleManager.ItemManager:getItemType(reward.id) == GConst.ItemConst.NOT_2_BIGNUM_TYPE then
self.rewardTx:setText(BigNumOpt.bigNum2Num(reward.count))
else
self.rewardTx:setText(BigNumOpt.bigNum2Str(reward.count))
end
local numstr = GConst.EMPTY_STRING
if ModuleManager.ItemManager:getItemType(reward.id) == GConst.ItemConst.NOT_2_BIGNUM_TYPE then
numstr = BigNumOpt.bigNum2Num(reward.count)
else
numstr = BigNumOpt.bigNum2Str(reward.count)
end
self.rewardTx:setText(string.format("<color=#ffffff>%s</color>", numstr))
end
GFunc.centerImgAndTx(self.rewardIcon, self.rewardTx, 10)
local bg = uiMap["tutorial_task_comp.chapter_task_bg"]
local light = uiMap["tutorial_task_comp.chapter_task_bg.light"]
if not self.animationtor then
self.animationtor = self.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
end
local canClaimed = DataManager.TutorialTaskData:canClaimTask()
self.fingerObj:setVisible(false)
if canClaimed then
if not DataManager.TutorialData:getIsInTutorial() and not DataManager.TutorialTaskData:showMaskFinger() then
self.fingerObj:setVisible(true)
-- CS.UnityEngine.Animator.StringToHash("frame_reward_equip") 结果是50306902
self.fingerObj:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR):Play(50306902)
end
self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.GET_REWARDS_1))
self.infoTx:setText(DataManager.TutorialTaskData:getTaskDesc(nil, true))
local numstr = GConst.EMPTY_STRING
if ModuleManager.ItemManager:getItemType(reward.id) == GConst.ItemConst.NOT_2_BIGNUM_TYPE then
numstr = BigNumOpt.bigNum2Num(reward.count)
else
numstr = BigNumOpt.bigNum2Str(reward.count)
end
self.rewardTx:setText(numstr)
bg:addClickListener(function()
ModuleManager.TutorialTaskManager:claimTask()
end)
bg:addRedPoint(-123, 75, 0.6)
self.animationtor.enabled = true
self.animationtor:Play(767057000)
light:setVisible(true)
else
self.animationtor.enabled = false
self.fingerObj:setVisible(false)
bg:addClickListener(function()
ModuleManager.TaskManager:taskGoto(DataManager.TutorialTaskData:getTaskType())
end)
bg:removeRedPoint()
light:setVisible(false)
end
end
return TutorialTaskComp

View File

@ -1,42 +1,71 @@
---@class MainCityUI : BaseUI
local MainCityUI = class("MainCityUI", BaseUI) local MainCityUI = class("MainCityUI", BaseUI)
local BF_UI_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_UI_HELPER local BF_UI_HELPER = GConst.TYPEOF_UNITY_CLASS.BF_UI_HELPER
local HERO_COMP = "app/ui/hero/hero_comp"
local MAIN_COMP = "app/ui/main_city/component/main_comp"
local STAGE_COMP = "app/ui/stage/stage_comp"
local HERO_MODEL_PATH = "assets/prefabs/models/maincity/role_show.prefab"
local ROLE_SHOW_COMP = "app/ui/main_city/component/role_show_comp"
local BOTTOM_BTN_CELL = "app/ui/main_city/cell/bottom_btn_cell" local BOTTOM_BTN_CELL = "app/ui/main_city/cell/bottom_btn_cell"
local BOTTOM_BTN_CELL_COUNT = 5
local SIDE_BAR_DEFAULT_CELL_WIDTH = 80 MainCityUI.CLICK_BTN_TYPE = {
local SIDE_BAR_DEFAULT_CELL_WIDTH_SPACE = 10 [1] = "SHOP",
local SIDE_BAR_DEFAULT_CELL_HEIGHT = 80 [2] = "EQUIP",
local SIDE_BAR_DEFAULT_CELL_HEIGHT_SPACE = 32 [3] = "HOME",
local SIDE_BAR_COMP_TYPE = { [4] = "TALENT",
} [5] = "CHALLENGE",
local SIDE_BAR_PREFAB_PATH = {
}
local SIDE_BAR_COMP_PATH = {
}
local SIDE_BAR_NAME = {
} }
local BLACK_FADE_TIME = 0.25 local MAIN_COMP_INDEX = 1
local SAVE_POWER_MODE_TIME = 60
function MainCityUI:getUIType() function MainCityUI:getUIType()
return UIManager.UI_TYPE.MAIN return UIManager.UI_TYPE.MAIN
end end
function MainCityUI:currencyParams() function MainCityUI:currencyParams()
self.targetIndex = self.targetIndex or 0 if self.cheat then
local params = {}
params.itemIds = {}
return params
end
self.selectedIndex = self.selectedIndex or MAIN_COMP_INDEX
local params = {} local params = {}
local hidAddImg = false
params.showType = GConst.CURRENCY_TYPE.HORIZONTAL params.showType = GConst.CURRENCY_TYPE.HORIZONTAL
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE then
params.itemIds = { params.itemIds = {
GConst.ItemConst.ITEM_ID_GOLD, GConst.ItemConst.ITEM_ID_GOLD,
GConst.ItemConst.ITEM_ID_GEM, GConst.ItemConst.ITEM_ID_GEM,
GConst.ItemConst.ITEM_ID_VIT,
}
elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.EQUIP then
params.itemIds = {
GConst.ItemConst.ITEM_ID_GOLD,
GConst.ItemConst.ITEM_ID_GEM,
GConst.ItemConst.ITEM_ID_VIT,
}
elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
params.itemIds = {
GConst.ItemConst.ITEM_ID_GOLD,
GConst.ItemConst.ITEM_ID_GEM,
GConst.ItemConst.ITEM_ID_VIT,
}
elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.TALENT then
params.itemIds = {
GConst.ItemConst.ITEM_ID_GOLD,
GConst.ItemConst.ITEM_ID_GEM,
GConst.ItemConst.ITEM_ID_TALENT_ID,
}
elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.CHALLENGE then
params.itemIds = {
GConst.ItemConst.ITEM_ID_GOLD,
GConst.ItemConst.ITEM_ID_GEM,
GConst.ItemConst.ITEM_ID_VIT,
} }
return params, true, hidAddImg
end end
return params, true
end
function MainCityUI:getPrefabPath() function MainCityUI:getPrefabPath()
return "assets/prefabs/ui/main_city/main_ui.prefab" return "assets/prefabs/ui/main_city/main_ui.prefab"
@ -44,88 +73,22 @@ end
function MainCityUI:ctor(params) function MainCityUI:ctor(params)
self.isFirstEnter = params and params.isFirstEnter self.isFirstEnter = params and params.isFirstEnter
self.targetIndex = params and params.targetIndex or 0 self.targetIndex = params and params.targetIndex
self.savePowerModeTime = SAVE_POWER_MODE_TIME
end
function MainCityUI:onReshow()
if self.mineComp then
self.mineComp:checkRedPoint()
end
end end
function MainCityUI:onLoadRootComplete() function MainCityUI:onLoadRootComplete()
if self:isClosed() then local uiMap = self.root:genAllChildren()
return self.bottomBgSelected = uiMap["main_ui.bottom_node.bottom_bg_selected"]
end self.bottomBgSelected:setLocalPositionX(-178)
self.uiMap = self.root:genAllChildren()
self:_display() self:_display()
self:_addListeners() self:_addListeners()
self:_bind() self:_bind()
self:updateTime() self:updateTime()
self:scheduleGlobal(function() self:scheduleGlobal(function()
self:updateTime() self:updateTime()
end, 1) end, 1)
self:hideBlackUI()
DataManager.HeroData:getMainHeroEntity():getPassiveSkillIds()
end
function MainCityUI:_display()
self:initComp() -- 初始化页签界面
self:initBottom() -- 初始化底部页签
self:refreshBottom(nil, false) -- 刷新底部页签
-- 检查弹窗
self:checkMainPop()
end
function MainCityUI:_addListeners()
self:addEventListener(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_POP, function()
self:checkMainPop()
end)
self:addEventListener(EventManager.CUSTOM_EVENT.CURRENCY_BAR_FLY, function(params)
local pos = params.pos
local imgNum = params.imgNum
local itemIds = params.itemIds
if self.targetIndex == 0 and self:isTopUI() then
if itemIds and #itemIds > 0 then
local allPos = {}
for i = 1, imgNum do
local posX, posY = GFunc.randomPos(i, {x = pos.x, y = pos.y})
allPos[i] = {x = posX, y = posY}
end
local flyPos = {}
for _, id in ipairs(itemIds) do
flyPos[id] = allPos
end
UIManager:showCurrencyAction(flyPos)
end
else
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CURRENCY_BAR_FLY_OVER)
end
end)
end
function MainCityUI:_bind()
self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(params)
params = params or {}
local page = params.page or self.targetIndex
self:refreshBottom(page, true)
end)
self:bind(DataManager.BagData.ItemData, "dirty", function(binder, value)
self.dungeonComp:refresh()
self.mineComp:refresh()
end)
DataManager:registerCrossDayFunc("crossDay", function()
DataManager:resetSignInInfo()
-- 检查弹窗
self:checkMainPop()
end)
end end
function MainCityUI:onSetUIOrder() function MainCityUI:onSetUIOrder()
@ -140,321 +103,401 @@ function MainCityUI:onSetUIOrder()
end end
end end
-- 初始化底部页签栏 function MainCityUI:_display()
function MainCityUI:initBottom() self:initBottomUI()
if not self.bottomBtnCells then self:initComp()
self.bottomBtnCells = {} self:refreshBottom()
for i = 1, BOTTOM_BTN_CELL_COUNT do self:changeModel() -- 主界面
table.insert(self.bottomBtnCells, CellManager:addCellComp(self.uiMap["main_ui.bottom_node.bottom_btn_cell_" .. i], BOTTOM_BTN_CELL)) self:changeHero() -- 装备界面
end
end
for i = 1, BOTTOM_BTN_CELL_COUNT do
local icon = GConst.MainCityConst.BOTTOM_ICON[i]
local closeIcon = GConst.MainCityConst.BOTTOM_CLOSE_ICON[i]
local isOpen
if i == GConst.MainCityConst.BOTTOM_PAGE.DUNGEON then
isOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_GOLD, true)
or ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_DIAMOND, true)
or ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_RUNE, true)
or ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ARENA, true)
elseif i == GConst.MainCityConst.BOTTOM_PAGE.SHOP then
isOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true)
or ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SUMMON_WEAPON, true)
end
self.bottomBtnCells[i]:refresh(i, false, icon, closeIcon, isOpen)
self.bottomBtnCells[i]:addClickListener(function()
local isOpen
if i == GConst.MainCityConst.BOTTOM_PAGE.DUNGEON then
isOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_GOLD, true)
if not isOpen then
isOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_DIAMOND, true)
if not isOpen then
isOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_RUNE, true)
if not isOpen then
isOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ARENA, true)
end
end
end
if not isOpen then -- 弹toast
local notShowToast = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_GOLD, false)
if notShowToast then
notShowToast = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_DIAMOND, false)
if notShowToast then
notShowToast = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DUNGEON_RUNE, false)
if notShowToast then
notShowToast = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ARENA, false)
end
end
end
end
elseif i == GConst.MainCityConst.BOTTOM_PAGE.SHOP then
isOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true)
if not isOpen then
isOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SUMMON_WEAPON, true)
end
if not isOpen then -- 弹toast
local notShowToast = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, false)
if notShowToast then
notShowToast = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SUMMON_WEAPON, false)
end
end
else
isOpen = ModuleManager:getIsOpen(GConst.MainCityConst.BOTTOM_MODULE_KEY[i], false)
end
if isOpen then
self:refreshBottom(i, true)
end end
function MainCityUI:_addListeners()
self:addEventListener(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_POP, function()
self:checkMainPop()
end) end)
end end
self.tutorialTaskFinger = self.uiMap["main_ui.bottom_node.tutorial_finger"]
function MainCityUI:_bind()
self:bind(DataManager.StageData, "isDirty", function()
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
self.subComps[self.selectedIndex]:refreshChapter()
end
end)
self:bind(DataManager.PlayerData, "dirty", function(binder, value)
self:refreshRoleInfo()
end, true)
self:bind(DataManager.PlayerData, "lvUpDirty", function(binder, value)
self:checkMainPop()
end)
-- self:bind(DataManager.BagData.ItemData, "dirty", function(binder, value)
-- UIManager:refreshCurrencyBarTxt()
-- end)
-- self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE_VIT, function(params)
-- params = params or {}
-- local page = params.page or self.selectedIndex
-- if page == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE then
-- self.showStoreIdx = params.storeIdx
-- elseif page == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
-- self.patternIdx = params.patternIdx
-- end
-- self:refreshBottom(page, false)
-- self:refreshRoleInfo()
-- end)
-- self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(params)
-- params = params or {}
-- local page = params.page or self.selectedIndex
-- if page == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE then
-- self.showStoreIdx = params.storeIdx
-- self.storeOffsetY = params.storeOffsetY
-- elseif page == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
-- self.patternIdx = params.patternIdx
-- end
-- self:refreshBottom(page, true)
-- self:refreshRoleInfo()
-- end)
end end
-- 刷新底部页签栏 function MainCityUI:initBottomUI()
function MainCityUI:refreshBottom(targetIndex, playAnim) local uiMap = self.root:genAllChildren()
targetIndex = targetIndex or 0 self.darkImg = uiMap["main_ui.bottom_node.dark_img"]
self.bottomBtnCells = {}
-- 如果点击一样的 则是关闭效果 self.bottomBtnIcons = {}
if self.targetIndex == targetIndex then self.lineObjs = {}
targetIndex = 0 for i = 1, 2 do
self.bottomBtnIcons[i] = uiMap["main_ui.bottom_node.bottom_btn_cell_" .. i .. ".icon"]
local cellCom = CellManager:addCellComp(uiMap["main_ui.bottom_node.bottom_btn_cell_" .. i], BOTTOM_BTN_CELL)
cellCom:addClickListener(function()
if self.selectedIndex == i then
return
end end
local oldIndex = self.targetIndex if i <= #MainCityUI.CLICK_BTN_TYPE then
self.targetIndex = targetIndex BIReport:postHomeBtnCilck(BIReport.CLICK_BTN_TYPE[MainCityUI.CLICK_BTN_TYPE[i]])
for i = 1, BOTTOM_BTN_CELL_COUNT do
local icon = GConst.MainCityConst.BOTTOM_ICON[i]
local closeIcon = GConst.MainCityConst.BOTTOM_CLOSE_ICON[i]
local isOpen = true -- TODO
self.bottomBtnCells[i]:refresh(i, targetIndex == i, icon, closeIcon, isOpen)
end end
-- 展示页签内容 self:refreshBottom(i, true)
if self.targetIndex == 0 or self.subComps[self.targetIndex] then end)
self:switchComp(self.targetIndex, oldIndex) table.insert(self.bottomBtnCells, cellCom)
local lineObj = uiMap["main_ui.bottom_node.line_node.line_" .. i]
if lineObj then
table.insert(self.lineObjs, lineObj)
end
end end
self:refreshBottomRedPoint()
end end
-- 初始化页签界面
function MainCityUI:initComp() function MainCityUI:initComp()
if not self.subComps then if not self.subComps then
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
self.subComps = {} self.subComps = {}
-- 主城
-- -- 主角 local mainComp = uiMap["main_ui.sub_ui_node.main_comp"]
-- local heroComp = uiMap["main_ui.sub_ui_node.hero_main_comp"] mainComp:initPrefabHelper()
-- heroComp:initPrefabHelper() mainComp:genAllChildren()
-- heroComp:genAllChildren() self.mainComp = mainComp:addLuaComponent(MAIN_COMP)
-- self.subComps[1] = heroComp:addLuaComponent(HERO_MAIN_COMP) self.subComps[GConst.MainCityConst.BOTTOM_PAGE.MAIN] = self.mainComp
-- self.heroComp = self.subComps[1] -- 招式养成
local heroComp = uiMap["main_ui.sub_ui_node.hero_ui"]
-- -- 试炼副本 heroComp:initPrefabHelper()
-- local dungeonComp = uiMap["main_ui.sub_ui_node.dungeon_main_comp"] heroComp:genAllChildren()
-- dungeonComp:initPrefabHelper() self.subComps[GConst.MainCityConst.BOTTOM_PAGE.HERO] = heroComp:addLuaComponent(HERO_COMP)
-- dungeonComp:genAllChildren() self:onSetUIOrder()
-- self.subComps[2] = dungeonComp:addLuaComponent(DUNGEON_MAIN_COMP)
-- self.dungeonComp = self.subComps[2]
-- self.dungeonComp:setParentUI(self)
-- -- 强化
-- local trainComp = uiMap["main_ui.sub_ui_node.train_main_comp"]
-- trainComp:initPrefabHelper()
-- trainComp:genAllChildren()
-- self.subComps[3] = trainComp:addLuaComponent(TRAIN_MAIN_COMP)
-- self.trainComp = self.subComps[3]
-- -- 地下城
-- local mineComp = uiMap["main_ui.sub_ui_node.mine_main_comp"]
-- mineComp:initPrefabHelper()
-- mineComp:genAllChildren()
-- self.subComps[4] = mineComp:addLuaComponent(MINE_MAIN_COMP)
-- self.mineComp = self.subComps[4]
-- self.mineComp:setParentUI(self)
-- -- 商城
-- local shopComp = uiMap["main_ui.sub_ui_node.shop_main_comp"]
-- shopComp:initPrefabHelper()
-- shopComp:genAllChildren()
-- self.subComps[5] = shopComp:addLuaComponent(SHOP_MAIN_COMP)
-- self.shopComp = self.subComps[5]
-- self.shopComp:setParentUI(self)
-- self:onSetUIOrder()
end end
end end
-- 切换展示对应页签 function MainCityUI:refreshBottom(selectedIndex, playAnim)
function MainCityUI:switchComp(index, oldIndex) if self.targetIndex then
index = index or self.targetIndex selectedIndex = self.targetIndex
playAnim = true
self.targetIndex = nil
end
if selectedIndex and (not self.subComps[selectedIndex]) then
return
end
local oldIndex = self.selectedIndex
self.selectedIndex = selectedIndex and selectedIndex or MAIN_COMP_INDEX
self:switchComp()
-- 动效
if playAnim and (oldIndex ~= selectedIndex) then
local targetX = self.bottomBtnCells[self.selectedIndex]:getCurLocalPosX()
local isLeft = self.selectedIndex < oldIndex
local offset = isLeft and -20 or 20
GFunc.goTargetPosXShake(self.bottomBgSelected, nil, targetX, offset)
self:refreshBottomCell()
end
end
function MainCityUI:refreshBottomCell()
for i, cell in ipairs(self.bottomBtnCells) do
cell:refresh(I18N:getGlobalText("MAIN_BTN_" .. i), i == self.selectedIndex, i)
end
end
function MainCityUI:switchComp(index)
index = index or self.selectedIndex
for i, comp in pairs(self.subComps) do for i, comp in pairs(self.subComps) do
-- 页签被隐藏时调用
if oldIndex and comp.onHide and i ~= index and oldIndex == GConst.MainCityConst.BOTTOM_PAGE.TRAIN then
comp:onHide()
end
comp:getBaseObject():setActive(i == index) comp:getBaseObject():setActive(i == index)
if i == index then if i == index then
comp:refresh(self) if i == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE then
if self.showSummon and self.showSummon > 0 then
comp:refresh(self.showSummon)
self.showSummon = nil
elseif self.showStoreIdx and self.showStoreIdx > 0 then
comp:refresh(self.showStoreIdx, nil, self.storeOffsetY)
self.showStoreIdx = nil
self.storeOffsetY = nil
else
comp:refresh()
end
elseif i == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
comp:refresh(self.patternIdx)
self.patternIdx = nil
else
comp:refresh()
end
self:updateTime() self:updateTime()
end end
end end
local params = {}
params.showType = GConst.CURRENCY_TYPE.HORIZONTAL
self:updateCurrencyBar() self:updateCurrencyBar()
self:changeHero()
if self.selectedIndex == MAIN_COMP_INDEX then
self:checkMainPop() self:checkMainPop()
end end
-- 定时器
function MainCityUI:updateTime()
self:refreshSubComps()
self:refreshBottomRedPoint()
self:updateSavePowerModeTime()
end end
-- 定时刷新子页签内容 function MainCityUI:changeModel()
function MainCityUI:refreshSubComps()
-- TODO
self.shopComp:updateTime()
end end
-- 定时刷新左部分界面 function MainCityUI:changeHero()
function MainCityUI:refreshLeftNode() if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.EQUIP or self._baseVisible == false then
self:_refreshLeftSideBar() if self.heroModelComp then
self.heroModelComp:setActive(false)
end end
-- 定时刷新左侧边栏
function MainCityUI:_refreshLeftSideBar()
local leftNum = 0
local offsetY = - SIDE_BAR_DEFAULT_CELL_HEIGHT / 2
local x = 0
local y = 0
local rp = false -- 总红点
end
-- 定时刷新右部分界面
function MainCityUI:refreshRightNode()
self:_refreshRightSideBar()
end
-- 定时刷新右侧边栏
function MainCityUI:_refreshRightSideBar()
local rightNum = 0
local offsetY = - SIDE_BAR_DEFAULT_CELL_HEIGHT / 2
local x = 0
local y = 0
local rp = false
end
-- 定时刷新底部红点
function MainCityUI:refreshBottomRedPoint()
end
-- 检测弹窗
function MainCityUI:checkMainPop()
local topUI = UIManager:getTopUIObj()
if topUI:getUIIndex() ~= self:getUIIndex() then
return return
end end
local entity = DataManager.HeroData:getUniqueHero()
local showSpecialIdle = false
local eid = entity:getWearedEquips()[GConst.EquipConst.WEAPON_PART]
if eid then
local eEntity = DataManager.BagData.EquipData:getEquipByEid(eid)
if eEntity and eEntity:getHeroPose() == entity:getHid() then
showSpecialIdle = true
end
end end
-- 动态获取侧边栏按钮 if self.heroModelComp then
function MainCityUI:_refreshSideBar(type, isOpen, isShake, isRed, isAdPoint, parent, x, y, forceDisVisible, clickCallback) self.heroModelComp:setActive(true)
if not self.sideBarCells then
self.sideBarCells = {}
end end
if not self.sideBarCells[type] then if not self.heroModelComp then
if not self.loadingSideBarCells then self:loadUIModelRoot(HERO_MODEL_PATH, function(obj)
self.loadingSideBarCells = {} if self.heroModelComp then
end obj:destroy()
if not self.loadingSideBarCells[type] then -- 未加载中,加载对应模块侧边栏按钮
self.loadingSideBarCells[type] = true
CellManager:loadCellAsync(SIDE_BAR_PREFAB_PATH[type], SIDE_BAR_COMP_PATH[type], parent, function(cell)
self.loadingSideBarCells[type] = false
-- 如果已经加载了 则销毁新生成的
if self.sideBarCells[type] then
self.sideBarCells[type]:refresh(self, isOpen, isShake, isRed, isAdPoint, x, y, forceDisVisible, clickCallback)
cell.baseObject:destroy()
return return
end end
cell.baseObject:getGameObject().name = SIDE_BAR_NAME[type] self.heroModelComp = obj:addLuaComponent(ROLE_SHOW_COMP)
self.sideBarCells[type] = cell self.heroModelComp:getCameraRenderTexture(function(texture)
self.sideBarCells[type]:refresh(self, isOpen, isShake, isRed, isAdPoint, x, y, forceDisVisible, clickCallback) if self:isClosed() then
return
end
if entity then
self.heroModelComp:showHero(entity:getHid(), entity:getWeaponId(), function()
-- if showSpecialIdle and self.heroModelComp.modelObj then
-- self.heroModelComp.modelObj:play("zs_idle", -1, 0)
-- end
if self.heroModelComp.modelObj then
self.heroModelComp.modelObj:play("idle_display", -1, 0)
end
end) end)
end end
self.heroShowTexture = texture
if self.equipComp then
self.equipComp:setRt(self.heroShowTexture)
self.equipComp:setRoleShowComp(self.heroModelComp)
end
end)
end)
else else
self.sideBarCells[type]:refresh(self, isOpen, isShake, isRed, isAdPoint, x, y, forceDisVisible, clickCallback) if entity:getHid() then
self.heroModelComp:showHero(entity:getHid(), entity:getWeaponId(), function()
-- if showSpecialIdle and self.heroModelComp.modelObj then
-- self.heroModelComp.modelObj:play("zs_idle", -1, 0)
-- end
if self.heroModelComp.modelObj then
self.heroModelComp.modelObj:play("idle_display", -1, 0)
end
end)
end
end end
end end
-- 获取侧边栏按钮相对位置 function MainCityUI:updateTime()
function MainCityUI:_getSideBtnPos(btnNum, offsetY, isRight) if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE or self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
local x = 0 self.subComps[self.selectedIndex]:updateTime()
local y = offsetY end
local maxColumnNum = self:_getMaxColumnNum()
btnNum = btnNum + 1 self:checkRedPoint()
if btnNum < maxColumnNum then end
offsetY = offsetY - (SIDE_BAR_DEFAULT_CELL_HEIGHT + SIDE_BAR_DEFAULT_CELL_HEIGHT_SPACE)
function MainCityUI:refreshRoleInfo()
local uiMap = self.root:genAllChildren()
local v, _, _2 = DataManager.PlayerData:getExpPer()
uiMap["main_ui.role_node.role_cell.setting.lv"]:setText(DataManager.PlayerData:getLv())
uiMap["main_ui.role_node.role_cell.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = v
uiMap["main_ui.role_node.role_cell.setting"]:addClickListener(function()
ModuleManager.GameSettingManager:showSettingUI()
end)
end
function MainCityUI:checkRedPoint()
-- 装备
-- if DataManager.BagData.EquipData:getRedPoint() or DataManager.HeroData:getRedPoint() then
-- self.bottomBtnIcons[GConst.MainCityConst.BOTTOM_PAGE.EQUIP]:addRedPoint(40, 40, 0.7)
-- else
-- self.bottomBtnIcons[GConst.MainCityConst.BOTTOM_PAGE.EQUIP]:removeRedPoint()
-- end
-- -- 主线挑战
-- if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.CHALLENGE, true) and DataManager.ChallengeData:showRedPoint() then
-- self.bottomBtnIcons[GConst.MainCityConst.BOTTOM_PAGE.CHALLENGE]:addRedPoint(40, 40, 0.7)
-- else
-- self.bottomBtnIcons[GConst.MainCityConst.BOTTOM_PAGE.CHALLENGE]:removeRedPoint()
-- end
end
function MainCityUI:checkFuncOpen()
if not self.lvUpHide then
return
end
for k,v in pairs(ModuleManager.MODULE_KEY) do
if not DataManager.PlayerData:isShowFuncOpen(v) and ModuleManager:getIsOpen(v, true) then
local params = {}
params.funcType = v
params.callback = function ()
self:checkFuncOpen()
end
ModuleManager.MaincityManager:showFuncOpenUI(params)
return
end
end
end
-- 检查未正常退出得战斗
function MainCityUI:checkUndoneBattle()
local saveData = LocalData:getBattlePointData()
if saveData and saveData.battleType then
if not saveData.version or saveData.version ~= Platform:getClientVersion() then -- 版本号不相同时,删除数据
DataManager.BattleData:savePointData()
return
end
if saveData.battleType == ModuleManager.BattleManager.BATTLE_TYPE.STAGE then
local chapterId = tonumber(saveData.chapterId)
local config = ConfigManager:getConfig("chapter")[chapterId]
if not config then
DataManager.BattleData:savePointData()
return
end
end
-- 主线挑战不重连
if saveData.battleType == ModuleManager.BattleManager.BATTLE_TYPE.CHALLENGE then
DataManager.BattleData:savePointData()
return
end
local function enterBattle()
self.hasUnDoneBattle = false
if saveData.battleType == ModuleManager.BattleManager.BATTLE_TYPE.STAGE then
DataManager.StageData:changeChapterId(tonumber(saveData.chapterId))
end
ModuleManager.BattleManager:playBattle(saveData.battleType, saveData, nil, function()
UIManager:closeAllUI()
ModuleManager.MaincityManager:showMainCityUI()
end)
end
if not DataManager.TutorialData:getIsFuncTutorialFinished(DataManager.TutorialData.FIRST_FIGHT_END_ID) then
enterBattle()
else else
local num = btnNum - maxColumnNum GFunc.showMessageBox({
if num > 0 then boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
if not isRight then content = I18N:getGlobalText(I18N.GlobalConst.BATTLE_RECONNECT),
x = SIDE_BAR_DEFAULT_CELL_WIDTH + SIDE_BAR_DEFAULT_CELL_WIDTH_SPACE okFunc = function()
else enterBattle()
x = - (SIDE_BAR_DEFAULT_CELL_WIDTH + SIDE_BAR_DEFAULT_CELL_WIDTH_SPACE) end,
cancelFunc = function()
DataManager.BattleData:savePointData()
self.hasUnDoneBattle = false
self:checkTutorial()
end
})
-- 有未完成的战斗,记录状态
self.hasUnDoneBattle = true
end end
end end
offsetY = -(SIDE_BAR_DEFAULT_CELL_HEIGHT / 2) - num * (SIDE_BAR_DEFAULT_CELL_HEIGHT + SIDE_BAR_DEFAULT_CELL_HEIGHT_SPACE)
end
return offsetY, btnNum, x, y
end end
-- 侧边栏按钮可支持数量 function MainCityUI:checkMainPop()
function MainCityUI:_getMaxColumnNum() -- local topUI = UIManager:getTopUIObj()
if not self.maxColumnNum then -- if topUI:getUIIndex() ~= self:getUIIndex() then
local screenOffsetY = GFunc.calculateFitSizeY() -- return
self.maxColumnNum = 5 + screenOffsetY // (SIDE_BAR_DEFAULT_CELL_HEIGHT + SIDE_BAR_DEFAULT_CELL_HEIGHT_SPACE) -- end
end
return self.maxColumnNum -- -- 功能解锁(todo 把所有的找出来,免得每次关闭界面都要走一遍)
-- for k,v in pairs(ModuleManager.MODULE_KEY) do
-- if ModuleManager:showPop(v) and (not DataManager.PlayerData:isShowFuncOpen(v)) and ModuleManager:getIsOpen(v, true) then
-- local params = {}
-- params.funcType = v
-- ModuleManager.MaincityManager:showFuncOpenUI(params)
-- return
-- end
-- end
-- -- 章节解锁
-- if ModuleManager.StageManager:showChapterUnlockUI() then
-- return
-- end
-- -- 活动弹窗
-- if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
-- if ModuleManager.ActivityPopManager:checkActivityPop() then
-- return
-- end
-- end
-- -- 引导
-- if self:checkTutorial() then
-- return
-- end
end end
-- 提供给战斗使用 隐藏除战斗外的UI -- 检查引导
function MainCityUI:hideMainUIExceptBattle() function MainCityUI:checkTutorial()
if self.chapterSliderComp then -- 有重连战斗,暂不开启引导
self.chapterSliderComp.baseObject:setVisible(false) if self.hasUnDoneBattle then
return
end end
local leftNode = self.uiMap["main_ui.left_node"] -- 检查抽卡引导
leftNode:setVisible(false) if not DataManager.TutorialData:getIsFuncTutorialFinished(DataManager.TutorialData.SUMMON_ID) then
local rightNode = self.uiMap["main_ui.right_node"] self.showSummon = 4
rightNode:setVisible(false) ModuleManager.TutorialManager:checkFuncTutorial(DataManager.TutorialData.SUMMON_ID)
local bottomNode = self.uiMap["main_ui.bottom_node"] return
bottomNode:setVisible(false)
self:refreshBottom(nil, true)
end end
function MainCityUI:showMainUIExceptBattle() if not DataManager.TutorialData:getIsFuncTutorialFinished(DataManager.TutorialData.FIGHT_FAIL_ID) then
if self.chapterSliderComp then if DataManager.PlayerData:getStageFailCount() == 1 then -- 首次章节战败
self.chapterSliderComp.baseObject:setVisible(true) ModuleManager.TutorialManager:checkFuncTutorial(DataManager.TutorialData.FIGHT_FAIL_ID)
end return
local leftNode = self.uiMap["main_ui.left_node"]
leftNode:setVisible(true)
local rightNode = self.uiMap["main_ui.right_node"]
rightNode:setVisible(true)
local bottomNode = self.uiMap["main_ui.bottom_node"]
bottomNode:setVisible(true)
end
function MainCityUI:onClose()
if self.sideBarCells then
for k, cell in pairs(self.sideBarCells) do
self.sideBarCells[k] = nil
cell.baseObject:destroy()
end end
end end
if self.loadingSideBarCells then
for k, _ in pairs(self.loadingSideBarCells) do
self.loadingSideBarCells[k] = false
end
end
DataManager:unregisterCrossDayFunc("crossDay")
end end
return MainCityUI return MainCityUI

8
lua/app/ui/stage.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d906c3a6b70c16d47a4c72435a41664f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0de7a644b742b3f48b51863a844aae01
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,93 @@
local ChapterCell = class("ChapterCell", BaseCell)
local chapterCfg = ConfigManager:getConfig("chapter")
function ChapterCell:init()
self.Data = DataManager.ChallengeData
local uiMap = self:getUIMap()
self.normalTitleImg = uiMap["cell.title_img.normal_title_img"]
self.titleTxNormal = uiMap["cell.title_img.normal_title_img.title_tx"]
self.greyTitleImg = uiMap["cell.title_img.grey_title_img"]
self.titleTxGrey = uiMap["cell.title_img.grey_title_img.title_tx"]
self.lockImg = uiMap["cell.title_img.grey_title_img.lock_img"]
self.picItemImgs = {
uiMap["cell.pic_img_1"],
uiMap["cell.pic_img_2"],
uiMap["cell.pic_img_3"]
}
self.maskBgs = {
uiMap["cell.pic_img_1.mask_img"],
uiMap["cell.pic_img_2.mask_img"],
uiMap["cell.pic_img_3.mask_img"]
}
self.checkImgs = {
uiMap["cell.pic_img_1.check_img"],
uiMap["cell.pic_img_2.check_img"],
uiMap["cell.pic_img_3.check_img"]
}
self.passedTxs = {
uiMap["cell.pic_img_1.passed_tx"],
uiMap["cell.pic_img_2.passed_tx"],
uiMap["cell.pic_img_3.passed_tx"]
}
self.lockTxs = {
uiMap["cell.pic_img_1.lock_tx"],
uiMap["cell.pic_img_2.lock_tx"],
uiMap["cell.pic_img_3.lock_tx"]
}
end
function ChapterCell:refresh(cfgdatas)
self.cfgDatas = cfgdatas
self.chapterId = self.cfgDatas[1].cfg.chapter
self.chapterCfg = chapterCfg[self.chapterId]
self.chapterIndex = DataManager.StageData:getChapter(self.chapterId)
self:initConstantTxt()
local canChapterChallenge = self.Data:canChallengeChapter(self.chapterId)
self:initPicItem(canChapterChallenge)
self.normalTitleImg:setActive(canChapterChallenge)
self.greyTitleImg:setActive(not canChapterChallenge)
self:bindEvent()
end
function ChapterCell:initConstantTxt()
local strCfg = I18N:getConfig("chapter")[self.chapterId]
self.titleTxNormal:setText(strCfg.name)
self.titleTxGrey:setText(I18N:getGlobalText(I18N.GlobalConst.PASSED_CHAPTER_TO_UNLOCK_DESC, self.chapterIndex))
for i = 1, 3 do
self.passedTxs[i]:setText(I18N:getGlobalText(I18N.GlobalConst.ALREADY_GOT_DESC))
self.lockTxs[i]:setText(I18N:getGlobalText(I18N.GlobalConst.PASSED_BEFORE_CHALLENGE_TO_UNLOCK_DESC))
end
end
function ChapterCell:initPicItem(canChapterChallenge)
for i = 1, 3 do
self.picItemImgs[i]:setActive(canChapterChallenge)
if canChapterChallenge then
self.picItemImgs[i]:setSprite(GConst.ATLAS_PATH.UI_CHALLENGE, self.cfgDatas[1].cfg.icon)
local passed = self.Data:getIsPassed(self.cfgDatas[i].cfgid)
self.passedTxs[i]:setActive(passed)
self.checkImgs[i]:setActive(passed)
local canChallenge = self.Data:canChallengeByCfgId(self.cfgDatas[i].cfgid)
self.lockTxs[i]:setActive(not canChallenge)
self.maskBgs[i]:setActive(passed or (not canChallenge))
end
end
end
function ChapterCell:bindEvent()
for i = 1, 3 do
self.picItemImgs[i]:addClickListener(function()
local canChallenge = self.Data:canChallengeByCfgId(self.cfgDatas[i].cfgid)
if not canChallenge then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.PASSED_BEFORE_CHALLENGE_TO_UNLOCK_DESC))
return
end
-- 打开挑战界面
local params = {}
params.cfgData = self.cfgDatas[i]
ModuleManager.ChallengeManager:showChallengeReadyUI(params)
end)
end
end
return ChapterCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2caa68f00f1473146b03262e5fb6c7a3
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,36 @@
local StageComp = class("StageComp", LuaComponent)
local STAGE_CELL = "app/ui/stage/cell/chapter_cell"
function StageComp:init()
local uiMap = self.baseObject:genAllChildren()
self.cellList = uiMap["challenge_ui.scrollrect"]
-- 刷新UI
self:bind(DataManager.StageData, "isDirty", function(binder, value)
self:refresh()
end)
end
function StageComp:refresh()
self:initScrollRect()
end
function StageComp:initScrollRect()
local listCfgs = self.Data:getListChallengeCfg()
self.scrollRect = self.cellList:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.scrollRect:addInitCallback(function()
return STAGE_CELL
end)
self.scrollRect:addRefreshCallback(function(index, cell)
cell:refresh(listCfgs[index])
end)
self.scrollRect:clearCells()
self.scrollRect:setTotalCount(#listCfgs)
self.scrollRect:refillCells(#listCfgs)
self.scrollRect:moveToIndex(self.Data:getFirstNotPassedChallengeIndex())
end
function StageComp:onDestroy()
self:unBindAll()
end
return StageComp

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4bdb95384e09f054a81ac063e25b0d4a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -1,4 +1,3 @@
---@class BagData : BaseData
local BagData = class("BagData", BaseData) local BagData = class("BagData", BaseData)
local ItemConst = require "app/module/item/item_const" local ItemConst = require "app/module/item/item_const"

View File

@ -1,5 +1,4 @@
local EquipEntity = require "app/userdata/bag/equip_entity" local EquipEntity = require "app/userdata/bag/equip_entity"
---@class EquipData
local EquipData = class("EquipData", BaseData) local EquipData = class("EquipData", BaseData)
function EquipData:setDirty() function EquipData:setDirty()

View File

@ -1,4 +1,3 @@
---@class BaseData
local BaseData = class("BaseData") local BaseData = class("BaseData")
function BaseData:ctor(...) function BaseData:ctor(...)

View File

@ -0,0 +1,31 @@
local HeroEntity = require "app/userdata/hero/hero_entity"
local HeroData = class("HeroData", BaseData)
function HeroData:ctor()
self.heroes = {}
self.heroCount = 0
end
function HeroData:clear()
self.heroes = {}
end
function HeroData:init(data)
self.heroes = {}
self.heroCount = 0
data = data or {}
for id, info in pairs(data) do
self:_addHero(info)
self.heroCount = self.heroCount + 1
end
end
function HeroData:_addHero(heroInfo)
self.heroes[heroInfo.cfg_id] = HeroEntity:create(heroInfo)
end
function HeroData:getHeroes()
return self.heroes
end
return HeroData

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 3d3ddf9f5b9c8ec4182c3c03d18b74bf
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,126 @@
local HeroEntity = class("HeroEntity", BaseData)
function HeroEntity:ctor(heroInfo)
self.id = heroInfo.id or 1
self.cfgId = heroInfo.cfg_id or self.id
self.data.lv = heroInfo.lv or 1
self.attrDirty = false
self.data.powerDirty = false
self:_loadConfig()
self.baseAttrOriginal = {}
self:initAttrTab()
self:updateAttr()
end
function HeroEntity:initAttrTab()
self.allAttr = {}
local cfg = ConfigManager:getConfig("attr")
for i = 1, #cfg do
self.allAttr[i] = {unit = 0, value = 0}
end
end
function HeroEntity:_loadConfig()
self.config = ConfigManager:getConfig("hero")[self.cfgId]
end
function HeroEntity:setHid(id)
self.id = id
end
function HeroEntity:getHid()
return self.id
end
function HeroEntity:getId()
return self.cfgId
end
function HeroEntity:setId(id)
if not id then
return
end
self.cfgId = id
self:_loadConfig()
self:setDirty()
end
function HeroEntity:setLv(lv)
if not lv then
return
end
self.data.lv = lv
self:setDirty()
end
function HeroEntity:getLv()
return self.data.lv
end
function HeroEntity:setAttrDirty()
self.attrDirty = true
end
function HeroEntity:getAllAttr()
if self.attrDirty == true then
self.attrDirty = false
self:updateAttr()
end
return self.allAttr
end
function HeroEntity:updateAttr()
self:updateBaseAttr()
self:_updateAllAttr()
self:calculatePower()
end
function HeroEntity:updateBaseAttr()
self.baseAttrOriginal[GConst.ATTR_TYPE.hp] = self.config.hp or 0
self.baseAttrOriginal[GConst.ATTR_TYPE.atk] = self.config.atk or 0
end
function HeroEntity:getAtk()
return self.allAttr[GConst.ATTR_TYPE.atk] or 0
end
function HeroEntity:getHp()
return self.allAttr[GConst.ATTR_TYPE.hp] or 0
end
function HeroEntity:setDirty()
self.attrDirty = true
end
function HeroEntity:canLvUp()
if self:isMaxLv() then
return false
end
local cost = self:getLvUpMaterials()
if not cost then
return false
end
for _, reward in ipairs(cost) do
if not GFunc.checkCost(reward.id, reward.num, false) then
return false
end
end
return true
end
function HeroEntity:getLvUpMaterials()
local nextLvInfo = ConfigManager:getConfig("hero_up")[self.data.lv + 1]
if not nextLvInfo then
return
end
return nextLvInfo.exp
end
return HeroEntity

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2432b989facc69d41a445b0237aa79b5
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,6 @@
local PlayerData = class("PlayerData", BaseData)
function PlayerData:init(data)
end
return PlayerData

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e1b54091cd01aa74e86120fd11015c1a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 167ddee3cbf9bb34287bd6d074f66f78
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,426 @@
local StageData = class("StageData", BaseData)
function StageData:ctor()
self.data.chapterId = 0
self.data.maxChapterId = 0
self.data.isDirty = false
self.chapterInfo = {}
self.data.showUnlockId = nil
self.patternMaxChapterId = {}
self.chapterBestWave = {} -- 每一个章节的最佳波次
end
function StageData:clear()
self.data.chapterId = 0
self.data.maxChapterId = 0
self.chapterInfo = {}
end
function StageData:init(data)
data = data or {}
for id, info in pairs(data) do
self.chapterInfo[id] = info
if id > self.data.chapterId then
self.data.chapterId = id
end
if info.passed and id > self.data.maxChapterId and self:isNromalPattern(id) then
self.data.maxChapterId = id
end
if info.passed then
local pattern = self:getChapterPattern(id)
if not self.patternMaxChapterId[pattern] then
self.patternMaxChapterId[pattern] = 0
end
if id > self.patternMaxChapterId[pattern] then
self.patternMaxChapterId[pattern] = id
end
end
end
self.data.chapterId = self:getNewChapterId()
if self.data.chapterId == 0 then
self.data.chapterId = 101 -- 默认关卡
end
end
function StageData:getChapter(chapterId)
chapterId = chapterId or self.data.chapterId
return math.floor(chapterId % 100 + 0.00001)
end
function StageData:getPassedMaxChapter()
return math.floor(self.data.maxChapterId % 100 + 0.00001)
end
function StageData:getChapterId()
-- return self.data.chapterId
return self.data.chapterId or 101
end
function StageData:getMaxChapterId(pattern)
-- if not pattern or pattern == GConst.StageConst.CHAPTER_PATTERN.NORMAL then
return self.data.maxChapterId
-- else
-- return self.patternMaxChapterId[pattern] or 0
-- end
end
function StageData:getNewChapterId()
local maxPassedId = self:getMaxChapterId()
local maxId = self:getChapterId()
local maxCfg = ConfigManager:getConfig("chapter")[maxPassedId]
if maxCfg and maxCfg.next_chapter then
maxId = maxCfg.next_chapter
else
maxId = maxPassedId
end
maxId = math.max(maxId, 101)
return maxId
end
function StageData:getChapterInfo(chapter)
chapter = chapter or self.data.chapterId
-- 容错处理
if not self.chapterInfo[chapter] then
self.chapterInfo[chapter] = {
liveTime = 0,
passed = false,
boxReward = {},
fightCount = 0,
bestWave = 0,
}
end
-- 容错处理
if not self.chapterInfo[chapter].bestWave then
self.chapterInfo[chapter].bestWave = 0
end
return self.chapterInfo[chapter]
end
function StageData:setChapterInfo(chapter, liveTime, passed, wave, boxReward)
if not self.chapterInfo[chapter] then
self.chapterInfo[chapter] = {
liveTime = 0,
passed = false,
boxReward = {},
fightCount = 0,
bestWave = 0,
}
end
if liveTime and liveTime > self.chapterInfo[chapter].liveTime then
self.chapterInfo[chapter].liveTime = liveTime
end
-- 容错处理
if not self.chapterInfo[chapter].bestWave then
self.chapterInfo[chapter].bestWave = 0
end
if wave and wave > self.chapterInfo[chapter].bestWave then
self.chapterInfo[chapter].bestWave = wave
end
if passed ~= nil and not self.chapterInfo[chapter].passed then
self.chapterInfo[chapter].passed = passed
end
if boxReward ~= nil then
self.chapterInfo[chapter].boxReward = boxReward
end
if passed and chapter > self.data.maxChapterId and self:isNromalPattern(chapter) then
self.data.maxChapterId = chapter
self.data.chapterId = self:getNewChapterId()
if self.data.chapterId ~= chapter then
self.data.showUnlockId = self.data.chapterId
end
local data = {}
data.max_chapter = self.data.chapterId
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
local id = math.floor(self.data.maxChapterId % 100 + 0.00001)
DataManager.ActivityGiftData:activeChapterPopGift(id)
end
if passed then
local pattern = self:getChapterPattern(chapter)
local change = false
if not self.patternMaxChapterId[pattern] then
self.patternMaxChapterId[pattern] = 0
end
if chapter > self.patternMaxChapterId[pattern] then
self.patternMaxChapterId[pattern] = chapter
change = true
end
local maxPassedId = self:getMaxChapterId(pattern)
if change and not self:isNromalPattern(chapter) then
local maxId = self:getChapterId()
local maxCfg = ConfigManager:getConfig("chapter")[maxPassedId]
if maxCfg and maxCfg.next_chapter then
maxId = maxCfg.next_chapter
else
maxId = maxPassedId
end
maxId = math.max(maxId, 201)
self.data.chapterId = maxId
end
end
-- DataManager.ActivityData:activeChapterPopGift(2)
end
function StageData:addFightCount(chapter)
if not self.chapterInfo[chapter] then
self.chapterInfo[chapter] = {
liveTime = 0,
passed = false,
boxReward = {},
fightCount = 0,
bestWave = 0,
}
end
if not self.chapterInfo[chapter].fightCount then
self.chapterInfo[chapter].fightCount = 0
end
self.chapterInfo[chapter].fightCount = self.chapterInfo[chapter].fightCount + 1
end
function StageData:getChapterInfoCount(chapter)
if not self.chapterInfo[chapter] then
return 0
end
self.chapterInfo[chapter].fightCount = self.chapterInfo[chapter].fightCount or 0
return self.chapterInfo[chapter].fightCount
end
function StageData:getChapterWave(chapterId)
if not self.chapterInfo[chapterId] then
self.chapterInfo[chapterId] = {
liveTime = 0,
passed = false,
boxReward = {},
fightCount = 0,
bestWave = 0,
}
end
return self.chapterInfo[chapterId].bestWave
end
function StageData:getChapterBox(chapterId, boxIndex)
if not self.chapterInfo[chapterId] then
return
end
for _, index in ipairs(self.chapterInfo[chapterId].boxReward) do
if index == boxIndex then
return
end
end
table.insert(self.chapterInfo[chapterId].boxReward, boxIndex)
self:setDirty()
end
function StageData:getChapterGenMonsterSteps(chapterId)
local stageChapterInfo = ConfigManager:getConfig("chapter")[chapterId]
if stageChapterInfo == nil then
return nil
end
return stageChapterInfo.stage
end
function StageData:changeChapterId(chapterId)
if not chapterId then
return
end
self.data.chapterId = chapterId
self:setDirty()
end
function StageData:setDirty()
self.data.isDirty = not self.data.isDirty
end
function StageData:getAllChapterInfo()
return self.chapterInfo
end
function StageData:getCurBoxChapterId()
local curpattern = self:getChapterPattern(self.data.chapterId)
local minChapterId
for id, info in pairs(self.chapterInfo) do
if id < self.data.chapterId and (not info.boxReward or #info.boxReward < 3) and curpattern == self:getChapterPattern(id) then -- 小于当前章节,并且没有领完奖励
if not minChapterId then
minChapterId = id
elseif minChapterId > id then
minChapterId = id
end
end
end
minChapterId = minChapterId or self.data.chapterId
return minChapterId
end
-- 获取指定章节当前小关卡阶段(箱子阶段)
function StageData:getCurStageIdByChapterId(chapterId)
if not chapterId then
chapterId = self.data.maxChapterId
end
if chapterId < self.data.maxChapterId then
return BIReport.FIGHT_STAGE_TYPE.THIRD
end
if not self.chapterInfo or not self.chapterInfo[chapterId] then
return BIReport.FIGHT_STAGE_TYPE.FIRST
end
if self.chapterInfo[chapterId].passed then
return BIReport.FIGHT_STAGE_TYPE.THIRD
end
local cfg = ConfigManager:getConfig("chapter")[chapterId]
if not cfg then
return BIReport.FIGHT_STAGE_TYPE.FIRST
end
if self.chapterInfo[chapterId].bestWave >= cfg.wave_1 then
return BIReport.FIGHT_STAGE_TYPE.THIRD
end
if self.chapterInfo[chapterId].bestWave >= cfg.wave_2 then
return BIReport.FIGHT_STAGE_TYPE.SECOND
end
return BIReport.FIGHT_STAGE_TYPE.FIRST
end
-- 获取指定章节当前小关卡阶段(箱子阶段)
function StageData:getCurStageIdByChapterDuration(chapterId, chapterDuration)
--local cfg = ConfigManager:getConfig("chapter")[chapterId]
--if not cfg then
-- return BIReport.FIGHT_STAGE_TYPE.FIRST
--end
--if chapterDuration > cfg.time_2*60 then
-- return BIReport.FIGHT_STAGE_TYPE.THIRD
--end
--if chapterDuration > cfg.time_1*60 then
-- return BIReport.FIGHT_STAGE_TYPE.SECOND
--end
return BIReport.FIGHT_STAGE_TYPE.FIRST
end
function StageData:getChapterUnlock()
return self.data.showUnlockId
end
function StageData:clearChapterUnlock()
self.data.showUnlockId = nil
end
function StageData:isNromalPattern(chapterId)
-- local pattern = self:getChapterPattern(chapterId)
-- return pattern == GConst.StageConst.CHAPTER_PATTERN.NORMAL
return true
end
function StageData:getChapterPattern(chapterId)
return chapterId // 100
end
function StageData:getDefaultHardId()
return 201
end
function StageData:getDefaultId()
return 101
end
function StageData:passChapter(chapterId)
local pattern = self:getChapterPattern(chapterId)
local maxId = self:getMaxChapterId(pattern)
return maxId >= chapterId
end
function StageData:getIsReceived(boxRewards, index)
if boxRewards then
for _, i in ipairs(boxRewards) do
if i == index then
return true
end
end
end
return false
end
function StageData:getFirstNotClaimChapterId()
local result = self:getChapterId()
local maxChapterId = self:getNewChapterId()
---@type ChapterCfg[]
local chaperCfgs = ConfigManager:getConfig("chapter")
for cfgId, cfg in pairs(chaperCfgs) do
if cfgId <= maxChapterId then
local showRedPoint = self:showMainCompRedPoint(cfgId)
if showRedPoint then
result = cfgId
break
end
end
end
return result
end
function StageData:showMainCompRedPoint(targetChapterId)
local chapterId = targetChapterId and targetChapterId or self:getFirstNotClaimChapterId()
local chapterInfo = self:getChapterInfo(chapterId)
---@type ChapterCfg
local cfg = ConfigManager:getConfig("chapter")[chapterId]
local step = {
cfg.wave_1,
cfg.wave_2
}
local rewardBox = {}
if chapterInfo.boxReward then
for _, id in ipairs(chapterInfo.boxReward) do
rewardBox[id] = true
end
end
-- 前两个
local showEffect = false
for i = 1, 2 do
showEffect = false
if chapterInfo.bestWave >= step[i] and not rewardBox[i] then
return true
end
end
-- 最后一个
showEffect = false
if chapterInfo.passed and not rewardBox[3] then
showEffect = true
end
return showEffect
end
function StageData:getFirstNoClaimIndex(chapterId)
local chapterInfo = self:getChapterInfo(chapterId)
---@type ChapterCfg
local cfg = ConfigManager:getConfig("chapter")[chapterId]
local step = {
cfg.wave_1,
cfg.wave_2
}
local rewardBox = {}
if chapterInfo.boxReward then
for _, id in ipairs(chapterInfo.boxReward) do
rewardBox[id] = true
end
end
local num = 3
for i = 1, num do
if not rewardBox[i] then
return i
end
end
-- 否则默认第一个
return 1
end
return StageData

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 2a97518dbfab4cc44af1932b8fc96900
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}