2021-04-21 13:12:04 +08:00
|
|
|
|
require("Base/BasePanel")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
DialoguePopup = Inherit(BasePanel)
|
|
|
|
|
local this = DialoguePopup
|
|
|
|
|
|
|
|
|
|
--- 角色所在位置0 --> 左边 1 --> 右边
|
|
|
|
|
local roleDir = 0
|
|
|
|
|
local opId = 0
|
|
|
|
|
local static_callBack
|
|
|
|
|
local chapterDataConfig = ConfigManager.GetConfig(ConfigName.ChapterEventPointConfig)
|
|
|
|
|
local chapterOptionData = ConfigManager.GetConfig(ConfigName.ChapterOptionConfig)
|
|
|
|
|
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function DialoguePopup:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.btnBack = Util.GetGameObject(self.gameObject, "mask")
|
|
|
|
|
this.dialogueRoot = Util.GetGameObject(self.gameObject, "dialog")
|
|
|
|
|
this.talkText = Util.GetGameObject(this.dialogueRoot, "Text"):GetComponent("Text")
|
|
|
|
|
this.roleIcon = Util.GetGameObject(this.dialogueRoot, "role"):GetComponent("Image")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function DialoguePopup:BindEvent()
|
|
|
|
|
Util.AddClick(this.btnBack, function()
|
|
|
|
|
-- 是否是最后一段对话
|
|
|
|
|
local isEnd = chapterOptionData[opId].JumpType == 5
|
|
|
|
|
if isEnd then
|
|
|
|
|
if static_callBack then
|
|
|
|
|
static_callBack()
|
|
|
|
|
static_callBack = nil
|
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end
|
|
|
|
|
else -- 继续对话
|
|
|
|
|
StoryManager.StoryJumpType(opId, this)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function DialoguePopup:AddListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function DialoguePopup:RemoveListener()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DialoguePopup:OnOpen(Id, func)
|
|
|
|
|
if func then
|
|
|
|
|
static_callBack = func
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not Id or Id == 0 then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
Log("请检查剧情Id配置是否正确")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local showType = chapterDataConfig[Id].ShowType
|
2021-01-26 17:08:39 +08:00
|
|
|
|
local showValues = GetLanguageStrById(chapterDataConfig[Id].ShowValues)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
opId = chapterDataConfig[Id].Option[1]
|
|
|
|
|
|
|
|
|
|
local contents = string.split(showValues, "|")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---设置对话内容s
|
|
|
|
|
this.talkText.text = contents[2]
|
|
|
|
|
local resId = tonumber(contents[1])
|
|
|
|
|
|
|
|
|
|
-- 配音资源名
|
|
|
|
|
local voice = chapterDataConfig[Id].VoiceRes
|
2021-04-08 17:32:40 +08:00
|
|
|
|
if IS_PLAY_VOICE and voice then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 使用相同通道播放,避免跳过剧情导致音效重复
|
|
|
|
|
SoundManager.PlaySound(voice, nil, nil, 10)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--- 设置表现形式
|
|
|
|
|
if not artConfig[resId] then
|
2021-01-09 14:20:06 +08:00
|
|
|
|
Log("资源表里咩有这个资源" .. resId)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
return;
|
|
|
|
|
end
|
|
|
|
|
local resName = artConfig[resId].Name
|
|
|
|
|
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.roleIcon.sprite = this.spLoader:LoadSprite(resName)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function DialoguePopup:OnShow(...)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function DialoguePopup:OnSortingOrderChange()
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function DialoguePopup:OnClose()
|
|
|
|
|
-- 界面关闭,配音音效关闭
|
|
|
|
|
SoundManager.StopSoundByChannel(10)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function DialoguePopup:OnDestroy()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader:Destroy()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return DialoguePopup
|