Merge branch 'dev' of http://git.juzugame.com/b6-client/b6-lua into dev
This commit is contained in:
commit
b61b6a6f85
@ -44,9 +44,9 @@ function CharacterSpineObject:initWithCharacterHelper(characterSpineHelper, inde
|
||||
end
|
||||
|
||||
function CharacterSpineObject:refreshSkeletonDataAsset(dataAsset)
|
||||
local skeletonAnimation = self:getSkeletonAnimation()
|
||||
skeletonAnimation.skeletonDataAsset = dataAsset
|
||||
skeletonAnimation:Initialize(true)
|
||||
local skeletonGraphic = self:getSkeletonGraphic()
|
||||
skeletonGraphic.skeletonDataAsset = dataAsset
|
||||
skeletonGraphic:Initialize(true)
|
||||
self.characterSpineHelper:Reload()
|
||||
end
|
||||
|
||||
@ -192,18 +192,11 @@ function CharacterSpineObject:removeAnimationCompleteCallback()
|
||||
end
|
||||
end
|
||||
|
||||
function CharacterSpineObject:getSkeletonAnimation()
|
||||
if self.skeletonAnimation == nil then
|
||||
self.skeletonAnimation = self.characterSpineHelper:GetSkeletonAnimation()
|
||||
function CharacterSpineObject:getSkeletonGraphic()
|
||||
if self.skeletonGraphic == nil then
|
||||
self.skeletonGraphic = self.characterSpineHelper:GetSkeletonGraphic()
|
||||
end
|
||||
return self.skeletonAnimation
|
||||
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
|
||||
return self.skeletonGraphic
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ function DataManager:init()
|
||||
self:initManager("HeroData", "app/userdata/hero/hero_data")
|
||||
self:initManager("BagData", "app/userdata/bag/bag_data")
|
||||
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
||||
self:initManager("FormationData", "app/userdata/formation/formation_data")
|
||||
end
|
||||
|
||||
function DataManager:initManager(name, path)
|
||||
@ -68,6 +69,7 @@ function DataManager:clear()
|
||||
self.ChapterData:clear()
|
||||
self.HeroData:clear()
|
||||
self.BagData:clear()
|
||||
self.FormationData:clear()
|
||||
|
||||
ModuleManager.TaskManager:clear()
|
||||
end
|
||||
@ -85,6 +87,7 @@ function DataManager:initWithServerData(data)
|
||||
self.ChapterData:init(data.ChapterData)
|
||||
self.HeroData:init(data.HeroData)
|
||||
self.BagData:init(data)
|
||||
self.FormationData:init(data.FormationData)
|
||||
|
||||
self:scheduleGlobal()
|
||||
self:checkDataBind()
|
||||
|
||||
@ -11,8 +11,6 @@ local LOCAL_DATA_KEY = {
|
||||
MESSAGE_BOX_SHOW_TODAY = "MESSAGE_BOX_SHOW_TODAY",
|
||||
GAME_QUALITY_LEVEL = "GAME_QUALITY_LEVEL", -- 游戏设置品质等级
|
||||
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_IP = "LAST_LOGIN_IP",
|
||||
ACCOUNT_INFO = "ACCOUNT_INFO",
|
||||
@ -201,44 +199,6 @@ function LocalData:getIosOrders()
|
||||
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)
|
||||
name = name or ""
|
||||
self:setString(LOCAL_DATA_KEY.LAST_LOGIN_NAME, name)
|
||||
|
||||
@ -11,6 +11,7 @@ local MODULE_PATHS = {
|
||||
ToastManager = "app/ui/common/toast",
|
||||
TaskManager = "app/module/task/task_manager",
|
||||
BattleManager = "app/module/battle/battle_manager",
|
||||
FormationManager = "app/module/formation/formation_manager",
|
||||
}
|
||||
|
||||
-- 这里的key对应func_open里的id
|
||||
|
||||
@ -157,8 +157,6 @@ if NOT_PUBLISH then
|
||||
[SDKManager.tryLoadRewardedAdDelay] = true,
|
||||
[ScrollRectBase.refillCells] = true,
|
||||
[DataManager.scheduleGlobal] = true,
|
||||
[NetManager.performWithDelayGlobal] = true,
|
||||
[NetManager.scheduleGlobal] = true,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -280,15 +280,15 @@ function SDKManager:showFullScreenAds(adsClickType, adCallback)
|
||||
return true
|
||||
end
|
||||
|
||||
if NetManager:isNotReachable() then
|
||||
-- 没有网
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NO_NETWORK))
|
||||
return false
|
||||
end
|
||||
if NetManager:getIsBusy() then
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NETWORK_ERROE_1))
|
||||
return false
|
||||
end
|
||||
-- if NetManager:isNotReachable() then
|
||||
-- -- 没有网
|
||||
-- GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NO_NETWORK))
|
||||
-- return false
|
||||
-- end
|
||||
-- if NetManager:getIsBusy() then
|
||||
-- GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.NETWORK_ERROE_1))
|
||||
-- return false
|
||||
-- end
|
||||
if DataManager.MallActData:skipAd() then
|
||||
self:adRewradAd(true)
|
||||
if adCallback then
|
||||
|
||||
@ -377,9 +377,9 @@ function SDKPayGoogleManager:doUncompletePay(callback)
|
||||
if not DataManager:getLoginSuccess() then
|
||||
return
|
||||
end
|
||||
if NetManager:getIsBusy() then
|
||||
return
|
||||
end
|
||||
-- if NetManager:getIsBusy() then
|
||||
-- return
|
||||
-- end
|
||||
if self:_getIsGoogleStoreConnected() then
|
||||
-- google商店是否初始化
|
||||
self.alreadyFinishUncompletePay = true
|
||||
|
||||
@ -277,9 +277,9 @@ function SDKPayiOSManager:doUncompletePay(callback)
|
||||
if not DataManager:getLoginSuccess() then
|
||||
return
|
||||
end
|
||||
if NetManager:getIsBusy() then
|
||||
return
|
||||
end
|
||||
-- if NetManager:getIsBusy() then
|
||||
-- return
|
||||
-- end
|
||||
|
||||
if self:_getIsIosInitialized() then
|
||||
self.alreadyFinishUncompletePay = true
|
||||
|
||||
@ -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
|
||||
@ -60,7 +60,7 @@ function SpineManager:loadUISpinePrefabAsync(parent, spineAssetPath, spineAsset,
|
||||
end
|
||||
|
||||
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)
|
||||
if parent and parent:isDestroyed() then
|
||||
ResourceManager:destroyPrefab(prefab)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
local skill_hero = {
|
||||
[10]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=3,
|
||||
["method"]=2,
|
||||
["skill_type"]=1,
|
||||
@ -18,7 +18,7 @@ local skill_hero = {
|
||||
["battle_icon"]=1
|
||||
},
|
||||
[20]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=2,
|
||||
["method"]=2,
|
||||
["skill_type"]=0,
|
||||
@ -35,7 +35,7 @@ local skill_hero = {
|
||||
["battle_icon"]=2
|
||||
},
|
||||
[21]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=2,
|
||||
["method"]=1,
|
||||
["skill_type"]=2,
|
||||
@ -70,7 +70,7 @@ local skill_hero = {
|
||||
["battle_icon"]=2
|
||||
},
|
||||
[30]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=4,
|
||||
["method"]=2,
|
||||
["skill_type"]=1,
|
||||
@ -84,7 +84,7 @@ local skill_hero = {
|
||||
["battle_icon"]=3
|
||||
},
|
||||
[40]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=5,
|
||||
["method"]=2,
|
||||
["skill_type"]=0,
|
||||
@ -101,7 +101,7 @@ local skill_hero = {
|
||||
["battle_icon"]=4
|
||||
},
|
||||
[50]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=1,
|
||||
["method"]=2,
|
||||
["skill_type"]=1,
|
||||
@ -119,7 +119,7 @@ local skill_hero = {
|
||||
["battle_icon"]=5
|
||||
},
|
||||
[60]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=3,
|
||||
["method"]=2,
|
||||
["skill_type"]=0,
|
||||
@ -136,7 +136,7 @@ local skill_hero = {
|
||||
["battle_icon"]=6
|
||||
},
|
||||
[70]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=2,
|
||||
["method"]=2,
|
||||
["skill_type"]=0,
|
||||
@ -153,7 +153,7 @@ local skill_hero = {
|
||||
["battle_icon"]=7
|
||||
},
|
||||
[71]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=2,
|
||||
["method"]=1,
|
||||
["skill_type"]=2,
|
||||
@ -189,7 +189,7 @@ local skill_hero = {
|
||||
["battle_icon"]=7
|
||||
},
|
||||
[72]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=2,
|
||||
["method"]=1,
|
||||
["skill_type"]=2,
|
||||
@ -232,7 +232,7 @@ local skill_hero = {
|
||||
["battle_icon"]=7
|
||||
},
|
||||
[80]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=4,
|
||||
["method"]=2,
|
||||
["skill_type"]=0,
|
||||
@ -254,7 +254,7 @@ local skill_hero = {
|
||||
["battle_icon"]=8
|
||||
},
|
||||
[81]={
|
||||
["energy"]=3,
|
||||
["energy"]=10,
|
||||
["position"]=4,
|
||||
["method"]=2,
|
||||
["skill_type"]=1,
|
||||
|
||||
@ -73,13 +73,11 @@ function Game:initOther()
|
||||
BF.exports.EffectManager = require "app/common/effect_manager"
|
||||
BF.exports.SpineManager = require "app/common/spine_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.CellManager = require "app/common/cell_manager"
|
||||
BF.exports.Time = require "app/common/time"
|
||||
BF.exports.BaseData = require "app/userdata/base_data"
|
||||
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.BaseModule = require "app/module/base_module"
|
||||
BF.exports.ModuleManager = require "app/common/module_manager"
|
||||
@ -95,7 +93,6 @@ function Game:initOther()
|
||||
|
||||
CameraManager:init()
|
||||
WebRequestManager:init()
|
||||
NetManager:init()
|
||||
I18N:init()
|
||||
ServerDataManager:init()
|
||||
DataManager:init()
|
||||
@ -143,13 +140,11 @@ function Game:specialForIdea()
|
||||
EffectManager = EffectManager or require "app/common/effect_manager"
|
||||
SpineManager = SpineManager or require "app/common/spine_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"
|
||||
CellManager = CellManager or require "app/common/cell_manager"
|
||||
Time = Time or require "app/common/time"
|
||||
BaseData = BaseData or require "app/userdata/base_data"
|
||||
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"
|
||||
BaseModule = BaseModule or require "app/module/base_module"
|
||||
ModuleManager = ModuleManager or require "app/common/module_manager"
|
||||
|
||||
@ -10,6 +10,7 @@ local CONST_PATHS = {
|
||||
TutorialConst = "app/module/tutorial/tutorial_const",
|
||||
BattleConst = "app/module/battle/battle_const",
|
||||
HeroConst = "app/module/hero/hero_const",
|
||||
FormationConst = "app/module/formation/formation_const",
|
||||
}
|
||||
|
||||
if EDITOR_MODE then
|
||||
@ -366,6 +367,16 @@ GConst.HERO_FRAME_QLT = {
|
||||
[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 = {
|
||||
DEFAULT = "equip_quality_1",
|
||||
GRAY = "equip_quality_1",
|
||||
|
||||
@ -1535,25 +1535,6 @@ function GFunc.getRewardTable(type, id, count)
|
||||
}
|
||||
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)
|
||||
return {
|
||||
type = GConst.REWARD_TYPE.RUNES,
|
||||
|
||||
@ -72,19 +72,6 @@ function BaseModule:removeAllEventListeners()
|
||||
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即可
|
||||
function BaseModule:clear()
|
||||
end
|
||||
|
||||
@ -13,10 +13,20 @@ BattleConst.ELEMENT_WIGHT = 100
|
||||
BattleConst.MAX_ELEMENT_WIGHT = 500
|
||||
BattleConst.SIDE_ATK = 1
|
||||
BattleConst.SIDE_DEF = 2
|
||||
BattleConst.SKILL_TYPE_ACTIVE = 1
|
||||
BattleConst.SKILL_SELECT_COUNT = 3
|
||||
BattleConst.DEFAULT_FACTOR = 10000
|
||||
BattleConst.INIT_POS_X = 200
|
||||
BattleConst.UNIT_BODY_WIDTH = 100
|
||||
|
||||
-- 为方便存储,这里使用字符串
|
||||
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 = {
|
||||
@ -27,6 +37,10 @@ BattleConst.UNIT_STATE = {
|
||||
DEAD = 4, -- 死亡
|
||||
}
|
||||
|
||||
BattleConst.SPINE_ANIMATION_NAME = {
|
||||
IDLE = "idle",
|
||||
}
|
||||
|
||||
---- 格子类型
|
||||
BattleConst.GRID_TYPE = {
|
||||
EMPTY = 0,
|
||||
|
||||
17
lua/app/module/battle/component/battle_hero_comp.lua
Normal file
17
lua/app/module/battle/component/battle_hero_comp.lua
Normal 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
|
||||
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc2318d7940bb8e41b78633f73e985e8
|
||||
guid: 2de8b968215b6754d98014fe8d8feedf
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
@ -3,12 +3,22 @@ local BattleConst = require "app/module/battle/battle_const"
|
||||
local BattleUnitComp = class("BattleUnitComp", LuaComponent)
|
||||
|
||||
local UNIT_STATE = BattleConst.UNIT_STATE
|
||||
local SIDE_ATK = BattleConst.SIDE_ATK
|
||||
local SPINE_ANIMATION_NAME = BattleConst.SPINE_ANIMATION_NAME
|
||||
|
||||
function BattleUnitComp:ctor()
|
||||
end
|
||||
|
||||
function BattleUnitComp:init()
|
||||
self:_initBase()
|
||||
function BattleUnitComp:initPosition()
|
||||
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
|
||||
|
||||
function BattleUnitComp:_initBase()
|
||||
@ -16,21 +26,44 @@ function BattleUnitComp:_initBase()
|
||||
self.isDead = false
|
||||
end
|
||||
|
||||
function BattleUnitComp:tick(dt)
|
||||
if self.isClear then
|
||||
return
|
||||
function BattleUnitComp:initWithEntity(modelId, entity, battleController, target)
|
||||
self.modelId = modelId
|
||||
self.unitEntity = entity
|
||||
self.battleController = battleController
|
||||
self.target = target
|
||||
self:_initBase()
|
||||
self:initPosition()
|
||||
self:playBorn()
|
||||
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)
|
||||
|
||||
function BattleUnitComp:hideOutsideScreen()
|
||||
if self.unitEntity:getSide() == SIDE_ATK then
|
||||
self.baseObject:setLocalPosition(-GConst.UI_SCREEN_WIDTH/2 - BattleConst.UNIT_BODY_WIDTH, 0, 0)
|
||||
else
|
||||
self.baseObject:setLocalPosition(GConst.UI_SCREEN_WIDTH/2 + BattleConst.UNIT_BODY_WIDTH, 0, 0)
|
||||
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
|
||||
@ -1,3 +1,5 @@
|
||||
local BattleHelper = require "app/module/battle/helper/battle_helper"
|
||||
|
||||
local BattleController = class("BattleController")
|
||||
|
||||
local BATTLE_BOARD_SKILL_HANDLE = require "app/module/battle/skill/battle_board_skill_handle"
|
||||
@ -32,6 +34,11 @@ end
|
||||
function BattleController:initOther()
|
||||
end
|
||||
|
||||
-- 需要额外加载的资源
|
||||
function BattleController:loadOtherRes(callback)
|
||||
return callback()
|
||||
end
|
||||
|
||||
function BattleController:onLinkChange()
|
||||
for posId, entity in pairs(DataManager.BattleData:getGridEnties()) do
|
||||
if entity:getCell() then
|
||||
@ -85,12 +92,59 @@ end
|
||||
function BattleController:init(params)
|
||||
params = params or {}
|
||||
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()
|
||||
self.battleUI = UIManager:showUI(self:getBattleUIPath())
|
||||
self.battleUI:setController(self)
|
||||
self.battleUI:addLoadUICompleteListener(function()
|
||||
self:initAllUnits(onPreloadFinished)
|
||||
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
|
||||
|
||||
function BattleController:onTouchEvent(eventType, posId)
|
||||
@ -755,7 +809,7 @@ function BattleController:snapshotBoard()
|
||||
end
|
||||
|
||||
function BattleController:clear()
|
||||
|
||||
BattleHelper:clear()
|
||||
end
|
||||
|
||||
function BattleController:endBattleAndExit()
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c64e57074a12a04a98c2bd95599566a
|
||||
guid: 05735c0c843e6724883965982ae2da2b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
52
lua/app/module/battle/helper/battle_helper.lua
Normal file
52
lua/app/module/battle/helper/battle_helper.lua
Normal 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
|
||||
10
lua/app/module/battle/helper/battle_helper.lua.meta
Normal file
10
lua/app/module/battle/helper/battle_helper.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58d901e56ad3d444ca0bc601e83444c3
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
8
lua/app/module/formation.meta
Normal file
8
lua/app/module/formation.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 711a478ba771167498a776130c47c479
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
lua/app/module/formation/formation_manager.lua
Normal file
20
lua/app/module/formation/formation_manager.lua
Normal 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
|
||||
10
lua/app/module/formation/formation_manager.lua.meta
Normal file
10
lua/app/module/formation/formation_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5234cdd00d84e543a3afe369d8a4c4d
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -30,98 +30,6 @@ Example: del_item]],
|
||||
Example: 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
|
||||
@ -2,6 +2,7 @@ local ItemConst = {}
|
||||
|
||||
ItemConst.ITEM_ID_GOLD = 1
|
||||
ItemConst.ITEM_ID_GEM = 2
|
||||
ItemConst.ITEM_ID_VIT = 3
|
||||
|
||||
ItemConst.ITEM_TYPE = {
|
||||
RES = 1,
|
||||
|
||||
@ -37,7 +37,6 @@ end
|
||||
|
||||
function LoginManager:goToLoginScene()
|
||||
ModuleManager.BattleManager:clearOnExitScene()
|
||||
NetManager:closeAndClear()
|
||||
UIManager:backToLoginWithoutLogout()
|
||||
DataManager:clear()
|
||||
end
|
||||
|
||||
@ -38,9 +38,6 @@ function LoginUI:onLoadRootComplete()
|
||||
self:refreshServerList(serverList)
|
||||
ModuleManager.LoginManager:saveAuthArgs()
|
||||
ModuleManager.LoginManager:initSocket()
|
||||
|
||||
local info = LocalData:getLastLoginInfo()
|
||||
BIReport:postAccountLoginClick(info.type)
|
||||
end)
|
||||
|
||||
-- first 可以卸载了, 此项目只会启动时检查一次热更,之后不会再次检查
|
||||
|
||||
@ -77,9 +77,6 @@ function TestLoginUI:loginGame()
|
||||
-- ModuleManager.LoginManager:initSocket()
|
||||
ModuleManager.LoginManager:loginGame()
|
||||
|
||||
local info = LocalData:getLastLoginInfo()
|
||||
BIReport:postAccountLoginClick(info.type)
|
||||
|
||||
-- first 可以卸载了, 此项目只会启动时检查一次热更,之后不会再次检查
|
||||
CS.BF.BFMain.Instance.LuaMgr:OnGameInitSucc()
|
||||
LocalData:save()
|
||||
|
||||
@ -285,9 +285,7 @@ function TutorialManager:gmSkipTutorial()
|
||||
end
|
||||
|
||||
-- 强制引导则先跟服务器发送消息再退出
|
||||
-- NetManager:send(ProtoMsgType.FromMsgEnum.SkipGuideReq, {}, function(data)
|
||||
self:stopTutorial()
|
||||
-- end)
|
||||
end
|
||||
|
||||
return TutorialManager
|
||||
File diff suppressed because it is too large
Load Diff
29
lua/app/server/data/server_formation_data.lua
Normal file
29
lua/app/server/data/server_formation_data.lua
Normal 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
|
||||
10
lua/app/server/data/server_formation_data.lua.meta
Normal file
10
lua/app/server/data/server_formation_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89bb0382eca3c184e814ee1bc10355c8
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -1,3 +1,11 @@
|
||||
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
|
||||
8
lua/app/server/manager.meta
Normal file
8
lua/app/server/manager.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09d17db485e3192459d5fcd0a0cefb49
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
lua/app/server/manager/server_formation_manager.lua
Normal file
27
lua/app/server/manager/server_formation_manager.lua
Normal 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
|
||||
10
lua/app/server/manager/server_formation_manager.lua.meta
Normal file
10
lua/app/server/manager/server_formation_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f6f74ff6268bec4593ef0e060480d93
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -8,6 +8,7 @@ ServerDataConst.REWARD_TYPE = {
|
||||
ServerDataConst.DATA_OP_BEHAVIOR = {
|
||||
SYNC_DATA = "SYNC_DATA",
|
||||
CROSS_DAY = "CROSS_DAY",
|
||||
UPDATE_FORMATION = "UPDATE_FORMATION"
|
||||
}
|
||||
|
||||
return ServerDataConst
|
||||
@ -3,9 +3,7 @@ local ServerGameData = require "app/server/server_game_data"
|
||||
local ServerDataManager = {}
|
||||
|
||||
function ServerDataManager:init()
|
||||
end
|
||||
|
||||
function ServerDataManager:saveData()
|
||||
self.ServerFormationManager = require("app/server/manager/server_formation_manager")
|
||||
end
|
||||
|
||||
function ServerDataManager:randomReward(weightArr, callback)
|
||||
@ -40,7 +38,7 @@ function ServerDataManager:dataOperate(behavior, params, callback)
|
||||
end
|
||||
end)
|
||||
-- TODO临时处理
|
||||
LocalData:save()
|
||||
ServerGameData:saveData()
|
||||
else
|
||||
Logger.logError("Undefined data operation function, please check :%s", behavior)
|
||||
end
|
||||
@ -57,6 +55,70 @@ end
|
||||
|
||||
ServerDataManager.OP_FUNC = {
|
||||
[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
|
||||
@ -16,6 +16,7 @@ function ServerGameData:init()
|
||||
self:initServerData("BagData", "app/server/data/server_bag_data")
|
||||
self:initServerData("HeroData", "app/server/data/server_hero_data")
|
||||
self:initServerData("ChapterData", "app/server/data/server_chapter_data")
|
||||
self:initServerData("FormationData", "app/server/data/server_formation_data")
|
||||
end
|
||||
|
||||
function ServerGameData:initData()
|
||||
@ -23,7 +24,7 @@ function ServerGameData:initData()
|
||||
if self.distinctId == nil or self.distinctId == "" then
|
||||
self.distinctId = LocalData:getDistinctId()
|
||||
end
|
||||
local isNewPlayer = LocalData:getIsNewPlayer()
|
||||
local isNewPlayer = self:getIsNewPlayer()
|
||||
if isNewPlayer then
|
||||
for k, v in pairs(self.dataMap) do
|
||||
v:init()
|
||||
@ -69,9 +70,8 @@ function ServerGameData:initData()
|
||||
end
|
||||
end
|
||||
end
|
||||
self:setNotNewPlayer()
|
||||
self:saveData()
|
||||
LocalData:setNotNewPlayer()
|
||||
LocalData:save()
|
||||
else
|
||||
for k, v in pairs(self.dataMap) do
|
||||
v:init(v:loadLocalData())
|
||||
@ -99,6 +99,7 @@ function ServerGameData:saveData()
|
||||
for k, v in pairs(self.dataMap) do
|
||||
v:saveLocalData()
|
||||
end
|
||||
LocalData:save()
|
||||
end
|
||||
|
||||
-- 根据配置表添加奖励
|
||||
@ -197,4 +198,24 @@ function ServerGameData:setDistinctId(distinctId)
|
||||
self.distinctId = distinctId
|
||||
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
|
||||
@ -229,7 +229,7 @@ function BaseUI:isFullScreen()
|
||||
return true
|
||||
end
|
||||
|
||||
function BaseUI:currencyParams()
|
||||
function BaseUI:getCurrencyParams()
|
||||
return nil, false
|
||||
end
|
||||
|
||||
|
||||
@ -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:initGridCell()
|
||||
self:initSkill()
|
||||
self:initBattlefield()
|
||||
end
|
||||
|
||||
function BattleUI:_addListeners()
|
||||
@ -56,6 +57,15 @@ function BattleUI:initSkill()
|
||||
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)
|
||||
if not self.skillObjs then
|
||||
return
|
||||
|
||||
@ -6,27 +6,55 @@ function HeroCell:init()
|
||||
self.heroBg = uiMap["hero_cell.hero_bg"]
|
||||
self.check = uiMap["hero_cell.hero_bg.mask"]
|
||||
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
|
||||
|
||||
function HeroCell:refresh(heroEntity)
|
||||
function HeroCell:refresh(heroEntity, isGray)
|
||||
local heroInfo = heroEntity:getConfig()
|
||||
self:_refresh(heroInfo)
|
||||
self:_refresh(heroInfo, isGray)
|
||||
end
|
||||
|
||||
function HeroCell:refreshWithCfgId(id)
|
||||
function HeroCell:refreshWithCfgId(id, isGray)
|
||||
local heroInfo = ConfigManager:getConfig("hero")[id]
|
||||
self:_refresh(heroInfo)
|
||||
self:_refresh(heroInfo, isGray)
|
||||
end
|
||||
|
||||
function HeroCell:_refresh(heroInfo)
|
||||
function HeroCell:_refresh(heroInfo, isGray)
|
||||
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.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position])
|
||||
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
|
||||
|
||||
function HeroCell:setVisible(visible)
|
||||
self.baseObject:setVisible(visible)
|
||||
end
|
||||
|
||||
function HeroCell:setGray(isGray)
|
||||
if self.isGray == isGray then
|
||||
return
|
||||
end
|
||||
self.icon:setImageGray(isGray)
|
||||
self.matchImg:setImageGray(isGray)
|
||||
end
|
||||
|
||||
return HeroCell
|
||||
|
||||
@ -16,69 +16,40 @@ function ResourceCell:init()
|
||||
end
|
||||
|
||||
function ResourceCell:show(itemId, hideAddImg)
|
||||
-- hideAddImg = hideAddImg or false
|
||||
-- self:hide()
|
||||
-- if not itemId then
|
||||
-- return
|
||||
-- end
|
||||
-- self.baseObject:setActive(true)
|
||||
-- self.num = nil
|
||||
|
||||
-- local obj = DataManager.BagData.ItemData:getItemById(itemId)
|
||||
-- self.resImg:setSprite(obj:getIconRes())
|
||||
|
||||
-- self:unBindAll()
|
||||
-- self:bind(obj, "isDirty", function(binder, value)
|
||||
-- self:refreshTextRightNow()
|
||||
-- end)
|
||||
|
||||
-- self.baseObject:removeClickListener()
|
||||
|
||||
-- self.timeTx:setVisible(false)
|
||||
-- self.itemId = itemId
|
||||
-- if itemId == GConst.ItemConst.ITEM_ID_GEM then
|
||||
-- self.baseObject:addClickListener(function()
|
||||
-- if ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.SHOP, true) then
|
||||
-- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, {page = 5, storeIdx = 4})
|
||||
-- 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)
|
||||
hideAddImg = hideAddImg or false
|
||||
self:hide()
|
||||
if not itemId then
|
||||
return
|
||||
end
|
||||
self.baseObject:setActive(true)
|
||||
|
||||
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
|
||||
local obj = DataManager.BagData.ItemData:getItemById(itemId)
|
||||
self.resImg:setSprite(obj:getIconRes())
|
||||
|
||||
self:unBindAll()
|
||||
self:bind(obj, "isDirty", function(binder, value)
|
||||
self:refreshTextRightNow()
|
||||
end)
|
||||
|
||||
self.baseObject:removeClickListener()
|
||||
|
||||
self.timeTx:setVisible(false)
|
||||
self.itemId = itemId
|
||||
if itemId == GConst.ItemConst.ITEM_ID_GOLD then
|
||||
self.addImg:setVisible(not hideAddImg)
|
||||
else
|
||||
self.addImg:setVisible(not hideAddImg)
|
||||
end
|
||||
end
|
||||
|
||||
function ResourceCell:updateTime()
|
||||
if self.itemId then
|
||||
--local curTime = DataManager.BagData:getTimelyItemRecoveryTime(self.itemId)
|
||||
--if curTime <= 0 then
|
||||
-- self.timeTx:setText("")
|
||||
--else
|
||||
-- self.timeTx:setText(GFunc.getTimeStrWithMS(curTime))
|
||||
--end
|
||||
local curTime = DataManager.BagData:getTimelyItemRecoveryTime(self.itemId)
|
||||
if curTime <= 0 then
|
||||
self.timeTx:setText(GConst.EMPTY_STRING)
|
||||
else
|
||||
self.timeTx:setText(GFunc.getTimeStrWithMS(curTime))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -95,18 +66,18 @@ function ResourceCell:getAnchoredPosition()
|
||||
end
|
||||
|
||||
function ResourceCell:refreshTextRightNow()
|
||||
-- if not self.itemId then
|
||||
-- return
|
||||
-- end
|
||||
-- local obj = DataManager.BagData.ItemData:getItemById(self.itemId)
|
||||
-- local bigNum = obj:getBigNum()
|
||||
-- if bigNum.value < 0 then
|
||||
-- self.numTx:setText(0)
|
||||
-- elseif obj:getItemType() == 6 then
|
||||
-- self.numTx:setText(BigNumOpt.bigNum2Num(bigNum))
|
||||
-- else
|
||||
-- self.numTx:setText(BigNumOpt.bigNum2Str(bigNum))
|
||||
-- end
|
||||
if not self.itemId then
|
||||
return
|
||||
end
|
||||
local obj = DataManager.BagData.ItemData:getItemById(self.itemId)
|
||||
local count = obj:getNum()
|
||||
if count < 0 then
|
||||
self.numTx:setText("0")
|
||||
elseif obj:getItemType() == GConst.ItemConst.ITEM_ID_VIT then
|
||||
self.numTx:setText(GFunc.num2Str(count) .. "/" .. DataManager.PlayerData:getMaxVit())
|
||||
else
|
||||
self.numTx:setText(GFunc.num2Str(count))
|
||||
end
|
||||
end
|
||||
|
||||
function ResourceCell:refreshText()
|
||||
@ -114,7 +85,7 @@ function ResourceCell:refreshText()
|
||||
return
|
||||
end
|
||||
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)
|
||||
end
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ local CurrencyBar = class("CurrencyBar", Component)
|
||||
CurrencyBar.cellWidth = 174
|
||||
CurrencyBar.cellHeight = 40
|
||||
|
||||
local OFFSET_X = 200 -- -27
|
||||
local OFFSET_X = -27
|
||||
local OFFSET_Y = -22
|
||||
|
||||
function CurrencyBar:init()
|
||||
@ -97,14 +97,14 @@ function CurrencyBar:showSort()
|
||||
return
|
||||
end
|
||||
local w, h = GFunc.getUIExpandScreenSize()
|
||||
-- local offset = (w - 720) / 2
|
||||
local offset = 0
|
||||
local offset = (w - 720) / 2
|
||||
if offset <= 0 then
|
||||
offset = 0
|
||||
end
|
||||
if self.params.showType == GConst.CURRENCY_TYPE.HORIZONTAL then
|
||||
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
|
||||
else
|
||||
for i,v in ipairs(self.params.itemIds) do
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
local DevToolManager = require "app/module/gm/dev_tool_manager"
|
||||
local GMConst = require "app/module/gm/gm_const"
|
||||
-- local ItemConst = require "app/module/item/item_const"
|
||||
local GMToolUI = class("GMToolUI",BaseUI)
|
||||
|
||||
function GMToolUI:ctor()
|
||||
@ -23,16 +21,10 @@ function GMToolUI:onRefresh()
|
||||
local titleTx = self.uiMap['gm_tool_ui.title']
|
||||
local okBtn = self.uiMap['gm_tool_ui.ok_btn']
|
||||
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 inputFieldText = self.uiMap['gm_tool_ui.InputField.text']
|
||||
local scrollView = self.uiMap['gm_tool_ui.ScrollView']
|
||||
local textTip = self.uiMap['gm_tool_ui.text_tip']
|
||||
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.scrollRect = scrollView:getLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||
@ -50,7 +42,6 @@ function GMToolUI:onRefresh()
|
||||
self.inputField = inputField
|
||||
titleTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "GM面板"
|
||||
okBtnText:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "确定"
|
||||
attrBtnTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT).text = "英雄属性"
|
||||
|
||||
|
||||
okBtn:addClickListener(function()
|
||||
@ -73,20 +64,6 @@ function GMToolUI:onRefresh()
|
||||
CS.UnityEngine.Time.timeScale = timeScale
|
||||
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()
|
||||
local comp = UIManager.uiRoot:getComponent(typeof(CS.BF.ShowFPS))
|
||||
if comp == nil then
|
||||
@ -95,10 +72,6 @@ function GMToolUI:onRefresh()
|
||||
comp.enabled = not comp.enabled
|
||||
end
|
||||
end)
|
||||
|
||||
heroListNode:addClickListener(function()
|
||||
heroListNode:setActive(false)
|
||||
end)
|
||||
end
|
||||
|
||||
function GMToolUI:initScrollRectCell(index, cell)
|
||||
@ -116,73 +89,13 @@ function GMToolUI:sendMsg(gmCommand)
|
||||
else
|
||||
local args = {}
|
||||
args.args = string.split(gmCommand, " ")
|
||||
if args.args[1] == "time" then -- 特殊处理
|
||||
local args1 = {}
|
||||
args1.args = {}
|
||||
args1.args[1] = args.args[1]
|
||||
args1.args[2] = args.args[2] .. " " .. args.args[3]
|
||||
ModuleManager.DevToolManager:dealGM(args1)
|
||||
else
|
||||
ModuleManager.DevToolManager:dealGM(args)
|
||||
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
|
||||
ServerDataManager:dealGM(args, function()
|
||||
ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA, GConst.EMPTY_TABLE, function(msgData)
|
||||
DataManager:initWithServerData(msgData)
|
||||
ModuleManager.MaincityManager:firstEnterMainCity()
|
||||
end)
|
||||
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()
|
||||
|
||||
@ -17,7 +17,7 @@ function HeroListCell:init()
|
||||
self.titleTx = self.uiMap["hero_list_cell.title.title_desc"]
|
||||
end
|
||||
|
||||
function HeroListCell:refresh(index, heroList, allHeroCount, activeCount)
|
||||
function HeroListCell:refresh(index, heroList, stageFormation, allHeroCount, activeCount)
|
||||
if activeCount > 0 and index == 1 then
|
||||
self.title:setVisible(true)
|
||||
self.titleTx:setText("临时文本:已解锁")
|
||||
@ -38,13 +38,20 @@ function HeroListCell:refresh(index, heroList, allHeroCount, activeCount)
|
||||
for i = 1, 4 do
|
||||
if heroIndex <= activeCount then
|
||||
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
|
||||
if heroStartIndex <= activeCount then
|
||||
self.heroCells[i]:setVisible(false)
|
||||
else
|
||||
self.heroCells[i]:setVisible(true)
|
||||
self.heroCells[i]:refreshWithCfgId(heroList[heroStartIndex])
|
||||
self.heroCells[i]:refreshWithCfgId(heroList[heroIndex], true)
|
||||
end
|
||||
else
|
||||
self.heroCells[i]:setVisible(false)
|
||||
|
||||
@ -9,7 +9,7 @@ function HeroComp:init()
|
||||
return HERO_LIST_CELL
|
||||
end)
|
||||
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)
|
||||
self.heroList = {}
|
||||
local heroCfg = ConfigManager:getConfig("hero")
|
||||
@ -19,9 +19,15 @@ function HeroComp:init()
|
||||
end
|
||||
|
||||
function HeroComp:refresh()
|
||||
self.stageFormation = DataManager.FormationData:getStageFormation()
|
||||
self:refreshStageFormation()
|
||||
self:refreshScrollRect()
|
||||
end
|
||||
|
||||
function HeroComp:refreshStageFormation()
|
||||
|
||||
end
|
||||
|
||||
function HeroComp:refreshScrollRect()
|
||||
self:sortHeroList()
|
||||
self.allHeroCount = #self.heroList
|
||||
|
||||
@ -4,6 +4,7 @@ local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
|
||||
function MainComp:init()
|
||||
self.uiMap = self:getBaseObject():genAllChildren()
|
||||
self:initChapter()
|
||||
self:initStageFormation()
|
||||
self:initGM()
|
||||
end
|
||||
|
||||
@ -28,6 +29,16 @@ function MainComp:initChapter()
|
||||
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()
|
||||
self.btnGM = self.uiMap["main_comp.gm_btn"]
|
||||
self.btnGM:setVisible(not Platform:getIsPublishChannel(), 2)
|
||||
@ -38,6 +49,7 @@ end
|
||||
|
||||
function MainComp:refresh()
|
||||
self:refreshChapter()
|
||||
self:refreshStageFormaion()
|
||||
end
|
||||
|
||||
function MainComp:onFightBtnClick()
|
||||
@ -59,4 +71,20 @@ function MainComp:refreshChapter()
|
||||
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
|
||||
@ -21,49 +21,25 @@ function MainCityUI:getUIType()
|
||||
return UIManager.UI_TYPE.MAIN
|
||||
end
|
||||
|
||||
function MainCityUI:currencyParams()
|
||||
if self.cheat then
|
||||
local params = {}
|
||||
params.itemIds = {}
|
||||
return params
|
||||
function MainCityUI:getCurrencyParams()
|
||||
if self.currencyParams == nil then
|
||||
self.currencyParams = {
|
||||
itemIds = {}
|
||||
}
|
||||
end
|
||||
self.selectedIndex = self.selectedIndex or MAIN_COMP_INDEX
|
||||
local params = {}
|
||||
params.showType = GConst.CURRENCY_TYPE.HORIZONTAL
|
||||
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.COMMERCE 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.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,
|
||||
}
|
||||
self.currencyParams.showType = GConst.CURRENCY_TYPE.HORIZONTAL
|
||||
for k, v in ipairs(self.currencyParams.itemIds) do
|
||||
table.remove(self.currencyParams.itemIds)
|
||||
end
|
||||
return params, true
|
||||
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
|
||||
self.currencyParams.itemIds[1] = GConst.ItemConst.ITEM_ID_VIT
|
||||
self.currencyParams.itemIds[2] = GConst.ItemConst.ITEM_ID_GOLD
|
||||
elseif self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.HERO then
|
||||
return nil
|
||||
end
|
||||
return self.currencyParams
|
||||
end
|
||||
|
||||
|
||||
function MainCityUI:getPrefabPath()
|
||||
return "assets/prefabs/ui/main_city/main_ui.prefab"
|
||||
@ -119,13 +95,17 @@ function MainCityUI:_bind()
|
||||
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.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)
|
||||
-- UIManager:refreshCurrencyBarTxt()
|
||||
|
||||
@ -991,37 +991,6 @@ function UIManager:backToLoginWithoutLogout()
|
||||
Game:showLoginUI()
|
||||
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()
|
||||
self.disconnectMsgBoxVisible = true
|
||||
@ -1056,7 +1025,7 @@ function UIManager:_loadCurrencyBar(params, showBg, hidAddImg)
|
||||
end
|
||||
|
||||
function UIManager:showCurrencyBar(uiObj)
|
||||
local params, showBg, hidAddImg = uiObj:currencyParams()
|
||||
local params, showBg, hidAddImg = uiObj:getCurrencyParams()
|
||||
if params then
|
||||
local currCurrencyBarOrder = 0
|
||||
if self.currencyBarBindUI then
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
local ItemEntity = class("ItemEntity", BaseData)
|
||||
|
||||
function ItemEntity:ctor(id, bigNum)
|
||||
function ItemEntity:ctor(id, num)
|
||||
self.data.id = id
|
||||
self.data.bigNum = bigNum
|
||||
self.data.num = num
|
||||
self.data.isDirty = false
|
||||
self.config = nil
|
||||
|
||||
@ -30,19 +30,19 @@ function ItemEntity:getId()
|
||||
end
|
||||
|
||||
-- 道具数量
|
||||
function ItemEntity:getBigNum()
|
||||
return self.data.bigNum
|
||||
function ItemEntity:getNum()
|
||||
return self.data.num
|
||||
end
|
||||
|
||||
-- 加减道具数量
|
||||
function ItemEntity:addNum(num)
|
||||
self.data.bigNum = BigNumOpt.bigNumAdd(self.data.bigNum, bigNum)
|
||||
self.data.num = self.data.num + num
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
-- 设置数量
|
||||
function ItemEntity:setNum(bigNum)
|
||||
self.data.bigNum = bigNum
|
||||
function ItemEntity:setNum(num)
|
||||
self.data.num = num
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
@ -66,7 +66,7 @@ function ItemEntity:getFrameRes()
|
||||
end
|
||||
|
||||
function ItemEntity:getIconRes()
|
||||
return GConst.ATLAS_PATH.ICON_ITEM, tostring(self.config.icon)
|
||||
return GConst.ATLAS_PATH.ICON_ITEM, self.config.icon
|
||||
end
|
||||
|
||||
-- 类型
|
||||
|
||||
@ -7,6 +7,9 @@ local BattleConst = GConst.BattleConst
|
||||
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 ATTR_TYPE = GConst.ATTR_TYPE
|
||||
local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR
|
||||
|
||||
function BattleData:init(board, skillIds, skillPool)
|
||||
self:clear()
|
||||
self.atkTeam = self:initTeam(BattleConst.SIDE_ATK)
|
||||
@ -244,9 +247,54 @@ function BattleData:changeSkillId(elementType, newId)
|
||||
end
|
||||
|
||||
function BattleData:initTeam(side)
|
||||
local data = nil
|
||||
if side == BattleConst.SIDE_ATK then
|
||||
data = self:initHeroData()
|
||||
end
|
||||
local team = BattleTeamEntity:create()
|
||||
team:init(side)
|
||||
team:init(side, data)
|
||||
return team
|
||||
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
|
||||
13
lua/app/userdata/battle/skill/battle_skill_entity.lua
Normal file
13
lua/app/userdata/battle/skill/battle_skill_entity.lua
Normal 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
|
||||
10
lua/app/userdata/battle/skill/battle_skill_entity.lua.meta
Normal file
10
lua/app/userdata/battle/skill/battle_skill_entity.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c5c8cb74597bdb46b1fcc5c941b9625
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -4,10 +4,43 @@ local BattleTeamEntity = class("BattleTeamEntity", BaseData)
|
||||
|
||||
function BattleTeamEntity:ctor()
|
||||
self.members = {}
|
||||
self.membersCount = 0
|
||||
end
|
||||
|
||||
function BattleTeamEntity:init(side)
|
||||
function BattleTeamEntity:init(side, data)
|
||||
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
|
||||
|
||||
return BattleTeamEntity
|
||||
@ -1,9 +1,58 @@
|
||||
local BattleSkillEntity = require "app/userdata/battle/skill/battle_skill_entity"
|
||||
|
||||
local BattleUnitEntity = class("BattleUnitEntity", BaseData)
|
||||
|
||||
function BattleUnitEntity:ctor()
|
||||
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
|
||||
|
||||
return BattleUnitEntity
|
||||
8
lua/app/userdata/formation.meta
Normal file
8
lua/app/userdata/formation.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dd4742e9835fbe41b107d5cbe1a1b5f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
lua/app/userdata/formation/formation_data.lua
Normal file
43
lua/app/userdata/formation/formation_data.lua
Normal 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
|
||||
10
lua/app/userdata/formation/formation_data.lua.meta
Normal file
10
lua/app/userdata/formation/formation_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ed68c36ffa91694d9e2138c00b862d0
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||
@ -4,6 +4,8 @@ function HeroEntity:ctor(cfgId, lv)
|
||||
self.id = cfgId
|
||||
self.cfgId = cfgId
|
||||
self.data.lv = lv
|
||||
self.atkKey = nil
|
||||
self.hpKey = nil
|
||||
self.attrDirty = false
|
||||
self.config = ConfigManager:getConfig("hero")[self.cfgId]
|
||||
|
||||
@ -22,11 +24,19 @@ function HeroEntity:setLv(lv)
|
||||
if not lv then
|
||||
return
|
||||
end
|
||||
|
||||
if self.data.lv == lv then
|
||||
return
|
||||
end
|
||||
self.data.lv = lv
|
||||
self.atkKey = nil
|
||||
self.hpKey = nil
|
||||
self:setDirty()
|
||||
end
|
||||
|
||||
function HeroEntity:getCfgId()
|
||||
return self.cfgId
|
||||
end
|
||||
|
||||
function HeroEntity:getLv()
|
||||
return self.data.lv
|
||||
end
|
||||
@ -35,6 +45,10 @@ function HeroEntity:getQlt()
|
||||
return self.config.qlt
|
||||
end
|
||||
|
||||
function HeroEntity:getMatchType()
|
||||
return self.config.position
|
||||
end
|
||||
|
||||
function HeroEntity:setAttrDirty()
|
||||
self.attrDirty = true
|
||||
end
|
||||
@ -52,8 +66,22 @@ function HeroEntity:updateAttr()
|
||||
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
|
||||
self.baseAttrOriginal[GConst.ATTR_TYPE.hp] = self.config[self:getHpKey()] 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
|
||||
|
||||
function HeroEntity:getAtk()
|
||||
@ -99,4 +127,12 @@ function HeroEntity:getConfig()
|
||||
return self.config
|
||||
end
|
||||
|
||||
function HeroEntity:getModelId()
|
||||
return self.config.model_id
|
||||
end
|
||||
|
||||
function HeroEntity:getActiveSkill()
|
||||
return self.config.base_skill
|
||||
end
|
||||
|
||||
return HeroEntity
|
||||
@ -3,4 +3,12 @@ local PlayerData = class("PlayerData", BaseData)
|
||||
function PlayerData:init(data)
|
||||
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
|
||||
Loading…
x
Reference in New Issue
Block a user