diff --git a/Assets/Resources/Scripts/AIScripts/Enemy.cs b/Assets/Resources/Scripts/AIScripts/Enemy.cs index f3b0402..6c37b62 100644 --- a/Assets/Resources/Scripts/AIScripts/Enemy.cs +++ b/Assets/Resources/Scripts/AIScripts/Enemy.cs @@ -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 (); changestate(new idle()); diff --git a/Assets/Resources/Scripts/AIScripts/idle.cs b/Assets/Resources/Scripts/AIScripts/idle.cs index eb77cfe..5c2a0cc 100644 --- a/Assets/Resources/Scripts/AIScripts/idle.cs +++ b/Assets/Resources/Scripts/AIScripts/idle.cs @@ -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 ()); + } } } diff --git a/Assets/Resources/Scripts/AIScripts/wander.cs b/Assets/Resources/Scripts/AIScripts/wander.cs index 94138e1..366d8ae 100644 --- a/Assets/Resources/Scripts/AIScripts/wander.cs +++ b/Assets/Resources/Scripts/AIScripts/wander.cs @@ -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; diff --git a/Assets/Sprites/SpriteAnimations/SpiderController.controller b/Assets/Sprites/SpriteAnimations/SpiderController.controller index 1417794..c745d17 100644 Binary files a/Assets/Sprites/SpriteAnimations/SpiderController.controller and b/Assets/Sprites/SpriteAnimations/SpiderController.controller differ