Exemplo n.º 1
2
 // --- methods --- //
 /// <summary>
 /// Constructor of Inky.
 /// </summary>
 /// <param name="map">The map where Inky evolve.</param>
 /// <param name="pacman">The pacman to chase.</param>
 public Inky(Map map, Pacman pacman, Blinky blinky)
     : base(map, pacman)
 {
     _blinky = blinky;
 }
Exemplo n.º 2
0
        public Ghost(Map m, string character, Bitmap portret)
        {
            switch( character )
            {
            case "base" :
                this.ai = new BaseAI();
                break;
            case "guard" :
                this.ai = new GuardAI();
                break;
            case "hunter" :
                this.ai = new HunterAI();
                break;
            default :
                this.ai = new BaseAI();
                break;
            }

            this.position = m.GetStartGPosition();
            this.direction = Direction.down;
            this.mapa = m;
            this.ghost = portret;
            try
            {
                this.ghostR = ResourceManager.getGhost(4);
            } catch {
                MessageBox.Show("The ghost reverse image could not be read:", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public virtual Direction MakeDecision(Ghost g, Point pacPoint, Map map)
        {
            this.ways = g.mapa.PosibleWay( g.position ); 		// Bool array of posible way
            this.rnd = new Random();

            if( rnd.Next(1,9) == 5) return ((Direction) rnd.Next(0,4));  // Random element

            bool pravda = true;
            switch( this.ways.free )
            {
            case 1:				/* Turn round */
                if(pravda) return OneWay(g);
                break;
            case 2: 			/* go straight */
                if(pravda) return TwoWays(g);
                break;
            case 3: 			/* prefer 2 ways */
                if (pravda) return ThreeWays(g, this.ways);
                break;
            case 4: 			/* totaly random */
                if(pravda) return FourWays(g.direction);
                break;
            default :
                return ((Direction) rnd.Next(0,4));
            }

            return (Direction) rnd.Next(0,3);
        }
Exemplo n.º 4
0
        protected int _thinkCounter; // Permet de savoir quand l'acteur est au milieu d'une case

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor of Actor.
        /// </summary>
        /// <param name="map">A map representative of the pacman maze.</param>
        public Actor(Map map)
            : base(new Vector2(28, 28))
        {
            _map = map;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor of Blinky.
 /// </summary>
 /// <param name="map">The map where Blinky evolve.</param>
 /// <param name="pacman">The pacman to chase.</param>
 public Blinky(Map map, Pacman pacman)
     : base(map, pacman)
 {
     _elroySpeed = 0;
 }
Exemplo n.º 6
0
        public void ChoseMap(object sender, EventArgs e)
        {
            pause = true;

            OpenFileDialog vyber = new OpenFileDialog();
            vyber.Multiselect = false;
            vyber.Title = "Chose map";

            vyber.ShowDialog(this);
            ;
            try {
                if( vyber.CheckFileExists && vyber.CheckPathExists)
                {
                    Console.WriteLine("[OK] New map: {0}", vyber.FileName);

                    StopGame();
                    this.newMap = new Map( 0 );

                }
                else
                {
                    StopGame();
                    PrepareGame(1 , 0 , 3);
                    MessageBox.Show("Cannot open file.", "Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            } catch{
                MessageBox.Show("Cannot open file.", "Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            } finally {
                vyber.Dispose();
            }
        }
Exemplo n.º 7
0
        private void PrepareGame(int levelIN, int scoreIN, int livesIN)
        {
            if( this.newMap != null ) {
                this.mapa = this.newMap;
            } else {
                this.mapa = new Map ( 0 );
            }

            if(this.pac == null )	this.pac = new Pacman (this.mapa , 1, 3, 0);
            else
            {
                this.pac.mapa = this.mapa;
                this.pac.position = this.mapa.GetStartPosition();
            }
            if(SB != null) SB.Dispose();

            #if DEBUG
            Console.WriteLine("[OK] Map and Pacman create.");
            #endif

            #region /* rozmery */
            this.PlaygroundWidth = this.mapa.map.GetLength(0) * this.sizeField + 30;
            this.PlaygroundHeight = this.mapa.map.GetLength(1) * this.sizeField + 60;
            #endregion

            #region /* status bar */
            SB = new StatusBar();
            SB.Parent = this;
            SB.Text = "SPEED: " + this.actualSpeed.ToString() + ";  LIVES: 3;  SCORE: 0";
            SB.Anchor = AnchorStyles.Bottom;
            SB.Dock = DockStyle.Bottom;
            SB.Font = new Font("serif", 13);
            SB.Height = 25;
            SB.Width = this.PlaygroundWidth - 5;
            SB.ForeColor = Color.AliceBlue;
            #endregion

            this.bonusIs = true;
            this.BackColor = Color.Black;
            this.Select();		// ziskani zamereni

            ClientSize = new Size( this.PlaygroundWidth, this.PlaygroundHeight );

            Paint -= new PaintEventHandler( this.OnStart );
            Paint += new PaintEventHandler( this.OnPaint );
        }
Exemplo n.º 8
0
 // -- attributes --- //
 // --- methods --- //
 /// <summary>
 /// Constructor of Clyde.
 /// </summary>
 /// <param name="map">The map where Clyde evolve.</param>
 /// <param name="pacman">The pacman to chase.</param>
 public Clyde(Map map, Pacman pacman)
     : base(map, pacman)
 {
 }
Exemplo n.º 9
0
        protected bool[] Coin(Point here, Map map)
        {
            bool[] co = new bool[5];
            for(int i = 0; i < 4; i++)
                if( map.coins[ Figure.Shift( (Direction) i , here).X , Figure.Shift( (Direction) i , here).Y ] ) co[i] = true;
                else co[i] = false;

            co[4] = false;

            return co;
        }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor of pacman.
 /// </summary>
 /// <param name="map">The maze where the pacman evolve.</param>
 public Pacman(Map map)
     : base(map)
 {
     _textureOffset = new Vector2(0, 10);
 }
Exemplo n.º 11
0
 // -- attributes --- //
 // --- methods --- //
 /// <summary>
 /// Constructor of Pinky.
 /// </summary>
 /// <param name="map">The map where Pinky evolve.</param>
 /// <param name="pacman">The pacman to chase.</param>
 public Pinky(Map map, Pacman pacman)
     : base(map, pacman)
 {
 }
Exemplo n.º 12
0
        /// <summary>
        /// Constructor of the game main loop.
        /// </summary>
        public GameLoop()
        {
            Content.RootDirectory = "Content";

            _graphics = new GraphicsDeviceManager(this);
            _graphics.PreferredBackBufferWidth = 448;
            _graphics.PreferredBackBufferHeight = 576;
            _graphics.ApplyChanges();

            _ghosts = new Ghost[4];

            _map = new Map(_ghosts);
            _pacman = new Pacman(_map);

            Blinky blinky = new Blinky(_map, _pacman);
            Pinky pinky = new Pinky(_map, _pacman);
            Inky inky = new Inky(_map, _pacman, blinky);
            Clyde clyde = new Clyde(_map, _pacman);

            _ghosts[0] = blinky;
            _ghosts[1] = pinky;
            _ghosts[2] = inky;
            _ghosts[3] = clyde;

            _score = 0;
            _eatingScore = 0;
            _life = 3;
            _level = 1;
            _ready = 60 * 4;
            this.IsMouseVisible = true;

            _isOnHomeScreen = true;
            _homeScreen = new HomeScreen(_score, _highScore);
        }
Exemplo n.º 13
0
 // --- methods --- //
 /// <summary>
 /// Constructor of Ghost class.
 /// </summary>
 /// <param name="map">Map of the pacman game.</param>
 /// <param name="pacman">The pacman evolving in the map.</param>
 public Ghost(Map map, Pacman pacman)
     : base(map)
 {
     _pacman = pacman;
 }