65 lines
2 KiB
Lua
65 lines
2 KiB
Lua
|
local XUiPanelSkillTeach = XLuaUiManager.Register(XLuaUi, "UiPanelSkillTeach")
|
|||
|
local CSXAudioManager = CS.XAudioManager
|
|||
|
function XUiPanelSkillTeach:OnAwake()
|
|||
|
self:AutoAddListener()
|
|||
|
self.BtnTeach.gameObject:SetActiveEx(false)
|
|||
|
end
|
|||
|
|
|||
|
function XUiPanelSkillTeach:OnStart(characterId)
|
|||
|
self.CharacterId = characterId
|
|||
|
end
|
|||
|
|
|||
|
function XUiPanelSkillTeach:OnEnable()
|
|||
|
XSoundManager.PlaySoundByType(CSXAudioManager.UiMainNeedPlayedBgmCueId,XSoundManager.SoundType.BGM)
|
|||
|
self:UpdateView()
|
|||
|
end
|
|||
|
|
|||
|
function XUiPanelSkillTeach:AutoAddListener()
|
|||
|
self:RegisterClickEvent(self.BtnTanchuangClose, self.OnBtnTanchuangCloseClick)
|
|||
|
self:RegisterClickEvent(self.BtnTeach, self.OnBtnTeachClick)
|
|||
|
self:RegisterClickEvent(self.BtnFight, self.OnBtnFightClick)
|
|||
|
end
|
|||
|
|
|||
|
function XUiPanelSkillTeach:OnBtnTanchuangCloseClick()
|
|||
|
self:Close()
|
|||
|
end
|
|||
|
|
|||
|
function XUiPanelSkillTeach:OnBtnTeachClick()
|
|||
|
local characterId = self.CharacterId
|
|||
|
local url = XCharacterConfigs.GetCharTeachWebUrlById(characterId)
|
|||
|
self:UpdateWebView(url)
|
|||
|
end
|
|||
|
|
|||
|
function XUiPanelSkillTeach:OnBtnFightClick()
|
|||
|
local characterId = self.CharacterId
|
|||
|
XDataCenter.FubenManager.EnterSkillTeachFight(characterId)
|
|||
|
end
|
|||
|
|
|||
|
function XUiPanelSkillTeach:UpdateView()
|
|||
|
local characterId = self.CharacterId
|
|||
|
|
|||
|
local data = XCharacterConfigs.GetCharTeachById(characterId)
|
|||
|
if not data then return end
|
|||
|
|
|||
|
self:SetUiSprite(self.ImgSkill, data.TeachIcon)
|
|||
|
self.TxtSkillName.text = data.Title
|
|||
|
self.TxtSkillDesc.text = string.format("%s%s", " ", data.Description)
|
|||
|
end
|
|||
|
|
|||
|
function XUiPanelSkillTeach:UpdateWebView(url)
|
|||
|
if self.CurUrl and self.CurUrl == url then
|
|||
|
return
|
|||
|
end
|
|||
|
self.CurUrl = url
|
|||
|
|
|||
|
if self.WebViewPanel then
|
|||
|
CS.UnityEngine.Object.Destroy(self.WebViewPanel.gameObject)
|
|||
|
self.WebViewPanel = nil
|
|||
|
end
|
|||
|
|
|||
|
CS.XTool.WaitNativeCoroutine(CS.UnityEngine.WaitForEndOfFrame(), function ()
|
|||
|
self.WebViewPanel = CS.UnityEngine.Object.Instantiate(self.PanelWebView, self.PanelWebView.parent)
|
|||
|
CS.XWebView.Load(self.WebViewPanel.gameObject, self.CurUrl)
|
|||
|
end)
|
|||
|
end
|