using AX.MessageSystem; using AX.NetworkSystem; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SnowConnonSkillPanelController : MonoBehaviour { [Rename("出水")] public ToggleRecordByAC SprayWater; [Rename("出泡沫")] public ToggleRecordByAC SprayFoam; public GameObject SelectSnowConnon; private static SnowConnonSkillPanelController instance; private LayWaterPanel laywaterpanel; public static SnowConnonSkillPanelController Instance { get { return instance; } } // Use this for initialization void Start() { instance = this; laywaterpanel = GetComponent(); SprayWater.OutInterFaceToggle = SprayToggleChange; SprayFoam.OutInterFaceToggle = SprayFoamChange; } /// /// 选中移动水泡时的UI显示 /// /// public void SetSnowConnon(GameObject select) { SelectSnowConnon = select; if (select.GetComponent().hasWaterConnect) { SprayWater.GetComponent().interactable = true; } else { SprayWater.GetComponent().interactable = false; } if (select.GetComponent().hasFoamConnect) { SprayFoam.GetComponent().interactable = true; } else { SprayFoam.GetComponent().interactable = false; } switch (select.GetComponent().skill) { case SnowCannonSkill.喷水: SprayWater.GetComponent().isOn = true; laywaterpanel.laywater.gameObject.SetActive(true); GetComponent().SetShowEnable(); break; case SnowCannonSkill.喷泡沫: SprayFoam.GetComponent().isOn = true; laywaterpanel.laywater.gameObject.SetActive(true); GetComponent().SetShowEnable(); break; case SnowCannonSkill.None: //ResertUI(); SprayWater.GetComponent().isOn = false; SprayFoam.GetComponent().isOn = false; laywaterpanel.laywater.gameObject.SetActive(false); break; } } private void SprayToggleChange(bool value) { if (value) { if (SelectSnowConnon.GetComponent().skill == SnowCannonSkill.喷水) { return; } float remian= SelectSnowConnon.GetComponent().CheckWaterRemain(SelectSnowConnon.GetComponent().WaterSourceLine); if (!(remian>0||remian==-100)) { LoadPromptWin.Instance.LoadTextPromptWindow("剩余水量不足",1f); return; } SelectSnowConnon.GetComponent().skill = SnowCannonSkill.喷水; laywaterpanel.laywater.gameObject.SetActive(true); SelectSnowConnon.GetComponent().Spray(SnowCannonSkill.喷水); GetComponent().SetShowEnable(); //连接水源流量设置 // MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = value, ChangObjId = SelectSnowConnon.GetComponent().gameObjID }); //出水同步 SpraySyncData spraysync = new SpraySyncData(); spraysync.SendUserID = CurrentUserInfo.mySelf.Id; spraysync.spraytype = SprayParticleType.WaterStraight; spraysync.IsOn = true; spraysync.size = SelectSnowConnon.GetComponentInChildren(true).GetScaleValue(); spraysync.gameObjID = SelectSnowConnon.GetComponent().gameObjID; // spraysync.UserID = selectMoveWaterConnon.GetComponent().UserID; // spraysync.gameObjType = selectMoveWaterConnon.GetComponent().gameObjType; NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync); } else { SelectSnowConnon.GetComponent().Spray(SnowCannonSkill.None); SelectSnowConnon.GetComponent().skill = SnowCannonSkill.None; laywaterpanel.laywater.gameObject.SetActive(false); //连接水源流量设置 //MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = value, ChangObjId = SelectSnowConnon.GetComponent().gameObjID }); if (SelectSnowConnon.GetComponent().Flow != 0) { SelectSnowConnon.GetComponent().Flow = 0; } SpraySyncData spraysync = new SpraySyncData(); spraysync.SendUserID = CurrentUserInfo.mySelf.Id; spraysync.spraytype = SprayParticleType.WaterStraight; spraysync.IsOn = false; spraysync.size = SelectSnowConnon.GetComponentInChildren(true).GetScaleValue(); spraysync.gameObjID = SelectSnowConnon.GetComponent().gameObjID; //spraysync.UserID = selectMoveWaterConnon.GetComponent().UserID; //spraysync.gameObjType = selectMoveWaterConnon.GetComponent().gameObjType; NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync); } } private void SprayFoamChange(bool value) { if (value) { if (SelectSnowConnon.GetComponent().skill == SnowCannonSkill.喷泡沫) { return; } float remian = SelectSnowConnon.GetComponent().CheckWaterRemain(SelectSnowConnon.GetComponent().WaterSourceLine); if (!(remian > 0 || remian == -100)) { LoadPromptWin.Instance.LoadTextPromptWindow("剩余水量不足", 1f); return; } float remianfoam = SelectSnowConnon.GetComponent().CheckFoamRemain(); if (!(remianfoam==-100||remianfoam>0)) {//没泡沫 LoadPromptWin.Instance.LoadTextPromptWindow("剩余泡沫量不足", 1f); return; } SelectSnowConnon.GetComponent().skill = SnowCannonSkill.喷泡沫; laywaterpanel.laywater.gameObject.SetActive(true); SelectSnowConnon.GetComponent().Spray(SnowCannonSkill.喷泡沫); GetComponent().SetShowEnable(); //连接水源流量设置 // MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = value, ChangObjId = SelectSnowConnon.GetComponent().gameObjID }); SpraySyncData spraysync = new SpraySyncData(); spraysync.SendUserID = CurrentUserInfo.mySelf.Id; spraysync.spraytype = SprayParticleType.Froth; spraysync.IsOn = true; spraysync.size = SelectSnowConnon.GetComponentInChildren(true).GetScaleValue(); spraysync.gameObjID = SelectSnowConnon.GetComponent().gameObjID; spraysync.UserID = SelectSnowConnon.GetComponent().UserID; spraysync.gameObjType = SelectSnowConnon.GetComponent().gameObjType; NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync); } else { SelectSnowConnon.GetComponent().Spray(SnowCannonSkill.None); SelectSnowConnon.GetComponent().skill = SnowCannonSkill.None; if (SelectSnowConnon.GetComponent().Flow!=0) { SelectSnowConnon.GetComponent().Flow = 0; } laywaterpanel.laywater.gameObject.SetActive(false); //连接水源流量设置 // MessageDispatcher.SendMessage("SPRAY_WATER", new flowchangeinfo() { IsAdd = value, ChangObjId = SelectSnowConnon.GetComponent().gameObjID }); SpraySyncData spraysync = new SpraySyncData(); spraysync.SendUserID = CurrentUserInfo.mySelf.Id; spraysync.spraytype = SprayParticleType.WaterStraight; spraysync.IsOn = false; spraysync.size = SelectSnowConnon.GetComponentInChildren(true).GetScaleValue(); spraysync.gameObjID = SelectSnowConnon.GetComponent().gameObjID; spraysync.UserID = SelectSnowConnon.GetComponent().UserID; spraysync.gameObjType = SelectSnowConnon.GetComponent().gameObjType; NetworkManager.Default.SendAsync(/*CurrentUserInfo.mySelf.Id,*/ "SPRAY_WATER_SYNC", spraysync); } } // Update is called once per frame void Update() { } private void ResertUI() { Toggle[] all = transform.GetComponentsInChildren(true); for (int i = 0; i < all.Length; i++) { all[i].isOn = false; } } }