private void CheckGhostHit(Ghost ghost) { if (ghost.CheckPoint(pacman) == true) { lives--; l_lives.Text = "Lives: " + lives; bewegung = false; } }
public Boolean ghostCollision(Pacman pacman, Ghost ghost) { if ((pacman.element.Position.X < ghost.element.Position.X +20 && pacman.element.Position.X > ghost.element.Position.X - 20) && (pacman.element.Position.Y < ghost.element.Position.Y + 20 && pacman.element.Position.Y > ghost.element.Position.Y - 20)) return true; return false; }
public Form1() { InitializeComponent(); this.raster = new Raster(this.pictureBox1.ClientSize.Height, this.pictureBox1.ClientSize.Width); this.pictureBox1.Invalidate(); Ghost g1 = new Ghost(645, 365, pbblue); // inizalisiert die Ghosts Ghost g2 = new Ghost(645, 5, pborange); Ghost g3 = new Ghost(5, 365, pbred); ghostlist.Add(g1); ghostlist.Add(g2); ghostlist.Add(g3); ap.HitPoint += new AllePunkte.HitPointHandler(ap_HitPoint); ap.Won +=new AllePunkte.WinHandler(WinMessage); a = new Thread(Play); // Musik a.Name = "Pacman_Music"; a.Start(); }
public Vector2?FindPath(Ghost aGhost) { return(aGhost.GoToPosition(aGhost.Player.Column, aGhost.Player.Row)); }
public void GhostsMove(Ghost ghost) { if (ghost.GhostSteps < chunkSize / step) { switch (ghost.GhostDirection) { case 1: ghost.pctGhost.Location = new Point(ghost.pctGhost.Location.X, ghost.pctGhost.Location.Y - step); break; case 2: if (ghost.GhostCenterX - step < 0) { ghost.pctGhost.Location = new Point(width - chunkSize / 2 - step, ghost.pctGhost.Location.Y); } else { ghost.pctGhost.Location = new Point(ghost.pctGhost.Location.X - step, ghost.pctGhost.Location.Y); } break; case 3: ghost.pctGhost.Location = new Point(ghost.pctGhost.Location.X, ghost.pctGhost.Location.Y + step); break; case 0: if (ghost.GhostCenterX + step >= width) { ghost.pctGhost.Location = new Point(-1 * chunkSize / 2, ghost.pctGhost.Location.Y); } else { ghost.pctGhost.Location = new Point(ghost.pctGhost.Location.X + step, ghost.pctGhost.Location.Y); } break; } ghost.GhostCenterX = ghost.pctGhost.Location.X + chunkSize / 2; ghost.GhostCenterY = ghost.pctGhost.Location.Y + chunkSize / 2; ghost.GhostSteps++; } else { if (ghostMoveType == 1) { if (ghost.Name == "Yellow") { switch ((int)pacman.direction) { case 1: ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX, pacman.PacmanPctCenterY - 4 * chunkSize); break; case 2: ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX - 4 * chunkSize, pacman.PacmanPctCenterY); break; case 3: ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX, pacman.PacmanPctCenterY + 4 * chunkSize); break; case 4: ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX + 4 * chunkSize, pacman.PacmanPctCenterY); break; } } else if (ghost.Name == "Red") { ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX, pacman.PacmanPctCenterY); } else if (ghost.Name == "Pink") { switch ((int)pacman.direction) { case 1: ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX, pacman.PacmanPctCenterY + 4 * chunkSize); break; case 2: ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX + 4 * chunkSize, pacman.PacmanPctCenterY); break; case 3: ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX, pacman.PacmanPctCenterY - 4 * chunkSize); break; case 4: ghost.GhostDirection = GhostsDirection(ghost, pacman.PacmanPctCenterX - 4 * chunkSize, pacman.PacmanPctCenterY); break; } } ghost.GhostSteps = 0; } else if (ghostMoveType == 2) { if (ghost.Name == "Yellow") { ghost.GhostDirection = GhostsDirection(ghost, 560, 10); } else if (ghost.Name == "Red") { ghost.GhostDirection = GhostsDirection(ghost, 10, 10); } else if (ghost.Name == "Pink") { ghost.GhostDirection = GhostsDirection(ghost, 10, 620); } ghost.GhostSteps = 0; } } }
int GhostsDirection(Ghost ghost, int targetX, int targetY) { int upChunkValue = game.GameMap[ghost.GhostCenterX / chunkSize, (ghost.GhostCenterY / chunkSize) - 1]; int downChunkValue = game.GameMap[ghost.GhostCenterX / chunkSize, (ghost.GhostCenterY / chunkSize) + 1]; int rightChunkValue = 0; int leftChunkValue = 0; if ((ghost.GhostCenterX / chunkSize) + 1 == 28) { rightChunkValue = game.GameMap[0, ghost.GhostCenterY / chunkSize]; } else { rightChunkValue = game.GameMap[(ghost.GhostCenterX / chunkSize) + 1, ghost.GhostCenterY / chunkSize]; } if ((ghost.GhostCenterX / chunkSize) - 1 == -1) { rightChunkValue = game.GameMap[width / chunkSize - 1, ghost.GhostCenterY / chunkSize]; } else { leftChunkValue = game.GameMap[(ghost.GhostCenterX / chunkSize) - 1, ghost.GhostCenterY / chunkSize]; } int nextDirection = 0; double lenght; ghostWayLenght = 1000000000; if (upChunkValue != 1 && (ghost.GhostDirection + 2) % 4 != 1) { ghostWayLenght = Math.Sqrt(Math.Pow(ghost.GhostCenterX - targetX, 2) + Math.Pow(ghost.GhostCenterY - chunkSize - targetY, 2)); nextDirection = 1; } if (leftChunkValue != 1 && (ghost.GhostDirection + 2) % 4 != 2) { lenght = Math.Sqrt(Math.Pow(ghost.GhostCenterX - chunkSize - targetX, 2) + Math.Pow(ghost.GhostCenterY - targetY, 2)); if (lenght < ghostWayLenght) { ghostWayLenght = lenght; nextDirection = 2; } } if (downChunkValue != 1 && (ghost.GhostDirection + 2) % 4 != 3) { lenght = Math.Sqrt(Math.Pow(ghost.GhostCenterX - targetX, 2) + Math.Pow(ghost.GhostCenterY + chunkSize - targetY, 2)); if (lenght < ghostWayLenght) { ghostWayLenght = lenght; nextDirection = 3; } } if (rightChunkValue != 1 && (ghost.GhostDirection + 2) % 4 != 0) { lenght = Math.Sqrt(Math.Pow(ghost.GhostCenterX + chunkSize - targetX, 2) + Math.Pow(ghost.GhostCenterY - targetY, 2)); if (lenght < ghostWayLenght) { ghostWayLenght = lenght; nextDirection = 0; } } return(nextDirection); }
public Vector2?FindPath(Ghost aGhost) { return(aGhost.AvoidPosition(aGhost.Player.Position)); }
public void Exit(Ghost aGhost) { Console.ForegroundColor = aGhost.Color; Console.WriteLine("Exited SCARED"); }
public override void LoadContent() { _font = Resources.GetFont(Resources.FontResources.NinaB); var tempSheet = Resources.GetBitmap(Resources.BitmapResources.pacman); _spriteSheet = new Bitmap(tempSheet.Width, tempSheet.Height); _spriteSheet.DrawImage(0, 0, tempSheet, 0, 0, tempSheet.Width, tempSheet.Height); _spriteSheet.MakeTransparent(Microsoft.SPOT.Presentation.Media.Color.Black); _maze = new Maze(); _maze.Draw(Surface, Host); _pacman = new Player(_spriteSheet, _maze); #region Initialize Bonus Point Sprites _bonus200 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(80, 104, 16, 8) })); _bonus400 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(96, 104, 16, 8) })); _bonus800 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(112, 104, 16, 8) })); _bonus1600 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(128, 104, 16, 8) })); _bonus100 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(0, 112, 16, 8) })); _bonus300 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(16, 112, 16, 8) })); _bonus500 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(32, 112, 16, 8) })); _bonus700 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(48, 112, 16, 8) })); _bonus1000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(64, 112, 20, 8) })); _bonus2000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(84, 112, 20, 8) })); _bonus3000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(106, 112, 20, 8) })); _bonus5000 = new Sprite(new AnimationSequence(_spriteSheet, 0, new Rect[] { new Rect(128, 112, 16, 8) })); #endregion #region Initialize Ghosts _blinky = new Ghost(_spriteSheet, _maze, _pacman, 16, new Personality() { ScatterX = 13 * 16, ScatterY = -2 * 16, TargetOffsetX = 0, TargetOffsetY = 0, HouseX = 7 * 16, HouseY = 7 * 16, StartX = 7 * 16, StartY = 5 * 16 }); _blinky.CurrentDirection = Direction.Left; _pinky = new Ghost(_spriteSheet, _maze, _pacman, 32, new Personality() { ScatterX = 1 * 16, ScatterY = -2 * 16, TargetOffsetX = 4 * 16, TargetOffsetY = 0, HouseX = 6 * 16, HouseY = 7 * 16, StartX = 6 * 16, StartY = 7 * 16 }); _pinky.CurrentDirection = Direction.Left; _inky = new Ghost(_spriteSheet, _maze, _pacman, 48, new Personality() { ScatterX = 14 * 16, ScatterY = 15 * 16, TargetOffsetX = -3 * 16, TargetOffsetY = 0, HouseX = 7 * 16, HouseY = 7 * 16, StartX = 7 * 16, StartY = 7 * 16 }); _inky.CurrentDirection = Direction.Left; _clyde = new Ghost(_spriteSheet, _maze, _pacman, 64, new Personality() { ScatterX = 0 * 16, ScatterY = 15 * 16, TargetOffsetX = 0, TargetOffsetY = -2 * 16, HouseX = 8 * 16, HouseY = 7 * 16, StartX = 8 * 16, StartY = 7 * 16 }); _clyde.CurrentDirection = Direction.Left; #endregion _pacman.Enemies = new Ghost[] { _blinky, _pinky, _inky, _clyde }; #region Add objects to scene AddToScene(_showBonusCountDown); AddToScene(_showBonusScoreCountDown); AddToScene(_maze); AddToScene(_pacman); AddToScene(_blinky); AddToScene(_pinky); AddToScene(_inky); AddToScene(_clyde); #endregion _maze.LevelComplete += MazeLevelComplete; _showBonusCountDown.Expired += BonusCountDown_Expired; MessageService.Instance.Subscribe(typeof(Messages.PacmanDeadMessage), HandlePacmanDeadMessage); MessageService.Instance.Subscribe(typeof(Messages.PacmanAteGhostMessage), HandlePacmanAteGhostMessage); MessageService.Instance.Subscribe(typeof(Messages.AteBonusItemMessage), HandleAteBonusItem); base.LoadContent(); Reset(); }
public void Enter(Ghost aGhost) { Console.ForegroundColor = aGhost.Color; Console.WriteLine("Entered DEAD"); SoundEffectManager.PlayGhostSound(); }
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(); }
public void Remove(Ghost ghost) { Ghosts.Remove(ghost); }
public void Add(Ghost ghost) { Ghosts.Add(ghost); }
private void CreateLevel() { StreamReader file = new StreamReader("level.txt"); while (!file.EndOfStream) level_data.Add(file.ReadLine()); file.Close(); for (int i = 0; i < level_data.Count; i++) tile_Y += 1; for (int j = 0; j < level_data[1].Length; j++) tile_X += 1; level = new Tile[tile_Y, tile_X]; for (int i = 0; i < level_data.Count; i++) { for (int j = 0; j < level_data[i].Length; j++) { if (level_data[i][j] == 'x') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 0, 16, 16)); } else if (level_data[i][j] == 'f') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); } else if (level_data[i][j] == 'r' || level_data[i][j] == 'm' || level_data[i][j] == 'b' || level_data[i][j] == 'o') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); Character g = new Ghost(character_sheet, new Vector2(j * 16, i * 16), level_data); ghosts.Add(g); } else if (level_data[i][j] == 'p') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 0, 16, 16)); Food f = new Food(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(0, 16, 16, 16)); food.Add(f); pacman_startpos = new Vector2(j * 16, i * 16); pacman = new Pacman(character_sheet, new Vector2(j * 16, i * 16), level_data, pacman_startpos); } else if (level_data[i][j] == 'e') { level[i, j] = new Tile(world_sheet, new Vector2(j * 16, i * 16), new Rectangle(16, 16, 16, 16)); } } } }
public void Enter(Ghost aGhost) { Console.ForegroundColor = aGhost.Color; Console.WriteLine("Entered ALIVE"); }
/// <summary> /// East ghost /// </summary> /// <param name="clyde"></param> public void EatGhost(Ghost ghost) { ghost.Kill(); }
static void Main() { //İmleci Görünmez yapmak için Console.CursorVisible = false; // //Sound Effects // SoundPlayer Walk = new SoundPlayer(); Walk.SoundLocation = Environment.CurrentDirectory + "\\SFX/Walk.wav"; SoundPlayer Gover = new SoundPlayer(); Gover.SoundLocation = Environment.CurrentDirectory + "\\SFX/GameOver.wav"; SoundPlayer Victory = new SoundPlayer(); Victory.SoundLocation = Environment.CurrentDirectory + "\\SFX/Victory.wav"; // //LOADING // Loading(); // //Mega Yem // Yem[] Yemlik = new Yem[6]; int[,] Konum = new int[6, 2] { { 9, 5 }, { 9, 16 }, { 32, 5 }, { 32, 16 }, { 19, 2 }, { 22, 19 } }; for (int i = 0; i < 6; i++) { Yem k1 = new Yem(); k1.X = Konum[i, 0]; k1.Y = Konum[i, 1]; Yemlik[i] = k1; } // //Mini Yem // MiniYem[] Puan = new MiniYem[22]; int[,] Local = new int[22, 2] { { 11, 4 }, { 11, 6 }, { 30, 4 }, { 30, 6 }, { 19, 8 }, { 22, 8 }, { 11, 15 }, { 11, 17 }, { 30, 15 }, { 30, 17 }, { 19, 13 }, { 22, 13 }, { 3, 8 }, { 38, 8 }, { 3, 13 }, { 38, 13 }, { 18, 3 }, { 23, 18 }, { 4, 5 }, { 4, 16 }, { 37, 5 }, { 37, 16 } }; //{18,3},{23,18},{4,5},{4,16},{37,5},{37,16} Pacman CLU = new Pacman(); for (int i = 0; i < 22; i++) { MiniYem k2 = new MiniYem(); k2.X = Local[i, 0]; k2.Y = Local[i, 1]; Puan[i] = k2; } // //Green Ghost Object // Ghost Enemy = new Ghost(); Enemy.X = 15; Enemy.Y = 18; Enemy.BColor = ConsoleColor.Green; Enemy.FColor = ConsoleColor.DarkMagenta; int AdımX = 15; int AdımY = 18; byte flag = 0; // //Red Ghost Object // Ghost Jelly = new Ghost(); Jelly.X = 15; Jelly.Y = 18; Jelly.BColor = ConsoleColor.Red; Jelly.FColor = ConsoleColor.Gray; int StepX = 26; int StepY = 3; byte Bayrak = 0; bool Game = true; ConsoleKeyInfo Key = Console.ReadKey(); bool isKeyPressed = false; Console.Clear(); //Menu.Stop(); DrawFrame(); PacMap.Map(); //bool Game = false; Walk.PlayLooping(); while (Game) { //PacMap.Map(); //Key = Console.ReadKey(); CLU.PacMove(Key); if (Console.KeyAvailable) { Key = Console.ReadKey(); isKeyPressed = true; } else { isKeyPressed = false; } CLU.PacMove(Key, isKeyPressed); CLU.PacManCiz(); // //Green Ghost // Enemy.tX = Enemy.X; Enemy.tY = Enemy.Y; Enemy.X = AdımX; Enemy.Y = AdımY; if (((Enemy.X == CLU.X) && (Enemy.Y == CLU.Y)) || ((Enemy.tX == CLU.X) && (Enemy.tY == CLU.X)) || ((Enemy.X == CLU.tX) && (Enemy.X == CLU.tY)) || ((Enemy.tX == CLU.tX) && (Enemy.tY == CLU.tY))) { Gover.Play(); Game = false; } Enemy.Ciz(); Enemy.Move(Enemy.tX, Enemy.tY); if (flag == 0) { AdımY--; AdımX = 15; if (AdımY <= 3) { flag = 1; } } else if (flag == 1) { AdımY = 3; AdımX--; if (AdımX <= 7) { flag = 2; } } else if (flag == 2) { AdımY = 3; AdımX++; if (AdımX >= 15) { flag = 3; } } else if (flag == 3) { AdımY++; AdımX = 15; if (AdımY >= 18) { flag = 0; } } // // //Red Ghost // Jelly.tX = Jelly.X; Jelly.tY = Jelly.Y; Jelly.X = StepX; Jelly.Y = StepY; if ((Jelly.X == CLU.X) && (Jelly.Y == CLU.Y)) { Gover.Play(); Game = false; } Jelly.Ciz(); Jelly.Move(Jelly.tX, Jelly.tY); if (Bayrak == 0) { StepY++; StepX = 26; if (StepY >= 18) { Bayrak = 1; } } else if (Bayrak == 1) { StepY = 18; StepX++; if (StepX >= 34) { Bayrak = 2; } } else if (Bayrak == 2) { StepY = 18; StepX--; if (StepX <= 26) { Bayrak = 3; } } else if (Bayrak == 3) { StepY--; StepX = 26; if (StepY <= 3) { Bayrak = 0; } } // //PacMap PacMap.Map(); for (int i = 0; i < 6; i++) { Yemlik[i].YemCiz(); if (((Yemlik[i].X == CLU.X) && (Yemlik[i].Y == CLU.Y)) && (Yemlik[i].Exist == true)) { Yemlik[i].Exist = false; CLU.PacManCiz(); CLU.Score += 20; //Walk.Play(); } } // for (int i = 0; i < 22; i++) { Puan[i].YemCiz(); if (((Puan[i].X == CLU.X) && (Puan[i].Y == CLU.Y)) && (Puan[i].Exist == true)) { Puan[i].Exist = false; CLU.PacManCiz(); CLU.Score += 5; //Walk.Play(); } } // //DrawFrame DrawFrame(); //Thread.Sleep(20); CLU.PrintScore(); // //Score Limit // if (CLU.Score >= 230) { Walk.Stop(); Victory.Play(); Game = false; } Thread.Sleep(100); } if (CLU.Score < 230) { GameOver(CLU.Score); } else { GameWon(CLU.Score); } bool ReGame = Replay(); if (ReGame == true) { Main(); } else { Environment.Exit(0); } }
public Vector2?FindPath(Ghost aGhost) { return(aGhost.GoToPosition((int)aGhost.SpawnPosition.X / Tile.Size, (int)aGhost.SpawnPosition.Y / Tile.Size)); }