You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.3 KiB
83 lines
2.3 KiB
using UnityEngine; |
|
/// <summary> |
|
/// 灭火类角色/车辆控制器 |
|
/// </summary> |
|
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<HoseController>(); |
|
hosecontrol.HoseSyetem.Add(hose.GetComponent<ParticleSystem>()); |
|
hosecontrol.HoseSyetem.Add(hose.transform.Find("SprayCore").GetComponent<ParticleSystem>()); |
|
hosecontrol.HoseSyetem.Add(hose.transform.Find("SprayWide").GetComponent<ParticleSystem>()); |
|
} |
|
private void Start() |
|
{ |
|
task = transform.Find("Info/Task").GetComponent<TextMesh>(); |
|
} |
|
|
|
protected virtual void LateUpdate() |
|
{ |
|
if(SelectionManager.IsContains(gameObject)) |
|
{ |
|
WaterGunControl(); |
|
HoseRangeControl(); |
|
} |
|
|
|
} |
|
|
|
/// <summary> |
|
/// 水炮控制 |
|
/// </summary> |
|
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); |
|
} |
|
|
|
} |
|
/// <summary> |
|
/// 水流射程控制 |
|
/// </summary> |
|
private void HoseRangeControl() |
|
{ |
|
//增加射程 + |
|
if (Input.GetKey(PowerManager.Instance.hoseIncrease)) |
|
{ |
|
GetComponent<HoseController>().speed += Time.deltaTime * 0.5f; |
|
|
|
} |
|
//缩短射程 - |
|
else if (Input.GetKey(PowerManager.Instance.hoseReduce)) |
|
{ |
|
GetComponent<HoseController>().speed -= Time.deltaTime * 0.5f; |
|
} |
|
|
|
} |
|
}
|
|
|