using SpringGUI; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //Author:ZCG //CreatTime:12/15/2017 /// /// 水炮属性面板 /// public class UIPlanWaterCannon : BaseInstanceMono { private static UIPlanWaterCannon instance; public static UIPlanWaterCannon Instance { get { if (instance == null) { Transform canvas = GameObject.Find("Canvas").transform; GameObject panel = Instantiate(Resources.Load("Prefab/Tool/UIPlanWaterCannon") as GameObject, canvas); instance = panel.GetComponent(); instance.Init(); } return instance; } } private Slider Slider_SetWaterSpeed;//水速度 private Slider Slider_SetPingPongSpeed;//摇摆速度 private Text Text_WaterSpeed;//水速度 private Text Text_PingPongSpeed;//摇摆速度 public void Init() { Slider_SetWaterSpeed = transform.Find("Slider_SetWaterSpeed").GetComponent(); Slider_SetPingPongSpeed = transform.Find("Slider_SetPingPongSpeed").GetComponent(); Text_WaterSpeed = transform.Find("Text_WaterSpeed").GetComponent(); Text_PingPongSpeed = transform.Find("Text_PingPongSpeed").GetComponent(); } /// /// 重置面板 /// public override void LoadObjData(GameObject chooseObject) { gameObject.SetActive(true); ChooseObj = chooseObject; //摇摆 var type = ChooseObj.GetComponent(); Slider_SetPingPongSpeed.value = type.GetPingPongSpeed() * 10; Text_PingPongSpeed.text = (type.GetPingPongSpeed() * 10).ToString(); //射水 var particle = ChooseObj.transform.Find("Rotate/Head/WaterStraight/WaterStraightPos/WaterStraight").GetComponent(); Slider_SetWaterSpeed.value = particle.GetScaleValue() * 10; Text_WaterSpeed.text = (particle.GetScaleValue()*10).ToString(); } public override void ResetData(GameObject dataObj) { dataObj.GetComponent().Revocation(); } /// /// 设置射水速度 /// /// public void SetWaterSpeed(float value) { ChooseObj.GetComponent().SetWaterSpeed(value/10f); Text_WaterSpeed.text = value.ToString(); } /// /// 设置摇摆速度 /// /// public void SetPingPongSpeed(float value) { ChooseObj.GetComponent().SetPingPongSpeed(value/10f); Text_PingPongSpeed.text = value.ToString(); } public void OpenPingPong() { ChooseObj.GetComponent().OpenPingPong(); } public void PutOutFire() { if (ChooseObj.GetComponent().hasSupplier) { ChooseObj.GetComponent().PutOutFire(); } else { ResourceLoadWindow.Instance.LoadTextHintWindow("请连接水源", 2); } } /// /// 确认 /// public void Confirm() { gameObject.SetActive(false); ChooseObj.GetComponent().Confirm(); } /// /// 关闭 /// public void Cancel() { Revocation(); gameObject.SetActive(false); } /// /// 撤销 /// public void Revocation() { ChooseObj.GetComponent().Revocation(); LoadObjData(ChooseObj); } public override void EditorRight() { } }