123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- 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;
- /// <summary>
- /// 是否任务激活
- /// </summary>
- public bool isTaskEnable = false;
- /// <summary>
- /// 对话开启条件 任务卡id
- /// </summary>
- public int requirementTaskId = 0;
- /// <summary>
- /// 对话开启条件 步骤id
- /// </summary>
- 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<SceneEventOpenDialog>();
- 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<TaskCardVo> taskVos = UserProxy.Instance.player.collectTaskCard.GetActivingCards();
- foreach (var item in taskVos)
- {
- if (int.Parse(item.typeId) != requirementTaskId)
- {
- continue;
- }
- List<Ins_TaskStepVo> 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<EventComponent>();
- 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>().text = taskName;
- btnInteractive = dialog.GetComponent<Button>();
- EventTriggerListener.Get(btnInteractive.gameObject).onClick = ((_btn) =>
- {
- OnClickInteractive();
- });
- }
-
- }
- public void OnTriggerExit(Collider collider)
- {
- if(btnInteractive)
- {
- btnInteractive.onClick.RemoveAllListeners();
- btnInteractive.gameObject.SetActive(false);
- }
- }
- public void EnableCollider()
- {
- }
- public void OnClickInteractive()
- {
- isEntry = true;
- EventComponent e = GameEntry.GetComponent<EventComponent>();
- e.FireNow(this, new BattleEventOpenDialog(npcId, stageIndex));
- btnInteractive.gameObject.SetActive(false);
- btnInteractive.onClick.RemoveAllListeners();
- }
- }
|