using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityGameFramework.Runtime; public class SceneEventOpenDialogLogic : MonoBehaviour { public string taskName = ""; public int npcId; public int stageIndex; public bool isNpc = false; public bool isOnly = true; /// /// 是否任务激活 /// public bool isTaskEnable = false; /// /// 对话开启条件 任务卡id /// public int requirementTaskId = 0; /// /// 对话开启条件 步骤id /// public int requirementStepId = 0; private bool isEntry = false; Button btnInteractive; private void Awake() { isEntry = false; } // Start is called before the first frame update void Start() { SceneEventOpenDialog info = this.gameObject.GetComponent(); this.taskName = info.taskName; this.npcId = info.npcId; this.stageIndex = info.stageIndex; this.isNpc = info.isNpc; this.isOnly = info.isOnly; this.isTaskEnable = info.isTaskEnable; this.requirementTaskId = info.requirementTaskId; this.requirementStepId = info.requirementStepId; if (isTaskEnable) { bool isOk = false; List taskVos = UserProxy.Instance.player.collectTaskCard.GetActivingCards(); foreach (var item in taskVos) { if (int.Parse(item.typeId) != requirementTaskId) { continue; } List stepVos = item.curSteps; foreach (var step in stepVos) { if (step.typeId == requirementStepId) { if (!step.isFinish()) { isOk = true; } } } } if (isOk) { this.gameObject.SetActive(true); } else { this.gameObject.SetActive(false); } } } public void OnTriggerEnter(Collider collider) { if (collider.gameObject.layer != LayerMask.NameToLayer("Player")) { return; } if(isOnly && isEntry) { return; } if(!isNpc) { EventComponent e = GameEntry.GetComponent(); e.FireNow(this, new BattleEventOpenDialog(npcId, stageIndex)); this.gameObject.SetActive(false); } else { BattleCanvas battlePanel = UI_BaseMainWindow.Instance().battleCanvas; GameObject interactive = battlePanel.transform.Find("Main/Interactive").gameObject; interactive.SetActive(true); for (int i=0; i < interactive.transform.childCount; ++i) { Transform tsfm = interactive.transform.GetChild(i); tsfm.gameObject.SetActive(false); } GameObject dialog = battlePanel.transform.Find("Main/Interactive/dialog").gameObject; dialog.SetActive(true); dialog.transform.Find("Text").GetComponent().text = taskName; btnInteractive = dialog.GetComponent