体力
This commit is contained in:
parent
3785afdf9c
commit
7508f219d2
@ -117,7 +117,8 @@ BIReport.RUNE_OPT_TYPE = {
|
||||
BIReport.ITEM_GET_TYPE = {
|
||||
NEW_PLAYER_INITIAL = "NewPlayerInitial", -- 新玩家创号自带
|
||||
UPGRADE_HERO = "UpgradeHero",
|
||||
FIGHT_END = "FightEnd",
|
||||
CHAPTER_FIGHT_START = "ChapterFightStart",
|
||||
CHAPTER_FIGHT_END = "ChapterFightEnd",
|
||||
CHAPTER_BOX = "ChapterBox"
|
||||
}
|
||||
|
||||
|
||||
@ -544,6 +544,11 @@ function GFunc.getConstValue(key)
|
||||
return ConstCfg[key] and ConstCfg[key].value or 0
|
||||
end
|
||||
|
||||
function GFunc.getConstReward(key)
|
||||
local ConstCfg = ConfigManager:getConfig("const")
|
||||
return ConstCfg[key] and ConstCfg[key].reward
|
||||
end
|
||||
|
||||
function GFunc.getTargetAnchoredPosition(targetGo, parent)
|
||||
local rectTransform = targetGo:getComponent(GConst.TYPEOF_UNITY_CLASS.RECTTRANSFORM)
|
||||
local rect = rectTransform.rect
|
||||
|
||||
@ -24,8 +24,26 @@ function ChapterManager:startFight()
|
||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8))
|
||||
return
|
||||
end
|
||||
---- 通信
|
||||
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE)
|
||||
local cost = DataManager.ChapterData:getFightCost()
|
||||
local vitCostNum = 0
|
||||
if cost then
|
||||
vitCostNum = GFunc.getRewardNum(cost)
|
||||
end
|
||||
if vitCostNum > DataManager.BagData.ItemData:getVit() then
|
||||
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
|
||||
return
|
||||
end
|
||||
local parmas = {
|
||||
id = DataManager.ChapterData:getChapterId()
|
||||
}
|
||||
ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.START_FIGHT, parmas, function(result)
|
||||
if result.status == 0 then
|
||||
if result.cost then
|
||||
GFunc.addCosts(result.cost, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_START)
|
||||
end
|
||||
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ChapterManager:endFight(id, combatReport)
|
||||
@ -53,7 +71,7 @@ function ChapterManager:endFight(id, combatReport)
|
||||
if combatReport.victory and DataManager.ChapterData:getChapterId() == DataManager.ChapterData:getMaxChapterId() + 1 then
|
||||
DataManager.ChapterData:goNextChapter()
|
||||
end
|
||||
GFunc.addRewards(result.rewards, BIReport.ITEM_GET_TYPE.FIGHT_END)
|
||||
GFunc.addRewards(result.rewards, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_END)
|
||||
local newRewards = {}
|
||||
if result.rewards then
|
||||
GFunc.mergeRewards2(result.rewards, newRewards)
|
||||
|
||||
@ -121,7 +121,7 @@ end
|
||||
|
||||
function ServerItemData:resetVitRecoverTime()
|
||||
local maxCount = self:getMaxVit()
|
||||
local ServerGameData = require "app/server/data/server_game_data"
|
||||
local ServerGameData = require "app/server/server_game_data"
|
||||
local currentCount = ServerGameData.PlayerData:getVit()
|
||||
if currentCount >= maxCount then -- 已经达到上限
|
||||
return
|
||||
@ -131,7 +131,7 @@ function ServerItemData:resetVitRecoverTime()
|
||||
if currentCount >= maxCount then -- 已经达到上限
|
||||
return
|
||||
end
|
||||
for i,v in ipairs(self.recoveries) do
|
||||
for i,v in ipairs(self.data.recoveries) do
|
||||
if v.cfg_id == GConst.ItemConst.ITEM_ID_VIT then
|
||||
self.data.recoveries[i].ts = Time:getServerTime()
|
||||
end
|
||||
|
||||
@ -31,6 +31,32 @@ function ServerChapterManager:openBox(params, callback)
|
||||
end
|
||||
end
|
||||
|
||||
function ServerChapterManager:startFight(params, callback)
|
||||
local result = {
|
||||
status = 1
|
||||
}
|
||||
local cost = GFunc.getConstReward("chapter_cost")
|
||||
if cost == nil then
|
||||
if callback then
|
||||
callback(result)
|
||||
end
|
||||
return
|
||||
end
|
||||
local vitCostNum = GFunc.getRewardNum(cost)
|
||||
local ServerGameData = ServerDataManager:getServerGameData()
|
||||
if vitCostNum > ServerGameData.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_VIT) then
|
||||
if callback then
|
||||
callback(result)
|
||||
end
|
||||
return
|
||||
end
|
||||
result.cost = ServerGameData:addCosts({cost})
|
||||
result.status = 0
|
||||
if callback then
|
||||
callback(result)
|
||||
end
|
||||
end
|
||||
|
||||
function ServerChapterManager:endFight(params, callback)
|
||||
local result = {
|
||||
status = 1
|
||||
|
||||
@ -10,6 +10,7 @@ ServerDataConst.DATA_OP_BEHAVIOR = {
|
||||
CROSS_DAY = "CROSS_DAY",
|
||||
UPDATE_FORMATION = "UPDATE_FORMATION",
|
||||
UPGRADE_HERO = "UPGRADE_HERO",
|
||||
START_FIGHT = "START_FIGHT",
|
||||
END_FIGHT = "END_FIGHT",
|
||||
OPEN_CHAPTER_BOX = "OPEN_CHAPTER_BOX",
|
||||
MARK_GUIDE = "MARK_GUIDE",
|
||||
|
||||
@ -66,6 +66,7 @@ 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,
|
||||
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPGRADE_HERO] = function (...) ServerDataManager.ServerHeroManager:onUpgradeHero(...) end,
|
||||
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.START_FIGHT] = function(...) ServerDataManager.ServerChapterManager:startFight(...) end,
|
||||
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.END_FIGHT] = function(...) ServerDataManager.ServerChapterManager:endFight(...) end,
|
||||
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.OPEN_CHAPTER_BOX] = function(...) ServerDataManager.ServerChapterManager:openBox(...) end,
|
||||
[GConst.ServerDataConst.DATA_OP_BEHAVIOR.MARK_GUIDE] = function(...) ServerDataManager.ServerTutorialManager:markGuide(...) end,
|
||||
|
||||
@ -149,7 +149,12 @@ function MainComp:refreshChapter(force)
|
||||
end
|
||||
|
||||
self.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
|
||||
self.uiMap["main_comp.fight_btn.desc_2"]:setText(DataManager.ChapterData:getFightCost())
|
||||
local cost = DataManager.ChapterData:getFightCost()
|
||||
if cost then
|
||||
self.uiMap["main_comp.fight_btn.desc_2"]:setText(GFunc.getRewardNum(cost))
|
||||
else
|
||||
self.uiMap["main_comp.fight_btn.desc_2"]:setText("0")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -74,6 +74,10 @@ function ItemData:getItemNumById(id)
|
||||
return num
|
||||
end
|
||||
|
||||
function ItemData:getVit()
|
||||
return self:getItemNumById(GConst.ItemConst.ITEM_ID_VIT)
|
||||
end
|
||||
|
||||
function ItemData:addItemReward(item, itemGetType)
|
||||
CACHE_ITEM.cfg_id = GFunc.getRewardId(item)
|
||||
CACHE_ITEM.count = GFunc.getRewardNum(item)
|
||||
|
||||
@ -170,14 +170,8 @@ function ChapterData:getChapterMaxWave(chapterId)
|
||||
return 0
|
||||
end
|
||||
|
||||
function ChapterData:getFightCost(chapterId)
|
||||
chapterId = chapterId or self:getChapterId()
|
||||
local cfg = self:getChapterCfg()[chapterId]
|
||||
if cfg and cfg.cost then
|
||||
return cfg.cost.num
|
||||
end
|
||||
|
||||
return 0
|
||||
function ChapterData:getFightCost()
|
||||
return GFunc.getConstReward("chapter_cost")
|
||||
end
|
||||
|
||||
function ChapterData:getMaxChapterId()
|
||||
|
||||
@ -3,6 +3,13 @@ local PlayerData = class("PlayerData", BaseData)
|
||||
function PlayerData:init(data)
|
||||
end
|
||||
|
||||
function PlayerData:setVit(vit)
|
||||
self.vit = vit
|
||||
end
|
||||
|
||||
function PlayerData:getVit()
|
||||
return self.vit or 0
|
||||
end
|
||||
|
||||
function PlayerData:getMaxVit()
|
||||
if self.maxVit == nil then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user