]> git.lizzy.rs Git - SuperMouseAdventure.git/blobdiff - 2DGame/Assets/Scripts/Enemies/Boss/BossMovement.cs
Dialog-System 0.4
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Enemies / Boss / BossMovement.cs
index c9ee34dc0d42ec92722b938737b7c740d8c7f066..14d3269804bb355b6e31b0abe833821bf7de5a70 100644 (file)
@@ -5,31 +5,42 @@ using UnityEngine;
 public class BossMovement : StateMachineBehaviour
 {   
     FollowPlayer fp;
+    Boss boss;
 
     // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
     override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
     {
         fp = animator.GetComponent<FollowPlayer>();
+        boss = animator.GetComponent<Boss>();
     }
 
     // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
     override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
     {
-        if (fp.distToPlayer < fp.agroRange - 20)
+        if (boss.bossfight)
         {
-            animator.SetBool("Idle", false);
-            animator.SetTrigger("Attack");
+            if (fp.distToPlayer < fp.agroRange - 20)
+            {
+                animator.SetBool("Idle", false);
+                animator.SetBool("Attack", true);
+            }
+            else if (fp.distToPlayer > fp.agroRange)
+            {
+                animator.SetBool("Idle", true);
+                animator.SetBool("Attack", false);
+            }
         }
-        else if (fp.distToPlayer > fp.agroRange)
+        else
         {
             animator.SetBool("Idle", true);
+            animator.SetBool("Attack", false);
         }
     }
 
     // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
     override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
     {
-        animator.ResetTrigger("Attack");
+        animator.SetBool("Attack", false);
         animator.SetBool("Idle", false);
     }
 }