コード例 #1
0
ファイル: GameMaster.cs プロジェクト: EphemeralGeek/Pacman
        //END TEST CODE
        public void Start()
        {
            //while (!(new MainMenu()).Start) { /*Waiting on player to begin */} //Perhaps insert a thread here.

            //Game game = (new SetupMenu()).getGame();

            //TESTING CODE DELETE THIS AFTER MENU wOrks
            logic = new GameLogicClassic();
            //END TEST CODE

            //switch (game.mode)
            //{
            //    case ModeTypes.Battle:
            //        logic = new GameLogicBattle(game.GetPlayers());
            //        break;
            //    case ModeTypes.Classic:
            //        logic = new GameLogicClassic();
            //        break;
            //    case ModeTypes.GhostTag:
            //        logic = new GameLogicTag(game.GetPlayers());
            //        break;
            //    default:
            //        logic = new GameLogicClassic();
            //        break;
            //}

             // Perhaps new thread here for the board UI.

             // Passing in the whole board so the UI can have access
             // to both the elements and the nodes.

            while (true) //Bad code. Perhaps different design for continued iteration.
            {

            }
        }
コード例 #2
0
ファイル: GameMaster.cs プロジェクト: EphemeralGeek/Pacman
        //END TEST CODE
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            //Create a list of players
            //logic = new GameLogicBattle(game.GetPlayers());

            logic = new GameLogicClassic();

            boardToShare = logic.GameLogicSetup(plays);

            start = new Start(BoardWidth, BoardHeight, 0, 0);
            setup = new Setup(BoardWidth, BoardHeight, 0, 0);
            playerSetup = new PlayerSetup(BoardWidth, BoardHeight, 0, 0);
            endScreen = new EndScreen(BoardWidth, BoardHeight, 0, 0);

            IsMouseVisible = true;
            mouseState = Mouse.GetState();
            previousMouseState = mouseState;
            padState = GamePad.GetState(PlayerIndex.One);
            prevPadState = padState;
            //screenCenter = new Point(((BoardWidth / 2)), 0);
            gameState = GameState.StartMenu;
            screenNumber = 0;
            //scoreBoard.Initialize(this);
            base.Initialize();
        }
コード例 #3
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());
        }
コード例 #4
0
ファイル: GameMaster.cs プロジェクト: EphemeralGeek/Pacman
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            List<Element> plays = new List<Element>();
            plays.Add(new Element { et = ElementTypes.Ghost, X = 1, Y = 1 });
            plays.Add(new Element { et = ElementTypes.PacPlayer, X = 5, Y = 2 });
            //logic = new GameLogicBattle(game.GetPlayers());
            logic = new GameLogicClassic();
            boardToShare = logic.GameLogicSetup(plays);
            gameUI = new BoardUI(logic.B, BoardWidth, BoardHeight, 0, 0); //((Window.ClientBounds.Width / 2) + (.5 * BoardWidth)), ((Window.ClientBounds.Height / 2) + (.5 * BoardHeight)));

            foreach(Element Element in plays){
                gameUI.RegisterSprite(new StaticSprite(Element, "images/pacdemo"));
            }

            base.Initialize();
        }