137 lines
3.9 KiB
C#
137 lines
3.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class WRJController : MonoBehaviour
|
|
{
|
|
public List<Vector3> wayPoints = new List<Vector3>();
|
|
public int index1 = 0;
|
|
public float speed;
|
|
//public HuoPaoController[] huoPaoControllerList;
|
|
//public List<HuoPaoController> attackTarget = new List<HuoPaoController>();
|
|
public bool isMove = false;
|
|
public float dis;
|
|
public float limitDis;
|
|
public Transform firePos;
|
|
public GameObject firePrefab;
|
|
public bool isGoToPlace = false;
|
|
public bool isAuto = false;
|
|
public int fireCount;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
if (isMove)
|
|
{
|
|
MoveToway1();
|
|
}
|
|
if (isGoToPlace)
|
|
{
|
|
InvokeRepeating("OnFire", 1, 1);
|
|
isGoToPlace = false;
|
|
}
|
|
|
|
}
|
|
|
|
public void MoveToway1()
|
|
{
|
|
|
|
if (wayPoints.Count == 0) return;
|
|
if (index1 > wayPoints.Count - 1) { return; }
|
|
transform.localPosition = Vector3.MoveTowards(transform.localPosition, wayPoints[index1], speed * Time.deltaTime);
|
|
if (Vector3.Distance(wayPoints[index1], transform.localPosition) < 0.01f)
|
|
{
|
|
index1++;
|
|
|
|
if (index1 == wayPoints.Count)
|
|
{
|
|
transform.localPosition = wayPoints[index1 - 1];
|
|
isGoToPlace = true;
|
|
isMove = false;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public void SetAttackTarget(HuoPaoController target)
|
|
{
|
|
//if (!attackTarget.Contains(target))
|
|
// attackTarget.Add(target);
|
|
|
|
}
|
|
|
|
public void SetMove()
|
|
{
|
|
isMove = true;
|
|
if (!isAuto)
|
|
{
|
|
wayPoints.Clear();
|
|
wayPoints.Add(new Vector3(-132.7299f, 149.0329f, -309.2459f));
|
|
wayPoints.Add(new Vector3(-98.94415f, 188.4612f, -219.9548f));
|
|
wayPoints.Add(new Vector3(-69.9848f, 212.5105f, -145.1433f));
|
|
wayPoints.Add(new Vector3(-2.413391f, 201.8178f, -24.47968f));
|
|
wayPoints.Add(new Vector3(48f, 191.4619f, 47f));
|
|
}
|
|
}
|
|
|
|
public int currentHuoPaoIndex = 0;
|
|
private void OnFire()
|
|
{
|
|
//for (int i = 0; i < huoPaoControllerList.Length; i++)
|
|
//{
|
|
|
|
if (fireCount <= 0) return;
|
|
if (isAuto)
|
|
{
|
|
//if (currentHuoPaoIndex >= huoPaoControllerList.Length - 1)
|
|
//{
|
|
// CancelInvoke("OnFire");
|
|
// return;
|
|
//}
|
|
|
|
//if (huoPaoControllerList[currentHuoPaoIndex] == null)
|
|
//{
|
|
// currentHuoPaoIndex++;
|
|
//}
|
|
|
|
//if (firePos != null)
|
|
//{
|
|
// firePos.LookAt(huoPaoControllerList[currentHuoPaoIndex].transform.position);
|
|
// GameObject fire = Instantiate(firePrefab);
|
|
// fire.transform.eulerAngles = firePos.eulerAngles;
|
|
// fire.transform.position = firePos.position;
|
|
// fire.GetComponent<BulletController>().SetBoolIsMove();
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
//if (currentHuoPaoIndex >= attackTarget.Count - 1)
|
|
//{
|
|
// CancelInvoke("OnFire");
|
|
// return;
|
|
//}
|
|
|
|
//if (attackTarget[currentHuoPaoIndex] == null)
|
|
//{
|
|
// currentHuoPaoIndex++;
|
|
//}
|
|
|
|
//if (firePos != null)
|
|
//{
|
|
// firePos.LookAt(attackTarget[currentHuoPaoIndex].transform.position);
|
|
// GameObject fire = Instantiate(firePrefab);
|
|
// fire.transform.eulerAngles = firePos.eulerAngles;
|
|
// fire.transform.position = firePos.position;
|
|
// fire.GetComponent<BulletController>().SetBoolIsMove();
|
|
//}
|
|
}
|
|
fireCount--;
|
|
}
|
|
}
|