public override void Init <T>(string name, UIInfo info, T arg) { base.Init(name, info, arg); string idStr = arg as string; if (!UiTools.IsNumeric(idStr)) { Debug.LogErrorFormat("对话id非法 = {0}", idStr); TouchClose(); return; } groupId = int.Parse(idStr); m_Index = 0; dialogueList = TableMgr.singleton.DialogueTable.GetDialogueByGroup(groupId); if (dialogueList == null) { Debug.LogErrorFormat("对话id非法 = {0}", idStr); TouchClose(); return; } dialogueRes = dialogueList[m_Index]; m_tip.gameObject.SetActive(false); m_person1.gameObject.SetActive(false); m_person2.gameObject.SetActive(false); //ShowNode.gameObject.SetActive(false); //gameObject.AddComponent<DelayCallBack>().SetAction(()=> //{ // ShowNode.gameObject.SetActive(true); // UIFresh(); // BgBtn.button.onClick.AddListener(UIFresh); //}, m_Dialogue.startDelay, true); //ShowNode.gameObject.SetActive(true); UIFresh(); BgBtn.button.onClick.AddListener(UIFresh); }
private void UIFresh() { //Debug.Log(m_Index); //if (!m_is_end && mOffset > 0) //{ // m_is_end = true; // m_tip.text.text = mText; // nextIcon.gameObject.SetActive(true); // return; //} if (m_Index < 0 || m_Index >= dialogueList.Count) { TouchClose(); if (m_Action != null) { m_Action(groupId); } return; } dialogueRes = dialogueList[m_Index]; //if (dialogueRes == null) //{ // TouchClose(); // if (m_Action != null) // { // m_Action(); // } // return; //} //if (m_Index >= m_Dialogue.dialogues.Length) //{ // BgBtn.button.interactable = false; // gameObject.AddComponent<DelayCallBack>().SetAction(() => // { // TouchClose(); // if (m_Action != null) // { // m_Action(); // } // }, m_Dialogue.actionDelay, true); // return; //} var npcRes1 = TableMgr.singleton.NpcTable.GetItemByID(dialogueRes.npc1); if (npcRes1 != null) { person1.gameObject.SetActive(true); person1.image.sprite = Global.gApp.gResMgr.LoadAssets <Sprite>(npcRes1.icon); if (dialogueRes.pos == 1) { m_nameText.text.text = LanguageMgr.GetText(npcRes1.tid_name); } } else { person1.gameObject.SetActive(false); } var npcRes2 = TableMgr.singleton.NpcTable.GetItemByID(dialogueRes.npc2); if (npcRes2 != null) { person2.gameObject.SetActive(true); person2.image.sprite = Global.gApp.gResMgr.LoadAssets <Sprite>(npcRes2.icon); if (dialogueRes.pos == 2) { m_nameText.text.text = LanguageMgr.GetText(npcRes2.tid_name); } } else { person2.gameObject.SetActive(false); } person1.image.color = ColorUtil.GetSpecialColor(dialogueRes.pos == 2, BlankColor); person2.image.color = ColorUtil.GetSpecialColor(dialogueRes.pos == 1, BlankColor); m_tip.gameObject.SetActive(true); //m_tip.text.text = LanguageMgr.GetText(dialogueRes.dialogues); m_tip.text.text = (dialogueRes.dialogues); //mText = dialogueRes.dialogues; //mText = LanguageMgr.GetText(dialogueRes.dialogues); //mNextChar = 0f; //mOffset = 0; //m_is_end = false; m_Index++; //nextIcon.gameObject.SetActive(false); //dialogueRes = TableMgr.singleton.DialogueTable.GetItemByID(dialogueRes.nextID); //nextIcon.gameObject.SetActive(dialogueRes != null); }