void Scan() { State = RobotSentinelStates.Scanning; LastScan = Game1.CurrentTime; Scanner = new ScanningCircle(new Vector2(DrawBox.Center.X, DrawBox.Bottom), SCANNING_RANGE, SCANNING_SPEED); }
public override void Update(GameTime gameTime) { switch (State) { case RobotSentinelStates.Walking: Velocity.X = Direction * WALKING_SPEED; if (DrawBox.Center.X <= LeftBounds) Velocity.X = Math.Abs(Velocity.X); if (DrawBox.Center.X >= RightBounds) Velocity.X = -Math.Abs(Velocity.X); if (Game1.CurrentTime - LastScan > TimeBetweenScans) Scan(); break; case RobotSentinelStates.Scanning: Velocity.X = 0; if (Game1.CurrentTime - LastScan > ScanDuration) RestoreState(); break; case RobotSentinelStates.Attacking: Velocity.X = 0; Game1.EventMan.Notify(Events.PlayerHitByLaser, this); if (Game1.CurrentTime - LastAttack > AttackDuration) RestoreState(); break; } if (Scanner != null) { if (Scanner.Destroy) Scanner = null; else Scanner.Update(gameTime); } UpdateMovement(gameTime); }
void RestoreState() { State = RobotSentinelStates.Walking; Scanner = null; }
public void PlayerSpottedByScanner(object nothing) { if (Target != null) { if (Target.State == Player.PlayerStates.Standing || Target.State == Player.PlayerStates.Walking || Target.State == Player.PlayerStates.Shooting) { State = RobotSentinelStates.Attacking; Scanner = null; LastAttack = Game1.CurrentTime; } } }