예제 #1
0
        public Impostazioni(object mappaPacman, ref datiGhost[] datiGhosts)
        {
            InitializeComponent();
            this.mappaPacman = (Mappa)mappaPacman;
            this.datiGhosts  = datiGhosts;

            CoB_VelocitaPinky.SelectedIndex = CoB_VelocitaInky.SelectedIndex = CoB_VelocitaClyde.SelectedIndex = CoB_VelocitaBlinky.SelectedIndex = CoB_VelocitaPacman.SelectedIndex = 2;
        }
예제 #2
0
        public MainPacman()
        {
            InitializeComponent();
            IncorporaFont(17f, lbl_Close.Font.Style);

            eat_ghostPlayer.Load();
            eat_pillPlayer.Load();
            eat_powPlayer.Load();
            mortoPlayer.Load();
            riderePlayer.Load();
            startPlayer.Load();
            extra_livesPlayer.Load();


            lbl_Close.Font = new System.Drawing.Font(MyFontFamily, 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            #region dati

            List <int[]> zonaNavigabileOrizzontale = new List <int[]>();
            List <int[]> zonaNavigabileVerticale   = new List <int[]>();
            List <int[]> pilloleOrizzontale        = new List <int[]>();
            List <int[]> pilloleVerticale          = new List <int[]>();
            List <int[]> pilloleSpeciali           = new List <int[]>();

            zonaNavigabileOrizzontale.Add(new int[] { 12, 12, 162, 203, 354 });
            zonaNavigabileOrizzontale.Add(new int[] { 66, 12, 354 });
            zonaNavigabileOrizzontale.Add(new int[] { 107, 12, 80, 121, 162, 203, 244, 285, 354 });
            zonaNavigabileOrizzontale.Add(new int[] { 149, 121, 244 });
            zonaNavigabileOrizzontale.Add(new int[] { 190, -22, 121, 244, 387 });
            zonaNavigabileOrizzontale.Add(new int[] { 231, 121, 244 });
            zonaNavigabileOrizzontale.Add(new int[] { 272, 12, 162, 203, 354 });
            zonaNavigabileOrizzontale.Add(new int[] { 313, 12, 38, 80, 285, 327, 354 });
            zonaNavigabileOrizzontale.Add(new int[] { 354, 12, 80, 121, 162, 203, 244, 285, 354 });
            zonaNavigabileOrizzontale.Add(new int[] { 395, 12, 354 });

            zonaNavigabileVerticale.Add(new int[] { 12, 12, 107, 272, 313, 354, 395 });
            zonaNavigabileVerticale.Add(new int[] { 38, 313, 354 });
            zonaNavigabileVerticale.Add(new int[] { 80, 12, 354 });
            zonaNavigabileVerticale.Add(new int[] { 121, 66, 107, 149, 272, 313, 354 });
            zonaNavigabileVerticale.Add(new int[] { 162, 12, 66, 107, 149, 272, 313, 354, 395 });
            zonaNavigabileVerticale.Add(new int[] { 203, 12, 66, 107, 149, 272, 313, 354, 395 });
            zonaNavigabileVerticale.Add(new int[] { 244, 66, 107, 149, 272, 313, 354 });
            zonaNavigabileVerticale.Add(new int[] { 285, 12, 354 });
            zonaNavigabileVerticale.Add(new int[] { 327, 313, 354 });
            zonaNavigabileVerticale.Add(new int[] { 354, 12, 107, 272, 313, 354, 395 });

            pilloleOrizzontale.Add(new int[] { 21, 21, 185, 12, 213, 378, 12 });
            pilloleOrizzontale.Add(new int[] { 76, 21, 378, 26 });
            pilloleOrizzontale.Add(new int[] { 117, 21, 102, 6, 130, 186, 4, 213, 268, 4, 296, 378, 6 });
            pilloleOrizzontale.Add(new int[] { 281, 21, 185, 12, 213, 378, 12 });
            pilloleOrizzontale.Add(new int[] { 322, 34, 62, 2, 89, 185, 7, 213, 309, 7, 336, 364, 2 });
            pilloleOrizzontale.Add(new int[] { 364, 21, 102, 6, 130, 186, 4, 213, 268, 4, 296, 378, 6 });
            pilloleOrizzontale.Add(new int[] { 405, 21, 378, 26 });

            pilloleVerticale.Add(new int[] { 21, 35, 35, 1, 62, 62, 1, 89, 117, 2, 295, 322, 2, 377, 405, 2 });
            pilloleVerticale.Add(new int[] { 48, 336, 364, 2 });
            pilloleVerticale.Add(new int[] { 89, 35, 76, 3, 89, 117, 2, 131, 281, 11, 295, 322, 2, 336, 364, 2 });
            pilloleVerticale.Add(new int[] { 130, 89, 117, 2, 336, 364, 2 });
            pilloleVerticale.Add(new int[] { 172, 34, 76, 3, 295, 323, 2, 377, 405, 2 });
            pilloleVerticale.Add(new int[] { 213, 34, 76, 3, 295, 323, 2, 377, 405, 2 });
            pilloleVerticale.Add(new int[] { 255, 89, 117, 2, 336, 364, 2 });
            pilloleVerticale.Add(new int[] { 296, 35, 76, 3, 89, 117, 2, 131, 281, 11, 295, 322, 2, 336, 364, 2 });
            pilloleVerticale.Add(new int[] { 336, 336, 364, 2 });
            pilloleVerticale.Add(new int[] { 365, 35, 35, 1, 62, 62, 1, 89, 117, 2, 295, 322, 2, 377, 405, 2 });

            pilloleSpeciali.Add(new int[] { 44, 17, 17, 1, 360, 360, 1 });
            pilloleSpeciali.Add(new int[] { 317, 17, 17, 1, 360, 360, 1 });

            int[,] zoneSpeciali = new int[, ] {
                { 387, 190, -22, 190, 2 }, { -22, 190, 387, 190, 0 }
            };


            ghosts     = new Ghost[4];
            datiGhosts = new datiGhost[4];

            ghosts[0]                            = new Ghost("blinky", 0, 60, 7000, 3000, 250);
            datiGhosts[0].speed                  = new Timer();
            datiGhosts[0].speedIniziale          = datiGhosts[0].speed.Intervallo = 32;
            datiGhosts[0].durataMorte            = new Timer();
            datiGhosts[0].durataMorte.Intervallo = 5000;
            datiGhosts[0].durataMorte.Tag        = datiGhosts[0].speed.Tag = 0;
            datiGhosts[0].direzione              = 0;
            datiGhosts[0].puntoPartenza          = new Point(12, 12);

            ghosts[1]                            = new Ghost("inky", 0, 60, 7000, 3000, 250);
            datiGhosts[1].speed                  = new Timer();
            datiGhosts[1].speedIniziale          = datiGhosts[1].speed.Intervallo = 33;
            datiGhosts[1].durataMorte            = new Timer();
            datiGhosts[1].durataMorte.Intervallo = 5000;
            datiGhosts[1].durataMorte.Tag        = datiGhosts[1].speed.Tag = 1;
            datiGhosts[1].direzione              = 0;
            datiGhosts[1].puntoPartenza          = new Point(354, 12);

            ghosts[2]                            = new Ghost("pinky", 0, 60, 7000, 3000, 250);
            datiGhosts[2].speed                  = new Timer();
            datiGhosts[2].speedIniziale          = datiGhosts[2].speed.Intervallo = 34;
            datiGhosts[2].durataMorte            = new Timer();
            datiGhosts[2].durataMorte.Intervallo = 5000;
            datiGhosts[2].durataMorte.Tag        = datiGhosts[2].speed.Tag = 2;
            datiGhosts[2].direzione              = 0;
            datiGhosts[2].puntoPartenza          = new Point(12, 395);

            ghosts[3]                            = new Ghost("clyde", 0, 60, 7000, 3000, 250);
            datiGhosts[3].speed                  = new Timer();
            datiGhosts[3].speedIniziale          = datiGhosts[3].speed.Intervallo = 35;
            datiGhosts[3].durataMorte            = new Timer();
            datiGhosts[3].durataMorte.Intervallo = 5000;
            datiGhosts[3].durataMorte.Tag        = datiGhosts[3].speed.Tag = 3;
            datiGhosts[3].direzione              = 0;
            datiGhosts[3].puntoPartenza          = new Point(354, 395);

            #endregion

            pacmanSpeed.Intervallo = 29;

            mappa = new Mappa(Properties.Resources.background, zonaNavigabileOrizzontale, zonaNavigabileVerticale, pacman, 190, 313, 0, pacmanSpeed, pilloleOrizzontale, pilloleVerticale, pilloleSpeciali, ghosts, ref datiGhosts, zoneSpeciali);
            mappa.incrementoPunteggio         += new EventHandler(incrementoPunteggio);
            mappa.incrementoPunteggioSpeciale += new EventHandler(incrementoPunteggioSpeciale);
            mappa.mortePacman += mortePacman;
            mappa.morteGhost  += incrementoPunteggioGhost;
            mappa.vinto       += vinto;

            gioco     = new Gioco(mappa, 2, lbl_info, MyFontFamily);
            this.Size = new Size(0, 0);
            this.Controls.Add(gioco);
            gioco.Location = new Point(0, 30);

            gioco.MouseDown += MainPacman_MouseDown;
            gioco.MouseUp   += MainPacman_MouseUp;
            gioco.MouseMove += MainPacman_MouseMove;
            mappa.MouseDown += MainPacman_MouseDown;
            mappa.MouseUp   += MainPacman_MouseUp;
            mappa.MouseMove += MainPacman_MouseMove;

            this.info = new Info(MyFontFamily);
            this.Controls.Add(this.info);
            this.info.Location = new Point(gioco.Size.Width, gioco.Size.Height - info.Size.Height + 30);
            this.info.BringToFront();

            spostaInfo.Intervallo = 10;
            spostaInfo.Tick      += spostaSinistraInfo;

            impostazioni = new Impostazioni(mappa, ref datiGhosts);
            this.Controls.Add(impostazioni);
            impostazioni.Location = new Point(0, -impostazioni.Size.Height);
            impostazioni.BringToFront();
            spostaImpostazioni.Intervallo = 10;
            spostaImpostazioni.Tick      += spostaSinistraImpostazioni;

            start.Tick      += inizia;
            start.Intervallo = 10;
            start.StartP();
        }
예제 #3
0
        public Gioco(Mappa mappa, int vite, Label info, FontFamily MyFontFamily)
        {
            this.mappa          = mappa;
            this.mappa.Location = new Point(0, 20);
            this.Controls.Add(mappa);
            this.BackColor    = Color.Black;
            this.Size         = new Size(mappa.Size.Width, mappa.Size.Height + mappa.Location.Y + 80);
            this.info         = info;
            this.MyFontFamily = MyFontFamily;

            this.Controls.Add(lbl_Score);
            lbl_Score.Text      = "SCORE";
            lbl_Score.Font      = new System.Drawing.Font(MyFontFamily, 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lbl_Score.ForeColor = Color.White;
            lbl_Score.BackColor = Color.Transparent;
            lbl_Score.Location  = new Point(0, mappa.Size.Height + mappa.Location.Y);
            lbl_Score.AutoSize  = true;

            this.Controls.Add(lbl_ScoreNumber);
            lbl_ScoreNumber.Text      = "0";
            lbl_ScoreNumber.Font      = new System.Drawing.Font(MyFontFamily, 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lbl_ScoreNumber.ForeColor = Color.Yellow;
            lbl_ScoreNumber.BackColor = Color.Transparent;
            lbl_ScoreNumber.Location  = new Point(lbl_Score.Size.Width, mappa.Size.Height + mappa.Location.Y);
            lbl_ScoreNumber.BringToFront();
            lbl_ScoreNumber.AutoSize = true;

            this.Controls.Add(lbl_Lives);
            lbl_Lives.Text      = "LIVES";
            lbl_Lives.Font      = new System.Drawing.Font(MyFontFamily, 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lbl_Lives.ForeColor = Color.White;
            lbl_Lives.BackColor = Color.Transparent;
            lbl_Lives.Location  = new Point(180, mappa.Size.Height + mappa.Location.Y);
            lbl_Lives.BringToFront();
            lbl_Lives.AutoSize = true;

            this.Controls.Add(lbl_Livello);
            lbl_Livello.Text      = "LIVELLO " + this.livello.ToString();
            lbl_Livello.Font      = new System.Drawing.Font(MyFontFamily, 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lbl_Livello.ForeColor = Color.Green;
            lbl_Livello.BackColor = Color.Transparent;
            lbl_Livello.Location  = new Point(0, mappa.Size.Height + mappa.Location.Y + 25);
            lbl_Livello.BringToFront();
            lbl_Livello.AutoSize = true;

            this.Controls.Add(lbl_Pause);
            lbl_Pause.Text      = "PAUSE";
            lbl_Pause.Font      = new System.Drawing.Font(MyFontFamily, 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lbl_Pause.ForeColor = Color.White;
            lbl_Pause.BackColor = Color.Transparent;
            lbl_Pause.Location  = new Point(-230, 230);
            lbl_Pause.BringToFront();
            lbl_Pause.AutoSize = true;

            restart.Image = Properties.Resources.refresh2;
            this.Controls.Add(restart);
            restart.Location    = new Point(23, 0);
            restart.MouseEnter += restartMouseEnter;
            restart.MouseLeave += restartMouseLeave;
            restart.Click      += restartMouseClick;
            restart.Size        = Properties.Resources.refresh2.Size;

            imagePausePlay[0, 0] = Properties.Resources.pause2;
            imagePausePlay[0, 1] = Properties.Resources.pause;

            imagePausePlay[1, 0] = Properties.Resources.play2;
            imagePausePlay[1, 1] = Properties.Resources.play;

            pausePlay.Image = imagePausePlay[0, 0];
            this.Controls.Add(pausePlay);
            pausePlay.Location    = new Point(0, 0);
            pausePlay.MouseEnter += pausePlayMouseEnter;
            pausePlay.MouseLeave += pausePlayMouseLeave;
            pausePlay.Click      += pausePlayMouseClick;
            pausePlay.Size        = Properties.Resources.refresh2.Size;

            sposta.Intervallo = 10;
            sposta.Tick      += spostaDestra;

            this.Vite = vite;
        }