using AX.InputSystem; using AX.MessageSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class FireManSkillTogge : MonoBehaviour { public FireManSkills fireManSkills; private GameObject chooseObj; private GameObject lastchoose; public bool flag = false; void Awake() { GetComponent().onValueChanged.AddListener(RespondFun); //MessageDispatcher.AddListener("SelectChange", SetFireManSkills); //MessageDispatcher.AddListener("SetFireManSkills", SetFireManSkills); } private void SetFireManSkills(IMessage obj) { //chooseObj = (GameObject)obj.Data; //Debug.Log(chooseObj.GetComponent().workType.ToString() + chooseObj.name); //if (fireManSkills == chooseObj.GetComponent().workType) //{ // GetComponent().isOn = true; //} //else //{ // GetComponent().isOn = false; //} // GetComponent().interactable = (chooseObj.GetComponent().EnabledSkills & fireManSkills) != 0; //lastchoose = chooseObj; } public void RespondFun(bool value) { if (FireManSkillsPanel.GetInstance.IsChange) { return; } if (SelectedObjs.selectedCharacters.Count > 0) { SelectedObjs.selectedCharacters[0].GetComponent().workType = value ? fireManSkills : FireManSkills.None; //如果技能按钮是出水 if (fireManSkills == FireManSkills.SprayWater) { if (value) {//如果正在出水,不显示出水选择按钮直接根据消防员当前出水粒子发送出水消息 if (flag == true) { MessageDispatcher.SendMessage("CHANGE_PARTICLE_TYPE_COMMAND", new ParticleTypeCmdArgs() { ParticleType = SelectedObjs.selectedCharacters[0].GetComponent().particleenum }); flag = false; return; } } } // SelectedObjs.selectedCharacters[0].GetComponent().workType = value ? fireManSkills : FireManSkills.None; if (RecordEvent.IsRecord()) { string json = JsonUtility.ToJson(new PowerSkillRecordEventData() { GameId = SelectedObjs.selectedCharacters[0].GetComponent().gameObjID, EnabledSkills = (int)SelectedObjs.selectedCharacters[0].GetComponent().EnabledSkills, CurrentSkill = (int)fireManSkills, Skill = fireManSkills.ToString(), ArgData = value }); RecordEvent.AddEventData(SelectedObjs.selectedCharacters[0].GetComponent().gameObjType, RecordEventType.FireManSkill, json); } MessageDispatcher.SendMessage(SelectedObjs.selectedCharacters[0].GetComponent().gameObjID, gameObject.name, value); } } private void OnDestroy() { //MessageDispatcher.RemoveListener("SetFireManSkills", SetFireManSkills); } }