public GhostBehavior() { Random rnd = new Random(); this.state = Ghost.States.Waiting; this.ghostVelocity = Constants.DEFAULT_PLAYER_VELOCITY; this.transition = rnd.Next(10); this.Wait(); }
public void Wait() { this.nextState = Ghost.States.Waiting; this.duration = 15.0f; }
public void Update(GameTime gameTime) { var elapsed = gameTime.ElapsedGameTime.TotalSeconds; //Devemos aguardar um certo tempo if (transition <= 0) { if (this.state == Ghost.States.Frightened || this.state == Ghost.States.Waiting || this.state == Ghost.States.Chase) { this.Walk(); } else if (this.state == Ghost.States.Scatter) { this.Chase(); } this.transition = this.duration; this.state = this.nextState; this.OnStateChanged(); } else transition -= elapsed; }
public void Fright() { this.nextState = Ghost.States.Frightened; this.ghostVelocity = Constants.DEFAULT_PLAYER_VELOCITY * 0.8f; this.duration = 10.0; }
public void Chase() { this.nextState = Ghost.States.Chase; this.ghostVelocity = Constants.DEFAULT_PLAYER_VELOCITY; this.duration = 30.0; }
public void Walk() { this.nextState = Ghost.States.Scatter; this.ghostVelocity = Constants.DEFAULT_PLAYER_VELOCITY; this.duration = 15.0; }