Merge branch 'dev' of http://git.juzugame.com/b6-client/b6-lua into dev
This commit is contained in:
commit
1718c96004
@ -13,6 +13,7 @@ function DataManager:init()
|
|||||||
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
||||||
self:initManager("FormationData", "app/userdata/formation/formation_data")
|
self:initManager("FormationData", "app/userdata/formation/formation_data")
|
||||||
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
|
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
|
||||||
|
self:initManager("MailData", "app/userdata/mail/mail_data")
|
||||||
self:initManager("ActivityData", "app/userdata/activity/activity_data")
|
self:initManager("ActivityData", "app/userdata/activity/activity_data")
|
||||||
self:initManager("GodPigData", "app/userdata/activity/god_pig/god_pig_data")
|
self:initManager("GodPigData", "app/userdata/activity/god_pig/god_pig_data")
|
||||||
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
|
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
|
||||||
@ -82,6 +83,7 @@ function DataManager:clear()
|
|||||||
self.BagData:clear()
|
self.BagData:clear()
|
||||||
self.FormationData:clear()
|
self.FormationData:clear()
|
||||||
self.ActivityData:clear()
|
self.ActivityData:clear()
|
||||||
|
self.MailData:clear()
|
||||||
self.GodPigData:clear()
|
self.GodPigData:clear()
|
||||||
self.BountyData:clear()
|
self.BountyData:clear()
|
||||||
self.DailyTaskData:clear()
|
self.DailyTaskData:clear()
|
||||||
@ -110,6 +112,7 @@ function DataManager:initWithServerData(data)
|
|||||||
self.BagData:init(data.bag)
|
self.BagData:init(data.bag)
|
||||||
self.FormationData:init(data.fight_info)
|
self.FormationData:init(data.fight_info)
|
||||||
self.TutorialData:init(data.guide)
|
self.TutorialData:init(data.guide)
|
||||||
|
self.MailData:init(data.mail_info)
|
||||||
self.ActivityData:init()
|
self.ActivityData:init()
|
||||||
self.GodPigData:init()
|
self.GodPigData:init()
|
||||||
self.BountyData:init(data.bounty)
|
self.BountyData:init(data.bounty)
|
||||||
|
|||||||
@ -37,6 +37,8 @@ local MODULE_PATHS = {
|
|||||||
BountyManager = "app/module/bounty/bounty_manager",
|
BountyManager = "app/module/bounty/bounty_manager",
|
||||||
-- 商店
|
-- 商店
|
||||||
ShopManager = "app/module/shop/shop_manager",
|
ShopManager = "app/module/shop/shop_manager",
|
||||||
|
-- 邮件
|
||||||
|
MailManager = "app/module/mail/mail_manager",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 这里的key对应func_open里的id
|
-- 这里的key对应func_open里的id
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -111,6 +111,7 @@ local LocalizationGlobalConst =
|
|||||||
IDLE_DROP_DESC_3 = "IDLE_DROP_DESC_3",
|
IDLE_DROP_DESC_3 = "IDLE_DROP_DESC_3",
|
||||||
STR_FREE = "STR_FREE",
|
STR_FREE = "STR_FREE",
|
||||||
TODAY_REMAIN_TIMES = "TODAY_REMAIN_TIMES",
|
TODAY_REMAIN_TIMES = "TODAY_REMAIN_TIMES",
|
||||||
|
BUY_ENERGY = "BUY_ENERGY",
|
||||||
}
|
}
|
||||||
|
|
||||||
return LocalizationGlobalConst
|
return LocalizationGlobalConst
|
||||||
@ -206,7 +206,6 @@ local skill = {
|
|||||||
["fx_target_delay"]=900
|
["fx_target_delay"]=900
|
||||||
},
|
},
|
||||||
[1200121]={
|
[1200121]={
|
||||||
["energy"]=10,
|
|
||||||
["position"]=1,
|
["position"]=1,
|
||||||
["effect_type"]=2,
|
["effect_type"]=2,
|
||||||
["trigger"]=3,
|
["trigger"]=3,
|
||||||
@ -222,7 +221,6 @@ local skill = {
|
|||||||
["skill_position"]=1
|
["skill_position"]=1
|
||||||
},
|
},
|
||||||
[1200122]={
|
[1200122]={
|
||||||
["energy"]=10,
|
|
||||||
["position"]=1,
|
["position"]=1,
|
||||||
["effect_type"]=2,
|
["effect_type"]=2,
|
||||||
["trigger"]=3,
|
["trigger"]=3,
|
||||||
@ -243,6 +241,38 @@ local skill = {
|
|||||||
["obj"]=1,
|
["obj"]=1,
|
||||||
["skill_position"]=1
|
["skill_position"]=1
|
||||||
},
|
},
|
||||||
|
[1200123]={
|
||||||
|
["position"]=1,
|
||||||
|
["buff_condition"]={
|
||||||
|
{
|
||||||
|
{
|
||||||
|
["type"]="state",
|
||||||
|
["attr"]="normal_attack_dec",
|
||||||
|
["op"]=">",
|
||||||
|
["v"]=0,
|
||||||
|
["side"]=2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["condition_rel"]={
|
||||||
|
{
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["effect_type"]=2,
|
||||||
|
["trigger"]=7,
|
||||||
|
["effect"]={
|
||||||
|
{
|
||||||
|
["type"]="dmg_addition_blue_add",
|
||||||
|
["num"]=5000,
|
||||||
|
["ratio"]=10000,
|
||||||
|
["round"]=1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["obj"]=1,
|
||||||
|
["skill_position"]=2
|
||||||
|
},
|
||||||
[1300110]={
|
[1300110]={
|
||||||
["position"]=1,
|
["position"]=1,
|
||||||
["effect_type"]=1,
|
["effect_type"]=1,
|
||||||
@ -3089,6 +3119,23 @@ local skill = {
|
|||||||
},
|
},
|
||||||
[4300121]={
|
[4300121]={
|
||||||
["position"]=4,
|
["position"]=4,
|
||||||
|
["buff_condition"]={
|
||||||
|
{
|
||||||
|
{
|
||||||
|
["type"]="state",
|
||||||
|
["attr"]="burn",
|
||||||
|
["op"]=">",
|
||||||
|
["v"]=0,
|
||||||
|
["side"]=2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
["condition_rel"]={
|
||||||
|
{
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
}
|
||||||
|
},
|
||||||
["effect_type"]=2,
|
["effect_type"]=2,
|
||||||
["trigger"]=7,
|
["trigger"]=7,
|
||||||
["effect"]={
|
["effect"]={
|
||||||
@ -5881,6 +5928,6 @@ local skill = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
local config = {
|
local config = {
|
||||||
data=skill,count=276
|
data=skill,count=277
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
@ -700,11 +700,16 @@ local skill_rogue = {
|
|||||||
["limit_times"]=1,
|
["limit_times"]=1,
|
||||||
["weight"]=3000,
|
["weight"]=3000,
|
||||||
["qlt"]=3,
|
["qlt"]=3,
|
||||||
["type"]=1,
|
["type"]=12,
|
||||||
["parameter"]={
|
|
||||||
1200121
|
|
||||||
},
|
|
||||||
["skill_position"]=1,
|
["skill_position"]=1,
|
||||||
|
["effect"]={
|
||||||
|
{
|
||||||
|
["type"]="add_skill",
|
||||||
|
["num"]=1200123,
|
||||||
|
["ratio"]=10000,
|
||||||
|
["round"]=1
|
||||||
|
}
|
||||||
|
},
|
||||||
["icon"]="44"
|
["icon"]="44"
|
||||||
},
|
},
|
||||||
[1200104]={
|
[1200104]={
|
||||||
|
|||||||
@ -111,6 +111,7 @@ local localization_global =
|
|||||||
["IDLE_DROP_DESC_3"] = "立刻获得{0}小时挂机奖励",
|
["IDLE_DROP_DESC_3"] = "立刻获得{0}小时挂机奖励",
|
||||||
["STR_FREE"] = "免费",
|
["STR_FREE"] = "免费",
|
||||||
["TODAY_REMAIN_TIMES"] = "今日剩余{0}次",
|
["TODAY_REMAIN_TIMES"] = "今日剩余{0}次",
|
||||||
|
["BUY_ENERGY"] = "购买体力",
|
||||||
}
|
}
|
||||||
|
|
||||||
return localization_global
|
return localization_global
|
||||||
@ -6,8 +6,8 @@ local task = {
|
|||||||
{
|
{
|
||||||
["type"]=1,
|
["type"]=1,
|
||||||
["type_for_nothing"]="Vw==",
|
["type_for_nothing"]="Vw==",
|
||||||
["id"]=16,
|
["id"]=17,
|
||||||
["id_for_nothing"]="Vw4=",
|
["id_for_nothing"]="Vw8=",
|
||||||
["num"]=1,
|
["num"]=1,
|
||||||
["num_for_nothing"]="Vw=="
|
["num_for_nothing"]="Vw=="
|
||||||
}
|
}
|
||||||
@ -21,8 +21,8 @@ local task = {
|
|||||||
{
|
{
|
||||||
["type"]=1,
|
["type"]=1,
|
||||||
["type_for_nothing"]="Vw==",
|
["type_for_nothing"]="Vw==",
|
||||||
["id"]=17,
|
["id"]=16,
|
||||||
["id_for_nothing"]="Vw8=",
|
["id_for_nothing"]="Vw4=",
|
||||||
["num"]=1,
|
["num"]=1,
|
||||||
["num_for_nothing"]="Vw=="
|
["num_for_nothing"]="Vw=="
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ local CONST_PATHS = {
|
|||||||
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",
|
FormationConst = "app/module/formation/formation_const",
|
||||||
|
MailConst = "app/module/mail/mail_const",
|
||||||
}
|
}
|
||||||
|
|
||||||
if EDITOR_MODE then
|
if EDITOR_MODE then
|
||||||
|
|||||||
8
lua/app/module/mail.meta
Normal file
8
lua/app/module/mail.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 085251417eef56a4a8431c13b3392fd6
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
16
lua/app/module/mail/mail_const.lua
Normal file
16
lua/app/module/mail/mail_const.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
local MailConst = {}
|
||||||
|
|
||||||
|
MailConst.MAIL_TYPE = {
|
||||||
|
CUSTOM = 0, -- 自定义邮件,需要读取
|
||||||
|
AD = 1, -- 广告邮件,直接看广告领取
|
||||||
|
NORMAL = 2, -- 普通邮件,直接领取
|
||||||
|
READ = 3, -- 读取邮件
|
||||||
|
}
|
||||||
|
|
||||||
|
MailConst.MAIL_STATE = {
|
||||||
|
NOT_READ = 0,
|
||||||
|
READED = 1,
|
||||||
|
RECEIVED = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
return MailConst
|
||||||
10
lua/app/module/mail/mail_const.lua.meta
Normal file
10
lua/app/module/mail/mail_const.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 40977769f7f9c5f40b5bdac7c190ec35
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
135
lua/app/module/mail/mail_manager.lua
Normal file
135
lua/app/module/mail/mail_manager.lua
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
local MailManager = class("MailManager", BaseModule)
|
||||||
|
|
||||||
|
function MailManager:showMailUI()
|
||||||
|
UIManager:showUI("app/ui/mail/mail_ui")
|
||||||
|
self:getMailList()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:getMailList(force)
|
||||||
|
if not force and not DataManager.MailData:getNeedGetNewMail() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self:sendMessage(ProtoMsgType.FromMsgEnum.MailListReq, {}, {}, self.getMailListFinish)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:getMailListFinish(result)
|
||||||
|
if result.status == 0 then
|
||||||
|
DataManager.MailData:init(result)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 触发服务器时间相关邮件
|
||||||
|
function MailManager:getTriggeredTimeMail()
|
||||||
|
self:sendMessage(ProtoMsgType.FromMsgEnum.MailCycleReq, {}, {}, self.getTriggeredTimeMailFinish)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:getTriggeredTimeMailFinish(result)
|
||||||
|
if result.status == 0 then
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:claimMail(ids)
|
||||||
|
if not ids then
|
||||||
|
for mailId, entity in pairs(DataManager.MailData:getMails()) do
|
||||||
|
if entity:getIsNormalMail() and entity:canClaim() then
|
||||||
|
if not ids then
|
||||||
|
ids = {}
|
||||||
|
end
|
||||||
|
table.insert(ids, mailId)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for _, id in ipairs(ids) do
|
||||||
|
local entity = DataManager.MailData:getMails()[id]
|
||||||
|
if not entity or not entity:canClaim() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not ids then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local reqData = {ids = ids}
|
||||||
|
self:sendMessage(ProtoMsgType.FromMsgEnum.MailExtractReq, reqData, {}, self.claimMailFinish, BIReport.ITEM_GET_TYPE.MAIL)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:claimMailFinish(result)
|
||||||
|
if result.status == 0 then
|
||||||
|
GFunc.showRewardBox(result.rewards)
|
||||||
|
|
||||||
|
local needDeleteIds = {}
|
||||||
|
for _, id in ipairs(result.ids) do
|
||||||
|
local entity = DataManager.MailData:getMails()[id]
|
||||||
|
entity:receivedThis()
|
||||||
|
if entity:getIsAdMail() or entity:getIsNormalMail() then
|
||||||
|
table.insert(needDeleteIds, id)
|
||||||
|
end
|
||||||
|
BIReport:postMailClaim(id)
|
||||||
|
end
|
||||||
|
|
||||||
|
if needDeleteIds[1] then
|
||||||
|
DataManager.MailData:deleteMail(needDeleteIds) -- 提前删除邮件,提升体验
|
||||||
|
self:deleteMail(needDeleteIds)
|
||||||
|
end
|
||||||
|
|
||||||
|
DataManager.MailData:refreshRedPoint()
|
||||||
|
DataManager.MailData:setDirty()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:deleteMail(ids)
|
||||||
|
if not ids then
|
||||||
|
for mailId, entity in pairs(DataManager.MailData:getMails()) do
|
||||||
|
if entity:canDelete() then
|
||||||
|
if not ids then
|
||||||
|
ids = {}
|
||||||
|
end
|
||||||
|
table.insert(ids, mailId)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not ids or not ids[1] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local reqData = {ids = ids}
|
||||||
|
local rspData = {ids = ids}
|
||||||
|
self:sendMessage(ProtoMsgType.FromMsgEnum.MailDeleteReq, reqData, rspData, self.deleteMailFinish)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:deleteMailFinish(result)
|
||||||
|
if result.status then
|
||||||
|
DataManager.MailData:deleteMail(result.ids)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:readMail(id)
|
||||||
|
local entity = DataManager.MailData:getMails()[id]
|
||||||
|
if not entity:notRead() then
|
||||||
|
UIManager:showUI("app/ui/mail/mail_detail_ui", {id = id})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local reqData = {ids = {id}}
|
||||||
|
local rspData = {ids = {id}}
|
||||||
|
self:sendMessage(ProtoMsgType.FromMsgEnum.MailReadReq, reqData, rspData, self.readMailFinish)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:readMailFinish(result)
|
||||||
|
if result.status == 0 then
|
||||||
|
for _, id in ipairs(result.ids) do
|
||||||
|
DataManager.MailData:setMailRead(id)
|
||||||
|
BIReport:postMailOpen(id)
|
||||||
|
end
|
||||||
|
|
||||||
|
UIManager:showUI("app/ui/mail/mail_detail_ui", {id = result.ids[1]})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailManager:needUpdateMail()
|
||||||
|
DataManager.MailData:setNeedGetNewMail(true)
|
||||||
|
DataManager.MailData:setDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
return MailManager
|
||||||
10
lua/app/module/mail/mail_manager.lua.meta
Normal file
10
lua/app/module/mail/mail_manager.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9bb5abd215ec3b44aacf26c4581b1fa7
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -14,29 +14,25 @@ end
|
|||||||
|
|
||||||
function BuyVitUI:onLoadRootComplete()
|
function BuyVitUI:onLoadRootComplete()
|
||||||
local uiMap = self.root:genAllChildren()
|
local uiMap = self.root:genAllChildren()
|
||||||
self.root:addClickListener(function()
|
|
||||||
self:closeUI()
|
|
||||||
end)
|
|
||||||
|
|
||||||
uiMap["buy_vit_ui.bg.close_btn"]:addClickListener(function()
|
uiMap["buy_vit_ui.bg.close_btn"]:addClickListener(function()
|
||||||
self:closeUI()
|
self:closeUI()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- uiMap["buy_vit_ui.bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BUY_VIT_DESC_1))
|
uiMap["buy_vit_ui.bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BUY_ENERGY))
|
||||||
local constCfg = ConfigManager:getConfig("const")
|
local constCfg = ConfigManager:getConfig("const")
|
||||||
local diamondReward = constCfg["stamina_diamond_buy"].reward
|
local diamondReward = constCfg["stamina_diamond_buy"].reward
|
||||||
local adReward = constCfg["stamina_ad_buy"].reward
|
local adReward = constCfg["stamina_ad_buy"].reward
|
||||||
uiMap["buy_vit_ui.bg.cell_1.num_tx"]:setText("x" .. GFunc.getRewardNum(diamondReward))
|
uiMap["buy_vit_ui.bg.cell_1.num_tx_1"]:setText("x" .. GFunc.getRewardNum(diamondReward))
|
||||||
uiMap["buy_vit_ui.bg.cell_2.num_tx"]:setText("x" .. GFunc.getRewardNum(adReward))
|
uiMap["buy_vit_ui.bg.cell_2.num_tx_1"]:setText("x" .. GFunc.getRewardNum(adReward))
|
||||||
|
|
||||||
self.descTx1 = uiMap["buy_vit_ui.bg.cell_1.desc_tx"]
|
self.descTx1 = uiMap["buy_vit_ui.bg.cell_1.desc_tx"]
|
||||||
self.descTx2 = uiMap["buy_vit_ui.bg.cell_2.desc_tx"]
|
self.descTx2 = uiMap["buy_vit_ui.bg.cell_2.desc_tx"]
|
||||||
self.numTx1 = uiMap["buy_vit_ui.bg.cell_1.num_tx_1"]
|
self.numTx1 = uiMap["buy_vit_ui.bg.cell_1.num_tx_2"]
|
||||||
self.numTx2 = uiMap["buy_vit_ui.bg.cell_2.num_tx_1"]
|
self.numTx2 = uiMap["buy_vit_ui.bg.cell_2.num_tx_2"]
|
||||||
self.checkImg1 = uiMap["buy_vit_ui.bg.cell_1.check_img"]
|
self.checkImg1 = uiMap["buy_vit_ui.bg.cell_1.check_img"]
|
||||||
self.checkImg2 = uiMap["buy_vit_ui.bg.cell_2.check_img"]
|
self.checkImg2 = uiMap["buy_vit_ui.bg.cell_2.check_img"]
|
||||||
self.iconImg1 = uiMap["buy_vit_ui.bg.cell_1.icon_img_1"]
|
self.iconImg1 = uiMap["buy_vit_ui.bg.cell_1.icon_img"]
|
||||||
self.iconImg2 = uiMap["buy_vit_ui.bg.cell_2.icon_img_1"]
|
self.iconImg2 = uiMap["buy_vit_ui.bg.cell_2.icon_img"]
|
||||||
|
|
||||||
self.buyBtn1 = uiMap["buy_vit_ui.bg.cell_1"]
|
self.buyBtn1 = uiMap["buy_vit_ui.bg.cell_1"]
|
||||||
self.buyBtn2 = uiMap["buy_vit_ui.bg.cell_2"]
|
self.buyBtn2 = uiMap["buy_vit_ui.bg.cell_2"]
|
||||||
@ -84,9 +80,6 @@ function BuyVitUI:onRefresh()
|
|||||||
self.checkImg2:setVisible(false)
|
self.checkImg2:setVisible(false)
|
||||||
self.iconImg2:setVisible(true)
|
self.iconImg2:setVisible(true)
|
||||||
self.numTx2:setVisible(true)
|
self.numTx2:setVisible(true)
|
||||||
self.iconImg2:setSprite(GConst.ATLAS_PATH.COMMON, "common_ad", function ()
|
|
||||||
self.iconImg2:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_IMAGE):SetNativeSize()
|
|
||||||
end)
|
|
||||||
else
|
else
|
||||||
self.buyBtn2:setTouchEnable(false)
|
self.buyBtn2:setTouchEnable(false)
|
||||||
self.checkImg2:setVisible(true)
|
self.checkImg2:setVisible(true)
|
||||||
@ -94,13 +87,18 @@ function BuyVitUI:onRefresh()
|
|||||||
self.numTx2:setVisible(false)
|
self.numTx2:setVisible(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.descTx1:setText(I18N:getGlobalText(I18N.GlobalConst.BUY_VIT_DESC_2, maxGemBuy - gemBuyCount))
|
self.descTx1:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, maxGemBuy - gemBuyCount))
|
||||||
self.descTx2:setText(I18N:getGlobalText(I18N.GlobalConst.BUY_VIT_DESC_2, maxAdBuy - adBuyCount))
|
self.descTx2:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, maxAdBuy - adBuyCount))
|
||||||
|
|
||||||
local constCfg = ConfigManager:getConfig("const")
|
local constCfg = ConfigManager:getConfig("const")
|
||||||
local diamondCost = constCfg["stamina_diamond_cost"].reward
|
local diamondCost = constCfg["stamina_diamond_cost"].reward
|
||||||
self.numTx1:setText(tostring(GFunc.getRewardNum(diamondCost)))
|
self.numTx1:setText(tostring(GFunc.getRewardNum(diamondCost)))
|
||||||
self.numTx2:setText((maxAdBuy - adBuyCount) .. "/" .. GFunc.getConstIntValue("stamina_ad_times"))
|
self.numTx2:setText((maxAdBuy - adBuyCount) .. "/" .. GFunc.getConstIntValue("stamina_ad_times"))
|
||||||
|
if not self.adjustIconAndNum then
|
||||||
|
self.adjustIconAndNum = true
|
||||||
|
GFunc.centerImgAndTx(self.iconImg1, self.numTx1)
|
||||||
|
GFunc.centerImgAndTx(self.iconImg2, self.numTx2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return BuyVitUI
|
return BuyVitUI
|
||||||
@ -18,6 +18,7 @@ function SelectOtherBtnUI:onLoadRootComplete()
|
|||||||
end)
|
end)
|
||||||
self.uiMap["select_other_btn_ui.bg.mail_btn"]:addClickListener(function()
|
self.uiMap["select_other_btn_ui.bg.mail_btn"]:addClickListener(function()
|
||||||
self:closeUI()
|
self:closeUI()
|
||||||
|
ModuleManager.MailManager:showMailUI()
|
||||||
end)
|
end)
|
||||||
self.uiMap["select_other_btn_ui.bg.mail_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.MAIL_NAME))
|
self.uiMap["select_other_btn_ui.bg.mail_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.MAIL_NAME))
|
||||||
|
|
||||||
|
|||||||
8
lua/app/ui/mail.meta
Normal file
8
lua/app/ui/mail.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7f38a3c4920f0d6498585ad8264181f1
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
lua/app/ui/mail/cell.meta
Normal file
8
lua/app/ui/mail/cell.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9e0046c59ad9bbc43933e1d2dca2d905
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
91
lua/app/ui/mail/cell/mail_cell.lua
Normal file
91
lua/app/ui/mail/cell/mail_cell.lua
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
local MailCell = class("MailCell", BaseCell)
|
||||||
|
|
||||||
|
local TITLE_ICON = {
|
||||||
|
[GConst.MailConst.MAIL_STATE.NOT_READ] = "mail_dec_2",
|
||||||
|
[GConst.MailConst.MAIL_STATE.READED] = "mail_dec_3",
|
||||||
|
[GConst.MailConst.MAIL_STATE.RECEIVED] = "mail_dec_3",
|
||||||
|
}
|
||||||
|
|
||||||
|
local AD_TITLE_ICON = "mail_dec_1"
|
||||||
|
|
||||||
|
function MailCell:refresh(entity)
|
||||||
|
if not entity then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local uiMap = self:getUIMap()
|
||||||
|
local normalNode = uiMap["mail_cell.bg_normal"]
|
||||||
|
local adNode = uiMap["mail_cell.bg_ad"]
|
||||||
|
local readNode = uiMap["mail_cell.bg_read"]
|
||||||
|
if entity:getMailType() == GConst.MailConst.MAIL_TYPE.CUSTOM then
|
||||||
|
normalNode:setVisible(false)
|
||||||
|
adNode:setVisible(false)
|
||||||
|
readNode:setVisible(true)
|
||||||
|
elseif entity:getMailType() == GConst.MailConst.MAIL_TYPE.AD then
|
||||||
|
normalNode:setVisible(false)
|
||||||
|
adNode:setVisible(true)
|
||||||
|
readNode:setVisible(false)
|
||||||
|
elseif entity:getMailType() == GConst.MailConst.MAIL_TYPE.NORMAL then
|
||||||
|
normalNode:setVisible(true)
|
||||||
|
adNode:setVisible(false)
|
||||||
|
readNode:setVisible(false)
|
||||||
|
elseif entity:getMailType() == GConst.MailConst.MAIL_TYPE.READ then
|
||||||
|
normalNode:setVisible(false)
|
||||||
|
adNode:setVisible(false)
|
||||||
|
readNode:setVisible(true)
|
||||||
|
end
|
||||||
|
GFunc.setAdsSprite(uiMap["mail_cell.bg_ad.claim_btn.ad"])
|
||||||
|
uiMap["mail_cell.bg_normal.claim_btn.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_CLAIM))
|
||||||
|
uiMap["mail_cell.bg_read.claim_btn.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_READ))
|
||||||
|
uiMap["mail_cell.bg_normal.claim_btn"]:addClickListener(function()
|
||||||
|
if entity:canClaim() then
|
||||||
|
ModuleManager.MailManager:claimMail({entity:getId()})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
uiMap["mail_cell.bg_ad.claim_btn"]:addClickListener(function()
|
||||||
|
if entity:canClaim() then
|
||||||
|
SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.MAIL, function()
|
||||||
|
ModuleManager.MailManager:claimMail({entity:getId()})
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
uiMap["mail_cell.bg_read.claim_btn"]:addClickListener(function()
|
||||||
|
ModuleManager.MailManager:readMail(entity:getId())
|
||||||
|
end)
|
||||||
|
|
||||||
|
local titleIcon = uiMap["mail_cell.title_icon"]
|
||||||
|
local icon = TITLE_ICON[entity:getState()] or TITLE_ICON[GConst.MailConst.MAIL_STATE.NOT_READ]
|
||||||
|
|
||||||
|
if entity:notRead() and entity:getMailType() == GConst.MailConst.MAIL_TYPE.AD then
|
||||||
|
icon = AD_TITLE_ICON
|
||||||
|
end
|
||||||
|
if self.icon ~= icon then
|
||||||
|
titleIcon:setSprite(GConst.ATLAS_PATH.UI_MAIL, icon)
|
||||||
|
self.icon = icon
|
||||||
|
end
|
||||||
|
uiMap["mail_cell.new"]:setVisible(entity:showNew())
|
||||||
|
uiMap["mail_cell.desc"]:setText(entity:getMailName())
|
||||||
|
uiMap["mail_cell.time"]:setText(entity:getRemainCdStr())
|
||||||
|
local rewardBg = uiMap["mail_cell.reward_bg"]
|
||||||
|
local mask = uiMap["mail_cell.reward_bg.mask"]
|
||||||
|
if not self.rewardCell then
|
||||||
|
self.rewardCell = CellManager:addCellComp(uiMap["mail_cell.reward_cell"], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
||||||
|
end
|
||||||
|
local rewards = entity:getRewards()
|
||||||
|
local showCheck = entity:isReceived()
|
||||||
|
if rewards[2] then
|
||||||
|
rewardBg:setVisible(true)
|
||||||
|
self.rewardCell:getBaseObject():setVisible(false)
|
||||||
|
mask:setVisible(showCheck)
|
||||||
|
else
|
||||||
|
rewardBg:setVisible(false)
|
||||||
|
if entity:haveReward() then
|
||||||
|
self.rewardCell:getBaseObject():setVisible(true, 0.7)
|
||||||
|
self.rewardCell:refreshByConfig(rewards[1], showCheck, showCheck)
|
||||||
|
else
|
||||||
|
self.rewardCell:getBaseObject():setVisible(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return MailCell
|
||||||
10
lua/app/ui/mail/cell/mail_cell.lua.meta
Normal file
10
lua/app/ui/mail/cell/mail_cell.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1f5fcba2f06710a4bbeab76ae83d1b76
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
99
lua/app/ui/mail/mail_detail_ui.lua
Normal file
99
lua/app/ui/mail/mail_detail_ui.lua
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
local MailDetailUI = class("MailDetailUI", BaseUI)
|
||||||
|
|
||||||
|
function MailDetailUI:isFullScreen()
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailDetailUI:getPrefabPath()
|
||||||
|
return "assets/prefabs/ui/mail/mail_detail_ui.prefab"
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailDetailUI:ctor(params)
|
||||||
|
self.entity = DataManager.MailData:getMails()[params.id]
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailDetailUI:onLoadRootComplete()
|
||||||
|
self:_display()
|
||||||
|
self:_addListeners()
|
||||||
|
self:_bind()
|
||||||
|
|
||||||
|
self.sid = self:scheduleGlobal(function()
|
||||||
|
self:updateTime()
|
||||||
|
end, 1)
|
||||||
|
self:updateTime()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailDetailUI:_display()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
uiMap["mail_detail_ui.bg.btn_claimed.btn_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_CLAIM))
|
||||||
|
uiMap["mail_detail_ui.bg.tx_1"]:setText(self.entity:getMailName())
|
||||||
|
uiMap["mail_detail_ui.bg.tx_4"]:setText(I18N:getGlobalText(I18N.GlobalConst.IDLE_TITLE2))
|
||||||
|
uiMap["mail_detail_ui.bg.btn_claimed"]:setActive(not self.entity:isReceived())
|
||||||
|
|
||||||
|
local content = uiMap["mail_detail_ui.bg.tx_3"]
|
||||||
|
content:setText(self.entity:getMailDesc())
|
||||||
|
content:setSizeDeltaY(content:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredHeight)
|
||||||
|
content:setAnchoredPositionY(0)
|
||||||
|
|
||||||
|
|
||||||
|
local haveReward = self.entity:haveReward()
|
||||||
|
uiMap["mail_detail_ui.bg.img_bg"]:setVisible(haveReward)
|
||||||
|
local contentScroll = uiMap["mail_detail_ui.bg.scrollrect"]
|
||||||
|
if haveReward then
|
||||||
|
contentScroll:setSizeDeltaY(180)
|
||||||
|
else
|
||||||
|
contentScroll:setSizeDeltaY(351)
|
||||||
|
end
|
||||||
|
|
||||||
|
self:refreshScrollRect()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailDetailUI:_addListeners()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
uiMap["mail_detail_ui.bg.btn_claimed"]:addClickListener(function()
|
||||||
|
ModuleManager.MailManager:claimMail({self.entity:getId()})
|
||||||
|
end)
|
||||||
|
|
||||||
|
uiMap["mail_detail_ui.bg.btn_close"]:addClickListener(function()
|
||||||
|
self:closeUI()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailDetailUI:_bind()
|
||||||
|
self:bind(DataManager.MailData, "isDirty", function()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
uiMap["mail_detail_ui.bg.btn_claimed"]:setActive(not self.entity:isReceived())
|
||||||
|
self:refreshScrollRect()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailDetailUI:refreshScrollRect()
|
||||||
|
if not self.entity then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.scrollRect then
|
||||||
|
self.scrollRect:updateAllCell()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
local scrollView = uiMap["mail_detail_ui.bg.img_bg.scrollrect"]
|
||||||
|
self.scrollRect = scrollView:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||||
|
self.scrollRect:addInitCallback(function()
|
||||||
|
return GConst.TYPEOF_LUA_CLASS.REWARD_CELL
|
||||||
|
end)
|
||||||
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||||
|
cell:refreshByConfig(self.entity:getRewards()[index], self.entity:isReceived(), self.entity:isReceived())
|
||||||
|
end)
|
||||||
|
self.scrollRect:clearCells()
|
||||||
|
self.scrollRect:refillCells(#self.entity:getRewards())
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailDetailUI:updateTime()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
uiMap["mail_detail_ui.bg.tx_2"]:setText(self.entity:getRemainCdStr())
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return MailDetailUI
|
||||||
10
lua/app/ui/mail/mail_detail_ui.lua.meta
Normal file
10
lua/app/ui/mail/mail_detail_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 88fc0b06ecebcf54f9713464dee3bde3
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
129
lua/app/ui/mail/mail_ui.lua
Normal file
129
lua/app/ui/mail/mail_ui.lua
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
local MailUI = class("MailUI", BaseUI)
|
||||||
|
|
||||||
|
local MAIL_CELL = "app/ui/mail/cell/mail_cell"
|
||||||
|
|
||||||
|
function MailUI:isFullScreen()
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:getPrefabPath()
|
||||||
|
return "assets/prefabs/ui/mail/mail_ui.prefab"
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:ctor()
|
||||||
|
self.mailList = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:onClose()
|
||||||
|
DataManager.MailData:setLastMailId()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:dealData()
|
||||||
|
local list = {}
|
||||||
|
local count = 0
|
||||||
|
for id, entity in pairs(DataManager.MailData:getMails()) do
|
||||||
|
if not entity:isOver() then
|
||||||
|
table.insert(list, entity)
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(list, function(a, b)
|
||||||
|
local aCan = a:canDelete()
|
||||||
|
local bCan = b:canDelete()
|
||||||
|
if aCan == bCan then
|
||||||
|
local aCd = a:getRemainCd()
|
||||||
|
local bCd = b:getRemainCd()
|
||||||
|
if aCd == bCd then
|
||||||
|
return a:getId() > b:getId()
|
||||||
|
else
|
||||||
|
return aCd < bCd
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return not aCan
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
if count ~= #self.mailList then
|
||||||
|
self.needRefills = true
|
||||||
|
end
|
||||||
|
self.mailList = list
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:onLoadRootComplete()
|
||||||
|
self:_display()
|
||||||
|
self:_addListeners()
|
||||||
|
|
||||||
|
self.sid = self:scheduleGlobal(function()
|
||||||
|
self:updateTime()
|
||||||
|
end, 1)
|
||||||
|
self:updateTime()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:_display()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
self.root:addClickListener(function()
|
||||||
|
self:closeUI()
|
||||||
|
end)
|
||||||
|
uiMap["mail_ui.bg.title_bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.MAIL_TITLE))
|
||||||
|
uiMap["mail_ui.bg.btn_delect.btn_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_DELETE_ALL))
|
||||||
|
uiMap["mail_ui.bg.btn_claimed.btn_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_CLAIM_ALL))
|
||||||
|
|
||||||
|
local uiSpine1 = uiMap["mail_ui.ui_spine_1"]
|
||||||
|
local uiSpine2 = uiMap["mail_ui.ui_spine_2"]
|
||||||
|
uiSpine1:playAnimComplete("born", false, false, function ()
|
||||||
|
uiSpine1:playAnim("idle", true, false)
|
||||||
|
end)
|
||||||
|
uiSpine2:clearTrack()
|
||||||
|
uiSpine2:playAnimComplete("born", false, true, function ()
|
||||||
|
uiSpine2:playAnim("idle", true, false)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:_addListeners()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
uiMap["mail_ui.bg.btn_close"]:addClickListener(function()
|
||||||
|
self:closeUI()
|
||||||
|
end)
|
||||||
|
|
||||||
|
uiMap["mail_ui.bg.btn_delect"]:addClickListener(function()
|
||||||
|
ModuleManager.MailManager:deleteMail()
|
||||||
|
end)
|
||||||
|
|
||||||
|
uiMap["mail_ui.bg.btn_claimed"]:addClickListener(function()
|
||||||
|
ModuleManager.MailManager:claimMail()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:refreshScrollRect()
|
||||||
|
if self.scrollRect then
|
||||||
|
if self.needRefills then
|
||||||
|
self.scrollRect:clearCells()
|
||||||
|
self.scrollRect:refillCells(#self.mailList)
|
||||||
|
else
|
||||||
|
self.scrollRect:updateAllCell()
|
||||||
|
end
|
||||||
|
self.needRefills = false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
local scrollView = uiMap["mail_ui.bg.img_2.scrollrect"]
|
||||||
|
self.scrollRect = scrollView:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE)
|
||||||
|
self.scrollRect:addInitCallback(function()
|
||||||
|
return MAIL_CELL
|
||||||
|
end)
|
||||||
|
self.scrollRect:addRefreshCallback(function(index, cell)
|
||||||
|
cell:refresh(self.mailList[index])
|
||||||
|
end)
|
||||||
|
self.scrollRect:clearCells()
|
||||||
|
self.scrollRect:refillCells(#self.mailList)
|
||||||
|
self.needRefills = false
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailUI:updateTime()
|
||||||
|
self:dealData()
|
||||||
|
self:refreshScrollRect()
|
||||||
|
end
|
||||||
|
|
||||||
|
return MailUI
|
||||||
10
lua/app/ui/mail/mail_ui.lua.meta
Normal file
10
lua/app/ui/mail/mail_ui.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9f6ce58542eaf3046bc7f329075ae62e
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
8
lua/app/userdata/mail.meta
Normal file
8
lua/app/userdata/mail.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b2f9edf752615204da2c3f31531c458e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
203
lua/app/userdata/mail/mail_data.lua
Normal file
203
lua/app/userdata/mail/mail_data.lua
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
local MailData = class("MailData", BaseData)
|
||||||
|
|
||||||
|
local MailEntity = "app/userdata/mail/mail_entity"
|
||||||
|
|
||||||
|
local TIME_TYPE = {
|
||||||
|
DAY = 1,
|
||||||
|
WEEK = 2,
|
||||||
|
MONTH = 3,
|
||||||
|
}
|
||||||
|
function MailData:ctor()
|
||||||
|
self.mails = {}
|
||||||
|
self.needGetNewMail = false
|
||||||
|
self.data.isDirty = false
|
||||||
|
self.data.redPoint = false
|
||||||
|
self.maxMailId = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:clear()
|
||||||
|
self.mails = {}
|
||||||
|
self.data.redPoint = false
|
||||||
|
self.lastMailId = nil
|
||||||
|
self.mailIsOpen = false
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:init(data)
|
||||||
|
data = data or GConst.EMPTY_TABLE
|
||||||
|
self.mails = {}
|
||||||
|
self.needGetNewMail = false
|
||||||
|
self:addMails(data.mails)
|
||||||
|
|
||||||
|
self:updateRedPointCd()
|
||||||
|
DataManager:registerDataCd("MailData")
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:updateRedPointCd()
|
||||||
|
self.needUpdateRedPointInfo = {}
|
||||||
|
local cfg = ConfigManager:getConfig("mail")
|
||||||
|
for i,v in ipairs(cfg) do
|
||||||
|
if v.time_type == TIME_TYPE.DAY then
|
||||||
|
for ii = 1, 7 do
|
||||||
|
self.needUpdateRedPointInfo[ii] = self.needUpdateRedPointInfo[ii] or {}
|
||||||
|
if #v.time_send == 3 then
|
||||||
|
local time = v.time_send[1] * 3600 + v.time_send[2] * 60 + v.time_send[3]
|
||||||
|
if not table.containValue(self.needUpdateRedPointInfo[ii], time) then
|
||||||
|
table.insert(self.needUpdateRedPointInfo[ii], time)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif v.time_type == TIME_TYPE.WEEK then
|
||||||
|
if #v.time_send == 4 then
|
||||||
|
local day = v.time_send[1]
|
||||||
|
self.needUpdateRedPointInfo[day] = self.needUpdateRedPointInfo[day] or {}
|
||||||
|
local time = v.time_send[2] * 3600 + v.time_send[3] * 60 + v.time_send[4]
|
||||||
|
if not table.containValue(self.needUpdateRedPointInfo[day], time) then
|
||||||
|
table.insert(self.needUpdateRedPointInfo[day], time)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif v.time_type == TIME_TYPE.MONTH then
|
||||||
|
--TODO 暂时没有 无数据格式
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:updateCd()
|
||||||
|
local nowTime = Time:getServerTime()
|
||||||
|
local today = Time:getDayofWeek()
|
||||||
|
local times = self.needUpdateRedPointInfo[today] or {}
|
||||||
|
local curTime = nowTime % 86400
|
||||||
|
for i, v in ipairs(times) do
|
||||||
|
if v == curTime then
|
||||||
|
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:addMails(mails)
|
||||||
|
if not mails then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, info in pairs(mails) do
|
||||||
|
local entity = require(MailEntity):create(info)
|
||||||
|
self.mails[info.id] = entity
|
||||||
|
if self.maxMailId < info.id then
|
||||||
|
self.maxMailId = info.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self:setDirty()
|
||||||
|
self:refreshRedPoint()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:getMails()
|
||||||
|
return self.mails
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:setDirty()
|
||||||
|
self.data.isDirty = not self.data.isDirty
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:setMailReceived(id)
|
||||||
|
if not self.mails[id] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.mails[id]:receivedThis()
|
||||||
|
|
||||||
|
self:setDirty()
|
||||||
|
self:refreshRedPoint()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:setMailRead(id)
|
||||||
|
if not self.mails[id] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.mails[id]:readThis()
|
||||||
|
|
||||||
|
self:refreshRedPoint()
|
||||||
|
self:setDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:deleteMail(ids)
|
||||||
|
if not ids then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, id in ipairs(ids) do
|
||||||
|
self.mails[id] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
self:setDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:refreshRedPoint()
|
||||||
|
if self.needGetNewMail then
|
||||||
|
self.data.redPoint = true
|
||||||
|
self.isAdRedPoint = false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local reset = true
|
||||||
|
local haveNoAdRp = false
|
||||||
|
for id, entity in pairs(self.mails) do
|
||||||
|
if entity:canClaim() then
|
||||||
|
self.data.redPoint = true
|
||||||
|
if entity:getIsAdMail() then
|
||||||
|
if not haveNoAdRp then
|
||||||
|
self.isAdRedPoint = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
haveNoAdRp = true
|
||||||
|
self.isAdRedPoint = false
|
||||||
|
end
|
||||||
|
reset = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if reset then
|
||||||
|
self.data.redPoint = false
|
||||||
|
self.isAdRedPoint = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:getRedPoint()
|
||||||
|
return self.data.redPoint, self.isAdRedPoint
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:setNeedGetNewMail(need)
|
||||||
|
self.needGetNewMail = need == true
|
||||||
|
if self.needGetNewMail then
|
||||||
|
self:refreshRedPoint()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:getNeedGetNewMail()
|
||||||
|
return self.needGetNewMail
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:getLastMailId()
|
||||||
|
if not self.lastMailId then
|
||||||
|
self.lastMailId = LocalData:getLastMailId()
|
||||||
|
end
|
||||||
|
return self.lastMailId
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:setLastMailId()
|
||||||
|
if not self.maxMailId or not self.lastMailId then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.lastMailId < self.maxMailId then
|
||||||
|
self.lastMailId = self.maxMailId
|
||||||
|
LocalData:setLastMailId(self.lastMailId)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailData:getIsOpen()
|
||||||
|
if not self.mailIsOpen then
|
||||||
|
self.mailIsOpen = ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.MAIL_OPEN, true)
|
||||||
|
end
|
||||||
|
return self.mailIsOpen
|
||||||
|
end
|
||||||
|
|
||||||
|
return MailData
|
||||||
10
lua/app/userdata/mail/mail_data.lua.meta
Normal file
10
lua/app/userdata/mail/mail_data.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a1288415a188ea64f807d5e0e28bc56f
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
169
lua/app/userdata/mail/mail_entity.lua
Normal file
169
lua/app/userdata/mail/mail_entity.lua
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
local MailEntity = class("MailEntity", BaseData)
|
||||||
|
|
||||||
|
function MailEntity:ctor(info)
|
||||||
|
info = info or GConst.EMPTY_TABLE
|
||||||
|
self.id = info.id or 0
|
||||||
|
self.createTime = GFunc.formatTimeStep(info.create_at)
|
||||||
|
self.mailExpire = GFunc.formatTimeStep(info.expire + info.create_at)
|
||||||
|
self.state = info.state or GConst.MailConst.MAIL_TYPE.NOT_READ
|
||||||
|
self.mailType = GConst.MailConst.MAIL_TYPE.CUSTOM
|
||||||
|
self.mailCfgId = nil -- 可能为空
|
||||||
|
self.title = json.decode(info.title or "{}")
|
||||||
|
self.body = json.decode(info.body or "{}")
|
||||||
|
self.rewards = info.rewards or {}
|
||||||
|
self.data.isDirty = false
|
||||||
|
|
||||||
|
if self.title.key then
|
||||||
|
local cfg = ConfigManager:getConfig("mail")[self.title.key]
|
||||||
|
if cfg then
|
||||||
|
self.mailCfgId = self.title.key
|
||||||
|
self.mailType = cfg.type
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:setDirty()
|
||||||
|
self.data.isDirty = not self.data.isDirty
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getId()
|
||||||
|
return self.id
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:notRead()
|
||||||
|
return self.state == GConst.MailConst.MAIL_STATE.NOT_READ
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:isRead()
|
||||||
|
return self.state == GConst.MailConst.MAIL_STATE.READED
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:readThis()
|
||||||
|
if self:isReceived() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self.state = GConst.MailConst.MAIL_STATE.READED
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:isReceived()
|
||||||
|
return self.state == GConst.MailConst.MAIL_STATE.RECEIVED
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:receivedThis()
|
||||||
|
self.state = GConst.MailConst.MAIL_STATE.RECEIVED
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getState()
|
||||||
|
return self.state
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getMailName()
|
||||||
|
if self.mailCfgId then
|
||||||
|
return I18N:getConfig("mail")[self.mailCfgId].name
|
||||||
|
else
|
||||||
|
local language = I18N:getCurLanguage()
|
||||||
|
if self.title.content then
|
||||||
|
return self.title.content[language] or GConst.EMPTY_STRING
|
||||||
|
elseif self.title.raw then
|
||||||
|
return self.title.raw
|
||||||
|
else
|
||||||
|
return GConst.EMPTY_STRING
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getMailDesc()
|
||||||
|
if self.mailCfgId then
|
||||||
|
return I18N:getConfig("mail")[self.mailCfgId].desc
|
||||||
|
else
|
||||||
|
local language = I18N:getCurLanguage()
|
||||||
|
if self.body.content then
|
||||||
|
return self.body.content[language] or GConst.EMPTY_STRING
|
||||||
|
elseif self.body.raw then
|
||||||
|
return self.body.raw
|
||||||
|
else
|
||||||
|
return GConst.EMPTY_STRING
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getMailExpire()
|
||||||
|
return self.mailExpire
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getRemainCd()
|
||||||
|
if not self.mailExpire then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local remainCd = self.mailExpire - Time:getServerTime()
|
||||||
|
if remainCd < 0 then
|
||||||
|
remainCd = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
return remainCd
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getRemainCdStr()
|
||||||
|
local hour = self:getRemainCd() // 3600
|
||||||
|
if hour <= 0 then
|
||||||
|
hour = 1
|
||||||
|
end
|
||||||
|
return I18N:getGlobalText(I18N.GlobalConst.MAIL_COUNTDOWN, hour)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getRewards()
|
||||||
|
return self.rewards
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:haveReward()
|
||||||
|
return self:getRewards()[1] ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getMailType()
|
||||||
|
return self.mailType
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getIsAdMail()
|
||||||
|
return self.mailType == GConst.MailConst.MAIL_TYPE.AD
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:getIsNormalMail()
|
||||||
|
return self.mailType == GConst.MailConst.MAIL_TYPE.NORMAL
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:canClaim()
|
||||||
|
if self:isOver() then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if not self:getRewards()[1] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return not self:isReceived()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:isOver()
|
||||||
|
return self:getRemainCd() <= 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:canDelete()
|
||||||
|
if self:isReceived() then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if not self:haveReward() and self:isRead() then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
function MailEntity:showNew()
|
||||||
|
if not self:notRead() then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return self:getId() > DataManager.MailData:getLastMailId()
|
||||||
|
end
|
||||||
|
|
||||||
|
return MailEntity
|
||||||
10
lua/app/userdata/mail/mail_entity.lua.meta
Normal file
10
lua/app/userdata/mail/mail_entity.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2726071e33132774391e1f44fe68b154
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -7,7 +7,7 @@ function PlayerData:init(data)
|
|||||||
self.data.dirty = false
|
self.data.dirty = false
|
||||||
self.data.payAmount = basicInfo.pay_amount or 0
|
self.data.payAmount = basicInfo.pay_amount or 0
|
||||||
|
|
||||||
local energyLimit = data.energyLimit or GConst.EMPTY_TABLE
|
local energyLimit = data.energy_limit or GConst.EMPTY_TABLE
|
||||||
self.data.vitGemCount = energyLimit.diamond_count or 0
|
self.data.vitGemCount = energyLimit.diamond_count or 0
|
||||||
self.data.vitADCount = energyLimit.ad_count or 0
|
self.data.vitADCount = energyLimit.ad_count or 0
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user