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.
88 lines
2.2 KiB
88 lines
2.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class AI_Worker : MonoBehaviour
|
|
{
|
|
public string ID;
|
|
public float timer = 0f;
|
|
public float workTime = 20f;
|
|
public bool isWorkOver = false;
|
|
public bool isDie = false;
|
|
public bool isCheck = false;
|
|
|
|
public int PointIdenx = 0;
|
|
private int tempIndex=0;
|
|
public Animator animator;
|
|
public Transform[] movePoints;
|
|
|
|
//当前移动目标点
|
|
public Vector3 targerPos;
|
|
|
|
private void Start()
|
|
{
|
|
animator = GetComponent<Animator>();
|
|
movePoints = AISys.Instance._movePoints;
|
|
workTime = Random.Range(3, 10);
|
|
|
|
AISys.Instance.pointIsUse[PointIdenx] = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
if (timer <= workTime&&isWorkOver==false&&!isDie)
|
|
{
|
|
timer += Time.deltaTime;
|
|
|
|
}
|
|
|
|
if(timer >= workTime && !isDie)
|
|
{
|
|
workTime = Random.Range(25, 50);
|
|
isWorkOver = true;
|
|
timer = 0;
|
|
if (AISys.Instance.pointIsUse[PointIdenx] == true)
|
|
{
|
|
for (int i = 0; i < AISys.Instance.pointIsUse.Length; i++)
|
|
{
|
|
|
|
if (AISys.Instance.pointIsUse[i] == false)
|
|
{
|
|
AISys.Instance.pointIsUse[PointIdenx] = false;
|
|
PointIdenx = i;
|
|
targerPos = movePoints[PointIdenx].position + new Vector3((Random.insideUnitCircle * 3f).x, 0, (Random.insideUnitCircle * 3f).y);
|
|
AISys.Instance.pointIsUse[PointIdenx] = true;
|
|
break;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void Accident()
|
|
{
|
|
isWorkOver = true;
|
|
targerPos = AISys.Instance.Pass1AccidentPoint.position;
|
|
isDie = true;
|
|
transform.position = new Vector3(-8.78f,6.6f,-125f);
|
|
Transform kuang = transform.Find("FangKuang");
|
|
if (kuang != null)
|
|
{
|
|
kuang.GetComponent<MeshRenderer>().material.color = Color.red;
|
|
kuang.localEulerAngles = new Vector3(90, 0, 0);
|
|
kuang.localPosition = new Vector3(0, 0, 0);
|
|
}
|
|
|
|
|
|
}
|
|
}
|