This commit is contained in:
xiekaidong 2023-04-11 22:12:55 +08:00
commit b61b6a6f85
64 changed files with 909 additions and 1701 deletions

View File

@ -44,9 +44,9 @@ function CharacterSpineObject:initWithCharacterHelper(characterSpineHelper, inde
end end
function CharacterSpineObject:refreshSkeletonDataAsset(dataAsset) function CharacterSpineObject:refreshSkeletonDataAsset(dataAsset)
local skeletonAnimation = self:getSkeletonAnimation() local skeletonGraphic = self:getSkeletonGraphic()
skeletonAnimation.skeletonDataAsset = dataAsset skeletonGraphic.skeletonDataAsset = dataAsset
skeletonAnimation:Initialize(true) skeletonGraphic:Initialize(true)
self.characterSpineHelper:Reload() self.characterSpineHelper:Reload()
end end
@ -192,18 +192,11 @@ function CharacterSpineObject:removeAnimationCompleteCallback()
end end
end end
function CharacterSpineObject:getSkeletonAnimation() function CharacterSpineObject:getSkeletonGraphic()
if self.skeletonAnimation == nil then if self.skeletonGraphic == nil then
self.skeletonAnimation = self.characterSpineHelper:GetSkeletonAnimation() self.skeletonGraphic = self.characterSpineHelper:GetSkeletonGraphic()
end end
return self.skeletonAnimation return self.skeletonGraphic
end
function CharacterSpineObject:setSortingOrder(order)
if self.mainSpineMeshRenderer == nil then
self.mainSpineMeshRenderer = self.mainSpine:BFGetComponent(GConst.TYPEOF_UNITY_CLASS.MESH_RENDERER)
end
self.mainSpineMeshRenderer.sortingOrder = order
end end

View File

@ -10,6 +10,7 @@ function DataManager:init()
self:initManager("HeroData", "app/userdata/hero/hero_data") self:initManager("HeroData", "app/userdata/hero/hero_data")
self:initManager("BagData", "app/userdata/bag/bag_data") self:initManager("BagData", "app/userdata/bag/bag_data")
self:initManager("BattleData", "app/userdata/battle/battle_data") self:initManager("BattleData", "app/userdata/battle/battle_data")
self:initManager("FormationData", "app/userdata/formation/formation_data")
end end
function DataManager:initManager(name, path) function DataManager:initManager(name, path)
@ -68,6 +69,7 @@ function DataManager:clear()
self.ChapterData:clear() self.ChapterData:clear()
self.HeroData:clear() self.HeroData:clear()
self.BagData:clear() self.BagData:clear()
self.FormationData:clear()
ModuleManager.TaskManager:clear() ModuleManager.TaskManager:clear()
end end
@ -85,6 +87,7 @@ function DataManager:initWithServerData(data)
self.ChapterData:init(data.ChapterData) self.ChapterData:init(data.ChapterData)
self.HeroData:init(data.HeroData) self.HeroData:init(data.HeroData)
self.BagData:init(data) self.BagData:init(data)
self.FormationData:init(data.FormationData)
self:scheduleGlobal() self:scheduleGlobal()
self:checkDataBind() self:checkDataBind()

View File

@ -11,8 +11,6 @@ local LOCAL_DATA_KEY = {
MESSAGE_BOX_SHOW_TODAY = "MESSAGE_BOX_SHOW_TODAY", MESSAGE_BOX_SHOW_TODAY = "MESSAGE_BOX_SHOW_TODAY",
GAME_QUALITY_LEVEL = "GAME_QUALITY_LEVEL", -- 游戏设置品质等级 GAME_QUALITY_LEVEL = "GAME_QUALITY_LEVEL", -- 游戏设置品质等级
LAST_LOGIN_URL = "LAST_LOGIN_URL", LAST_LOGIN_URL = "LAST_LOGIN_URL",
LAST_LOGIN_INFO = "LAST_LOGIN_INFO", -- 上一次登录成功的信息
LAST_LOGIN_TYPE = "LAST_LOGIN_TYPE", -- 上次登录类型 token不记录
LAST_LOGIN_NAME = "LAST_LOGIN_NAME", LAST_LOGIN_NAME = "LAST_LOGIN_NAME",
LAST_LOGIN_IP = "LAST_LOGIN_IP", LAST_LOGIN_IP = "LAST_LOGIN_IP",
ACCOUNT_INFO = "ACCOUNT_INFO", ACCOUNT_INFO = "ACCOUNT_INFO",
@ -201,44 +199,6 @@ function LocalData:getIosOrders()
end end
end end
function LocalData:setLastLoginInfo(loginType, id, token)
local str = json.encode({
type = loginType,
id = id,
token = token
})
if not loginType then
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_TYPE, "")
elseif loginType ~= "token" then
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_TYPE, loginType)
end
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_INFO, str)
end
function LocalData:getLastLoginInfo()
local str = self:getString(LOCAL_DATA_KEY.LAST_LOGIN_INFO, "{}")
local info = json.decode(str)
info.type = info.type or NetManager.LOGIN_TYPE.ANONYMOUS
info.id = info.id or DeviceHelper:getDeviceId()
info.token = info.token
return info
end
function LocalData:getLastLoginType()
local str = self:getString(LOCAL_DATA_KEY.LAST_LOGIN_TYPE, "")
if str == "" then
str = NetManager.LOGIN_TYPE.ANONYMOUS
end
if str ~= NetManager.LOGIN_TYPE.ANONYMOUS and
str ~= NetManager.LOGIN_TYPE.APPLE and
str ~= NetManager.LOGIN_TYPE.GOOGLE and
str ~= NetManager.LOGIN_TYPE.FACEBOOK
then
str = NetManager.LOGIN_TYPE.ANONYMOUS
end
return str
end
function LocalData:setLastLoginName(name) function LocalData:setLastLoginName(name)
name = name or "" name = name or ""
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_NAME, name) self:setString(LOCAL_DATA_KEY.LAST_LOGIN_NAME, name)

View File

@ -11,6 +11,7 @@ local MODULE_PATHS = {
ToastManager = "app/ui/common/toast", ToastManager = "app/ui/common/toast",
TaskManager = "app/module/task/task_manager", TaskManager = "app/module/task/task_manager",
BattleManager = "app/module/battle/battle_manager", BattleManager = "app/module/battle/battle_manager",
FormationManager = "app/module/formation/formation_manager",
} }
-- 这里的key对应func_open里的id -- 这里的key对应func_open里的id

View File

@ -157,8 +157,6 @@ if NOT_PUBLISH then
[SDKManager.tryLoadRewardedAdDelay] = true, [SDKManager.tryLoadRewardedAdDelay] = true,
[ScrollRectBase.refillCells] = true, [ScrollRectBase.refillCells] = true,
[DataManager.scheduleGlobal] = true, [DataManager.scheduleGlobal] = true,
[NetManager.performWithDelayGlobal] = true,
[NetManager.scheduleGlobal] = true,
} }
end end
end end

View File

@ -280,15 +280,15 @@ function SDKManager:showFullScreenAds(adsClickType, adCallback)
return true return true
end end
if NetManager:isNotReachable() then -- if NetManager:isNotReachable() then
-- 没有网 -- -- 没有网
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NO_NETWORK)) -- GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NO_NETWORK))
return false -- return false
end -- end
if NetManager:getIsBusy() then -- if NetManager:getIsBusy() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NETWORK_ERROE_1)) -- GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NETWORK_ERROE_1))
return false -- return false
end -- end
if DataManager.MallActData:skipAd() then if DataManager.MallActData:skipAd() then
self:adRewradAd(true) self:adRewradAd(true)
if adCallback then if adCallback then

View File

@ -377,9 +377,9 @@ function SDKPayGoogleManager:doUncompletePay(callback)
if not DataManager:getLoginSuccess() then if not DataManager:getLoginSuccess() then
return return
end end
if NetManager:getIsBusy() then -- if NetManager:getIsBusy() then
return -- return
end -- end
if self:_getIsGoogleStoreConnected() then if self:_getIsGoogleStoreConnected() then
-- google商店是否初始化 -- google商店是否初始化
self.alreadyFinishUncompletePay = true self.alreadyFinishUncompletePay = true

View File

@ -277,9 +277,9 @@ function SDKPayiOSManager:doUncompletePay(callback)
if not DataManager:getLoginSuccess() then if not DataManager:getLoginSuccess() then
return return
end end
if NetManager:getIsBusy() then -- if NetManager:getIsBusy() then
return -- return
end -- end
if self:_getIsIosInitialized() then if self:_getIsIosInitialized() then
self.alreadyFinishUncompletePay = true self.alreadyFinishUncompletePay = true

View File

@ -1,27 +0,0 @@
local ServerPushManager = {}
---- 注册推送监听
function ServerPushManager:addServerPushListener(msgName, module, callback)
NetManager:registerMsgCallback(msgName, module, callback)
end
---- 移除推送监听
function ServerPushManager:removeServerPushListener(msgName, module)
NetManager:unRegisterMsgCallback(msgName, module)
end
---- 初始化全局推送监听
function ServerPushManager:initWhenLogin()
self:addServerPushListener(ProtoMsgType.FromMsgEnum.KickOutNtf, UIManager, UIManager.showKickOut)
self:addServerPushListener(ProtoMsgType.FromMsgEnum.MallActTriggerGiftNtf, ModuleManager.MallManager, ModuleManager.MallManager.MallActTriggerGiftNtf)
self:addServerPushListener(ProtoMsgType.FromMsgEnum.BattlePassBoughtNtf, ModuleManager.BountyManager, ModuleManager.BountyManager.buyCardFinish)
self:addServerPushListener(ProtoMsgType.FromMsgEnum.SummonPoolLevelNtf, ModuleManager.SummonManager, ModuleManager.SummonManager.SummonPoolLevelNtf)
self:addServerPushListener(ProtoMsgType.FromMsgEnum.NewMailNtf, ModuleManager.MailManager, ModuleManager.MailManager.needUpdateMail)
end
---- 移除全局推送监听
function ServerPushManager:removeWhenLoginOut()
self:removeServerPushListener(ProtoMsgType.FromMsgEnum.KickOutNtf, UIManager)
end
return ServerPushManager

View File

@ -60,7 +60,7 @@ function SpineManager:loadUISpinePrefabAsync(parent, spineAssetPath, spineAsset,
end end
function SpineManager:loadHeroAsync(id, parent, callback) function SpineManager:loadHeroAsync(id, parent, callback)
local path = "assets/prefabs/spine/mesh/characters/" .. id .. ".prefab" local path = "assets/prefabs/spine/ui/characters/" .. id .. ".prefab"
ResourceManager:loadAsync(path, TYPE_OF_GAME_OBJECT, function(assetPath, prefab) ResourceManager:loadAsync(path, TYPE_OF_GAME_OBJECT, function(assetPath, prefab)
if parent and parent:isDestroyed() then if parent and parent:isDestroyed() then
ResourceManager:destroyPrefab(prefab) ResourceManager:destroyPrefab(prefab)

View File

@ -1,6 +1,6 @@
local skill_hero = { local skill_hero = {
[10]={ [10]={
["energy"]=3, ["energy"]=10,
["position"]=3, ["position"]=3,
["method"]=2, ["method"]=2,
["skill_type"]=1, ["skill_type"]=1,
@ -18,7 +18,7 @@ local skill_hero = {
["battle_icon"]=1 ["battle_icon"]=1
}, },
[20]={ [20]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -35,7 +35,7 @@ local skill_hero = {
["battle_icon"]=2 ["battle_icon"]=2
}, },
[21]={ [21]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=1, ["method"]=1,
["skill_type"]=2, ["skill_type"]=2,
@ -70,7 +70,7 @@ local skill_hero = {
["battle_icon"]=2 ["battle_icon"]=2
}, },
[30]={ [30]={
["energy"]=3, ["energy"]=10,
["position"]=4, ["position"]=4,
["method"]=2, ["method"]=2,
["skill_type"]=1, ["skill_type"]=1,
@ -84,7 +84,7 @@ local skill_hero = {
["battle_icon"]=3 ["battle_icon"]=3
}, },
[40]={ [40]={
["energy"]=3, ["energy"]=10,
["position"]=5, ["position"]=5,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -101,7 +101,7 @@ local skill_hero = {
["battle_icon"]=4 ["battle_icon"]=4
}, },
[50]={ [50]={
["energy"]=3, ["energy"]=10,
["position"]=1, ["position"]=1,
["method"]=2, ["method"]=2,
["skill_type"]=1, ["skill_type"]=1,
@ -119,7 +119,7 @@ local skill_hero = {
["battle_icon"]=5 ["battle_icon"]=5
}, },
[60]={ [60]={
["energy"]=3, ["energy"]=10,
["position"]=3, ["position"]=3,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -136,7 +136,7 @@ local skill_hero = {
["battle_icon"]=6 ["battle_icon"]=6
}, },
[70]={ [70]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -153,7 +153,7 @@ local skill_hero = {
["battle_icon"]=7 ["battle_icon"]=7
}, },
[71]={ [71]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=1, ["method"]=1,
["skill_type"]=2, ["skill_type"]=2,
@ -189,7 +189,7 @@ local skill_hero = {
["battle_icon"]=7 ["battle_icon"]=7
}, },
[72]={ [72]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=1, ["method"]=1,
["skill_type"]=2, ["skill_type"]=2,
@ -232,7 +232,7 @@ local skill_hero = {
["battle_icon"]=7 ["battle_icon"]=7
}, },
[80]={ [80]={
["energy"]=3, ["energy"]=10,
["position"]=4, ["position"]=4,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -254,7 +254,7 @@ local skill_hero = {
["battle_icon"]=8 ["battle_icon"]=8
}, },
[81]={ [81]={
["energy"]=3, ["energy"]=10,
["position"]=4, ["position"]=4,
["method"]=2, ["method"]=2,
["skill_type"]=1, ["skill_type"]=1,

View File

@ -73,13 +73,11 @@ function Game:initOther()
BF.exports.EffectManager = require "app/common/effect_manager" BF.exports.EffectManager = require "app/common/effect_manager"
BF.exports.SpineManager = require "app/common/spine_manager" BF.exports.SpineManager = require "app/common/spine_manager"
BF.exports.WebRequestManager = require "app/common/webrequest_manager" BF.exports.WebRequestManager = require "app/common/webrequest_manager"
BF.exports.NetManager = require "app/net/net_manager"
BF.exports.I18N = require "app/common/i18n_manager" BF.exports.I18N = require "app/common/i18n_manager"
BF.exports.CellManager = require "app/common/cell_manager" BF.exports.CellManager = require "app/common/cell_manager"
BF.exports.Time = require "app/common/time" BF.exports.Time = require "app/common/time"
BF.exports.BaseData = require "app/userdata/base_data" BF.exports.BaseData = require "app/userdata/base_data"
BF.exports.BaseObject = require "app/bf/unity/base_object" BF.exports.BaseObject = require "app/bf/unity/base_object"
BF.exports.ServerPushManager = require "app/common/server_push_manager"
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"
@ -95,7 +93,6 @@ function Game:initOther()
CameraManager:init() CameraManager:init()
WebRequestManager:init() WebRequestManager:init()
NetManager:init()
I18N:init() I18N:init()
ServerDataManager:init() ServerDataManager:init()
DataManager:init() DataManager:init()
@ -143,13 +140,11 @@ function Game:specialForIdea()
EffectManager = EffectManager or require "app/common/effect_manager" EffectManager = EffectManager or require "app/common/effect_manager"
SpineManager = SpineManager or require "app/common/spine_manager" SpineManager = SpineManager or require "app/common/spine_manager"
WebRequestManager = WebRequestManager or require "app/common/webrequest_manager" WebRequestManager = WebRequestManager or require "app/common/webrequest_manager"
NetManager = NetManager or require "app/net/net_manager"
I18N = I18N or require "app/common/i18n_manager" I18N = I18N or require "app/common/i18n_manager"
CellManager = CellManager or require "app/common/cell_manager" CellManager = CellManager or require "app/common/cell_manager"
Time = Time or require "app/common/time" Time = Time or require "app/common/time"
BaseData = BaseData or require "app/userdata/base_data" BaseData = BaseData or require "app/userdata/base_data"
BaseObject = BaseObject or require "app/bf/unity/base_object" BaseObject = BaseObject or require "app/bf/unity/base_object"
ServerPushManager = ServerPushManager or require "app/module/login/server_push_manager"
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"

View File

@ -10,6 +10,7 @@ local CONST_PATHS = {
TutorialConst = "app/module/tutorial/tutorial_const", TutorialConst = "app/module/tutorial/tutorial_const",
BattleConst = "app/module/battle/battle_const", BattleConst = "app/module/battle/battle_const",
HeroConst = "app/module/hero/hero_const", HeroConst = "app/module/hero/hero_const",
FormationConst = "app/module/formation/formation_const",
} }
if EDITOR_MODE then if EDITOR_MODE then
@ -366,6 +367,16 @@ GConst.HERO_FRAME_QLT = {
[7] = "frame_7", [7] = "frame_7",
} }
GConst.HERO_FRAME_GRAY_QLT = {
[1] = "frame_gray_1",
[2] = "frame_gray_2",
[3] = "frame_gray_3",
[4] = "frame_gray_4",
[5] = "frame_gray_5",
[6] = "frame_gray_6",
[7] = "frame_gray_7",
}
GConst.QLT_LABLE = { GConst.QLT_LABLE = {
DEFAULT = "equip_quality_1", DEFAULT = "equip_quality_1",
GRAY = "equip_quality_1", GRAY = "equip_quality_1",

View File

@ -1535,25 +1535,6 @@ function GFunc.getRewardTable(type, id, count)
} }
end end
function GFunc.formatRewardsToServerStruct(rewardList)
local rewards = {}
for _, reward in ipairs(rewardList) do
local serverReward = GFunc.getServerRewardTable(reward.type, reward.id, reward.count)
table.insert(rewards, serverReward)
end
return rewards
end
function GFunc.getServerRewardTable(type, id, count)
if type == GConst.REWARD_TYPE.ITEM then
return GFunc.getServerItemRewardTable(id, count)
elseif type == GConst.REWARD_TYPE.RUNES then
return GFunc.getServerRuneRewardTable(id, BigNumOpt.bigNum2Num(count))
elseif type == GConst.REWARD_TYPE.EQUIP then
return GFunc.getServerEquipRewardTable(id, count)
end
end
function GFunc.getServerRuneRewardTable(id, level) function GFunc.getServerRuneRewardTable(id, level)
return { return {
type = GConst.REWARD_TYPE.RUNES, type = GConst.REWARD_TYPE.RUNES,

View File

@ -72,19 +72,6 @@ function BaseModule:removeAllEventListeners()
end end
end end
-- 阻塞式等待服务器回复以后再回调callback
function BaseModule:sendMessage(msgName, params, responseData, callback, getType, lockGame)
if lockGame == nil then
lockGame = true
end
NetManager:send(self, msgName, params, responseData, callback, lockGame, nil, getType)
end
-- 阻塞式等待所有指令完成以后再发送此消息并且锁界面等待服务器回复以后再回调callback
function BaseModule:sendMessageTillBeforeOver(msgName, params, responseData, callback, getType)
NetManager:sendTillBeforeOver(self, msgName, params, responseData, callback, true, nil, getType)
end
-- 各个模块的manager按各自需求来重写clear即可 -- 各个模块的manager按各自需求来重写clear即可
function BaseModule:clear() function BaseModule:clear()
end end

View File

@ -13,10 +13,20 @@ BattleConst.ELEMENT_WIGHT = 100
BattleConst.MAX_ELEMENT_WIGHT = 500 BattleConst.MAX_ELEMENT_WIGHT = 500
BattleConst.SIDE_ATK = 1 BattleConst.SIDE_ATK = 1
BattleConst.SIDE_DEF = 2 BattleConst.SIDE_DEF = 2
BattleConst.SKILL_TYPE_ACTIVE = 1
BattleConst.SKILL_SELECT_COUNT = 3 BattleConst.SKILL_SELECT_COUNT = 3
BattleConst.DEFAULT_FACTOR = 10000
BattleConst.INIT_POS_X = 200
BattleConst.UNIT_BODY_WIDTH = 100
-- 为方便存储,这里使用字符串
BattleConst.BATTLE_TYPE = { BattleConst.BATTLE_TYPE = {
STAGE = 1, STAGE = "1",
}
BattleConst.TYPEOF_LUA_COMP = {
BATTLE_HERO_COMPONENT = "app/module/battle/component/battle_hero_comp",
BATTLE_MONSTER_COMPONENT = "app/module/battle/component/battle_monster_comp",
} }
BattleConst.UNIT_STATE = { BattleConst.UNIT_STATE = {
@ -27,6 +37,10 @@ BattleConst.UNIT_STATE = {
DEAD = 4, -- 死亡 DEAD = 4, -- 死亡
} }
BattleConst.SPINE_ANIMATION_NAME = {
IDLE = "idle",
}
---- 格子类型 ---- 格子类型
BattleConst.GRID_TYPE = { BattleConst.GRID_TYPE = {
EMPTY = 0, EMPTY = 0,

View File

@ -0,0 +1,17 @@
local BattleConst = require "app/module/battle/battle_const"
local BattleUnitComp = require "app/module/battle/component/battle_unit_comp"
local BattleHeroComp = class("BattleHeroComp", BattleUnitComp)
local UNIT_STATE = BattleConst.UNIT_STATE
function BattleHeroComp:init()
self.battleMgr = CS.BF.BFMain.Instance.BattleMgr
end
function BattleHeroComp:initBase()
self.isDead = false
self.currState = UNIT_STATE.INIT
end
return BattleHeroComp

View File

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

View File

@ -3,12 +3,22 @@ local BattleConst = require "app/module/battle/battle_const"
local BattleUnitComp = class("BattleUnitComp", LuaComponent) local BattleUnitComp = class("BattleUnitComp", LuaComponent)
local UNIT_STATE = BattleConst.UNIT_STATE local UNIT_STATE = BattleConst.UNIT_STATE
local SIDE_ATK = BattleConst.SIDE_ATK
local SPINE_ANIMATION_NAME = BattleConst.SPINE_ANIMATION_NAME
function BattleUnitComp:ctor() function BattleUnitComp:ctor()
end end
function BattleUnitComp:init() function BattleUnitComp:initPosition()
self:_initBase() if self.unitEntity:getSide() == SIDE_ATK then
self.baseObject:setLocalPosition(-BattleConst.INIT_POS_X, 0, 0)
else
self.baseObject:setLocalPosition(BattleConst.INIT_POS_X, 0, 0)
end
end
function BattleUnitComp:playBorn()
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
end end
function BattleUnitComp:_initBase() function BattleUnitComp:_initBase()
@ -16,21 +26,44 @@ function BattleUnitComp:_initBase()
self.isDead = false self.isDead = false
end end
function BattleUnitComp:tick(dt) function BattleUnitComp:initWithEntity(modelId, entity, battleController, target)
if self.isClear then self.modelId = modelId
return self.unitEntity = entity
end self.battleController = battleController
if self.isDead then self.target = target
self:updateDead(dt) self:_initBase()
return self:initPosition()
end self:playBorn()
if self.currState == UNIT_STATE.IDLE then end
self:updateIdle(dt)
return function BattleUnitComp:hideOutsideScreen()
end if self.unitEntity:getSide() == SIDE_ATK then
if self.currState == UNIT_STATE.ATTACK then self.baseObject:setLocalPosition(-GConst.UI_SCREEN_WIDTH/2 - BattleConst.UNIT_BODY_WIDTH, 0, 0)
self:updateAttack(dt) else
self.baseObject:setLocalPosition(GConst.UI_SCREEN_WIDTH/2 + BattleConst.UNIT_BODY_WIDTH, 0, 0)
end end
end end
function BattleUnitComp:playAnimation(name, loop, forceRefresh)
self.currAnimationName = name
self.baseObject:playAnimation(name, loop, forceRefresh)
end
function BattleUnitComp:tick(dt)
-- if self.isClear then
-- return
-- end
-- if self.isDead then
-- self:updateDead(dt)
-- return
-- end
-- if self.currState == UNIT_STATE.IDLE then
-- self:updateIdle(dt)
-- return
-- end
-- if self.currState == UNIT_STATE.ATTACK then
-- self:updateAttack(dt)
-- end
end
return BattleUnitComp return BattleUnitComp

View File

@ -1,3 +1,5 @@
local BattleHelper = require "app/module/battle/helper/battle_helper"
local BattleController = class("BattleController") local BattleController = class("BattleController")
local BATTLE_BOARD_SKILL_HANDLE = require "app/module/battle/skill/battle_board_skill_handle" local BATTLE_BOARD_SKILL_HANDLE = require "app/module/battle/skill/battle_board_skill_handle"
@ -32,6 +34,11 @@ end
function BattleController:initOther() function BattleController:initOther()
end end
-- 需要额外加载的资源
function BattleController:loadOtherRes(callback)
return callback()
end
function BattleController:onLinkChange() function BattleController:onLinkChange()
for posId, entity in pairs(DataManager.BattleData:getGridEnties()) do for posId, entity in pairs(DataManager.BattleData:getGridEnties()) do
if entity:getCell() then if entity:getCell() then
@ -85,12 +92,59 @@ end
function BattleController:init(params) function BattleController:init(params)
params = params or {} params = params or {}
DataManager.BattleData:init(self:getInitBoard()) DataManager.BattleData:init(self:getInitBoard())
BattleHelper:init()
self:prepareFight()
end
function BattleController:prepareFight()
local count = 0
local totalCount = 2
local function onPreloadFinished()
count = count + 1
if count == totalCount then
self:onLoadComplete()
end
end
UIManager:closeAllUI() UIManager:closeAllUI()
self.battleUI = UIManager:showUI(self:getBattleUIPath()) self.battleUI = UIManager:showUI(self:getBattleUIPath())
self.battleUI:setController(self) self.battleUI:setController(self)
self.battleUI:addLoadUICompleteListener(function() self.battleUI:addLoadUICompleteListener(function()
self:initAllUnits(onPreloadFinished)
end) end)
self:loadOtherRes(onPreloadFinished)
end
function BattleController:initAllUnits(callback)
self.atkUnits = {}
self.defUnits = {}
local atkTeam = DataManager.BattleData:getAtkTeam()
local count = 0
local totalCount = atkTeam:getMembersCount()
local function onloadFinished()
count = count + 1
if count == totalCount then
callback()
end
end
local members = atkTeam:getAllMembers()
for k, v in pairs(members) do
local modelId = v:getModelId()
BattleHelper:loadBattleHeroModel(modelId, self.battleUI:getBattleNode(), function(spineObject)
local heroComp = spineObject:addLuaComponent(BattleConst.TYPEOF_LUA_COMP.BATTLE_HERO_COMPONENT)
heroComp:initWithEntity(modelId, v, self)
self.atkUnits[v:getMatchType()] = heroComp
if not v:getIsMainUnit() then
heroComp:hideOutsideScreen()
end
onloadFinished()
end)
end
if totalCount == 0 then
callback()
end
end
function BattleController:onLoadComplete()
end end
function BattleController:onTouchEvent(eventType, posId) function BattleController:onTouchEvent(eventType, posId)
@ -755,7 +809,7 @@ function BattleController:snapshotBoard()
end end
function BattleController:clear() function BattleController:clear()
BattleHelper:clear()
end end
function BattleController:endBattleAndExit() function BattleController:endBattleAndExit()

View File

@ -1,5 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 1c64e57074a12a04a98c2bd95599566a guid: 05735c0c843e6724883965982ae2da2b
folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -0,0 +1,52 @@
local BattleHelper = {}
function BattleHelper:init()
self.isClear = false
self.characterPools = {}
self.characterMap = {}
end
function BattleHelper:loadBattleHeroModel(id, parent, callback)
local pool = self.characterPools[id]
if pool and #pool > 0 then
local spineObject = table.remove(pool)
spineObject:setActive(true)
if self.characterMap then
self.characterMap[spineObject:getInstanceID()] = spineObject
end
callback(spineObject)
else
SpineManager:loadHeroAsync(id, parent, function(spineObject)
if self.characterMap then
self.characterMap[spineObject:getInstanceID()] = spineObject
callback(spineObject)
end
end)
end
end
function BattleHelper:recycleBattleHeroModel(modelId, character)
if character:isDestroyed() then
return
end
character:setActive(false)
if self.characterMap then
self.characterMap[character:getInstanceID()] = nil
end
if self.characterPools then
local pool = self.characterPools[modelId]
if pool == nil then
pool = {}
self.characterPools[modelId] = pool
end
table.insert(pool, character)
end
end
function BattleHelper:clear()
self.isClear = true
self.characterPools = nil
self.characterMap = nil
end
return BattleHelper

View File

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

View File

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

View File

@ -0,0 +1,20 @@
local FormationManager = class("FormationManager", BaseModule)
function FormationManager:upHeroToStageFormation(heroId, matchType)
local formation = DataManager.FormationData:getStageFormation()
if formation[matchType] == heroId then
return
end
local args = {
formationType = GConst.BattleConst.BATTLE_TYPE.STAGE,
matchType = matchType,
heroId = heroId
}
ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPDATE_FORMATION, args, function(msgData)
if msgData.status == 0 then
DataManager.FormationData:upHeroToFormation(GConst.BattleConst.BATTLE_TYPE.STAGE, matchType, heroId)
end
end)
end
return FormationManager

View File

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

View File

@ -30,98 +30,6 @@ Example: del_item]],
Example: clear_item]], Example: clear_item]],
type = "clear_item" type = "clear_item"
}, },
{
title = "通关",
desc = [[ type:pass_chapter
Example: pass_chapter 100]],
type = "pass_chapter"
},
-- {
-- title = "添加装备",
-- desc = [[添加装备 type:addEquip
-- arg1:equipId arg2:数量
-- Example: addEquip 10103 2]],
-- type = "addEquip"
-- },
-- {
-- title = "设置等级",
-- desc = [[清号 type:setLv
-- arg1:数量
-- Example: setLv 100]],
-- type = "setLv"
-- },
{
title = "全装备",
desc = [[ type:all_equips
Example: all_equips]],
type = "all_equips"
},
{
title = "全传家宝",
desc = [[ type:all_legacies
Example: all_legacies]],
type = "all_legacies"
},
{
title = "全符文",
desc = [[ type:all_runes
Example: all_runes]],
type = "all_runes"
},
{
title = "每日重置",
desc = [[ type:reset_by_day
Example: reset_by_day]],
type = "reset_by_day"
},
{
title = "设置时间",
desc = [[ type:time
Example: time 2023-3-9 18:10:59]],
type = "time"
},
{
title = "重置时间差",
desc = [[ type:time_diff
Example: time_diff 0]],
type = "time_diff"
},
{
title = "调整时间差",
desc = [[ type:add_time_diff
Example: add_time_diff 1000]],
type = "add_time_diff"
},
{
title = "设置引导任务状态",
desc = [[ type:task_tutor
Example: task_tutor id progress 0]],
type = "task_tutor"
},
{
title = "设置任务进度",
desc = [[ type:trig_event
Example: trig_event task_type progress]],
type = "trig_event"
},
{
title = "礼包购买",
desc = [[ type:add_gift 1.mall_act 2.mall_daily 3.mall_treasure
Example: add_gift 1 30001]],
type = "add_gift"
},
{
title = "新增邮件",
desc = [[ type:add_mail id
Example: add_mail 1]],
type = "add_mail"
},
{
title = "新增自定义邮件",
desc = [[ type:add_cumail title body attachment
Example: add_cumail title body attachment]],
type = "add_cumail"
},
} }
return GMConst return GMConst

View File

@ -2,6 +2,7 @@ local ItemConst = {}
ItemConst.ITEM_ID_GOLD = 1 ItemConst.ITEM_ID_GOLD = 1
ItemConst.ITEM_ID_GEM = 2 ItemConst.ITEM_ID_GEM = 2
ItemConst.ITEM_ID_VIT = 3
ItemConst.ITEM_TYPE = { ItemConst.ITEM_TYPE = {
RES = 1, RES = 1,

View File

@ -37,7 +37,6 @@ end
function LoginManager:goToLoginScene() function LoginManager:goToLoginScene()
ModuleManager.BattleManager:clearOnExitScene() ModuleManager.BattleManager:clearOnExitScene()
NetManager:closeAndClear()
UIManager:backToLoginWithoutLogout() UIManager:backToLoginWithoutLogout()
DataManager:clear() DataManager:clear()
end end

View File

@ -38,9 +38,6 @@ function LoginUI:onLoadRootComplete()
self:refreshServerList(serverList) self:refreshServerList(serverList)
ModuleManager.LoginManager:saveAuthArgs() ModuleManager.LoginManager:saveAuthArgs()
ModuleManager.LoginManager:initSocket() ModuleManager.LoginManager:initSocket()
local info = LocalData:getLastLoginInfo()
BIReport:postAccountLoginClick(info.type)
end) end)
-- first 可以卸载了, 此项目只会启动时检查一次热更,之后不会再次检查 -- first 可以卸载了, 此项目只会启动时检查一次热更,之后不会再次检查

View File

@ -77,9 +77,6 @@ function TestLoginUI:loginGame()
-- ModuleManager.LoginManager:initSocket() -- ModuleManager.LoginManager:initSocket()
ModuleManager.LoginManager:loginGame() ModuleManager.LoginManager:loginGame()
local info = LocalData:getLastLoginInfo()
BIReport:postAccountLoginClick(info.type)
-- first 可以卸载了, 此项目只会启动时检查一次热更,之后不会再次检查 -- first 可以卸载了, 此项目只会启动时检查一次热更,之后不会再次检查
CS.BF.BFMain.Instance.LuaMgr:OnGameInitSucc() CS.BF.BFMain.Instance.LuaMgr:OnGameInitSucc()
LocalData:save() LocalData:save()

View File

@ -285,9 +285,7 @@ function TutorialManager:gmSkipTutorial()
end end
-- 强制引导则先跟服务器发送消息再退出 -- 强制引导则先跟服务器发送消息再退出
-- NetManager:send(ProtoMsgType.FromMsgEnum.SkipGuideReq, {}, function(data) self:stopTutorial()
self:stopTutorial()
-- end)
end end
return TutorialManager return TutorialManager

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
local ServerFormationData = class("ServerFormationData", ServerBaseData)
function ServerFormationData:init(data)
if data then
self.data.formations = data.formations or {}
else
self.data.formations = {}
end
end
function ServerFormationData:getFormation(formationType)
local formation = self.data.formations[formationType]
if formation == nil then
formation = {}
self.data.formations[formationType] = formation
end
return formation
end
function ServerFormationData:upHeroToFormation(formationType, matchType, heroId)
local formation = self:getFormation(formationType)
if formation[matchType] == heroId then
return false
end
formation[matchType] = heroId
return true
end
return ServerFormationData

View File

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

View File

@ -1,3 +1,11 @@
local ServerPlayerData = class("ServerPlayerData", ServerBaseData) local ServerPlayerData = class("ServerPlayerData", ServerBaseData)
function ServerPlayerData:setVit(vit)
self.vit = tonumber(vit) or 0
end
function ServerPlayerData:getVit()
return self.vit or 0
end
return ServerPlayerData return ServerPlayerData

View File

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

View File

@ -0,0 +1,27 @@
local ServerFormationManager = {}
function ServerFormationManager:updateFormation(params, callback)
local result = {
status = 1
}
if params == nil then
if callback then
callback(result)
end
return
end
local formationType = params.formationType
local matchType = tostring(params.matchType)
local heroId = params.heroId
if formationType and matchType and heroId then
local ServerGameData = require "app/server/server_game_data"
if ServerGameData.FormationData:upHeroToFormation(formationType, matchType, heroId) then
result.status = 0
end
end
if callback then
callback(result)
end
end
return ServerFormationManager

View File

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

View File

@ -8,6 +8,7 @@ ServerDataConst.REWARD_TYPE = {
ServerDataConst.DATA_OP_BEHAVIOR = { ServerDataConst.DATA_OP_BEHAVIOR = {
SYNC_DATA = "SYNC_DATA", SYNC_DATA = "SYNC_DATA",
CROSS_DAY = "CROSS_DAY", CROSS_DAY = "CROSS_DAY",
UPDATE_FORMATION = "UPDATE_FORMATION"
} }
return ServerDataConst return ServerDataConst

View File

@ -3,9 +3,7 @@ local ServerGameData = require "app/server/server_game_data"
local ServerDataManager = {} local ServerDataManager = {}
function ServerDataManager:init() function ServerDataManager:init()
end self.ServerFormationManager = require("app/server/manager/server_formation_manager")
function ServerDataManager:saveData()
end end
function ServerDataManager:randomReward(weightArr, callback) function ServerDataManager:randomReward(weightArr, callback)
@ -40,7 +38,7 @@ function ServerDataManager:dataOperate(behavior, params, callback)
end end
end) end)
-- TODO临时处理 -- TODO临时处理
LocalData:save() ServerGameData:saveData()
else else
Logger.logError("Undefined data operation function, please check :%s", behavior) Logger.logError("Undefined data operation function, please check :%s", behavior)
end end
@ -57,6 +55,70 @@ end
ServerDataManager.OP_FUNC = { ServerDataManager.OP_FUNC = {
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA] = function (...) ServerDataManager:onSyncData(...) end, [GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA] = function (...) ServerDataManager:onSyncData(...) end,
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPDATE_FORMATION] = function (...) ServerDataManager.ServerFormationManager:updateFormation(...) end,
} }
function ServerDataManager:dealGM(params, callback)
if IS_PUBLISH then
return
end
if not params or not params.args then
return
end
local args = params.args
if args[1] == "add_item" then
local id = tonumber(args[2])
local count = tonumber(args[3])
if not id or not count then
return
end
ServerGameData.BagData.ItemData:addItem(id, count)
if id == GConst.ItemConst.ITEM_ID_EXP then
ServerGameData.PlayerData:addExp(count)
end
elseif args[1] == "add_items" then
local cfg = ConfigManager:getConfig("item")
local count = tonumber(args[2])
if not count then
for k, v in pairs(cfg) do
if k == GConst.ItemConst.ITEM_ID_GOLD then
ServerGameData.BagData.ItemData:addItem(k, 99999999)
else
ServerGameData.BagData.ItemData:addItem(k, 2000)
end
if k == GConst.ItemConst.ITEM_ID_EXP then
ServerGameData.PlayerData:addExp(1000)
end
end
else
for k, v in pairs(cfg) do
ServerGameData.BagData:addItem(k, count)
if k == GConst.ItemConst.ITEM_ID_EXP then
ServerGameData.PlayerData:addExp(count)
end
end
end
elseif args[1] == "del_item" then
local id = tonumber(args[2])
local count = tonumber(args[3])
if not id or not count then
return
end
ServerGameData.BagData.ItemData:addItem(id, -count)
if id == GConst.ItemConst.ITEM_ID_EXP then
ServerGameData.PlayerData:addExp(-count)
end
elseif args[1] == "clear_item" then
local items = ServerGameData.BagData.ItemData:getAllItems()
for k, v in pairs(items) do
v.count = 0
end
end
ServerGameData:saveData()
if callback then
callback()
end
end
return ServerDataManager return ServerDataManager

View File

@ -16,6 +16,7 @@ function ServerGameData:init()
self:initServerData("BagData", "app/server/data/server_bag_data") self:initServerData("BagData", "app/server/data/server_bag_data")
self:initServerData("HeroData", "app/server/data/server_hero_data") self:initServerData("HeroData", "app/server/data/server_hero_data")
self:initServerData("ChapterData", "app/server/data/server_chapter_data") self:initServerData("ChapterData", "app/server/data/server_chapter_data")
self:initServerData("FormationData", "app/server/data/server_formation_data")
end end
function ServerGameData:initData() function ServerGameData:initData()
@ -23,7 +24,7 @@ function ServerGameData:initData()
if self.distinctId == nil or self.distinctId == "" then if self.distinctId == nil or self.distinctId == "" then
self.distinctId = LocalData:getDistinctId() self.distinctId = LocalData:getDistinctId()
end end
local isNewPlayer = LocalData:getIsNewPlayer() local isNewPlayer = self:getIsNewPlayer()
if isNewPlayer then if isNewPlayer then
for k, v in pairs(self.dataMap) do for k, v in pairs(self.dataMap) do
v:init() v:init()
@ -69,9 +70,8 @@ function ServerGameData:initData()
end end
end end
end end
self:setNotNewPlayer()
self:saveData() self:saveData()
LocalData:setNotNewPlayer()
LocalData:save()
else else
for k, v in pairs(self.dataMap) do for k, v in pairs(self.dataMap) do
v:init(v:loadLocalData()) v:init(v:loadLocalData())
@ -99,6 +99,7 @@ function ServerGameData:saveData()
for k, v in pairs(self.dataMap) do for k, v in pairs(self.dataMap) do
v:saveLocalData() v:saveLocalData()
end end
LocalData:save()
end end
-- 根据配置表添加奖励 -- 根据配置表添加奖励
@ -197,4 +198,24 @@ function ServerGameData:setDistinctId(distinctId)
self.distinctId = distinctId self.distinctId = distinctId
end end
function ServerGameData:getIsNewPlayer()
return LocalData:getIsNewPlayer()
end
function ServerGameData:setNotNewPlayer()
LocalData:setNotNewPlayer()
end
if NOT_PUBLISH then
ServerGameData.editorGetIsNewPlayer = ServerGameData.getIsNewPlayer
function ServerGameData:getIsNewPlayer()
return LocalData:getInt(LocalData:getDistinctId() .. LocalData.KEYS.IS_NEW_PLAYER, 0) == 0
end
ServerGameData.editorSetNotNewPlayer = ServerGameData.setNotNewPlayer
function ServerGameData:setNotNewPlayer()
LocalData:setInt(LocalData:getDistinctId() .. LocalData.KEYS.IS_NEW_PLAYER, 1)
end
end
return ServerGameData return ServerGameData

View File

@ -229,7 +229,7 @@ function BaseUI:isFullScreen()
return true return true
end end
function BaseUI:currencyParams() function BaseUI:getCurrencyParams()
return nil, false return nil, false
end end

View File

@ -25,6 +25,7 @@ function BattleUI:_display()
self.boardMask2D = uiMap["battle_ui.bg_2.board_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D) self.boardMask2D = uiMap["battle_ui.bg_2.board_node"]:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
self:initGridCell() self:initGridCell()
self:initSkill() self:initSkill()
self:initBattlefield()
end end
function BattleUI:_addListeners() function BattleUI:_addListeners()
@ -56,6 +57,15 @@ function BattleUI:initSkill()
end end
end end
function BattleUI:initBattlefield()
local uiMap = self.root:genAllChildren()
self.battleNode = uiMap["battle_ui.battle_node"]
end
function BattleUI:getBattleNode()
return self.battleNode
end
function BattleUI:refreshSkill(elementMap) function BattleUI:refreshSkill(elementMap)
if not self.skillObjs then if not self.skillObjs then
return return

View File

@ -6,27 +6,55 @@ function HeroCell:init()
self.heroBg = uiMap["hero_cell.hero_bg"] self.heroBg = uiMap["hero_cell.hero_bg"]
self.check = uiMap["hero_cell.hero_bg.mask"] self.check = uiMap["hero_cell.hero_bg.mask"]
self.matchImg = uiMap["hero_cell.hero_bg.match_img"] self.matchImg = uiMap["hero_cell.hero_bg.match_img"]
self.isGray = false
self.baseObject:addClickListener(function()
if self.clickCallback then
self.clickCallback()
end
end)
end end
function HeroCell:refresh(heroEntity) function HeroCell:refresh(heroEntity, isGray)
local heroInfo = heroEntity:getConfig() local heroInfo = heroEntity:getConfig()
self:_refresh(heroInfo) self:_refresh(heroInfo, isGray)
end end
function HeroCell:refreshWithCfgId(id) function HeroCell:refreshWithCfgId(id, isGray)
local heroInfo = ConfigManager:getConfig("hero")[id] local heroInfo = ConfigManager:getConfig("hero")[id]
self:_refresh(heroInfo) self:_refresh(heroInfo, isGray)
end end
function HeroCell:_refresh(heroInfo) function HeroCell:_refresh(heroInfo, isGray)
self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_FRAME_QLT[heroInfo.qlt]) self.clickCallback = nil
if isGray then
self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_FRAME_GRAY_QLT[heroInfo.qlt])
else
self.heroBg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HERO_FRAME_QLT[heroInfo.qlt])
end
self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, tostring(heroInfo.icon)) self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, tostring(heroInfo.icon))
self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position]) self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position])
self.check:setVisible(false) self.check:setVisible(false)
self:setGray(isGray)
end
function HeroCell:showCheck(visible)
self.check:setVisible(visible)
end
function HeroCell:addClickListener(callback)
self.clickCallback = callback
end end
function HeroCell:setVisible(visible) function HeroCell:setVisible(visible)
self.baseObject:setVisible(visible) self.baseObject:setVisible(visible)
end end
function HeroCell:setGray(isGray)
if self.isGray == isGray then
return
end
self.icon:setImageGray(isGray)
self.matchImg:setImageGray(isGray)
end
return HeroCell return HeroCell

View File

@ -16,69 +16,40 @@ 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
-- 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_GOLD then
-- self.baseObject:addClickListener(function() self.addImg:setVisible(not hideAddImg)
-- if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true) then else
-- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = 5, storeIdx = 4}) self.addImg:setVisible(not hideAddImg)
-- end end
-- end)
-- self.addImg:setVisible(not hideAddImg)
-- elseif itemId == GConst.ItemConst.ITEM_ID_GOLD then
-- if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true) then
-- self.baseObject:addClickListener(function()
-- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = 5, storeIdx = 2})
-- end)
-- end
-- self.addImg:setVisible(not hideAddImg)
-- else
-- self.addImg:setVisible(not hideAddImg)
-- end
-- self:refreshCurrencyAddTx(itemId, nil)
end
function ResourceCell:refreshCurrencyAddTx(itemId, bigNum)
-- if self.itemId == itemId then
-- if bigNum then
-- local obj = DataManager.BagData.ItemData:getItemById(self.itemId)
-- if obj:getItemType() == 6 then
-- self.addTx:setText("+" .. tostring(BigNumOpt.bigNum2Num(bigNum)))
-- else
-- self.addTx:setText("+" .. BigNumOpt.bigNum2Str(bigNum))
-- end
-- else
-- self.addTx:setText(nil)
-- end
-- end
end end
function ResourceCell:updateTime() function ResourceCell:updateTime()
if self.itemId then if self.itemId then
--local curTime = DataManager.BagData:getTimelyItemRecoveryTime(self.itemId) local curTime = DataManager.BagData:getTimelyItemRecoveryTime(self.itemId)
--if curTime <= 0 then if curTime <= 0 then
-- self.timeTx:setText("") self.timeTx:setText(GConst.EMPTY_STRING)
--else else
-- self.timeTx:setText(GFunc.getTimeStrWithMS(curTime)) self.timeTx:setText(GFunc.getTimeStrWithMS(curTime))
--end end
end end
end end
@ -95,18 +66,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 count = obj:getNum()
-- if bigNum.value < 0 then if count < 0 then
-- self.numTx:setText(0) self.numTx:setText("0")
-- elseif obj:getItemType() == 6 then elseif obj:getItemType() == GConst.ItemConst.ITEM_ID_VIT then
-- self.numTx:setText(BigNumOpt.bigNum2Num(bigNum)) self.numTx:setText(GFunc.num2Str(count) .. "/" .. DataManager.PlayerData:getMaxVit())
-- else else
-- self.numTx:setText(BigNumOpt.bigNum2Str(bigNum)) self.numTx:setText(GFunc.num2Str(count))
-- end end
end end
function ResourceCell:refreshText() function ResourceCell:refreshText()
@ -114,7 +85,7 @@ function ResourceCell:refreshText()
return return
end end
local text = self.numTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).text local text = self.numTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).text
self.numTx:setText("") self.numTx:setText(GConst.EMPTY_STRING)
self.numTx:setText(text) self.numTx:setText(text)
end end

View File

@ -4,7 +4,7 @@ local CurrencyBar = class("CurrencyBar", Component)
CurrencyBar.cellWidth = 174 CurrencyBar.cellWidth = 174
CurrencyBar.cellHeight = 40 CurrencyBar.cellHeight = 40
local OFFSET_X = 200 -- -27 local OFFSET_X = -27
local OFFSET_Y = -22 local OFFSET_Y = -22
function CurrencyBar:init() function CurrencyBar:init()
@ -97,14 +97,14 @@ function CurrencyBar:showSort()
return return
end end
local w, h = GFunc.getUIExpandScreenSize() local w, h = GFunc.getUIExpandScreenSize()
-- local offset = (w - 720) / 2 local offset = (w - 720) / 2
local offset = 0
if offset <= 0 then if offset <= 0 then
offset = 0 offset = 0
end end
if self.params.showType == GConst.CURRENCY_TYPE.HORIZONTAL then if self.params.showType == GConst.CURRENCY_TYPE.HORIZONTAL then
for i,v in ipairs(self.params.itemIds) do for i,v in ipairs(self.params.itemIds) do
self.currencyList[i]:setAnchoredPosition(OFFSET_X + (i - 1)*self.cellWidth + self.offsetX - offset, OFFSET_Y + self.offsetY) Logger.logHighlight(OFFSET_X - (i - 1)*self.cellWidth + self.offsetX - offset)
self.currencyList[i]:setAnchoredPosition(OFFSET_X - (i - 1)*self.cellWidth + self.offsetX - offset, OFFSET_Y + self.offsetY)
end end
else else
for i,v in ipairs(self.params.itemIds) do for i,v in ipairs(self.params.itemIds) do

View File

@ -1,6 +1,4 @@
local DevToolManager = require "app/module/gm/dev_tool_manager"
local GMConst = require "app/module/gm/gm_const" local GMConst = require "app/module/gm/gm_const"
-- local ItemConst = require "app/module/item/item_const"
local GMToolUI = class("GMToolUI",BaseUI) local GMToolUI = class("GMToolUI",BaseUI)
function GMToolUI:ctor() function GMToolUI:ctor()
@ -23,16 +21,10 @@ function GMToolUI:onRefresh()
local titleTx = self.uiMap['gm_tool_ui.title'] local titleTx = self.uiMap['gm_tool_ui.title']
local okBtn = self.uiMap['gm_tool_ui.ok_btn'] local okBtn = self.uiMap['gm_tool_ui.ok_btn']
local okBtnText = self.uiMap['gm_tool_ui.ok_btn.text'] local okBtnText = self.uiMap['gm_tool_ui.ok_btn.text']
local helpBtn = self.uiMap['gm_tool_ui.help_btn']
local inputField = self.uiMap['gm_tool_ui.InputField'] local inputField = self.uiMap['gm_tool_ui.InputField']
local inputFieldText = self.uiMap['gm_tool_ui.InputField.text']
local scrollView = self.uiMap['gm_tool_ui.ScrollView'] local scrollView = self.uiMap['gm_tool_ui.ScrollView']
local textTip = self.uiMap['gm_tool_ui.text_tip'] local textTip = self.uiMap['gm_tool_ui.text_tip']
local speedUpBtn = self.uiMap["gm_tool_ui.speed_up_btn"] local speedUpBtn = self.uiMap["gm_tool_ui.speed_up_btn"]
local attrBtn = self.uiMap["gm_tool_ui.attr_btn"]
local attrBtnTx = self.uiMap["gm_tool_ui.attr_btn.text"]
local heroListNode = self.uiMap["gm_tool_ui.hero_list_node"]
self.heroListNode = heroListNode
self.uiMap['gm_tool_ui.close_btn']:addClickListener(function() self:closeUI() end) self.uiMap['gm_tool_ui.close_btn']:addClickListener(function() self:closeUI() end)
self.scrollRect = scrollView:getLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) self.scrollRect = scrollView:getLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
@ -50,7 +42,6 @@ function GMToolUI:onRefresh()
self.inputField = inputField self.inputField = inputField
titleTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "GM面板" titleTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "GM面板"
okBtnText:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "确定" okBtnText:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "确定"
attrBtnTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "英雄属性"
okBtn:addClickListener(function() okBtn:addClickListener(function()
@ -73,20 +64,6 @@ function GMToolUI:onRefresh()
CS.UnityEngine.Time.timeScale = timeScale CS.UnityEngine.Time.timeScale = timeScale
end) end)
attrBtn:addClickListener(function()
local allAttr = DataManager.HeroData:getMainHeroEntity():getAllAttr()
local allAttr1 = {}
local cfg = ConfigManager:getConfig("attr")
for i = 1, #cfg do
allAttr1[i] = {unit = allAttr[i].unit, value = allAttr[i].value}
end
Logger.logHighlight("============================ hero attr")
Logger.printTable(allAttr1)
Logger.logHighlight("============================ hero attr")
local str = json.encode(allAttr1)
ModuleManager.TipsManager:showHelpTips({desc = str})
end)
self.uiMap["gm_tool_ui.fps_btn"]:addClickListener(function() self.uiMap["gm_tool_ui.fps_btn"]:addClickListener(function()
local comp = UIManager.uiRoot:getComponent(typeof(CS.BF.ShowFPS)) local comp = UIManager.uiRoot:getComponent(typeof(CS.BF.ShowFPS))
if comp == nil then if comp == nil then
@ -95,10 +72,6 @@ function GMToolUI:onRefresh()
comp.enabled = not comp.enabled comp.enabled = not comp.enabled
end end
end) end)
heroListNode:addClickListener(function()
heroListNode:setActive(false)
end)
end end
function GMToolUI:initScrollRectCell(index, cell) function GMToolUI:initScrollRectCell(index, cell)
@ -116,75 +89,15 @@ function GMToolUI:sendMsg(gmCommand)
else else
local args = {} local args = {}
args.args = string.split(gmCommand, " ") args.args = string.split(gmCommand, " ")
if args.args[1] == "time" then -- 特殊处理 ServerDataManager:dealGM(args, function()
local args1 = {} ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA, GConst.EMPTY_TABLE, function(msgData)
args1.args = {} DataManager:initWithServerData(msgData)
args1.args[1] = args.args[1] ModuleManager.MaincityManager:firstEnterMainCity()
args1.args[2] = args.args[2] .. " " .. args.args[3] end)
ModuleManager.DevToolManager:dealGM(args1) end)
else
ModuleManager.DevToolManager:dealGM(args)
end
end end
end end
function GMToolUI:initHeroScrollRect(index, cell)
self.heroList = {}
-- local HeroConst = require "app/module/hero/hero_const"
for hid, entity in pairs(DataManager.HeroData:getAllHero()) do
local star = entity:getStar()
local qlt = entity:getQuality()
local group = entity:getGroup()
local lv = entity:getLv()
local heroId = entity:getId()
local sort = 0
sort = heroId + group*10000000 + qlt*100000000 + star*1000000000 + lv*10000000000
-- if self.filterType == HeroConst.FILTER_TYPE.ALL then
-- sort = heroId + group*10000000 + qlt*100000000 + star*1000000000 + lv*10000000000
-- elseif self.filterType == HeroConst.FILTER_TYPE.STAR then
-- sort = heroId + group*10000000 + qlt*100000000 + lv*1000000000 + star*100000000000
-- elseif self.filterType == HeroConst.FILTER_TYPE.LV then
-- sort = heroId + group*10000000 + qlt*100000000 + star*1000000000 + lv*10000000000
-- elseif self.filterType == HeroConst.FILTER_TYPE.QLT then
-- sort = heroId + group*10000000 + star*100000000 + lv*1000000000 + qlt*100000000000
-- elseif self.filterType == HeroConst.FILTER_TYPE.GROUP then
-- sort = heroId + qlt*10000000 + star*100000000 + lv*1000000000 + group*100000000000
-- elseif self.filterType == HeroConst.FILTER_TYPE.USED then
-- end
table.insert(self.heroList, {
heroData = entity,
sort = sort
})
end
table.sort(self.heroList, function (a, b)
return a.sort > b.sort
end)
if self.heroScrollRect then
self.heroScrollRect:refillCells(#self.heroList)
return
end
local uiMap = self.root:genAllChildren()
self.heroScrollRect = uiMap["gm_tool_ui.hero_list_node.ScrollView (1)"]:getLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
self.heroScrollRect:clearCells()
self.heroScrollRect:setFadeArgs(0, 0.3)
self.heroScrollRect:addInitCallback(function()
return GConst.TYPEOF_LUA_CLASS.HERO_CELL
end)
self.heroScrollRect:addRefreshCallback(function(index, cell)
self:refreshHeroCell(cell, self.heroList[index].heroData)
end)
self.heroScrollRect:refillCells(#self.heroList)
end
function GMToolUI:refreshHeroCell(cell, heroData)
cell:refresh(heroData)
cell:addClickListener(function()
self.textTip:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "英雄升级 (会清空当前经验) \n arg1:英雄唯一ID arg2 目标等级"
self.inputField:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_INPUT_FIELD).text = string.format("%s %s ", "hero_upgrade", heroData:getHid())
self.heroListNode:setActive(false)
end)
end
function GMToolUI:updateTime() function GMToolUI:updateTime()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["gm_tool_ui.time"]:setText(Time:formatTimeYMDHMS(Time:getServerTime())) uiMap["gm_tool_ui.time"]:setText(Time:formatTimeYMDHMS(Time:getServerTime()))

View File

@ -17,7 +17,7 @@ function HeroListCell:init()
self.titleTx = self.uiMap["hero_list_cell.title.title_desc"] self.titleTx = self.uiMap["hero_list_cell.title.title_desc"]
end end
function HeroListCell:refresh(index, heroList, allHeroCount, activeCount) function HeroListCell:refresh(index, heroList, stageFormation, allHeroCount, activeCount)
if activeCount > 0 and index == 1 then if activeCount > 0 and index == 1 then
self.title:setVisible(true) self.title:setVisible(true)
self.titleTx:setText("临时文本:已解锁") self.titleTx:setText("临时文本:已解锁")
@ -38,13 +38,20 @@ function HeroListCell:refresh(index, heroList, allHeroCount, activeCount)
for i = 1, 4 do for i = 1, 4 do
if heroIndex <= activeCount then if heroIndex <= activeCount then
self.heroCells[i]:setVisible(true) self.heroCells[i]:setVisible(true)
self.heroCells[i]:refresh(DataManager.HeroData:getHeroById(heroList[heroStartIndex])) local heroId = heroList[heroIndex]
local heroEntity = DataManager.HeroData:getHeroById(heroId)
local matchType = heroEntity:getMatchType()
self.heroCells[i]:refresh(heroEntity, false)
self.heroCells[i]:showCheck(stageFormation[matchType] == heroId)
self.heroCells[i]:addClickListener(function()
ModuleManager.FormationManager:upHeroToStageFormation(heroId, matchType)
end)
elseif heroIndex <= allHeroCount then elseif heroIndex <= allHeroCount then
if heroStartIndex <= activeCount then if heroStartIndex <= activeCount then
self.heroCells[i]:setVisible(false) self.heroCells[i]:setVisible(false)
else else
self.heroCells[i]:setVisible(true) self.heroCells[i]:setVisible(true)
self.heroCells[i]:refreshWithCfgId(heroList[heroStartIndex]) self.heroCells[i]:refreshWithCfgId(heroList[heroIndex], true)
end end
else else
self.heroCells[i]:setVisible(false) self.heroCells[i]:setVisible(false)

View File

@ -9,7 +9,7 @@ function HeroComp:init()
return HERO_LIST_CELL return HERO_LIST_CELL
end) end)
self.scrollRect:addRefreshCallback(function(index, cell) self.scrollRect:addRefreshCallback(function(index, cell)
cell:refresh(index, self.heroList, self.allHeroCount, self.activeCount) cell:refresh(index, self.heroList, self.stageFormation, self.allHeroCount, self.activeCount)
end) end)
self.heroList = {} self.heroList = {}
local heroCfg = ConfigManager:getConfig("hero") local heroCfg = ConfigManager:getConfig("hero")
@ -19,9 +19,15 @@ function HeroComp:init()
end end
function HeroComp:refresh() function HeroComp:refresh()
self.stageFormation = DataManager.FormationData:getStageFormation()
self:refreshStageFormation()
self:refreshScrollRect() self:refreshScrollRect()
end end
function HeroComp:refreshStageFormation()
end
function HeroComp:refreshScrollRect() function HeroComp:refreshScrollRect()
self:sortHeroList() self:sortHeroList()
self.allHeroCount = #self.heroList self.allHeroCount = #self.heroList

View File

@ -4,6 +4,7 @@ local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
function MainComp:init() function MainComp:init()
self.uiMap = self:getBaseObject():genAllChildren() self.uiMap = self:getBaseObject():genAllChildren()
self:initChapter() self:initChapter()
self:initStageFormation()
self:initGM() self:initGM()
end end
@ -28,6 +29,16 @@ function MainComp:initChapter()
end) end)
end end
function MainComp:initStageFormation()
self.heroCells = {
self.uiMap["main_comp.hero_bg.hero_cell_1"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
self.uiMap["main_comp.hero_bg.hero_cell_2"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
self.uiMap["main_comp.hero_bg.hero_cell_3"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
self.uiMap["main_comp.hero_bg.hero_cell_4"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
self.uiMap["main_comp.hero_bg.hero_cell_5"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL),
}
end
function MainComp:initGM() function MainComp:initGM()
self.btnGM = self.uiMap["main_comp.gm_btn"] self.btnGM = self.uiMap["main_comp.gm_btn"]
self.btnGM:setVisible(not Platform:getIsPublishChannel(), 2) self.btnGM:setVisible(not Platform:getIsPublishChannel(), 2)
@ -38,6 +49,7 @@ end
function MainComp:refresh() function MainComp:refresh()
self:refreshChapter() self:refreshChapter()
self:refreshStageFormaion()
end end
function MainComp:onFightBtnClick() function MainComp:onFightBtnClick()
@ -59,4 +71,20 @@ function MainComp:refreshChapter()
end end
end end
function MainComp:refreshStageFormaion()
local formation = DataManager.FormationData:getStageFormation()
for i, heroCell in ipairs(self.heroCells) do
if formation[i] then
local heroEntity = DataManager.HeroData:getHeroById(formation[i])
if heroEntity then
heroCell:refresh(heroEntity)
else
heroCell:setVisible(false)
end
else
heroCell:setVisible(false)
end
end
end
return MainComp return MainComp

View File

@ -21,49 +21,25 @@ function MainCityUI:getUIType()
return UIManager.UI_TYPE.MAIN return UIManager.UI_TYPE.MAIN
end end
function MainCityUI:currencyParams() function MainCityUI:getCurrencyParams()
if self.cheat then if self.currencyParams == nil then
local params = {} self.currencyParams = {
params.itemIds = {} itemIds = {}
return params }
end end
self.selectedIndex = self.selectedIndex or MAIN_COMP_INDEX self.selectedIndex = self.selectedIndex or MAIN_COMP_INDEX
local params = {} self.currencyParams.showType = GConst.CURRENCY_TYPE.HORIZONTAL
params.showType = GConst.CURRENCY_TYPE.HORIZONTAL for k, v in ipairs(self.currencyParams.itemIds) do
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE then table.remove(self.currencyParams.itemIds)
params.itemIds = { end
GConst.ItemConst.ITEM_ID_GOLD, if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
GConst.ItemConst.ITEM_ID_GEM, self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_VIT
GConst.ItemConst.ITEM_ID_VIT, self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GOLD
} elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then
elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.EQUIP then return nil
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,
}
end end
return params, true return self.currencyParams
end 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"
@ -119,13 +95,17 @@ function MainCityUI:_bind()
self.subComps[self.selectedIndex]:refreshChapter() self.subComps[self.selectedIndex]:refreshChapter()
end end
end) end)
self:bind(DataManager.PlayerData, "dirty", function(binder, value) self:bind(DataManager.PlayerData, "dirty", function(binder, value)
self:refreshRoleInfo() self:refreshRoleInfo()
end, true) end, true)
self:bind(DataManager.PlayerData, "lvUpDirty", function(binder, value) self:bind(DataManager.PlayerData, "lvUpDirty", function(binder, value)
self:checkMainPop() self:checkMainPop()
end) end)
self:bind(DataManager.FormationData, "dirty", function(binder, value)
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then
self.subComps[self.selectedIndex]:refresh()
end
end)
-- self:bind(DataManager.BagData.ItemData, "dirty", function(binder, value) -- self:bind(DataManager.BagData.ItemData, "dirty", function(binder, value)
-- UIManager:refreshCurrencyBarTxt() -- UIManager:refreshCurrencyBarTxt()

View File

@ -991,37 +991,6 @@ function UIManager:backToLoginWithoutLogout()
Game:showLoginUI() Game:showLoginUI()
end end
-- 掉线提示处理
function UIManager:showKickOut(msgData)
local content
local reason = NetManager:getKickOutReasonEnum(msgData.reason)
if reason == 0 then -- 服务器维护
content = I18N:getGlobalText(I18N.GlobalConst.MAINTAIN)
elseif reason == 1 then -- 网络消息流控,也就是短时间内通信次数太多
content = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_RELOGIN)
elseif reason == 2 then -- 封号
content = I18N:getGlobalText(I18N.GlobalConst.FORBIDDEN)
elseif reason == 3 then -- 多点登录
content = I18N:getGlobalText(I18N.GlobalConst.OTHER_LOGIN)
else
content = I18N:getGlobalText(I18N.GlobalConst.DISCONNECT_RELOGIN)
end
self.disconnectMsgBoxVisible = true
-- 被踢了的话就先断开连接再弹确认框
NetManager:closeAndClear()
local params = {
content = content,
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
okFunc = function()
self.disconnectMsgBoxVisible = false
ModuleManager.LoginManager:goToLoginScene()
end,
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK,
top = true,
}
GFunc.showMessageBox(params)
end
-- 掉线提示处理 -- 掉线提示处理
function UIManager:showDisconnect() function UIManager:showDisconnect()
self.disconnectMsgBoxVisible = true self.disconnectMsgBoxVisible = true
@ -1056,7 +1025,7 @@ function UIManager:_loadCurrencyBar(params, showBg, hidAddImg)
end end
function UIManager:showCurrencyBar(uiObj) function UIManager:showCurrencyBar(uiObj)
local params, showBg, hidAddImg = uiObj:currencyParams() local params, showBg, hidAddImg = uiObj:getCurrencyParams()
if params then if params then
local currCurrencyBarOrder = 0 local currCurrencyBarOrder = 0
if self.currencyBarBindUI then if self.currencyBarBindUI then

View File

@ -1,8 +1,8 @@
local ItemEntity = class("ItemEntity", BaseData) local ItemEntity = class("ItemEntity", BaseData)
function ItemEntity:ctor(id, bigNum) function ItemEntity:ctor(id, num)
self.data.id = id self.data.id = id
self.data.bigNum = bigNum self.data.num = num
self.data.isDirty = false self.data.isDirty = false
self.config = nil self.config = nil
@ -30,19 +30,19 @@ function ItemEntity:getId()
end end
-- 道具数量 -- 道具数量
function ItemEntity:getBigNum() function ItemEntity:getNum()
return self.data.bigNum return self.data.num
end end
-- 加减道具数量 -- 加减道具数量
function ItemEntity:addNum(num) function ItemEntity:addNum(num)
self.data.bigNum = BigNumOpt.bigNumAdd(self.data.bigNum, bigNum) self.data.num = self.data.num + num
self:setDirty() self:setDirty()
end end
-- 设置数量 -- 设置数量
function ItemEntity:setNum(bigNum) function ItemEntity:setNum(num)
self.data.bigNum = bigNum self.data.num = num
self:setDirty() self:setDirty()
end end
@ -66,7 +66,7 @@ function ItemEntity:getFrameRes()
end end
function ItemEntity:getIconRes() function ItemEntity:getIconRes()
return GConst.ATLAS_PATH.ICON_ITEM, tostring(self.config.icon) return GConst.ATLAS_PATH.ICON_ITEM, self.config.icon
end end
-- 类型 -- 类型

View File

@ -7,6 +7,9 @@ local BattleConst = GConst.BattleConst
local BATTLE_GRID_ENTITY = require "app/userdata/battle/battle_grid_entity" local BATTLE_GRID_ENTITY = require "app/userdata/battle/battle_grid_entity"
local BATTLE_BOARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_borad_skill_entity" local BATTLE_BOARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_borad_skill_entity"
local ATTR_TYPE = GConst.ATTR_TYPE
local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR
function BattleData:init(board, skillIds, skillPool) function BattleData:init(board, skillIds, skillPool)
self:clear() self:clear()
self.atkTeam = self:initTeam(BattleConst.SIDE_ATK) self.atkTeam = self:initTeam(BattleConst.SIDE_ATK)
@ -244,9 +247,54 @@ function BattleData:changeSkillId(elementType, newId)
end end
function BattleData:initTeam(side) function BattleData:initTeam(side)
local data = nil
if side == BattleConst.SIDE_ATK then
data = self:initHeroData()
end
local team = BattleTeamEntity:create() local team = BattleTeamEntity:create()
team:init(side) team:init(side, data)
return team return team
end end
function BattleData:getAtkTeam()
return self.atkTeam
end
function BattleData:getDefTeam()
return self.defTeam
end
function BattleData:initHeroData()
local units = {}
local formation = DataManager.FormationData:getStageFormation()
for matchType, heroId in pairs(formation) do
if heroId > 0 then
local heroEntity = DataManager.HeroData:getHeroById(heroId)
if heroEntity then
local heroAttr = heroEntity:getAllAttr()
local activeSkill = heroEntity:getActiveSkill() -- 主动技能
local hp = heroAttr[ATTR_TYPE.hp] // DEFAULT_FACTOR
local unitData = {
id = heroId,
modelId = heroEntity:getModelId(),
level = heroEntity:getLv(),
qlt = heroEntity:getQlt(),
matchType = matchType,
activeSkill = activeSkill,
attr = {
hp = hp,
max_hp = hp,
atk = heroAttr[ATTR_TYPE.atk] // DEFAULT_FACTOR,
}
}
table.insert(units, unitData)
end
end
end
local data = {
units = units
}
return data
end
return BattleData return BattleData

View File

@ -0,0 +1,13 @@
local BattleSkillEntity = class("BattleSkillEntity", BaseData)
function BattleSkillEntity:ctor(skillId, skillType, owner)
self.skillType = skillType
self.skillId = skillId
self.owner = owner
self:init()
end
function BattleSkillEntity:init()
end
return BattleSkillEntity

View File

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

View File

@ -4,10 +4,43 @@ local BattleTeamEntity = class("BattleTeamEntity", BaseData)
function BattleTeamEntity:ctor() function BattleTeamEntity:ctor()
self.members = {} self.members = {}
self.membersCount = 0
end end
function BattleTeamEntity:init(side) function BattleTeamEntity:init(side, data)
self.side = side self.side = side
if data then
table.sort(data.units, function(a, b)
if a.level == b.level then
if a.qlt == b.qlt then
return a.id > b.id
else
return a.qlt > b.qlt
end
else
return a.level > b.level
end
end)
self.mainHero = nil
for i, unitData in ipairs(data.units) do
local unit = BattleUnitEntity:create()
unit:init(unitData, side, self)
self.members[unitData.matchType] = unit
self.membersCount = self.membersCount + 1
if self.mainHero == nil then
unit:setIsMainUnit(true)
self.mainHero = unit
end
end
end
end
function BattleTeamEntity:getAllMembers()
return self.members
end
function BattleTeamEntity:getMembersCount()
return self.membersCount
end end
return BattleTeamEntity return BattleTeamEntity

View File

@ -1,9 +1,58 @@
local BattleSkillEntity = require "app/userdata/battle/skill/battle_skill_entity"
local BattleUnitEntity = class("BattleUnitEntity", BaseData) local BattleUnitEntity = class("BattleUnitEntity", BaseData)
function BattleUnitEntity:ctor() function BattleUnitEntity:ctor()
end end
function BattleUnitEntity:init() function BattleUnitEntity:init(unitData, side, team)
self.unitData = unitData
self.side = side
self.team = team
self:initAttr()
self:initSkill()
end
function BattleUnitEntity:initAttr()
local attr = self.attr or {}
if self.attr then -- 已经初始化过了
for k, v in pairs(attr) do
attr[k] = self.unitData.attr[k] or 0
end
else
for k, v in pairs(self.unitData.attr) do
attr[k] = v
end
end
self.attr = attr
end
function BattleUnitEntity:initSkill()
self.skills = {}
if self.unitData.activeSkill then
local skill = BattleSkillEntity:create(self.unitData.activeSkill, GConst.BattleConst.SKILL_TYPE_ACTIVE, self)
table.insert(self.skills, skill)
end
end
function BattleUnitEntity:getModelId()
return self.unitData.modelId
end
function BattleUnitEntity:getMatchType()
return self.unitData.matchType
end
function BattleUnitEntity:getSide()
return self.side
end
function BattleUnitEntity:setIsMainUnit(isMainUnit)
self.isMainUnit = isMainUnit
end
function BattleUnitEntity:getIsMainUnit()
return self.isMainUnit
end end
return BattleUnitEntity return BattleUnitEntity

View File

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

View File

@ -0,0 +1,43 @@
local FormationData = class("FormationData", BaseData)
function FormationData:init(data)
self.data.dirty = false
self.formations = {}
if data and data.formations then
for formationType, formation in pairs(data.formations) do
local clientFormation = {}
self.formations[formationType] = clientFormation
for matchTypeStr, heroId in pairs(formation) do
clientFormation[tonumber(matchTypeStr)] = heroId
end
end
end
end
function FormationData:getStageFormation()
return self:getFormation(GConst.BattleConst.BATTLE_TYPE.STAGE)
end
function FormationData:getFormation(formationType)
local formation = self.formations[formationType]
if formation == nil then
formation = {}
self.formations[formationType] = formation
end
return formation
end
function FormationData:upHeroToFormation(formationType, matchType, heroId)
local formation = self:getFormation(formationType)
if formation[matchType] == heroId then
return
end
formation[matchType] = heroId
self:setDirty()
end
function FormationData:setDirty()
self.data.dirty = not self.data.dirty
end
return FormationData

View File

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

View File

@ -4,6 +4,8 @@ function HeroEntity:ctor(cfgId, lv)
self.id = cfgId self.id = cfgId
self.cfgId = cfgId self.cfgId = cfgId
self.data.lv = lv self.data.lv = lv
self.atkKey = nil
self.hpKey = nil
self.attrDirty = false self.attrDirty = false
self.config = ConfigManager:getConfig("hero")[self.cfgId] self.config = ConfigManager:getConfig("hero")[self.cfgId]
@ -22,11 +24,19 @@ function HeroEntity:setLv(lv)
if not lv then if not lv then
return return
end end
if self.data.lv == lv then
return
end
self.data.lv = lv self.data.lv = lv
self.atkKey = nil
self.hpKey = nil
self:setDirty() self:setDirty()
end end
function HeroEntity:getCfgId()
return self.cfgId
end
function HeroEntity:getLv() function HeroEntity:getLv()
return self.data.lv return self.data.lv
end end
@ -35,6 +45,10 @@ function HeroEntity:getQlt()
return self.config.qlt return self.config.qlt
end end
function HeroEntity:getMatchType()
return self.config.position
end
function HeroEntity:setAttrDirty() function HeroEntity:setAttrDirty()
self.attrDirty = true self.attrDirty = true
end end
@ -52,8 +66,22 @@ function HeroEntity:updateAttr()
end end
function HeroEntity:updateBaseAttr() function HeroEntity:updateBaseAttr()
self.baseAttrOriginal[GConst.ATTR_TYPE.hp] = self.config.hp or 0 self.baseAttrOriginal[GConst.ATTR_TYPE.hp] = self.config[self:getHpKey()] or 0
self.baseAttrOriginal[GConst.ATTR_TYPE.atk] = self.config.atk or 0 self.baseAttrOriginal[GConst.ATTR_TYPE.atk] = self.config[self:getAtkKey()] or 0
end
function HeroEntity:getHpKey()
if self.hpKey == nil then
self.hpKey = "hp_" .. self.data.lv
end
return self.hpKey
end
function HeroEntity:getAtkKey()
if self.atkKey == nil then
self.atkKey = "atk_" .. self.data.lv
end
return self.atkKey
end end
function HeroEntity:getAtk() function HeroEntity:getAtk()
@ -99,4 +127,12 @@ function HeroEntity:getConfig()
return self.config return self.config
end end
function HeroEntity:getModelId()
return self.config.model_id
end
function HeroEntity:getActiveSkill()
return self.config.base_skill
end
return HeroEntity return HeroEntity

View File

@ -3,4 +3,12 @@ local PlayerData = class("PlayerData", BaseData)
function PlayerData:init(data) function PlayerData:init(data)
end end
function PlayerData:getMaxVit()
if self.maxVit == nil then
self.maxVit = ConfigManager:getConfig("recovery")[GConst.ItemConst.ITEM_ID_VIT].limit
end
return self.maxVit
end
return PlayerData return PlayerData