Example #1
0
 //UPDATE
 public virtual void Update(GameTime gameTime, Player hero, Enemie enemie)
 {
     lastState = CurrentState;
     goUpdate  = false;
     if (moveTimer.Update(gameTime))
     {
         RandomDirection();
         goUpdate       = true;
         moveTimer.Time = GetTime();
     }
 }
Example #2
0
        //METHODE

        //UPDATE
        public override void Update(GameTime gameTime, Player hero, Enemie enemie)
        {
            base.Update(gameTime, hero, enemie);
            if (currentState == State.Walking)
            {
                if (util.getDistance(hero.Position, enemie.Position) < aggroDistance)
                {
                    if (lastState == State.Walking)
                    {
                        enemie.DrawAlert           = true;
                        chargeCooldownTimer.Timers = chargeCooldownTimer.Time * 0.6f;
                    }
                    currentState = State.Attack;
                }
                else
                {
                    if (enemie.DrawAlert)
                    {
                        enemie.DrawAlert = false;
                    }
                    chargeCooldownTimer.Reset();
                    preparingToChargeTimer.Reset();
                    currentState = State.Walking;
                }
            }

            if (currentState == State.Attack)
            {
                if (chargeCooldownTimer.Update(gameTime))
                {
                    currentState = State.PrepareToCharge;
                }
            }
            else if (currentState == State.PrepareToCharge)
            {
                if (preparingToChargeTimer.Update(gameTime))
                {
                    currentState = State.Charge;
                }
            }
            else if (currentState == State.Charge)
            {
                if (chargeTimer.Update(gameTime))
                {
                    currentState = State.Attack;
                }
            }
        }