] xunluo;
public GameObject mPlayer;
public enum RobotStatus
{
Idle,
Patrol,
Follow,
Attack,
};
public RobotStatus status=RobotStatus.Patrol;
public int i=0;
public NavMeshAgent mAgent;
public Animator ani;
private float ttt=2;
// Use this for initialization
void Start () {
mAgent = GetComponent<NavMeshAgent> ();
ani = GetComponent<Animator> ();
mPlayer = GameObject.FindGameObjectWithTag ("player");
}
void Xunluo(){
mAgent.SetDestination (xunluo [i]);
if (Vector3.Distance (transform.position, xunluo [i]) < 0.4f)
{
ani.SetBool ("idle", true);
i = Random.Range (0, 4);
status = RobotStatus.Idle;
}
}
// Update is called once per frame
void Update () {
switch (status) {
case RobotStatus.Patrol:
Xunluo ();
break;
case RobotStatus.Idle:
if (ttt > 0) {
ttt -= Time.deltaTime;
} else {
ttt = 2;
status = RobotStatus.Patrol;
ani.SetBool ("idle", false);
}
break;
case RobotStatus.Follow:
break;
case RobotStatus.Attack:
break;
}
}
}