using AX.MessageSystem; using AX.NetworkSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class FireRobotSkillPanelController : MonoBehaviour { [Rename("选中的机器人")] public GameObject SelectRobot; [Rename("机器人技能panel")] public Transform RobotSkillPanel; [Rename("铺设水带")] public ToggleRecordByAC LayWaterHoseToggle; [Rename("收起管线")] public ToggleRecordByAC PackUpLine; [Rename("出水")] public ToggleRecordByAC SprayWater; [Rename("出泡沫")] public ToggleRecordByAC SprayFroth; [Rename("装备选择")] public ToggleRecordByAC EquipSelect; [Rename("背包")] public ToggleRecordByAC Backpack; /// /// 出水UI /// public Transform LayWaterPanel; private static FireRobotSkillPanelController instance; public static FireRobotSkillPanelController Instance { get { return instance; } } // Use this for initialization void Start () { instance = this; LayWaterHoseToggle.OutInterFaceToggle = LayWaterHoseChange; PackUpLine.OutInterFaceToggle = PickUpLineChange; SprayFroth.OutInterFaceToggle = SprayFrothChange; SprayWater.OutInterFaceToggle = SprayWaterChange; EquipSelect.OutInterFaceToggle = EquipSelectChange; Backpack.OutInterFaceToggle = BackpackChange; } // Update is called once per frame void Update () { } public void SelectFireRobot(GameObject select) { SelectRobot = select; switch (select.GetComponent().WorkType) { case FireRobotSkill.待命: ResertRobotSkill(); break; case FireRobotSkill.出水: SprayWater.GetComponent().interactable = true; SprayWater.GetComponent().isOn = true; break; case FireRobotSkill.出泡沫: SprayFroth.GetComponent().interactable = true; SprayFroth.GetComponent().isOn = true; break; case FireRobotSkill.铺设水带: LayWaterHoseToggle.GetComponent().isOn = true; break; case FireRobotSkill.收起水带: PackUpLine.GetComponent().isOn = true; break; case FireRobotSkill.装备选择: EquipSelect.GetComponent().isOn = true; break; case FireRobotSkill.背包: Backpack.GetComponent().isOn = true; break; default: break; } if (SelectRobot.GetComponent()) { FireRobotWaterHoseManage f = SelectRobot.GetComponent(); if (f.IsConnentWaterSource && f.hasFoamConnect) { SprayFroth.GetComponent().interactable = true; } else { SprayFroth.GetComponent().interactable = false; } if (f.IsConnentWaterSource && f.hasWaterConnect) { SprayWater.GetComponent().interactable = true; } else { SprayWater.GetComponent().interactable = false; } } if (SelectRobot.GetComponent().WorkType==FireRobotSkill.出水|| SelectRobot.GetComponent().WorkType==FireRobotSkill.出泡沫) { if (!LayWaterPanel.gameObject.activeInHierarchy) { LayWaterPanel.gameObject.SetActive(true); } GetComponent().SetShowEnable(); } } private void BackpackChange(bool value) { if (value) { //SelectRobot.GetComponent().WorkType = FireRobotSkill.背包; UIManager.ShowView(); } else { SelectRobot.GetComponent().WorkType = FireRobotSkill.待命; UIManager.HideView(); UIManager.HideView(); } } private void EquipSelectChange(bool value) { if (value) { //SelectRobot.GetComponent().WorkType = FireRobotSkill.装备选择; UIManager.ShowView(); UIManager.ShowView(); } else { SelectRobot.GetComponent().WorkType = FireRobotSkill.待命; UIManager.HideView(); UIManager.HideView(); } } private void SprayWaterChange(bool value) { FireRobotController controller = SelectRobot.GetComponent(); if (value) { //本身就是出水状态 if (controller.WorkType == FireRobotSkill.出水) { if(SelectRobot.GetComponent().pathFindEnable==false) { SelectRobot.GetComponent().pathFindEnable = true; LayWaterPanel.gameObject.SetActive(true); if (SelectRobot.GetComponent().ConnentSource) { if (SelectRobot.GetComponent().ConnentSource.GetComponent().hasover) { controller.DestoryPartical(); } else { //启用出水铺设 } GetComponent().SetShowEnable(); } } } //开启出水 else { if(SelectRobot.GetComponent().ConnentSource) { float remain = SelectRobot.GetComponent().CheckWaterRemain(SelectRobot.GetComponent().WaterSourceLine); if (!(remain>0||remain==-100)) { LoadPromptWin.Instance.LoadTextPromptWindow("剩余水量不足",1f); return; } } controller.WorkType = FireRobotSkill.出水; controller.SetParticleType(SprayParticleType.WaterStraight); // SelectRobot.GetComponent().pathFindEnable = true; LayWaterPanel.gameObject.SetActive(true); GetComponent().SetShowEnable(); if (SelectRobot.GetComponent().remainlenght <= 0) { LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f); } SelectRobot.GetComponent().StartSprayingLay(); //连接水源流量设置 //MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = true, ChangObjId = SelectRobot.GetComponent().gameObjID }); //出水同步 SpraySyncData spraysync = new SpraySyncData(); spraysync.SendUserID = CurrentUserInfo.mySelf.Id; spraysync.IsOn = true; spraysync.spraytype = SprayParticleType.WaterStraight; spraysync.size = SelectRobot.GetComponent().ParticleSize; spraysync.gameObjID = SelectRobot.GetComponent().gameObjID; // spraysync.UserID = SelectRobot.GetComponent().UserID; // spraysync.gameObjType = SelectRobot.GetComponent().gameObjType; NetworkManager.Default.SendAsync("SPRAY_WATER_SYNC", spraysync); } } else { SelectRobot.GetComponent().WorkType = FireRobotSkill.待命; LayWaterPanel.gameObject.SetActive(false); if (SelectRobot.GetComponent().Flow!=0) { SelectRobot.GetComponent().Flow = 0; } SelectRobot.GetComponent().pathFindEnable = false; SelectRobot.GetComponent().DestoryPartical(); //MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = false, ChangObjId = SelectRobot.GetComponent().gameObjID }); //停止出水及同步 SelectRobot.GetComponent().DestoryPartical(); SelectRobot.GetComponent().JugeLenght(); } } private void SprayFrothChange(bool value) { FireRobotController controller = SelectRobot.GetComponent(); if (value) { //本身就是出水状态 if (controller.WorkType == FireRobotSkill.出泡沫) { if (SelectRobot.GetComponent().pathFindEnable == false) { SelectRobot.GetComponent().pathFindEnable = true; LayWaterPanel.gameObject.SetActive(true); if (SelectRobot.GetComponent().ConnentSource) { if (SelectRobot.GetComponent().ConnentSource.GetComponent().hasover) { controller.DestoryPartical(); } else { //启用出水铺设 } GetComponent().SetShowEnable(); } } } //开启出水 else { if (SelectRobot.GetComponent().ConnentSource) { float remain = SelectRobot.GetComponent().CheckWaterRemain(SelectRobot.GetComponent().WaterSourceLine); if (!(remain > 0 || remain == -100)) { LoadPromptWin.Instance.LoadTextPromptWindow("剩余水量不足", 1f); return; } float remainfoam = SelectRobot.GetComponent().CheckFoamRemain(); if (!(remainfoam==-100||remainfoam>0)) { LoadPromptWin.Instance.LoadTextPromptWindow("剩余泡沫量不足", 1f); } } controller.WorkType = FireRobotSkill.出泡沫; controller.SetParticleType(SprayParticleType.Froth); // SelectRobot.GetComponent().pathFindEnable = true; LayWaterPanel.gameObject.SetActive(true); GetComponent().SetShowEnable(); //出水铺设水带 if (SelectRobot.GetComponent().remainlenght <= 0) { LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f); } SelectRobot.GetComponent().StartSprayingLay(); //连接水源流量设置 //MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = true, ChangObjId = SelectRobot.GetComponent().gameObjID }); //出水同步 SpraySyncData spraysync = new SpraySyncData(); spraysync.SendUserID = CurrentUserInfo.mySelf.Id; spraysync.IsOn = true; spraysync.spraytype = SprayParticleType.Froth; spraysync.size = SelectRobot.GetComponent().ParticleSize; spraysync.gameObjID = SelectRobot.GetComponent().gameObjID; NetworkManager.Default.SendAsync("SPRAY_WATER_SYNC", spraysync); } } else { SelectRobot.GetComponent().WorkType = FireRobotSkill.待命; LayWaterPanel.gameObject.SetActive(false); if (SelectRobot.GetComponent().Flow != 0) { SelectRobot.GetComponent().Flow = 0; } //禁用寻路 SelectRobot.GetComponent().pathFindEnable = false; //MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = false, ChangObjId = SelectRobot.GetComponent().gameObjID }); SelectRobot.GetComponent().DestoryPartical(); SelectRobot.GetComponent().JugeLenght(); //SpraySyncData spraysync = new SpraySyncData(); //spraysync.SendUserID = CurrentUserInfo.mySelf.Id; //spraysync.IsOn = false; //spraysync.gameObjID = SelectRobot.GetComponent().gameObjID; //NetworkManager.Default.SendAsync("SPRAY_WATER_SYNC", spraysync); } } private void PickUpLineChange(bool value) { SelectRobot.GetComponent().WorkType = FireRobotSkill.待命; if (value) { // SelectRobot.GetComponent().WorkType = FireRobotSkill.收起水带; if (SelectRobot.GetComponent().WorkType==FireRobotSkill.出水|| SelectRobot.GetComponent().WorkType == FireRobotSkill.出泡沫) { LoadPromptWin.Instance.LoadTextPromptWindow("请先停止出水", 1f); return; } SelectRobot.GetComponent().PickUpLayHose(); SelectRobot.GetComponent().pathFindEnable = true; BaseNetworkSyncDate sync = new BaseNetworkSyncDate() { gameObjID = SelectRobot.GetComponent().gameObjID, SendUserID = CurrentUserInfo.mySelf.Id }; NetworkManager.Default.SendAsync("FIREROBOT_PICKUPLINE_SYNC", sync); PackUpLine.GetComponent().isOn = false; } else { } } private void LayWaterHoseChange(bool value) { if (value) { if (SelectRobot.GetComponent().remainlenght<=0) { LoadPromptWin.Instance.LoadTextPromptWindow("未装备水带或水带已用完", 1f); LayWaterHoseToggle.GetComponent().isOn = false; return; } SelectRobot.GetComponent().WorkType = FireRobotSkill.铺设水带; SelectRobot.GetComponent().pathFindEnable = true; SelectRobot.GetComponent().StartLay(); LayerWaterHoseSyncData syncarg = new LayerWaterHoseSyncData(); syncarg.SendUserID = CurrentUserInfo.mySelf.Id; syncarg.IsBegin = true; syncarg.gameObjID = SelectRobot.GetComponent().gameObjID; NetworkManager.Default.SendAsync( "FIREROBOT_LAYWATERHOSE_SYNC", syncarg); } else { if (SelectRobot.GetComponent().WorkType == FireRobotSkill.铺设水带) { if (SelectRobot.GetComponent().GetSelfConsumedLength()>0.2f) { SelectRobot.GetComponent().pathFindEnable = false; LayerWaterHoseSyncData syncarg = new LayerWaterHoseSyncData(); syncarg.SendUserID = CurrentUserInfo.mySelf.Id; syncarg.IsBegin = false; syncarg.gameObjID = SelectRobot.GetComponent().gameObjID; NetworkManager.Default.SendAsync("FIREROBOT_LAYWATERHOSE_SYNC", syncarg); } } SelectRobot.GetComponent().WorkType = FireRobotSkill.待命; SelectRobot.GetComponent().JugeLenght(); } } /// /// 重置机器人技能UI及选择机器人 /// public void ResertRobotSkill() { //SelectFireMan = select; Toggle[] all = RobotSkillPanel.GetComponentsInChildren(); for (int i = 0; i < all.Length; i++) { if (all[i].isOn) { all[i].isOn = false; } } } }