Exemple #1
0
        public override void CheckRange(Player player, GameTime gameTime)
        {
            if (Target == null)
            Target = player;

              if (Game1.CurrentTime - LastCharge < ChargeCooldown)
            return;

              float distance = player.DrawBox.Center.Distance(DrawBox.Center);

              switch (State)
              {
            case StoneRobotState.Stone:
              break;

            case StoneRobotState.Normal:
              if (distance < ATTACK_RANGE)
            State = StoneRobotState.Chasing;
              break;

            case StoneRobotState.Chasing:
              if (distance < CHARGE_RANGE)
              {
            State = StoneRobotState.Charging;
            LastCharge = Game1.CurrentTime;
              }
              break;

            case StoneRobotState.Charging:
              break;
              }
        }
Exemple #2
0
 public override void CollisionCheck(Player player, GameTime gameTime)
 {
     if (State == StoneRobotState.Charging && player.Hitbox.Intersects(Hitbox))
       {
     Game1.EventMan.Notify(Events.KnockedBack, new ActiveObject[]{ this, player });
     State = StoneRobotState.Normal;
     Velocity.X = 0;
       }
 }
Exemple #3
0
        public override void Update(GameTime gameTime)
        {
            int dir = 1;

              if (Target != null)
            dir = Target.DrawBox.Center.X < DrawBox.Center.X ? -1 : 1;

              switch (State)
              {
            case StoneRobotState.Stone:
              Velocity.X = 0;

              if (CurrentlyBeingShot)
              {
            State = StoneRobotState.Normal;
            LastCharge = Game1.CurrentTime;  // Reset so it doesn't charge immediately
              }
              break;

            case StoneRobotState.Normal:
              // Do nothing
              if (CurrentlyBeingShot && Game1.CurrentTime - LastCharge > ChargeCooldown)
              {
            State = StoneRobotState.Chasing;
              }
              break;

            case StoneRobotState.Chasing:
              Velocity.X = SPEED * dir;
              break;

            case StoneRobotState.Charging:
              Velocity.X = SPEED * dir;
              break;
              }

              UpdateMovement(gameTime);
        }