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.
161 lines
5.1 KiB
161 lines
5.1 KiB
11 months ago
|
using DG.Tweening;
|
||
|
using System.Collections;
|
||
|
using UnityEngine;
|
||
|
/// <summary>
|
||
|
/// 高喷车控制
|
||
|
/// </summary>
|
||
|
public class GaoPenCheController : ElevatingController
|
||
|
{
|
||
|
protected override void Init()
|
||
|
{
|
||
|
//StartCoroutine(OnAnimationPlay());
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 实例化时主臂和二级臂展开
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
private IEnumerator OnAnimationPlay()
|
||
|
{
|
||
|
yield return new WaitForSeconds(1f);
|
||
|
part2.transform.DORotate(new Vector3(-65f, 0f, 0f), 1f);
|
||
|
yield return new WaitForSeconds(1f);
|
||
|
part7.transform.DOLocalRotateQuaternion(Quaternion.Euler(new Vector3(90f,0,0)), 2f);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 主臂控制
|
||
|
/// </summary>
|
||
|
protected override void MainArmControl()
|
||
|
{
|
||
|
base.MainArmControl();
|
||
|
if (ctrlDown && Input.GetKey(PowerManager.Instance.up))
|
||
|
{
|
||
|
if (!firstFull)
|
||
|
{
|
||
|
float z = part3.transform.localPosition.z;
|
||
|
if (z > 12.4)
|
||
|
{
|
||
|
firstFull = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
firstZero = false;
|
||
|
part3.transform.localPosition = new Vector3(part3Pos.x, part3Pos.y, z + Time.deltaTime * zSpeed);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (firstFull && !secondFull && !thirdFull && !fourthFull)
|
||
|
{
|
||
|
float z = part4.transform.localPosition.z;
|
||
|
if (z > 11.9)
|
||
|
{
|
||
|
secondFull = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
secondZero = false;
|
||
|
part4.transform.localPosition = new Vector3(part4Pos.x, part4Pos.y, z + Time.deltaTime * zSpeed);
|
||
|
}
|
||
|
}
|
||
|
else if (firstFull && secondFull && !thirdFull && !fourthFull)
|
||
|
{
|
||
|
float z = part5.transform.localPosition.z;
|
||
|
if (z > 11.9)
|
||
|
{
|
||
|
thirdFull = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
thirdZero = false;
|
||
|
part5.transform.localPosition = new Vector3(part5Pos.x, part5Pos.y, z + Time.deltaTime * zSpeed);
|
||
|
}
|
||
|
}
|
||
|
else if (firstFull && secondFull && thirdFull && !fourthFull)
|
||
|
{
|
||
|
float z = part6.transform.localPosition.z;
|
||
|
if (z > 11.9)
|
||
|
{
|
||
|
fourthFull = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
fourthZero = false;
|
||
|
part6.transform.localPosition = new Vector3(part6Pos.x, part6Pos.y, z + Time.deltaTime * zSpeed);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (ctrlDown && Input.GetKey(PowerManager.Instance.down))
|
||
|
{
|
||
|
if (!fourthZero)
|
||
|
{
|
||
|
float z = part6.transform.localPosition.z;
|
||
|
if (z < 0)
|
||
|
{
|
||
|
fourthZero = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
fourthFull = false;
|
||
|
part6.transform.localPosition = new Vector3(part6Pos.x, part6Pos.y, z - Time.deltaTime * zSpeed);
|
||
|
}
|
||
|
}
|
||
|
else if (fourthZero && !thirdZero && !secondZero && !firstZero)
|
||
|
{
|
||
|
float z = part5.transform.localPosition.z;
|
||
|
if (z < 0)
|
||
|
{
|
||
|
|
||
|
thirdZero = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
thirdFull = false;
|
||
|
part5.transform.localPosition = new Vector3(part5Pos.x, part5Pos.y, z - Time.deltaTime * zSpeed);
|
||
|
}
|
||
|
}
|
||
|
else if (fourthZero && thirdZero && !secondZero && !firstZero)
|
||
|
{
|
||
|
float z = part4.transform.localPosition.z;
|
||
|
if (z < 0)
|
||
|
{
|
||
|
secondZero = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
secondFull = false;
|
||
|
part4.transform.localPosition = new Vector3(part4Pos.x, part4Pos.y, z - Time.deltaTime * zSpeed);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
else if (fourthZero && thirdZero && secondZero && !firstZero)
|
||
|
{
|
||
|
float z = part3.transform.localPosition.z;
|
||
|
if (z < 0)
|
||
|
{
|
||
|
firstZero = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
firstFull = false;
|
||
|
part3.transform.localPosition = new Vector3(part3Pos.x, part3Pos.y, z - Time.deltaTime * zSpeed);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 二级臂控制
|
||
|
/// </summary>
|
||
|
protected override void SecondArmControl()
|
||
|
{
|
||
|
if (ctrlDown && Input.GetKey(PowerManager.Instance.waterGunUp))
|
||
|
{
|
||
|
part7.transform.Rotate(-Time.deltaTime * rotSpeed, 0, 0);
|
||
|
}
|
||
|
else if (ctrlDown && Input.GetKey(PowerManager.Instance.waterGunDown))
|
||
|
{
|
||
|
part7.transform.Rotate(Time.deltaTime * rotSpeed, 0, 0);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|