public override BossState Update(WhiteBossController boss) { // do stuff to the boss... Debug.Log("idle"); // transitions to other states: if (boss.CanSeeAttackTarget()) { // transition to persue state... return(new BossStatePersue()); } // switch to move around level state // switch to dead state return(null); // stay in current state }
/// <summary> /// This function updates the boss each frame. /// </summary> /// <param name="boss"> The boss that this state applies to. </param> /// <returns> A new state. </returns> public override BossState Update(WhiteBossController boss) { Debug.Log("attack"); Vector3 vectorToPlayer = boss.VectorToAttackTarget(); timeUntilNextShot -= Time.deltaTime; if(timeUntilNextShot <=0) { boss.ShootProjectile(); timeUntilNextShot = timeBetweenShots; } // ends the if statement boss.ShootProjectile(); if (!boss.CanSeeAttackTarget()) return new BossStateIdle(); // if the player gets too far away from the enemy return the enemy to idle // switch to retreat state // once the boss has finished its attack, it retreats a short distance away from the player // switch to dead state return null; } // ends the Update() function