1
0
This commit is contained in:
MoMack20 2016-01-31 15:10:18 -05:00
parent 79c246a8a8
commit 0988fb0c8c
3 changed files with 22 additions and 4 deletions

View File

@ -10,10 +10,14 @@ public class Enemy : Controller{
public LayerMask enemyMask;
public bool rightdirection;
public float[] time = new float[10];
public bool idle;
public bool wander;
// Use this for initialization
void Start ()
{
time [0] = 2.0f;
time [1] = 4.0f;
print("start");
mAnimator = GetComponent<Animator> ();
changestate(new idle());

View File

@ -16,15 +16,22 @@ public class idle : state
}
public void Enter(Enemy enemy)
{
time = 0;
Debug.Log("idle");
this.enemy = enemy;
enemy.idle = true;
enemy.wander = false;
}
public void Exit(){}
public void onTriggerEnter(Collider2D other){}
public void Idle()
{
time += Time.deltaTime;
if (time >= enemy.time[0])
enemy.changestate(new wander());
if (time >= enemy.time [0]) {
time = 0;
enemy.idle = false;
enemy.wander = true;
enemy.changestate (new wander ());
}
}
}

View File

@ -25,8 +25,12 @@ public class wander : state
public void Execute()
{
time += Time.deltaTime;
if (time >= enemy.time[1])
enemy.changestate(new idle());
if (time >= enemy.time [1]) {
time = 0;
enemy.idle = true;
enemy.wander = false;
enemy.changestate (new idle ());
}
seeplayer();
if (enemy.isAir)
{
@ -41,6 +45,9 @@ public class wander : state
}
public void Enter(Enemy enemy)
{
time = 0;
enemy.wander = true;
enemy.idle = false;
Debug.Log("Wander");
this.enemy = enemy;
this.enemyMask = enemy.enemyMask;