Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
local DatingCharItemCtrl = class("DatingCharItemCtrl", BaseCtrl)
|
||||
DatingCharItemCtrl._mapNodeConfig = {
|
||||
imgBg = {},
|
||||
imgSelectBg = {},
|
||||
imgHeadIcon = {sComponentName = "Image"},
|
||||
txtCharName = {sComponentName = "TMP_Text", nCount = 2},
|
||||
redDotDatingItem = {},
|
||||
imgDating = {}
|
||||
}
|
||||
DatingCharItemCtrl._mapEventConfig = {}
|
||||
function DatingCharItemCtrl:SetSelect(bSelect)
|
||||
self._mapNode.imgBg.gameObject:SetActive(not bSelect)
|
||||
self._mapNode.imgSelectBg.gameObject:SetActive(bSelect)
|
||||
end
|
||||
function DatingCharItemCtrl:SetDatingCharItem(nCharId)
|
||||
self.nCharId = nCharId
|
||||
local mapCharacter = ConfigTable.GetData_Character(nCharId)
|
||||
if mapCharacter ~= nil then
|
||||
local nSkinId = mapCharacter.DefaultSkinId
|
||||
local mapSkin = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
if mapSkin ~= nil then
|
||||
self:SetPngSprite(self._mapNode.imgHeadIcon, mapSkin.Icon .. AllEnum.CharHeadIconSurfix.S)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharName[1], mapCharacter.Name)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharName[2], mapCharacter.Name)
|
||||
end
|
||||
self:SetSelect(false)
|
||||
self:RegisterRedDot()
|
||||
local bDating = PlayerData.Dating:CheckDating(self.nCharId)
|
||||
self._mapNode.imgDating.gameObject:SetActive(bDating)
|
||||
end
|
||||
function DatingCharItemCtrl:RegisterRedDot()
|
||||
RedDotManager.RegisterNode(RedDotDefine.Phone_Dating_Char, self.nCharId, self._mapNode.redDotDatingItem)
|
||||
end
|
||||
function DatingCharItemCtrl:Awake()
|
||||
end
|
||||
function DatingCharItemCtrl:OnEnable()
|
||||
end
|
||||
function DatingCharItemCtrl:OnDisable()
|
||||
end
|
||||
function DatingCharItemCtrl:OnDestroy()
|
||||
end
|
||||
return DatingCharItemCtrl
|
||||
@@ -0,0 +1,646 @@
|
||||
local DatingCtrl = class("DatingCtrl", BaseCtrl)
|
||||
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
|
||||
local ResTypeAny = GameResourceLoader.ResType.Any
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local Path = require("path")
|
||||
local typeof = typeof
|
||||
local Offset = CS.Actor2DOffsetData
|
||||
local LocalSettingData = require("GameCore.Data.LocalSettingData")
|
||||
local TimerManager = require("GameCore.Timer.TimerManager")
|
||||
local BubbleVoiceManager = require("Game.Actor2D.BubbleVoiceManager")
|
||||
DatingCtrl._mapNodeConfig = {
|
||||
animRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
imgBgRT = {
|
||||
sNodeName = "----Actor2D----",
|
||||
sComponentName = "RawImage"
|
||||
},
|
||||
rtImgBgRT = {
|
||||
sNodeName = "----Actor2D----",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtOffScreenRoot = {
|
||||
sNodeName = "----Actor2D_Node----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
trCamera = {
|
||||
sNodeName = "OffScreen3DCamera",
|
||||
sComponentName = "Camera"
|
||||
},
|
||||
bgLandmark = {
|
||||
sComponentName = "SpriteRenderer"
|
||||
},
|
||||
trCharacter = {sNodeName = "animator", sComponentName = "Transform"},
|
||||
trPanelOffsetL2D = {
|
||||
sNodeName = "panel_offset",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
trActorOffsetL2d = {
|
||||
sNodeName = "actor_offset",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
trL2D = {sNodeName = "L2D", sComponentName = "Transform"},
|
||||
trPng = {sNodeName = "PNG", sComponentName = "Transform"},
|
||||
spr_body = {
|
||||
sNodeName = "sp_body",
|
||||
sComponentName = "SpriteRenderer"
|
||||
},
|
||||
spr_face = {
|
||||
sNodeName = "sp_face",
|
||||
sComponentName = "SpriteRenderer"
|
||||
},
|
||||
trEmojiRoot = {
|
||||
sNodeName = "----emoji----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
cvEmojiRoot = {
|
||||
sNodeName = "----emoji----",
|
||||
sComponentName = "Canvas"
|
||||
},
|
||||
trEmoji = {sNodeName = "emoji_root", sComponentName = "Transform"},
|
||||
txtLandmark = {sComponentName = "TMP_Text"},
|
||||
imgTimeBg1 = {},
|
||||
goEvent = {
|
||||
sCtrlName = "Game.UI.Phone.Dating.DatingEventCtrl"
|
||||
},
|
||||
goSendGift = {
|
||||
sCtrlName = "Game.UI.Phone.Dating.DatingGiftCtrl"
|
||||
},
|
||||
goBubble = {},
|
||||
animBubble = {sNodeName = "goBubble", sComponentName = "Animator"},
|
||||
txtBubble = {sComponentName = "TMP_Text"},
|
||||
imgAffinityBg = {},
|
||||
txtAffinityCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Phone_Gift_Affinity"
|
||||
},
|
||||
txtAffinityValue = {sComponentName = "TMP_Text"},
|
||||
imgMsgDetail = {
|
||||
sNodeName = "imgMsgDetail",
|
||||
sComponentName = "Image"
|
||||
},
|
||||
txtNotice = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Book_Close_Tip"
|
||||
},
|
||||
aniMsgDetail = {
|
||||
sNodeName = "rtImgMsgDetail",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
btnSnapShot = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_HideImgMsg"
|
||||
}
|
||||
}
|
||||
DatingCtrl._mapEventConfig = {
|
||||
DatingEventAction = "OnEvent_DatingEventAction",
|
||||
DatingSendGift = "OnEvent_DatingSendGift",
|
||||
DatingEventFinish = "OnEvent_DatingEventFinish",
|
||||
DatingSendGiftFinish = "OnEvent_DatingSendGiftFinish",
|
||||
CloseDatingPanel = "OnEvent_CloseDatingPanel",
|
||||
[EventId.AvgVoiceDuration] = "OnEvent_AvgVoiceDuration",
|
||||
DatingOptionSelected = "OnEvent_DatingOptionSelected",
|
||||
DatingShowImgMsg = "OnBtnClick_DatingShowImgMsg"
|
||||
}
|
||||
local type_event = 1
|
||||
local type_gift = 2
|
||||
function DatingCtrl:CreateRT()
|
||||
end
|
||||
function DatingCtrl:ReleaseRT()
|
||||
end
|
||||
function DatingCtrl:GetOffsetData(sOffset)
|
||||
local objOffset = self:LoadAsset(sOffset, typeof(Offset))
|
||||
local nPanelId = self:GetOffsetPanelId()
|
||||
if nil == objOffset then
|
||||
printError(string.format("约会流程界面 加载偏移数据失败!!!panelId = %s, 加载路径[%s]", nPanelId, sOffset))
|
||||
return Vector3.zero, Vector3.one
|
||||
end
|
||||
local nX, nY = 0, 0
|
||||
local s, x, y = objOffset:GetOffsetData(nPanelId, indexOfPose("a"), true, nX, nY)
|
||||
local vPos = Vector3(x, y, 0)
|
||||
local vScale = Vector3(s, s, 1)
|
||||
return vPos, vScale
|
||||
end
|
||||
function DatingCtrl:GetOffsetPanelId()
|
||||
local nShowPanelId = self:GetPanelId()
|
||||
local tbConfig = Actor2DManager.GetMapPanelConfig(nShowPanelId)
|
||||
if nil ~= tbConfig and tbConfig.nReuse > 0 then
|
||||
nShowPanelId = tbConfig.nReuse
|
||||
end
|
||||
return nShowPanelId
|
||||
end
|
||||
function DatingCtrl:CheckUseL2D()
|
||||
local bL2D = false
|
||||
local tbConfig = Actor2DManager.GetMapPanelConfig(self:GetPanelId())
|
||||
if nil ~= tbConfig then
|
||||
bL2D = tbConfig.bL2D and LocalSettingData.mapData.UseLive2D
|
||||
end
|
||||
return bL2D
|
||||
end
|
||||
function DatingCtrl:GetName(sPortrait, sFace)
|
||||
local sFileFullName = Path.basename(sPortrait)
|
||||
local sFileExtName = Path.extension(sPortrait)
|
||||
local sFileName = string.gsub(sFileFullName, sFileExtName, "")
|
||||
sFileName = string.gsub(sFileName, "_a", "")
|
||||
local sBodyName = string.format("%s_%s", sFileName, "001")
|
||||
local sFaceName = string.format("%s_%s", sFileName, sFace)
|
||||
return sBodyName, sFaceName
|
||||
end
|
||||
function DatingCtrl:SetCharacterPng(nSkinId)
|
||||
local bSetSuccess, nT, nAnimLength, tbRenderer = Actor2DManager.SetActor2DWithRender(self._panel._nPanelId, self._mapNode.imgBgRT, self._panel.nCharId, nSkinId, nil, self._mapNode.rtOffScreenRoot)
|
||||
end
|
||||
function DatingCtrl:SetCharacterL2D(nSkinId)
|
||||
if nil ~= self.goL2D then
|
||||
if self.goL2D.nSkinId == nSkinId then
|
||||
return
|
||||
end
|
||||
self.goL2D.tbRenderer.trL2DIns.gameObject:SetActive(false)
|
||||
end
|
||||
local skinCfgData = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
local bSetSuccess, nT, nAnimLength, tbRenderer = Actor2DManager.SetActor2DWithRender(self._panel._nPanelId, self._mapNode.imgBgRT, self._panel.nCharId, nSkinId, nil, self._mapNode.rtOffScreenRoot)
|
||||
if bSetSuccess then
|
||||
self.goL2D = {}
|
||||
self.goL2D.nSkinId = nSkinId
|
||||
self.goL2D.tbRenderer = tbRenderer
|
||||
end
|
||||
NovaAPI.SetSpriteRendererSprite(self._mapNode.bgRight, self:LoadAsset(skinCfgData.Bg .. ".png", typeof(Sprite)))
|
||||
end
|
||||
function DatingCtrl:SetCharacter()
|
||||
local mapChar = ConfigTable.GetData_Character(self._panel.nCharId)
|
||||
if mapChar == nil then
|
||||
return
|
||||
end
|
||||
local nSkinId = mapChar.DefaultSkinId
|
||||
local bL2D = self:CheckUseL2D()
|
||||
local nType = AllEnum.Actor2DType.Normal
|
||||
if bL2D then
|
||||
self:SetCharacterL2D(nSkinId, nType)
|
||||
else
|
||||
self:SetCharacterPng(nSkinId, nType)
|
||||
end
|
||||
self._mapNode.trL2D.gameObject:SetActive(bL2D)
|
||||
self._mapNode.trPng.gameObject:SetActive(not bL2D)
|
||||
local skinCfgData = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
local vPos, vScale = self:GetOffsetData(skinCfgData.Offset)
|
||||
self._mapNode.trActorOffsetL2d.localPosition = vPos
|
||||
self._mapNode.trActorOffsetL2d.localScale = vScale
|
||||
local nShowPanelId = self:GetPanelId()
|
||||
local tbPanelOffsetData = Actor2DManager.GetMapPanelConfig(nShowPanelId)
|
||||
local x, y, s = 0, 0, 1
|
||||
if tbPanelOffsetData ~= nil then
|
||||
if 0 < tbPanelOffsetData.nReuse then
|
||||
x = tbPanelOffsetData.v3PanelOffset.x
|
||||
y = tbPanelOffsetData.v3PanelOffset.y
|
||||
s = tbPanelOffsetData.v3PanelOffset.z
|
||||
end
|
||||
if s <= 0 then
|
||||
s = 1
|
||||
end
|
||||
end
|
||||
self._mapNode.trPanelOffsetL2D.localPosition = Vector3(x, y, 0)
|
||||
self._mapNode.trPanelOffsetL2D.localScale = Vector3(s, s, 1)
|
||||
end
|
||||
function DatingCtrl:SetLandmarkBg()
|
||||
local mapCfg = ConfigTable.GetData("DatingLandmark", self._panel.nLandmark)
|
||||
if mapCfg ~= nil then
|
||||
local sPath = string.format("ImageAvg/AvgBg/%s.png", mapCfg.Bg)
|
||||
NovaAPI.SetSpriteRendererSprite(self._mapNode.bgLandmark, self:LoadAsset(sPath, typeof(Sprite)))
|
||||
end
|
||||
end
|
||||
local mapCharEmoji = {}
|
||||
local tbCharEmoji = {}
|
||||
local nLayerIndex = 0
|
||||
local timerEmoji
|
||||
local LoadPresetEmoji = function()
|
||||
local sPath = "Game.UI.Avg.AvgPreset"
|
||||
local AvgPreset = require(sPath)
|
||||
for _, v in ipairs(AvgPreset.CharEmoji) do
|
||||
local sEmojiName = v[3]
|
||||
local sEmojiSound = v[4] or ""
|
||||
local bIsLoop = v[5] or false
|
||||
mapCharEmoji[sEmojiName] = sEmojiSound
|
||||
table.insert(tbCharEmoji, sEmojiName)
|
||||
end
|
||||
package.loaded[sPath] = nil
|
||||
AvgPreset = nil
|
||||
nLayerIndex = CS.UnityEngine.LayerMask.NameToLayer("Cam_Layer_4")
|
||||
end
|
||||
function DatingCtrl:SetEmoji(sEmoji)
|
||||
local mapCharCfg = ConfigTable.GetData_Character(self._panel.nCharId)
|
||||
if mapCharCfg == nil then
|
||||
return
|
||||
end
|
||||
local nSkinId = mapCharCfg.DefaultSkinId
|
||||
local sFullPath = string.format("Actor2D/Character/%s/%s.asset", nSkinId, nSkinId)
|
||||
local objOffset = self:LoadAsset(sFullPath, typeof(Offset))
|
||||
if objOffset == nil then
|
||||
return
|
||||
end
|
||||
local sPose = "a"
|
||||
local nX, nY = 0, 0
|
||||
local s, x, y = objOffset:GetEmojiData(self:GetOffsetPanelId(), indexOfPose(sPose), table.indexof(tbCharEmoji, sEmoji), nX, nY)
|
||||
local v3OffsetPos = Vector3(x, y, 0)
|
||||
local v3OffsetScale = Vector3(s, math.abs(s), 1)
|
||||
if timerEmoji ~= nil then
|
||||
timerEmoji:Cancel(true)
|
||||
end
|
||||
local sEmojiFullPath = string.format("UI/Avg/AnimEmoji/%s.prefab", sEmoji)
|
||||
local goEmojiIns = self:CreatePrefabInstance(sEmojiFullPath, self._mapNode.trEmoji)
|
||||
goEmojiIns.transform:SetLayerRecursively(nLayerIndex)
|
||||
local animator = goEmojiIns:GetComponent("Animator")
|
||||
if animator ~= nil then
|
||||
animator:SetTrigger("tIn")
|
||||
end
|
||||
self._mapNode.trEmoji.anchoredPosition3D = v3OffsetPos
|
||||
self._mapNode.trEmoji.localScale = v3OffsetScale
|
||||
local sEmojiSoundName = mapCharEmoji[sEmoji]
|
||||
if sEmojiSoundName ~= nil then
|
||||
CS.WwiseAudioManager.Instance:PlaySound(sEmojiSoundName)
|
||||
end
|
||||
timerEmoji = TimerManager.Add(1, 3, Actor2DManager, function()
|
||||
destroy(goEmojiIns)
|
||||
timerEmoji = nil
|
||||
end, true, true, true, nil)
|
||||
end
|
||||
function DatingCtrl:SetBubble(sContent, nDuration)
|
||||
if sContent == nil or sContent == "" then
|
||||
return
|
||||
end
|
||||
self._mapNode.goBubble.gameObject:SetActive(true)
|
||||
self._mapNode.animBubble:SetTrigger("tIn")
|
||||
sContent = string.gsub(sContent, "==RT==", "\n")
|
||||
sContent = string.gsub(sContent, "==PLAYER_NAME==", PlayerData.Base:GetPlayerNickName())
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBubble, sContent)
|
||||
nDuration = nDuration == nil and 2 or nDuration
|
||||
self:AddTimer(1, nDuration, function()
|
||||
self._mapNode.animBubble:SetTrigger("tOut")
|
||||
end, true, true, true, nil)
|
||||
end
|
||||
function DatingCtrl:LoadEventConfig(tbEventId)
|
||||
local tbTempEvent = {}
|
||||
for _, v in ipairs(tbEventId) do
|
||||
local mapEventCfg
|
||||
if v.nType == GameEnum.DatingEventType.BranchA or v.nType == GameEnum.DatingEventType.BranchB then
|
||||
mapEventCfg = ConfigTable.GetData("DatingBranch", v.nId)
|
||||
if nil ~= mapEventCfg then
|
||||
local tbOptions = {}
|
||||
for k, nOptId in pairs(self.tbBranchOptionIds) do
|
||||
if mapEventCfg["Option" .. nOptId] ~= "" then
|
||||
table.insert(tbOptions, {
|
||||
nOptId = nOptId,
|
||||
sOpt = mapEventCfg["Option" .. nOptId]
|
||||
})
|
||||
end
|
||||
end
|
||||
local data = {nId = v, tbOptions = tbOptions}
|
||||
table.insert(self.tbAllEvent, data)
|
||||
table.insert(tbTempEvent, data)
|
||||
end
|
||||
elseif v.nType == GameEnum.DatingEventType.BeforeBranch or v.nType == GameEnum.DatingEventType.AfterBranch or v.nType == GameEnum.DatingEventType.Landmark then
|
||||
mapEventCfg = ConfigTable.GetData("DatingLandmarkEvent", v.nId)
|
||||
elseif v.nType == GameEnum.DatingEventType.LimitedLandmark or v.nType == GameEnum.DatingEventType.Regular then
|
||||
mapEventCfg = ConfigTable.GetData("DatingCharacterEvent", v.nId)
|
||||
elseif v.nType == GameEnum.DatingEventType.Start or v.nType == GameEnum.DatingEventType.End then
|
||||
mapEventCfg = ConfigTable.GetData("DatingStartEndEvent", v.nId)
|
||||
end
|
||||
if mapEventCfg ~= nil and v.nType ~= GameEnum.DatingEventType.BranchA and v.nType ~= GameEnum.DatingEventType.BranchB then
|
||||
local nEventAffinity = ConfigTable.GetConfigNumber("Dating_Event_Base_Affinity") + mapEventCfg.Affinity
|
||||
local bSpecial = false
|
||||
local sCG = ""
|
||||
if mapEventCfg.DatingEventType == GameEnum.DatingEventType.LimitedLandmark then
|
||||
if mapEventCfg.CG ~= nil then
|
||||
sCG = mapEventCfg.CG
|
||||
end
|
||||
local param = mapEventCfg.DatingEventParams
|
||||
if #param == 2 and tonumber(param[1]) == self._panel.nCharId and tonumber(param[2]) == self._panel.nLandmark then
|
||||
bSpecial = true
|
||||
end
|
||||
end
|
||||
local nMaxDescCount = 0
|
||||
for i = 3, 1, -1 do
|
||||
if mapEventCfg["Desc" .. i] ~= "" then
|
||||
nMaxDescCount = i
|
||||
break
|
||||
end
|
||||
end
|
||||
for i = 1, 3 do
|
||||
if mapEventCfg["Desc" .. i] ~= "" then
|
||||
local bLast = i == nMaxDescCount
|
||||
local nAffinity = nEventAffinity
|
||||
local data = {
|
||||
nEventId = v,
|
||||
bSpecial = bSpecial,
|
||||
sDesc = mapEventCfg["Desc" .. i],
|
||||
bLast = bLast,
|
||||
nAffinity = nAffinity,
|
||||
sResponse = mapEventCfg.Response
|
||||
}
|
||||
table.insert(self.tbAllEvent, data)
|
||||
table.insert(tbTempEvent, data)
|
||||
end
|
||||
end
|
||||
if sCG ~= "" then
|
||||
self.tbAllEvent[#self.tbAllEvent].sCG = sCG
|
||||
tbTempEvent[#tbTempEvent].sCG = sCG
|
||||
end
|
||||
end
|
||||
end
|
||||
return tbTempEvent
|
||||
end
|
||||
function DatingCtrl:ClosePanel()
|
||||
local func = function()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.Dating)
|
||||
end
|
||||
EventManager.Hit(EventId.SetTransition, 11, func)
|
||||
end
|
||||
function DatingCtrl:ShowReward()
|
||||
UTILS.OpenReceiveByDisplayItem(self.msgData.Show, self.msgData.Change, function()
|
||||
local nCharId = self._panel.nCharId
|
||||
if self.msgData.Info ~= nil then
|
||||
local nLastLevel = self.curAffinityInfo.Level
|
||||
local nLastExp = self.curAffinityInfo.Exp
|
||||
local mapDelay = {
|
||||
nCharId = nCharId,
|
||||
nCurLevel = self.msgData.Info.AffinityLevel,
|
||||
nLastLevel = nLastLevel,
|
||||
nCurExp = self.msgData.Info.AffinityExp,
|
||||
nLastExp = nLastExp
|
||||
}
|
||||
PlayerData.Dating:SetCharFavourLevelUpDelay(mapDelay)
|
||||
end
|
||||
self:ClosePanel()
|
||||
end, 0, AllEnum.ReceivePropsTitle.Dating)
|
||||
end
|
||||
function DatingCtrl:Awake()
|
||||
self.nPanelType = 0
|
||||
self._mapNode.goBubble.gameObject:SetActive(false)
|
||||
self._mapNode.imgTimeBg1.gameObject:SetActive(false)
|
||||
LoadPresetEmoji()
|
||||
end
|
||||
function DatingCtrl:FadeIn()
|
||||
EventManager.Hit(EventId.SetTransition)
|
||||
end
|
||||
function DatingCtrl:OnEnable()
|
||||
self.nOptionSelected = 0
|
||||
self.nTotalValue = 0
|
||||
self:CreateRT()
|
||||
if nil == self.uiRoot then
|
||||
self.uiRoot = PanelManager.GetUIRoot(self._panel._sSortingLayerName)
|
||||
end
|
||||
if nil ~= self.uiRoot then
|
||||
self._mapNode.rtOffScreenRoot:SetParent(self.uiRoot)
|
||||
self._mapNode.rtOffScreenRoot.localScale = Vector3.one
|
||||
self._mapNode.trEmojiRoot.localPosition = Vector3.zero
|
||||
self._mapNode.trEmojiRoot.localScale = Vector3(0.01, 0.01, 0.01)
|
||||
NovaAPI.SetCanvasWorldCamera(self._mapNode.cvEmojiRoot, self._mapNode.OffScreen3DCamera)
|
||||
end
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self._panel.nLandmark = tbParam[1]
|
||||
self._panel.nCharId = tbParam[2]
|
||||
local tbEventId = tbParam[3]
|
||||
self.tbEventId = {
|
||||
{
|
||||
nId = tbEventId,
|
||||
nType = GameEnum.DatingEventType.BeforeBranch
|
||||
}
|
||||
}
|
||||
self.curAffinityInfo = tbParam[4]
|
||||
self.tbBranchOptionIds = tbParam[5]
|
||||
self.tbReward = tbParam[6]
|
||||
self.bFirstOption = true
|
||||
local nStartId = PlayerData.Dating:GetCharStartEventId(self._panel.nCharId)
|
||||
if nStartId ~= nil then
|
||||
table.insert(self.tbEventId, 1, {
|
||||
nId = nStartId,
|
||||
nType = GameEnum.DatingEventType.Start
|
||||
})
|
||||
end
|
||||
local nBranchAId = PlayerData.Dating:GetCharBranchEventId(self._panel.nCharId, true)
|
||||
if nBranchAId ~= 0 then
|
||||
table.insert(self.tbEventId, {
|
||||
nId = nBranchAId,
|
||||
nType = GameEnum.DatingEventType.BranchA
|
||||
})
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAffinityValue, 0)
|
||||
self:SetLandmarkBg()
|
||||
self:SetCharacter()
|
||||
self:StartShowEvent()
|
||||
end
|
||||
end
|
||||
function DatingCtrl:OnDisable()
|
||||
self._mapNode.rtOffScreenRoot:SetParent(self.gameObject.transform)
|
||||
if self.goL2D ~= nil and self.goL2D.tbRenderer ~= nil then
|
||||
Actor2DManager.UnSetActor2DWithRender(self.goL2D.tbRenderer)
|
||||
end
|
||||
if self.charVoiceTimer ~= nil then
|
||||
self.charVoiceTimer:Cancel()
|
||||
self.charVoiceTimer = nil
|
||||
end
|
||||
BubbleVoiceManager.StopBubbleAnim(true)
|
||||
end
|
||||
function DatingCtrl:OnDestroy()
|
||||
end
|
||||
function DatingCtrl:OnEvent_DatingEventAction(nCurIndex, sResponse, nAffinity)
|
||||
self.nCurIndex = nCurIndex
|
||||
if sResponse ~= nil then
|
||||
local sType = sResponse
|
||||
local mapCharResponseCfg = CacheTable.GetData("_DatingCharResponse", self._panel.nCharId)
|
||||
if mapCharResponseCfg == nil then
|
||||
printError(string.format("角色%s没有配置Response", self._panel.nCharId))
|
||||
return
|
||||
end
|
||||
local cfgData = mapCharResponseCfg[sType]
|
||||
if cfgData ~= nil then
|
||||
PlayerData.Voice:PlayCharVoice(cfgData.VoiceKey, self._panel.nCharId)
|
||||
if self.goL2D ~= nil then
|
||||
Actor2DManager.PlayL2DAnim(self.goL2D.tbRenderer.trL2DIns.transform, cfgData.Action, false, true)
|
||||
end
|
||||
self:SetEmoji(cfgData.BubbleEmoji)
|
||||
self:SetBubble(cfgData.Words)
|
||||
end
|
||||
local twValue = DOTween.To(function()
|
||||
return self.nTotalValue
|
||||
end, function(v)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAffinityValue, self:ThousandsNumber(math.floor(v)))
|
||||
end, self.nTotalValue + nAffinity, 0.5)
|
||||
local _cb = function()
|
||||
self.nTotalValue = self.nTotalValue + nAffinity
|
||||
end
|
||||
twValue.onComplete = dotween_callback_handler(self, _cb)
|
||||
end
|
||||
end
|
||||
function DatingCtrl:OnEvent_DatingSendGift()
|
||||
self.nPanelType = type_gift
|
||||
self._mapNode.animRoot:Play("DatingPanel_Gift_in")
|
||||
self:AddTimer(1, 0.1, function()
|
||||
self._mapNode.goEvent.gameObject:SetActive(false)
|
||||
self._mapNode.goSendGift.gameObject:SetActive(true)
|
||||
self._mapNode.imgTimeBg1.gameObject:SetActive(true)
|
||||
end, true, true, true)
|
||||
self._mapNode.goSendGift:RefreshSendGift()
|
||||
end
|
||||
function DatingCtrl:OnEvent_DatingEventFinish()
|
||||
self._mapNode.animRoot:Play("DatingPanel_end")
|
||||
if self.nCurIndex == #self.tbAllEvent then
|
||||
return
|
||||
end
|
||||
local nAddValue = 0
|
||||
for i = self.nCurIndex + 1, #self.tbAllEvent do
|
||||
if self.tbAllEvent[i].bLast then
|
||||
nAddValue = nAddValue + self.tbAllEvent[i].nAffinity
|
||||
end
|
||||
end
|
||||
local twValue = DOTween.To(function()
|
||||
return self.nTotalValue
|
||||
end, function(v)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAffinityValue, self:ThousandsNumber(math.floor(v)))
|
||||
end, self.nTotalValue + nAddValue, 0.5)
|
||||
local _cb = function()
|
||||
self.nTotalValue = self.nTotalValue + nAddValue
|
||||
end
|
||||
twValue.onComplete = dotween_callback_handler(self, _cb)
|
||||
self.nCurIndex = #self.tbAllEvent
|
||||
end
|
||||
function DatingCtrl:OnEvent_DatingSendGiftFinish(sVoiceKey, msgData)
|
||||
self.msgData = msgData
|
||||
self.bPlayCharVoice = false
|
||||
self.nGiftVoiceId = PlayerData.Voice:PlayCharVoice(sVoiceKey, self._panel.nCharId)
|
||||
self.charVoiceTimer = self:AddTimer(1, 0.5, function()
|
||||
if not self.bPlayCharVoice then
|
||||
self:ShowReward()
|
||||
end
|
||||
self.charVoiceTimer = nil
|
||||
end, true, true, true)
|
||||
end
|
||||
function DatingCtrl:OnEvent_CloseDatingPanel()
|
||||
local nCharId = self._panel.nCharId
|
||||
self:ClosePanel()
|
||||
local nLastLevel = self.curAffinityInfo.Level
|
||||
local mapCharAffinity = ConfigTable.GetData("CharAffinityTemplate", nCharId)
|
||||
if mapCharAffinity == nil then
|
||||
return
|
||||
end
|
||||
local templateId = mapCharAffinity.TemplateId
|
||||
local nMaxAffinityLevel = PlayerData.Char:GetMaxAffinityLevel(templateId)
|
||||
if nLastLevel < nMaxAffinityLevel then
|
||||
local nLastExp = self.curAffinityInfo.Exp
|
||||
local curData = PlayerData.Char:GetCharAffinityData(nCharId)
|
||||
local mapDelay = {
|
||||
nCharId = nCharId,
|
||||
nCurLevel = curData.Level,
|
||||
nLastLevel = nLastLevel,
|
||||
nCurExp = curData.Exp,
|
||||
nLastExp = nLastExp
|
||||
}
|
||||
PlayerData.Dating:SetCharFavourLevelUpDelay(mapDelay)
|
||||
end
|
||||
end
|
||||
function DatingCtrl:OnEvent_AvgVoiceDuration(nDuration)
|
||||
if self.nGiftVoiceId ~= nil then
|
||||
local mapVoiceCfg = ConfigTable.GetData("VoDirectory", self.nGiftVoiceId)
|
||||
if mapVoiceCfg == nil then
|
||||
return
|
||||
end
|
||||
self.bPlayCharVoice = true
|
||||
if self.goL2D ~= nil then
|
||||
Actor2DManager.PlayL2DAnim(self.goL2D.tbRenderer.trL2DIns.transform, mapVoiceCfg.motion, false, true)
|
||||
end
|
||||
self._mapNode.goBubble.gameObject:SetActive(true)
|
||||
BubbleVoiceManager.PlayFixedBubbleAnim(self._mapNode.goBubble, mapVoiceCfg.voResource)
|
||||
if nDuration ~= nil and 0 < nDuration then
|
||||
self:AddTimer(1, nDuration, function()
|
||||
self:ShowReward()
|
||||
end, true, true, true)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nDuration)
|
||||
else
|
||||
self:ShowReward()
|
||||
end
|
||||
end
|
||||
end
|
||||
function DatingCtrl:OnBtnClick_DatingShowImgMsg(iconPath)
|
||||
self:SetPngSprite(self._mapNode.imgMsgDetail, iconPath)
|
||||
NovaAPI.SetImageNativeSize(self._mapNode.imgMsgDetail)
|
||||
self._mapNode.aniMsgDetail:Play("showMsg")
|
||||
end
|
||||
function DatingCtrl:OnBtnClick_HideImgMsg()
|
||||
self._mapNode.aniMsgDetail:Play("hideMsg")
|
||||
end
|
||||
function DatingCtrl:StartShowEvent()
|
||||
self.nPanelType = type_event
|
||||
local mapLandmarkCfg = ConfigTable.GetData("DatingLandmark", self._panel.nLandmark)
|
||||
if mapLandmarkCfg ~= nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLandmark, mapLandmarkCfg.Name)
|
||||
end
|
||||
self._mapNode.goEvent.gameObject:SetActive(true)
|
||||
self._mapNode.goSendGift.gameObject:SetActive(false)
|
||||
self.tbAllEvent = {}
|
||||
self.tbAllEvent = self:LoadEventConfig(self.tbEventId)
|
||||
self.nCurIndex = 0
|
||||
self._mapNode.goEvent:SetEventList(self.tbAllEvent, self.tbEventId)
|
||||
end
|
||||
function DatingCtrl:OnEvent_DatingOptionSelected(nOptionIndex)
|
||||
local callback = function(_, msgData)
|
||||
local tbNewEvents = {}
|
||||
if self.bFirstOption then
|
||||
self.bFirstOption = false
|
||||
for k, v in pairs(msgData.LandmarkEventIds) do
|
||||
table.insert(tbNewEvents, {
|
||||
nId = v,
|
||||
nType = GameEnum.DatingEventType.Landmark
|
||||
})
|
||||
end
|
||||
table.sort(tbNewEvents, function(a, b)
|
||||
local cfgDataA = ConfigTable.GetData("DatingLandmarkEvent", a.nId)
|
||||
local cfgDataB = ConfigTable.GetData("DatingLandmarkEvent", b.nId)
|
||||
if cfgDataA ~= nil and cfgDataB ~= nil then
|
||||
return cfgDataA.SortTag < cfgDataB.SortTag
|
||||
end
|
||||
end)
|
||||
local nBranchBId = PlayerData.Dating:GetCharBranchEventId(self._panel.nCharId, false)
|
||||
if nBranchBId ~= 0 then
|
||||
table.insert(tbNewEvents, {
|
||||
nId = nBranchBId,
|
||||
nType = GameEnum.DatingEventType.BranchA
|
||||
})
|
||||
end
|
||||
self.tbBranchOptionIds = msgData.BranchBOptionIds
|
||||
else
|
||||
table.insert(tbNewEvents, {
|
||||
nId = msgData.CharacterEventId,
|
||||
nType = GameEnum.DatingEventType.LimitedLandmark
|
||||
})
|
||||
table.insert(tbNewEvents, {
|
||||
nId = msgData.AfterBranchId,
|
||||
nType = GameEnum.DatingEventType.AfterBranch
|
||||
})
|
||||
local nEndId = PlayerData.Dating:GetCharEndEventId(self._panel.nCharId)
|
||||
if nEndId ~= nil then
|
||||
table.insert(tbNewEvents, {
|
||||
nId = nEndId,
|
||||
nType = GameEnum.DatingEventType.End
|
||||
})
|
||||
end
|
||||
PlayerData.Dating:RefreshLimitedEventList(self._panel.nCharId, {
|
||||
msgData.CharacterEventId
|
||||
})
|
||||
PlayerData.Char:ChangeCharAffinityValue(msgData.Info)
|
||||
if msgData.Change ~= nil then
|
||||
local mapDecodedChangeInfo = UTILS.DecodeChangeInfo(msgData.Change)
|
||||
HttpNetHandler.ProcChangeInfo(mapDecodedChangeInfo)
|
||||
end
|
||||
end
|
||||
local tbTempEvent = self:LoadEventConfig(tbNewEvents)
|
||||
self._mapNode.goEvent:AddEvent(tbTempEvent, tbNewEvents)
|
||||
end
|
||||
if nOptionIndex == 0 then
|
||||
nOptionIndex = self.tbBranchOptionIds[1]
|
||||
end
|
||||
local nNetMsgId = self.bFirstOption and NetMsgId.Id.char_dating_branch_a_select_req or NetMsgId.Id.char_dating_branch_b_select_req
|
||||
HttpNetHandler.SendMsg(nNetMsgId, {OptionId = nOptionIndex}, nil, callback)
|
||||
end
|
||||
return DatingCtrl
|
||||
@@ -0,0 +1,298 @@
|
||||
local DatingEventCtrl = class("DatingEventCtrl", BaseCtrl)
|
||||
DatingEventCtrl._mapNodeConfig = {
|
||||
imgBtnBg = {},
|
||||
btnSpeedUp = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_SpeedUp"
|
||||
},
|
||||
imgSpeed1 = {},
|
||||
imgSpeed2 = {},
|
||||
imgAutoPlay1 = {},
|
||||
imgAutoPlay2 = {},
|
||||
btnSkip = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Skip"
|
||||
},
|
||||
btnAutoPlay = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_AutoPlay"
|
||||
},
|
||||
goContent = {
|
||||
sNodeName = "Content",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
eventListSV = {sComponentName = "ScrollRect"},
|
||||
btnNextEvent = {
|
||||
sComponentName = "NaviButton",
|
||||
callback = "OnBtnClick_NextEvent"
|
||||
},
|
||||
goEventItem = {},
|
||||
goEventEndItem = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
goEventSelectionItem = {},
|
||||
endItemLayoutElement = {
|
||||
sNodeName = "goEventEndItem",
|
||||
sComponentName = "LayoutElement"
|
||||
},
|
||||
txtEndTips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Event_End_Tip"
|
||||
},
|
||||
btnSend = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Send"
|
||||
},
|
||||
txtSendGift = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Event_End_Send_Gift"
|
||||
},
|
||||
goSendGift = {},
|
||||
btnLeave = {
|
||||
nCount = 2,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Leave"
|
||||
},
|
||||
txtLeave = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Event_End_Leave"
|
||||
},
|
||||
rtImgTimeHour = {
|
||||
sNodeName = "imgTimeHour",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rtImgTimeMin = {
|
||||
sNodeName = "imgTimeMin",
|
||||
sComponentName = "RectTransform"
|
||||
}
|
||||
}
|
||||
DatingEventCtrl._mapEventConfig = {
|
||||
DatingEventNext = "OnEvent_DatingEventNext"
|
||||
}
|
||||
function DatingEventCtrl:SetEventList(tbEvent, tbEventId)
|
||||
self.tbEventId = {}
|
||||
for i = 1, #tbEventId do
|
||||
table.insert(self.tbEventId, tbEventId[i])
|
||||
end
|
||||
self.tbEvent = {}
|
||||
for i = 1, #tbEvent do
|
||||
table.insert(self.tbEvent, tbEvent[i])
|
||||
end
|
||||
for _, v in ipairs(self.tbEvent) do
|
||||
local goItem, itemCtrl
|
||||
if v.tbOptions ~= nil then
|
||||
goItem = instantiate(self._mapNode.goEventSelectionItem, self._mapNode.goContent)
|
||||
if goItem ~= nil then
|
||||
itemCtrl = self:BindCtrlByNode(goItem, "Game.UI.Phone.Dating.DatingEventOptionItemCtrl")
|
||||
end
|
||||
else
|
||||
goItem = instantiate(self._mapNode.goEventItem, self._mapNode.goContent)
|
||||
if goItem ~= nil then
|
||||
itemCtrl = self:BindCtrlByNode(goItem, "Game.UI.Phone.Dating.DatingEventItemCtrl")
|
||||
end
|
||||
end
|
||||
if goItem ~= nil and itemCtrl ~= nil then
|
||||
goItem:SetActive(true)
|
||||
itemCtrl:InitItem(v)
|
||||
goItem:SetActive(false)
|
||||
table.insert(self.tbEventItemCtrl, itemCtrl)
|
||||
end
|
||||
end
|
||||
local listCount = 0
|
||||
local foreachAffinityGift = function(mapData)
|
||||
local count = PlayerData.Item:GetItemCountByID(mapData.Id)
|
||||
if 0 < count then
|
||||
listCount = listCount + 1
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityGift, foreachAffinityGift)
|
||||
self._mapNode.goSendGift.gameObject:SetActive(0 < listCount)
|
||||
self._mapNode.btnLeave[2].gameObject:SetActive(listCount == 0)
|
||||
NovaAPI.SetLayoutElementMinHeight(self._mapNode.endItemLayoutElement, 0 < listCount and 252 or 70)
|
||||
self.bSpeed = false
|
||||
self.bAuto = false
|
||||
self.bSkip = false
|
||||
self._mapNode.goEventEndItem.gameObject:SetActive(false)
|
||||
self._mapNode.imgSpeed1.gameObject:SetActive(not self.bSpeed)
|
||||
self._mapNode.imgSpeed2.gameObject:SetActive(self.bSpeed)
|
||||
self._mapNode.imgSpeed1.gameObject:SetActive(not self.bAuto)
|
||||
self._mapNode.imgSpeed2.gameObject:SetActive(self.bAuto)
|
||||
self.nCurIndex = 1
|
||||
if self.nEventId == nil then
|
||||
self.nEventId = 1
|
||||
end
|
||||
local eventData = self.tbEvent[self.nCurIndex]
|
||||
self.nEventIndex = 0
|
||||
self.nCurEventId = eventData.nEventId
|
||||
self.nLastEventId = self.nCurEventId
|
||||
self:StartEvent()
|
||||
end
|
||||
function DatingEventCtrl:AddEvent(tbEvent, tbEventId)
|
||||
for i = 1, #tbEventId do
|
||||
table.insert(self.tbEventId, tbEventId[i])
|
||||
end
|
||||
for i = 1, #tbEvent do
|
||||
table.insert(self.tbEvent, tbEvent[i])
|
||||
end
|
||||
for _, v in ipairs(tbEvent) do
|
||||
local goItem, itemCtrl
|
||||
if v.tbOptions ~= nil then
|
||||
goItem = instantiate(self._mapNode.goEventSelectionItem, self._mapNode.goContent)
|
||||
if goItem ~= nil then
|
||||
itemCtrl = self:BindCtrlByNode(goItem, "Game.UI.Phone.Dating.DatingEventOptionItemCtrl")
|
||||
end
|
||||
else
|
||||
goItem = instantiate(self._mapNode.goEventItem, self._mapNode.goContent)
|
||||
if goItem ~= nil then
|
||||
itemCtrl = self:BindCtrlByNode(goItem, "Game.UI.Phone.Dating.DatingEventItemCtrl")
|
||||
end
|
||||
end
|
||||
if goItem ~= nil and itemCtrl ~= nil then
|
||||
goItem:SetActive(true)
|
||||
itemCtrl:InitItem(v)
|
||||
goItem:SetActive(false)
|
||||
table.insert(self.tbEventItemCtrl, itemCtrl)
|
||||
end
|
||||
end
|
||||
local listCount = 0
|
||||
local foreachAffinityGift = function(mapData)
|
||||
local count = PlayerData.Item:GetItemCountByID(mapData.Id)
|
||||
if 0 < count then
|
||||
listCount = listCount + 1
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityGift, foreachAffinityGift)
|
||||
self._mapNode.goSendGift.gameObject:SetActive(0 < listCount)
|
||||
self._mapNode.btnLeave[2].gameObject:SetActive(listCount == 0)
|
||||
NovaAPI.SetLayoutElementMinHeight(self._mapNode.endItemLayoutElement, 0 < listCount and 252 or 70)
|
||||
if self.bSkip then
|
||||
self:OnBtnClick_Skip()
|
||||
else
|
||||
self.nCurIndex = self.nCurIndex + 1
|
||||
self:StartEvent()
|
||||
end
|
||||
end
|
||||
function DatingEventCtrl:StartEvent()
|
||||
if self.tbEventItemCtrl[self.nCurIndex] ~= nil then
|
||||
self.tbEventItemCtrl[self.nCurIndex].gameObject:SetActive(true)
|
||||
self._mapNode.btnNextEvent.gameObject:SetActive(not self.tbEventItemCtrl[self.nCurIndex]:GetBranch() and not self.bSkip)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
NovaAPI.SetVerticalNormalizedPosition(self._mapNode.eventListSV, 0)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
local eventData = self.tbEvent[self.nEventId]
|
||||
self.nEventId = self.nEventId + 1
|
||||
if eventData.bLast then
|
||||
self.nLastEventId = eventData.nEventId
|
||||
self.nEventIndex = self.nEventIndex + 1
|
||||
self._mapNode.rtImgTimeMin:DOLocalRotate(Vector3(0, 0, -360), 1.2, RotateMode.FastBeyond360):SetUpdate(true)
|
||||
self._mapNode.rtImgTimeHour:DOLocalRotate(Vector3(0, 0, -self.nEventIndex / #self.tbEventId * 360), 1.2):SetUpdate(true)
|
||||
EventManager.Hit("DatingEventAction", self.nCurIndex, eventData.sResponse, eventData.nAffinity)
|
||||
end
|
||||
self.nCurEventId = eventData.nEventId
|
||||
self.tbEventItemCtrl[self.nCurIndex]:StartEvent(self.bSpeed and 2 or 1, self.bAuto or self.bSkip)
|
||||
end
|
||||
end
|
||||
function DatingEventCtrl:Awake()
|
||||
self.tbEventItemCtrl = {}
|
||||
self._mapNode.goEventItem.gameObject:SetActive(false)
|
||||
self._mapNode.rtImgTimeHour.localRotation = Quaternion.Euler(0, 0, 0)
|
||||
end
|
||||
function DatingEventCtrl:OnEnable()
|
||||
self._mapNode.imgAutoPlay1.gameObject:SetActive(true)
|
||||
self._mapNode.imgAutoPlay2.gameObject:SetActive(false)
|
||||
end
|
||||
function DatingEventCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbEventItemCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbEventItemCtrl[nInstanceId] = nil
|
||||
end
|
||||
end
|
||||
function DatingEventCtrl:OnDestroy()
|
||||
end
|
||||
function DatingEventCtrl:OnBtnClick_SpeedUp()
|
||||
if self.tbEventItemCtrl[self.nCurIndex] ~= nil then
|
||||
self.bSpeed = not self.bSpeed
|
||||
self._mapNode.imgSpeed1.gameObject:SetActive(not self.bSpeed)
|
||||
self._mapNode.imgSpeed2.gameObject:SetActive(self.bSpeed)
|
||||
self.tbEventItemCtrl[self.nCurIndex]:ChangeSpeed(self.bSpeed and 2 or 1)
|
||||
end
|
||||
end
|
||||
function DatingEventCtrl:OnBtnClick_AutoPlay()
|
||||
self.bAuto = not self.bAuto
|
||||
if self.bAuto and self.nCurIndex <= #self.tbEvent then
|
||||
EventManager.Hit("DatingEventRefreshTip")
|
||||
EventManager.Hit("DatingEventNext")
|
||||
elseif not self.bAuto and self.tbEventItemCtrl[self.nCurIndex]:GetAuto() then
|
||||
self.tbEventItemCtrl[self.nCurIndex]:FinishImmediately(true)
|
||||
end
|
||||
self._mapNode.imgAutoPlay1.gameObject:SetActive(not self.bAuto)
|
||||
self._mapNode.imgAutoPlay2.gameObject:SetActive(self.bAuto)
|
||||
end
|
||||
function DatingEventCtrl:OnBtnClick_Skip()
|
||||
if self.nCurIndex <= #self.tbEventItemCtrl then
|
||||
self.bSkip = true
|
||||
self.tbEventItemCtrl[self.nCurIndex]:SkipTimer()
|
||||
for i = self.nCurIndex, #self.tbEventItemCtrl do
|
||||
self.tbEventItemCtrl[i].gameObject:SetActive(true)
|
||||
self.nCurIndex = self.nCurIndex + 1
|
||||
end
|
||||
self._mapNode.btnNextEvent.gameObject:SetActive(false)
|
||||
self.tbEventItemCtrl[#self.tbEventItemCtrl]:SkipTimer()
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
NovaAPI.SetVerticalNormalizedPosition(self._mapNode.eventListSV, 0)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 3)
|
||||
if self.tbEventId[#self.tbEventId].nType == GameEnum.DatingEventType.End then
|
||||
self._mapNode.goEventEndItem:SetParent(self._mapNode.goContent)
|
||||
self._mapNode.btnNextEvent.gameObject:SetActive(false)
|
||||
self._mapNode.goEventEndItem.gameObject:SetActive(true)
|
||||
EventManager.Hit("DatingEventFinish")
|
||||
end
|
||||
end
|
||||
end
|
||||
function DatingEventCtrl:OnBtnClick_Send()
|
||||
EventManager.Hit("DatingSendGift")
|
||||
end
|
||||
function DatingEventCtrl:OnBtnClick_Leave()
|
||||
EventManager.Hit("CloseDatingPanel")
|
||||
end
|
||||
function DatingEventCtrl:OnBtnClick_NextEvent()
|
||||
if self.tbEventItemCtrl[self.nCurIndex]:GetAuto() then
|
||||
self.tbEventItemCtrl[self.nCurIndex]:FinishImmediately(false)
|
||||
else
|
||||
EventManager.Hit("DatingEventRefreshTip")
|
||||
EventManager.Hit("DatingEventNext")
|
||||
end
|
||||
end
|
||||
function DatingEventCtrl:OnEvent_DatingEventNext()
|
||||
if self.tbEventItemCtrl[self.nCurIndex]:GetAuto() then
|
||||
return
|
||||
end
|
||||
if self.bAuto and self.tbEventItemCtrl[self.nCurIndex]:GetBranch() then
|
||||
self.tbEventItemCtrl[self.nCurIndex]:SelectDefault()
|
||||
self.nCurIndex = self.nCurIndex + 1
|
||||
return
|
||||
end
|
||||
self.nCurIndex = self.nCurIndex + 1
|
||||
if self.nCurIndex > #self.tbEventItemCtrl then
|
||||
self._mapNode.rtImgTimeMin.localRotation = Quaternion.Euler(0, 0, -360)
|
||||
self._mapNode.rtImgTimeHour.localRotation = Quaternion.Euler(0, 0, -360)
|
||||
self._mapNode.goEventEndItem:SetParent(self._mapNode.goContent)
|
||||
self._mapNode.btnNextEvent.gameObject:SetActive(false)
|
||||
self._mapNode.goEventEndItem.gameObject:SetActive(true)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
NovaAPI.SetVerticalNormalizedPosition(self._mapNode.eventListSV, 0)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
EventManager.Hit("DatingEventFinish")
|
||||
return
|
||||
end
|
||||
self:StartEvent(self.bSpeed and 2 or 1, self.bAuto or self.bSkip)
|
||||
end
|
||||
return DatingEventCtrl
|
||||
@@ -0,0 +1,153 @@
|
||||
local DatingEventItemCtrl = class("DatingEventItemCtrl", BaseCtrl)
|
||||
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
|
||||
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
|
||||
DatingEventItemCtrl._mapNodeConfig = {
|
||||
goTag = {},
|
||||
txtTag = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Event_Special"
|
||||
},
|
||||
goTxtHeight = {},
|
||||
rtGoTxtHeight = {
|
||||
sNodeName = "goTxtHeight",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtHeight = {sComponentName = "TMP_Text"},
|
||||
rtTxtHeight = {
|
||||
sNodeName = "txtHeight",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtEvent = {sComponentName = "TMP_Text"},
|
||||
txtEventSpecial = {sComponentName = "TMP_Text"},
|
||||
goFavor = {},
|
||||
imgCG = {sComponentName = "Image"},
|
||||
rtImgCG = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtFavorCount = {sComponentName = "TMP_Text"},
|
||||
goTime = {},
|
||||
goWait = {},
|
||||
animWaiting = {sNodeName = "imgWait", sComponentName = "Animator"},
|
||||
imgTimeBar = {sComponentName = "Image"}
|
||||
}
|
||||
DatingEventItemCtrl._mapEventConfig = {
|
||||
DatingEventRefreshTip = "OnEvent_DatingEventRefreshTip"
|
||||
}
|
||||
DatingEventItemCtrl._mapRedDotConfig = {}
|
||||
local replace_str = "==DATING_CHARACTER=="
|
||||
local sEventCgPath = "Icon/DatingEventCG/"
|
||||
function DatingEventItemCtrl:InitItem(data)
|
||||
self.data = data
|
||||
self.bCG = false
|
||||
self._mapNode.rtImgCG.gameObject:SetActive(false)
|
||||
if data.sCG ~= nil then
|
||||
self.bCG = true
|
||||
self.nItemTime = self.nItemTime / 4
|
||||
self._mapNode.rtImgCG.gameObject:SetActive(true)
|
||||
local btn = self._mapNode.rtImgCG.gameObject:GetComponent("UIButton")
|
||||
local sCgPath = sEventCgPath .. data.sCG
|
||||
btn.onClick:AddListener(function()
|
||||
EventManager.Hit("DatingShowImgMsg", sCgPath)
|
||||
end)
|
||||
self:SetPngSprite(self._mapNode.imgCG, sCgPath)
|
||||
end
|
||||
self._mapNode.goFavor.gameObject:SetActive(data.bLast and data.nAffinity > 0)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFavorCount, "+" .. data.nAffinity)
|
||||
local charCfg = ConfigTable.GetData_Character(self._panel.nCharId)
|
||||
if charCfg ~= nil then
|
||||
local sDesc = string.gsub(data.sDesc, replace_str, charCfg.Name)
|
||||
local mapKrTag = ConfigTable.GetData("DatingCharTag", self._panel.nCharId)
|
||||
if mapKrTag ~= nil and mapKrTag.KrTag ~= nil then
|
||||
local tbKr = AllEnum.DatingKrTags[mapKrTag.KrTag]
|
||||
if tbKr ~= nil then
|
||||
for k, v in pairs(tbKr) do
|
||||
sDesc = string.gsub(sDesc, k, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtEvent, sDesc)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtEventSpecial, sDesc)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHeight, sDesc)
|
||||
end
|
||||
self._mapNode.goTag.gameObject:SetActive(data.bSpecial)
|
||||
self._mapNode.txtEventSpecial.gameObject:SetActive(data.bSpecial)
|
||||
self._mapNode.txtEvent.gameObject:SetActive(not data.bSpecial)
|
||||
self._mapNode.goTime.gameObject:SetActive(false)
|
||||
self._mapNode.goWait.gameObject:SetActive(false)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTxtHeight)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTxtHeight)
|
||||
local nH = self._mapNode.rtTxtHeight.rect.height
|
||||
self._mapNode.rtGoTxtHeight.sizeDelta = Vector2(self._mapNode.rtGoTxtHeight.sizeDelta.x, nH)
|
||||
end
|
||||
function DatingEventItemCtrl:StartEvent(nSpeed, bAuto)
|
||||
self.nCurTime = 0
|
||||
local sAnim = "DatingPanel_Event_in"
|
||||
if self.bCG then
|
||||
sAnim = "DatingPanel_SpCGEvent_in"
|
||||
elseif self.bSpecial then
|
||||
sAnim = "DatingPanel_SpEvent_in"
|
||||
end
|
||||
self.anim:Play(sAnim)
|
||||
self.bAuto = bAuto
|
||||
if bAuto or self.bCG then
|
||||
self._mapNode.goWait.gameObject:SetActive(false)
|
||||
self._mapNode.goTime.gameObject:SetActive(true)
|
||||
NovaAPI.SetImageFillAmount(self._mapNode.imgTimeBar, 0)
|
||||
self.eventTimer = self:AddTimer(0, 0.034, function()
|
||||
self.nCurTime = self.nCurTime + 0.034
|
||||
NovaAPI.SetImageFillAmount(self._mapNode.imgTimeBar, self.nCurTime / self.nItemTime)
|
||||
if self.nCurTime >= self.nItemTime then
|
||||
self.eventTimer:Cancel()
|
||||
self.eventTimer = nil
|
||||
self._mapNode.goTime.gameObject:SetActive(false)
|
||||
if self.bAuto then
|
||||
EventManager.Hit("DatingEventNext")
|
||||
end
|
||||
end
|
||||
end)
|
||||
self.eventTimer:SetSpeed(nSpeed)
|
||||
else
|
||||
self._mapNode.goWait.gameObject:SetActive(true)
|
||||
self._mapNode.animWaiting:SetTrigger("tManual")
|
||||
self._mapNode.goTime.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function DatingEventItemCtrl:ChangeSpeed(nSpeed)
|
||||
if self.eventTimer ~= nil then
|
||||
self.eventTimer:SetSpeed(nSpeed)
|
||||
end
|
||||
end
|
||||
function DatingEventItemCtrl:FinishImmediately(bCancelAuto)
|
||||
self._mapNode.goWait.gameObject:SetActive(false)
|
||||
if self.eventTimer ~= nil then
|
||||
self.bAuto = not bCancelAuto
|
||||
if not self.bAuto then
|
||||
self._mapNode.goTime.gameObject:SetActive(false)
|
||||
self._mapNode.goWait.gameObject:SetActive(true)
|
||||
self._mapNode.animWaiting:SetTrigger("tManual")
|
||||
end
|
||||
self.nCurTime = self.nItemTime + 0.5
|
||||
end
|
||||
end
|
||||
function DatingEventItemCtrl:GetAuto()
|
||||
return self.eventTimer ~= nil
|
||||
end
|
||||
function DatingEventItemCtrl:GetBranch()
|
||||
return false
|
||||
end
|
||||
function DatingEventItemCtrl:SkipTimer()
|
||||
self._mapNode.goWait.gameObject:SetActive(false)
|
||||
if self.eventTimer ~= nil then
|
||||
self.eventTimer:Cancel()
|
||||
self.eventTimer = nil
|
||||
self._mapNode.goTime.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function DatingEventItemCtrl:Awake()
|
||||
self.anim = self.gameObject:GetComponent("Animator")
|
||||
self.nItemTime = ConfigTable.GetConfigNumber("Dating_Single_Event_Time")
|
||||
end
|
||||
function DatingEventItemCtrl:OnEvent_DatingEventRefreshTip()
|
||||
self._mapNode.goWait.gameObject:SetActive(false)
|
||||
end
|
||||
return DatingEventItemCtrl
|
||||
@@ -0,0 +1,92 @@
|
||||
local DatingEventOptionItemCtrl = class("DatingEventOptionItemCtrl", BaseCtrl)
|
||||
DatingEventOptionItemCtrl._mapNodeConfig = {
|
||||
btnOption = {},
|
||||
goOptionTip = {},
|
||||
OptionList = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtSelection = {},
|
||||
txtSelectionDummy = {},
|
||||
txtOptionTip = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Phone_Dating_Option_Tip"
|
||||
}
|
||||
}
|
||||
DatingEventOptionItemCtrl._mapEventConfig = {
|
||||
DatingSelectOption = "OnEvent_DatingSelectOption"
|
||||
}
|
||||
DatingEventOptionItemCtrl._mapRedDotConfig = {}
|
||||
local replace_str = "==DATING_CHARACTER=="
|
||||
function DatingEventOptionItemCtrl:InitItem(data)
|
||||
self.data = data
|
||||
self.tbBtnCtrl = {}
|
||||
local charCfg = ConfigTable.GetData_Character(self._panel.nCharId)
|
||||
for nId, mapOptData in pairs(self.data.tbOptions) do
|
||||
local goItem = instantiate(self._mapNode.btnOption, self._mapNode.OptionList)
|
||||
if goItem ~= nil then
|
||||
goItem.gameObject:SetActive(true)
|
||||
local btnComp = goItem.transform:GetComponent("UIButton")
|
||||
local func_Handler = ui_handler(self, self.OnBtnClick_Select, btnComp, mapOptData.nOptId)
|
||||
btnComp.onClick:AddListener(func_Handler)
|
||||
table.insert(self.tbBtnCtrl, btnComp)
|
||||
local txtOption = goItem.transform:Find("AnimRoot/txtOption"):GetComponent("TMP_Text")
|
||||
local sOpt = mapOptData.sOpt
|
||||
if charCfg ~= nil then
|
||||
sOpt = string.gsub(sOpt, replace_str, charCfg.Name)
|
||||
mapOptData.sOpt = sOpt
|
||||
end
|
||||
NovaAPI.SetTMPText(txtOption, sOpt)
|
||||
end
|
||||
end
|
||||
self.txtSelection = instantiate(self._mapNode.txtSelection, self._mapNode.OptionList):GetComponent("TMP_Text")
|
||||
self.txtSelectionDummy = instantiate(self._mapNode.txtSelectionDummy, self._mapNode.OptionList):GetComponent("TMP_Text")
|
||||
self.txtSelectionDummy.gameObject:SetActive(true)
|
||||
end
|
||||
function DatingEventOptionItemCtrl:SelectDefault()
|
||||
self:OnBtnClick_Select(nil, self.data.tbOptions[1].nOptId)
|
||||
end
|
||||
function DatingEventOptionItemCtrl:OnBtnClick_Select(btn, nIndex)
|
||||
if self.bSelected then
|
||||
return
|
||||
end
|
||||
self.bSelected = true
|
||||
self._mapNode.goOptionTip.gameObject:SetActive(false)
|
||||
for k, mapOptData in pairs(self.data.tbOptions) do
|
||||
if mapOptData.nOptId == nIndex then
|
||||
NovaAPI.SetTMPText(self.txtSelection, mapOptData.sOpt)
|
||||
NovaAPI.SetTMPText(self.txtSelectionDummy, mapOptData.sOpt)
|
||||
self.txtSelection.gameObject:SetActive(true)
|
||||
self.txtSelectionDummy.gameObject:SetActive(true)
|
||||
self.animator:Play("DatingPanel_EventSelectionItem_Select")
|
||||
self:AddTimer(1, 1, function()
|
||||
EventManager.Hit("DatingOptionSelected", nIndex)
|
||||
end, true, true, true)
|
||||
end
|
||||
self.tbBtnCtrl[k].gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
function DatingEventOptionItemCtrl:StartEvent(nSpeed, bAuto)
|
||||
if bAuto then
|
||||
self:SelectDefault()
|
||||
end
|
||||
end
|
||||
function DatingEventOptionItemCtrl:ChangeSpeed(nSpeed)
|
||||
end
|
||||
function DatingEventOptionItemCtrl:FinishImmediately(bCancelAuto)
|
||||
end
|
||||
function DatingEventOptionItemCtrl:GetAuto()
|
||||
return false
|
||||
end
|
||||
function DatingEventOptionItemCtrl:GetBranch()
|
||||
return true
|
||||
end
|
||||
function DatingEventOptionItemCtrl:SkipTimer()
|
||||
self:SelectDefault()
|
||||
end
|
||||
function DatingEventOptionItemCtrl:Awake()
|
||||
self.bSelected = false
|
||||
self.animator = self.gameObject:GetComponent("Animator")
|
||||
end
|
||||
function DatingEventOptionItemCtrl:OnDisable()
|
||||
end
|
||||
return DatingEventOptionItemCtrl
|
||||
@@ -0,0 +1,563 @@
|
||||
local DatingGiftCtrl = class("DatingGiftCtrl", BaseCtrl)
|
||||
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
|
||||
DatingGiftCtrl._mapNodeConfig = {
|
||||
txtTips = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Finish_Send_Gift_Tip"
|
||||
},
|
||||
loopsvGiftList = {
|
||||
sNodeName = "svGiftList",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
goEmpty = {sNodeName = "Empty", sComponentName = "GameObject"},
|
||||
txtEmpty = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Phone_Gift_Send_List_Empty"
|
||||
},
|
||||
imgAffinity = {sComponentName = "Image"},
|
||||
txtAffinityLevelCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Send_Gift_Tacit"
|
||||
},
|
||||
txtLevelCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Affinity_Level"
|
||||
},
|
||||
txtAffinityLevel = {sComponentName = "TMP_Text"},
|
||||
txtGiftCount = {sComponentName = "TMP_Text"},
|
||||
rectPreProgress = {
|
||||
sNodeName = "imgPreProgress",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rectProgress = {
|
||||
sNodeName = "imgProgress",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtProgress = {
|
||||
sNodeName = "txtProgress",
|
||||
sComponentName = "TMP_Text"
|
||||
},
|
||||
t_common_04 = {},
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Send_Gift_Title"
|
||||
},
|
||||
btnPresent = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Present"
|
||||
},
|
||||
txtBtnPresent = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Gift_Send_Btn"
|
||||
},
|
||||
btnEnd = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_End"
|
||||
},
|
||||
txtBtnEnd = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Gift_Abandon_Btn"
|
||||
},
|
||||
btnPresentGray = {sComponentName = "UIButton"},
|
||||
txtBtnPresentGray = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Gift_Send_Btn"
|
||||
},
|
||||
btnEndGray = {sComponentName = "UIButton"},
|
||||
txtBtnEndGray = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Gift_Abandon_Btn"
|
||||
}
|
||||
}
|
||||
DatingGiftCtrl._mapEventConfig = {
|
||||
[EventId.AffinityChange] = "OnEvent_AffinityChange"
|
||||
}
|
||||
function DatingGiftCtrl:GetGiftFavourLevel(itemList)
|
||||
if self.PreferenceData == nil then
|
||||
return 2
|
||||
end
|
||||
local nLevel = 0
|
||||
for _, v in ipairs(itemList) do
|
||||
local itemData = ConfigTable.GetData("AffinityGift", v.Tid)
|
||||
for k, v in ipairs(itemData.Tags) do
|
||||
for k1, v1 in ipairs(self.PreferenceData.PreferTags) do
|
||||
if v == v1 and nLevel < 1 then
|
||||
nLevel = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, v in ipairs(itemData.Tags) do
|
||||
for k1, v1 in ipairs(self.PreferenceData.HateTags) do
|
||||
if v == v1 and nLevel < 3 then
|
||||
nLevel = 3
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if nLevel == 0 then
|
||||
nLevel = 2
|
||||
end
|
||||
return nLevel
|
||||
end
|
||||
function DatingGiftCtrl:GetGiftFeedbackLevel(tbItems)
|
||||
local nLevel = self:GetGiftFavourLevel(tbItems)
|
||||
if 1 < nLevel then
|
||||
nLevel = 3
|
||||
else
|
||||
for _, v in ipairs(tbItems) do
|
||||
local itemData = ConfigTable.GetData_Item(v.Tid)
|
||||
if itemData.Rarity == GameEnum.itemRarity.SSR then
|
||||
nLevel = 1
|
||||
else
|
||||
nLevel = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
return nLevel
|
||||
end
|
||||
function DatingGiftCtrl:RefreshAffinityLevel()
|
||||
local mapCharAffinity = ConfigTable.GetData("CharAffinityTemplate", self.nCharId)
|
||||
if mapCharAffinity == nil then
|
||||
return
|
||||
end
|
||||
local templateId = mapCharAffinity.TemplateId
|
||||
self.MaxAffinityLevel = PlayerData.Char:GetMaxAffinityLevel(templateId)
|
||||
local percent = 0
|
||||
local level = self.curFavourLevel >= self.MaxAffinityLevel and self.MaxAffinityLevel or self.curFavourLevel + 1
|
||||
local data = CacheTable.GetData("_AffinityLevel", templateId)[level]
|
||||
local curData = CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel]
|
||||
if self.curFavourLevel >= self.MaxAffinityLevel then
|
||||
percent = 1
|
||||
else
|
||||
percent = self.curFavourExp / data.NeedExp
|
||||
end
|
||||
local sizeDelta = self._mapNode.rectProgress.sizeDelta
|
||||
sizeDelta.x = self.progressBarWidth * percent < self.progressBarMinWidth and self.progressBarMinWidth or self.progressBarWidth * percent
|
||||
self._mapNode.rectProgress.sizeDelta = sizeDelta
|
||||
if self.curFavourLevel >= self.MaxAffinityLevel then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, ConfigTable.GetUIText("Phone_Gift_Affinity_Max_Level"))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", self.curFavourExp, data.NeedExp))
|
||||
end
|
||||
self._mapNode.rectProgress.gameObject:SetActive(0 < self.curFavourExp or self.curFavourLevel >= self.MaxAffinityLevel)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAffinityLevel, self.curFavourLevel)
|
||||
self:SetPngSprite(self._mapNode.imgAffinity, curData.AffinityLevelIcon .. "_s")
|
||||
end
|
||||
function DatingGiftCtrl:RefreshSendGift()
|
||||
self.nCharId = self._panel.nCharId
|
||||
local mapCharDesc = ConfigTable.GetData("CharacterDes", self.nCharId)
|
||||
if mapCharDesc ~= nil then
|
||||
self.PreferenceData = {
|
||||
PreferTags = mapCharDesc.PreferTags,
|
||||
HateTags = mapCharDesc.HateTags
|
||||
}
|
||||
end
|
||||
self.tbChooseItem = {}
|
||||
self._mapNode.rectPreProgress.gameObject:SetActive(false)
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(self.nCharId)
|
||||
self.curFavourLevel = affinityData.Level
|
||||
self.curFavourExp = affinityData.Exp
|
||||
self.preFavourLevel = self.curFavourLevel
|
||||
self.preFavourExp = self.curFavourExp
|
||||
self:RefreshAffinityLevel()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtGiftCount, orderedFormat(ConfigTable.GetUIText("Phone_Gift_Send_Day_Count_2"), 0, self.nMaxSendGiftCount))
|
||||
self:RefreshItemList()
|
||||
end
|
||||
function DatingGiftCtrl:RefreshItemList()
|
||||
self.tbItemData = {}
|
||||
local listCount = 0
|
||||
local foreachAffinityGift = function(mapData)
|
||||
local count = PlayerData.Item:GetItemCountByID(mapData.Id)
|
||||
if 0 < count then
|
||||
for i = 1, count do
|
||||
listCount = listCount + 1
|
||||
local itemData = ConfigTable.GetData_Item(mapData.Id)
|
||||
table.insert(self.tbItemData, {
|
||||
nTid = itemData.Id,
|
||||
nRarity = itemData.Rarity,
|
||||
nCount = 1,
|
||||
nExpire = itemData.ExpireType,
|
||||
favourLevel = self:GetGiftFavourLevelById(itemData.Id)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityGift, foreachAffinityGift)
|
||||
self._mapNode.goEmpty:SetActive(listCount == 0)
|
||||
self._mapNode.loopsvGiftList.gameObject:SetActive(0 < listCount)
|
||||
if 0 < listCount then
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
table.sort(self.tbItemData, function(a, b)
|
||||
if a.favourLevel == b.favourLevel then
|
||||
if a.nRarity == b.nRarity then
|
||||
return a.nTid < b.nTid
|
||||
end
|
||||
return a.nRarity < b.nRarity
|
||||
end
|
||||
return a.favourLevel < b.favourLevel
|
||||
end)
|
||||
self._mapNode.loopsvGiftList:Init(listCount, self, self.RefreshItemGrid, self.OnBtn_ClickItemGrid)
|
||||
end
|
||||
end
|
||||
function DatingGiftCtrl:RefreshItemGrid(grid)
|
||||
local nIndex = tonumber(grid.name) + 1
|
||||
local mapItem = self.tbItemData[nIndex]
|
||||
local nInstanceID = grid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
local itemObj = grid.transform:Find("btnGrid/AnimRoot/tc_item_02")
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(itemObj, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:SetItem(mapItem.nTid, mapItem.nRarity, nil, mapItem.nExpire)
|
||||
local imgAffinityLevel = grid.transform:Find("btnGrid/AnimRoot/tc_item_02/imgAffinityGiftLevel"):GetComponent("Image")
|
||||
local level = mapItem.favourLevel
|
||||
self:SetAtlasSprite(imgAffinityLevel, "11_ico", "zs_present_heart_" .. level)
|
||||
for nIdx, v in pairs(self.tbChooseItem) do
|
||||
if v ~= nil and v.nTid == mapItem.nTid and nIdx == nIndex then
|
||||
self.tbGridCtrl[nInstanceID]:SetMultiSelected_Blue(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DatingGiftCtrl:GetGiftFavourLevelById(itemId)
|
||||
if self.PreferenceData == nil then
|
||||
return 2
|
||||
end
|
||||
local itemData = ConfigTable.GetData("AffinityGift", itemId)
|
||||
for k, v in ipairs(itemData.Tags) do
|
||||
for k1, v1 in ipairs(self.PreferenceData.PreferTags) do
|
||||
if v == v1 then
|
||||
return 1
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, v in ipairs(itemData.Tags) do
|
||||
for k1, v1 in ipairs(self.PreferenceData.HateTags) do
|
||||
if v == v1 then
|
||||
return 3
|
||||
end
|
||||
end
|
||||
end
|
||||
return 2
|
||||
end
|
||||
function DatingGiftCtrl:GetCharAffinityAnim(nLevel, nNewLevel)
|
||||
local sVoKey = ""
|
||||
if nLevel == 1 then
|
||||
sVoKey = self.nFirstStageVoKey
|
||||
elseif nLevel == 2 then
|
||||
sVoKey = self.nSecondStageVoKey
|
||||
elseif nLevel == 3 then
|
||||
sVoKey = self.nThirdStageVoKey
|
||||
end
|
||||
if sVoKey ~= "" then
|
||||
return sVoKey
|
||||
end
|
||||
end
|
||||
function DatingGiftCtrl:PlayPreProgressAnim(mapBefore, mapAfter)
|
||||
local bMaxLv = mapAfter.nLevel == mapAfter.nMaxLevel
|
||||
local nAddLevel = mapAfter.nLevel - mapBefore.nLevel
|
||||
local nAddCount = 0
|
||||
if nAddLevel == 0 then
|
||||
nAddCount = 1
|
||||
elseif 0 < mapAfter.nExp then
|
||||
nAddCount = nAddLevel + 1
|
||||
else
|
||||
nAddCount = nAddLevel
|
||||
end
|
||||
local nAniTime = 0.2
|
||||
if nAddCount < 6 then
|
||||
nAniTime = 0.2
|
||||
elseif 6 <= nAddCount then
|
||||
nAniTime = 0.1
|
||||
end
|
||||
local nBeforeToMaxTime = nAniTime * (1 - mapBefore.nExp / mapBefore.nMaxExp)
|
||||
local nBeforeToAfterTime = nAniTime * ((mapAfter.nExp - mapBefore.nExp) / mapAfter.nMaxExp)
|
||||
local nZeroToAfterTime = nAniTime * mapAfter.nExp / mapAfter.nMaxExp
|
||||
local nAllTime = 0
|
||||
local height = self._mapNode.rectPreProgress.sizeDelta.y
|
||||
local sequence = DOTween.Sequence()
|
||||
for i = 1, nAddCount - 1 do
|
||||
local nTime = i == 1 and nBeforeToMaxTime or nAniTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:Append(self._mapNode.rectPreProgress:DOSizeDelta(Vector2(self.progressBarWidth, height), nTime))
|
||||
sequence:AppendCallback(function()
|
||||
self._mapNode.rectPreProgress.sizeDelta = Vector2(0, height)
|
||||
end)
|
||||
end
|
||||
if bMaxLv then
|
||||
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:Append(self._mapNode.rectPreProgress:DOSizeDelta(Vector2(self.progressBarWidth, height), nTime))
|
||||
elseif mapAfter.nExp > 0 then
|
||||
local nTime = 1 < nAddCount and nZeroToAfterTime or nBeforeToAfterTime
|
||||
nAllTime = nAllTime + nTime
|
||||
local width = self.progressBarWidth * mapAfter.nExp / mapAfter.nMaxExp
|
||||
sequence:Append(self._mapNode.rectPreProgress:DOSizeDelta(Vector2(width, height), nTime))
|
||||
elseif mapAfter.nExp == 0 then
|
||||
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:Append(self._mapNode.rectPreProgress:DOSizeDelta(Vector2(self.progressBarWidth, height), nTime))
|
||||
sequence:AppendCallback(function()
|
||||
self._mapNode.rectPreProgress.sizeDelta = Vector2(0, height)
|
||||
end)
|
||||
end
|
||||
sequence:SetUpdate(true)
|
||||
nAllTime = nAllTime + 0.2
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAllTime)
|
||||
end
|
||||
function DatingGiftCtrl:PlayProgressAnim(mapBefore, mapAfter)
|
||||
local bMaxLv = mapAfter.nLevel == mapAfter.nMaxLevel
|
||||
local nAddLevel = mapAfter.nLevel - mapBefore.nLevel
|
||||
local nAddCount = 0
|
||||
if nAddLevel == 0 then
|
||||
nAddCount = 1
|
||||
elseif 0 < mapAfter.nExp then
|
||||
nAddCount = nAddLevel + 1
|
||||
else
|
||||
nAddCount = nAddLevel
|
||||
end
|
||||
local nAniTime = 0.2
|
||||
if nAddCount < 6 then
|
||||
nAniTime = 0.2
|
||||
elseif 6 <= nAddCount then
|
||||
nAniTime = 0.1
|
||||
end
|
||||
local nBeforeToMaxTime = nAniTime * (1 - mapBefore.nExp / mapBefore.nMaxExp)
|
||||
local nBeforeToAfterTime = nAniTime * ((mapAfter.nExp - mapBefore.nExp) / mapAfter.nMaxExp)
|
||||
local nZeroToAfterTime = nAniTime * mapAfter.nExp / mapAfter.nMaxExp
|
||||
local nAllTime = 0
|
||||
local heigth = self._mapNode.rectPreProgress.sizeDelta.y
|
||||
local sequence = DOTween.Sequence()
|
||||
for i = 1, nAddCount - 1 do
|
||||
local nTime = i == 1 and nBeforeToMaxTime or nAniTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, heigth), nTime))
|
||||
sequence:AppendCallback(function()
|
||||
self._mapNode.rectProgress.sizeDelta = Vector2(0, heigth)
|
||||
end)
|
||||
end
|
||||
if bMaxLv then
|
||||
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, heigth), nTime))
|
||||
elseif mapAfter.nExp > 0 then
|
||||
local nTime = 1 < nAddCount and nZeroToAfterTime or nBeforeToAfterTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
local width = self.progressBarWidth * mapAfter.nExp / mapAfter.nMaxExp
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(width, heigth), nTime))
|
||||
elseif mapAfter.nExp == 0 then
|
||||
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, heigth), nTime))
|
||||
sequence:AppendCallback(function()
|
||||
self._mapNode.rectProgress.sizeDelta = Vector2(0, heigth)
|
||||
end)
|
||||
end
|
||||
sequence:SetUpdate(true)
|
||||
nAllTime = nAllTime + 0.2
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAllTime)
|
||||
end
|
||||
function DatingGiftCtrl:Awake()
|
||||
self._mapNode.btnPresentGray.gameObject:SetActive(false)
|
||||
self._mapNode.btnEndGray.gameObject:SetActive(false)
|
||||
self.tbGridCtrl = {}
|
||||
self.nMaxSendGiftCount = ConfigTable.GetConfigNumber("Dating_Max_Send_Gift_Count")
|
||||
self.nPresentAddition = ConfigTable.GetConfigNumber("Dating_Gift_Favorability_Addition")
|
||||
self.progressBarWidth = 400
|
||||
self.progressBarMinWidth = 23
|
||||
self.nFirstStageVoKey = ConfigTable.GetConfigValue("CharGiftFirstStageVoKey")
|
||||
self.nSecondStageVoKey = ConfigTable.GetConfigValue("CharGiftSecondStageVoKey")
|
||||
self.nThirdStageVoKey = ConfigTable.GetConfigValue("CharGiftThirdStageVoKey")
|
||||
end
|
||||
function DatingGiftCtrl:OnEnable()
|
||||
end
|
||||
function DatingGiftCtrl:OnDisable()
|
||||
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(objCtrl)
|
||||
self.tbGridCtrl[nInstanceId] = nil
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function DatingGiftCtrl:OnDestroy()
|
||||
end
|
||||
function DatingGiftCtrl:OnBtnClick_End()
|
||||
EventManager.Hit("CloseDatingPanel")
|
||||
end
|
||||
function DatingGiftCtrl:OnBtnClick_Present()
|
||||
if #self.tbItemData == 0 then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Gift_Send_Item_Empty"))
|
||||
return
|
||||
end
|
||||
local tbItems = {}
|
||||
local tbSendItems = {}
|
||||
for nIndex, v in pairs(self.tbChooseItem) do
|
||||
if nil == tbItems[v.nTid] then
|
||||
tbItems[v.nTid] = 1
|
||||
else
|
||||
tbItems[v.nTid] = tbItems[v.nTid] + 1
|
||||
end
|
||||
end
|
||||
for nId, nCount in pairs(tbItems) do
|
||||
table.insert(tbSendItems, {Tid = nId, Qty = nCount})
|
||||
end
|
||||
local callback = function(msgData)
|
||||
local level = self:GetGiftFeedbackLevel(tbSendItems)
|
||||
local nNewLevel = level
|
||||
if msgData.Info ~= nil then
|
||||
nNewLevel = msgData.Info.AffinityLevel
|
||||
end
|
||||
local sVoiceKey = self:GetCharAffinityAnim(level, nNewLevel)
|
||||
if sVoiceKey ~= nil then
|
||||
EventManager.Hit("DatingSendGiftFinish", sVoiceKey, msgData, self.curFavourLevel)
|
||||
end
|
||||
self._mapNode.btnPresentGray.gameObject:SetActive(true)
|
||||
self._mapNode.btnEndGray.gameObject:SetActive(true)
|
||||
self._mapNode.btnPresent.gameObject:SetActive(false)
|
||||
self._mapNode.btnEnd.gameObject:SetActive(false)
|
||||
self:RefreshSendGift()
|
||||
end
|
||||
if 0 < #tbSendItems then
|
||||
PlayerData.Dating:SendDatingSendGiftMsg(self.nCharId, tbSendItems, callback)
|
||||
else
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Gift_Send_Not_Select"))
|
||||
end
|
||||
end
|
||||
function DatingGiftCtrl:OnBtn_ClickItemGrid(grid)
|
||||
local nInstanceID = grid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
return
|
||||
end
|
||||
local nIndex = tonumber(grid.name) + 1
|
||||
local mapItem = self.tbItemData[nIndex]
|
||||
local itemCtrl = self.tbGridCtrl[nInstanceID]
|
||||
if self.tbChooseItem ~= nil and self.tbChooseItem[nIndex] ~= nil then
|
||||
itemCtrl:SetMultiSelected_Blue(false)
|
||||
self.tbChooseItem[nIndex] = nil
|
||||
else
|
||||
local nCount = 0
|
||||
if self.tbChooseItem ~= nil then
|
||||
for nIndex, v in pairs(self.tbChooseItem) do
|
||||
if v ~= nil then
|
||||
nCount = nCount + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
if nCount >= self.nMaxSendGiftCount then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Gift_Send_Max_Count"))
|
||||
return
|
||||
end
|
||||
self.tbChooseItem[nIndex] = {
|
||||
nTid = mapItem.nTid,
|
||||
itemCtrl = itemCtrl
|
||||
}
|
||||
itemCtrl:SetMultiSelected_Blue(true)
|
||||
end
|
||||
self:OnItemChosen()
|
||||
end
|
||||
function DatingGiftCtrl:OnItemChosen()
|
||||
local mapCharAffinity = ConfigTable.GetData("CharAffinityTemplate", self.nCharId)
|
||||
if mapCharAffinity == nil then
|
||||
return
|
||||
end
|
||||
local nSelectCount = 0
|
||||
local addedExp = 0
|
||||
for nIndex, v in pairs(self.tbChooseItem) do
|
||||
local data = ConfigTable.GetData("AffinityGift", v.nTid)
|
||||
local level = self:GetGiftFavourLevelById(v.nTid)
|
||||
local AffinityGiftPreferenceProp = ConfigTable.GetConfigNumberArray("AffinityGiftPreferenceProp")
|
||||
local nExp = data.BaseAffinity * (AffinityGiftPreferenceProp[level] / 100 + 1)
|
||||
addedExp = addedExp + nExp * self.nPresentAddition
|
||||
nSelectCount = nSelectCount + 1
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtGiftCount, orderedFormat(ConfigTable.GetUIText("Phone_Gift_Send_Day_Count_1"), nSelectCount, self.nMaxSendGiftCount))
|
||||
if self.curFavourLevel >= self.MaxAffinityLevel then
|
||||
return
|
||||
end
|
||||
local mapCharAffinity = ConfigTable.GetData("CharAffinityTemplate", self.nCharId)
|
||||
if mapCharAffinity == nil then
|
||||
return
|
||||
end
|
||||
local templateId = mapCharAffinity.TemplateId
|
||||
local addedLevel = self.curFavourLevel
|
||||
local preFinalExp = addedExp + self.curFavourExp
|
||||
if 0 < addedExp then
|
||||
while 0 < preFinalExp and not (addedLevel >= self.MaxAffinityLevel) do
|
||||
local needExp = CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1].NeedExp
|
||||
preFinalExp = preFinalExp - needExp
|
||||
if 0 <= preFinalExp then
|
||||
addedLevel = addedLevel + 1
|
||||
if addedLevel >= self.MaxAffinityLevel then
|
||||
preFinalExp = CacheTable.GetData("_AffinityLevel", templateId)[self.MaxAffinityLevel].NeedExp
|
||||
break
|
||||
end
|
||||
else
|
||||
preFinalExp = preFinalExp + needExp
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local sizeDelta = self._mapNode.rectPreProgress.sizeDelta
|
||||
local percent = 0
|
||||
if addedLevel > self.curFavourLevel then
|
||||
self._mapNode.rectProgress.gameObject:SetActive(false)
|
||||
percent = preFinalExp / CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1 > self.MaxAffinityLevel and self.MaxAffinityLevel or addedLevel + 1].NeedExp
|
||||
else
|
||||
self._mapNode.rectProgress.gameObject:SetActive(true)
|
||||
percent = (self.curFavourExp + addedExp) / CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1 > self.MaxAffinityLevel and self.MaxAffinityLevel or addedLevel + 1].NeedExp
|
||||
end
|
||||
if 1 <= percent then
|
||||
percent = 1
|
||||
end
|
||||
sizeDelta.x = self.progressBarWidth * percent
|
||||
self._mapNode.rectPreProgress.sizeDelta = sizeDelta
|
||||
local nShowFinalExp = self.curFavourExp + addedExp
|
||||
if addedLevel >= self.MaxAffinityLevel then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, ConfigTable.GetUIText("Phone_Gift_Affinity_Max_Level"))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", nShowFinalExp, CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1 > self.MaxAffinityLevel and self.MaxAffinityLevel or addedLevel + 1].NeedExp))
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAffinityLevel, addedLevel)
|
||||
self._mapNode.rectPreProgress.gameObject:SetActive(0 < addedExp)
|
||||
local mapLevelBefore = {
|
||||
nLevel = self.preFavourLevel,
|
||||
nMaxLevel = self.MaxAffinityLevel,
|
||||
nExp = self.preFavourExp,
|
||||
nMaxExp = CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel + 1 > self.MaxAffinityLevel and self.MaxAffinityLevel or self.curFavourLevel + 1].NeedExp
|
||||
}
|
||||
self.preFavourLevel = addedLevel
|
||||
self.preFavourExp = preFinalExp
|
||||
local mapLevelAfter = {
|
||||
nLevel = addedLevel,
|
||||
nMaxLevel = self.MaxAffinityLevel,
|
||||
nExp = preFinalExp,
|
||||
nMaxExp = CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1 > self.MaxAffinityLevel and self.MaxAffinityLevel or addedLevel + 1].NeedExp
|
||||
}
|
||||
self:PlayPreProgressAnim(mapLevelBefore, mapLevelAfter)
|
||||
end
|
||||
function DatingGiftCtrl:OnEvent_AffinityChange(charId, curLevel, lastFavourLevel)
|
||||
if self.nCharId == nil then
|
||||
return
|
||||
end
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(self.nCharId)
|
||||
self.curFavourLevel = curLevel
|
||||
self.curFavourExp = affinityData.Exp
|
||||
self._mapNode.rectProgress.gameObject:SetActive(true)
|
||||
self._mapNode.rectPreProgress.gameObject:SetActive(false)
|
||||
self:RefreshAffinityLevel()
|
||||
end
|
||||
return DatingGiftCtrl
|
||||
@@ -0,0 +1,112 @@
|
||||
local DatingLandmarkCtrl = class("DatingLandmarkCtrl", BaseCtrl)
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local LocalSettingData = require("GameCore.Data.LocalSettingData")
|
||||
DatingLandmarkCtrl._mapNodeConfig = {
|
||||
goBlur = {},
|
||||
canvasBlur = {sNodeName = "goBlur", sComponentName = "Canvas"},
|
||||
trRoot = {
|
||||
sNodeName = "----Actor2D_L2DInUI----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
trActor2D_PNG = {
|
||||
sNodeName = "----Actor2D_PNG----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
SlipInOutAnim = {sComponentName = "Animator"},
|
||||
goContent = {
|
||||
sNodeName = "----SafeAreaRoot----"
|
||||
},
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Select_Landmark_Title"
|
||||
},
|
||||
goLandMarkItem = {nCount = 3},
|
||||
btnGoto = {
|
||||
nCount = 3,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Goto"
|
||||
},
|
||||
txtBtnGoto = {
|
||||
nCount = 3,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Dating_Select_Landmark_Btn"
|
||||
},
|
||||
btnBack = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Back"
|
||||
}
|
||||
}
|
||||
DatingLandmarkCtrl._mapEventConfig = {
|
||||
[EventId.TransAnimInClear] = "OnEvent_TransAnimInClear"
|
||||
}
|
||||
function DatingLandmarkCtrl:SetLandmarkList()
|
||||
self.tbLandmark = PlayerData.Dating:GetRandomLandmark()
|
||||
for k, v in ipairs(self._mapNode.goLandMarkItem) do
|
||||
v.gameObject:SetActive(self.tbLandmark[k] ~= nil)
|
||||
if self.tbLandmark[k] ~= nil then
|
||||
self:SetLandmarkItem(self.tbLandmark[k], v)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DatingLandmarkCtrl:SetLandmarkItem(mapCfg, objItem)
|
||||
local imgLandmark = objItem.transform:Find("mask/imgLandmark"):GetComponent("Image")
|
||||
local txtName = objItem.transform:Find("txtName"):GetComponent("TMP_Text")
|
||||
local txtDesc = objItem.transform:Find("txtDesc"):GetComponent("TMP_Text")
|
||||
local imgTag = objItem.transform:Find("imgTag")
|
||||
local txtTag = objItem.transform:Find("imgTag/txtTag"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtTag, ConfigTable.GetUIText("Phone_Dating_Special_Event_Title"))
|
||||
NovaAPI.SetTMPText(txtName, mapCfg.Name)
|
||||
NovaAPI.SetTMPText(txtDesc, mapCfg.Desc)
|
||||
self:SetPngSprite(imgLandmark, mapCfg.Icon)
|
||||
local bHasNew = PlayerData.Dating:CheckHasNewEvent(self.nCharId, mapCfg.Id)
|
||||
imgTag.gameObject:SetActive(bHasNew)
|
||||
end
|
||||
function DatingLandmarkCtrl:Awake()
|
||||
end
|
||||
function DatingLandmarkCtrl:OnEnable()
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam) == "table" then
|
||||
self.nCharId = tbParam[1]
|
||||
end
|
||||
self._mapNode.goContent.gameObject:SetActive(false)
|
||||
self._mapNode.goBlur.gameObject:SetActive(true)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self._mapNode.goContent.gameObject:SetActive(true)
|
||||
local bL2d = LocalSettingData.mapData.UseLive2D
|
||||
self._mapNode.trRoot.gameObject:SetActive(bL2d)
|
||||
self._mapNode.trActor2D_PNG.gameObject:SetActive(not bL2d)
|
||||
if bL2d then
|
||||
Actor2DManager.SetActor2DInUI(self:GetPanelId(), self._mapNode.trRoot, self.nCharId, nil, true)
|
||||
else
|
||||
Actor2DManager.SetActor2D_PNG(self._mapNode.trActor2D_PNG, self:GetPanelId(), self.nCharId, nil)
|
||||
end
|
||||
self:SetLandmarkList()
|
||||
EventManager.Hit("RefreshSortingOrder", -100)
|
||||
NovaAPI.SetCanvasSortingName(self._mapNode.canvasBlur, self._panel._sSortingLayerName)
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function DatingLandmarkCtrl:OnDisable()
|
||||
end
|
||||
function DatingLandmarkCtrl:OnDestroy()
|
||||
end
|
||||
function DatingLandmarkCtrl:OnBtnClick_Goto(btn, nIndex)
|
||||
self.curAffinityInfo = PlayerData.Char:GetCharAffinityData(self.nCharId)
|
||||
local callback = function(msgData)
|
||||
self.datingData = msgData
|
||||
EventManager.Hit(EventId.SetTransition, 11)
|
||||
end
|
||||
self.nLandmarkId = self.tbLandmark[nIndex].Id
|
||||
PlayerData.Dating:SendDatingLandmarkSelectMsg(self.nCharId, self.nLandmarkId, callback)
|
||||
end
|
||||
function DatingLandmarkCtrl:OnBtnClick_Back()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.DatingLandmark)
|
||||
EventManager.Hit("RefreshSortingOrder")
|
||||
end
|
||||
function DatingLandmarkCtrl:OnEvent_TransAnimInClear()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.DatingLandmark)
|
||||
EventManager.Hit("RefreshSortingOrder")
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.Dating, self.nLandmarkId, self.nCharId, self.datingData.BeforeBranchId, self.curAffinityInfo, self.datingData.BranchAOptionIds, self.datingData.Change)
|
||||
end
|
||||
return DatingLandmarkCtrl
|
||||
@@ -0,0 +1,21 @@
|
||||
local DatingLandmarkPanel = class("DatingLandmarkPanel", BasePanel)
|
||||
DatingLandmarkPanel._bIsMainPanel = false
|
||||
DatingLandmarkPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Phone/DatingLandmarkPanel.prefab",
|
||||
sCtrlName = "Game.UI.Phone.Dating.DatingLandmarkCtrl"
|
||||
}
|
||||
}
|
||||
function DatingLandmarkPanel:Awake()
|
||||
end
|
||||
function DatingLandmarkPanel:OnEnable()
|
||||
end
|
||||
function DatingLandmarkPanel:OnAfterEnter()
|
||||
end
|
||||
function DatingLandmarkPanel:OnDisable()
|
||||
end
|
||||
function DatingLandmarkPanel:OnDestroy()
|
||||
end
|
||||
function DatingLandmarkPanel:OnRelease()
|
||||
end
|
||||
return DatingLandmarkPanel
|
||||
@@ -0,0 +1,22 @@
|
||||
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
|
||||
local DatingPanel = class("DatingPanel", BasePanel)
|
||||
DatingPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "Phone/DatingPanel.prefab",
|
||||
sCtrlName = "Game.UI.Phone.Dating.DatingCtrl"
|
||||
}
|
||||
}
|
||||
function DatingPanel:Awake()
|
||||
end
|
||||
function DatingPanel:OnEnable()
|
||||
end
|
||||
function DatingPanel:OnAfterEnter()
|
||||
end
|
||||
function DatingPanel:OnDisable()
|
||||
end
|
||||
function DatingPanel:OnDestroy()
|
||||
GameResourceLoader.Unload("ImageAvg")
|
||||
end
|
||||
function DatingPanel:OnRelease()
|
||||
end
|
||||
return DatingPanel
|
||||
@@ -0,0 +1,388 @@
|
||||
local PhoneDatingCtrl = class("PhoneDatingCtrl", BaseCtrl)
|
||||
local LocalData = require("GameCore.Data.LocalData")
|
||||
local newDayTime = UTILS.GetDayRefreshTimeOffset()
|
||||
PhoneDatingCtrl._mapNodeConfig = {
|
||||
txtDatingTime = {sComponentName = "TMP_Text"},
|
||||
imgHeadIcon = {sComponentName = "Image"},
|
||||
txtCharName = {sComponentName = "TMP_Text"},
|
||||
imgForce = {sComponentName = "Image"},
|
||||
goAffinityProgress = {},
|
||||
rectProgress = {
|
||||
sNodeName = "imgProgress",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtProgress = {sComponentName = "TMP_Text"},
|
||||
imgAffinity = {sComponentName = "Image"},
|
||||
txtLevel = {sComponentName = "TMP_Text"},
|
||||
txtAffinity = {sComponentName = "TMP_Text"},
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Phone_Dating_Special_Event_Title"
|
||||
},
|
||||
datingEventLSV = {
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnCharDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_CharDetail"
|
||||
},
|
||||
txtBtnCharDetail = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Phone_Dating_Char_Detail_Btn"
|
||||
},
|
||||
btnStartDating = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_StartDating"
|
||||
},
|
||||
txtBtnStartDating = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Phone_Dating_Start_Dating_Btn"
|
||||
},
|
||||
btnDatingGray = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_DatingGray"
|
||||
},
|
||||
txtBtnDatingGray = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Phone_Char_Dating_Count_Max"
|
||||
},
|
||||
goEventDetail = {},
|
||||
goBlur = {},
|
||||
goWindow = {},
|
||||
aniWindow = {sNodeName = "goWindow", sComponentName = "Animator"},
|
||||
btnBg = {
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtnClick_Close"
|
||||
},
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Phone_Dating_Event_Window_Title"
|
||||
},
|
||||
imgChar = {sComponentName = "Image"},
|
||||
imgSpCg = {sComponentName = "Image"},
|
||||
txtLandmark = {sComponentName = "TMP_Text"},
|
||||
txtEventName = {sComponentName = "TMP_Text"},
|
||||
txtDesc = {sComponentName = "TMP_Text"},
|
||||
btnReward = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Reward"
|
||||
},
|
||||
btnLeft = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Left"
|
||||
},
|
||||
btnRight = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Right"
|
||||
},
|
||||
goPageDot = {},
|
||||
goPage = {nCount = 8},
|
||||
btnClose = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Close"
|
||||
}
|
||||
}
|
||||
PhoneDatingCtrl._mapEventConfig = {}
|
||||
PhoneDatingCtrl._mapRedDotConfig = {}
|
||||
function PhoneDatingCtrl:Refresh(nCharId)
|
||||
self.nCharId = nCharId
|
||||
local mapCharacter = ConfigTable.GetData_Character(nCharId)
|
||||
if mapCharacter ~= nil then
|
||||
local nSkinId = mapCharacter.DefaultSkinId
|
||||
local mapSkin = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
if mapSkin ~= nil then
|
||||
self:SetPngSprite(self._mapNode.imgHeadIcon, mapSkin.Icon .. AllEnum.CharHeadIconSurfix.S)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCharName, mapCharacter.Name)
|
||||
local mapCharDes = ConfigTable.GetData("CharacterDes", nCharId)
|
||||
if mapCharDes then
|
||||
local mapForceCfg = ConfigTable.GetData("Force", mapCharDes.Force)
|
||||
if mapForceCfg ~= nil then
|
||||
end
|
||||
end
|
||||
end
|
||||
self._mapNode.goEventDetail.gameObject:SetActive(false)
|
||||
local nCount, nAllCount = PlayerData.Dating:GetDatingCount()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDatingTime, orderedFormat(ConfigTable.GetUIText("Dating_Day_Count"), nCount, nAllCount))
|
||||
local bDating = PlayerData.Dating:CheckDating(self.nCharId)
|
||||
self._mapNode.btnStartDating.gameObject:SetActive(not bDating)
|
||||
self._mapNode.btnDatingGray.gameObject:SetActive(bDating)
|
||||
self.mapEvent = PlayerData.Dating:GetLimitedEventList(self.nCharId)
|
||||
self.mapUnlockEvent = {}
|
||||
for k, v in ipairs(self.mapEvent) do
|
||||
if v.Status ~= AllEnum.DatingEventStatus.Lock then
|
||||
table.insert(self.mapUnlockEvent, v)
|
||||
end
|
||||
end
|
||||
self._mapNode.datingEventLSV.gameObject:SetActive(#self.mapEvent > 0)
|
||||
self._mapNode.datingEventLSV:SetAnim(0.1)
|
||||
self._mapNode.datingEventLSV:Init(#self.mapEvent, self, self.OnGridRefresh, self.OnGridClick)
|
||||
self:RefreshAffinity()
|
||||
end
|
||||
function PhoneDatingCtrl:RefreshAffinity()
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(self.nCharId)
|
||||
if affinityData == nil then
|
||||
return
|
||||
end
|
||||
self.curFavourLevel = affinityData.Level
|
||||
self.curFavourExp = affinityData.Exp
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLevel, self.curFavourLevel)
|
||||
if self.curFavourLevel < ConfigTable.GetConfigNumber("PhoneDatingAffinityLimit") then
|
||||
self._mapNode.btnStartDating.gameObject:SetActive(false)
|
||||
self._mapNode.btnDatingGray.gameObject:SetActive(true)
|
||||
local sTip = orderedFormat(ConfigTable.GetUIText("Phone_Dating_Affinity_Limit"), ConfigTable.GetConfigNumber("PhoneDatingAffinityLimit"))
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBtnDatingGray, sTip)
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtBtnDatingGray, ConfigTable.GetUIText("Phone_Char_Dating_Count_Max"))
|
||||
end
|
||||
local mapCharAffinity = ConfigTable.GetData("CharAffinityTemplate", self.nCharId)
|
||||
if mapCharAffinity == nil then
|
||||
return
|
||||
end
|
||||
local templateId = mapCharAffinity.TemplateId
|
||||
self.MaxAffinityLevel = PlayerData.Char:GetMaxAffinityLevel(templateId)
|
||||
local percent = 0
|
||||
local level = self.curFavourLevel >= self.MaxAffinityLevel and self.MaxAffinityLevel or self.curFavourLevel + 1
|
||||
local data = CacheTable.GetData("_AffinityLevel", templateId)[level]
|
||||
local curData = CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel]
|
||||
if self.curFavourLevel >= self.MaxAffinityLevel then
|
||||
percent = 1
|
||||
else
|
||||
percent = self.curFavourExp / data.NeedExp
|
||||
end
|
||||
local sizeDelta = self._mapNode.rectProgress.sizeDelta
|
||||
sizeDelta.x = self.progressBarWidth * percent < self.progressBarMinWidth and self.progressBarMinWidth or self.progressBarWidth * percent
|
||||
self._mapNode.rectProgress.sizeDelta = sizeDelta
|
||||
self._mapNode.rectProgress.gameObject:SetActive(self.curFavourExp > 0 or self.curFavourLevel >= self.MaxAffinityLevel)
|
||||
if self.curFavourLevel >= self.MaxAffinityLevel then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, ConfigTable.GetUIText("Phone_Gift_Affinity_Max_Level"))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", self.curFavourExp, data.NeedExp))
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtAffinity, curData.AffinityLevelName)
|
||||
self:SetPngSprite(self._mapNode.imgAffinity, curData.AffinityLevelIcon .. "_s")
|
||||
end
|
||||
function PhoneDatingCtrl:OnGridRefresh(goGrid, goIndex)
|
||||
local nIndex = goIndex + 1
|
||||
local eventData = self.mapEvent[nIndex]
|
||||
if eventData ~= nil then
|
||||
local mapCfg = ConfigTable.GetData("DatingCharacterEvent", eventData.Id)
|
||||
if mapCfg ~= nil then
|
||||
local imgLock = goGrid.transform:Find("btnGrid/AnimRoot/imgLock")
|
||||
local goUnlock = goGrid.transform:Find("btnGrid/AnimRoot/goUnlock")
|
||||
local imgSpCg = goUnlock.transform:Find("mask/imgSpCg"):GetComponent("Image")
|
||||
local txtDesc = goGrid.transform:Find("btnGrid/AnimRoot/txtDesc"):GetComponent("TMP_Text")
|
||||
local imgTitleBg = goGrid.transform:Find("btnGrid/AnimRoot/imgTitleBg")
|
||||
local txtLandmark = goGrid.transform:Find("btnGrid/AnimRoot/imgTitleBg/txtLandmark"):GetComponent("TMP_Text")
|
||||
local redDot = goGrid.transform:Find("btnGrid/AnimRoot/goUnlock/redDotDatingReward")
|
||||
RedDotManager.RegisterNode(RedDotDefine.Phone_Dating_Reward, {
|
||||
self.nCharId,
|
||||
eventData.Id
|
||||
}, redDot, nil, nil, true)
|
||||
local bLock = eventData.Status == AllEnum.DatingEventStatus.Lock
|
||||
imgTitleBg.gameObject:SetActive(not bLock)
|
||||
imgLock.gameObject:SetActive(bLock)
|
||||
goUnlock.gameObject:SetActive(not bLock)
|
||||
if bLock then
|
||||
NovaAPI.SetTMPText(txtDesc, mapCfg.Clue)
|
||||
else
|
||||
NovaAPI.SetTMPText(txtDesc, mapCfg.Name)
|
||||
local mapLandmark = ConfigTable.GetData("DatingLandmark", eventData.LandMark)
|
||||
if mapLandmark ~= nil then
|
||||
NovaAPI.SetTMPText(txtLandmark, mapLandmark.Name)
|
||||
end
|
||||
if mapCfg.CG ~= nil then
|
||||
local sCGPath = "Icon/DatingEventCG/" .. mapCfg.CG
|
||||
self:SetPngSprite(imgSpCg, sCGPath)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function PhoneDatingCtrl:OnGridClick(goGrid, goIndex)
|
||||
local nSelectIndex = goIndex + 1
|
||||
local eventData = self.mapEvent[nSelectIndex]
|
||||
if eventData.Status == AllEnum.DatingEventStatus.Lock then
|
||||
return
|
||||
end
|
||||
for k, v in ipairs(self.mapUnlockEvent) do
|
||||
if v.Id == eventData.Id then
|
||||
self.nSelectIndex = k
|
||||
end
|
||||
end
|
||||
self:OpenWindow()
|
||||
end
|
||||
function PhoneDatingCtrl:OpenWindow()
|
||||
self._mapNode.goEventDetail.gameObject:SetActive(true)
|
||||
self._mapNode.goWindow.gameObject:SetActive(false)
|
||||
self._mapNode.goBlur.gameObject:SetActive(true)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
self._mapNode.goWindow.gameObject:SetActive(true)
|
||||
self._mapNode.aniWindow:Play("t_window_04_t_in")
|
||||
EventManager.Hit("OpenEventDetailWindow", true)
|
||||
self:RefreshEventContent()
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
end
|
||||
function PhoneDatingCtrl:CloseWindow()
|
||||
EventManager.Hit("OpenEventDetailWindow", false)
|
||||
self._mapNode.aniWindow:Play("t_window_04_t_out")
|
||||
self._mapNode.goBlur.gameObject:SetActive(false)
|
||||
local nAnimLen = NovaAPI.GetAnimClipLength(self._mapNode.aniWindow, {
|
||||
"t_window_04_t_out"
|
||||
})
|
||||
self:AddTimer(1, nAnimLen, function()
|
||||
self._mapNode.goEventDetail.gameObject:SetActive(false)
|
||||
end, true, true, true)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAnimLen)
|
||||
end
|
||||
function PhoneDatingCtrl:RefreshEventContent()
|
||||
self.curEventData = self.mapUnlockEvent[self.nSelectIndex]
|
||||
local mapCfg = ConfigTable.GetData("DatingCharacterEvent", self.curEventData.Id)
|
||||
if mapCfg ~= nil then
|
||||
local nCharId = tonumber(mapCfg.DatingEventParams[1])
|
||||
local nLandmarkId = tonumber(mapCfg.DatingEventParams[2])
|
||||
local mapLandmark = ConfigTable.GetData("DatingLandmark", nLandmarkId)
|
||||
if mapLandmark ~= nil then
|
||||
local sLandmark = mapLandmark.Name
|
||||
NovaAPI.SetTMPText(self._mapNode.txtLandmark, sLandmark)
|
||||
end
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
|
||||
local mapSkin = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
if mapSkin ~= nil then
|
||||
self:SetPngSprite(self._mapNode.imgChar, mapSkin.Icon .. AllEnum.CharHeadIconSurfix.XXL)
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtEventName, mapCfg.Name)
|
||||
if self.curEventData.Status == AllEnum.DatingEventStatus.Lock then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDesc, mapCfg.Clue)
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDesc, mapCfg.Memory)
|
||||
end
|
||||
self._mapNode.btnReward.gameObject:SetActive(self.curEventData.Status == AllEnum.DatingEventStatus.Unlock)
|
||||
if mapCfg.CG ~= nil then
|
||||
local sCGPath = "Icon/DatingEventCG/" .. mapCfg.CG
|
||||
self:SetPngSprite(self._mapNode.imgSpCg, sCGPath)
|
||||
end
|
||||
end
|
||||
for k, v in ipairs(self._mapNode.goPage) do
|
||||
v.gameObject:SetActive(k <= #self.mapUnlockEvent)
|
||||
if k <= #self.mapUnlockEvent then
|
||||
local goCur = v.gameObject.transform:Find("imgPage")
|
||||
goCur.gameObject:SetActive(k == self.nSelectIndex)
|
||||
end
|
||||
end
|
||||
self._mapNode.btnLeft.gameObject:SetActive(self.nSelectIndex > 1)
|
||||
self._mapNode.btnRight.gameObject:SetActive(self.nSelectIndex < #self.mapUnlockEvent)
|
||||
end
|
||||
function PhoneDatingCtrl:Awake()
|
||||
self.progressBarWidth = 253
|
||||
self.progressBarMinWidth = 0
|
||||
end
|
||||
function PhoneDatingCtrl:FadeIn()
|
||||
end
|
||||
function PhoneDatingCtrl:FadeOut()
|
||||
end
|
||||
function PhoneDatingCtrl:OnEnable()
|
||||
end
|
||||
function PhoneDatingCtrl:OnDisable()
|
||||
end
|
||||
function PhoneDatingCtrl:OnDestroy()
|
||||
end
|
||||
function PhoneDatingCtrl:OnRelease()
|
||||
end
|
||||
function PhoneDatingCtrl:OnBtnClick_CharDetail()
|
||||
if nil ~= self.nCharId then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgPanel, PanelId.CharacterRelation, self.nCharId)
|
||||
end
|
||||
end
|
||||
function PhoneDatingCtrl:OnBtnClick_StartDating()
|
||||
local nCount, nAllCount = PlayerData.Dating:GetDatingCount()
|
||||
if nAllCount <= nCount then
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Dating_Day_Count_Max"))
|
||||
return
|
||||
end
|
||||
local bDating = PlayerData.Dating:CheckDating(self.nCharId)
|
||||
if bDating then
|
||||
return
|
||||
end
|
||||
local mapCharCfg = ConfigTable.GetData_Character(self.nCharId)
|
||||
if mapCharCfg ~= nil then
|
||||
local TipsTime = LocalData.GetPlayerLocalData("PhoneDating_Tips_Time")
|
||||
local _tipDay = 0
|
||||
if TipsTime ~= nil then
|
||||
_tipDay = tonumber(TipsTime)
|
||||
end
|
||||
local curTimeStamp = CS.ClientManager.Instance.serverTimeStampWithTimeZone
|
||||
local fixedTimeStamp = curTimeStamp + newDayTime * 3600
|
||||
local nYear = tonumber(os.date("!%Y", fixedTimeStamp))
|
||||
local nMonth = tonumber(os.date("!%m", fixedTimeStamp))
|
||||
local nDay = tonumber(os.date("!%d", fixedTimeStamp))
|
||||
local nowD = nYear * 366 + nMonth * 31 + nDay
|
||||
if nowD == _tipDay then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DatingLandmark, self.nCharId)
|
||||
else
|
||||
local sTip = orderedFormat(ConfigTable.GetUIText("Phone_Dating_Start_Tip_Text"), mapCharCfg.Name)
|
||||
local isSelectAgain = false
|
||||
local confirmCallback = function()
|
||||
if isSelectAgain then
|
||||
local _curTimeStamp = CS.ClientManager.Instance.serverTimeStampWithTimeZone
|
||||
local _fixedTimeStamp = _curTimeStamp + newDayTime * 3600
|
||||
local _nYear = tonumber(os.date("!%Y", _fixedTimeStamp))
|
||||
local _nMonth = tonumber(os.date("!%m", _fixedTimeStamp))
|
||||
local _nDay = tonumber(os.date("!%d", _fixedTimeStamp))
|
||||
local _nowD = _nYear * 366 + _nMonth * 31 + _nDay
|
||||
LocalData.SetPlayerLocalData("PhoneDating_Tips_Time", tostring(_nowD))
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.DatingLandmark, self.nCharId)
|
||||
end
|
||||
local againCallback = function(isSelect)
|
||||
isSelectAgain = isSelect
|
||||
end
|
||||
local msg = {
|
||||
nType = AllEnum.MessageBox.Confirm,
|
||||
sTitle = ConfigTable.GetUIText("Phone_Dating_Start_Tip_Title"),
|
||||
sContent = sTip,
|
||||
callbackConfirm = confirmCallback,
|
||||
callbackAgain = againCallback
|
||||
}
|
||||
EventManager.Hit(EventId.OpenMessageBox, msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
function PhoneDatingCtrl:OnBtnClick_DatingGray()
|
||||
local sTip
|
||||
if self.curFavourLevel < ConfigTable.GetConfigNumber("PhoneDatingAffinityLimit") then
|
||||
sTip = orderedFormat(ConfigTable.GetUIText("Phone_Dating_Affinity_Limit"), ConfigTable.GetConfigNumber("PhoneDatingAffinityLimit"))
|
||||
else
|
||||
sTip = ConfigTable.GetUIText("Phone_Dating_Day_Max_Count")
|
||||
end
|
||||
EventManager.Hit(EventId.OpenMessageBox, sTip)
|
||||
end
|
||||
function PhoneDatingCtrl:OnBtnClick_Reward()
|
||||
local callback = function()
|
||||
self.mapEvent = PlayerData.Dating:GetLimitedEventList(self.nCharId)
|
||||
self.mapUnlockEvent = {}
|
||||
for k, v in ipairs(self.mapEvent) do
|
||||
if v.Status ~= AllEnum.DatingEventStatus.Lock then
|
||||
table.insert(self.mapUnlockEvent, v)
|
||||
end
|
||||
end
|
||||
self._mapNode.datingEventLSV:Init(#self.mapEvent, self, self.OnGridRefresh, self.OnGridClick)
|
||||
self:RefreshEventContent()
|
||||
end
|
||||
PlayerData.Dating:SendReceiveDatingEventRewardMsg(self.nCharId, self.curEventData.Id, callback)
|
||||
end
|
||||
function PhoneDatingCtrl:OnBtnClick_Left()
|
||||
self.nSelectIndex = self.nSelectIndex - 1
|
||||
self:RefreshEventContent()
|
||||
end
|
||||
function PhoneDatingCtrl:OnBtnClick_Right()
|
||||
self.nSelectIndex = self.nSelectIndex + 1
|
||||
self:RefreshEventContent()
|
||||
end
|
||||
function PhoneDatingCtrl:OnBtnClick_Close()
|
||||
self:CloseWindow()
|
||||
end
|
||||
return PhoneDatingCtrl
|
||||
Reference in New Issue
Block a user