public override State Update()
                {
                    // Behaviour:
                    enemy.MoveTowardTarget(); // moves toward target/player


                    // Transition:
                    // if the minion health is at or below 0 or the boss's health is at 0 or below
                    if (enemy.bossHealth.health <= 0 || enemy.enemyBasicHealth.health <= 0)
                    {
                        enemy.DeathPhase();         // starts death phase
                        return(new States.Death()); // goes to Death state
                    }

                    enemy.dashTimer -= Time.deltaTime; // counts down to be able to dash
                    // checks to see if the player is in range for a dash attack and if the timer is at 0
                    if (enemy.CanSeeThing(enemy.attackTarget, enemy.targetDistanceToDash) && enemy.dashTimer <= 0)
                    {
                        enemy.dashTimer = 5;             // resets dash timer
                        SoundEffectBoard.DashSound();    // plays dash sound
                        enemy.dashTrail.Play();
                        return(new States.DashAttack()); // goes to dash attack state
                    }

                    return(null);
                }
Beispiel #2
0
                public override State Update()
                {
                    // Behavior:
                    player.MoveThePlayer(1); // makes the player move from sending the paramter 1

                    // transitions to other states:
                    if (player.playerHealth.health <= 0)
                    {
                        return(new States.Idle());                                 // if player is dead, goes to Idle() state
                    }
                    if (Input.GetButton("Fire3"))
                    {
                        return(new States.Sprinting());                              // if the player press sprint, goes to Sprinting() state
                    }
                    if (Input.GetKeyDown("space") && player.dashTimeToUseAgain <= 0) // Transition to Dashing when player presses space bar
                    {
                        SoundEffectBoard.DashSound();                                // plays dash sound effect
                        player.dashTrail.Play();
                        return(new States.Dashing());                                // goes to Dashing() state
                    }

                    if (!Input.GetKey("w") && !Input.GetKey("a") && !Input.GetKey("s") && !Input.GetKey("d")) // if the player is not pressing anything
                    {
                        return(new States.Idle());                                                            // goes to Idle() state
                    }
                    return(null);
                }