コード例 #1
0
ファイル: PacSprite.cs プロジェクト: EphemeralGeek/Pacman
 public PacSprite(Element e, double size)
     : base(e, size)
 {
     Path = "pacman/pacman";
     frames = 6;
     PlayMode = Mode.ForwardAndBackward;
 }
コード例 #2
0
ファイル: GhostSprite.cs プロジェクト: EphemeralGeek/Pacman
 /// <summary>
 /// This is just like the Sprite constructor
 /// except for the Color argument. This will
 /// let the ghost be drawn as any color desired.
 /// </summary>
 /// <param name="e">The element to be modeled</param>
 /// <param name="Color">The color of the ghost sprite</param>
 public GhostSprite(Element e, Color Color, double size)
     : base(e, size)
 {
     Path = "ghost/ghost";
     frames = 4;
     GhostColor = Color;
     fps = 1000 / 20;
     PlayMode = Mode.ForwardAndBackward;
 }
コード例 #3
0
ファイル: Sprite.cs プロジェクト: EphemeralGeek/Pacman
 public Sprite(Element e, double size)
 {
     Element = e;
     Prefix = "images_64/";
     Path = "fruit/banana";
     PlayMode = Mode.Repeat;
     frames = 1;
     this.size = size;
     scale = size / 64;
 }
コード例 #4
0
ファイル: SBoard.cs プロジェクト: EphemeralGeek/Pacman
        public SBoard(double width, double height, double x, double y, Element element)
            : base((int)width, (int)height, (int)x, (int)y)
        {
            player = element;
            LoadContent();

            posX = (float)x;
            posY = (float)y;
            Console.WriteLine(posX);
        }
コード例 #5
0
ファイル: WallSprite.cs プロジェクト: EphemeralGeek/Pacman
 public bool isWallBR(int x, int y, Element[,] c)
 {
     x = x + 1;
         y = y + 1;
         if ((((x < 0) || (y < 0)) || (x > c.GetLength(0) - 1) || (y > c.GetLength(1) - 1)) || c[x, y] == null || c[x, y].et.Equals(Enum.ElementTypes.PacDot) || c[x, y].et.Equals(Enum.ElementTypes.PacPlayer) || c[x, y].et.Equals(Enum.ElementTypes.Ghost) || c[x, y].et.Equals(Enum.ElementTypes.Powerup) || c[x, y].et.Equals(Enum.ElementTypes.Fruit) || c[x, y].et.Equals(Enum.ElementTypes.GhostSpawn))
         {
             return false;
         }
         else if (c[x, y].et.Equals(Enum.ElementTypes.Wall))
         {
             return true;
         }
         return false;
 }
コード例 #6
0
ファイル: WallSprite.cs プロジェクト: EphemeralGeek/Pacman
        public WallSprite(Element e, String path, double size, Board board)
            : base(e, size)
        {
            b = board;
            int ex = (int)e.X;
            int ey = (int)e.Y;
            int X = b.Width;
            int Y = b.Height;
            Element[,] c = new Element[X, Y];
            foreach (Element el in b.Elements)
            {
                int x1 = (int)el.X;
                int y1 = (int)el.Y;
                c[x1, y1] = el;

            }
            Path = wallpath(c,ex, ey);
        }
コード例 #7
0
ファイル: Game.cs プロジェクト: EphemeralGeek/Pacman
        /*
         * This method is responsible for creating players. The types of players
         * as well as the controller and controller scheme are a must when calling
         * this method.
         * */
        private void CreatePlayer(PlayerTypes humanOrAI, PlayerTypes pacOrGhost, ControllerTypes controller, ControllerScheme scheme)
        {
            Element player = new Element();

            if (pacOrGhost == PlayerTypes.PacPlayer)
                player.et = ElementTypes.PacPlayer;
            else
                player.et = ElementTypes.Ghost;

            if (humanOrAI == PlayerTypes.Human)
            {
                if (controller == ControllerTypes.Keyboard)
                    player.AddController(new KeyboardInput(scheme));
                else
                    player.AddController(new ControllerInput(scheme));
            }
            else
            {
                player.AddController(new GhostAI(player));
            }

            players.Add(player);
        }
コード例 #8
0
ファイル: Sprite.cs プロジェクト: EphemeralGeek/Pacman
 public static Sprite getSprite(Element e, Board b, double size)
 {
     switch (e.et)
     {
         case PacManMulti.Enum.ElementTypes.Ghost:
             return new GhostSprite(e, Colors[r.Next(4)], size);
         case PacManMulti.Enum.ElementTypes.PacPlayer:
             return new PacSprite(e, size);
         case PacManMulti.Enum.ElementTypes.Wall:
             return new WallSprite(e, "fancywall/M", size, b);
         case PacManMulti.Enum.ElementTypes.PacDot:
             return new StaticSprite(e, "pacdot", size);
         case PacManMulti.Enum.ElementTypes.Fruit:
             return new StaticSprite(e, "fruit/banana", size);
         case PacManMulti.Enum.ElementTypes.Powerup:
             return new StaticSprite(e, "pacpowerup", size);
         case PacManMulti.Enum.ElementTypes.GhostSpawn:
             return new Spawn(e, "spawn", size);
         default:
             break;
     }
     return new GhostSprite(e, new Color(r.Next(255), r.Next(255), r.Next(255)), size);
 }
コード例 #9
0
ファイル: SpriteDemo.cs プロジェクト: EphemeralGeek/Pacman
 public SpriteDemo(Element e)
     : base(e)
 {
     Path = "pacdemo";
 }
コード例 #10
0
ファイル: StaticSprite.cs プロジェクト: EphemeralGeek/Pacman
 public StaticSprite(Element e, string path)
     : base(e)
 {
     Path = path;
 }
コード例 #11
0
ファイル: GameMaster.cs プロジェクト: EphemeralGeek/Pacman
        public void setupPlay()
        {
            gameUI = new BoardUI(logic.B, BoardWidth, BoardHeight, 0, 0); //((Window.ClientBounds.Width / 2) + (.5 * BoardWidth)), ((Window.ClientBounds.Height / 2) + (.5 * BoardHeight)));
            plays.Clear();
            //plays.Add(new Element { et = ElementTypes.Ghost, X = 1, Y = 1 });

            ControllerScheme scheme = new ControllerScheme(ControllerTypes.Keyboard);
            scheme.Add(Keys.Up);
            scheme.Add(Keys.Down);
            scheme.Add(Keys.Left);
            scheme.Add(Keys.Right);
            scheme.Add(Keys.Enter);
            ControllerScheme scheme2 = new ControllerScheme(ControllerTypes.Keyboard);
            scheme2.Add(Keys.W);
            scheme2.Add(Keys.S);
            scheme2.Add(Keys.A);
            scheme2.Add(Keys.D);
            scheme2.Add(Keys.Enter);

            byte controllerNum = 0;
            byte keyboardNum = 0;
            for (int i = 0; i < playerSetup.players.Count(); i++)
            {
                //Keyboard controlled ghost
                if (playerSetup.players[i].controllerType == ControllerTypes.Keyboard && playerSetup.players[i].IsGhost)
                {
                    keyboardNum++;
                    Element e = new Element();
                    e.et = ElementTypes.Ghost;

                    if (keyboardNum == 1)
                    {
                        e.Control = new KeyboardInput(scheme);
                    }
                    else if (keyboardNum == 2)
                    {
                        e.Control = new KeyboardInput(scheme2);
                    }
                    else if (keyboardNum > 2 && e.et == ElementTypes.PacPlayer)
                    {
                        e.Control = new PacAI(e);
                    }
                    else if (keyboardNum > 2 && e.et == ElementTypes.Ghost)
                    {
                        e.Control = new GhostAI(e);
                    }

                    plays.Add(e);
                }
                //Keyboard controlled pacman
                else if (playerSetup.players[i].controllerType == ControllerTypes.Keyboard && !(playerSetup.players[i].IsGhost))
                {
                    keyboardNum++;
                    Element e = new Element();
                    e.et = ElementTypes.PacPlayer;

                    if (keyboardNum == 1)
                    {
                        e.Control = new KeyboardInput(scheme);
                    }
                    else if (keyboardNum == 2)
                    {
                        e.Control = new KeyboardInput(scheme2);
                    }
                    else if (keyboardNum > 2 && e.et == ElementTypes.PacPlayer)
                    {
                        e.Control = new PacAI(e);
                    }
                    else if (keyboardNum > 2 && e.et == ElementTypes.Ghost)
                    {
                        e.Control = new GhostAI(e);
                    }

                    plays.Add(e);
                }
                //AI controlled ghost
                else if ((playerSetup.players[i].controllerType == ControllerTypes.PacAI || playerSetup.players[i].controllerType == ControllerTypes.GhostAI) && (playerSetup.players[i].IsGhost))
                {
                    Element e = new Element();
                    e.et = ElementTypes.Ghost;
                    e.Control = new GhostAI(e);
                    e.IsAlive = true;
                    plays.Add(e);
                }
                //AI controlled pacman
                else if ((playerSetup.players[i].controllerType == ControllerTypes.PacAI || playerSetup.players[i].controllerType == ControllerTypes.GhostAI) && !(playerSetup.players[i].IsGhost))
                {
                    Element e = new Element();
                    e.et = ElementTypes.PacPlayer;
                    e.Control = new PacAI(e);
                    e.IsAlive = true;
                    plays.Add(e);
                }
                //Controller controlled pacman
                else if (playerSetup.players[i].controllerType == ControllerTypes.Xbox && !(playerSetup.players[i].IsGhost))
                {
                    controllerNum++;

                    Element e = new Element();
                    e.et = ElementTypes.PacPlayer;
                    if (controllerNum == 1)
                    {
                        e.Control = new ControllerInput(PlayerIndex.One);
                    }
                    else if (controllerNum == 2)
                    {
                        e.Control = new ControllerInput(PlayerIndex.Two);
                    }
                    else if (controllerNum == 3)
                    {
                        e.Control = new ControllerInput(PlayerIndex.Three);
                    }
                    else if (controllerNum == 4)
                    {
                        e.Control = new ControllerInput(PlayerIndex.Four);
                    }
                    else if (controllerNum > 4 && e.et == ElementTypes.PacPlayer)
                    {
                        //e.Control = new PacAI();
                    }
                    else if (controllerNum > 4 && e.et == ElementTypes.Ghost)
                    {
                        e.Control = new GhostAI(e);
                    }

                    plays.Add(e);
                }
                //Controller controlled ghost
                else if (playerSetup.players[i].controllerType == ControllerTypes.Xbox && (playerSetup.players[i].IsGhost))
                {
                    controllerNum++;

                    Element e = new Element();
                    e.et = ElementTypes.Ghost;
                    if (controllerNum == 1)
                    {
                        e.Control = new ControllerInput(PlayerIndex.One);
                    }
                    else if (controllerNum == 2)
                    {
                        e.Control = new ControllerInput(PlayerIndex.Two);
                    }
                    else if (controllerNum == 3)
                    {
                        e.Control = new ControllerInput(PlayerIndex.Three);
                    }
                    else if (controllerNum == 4)
                    {
                        e.Control = new ControllerInput(PlayerIndex.Four);
                    }
                    else if (controllerNum > 4 && e.et == ElementTypes.PacPlayer)
                    {
                        //e.Control = new PacAI();
                    }
                    else if (controllerNum > 4 && e.et == ElementTypes.Ghost)
                    {
                        e.Control = new GhostAI(e);
                    }

                    plays.Add(e);
                }

            }

            if (setup.gameMode == Setup.GameModes.Classic)
            {
                logic = new GameLogicClassic();
            }
            else if (setup.gameMode == Setup.GameModes.GhostHunt)
            {
                logic = new GameLogicGhostHunt();
            }

            boardToShare = logic.GameLogicSetup(plays);
            new Node(boardToShare, gameUI);
            Node.Handle.GenerateMatrix();

            List<Sprite> sprites = new List<Sprite>();

            foreach (Element Element in boardToShare.Elements)
            {
                Sprite gameSprite = Sprite.getSprite(Element, logic.B, (int)Math.Min(BoardWidth / logic.B.Width, BoardHeight / logic.B.Height));
                gameUI.RegisterSprite(gameSprite);

                //Assigning the elements within sprites names.
                if (gameSprite.Element.et == ElementTypes.Ghost)
                {
                    if (gameSprite.getColor() == Color.HotPink)
                        gameSprite.Element.Name = "Pinky";
                    else if (gameSprite.getColor() == Color.Cyan)
                        gameSprite.Element.Name = "Inky";
                    else if (gameSprite.getColor() == Color.Red)
                        gameSprite.Element.Name = "Blinky";
                    else if (gameSprite.getColor() == Color.Orange)
                        gameSprite.Element.Name = "Clyde";
                }
                else if (gameSprite.Element.et == ElementTypes.PacPlayer)
                {
                    gameSprite.Element.Name = "PacPlayer " + PacPlayerID;
                    PacPlayerID += 1;
                }

                if (gameSprite.Element.et == ElementTypes.Ghost ||
                    gameSprite.Element.et == ElementTypes.PacPlayer)
                    sprites.Add(gameSprite);
            }
            scoreManager = new ScoreManager(sprites);
            gameUI.LoadContent(Content);

            var aliveSprites =
                from m in plays.ToArray()
                where m.IsAlive
                where m.et == ElementTypes.PacPlayer ||
                m.et == ElementTypes.Ghost
                select m;
            scoreBoards = new SBoardManager(this, aliveSprites.ToArray());
        }
コード例 #12
0
ファイル: GameLogicTag.cs プロジェクト: EphemeralGeek/Pacman
 public GameLogicTag(Element[] element1)
 {
     // TODO: Complete member initialization
     this.element1 = element1;
 }
コード例 #13
0
ファイル: GameLogic.cs プロジェクト: EphemeralGeek/Pacman
        /// <summary>
        /// This will add the walls, powerups, and position the players.
        /// </summary>
        public void AddLayout()
        {
            //This will add all of the players to the board
            foreach (Element e in B.Elements)
            {
                if (e.et == ElementTypes.Ghost)
                {
                    e.X = 11;
                    e.Y = 11;

                }
                if (e.et == ElementTypes.PacPlayer)
                {
                    e.X = 11;
                    e.Y = 17;
                }

            }
            for (int i = 0; i < 22; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 0;

                e.et = ElementTypes.Wall;

                B.Elements.Add(e);
            }
            for (int i = 1; i < 21; i++)
            {
                Element e = new Element();

                e.X = 0;
                e.Y = i;

                e.et = ElementTypes.Wall;

                B.Elements.Add(e);
            }
            for (int i = 1; i < 21; i++)
            {
                Element e = new Element();

                e.X = 22;
                e.Y = i;

                e.et = ElementTypes.Wall;

                B.Elements.Add(e);
            }
            for (int i = 2; i < 20; i++)
            {
                Element e = new Element();

                e.X = i;
                e.Y = 22;

                e.et = ElementTypes.Wall;

                B.Elements.Add(e);
            }
            for (int i2 = 1; i2 < 19; i2++)
            {
                for (int i = 1; i < 19; i++)
                {
                    Element e = new Element();

                    e.X = i;
                    e.Y = i2;
                    e.et = ElementTypes.PacDot;

                    B.Elements.Add(e);
                }
            }
        }
コード例 #14
0
 public HybridController(Element E)
 {
     AIinput = new GhostAI(E);
 }
コード例 #15
0
 private void SpwanPacman(Element PacMan)
 {
     Random rand = new Random();
     bool IsNotSafe = true;
     while (IsNotSafe)
     {
         PacMan.X = rand.Next(22) + 5;
         PacMan.Y = rand.Next(12) + 9;
         if (!B.FastBoard.ContainsKey(new Point { X = (int)PacMan.X, Y = (int)PacMan.Y }))
         {
             //prevents PacMan from spawing in Ghost Spawn
             if ((PacMan.X == 13 && (PacMan.Y < 11 || PacMan.Y > 16) || (PacMan.X == 14 && (PacMan.Y < 11 || PacMan.Y > 16) || PacMan.X == 15 && (PacMan.Y < 11 || PacMan.Y > 16))))
             {
                 foreach (Element e in B.Players)
                 {
                     if (e != PacMan && ((int)e.X != (int)PacMan.X || (int)e.Y != (int)PacMan.Y))
                     {
                         IsNotSafe = false;
                     }
                 }
             }
         }
     }
 }
コード例 #16
0
 //Collision that checks for overlapping elements.
 private void Collide(Element e, GameTime t)
 {
     if (B.FastBoard.ContainsKey(new Point { X = (int)Math.Round(e.X), Y = (int)Math.Round(e.Y) }))
     {
         Element e2 = B.FastBoard[new Point { X = (int)Math.Round(e.X), Y = (int)Math.Round(e.Y) }];
         if (e.et == ElementTypes.PacPlayer)
         {
             if (e2.et == ElementTypes.PacDot && e2.IsAlive)
             {
                 e2.IsAlive = false;
                 e.Score += 20;
                 NumOfDots -= 1;
                 sound = InGameSounds.Chomp;
             }
             if (e2.et == ElementTypes.Powerup && e2.IsAlive)
             {
                 e2.IsAlive = false;
                 B.FastBoard.Remove(new Point { X = (int)e2.X, Y = (int)e2.Y });
                 e.IsPowered = true;
                 e.IsVulnerable = false;
                 foreach (Element els in B.Players)
                 {
                     if (els.et == ElementTypes.Ghost)
                     {
                         els.IsVulnerable = true;
                     }
                 }
                 e.Score += 100;
                 e.ts = t.TotalGameTime;
                 sound = InGameSounds.EatPowerUp;
             }
             if (e2.et == ElementTypes.Fruit && e2.IsAlive)
             {
                 e.Score += 200;
                 e2.IsAlive = false;
                 B.FastBoard.Remove(new Point{X = (int)e2.X, Y = (int) e2.Y});
                 sound = InGameSounds.EatFruit;
             }
         }
         if (e.et == ElementTypes.Ghost)
         {
             if (e2.et == ElementTypes.GhostSpawn && !e.IsAlive)
             {
                 e.IsAlive = true;
                 e.IsVulnerable = false;
                 numGhostDead -= 1;
             }
         }
     }
 }
コード例 #17
0
ファイル: Sprite.cs プロジェクト: EphemeralGeek/Pacman
 public Sprite(Element e)
 {
     Element = e;
 }
コード例 #18
0
ファイル: WallSprite.cs プロジェクト: EphemeralGeek/Pacman
        public string wallpath(Element[,] c, int j ,int k)
        {
            int bot = 0;
                    int right = 0;
                    int left = 0;
                    int top = 0;
                    int count = 0;
                    bool isbl = false;
                    bool isbr = false;
                    bool istl = false;
                    bool istr = false;
                    if (c[j, k] == null)
                    {

                    }
                    else if (c[j, k].et.Equals(Enum.ElementTypes.Wall))
                    {
                        isbl = isWallBL(j, k, c);
                        isbr =isWallBR(j, k, c);
                        istl = isWallTL(j, k, c);
                        istr= isWallTR(j, k, c);
                        bot = WallBot(j, k, c);
                        right = WallRight(j, k, c);
                        left = WallLeft(j, k, c);
                        top = WallTop(j, k, c);

                        count = bot + right + left + top;

                        if (count == 1)
                        {
                            return Path = "fancywall/H";
                        }
                        else if (count == 5)
                        {
                            return Path = "fancywall/V";
                        }
                        else if (count == 6)
                        {
                            return Path = "fancywall/BR";
                        }
                        else if (count == 10)
                        {
                            return Path = "fancywall/H";
                        }
                        else if (count == 11)
                        {
                            return Path = "fancywall/H";
                        }
                        else if (count == 13)
                        {
                            return Path = "fancywall/V";
                        }
                        else if (count == 14)
                        {
                            return Path = "fancywall/TR";
                        }
                        else if (count == 15)
                        {
                            return Path = "fancywall/BL";
                        }
                        else if (count == 16)
                        {
                            if (istl == false && istr == true)
                            {
                                return Path = "fancywall/BR";
                            }
                            else if (istl == true && istr == false)
                            {
                                return Path = "fancywall/BL";
                            }
                            else
                            {
                                return Path = "fancywall/H";
                            }
                        }
                        else if (count == 18)
                        {
                            return Path = "fancywall/V";
                        }
                        else if (count == 19)
                        {
                            if (istl == true && isbl == false)
                            {
                                return Path = "fancywall/TR";
                            }
                            else if (istl == false && isbl == true)
                            {
                                return Path = "fancywall/BR";
                            }
                            else
                            {
                                return Path = "fancywall/V";
                            }

                        }
                        else if (count == 23)
                        {
                            return Path = "fancywall/TL";
                        }
                        else if (count == 24)
                        {
                            if (isbl == false && isbr == true)
                            {
                                return Path = "fancywall/TR";
                            }
                            else if (isbl == true && isbr == false)
                            {
                                return Path = "fancywall/TL";
                            }
                            else
                            {
                                return Path = "fancywall/H";
                            }

                        }
                        else if (count == 28)
                        {
                            if (istr == true && isbr == false)
                            {
                                return Path = "fancywall/TL";
                            }
                            else if (istr == false && isbr == true)
                            {
                                return Path = "fancywall/BL";
                            }
                            else
                            {
                                return Path = "fancywall/V";
                            }
                        }
                        else if (count == 29)
                        {

                            if (isbr == false)
                            {
                                return Path = "fancyWall/TL";
                            }
                            else if (isbl == false)
                            {
                                return Path = "fancyWall/TR";
                            }
                            else if (istr == false)
                            {
                                return Path = "fancyWall/BL";
                            }
                            else if (istl == false)
                            {
                                return Path = "fancyWall/BR";
                            }
                            else
                            {
                                return Path = "fancywall/M";
                            }
                        }

                    }
                    else
                    {

                    }

                return Path;
        }
コード例 #19
0
ファイル: GameLogic.cs プロジェクト: EphemeralGeek/Pacman
        /// <summary>
        /// This will add the walls, powerups, and position the players.
        /// </summary>
        public virtual void AddLayout()
        {
            //This will add all of the players and the respawn point to the board
            B.Width = 28;
            B.Height = 31;
            B.Elements.Add(new Element { IsAlive = true, et = ElementTypes.GhostSpawn, X = 14, Y = 12, IsPowered = false, Control = null, CurrentDirection = Direction.Neutral, lives = 3, speed = 4, Name = "Spwaner", Score = 1000000 });
            B.Elements.Add(new Element { IsAlive = true, et = ElementTypes.GhostSpawn, X = 13, Y = 12, IsPowered = false, Control = null, CurrentDirection = Direction.Neutral, lives = 3, speed = 4, Name = "Spwaner", Score = 1000000 });
            foreach (Element e in B.Elements)
            {
                if (e.et == ElementTypes.Ghost)
                {
                    e.X = 9;
                    e.Y = 14;
                }
                if (e.et == ElementTypes.PacPlayer)
                {
                    e.X = 1;
                    e.Y = 1;
                }
            }

            //adds the first row of the walls to the board
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 0;
                e.et = ElementTypes.Wall;
                e.CurrentDirection = Direction.Neutral;
                B.Elements.Add(e);
            }

            //adds the second row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 1;
                e.CurrentDirection = Direction.Neutral;

                if (i == 0 || i == 13 || i == 14 || i == 27)
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
                else
                {
                    e.et = ElementTypes.PacDot;
                    B.Elements.Add(e);
                }

            }

            //adds the third row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 2;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 6 || i == 12 || i == 15 || i == 21|| i == 26)
                {
                    e.et = ElementTypes.PacDot;
                    B.Elements.Add(e);
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the fourth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 3;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 26)
                {
                    e.et = ElementTypes.Powerup;
                }else if (i == 6 || i == 12 || i == 15 || i == 21)
                {
                    e.et = ElementTypes.PacDot;
                }
                else
                {
                    e.et = ElementTypes.Wall;
                }
                B.Elements.Add(e);
            }

            //adds the fifth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 4;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 6 || i == 12 || i == 15 || i == 21 || i == 26)
                {
                    e.et = ElementTypes.PacDot;
                }
                else
                {
                    e.et = ElementTypes.Wall;
                }
                B.Elements.Add(e);
            }

            //adds the sixth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 5;
                e.CurrentDirection = Direction.Neutral;
                if (i == 0 || i == 27)
                {
                    e.et = ElementTypes.Wall;
                }
                else
                {
                    e.et = ElementTypes.PacDot;
                }
                B.Elements.Add(e);
            }

            //adds the seventh row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 6;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 6 || i == 9|| i == 18|| i == 21||i ==26 )
                {
                    e.et = ElementTypes.PacDot;
                }
                else
                {
                    e.et = ElementTypes.Wall;
                }
                B.Elements.Add(e);
            }

            //adds the eigth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 7;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 6 || i == 9 || i == 18 || i == 21 || i == 26)
                {
                    e.et = ElementTypes.PacDot;
                }
                else
                {
                    e.et = ElementTypes.Wall;
                }
                B.Elements.Add(e);
            }

            //adds the ninth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 8;
                e.CurrentDirection = Direction.Neutral;
                if (i == 0 || i == 7 || i == 8 || i == 13 || i == 14 || i == 19 || i == 20 || i == 27)
                {
                    e.et = ElementTypes.Wall;
                }
                else
                {
                    e.et = ElementTypes.PacDot;
                }
                B.Elements.Add(e);
            }

            //adds the tenth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 9;
                e.CurrentDirection = Direction.Neutral;
                if (i == 6 || i == 12 || i == 15 || i == 21 )
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the eleventh row of stuff
            for (int i = 5; i <= 22; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 10;
                e.CurrentDirection = Direction.Neutral;
                if (i == 6 || i == 12 || i == 15 || i == 21)
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the twelth row of stuff
            for (int i = 5; i <= 22; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 11;
                e.CurrentDirection = Direction.Neutral;
                if (i==5||i == 7 || i == 8 || i == 19 || i == 20||i==22)
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
                else
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
            }

            //adds the thirteenth row of stuff
            for (int i = 5; i <= 22; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 12;
                e.CurrentDirection = Direction.Neutral;
                if (i == 6 ||i == 9 || i == 21 )
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                    if (i == 13 || i == 14 || i == 18)
                    {
                    }
                    else
                    {
                        e.et = ElementTypes.Wall;
                        B.Elements.Add(e);
                    }
                }
            }

            //adds the fourteenth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 13;
                e.CurrentDirection = Direction.Neutral;
                if (i == 6 ||  i == 21)
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                    if (i == 13 || i == 14 || i == 15||i==16||i==11||i==12||i==18||i==9)
                    { }
                    else
                    {
                        e.et = ElementTypes.Wall;
                        B.Elements.Add(e);
                    }
                }
            }

            //adds the fifteenth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 14;
                e.CurrentDirection = Direction.Neutral;
                if ( i == 10 || i == 17)
                {

                        e.et = ElementTypes.Wall;
                        B.Elements.Add(e);
                }
                else
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
            }

            //adds the sixteenth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 15;
                e.CurrentDirection = Direction.Neutral;
                if (i == 6 || i == 21)
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                    if (i == 13 || i == 14 || i == 15 || i == 16 || i == 11 || i == 12 || i == 18 || i == 9)
                    { }
                    else
                    {
                        e.et = ElementTypes.Wall;
                        B.Elements.Add(e);
                    }
                }
            }

            //adds the seventeenth row of stuff
            for (int i = 5; i <= 22; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 16;
                e.CurrentDirection = Direction.Neutral;
                if (i == 6 || i == 9 || i == 21 ||i==18)
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                   e.et = ElementTypes.Wall;
                   B.Elements.Add(e);
                }

            }

            //adds the eighteenth row of stuff
            for (int i = 5; i <= 22; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 17;
                e.CurrentDirection = Direction.Neutral;
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                    if (i == 5 || i == 22 || i == 7 || i == 8 || i == 19 || i == 20 || 1==18)
                    {
                        e.et = ElementTypes.Wall;
                        B.Elements.Add(e);
                    }

            }

            //adds the nineteenth row of stuff
            for (int i = 5; i <= 22; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 18;
                e.CurrentDirection = Direction.Neutral;
                if (i == 6 || i == 9 || i == 18 || i == 21)
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the twentith row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 19;
                e.CurrentDirection = Direction.Neutral;
                if (i == 6 || i == 9 || i == 18 || i == 21)
                {
                    if (i == 6 || i == 21)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the twentyfirst row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 20;
                e.CurrentDirection = Direction.Neutral;
                if (i == 0 || i == 27 || i == 13 || i == 14)
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
                else
                {
                    e.et = ElementTypes.PacDot;
                    B.Elements.Add(e);
                }
            }

            //adds the twentysecond row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 21;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 6|| i == 12 || i == 15 || i ==21||i==26)
                {
                    e.et = ElementTypes.PacDot;
                    B.Elements.Add(e);
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the twentythird row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 22;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 6 || i == 12 || i == 15 || i == 21 || i == 26)
                {
                    e.et = ElementTypes.PacDot;
                    B.Elements.Add(e);
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the twentyfourth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 23;
                e.CurrentDirection = Direction.Neutral;
                if (i==0||i == 1 || i == 4 || i == 5 || i == 22 || i == 23 || i == 27 || i == 26)
                {
                    if (i == 1 || i == 26)
                    {
                        e.et = ElementTypes.Powerup;
                        B.Elements.Add(e);
                    }
                    else
                    {
                        e.et = ElementTypes.Wall;
                        B.Elements.Add(e);
                    }
                }
                else
                {
                    if (i != 13 || i != 14)
                    {
                        e.et = ElementTypes.PacDot;
                        B.Elements.Add(e);
                    }
                }
            }

            //adds the twentyfifth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 24;
                e.CurrentDirection = Direction.Neutral;
                if (i == 3 || i == 6 || i == 9 || i == 18 || i == 21 || i == 24)
                {
                    e.et = ElementTypes.PacDot;
                    B.Elements.Add(e);
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the twentysixth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 25;
                e.CurrentDirection = Direction.Neutral;
                if (i == 3 || i == 6 || i == 9 || i == 18 || i == 21 || i == 24)
                {
                    e.et = ElementTypes.PacDot;
                    B.Elements.Add(e);
                }
                else
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
            }

            //adds the twentyseventh row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 26;
                e.CurrentDirection = Direction.Neutral;
                if (i == 0 || i == 7 || i == 8 || i == 13 || i == 14 || i == 19||i==20||i==27)
                {
                    e.et = ElementTypes.Wall;
                    B.Elements.Add(e);
                }
                else
                {
                    e.et = ElementTypes.PacDot;
                    B.Elements.Add(e);
                }
            }

            //adds the twentyeigth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 27;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 12 || i == 15 || i == 26)
                {
                    e.et = ElementTypes.PacDot;
                }
                else
                {
                    e.et = ElementTypes.Wall;
                }
                B.Elements.Add(e);
            }

            //adds the twentyninth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 28;
                e.CurrentDirection = Direction.Neutral;
                if (i == 1 || i == 12 || i == 15 || i == 26)
                {
                    e.et = ElementTypes.PacDot;
                }
                else
                {
                    e.et = ElementTypes.Wall;
                }
                B.Elements.Add(e);
            }

            //adds the thirtieth row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 29;
                e.CurrentDirection = Direction.Neutral;
                if (i == 0 || i == 27)
                {
                    e.et = ElementTypes.Wall;
                }
                else
                {
                    e.et = ElementTypes.PacDot;
                }
                B.Elements.Add(e);
            }

            //adds the thirtyfirst row of stuff
            for (int i = 0; i <= 27; i++)
            {
                Element e = new Element();
                e.X = i;
                e.Y = 30;
                e.CurrentDirection = Direction.Neutral;

                    e.et = ElementTypes.Wall;

                B.Elements.Add(e);
            }
        }
コード例 #20
0
        private bool TryMove(Direction direction, double distance, Element e)
        {
            bool worked = false;

            if (direction == Direction.Up)
            {
                //makes sure we don't run into walls
                bool canMove = true;
                //checks to see if the element is a wall
                if (B.FastBoard.ContainsKey(new Point { Y = (int)(e.Y - 1), X = (int)e.X }))
                {
                    if (B.FastBoard[new Point { Y = (int)(e.Y - 1), X = (int)e.X }].et == ElementTypes.Wall||(e.et==ElementTypes.PacPlayer && B.FastBoard[new Point { Y = (int)(e.Y - 1), X = (int)e.X }].et == ElementTypes.GhostSpawn))
                    {
                        canMove = false;
                    }
                }
                if (canMove)
                {
                    e.Y -= distance;
                    worked = true;
                }
            }
            if (direction == Direction.Down)
            {
                //makes sure we don't run into walls
                bool canMove = true;

                //checks to see if the element is a wall
                if (B.FastBoard.ContainsKey(new Point { Y = (int)(e.Y + 1), X = (int)e.X }))
                {
                    if (B.FastBoard[new Point { Y = (int)(e.Y + 1), X = (int)e.X }].et == ElementTypes.Wall || (e.et == ElementTypes.PacPlayer && B.FastBoard[new Point { Y = (int)(e.Y + 1), X = (int)e.X }].et == ElementTypes.GhostSpawn))
                    {
                        canMove = false;
                    }
                }

                if (canMove)
                {
                    e.Y += distance;
                    worked = true;
                }
            }
            if (direction == Direction.Left)
            {
                //makes sure we don't run into walls
                bool canMove = true;

                //checks to see if the element is a wall
                if (B.FastBoard.ContainsKey(new Point { Y = (int)e.Y, X = (int)(e.X - 1) }))
                {
                    if (B.FastBoard[new Point { Y = (int)e.Y, X = (int)(e.X - 1) }].et == ElementTypes.Wall || (e.et == ElementTypes.PacPlayer && B.FastBoard[new Point { Y = (int)e.Y, X = (int)(e.X - 1) }].et == ElementTypes.GhostSpawn))
                        canMove = false;
                }
                if (canMove)
                {
                    e.X -= distance;
                    worked = true;
                }
            }
            if (direction == Direction.Right)
            {
                //makes sure we don't run into walls
                bool canMove = true;
                //checks to see if the element is a wall
                if (B.FastBoard.ContainsKey(new Point { Y = (int)e.Y, X = (int)(e.X + 1) }))
                {
                    if (B.FastBoard[new Point { Y = (int)e.Y, X = (int)(e.X + 1) }].et == ElementTypes.Wall || (e.et == ElementTypes.PacPlayer && B.FastBoard[new Point { Y = (int)e.Y, X = (int)(e.X + 1) }].et == ElementTypes.GhostSpawn))
                    {
                        canMove = false;
                    }
                }
                if (canMove)
                {
                    e.X += distance;
                    worked = true;
                }
            }
            if (NumOfDots == 0 || NumOfPacLives == 0)
            {
                EndGame = true;
                foreach (Element el in B.Players)
                {
                    el.IsAlive = true;
                }
            }
            return worked;
        }
コード例 #21
0
ファイル: StaticSprite.cs プロジェクト: EphemeralGeek/Pacman
 public StaticSprite(Element e, string path, double size)
     : base(e, size)
 {
     Path = path;
 }
コード例 #22
0
ファイル: WallSprite.cs プロジェクト: EphemeralGeek/Pacman
        public int WallTop(int x, int y, Element[,] c)
        {
            int count = 0;
            y = y - 1;
            if ((((x < 0) || (y < 0)) || (x > c.GetLength(0) - 1) || (y > c.GetLength(1) - 1)) ||  c[x,y] == null || c[x, y].et.Equals(Enum.ElementTypes.PacDot) || c[x, y].et.Equals(Enum.ElementTypes.PacPlayer) || c[x, y].et.Equals(Enum.ElementTypes.Ghost) || c[x, y].et.Equals(Enum.ElementTypes.Powerup) || c[x, y].et.Equals(Enum.ElementTypes.Fruit) || c[x, y].et.Equals(Enum.ElementTypes.GhostSpawn))
            {
                return count;
            }
            else
            {
                count = 5;
            }

            return count;
        }
コード例 #23
0
 private void KillPacman(Element PacMan)
 {
     SpwanPacman(PacMan);
     PacMan.CurrentDirection = Direction.Neutral;
     PacMan.lives -= 1;
     if (PacMan.lives <= 0)
     {
         PacMan.IsAlive = false;
     }
     NumOfPacLives -= 1;
 }
コード例 #24
0
ファイル: PacAI.cs プロジェクト: EphemeralGeek/Pacman
 public PacAI(Element E)
 {
     Me = E;
 }
コード例 #25
0
ファイル: GhostAI.cs プロジェクト: EphemeralGeek/Pacman
 public GhostAI(Element E)
 {
     Me = E;
 }