示例#1
0
        public GhostBehavior()
        {
            Random rnd = new Random();

            this.state = Ghost.States.Waiting;
            this.ghostVelocity = Constants.DEFAULT_PLAYER_VELOCITY;
            this.transition = rnd.Next(10);
            this.Wait();
        }
示例#2
0
 public void Wait()
 {
     this.nextState  = Ghost.States.Waiting;
     this.duration = 15.0f;
 }
示例#3
0
        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;
        }
示例#4
0
 public void Fright()
 {
     this.nextState  = Ghost.States.Frightened;
     this.ghostVelocity = Constants.DEFAULT_PLAYER_VELOCITY * 0.8f;
     this.duration = 10.0;
 }
示例#5
0
 public void Chase()
 {
     this.nextState = Ghost.States.Chase;
     this.ghostVelocity = Constants.DEFAULT_PLAYER_VELOCITY;
     this.duration = 30.0;
 }
示例#6
0
 public void Walk()
 {
     this.nextState = Ghost.States.Scatter;
     this.ghostVelocity = Constants.DEFAULT_PLAYER_VELOCITY;
     this.duration = 15.0;
 }