Exemplo n.º 1
0
        protected override void computeTargetTile(PacMan pac, Ghost ghost)
        {
            //We target a different point according to the mode
            switch (this.mode)
            {
            case Mode.Scatter:
                target = new Position(-1, 2);     //We target a fixed point in a corner
                break;

            case Mode.StayIn:
                target = new Position(14, 14);     //We target the center of the square to stay in it
                break;

            case Mode.GoOut:     //We target outside of the square
                target = new Position(0, 14);
                break;

            case Mode.Normal:
                //This ghost targets four tiles ahead of the pacman
                Position pos = fourAhead(pac.getState(), pac.getPosition());
                if (pac.getState() == State.Up)
                {
                    //According to an overflow bug in the original version,
                    //When the pacman is heading up, the target was also four tiles to the left.
                    //For a purpose of keeping the same artificial intelligence, we decided to keep this
                    //even though it does not causes any bug today.
                    pos.setPosY(pos.getPosY() - 4);
                }
                target = pos;
                break;
            }
        }
Exemplo n.º 2
0
        //Overriding computeTargetTile so that we can have a different target
        protected override void computeTargetTile(PacMan pac, Ghost ghost)
        {
            switch (this.mode)
            {
            case Mode.Scatter:     //If we are in Scatter mode, we target a fixed point in the corner of the map
                target = new Position(32, 28);
                break;

            case Mode.StayIn:     //We stay in the center
                target = new Position(14, 14);
                break;

            case Mode.GoOut:     //We target outside the center
                target = new Position(0, 14);
                break;

            case Mode.Normal:     //We chase the player

                //This ghost target two tiles ahead of the pacman, and create a vector from this
                //new position and the position of the red ghost, this vector timed by 2 gives
                //The target of the blue ghost.
                Position tmp = twoAhead(pac.getState(), pac.getPosition());
                int      xg  = ghost.getPosition().getPosX();
                int      yg  = ghost.getPosition().getPosY();
                int      xp  = pac.getPosition().getPosX();
                int      yp  = pac.getPosition().getPosY();
                target = new Position(2 * xp - xg, 2 * yp - yg);
                break;
            }
        }