using UnityEngine; /// /// 灭火类角色/车辆控制器 /// public class FireExtinguishController : MonoBehaviour { //水枪/炮 public GameObject waterGun; //水流 public GameObject hose; //水流显示 public bool isHose; //任务内容 public TextMesh task; //旋转速度 public float rotSpeed=40f; public virtual void InitData() { var t = MyTools.FindChildren(transform, "PT"); waterGun = t.gameObject; hose = Instantiate(AssetManager.Instance.hose) as GameObject; hose.transform.parent = t.transform.Find("PZ"); hose.transform.localPosition = Vector3.zero; hose.transform.localEulerAngles = Vector3.zero; var hosecontrol = gameObject.AddComponent(); hosecontrol.HoseSyetem.Add(hose.GetComponent()); hosecontrol.HoseSyetem.Add(hose.transform.Find("SprayCore").GetComponent()); hosecontrol.HoseSyetem.Add(hose.transform.Find("SprayWide").GetComponent()); } private void Start() { task = transform.Find("Info/Task").GetComponent(); } protected virtual void LateUpdate() { if(SelectionManager.IsContains(gameObject)) { WaterGunControl(); HoseRangeControl(); } } /// /// 水炮控制 /// protected virtual void WaterGunControl() { //水枪下俯 if (Input.GetKey(PowerManager.Instance.waterGunDown)) { waterGun.transform.Rotate(Time.deltaTime * rotSpeed, 0, 0, Space.Self); } //水枪上扬 else if (Input.GetKey(PowerManager.Instance.waterGunUp)) { waterGun.transform.Rotate(-Time.deltaTime * rotSpeed, 0, 0, Space.Self); } } /// /// 水流射程控制 /// private void HoseRangeControl() { //增加射程 + if (Input.GetKey(PowerManager.Instance.hoseIncrease)) { GetComponent().speed += Time.deltaTime * 0.5f; } //缩短射程 - else if (Input.GetKey(PowerManager.Instance.hoseReduce)) { GetComponent().speed -= Time.deltaTime * 0.5f; } } }