示例#1
0
        public void consMaze(Player pl, GhostCollcection ghosts)
        {
            Console.CursorVisible = false;
            pl.Spawn(13, 17);
            Game.GhostsCol.spawnAllGhosts();
            addCheries();

            char ch;

            while (true)
            {
                if (gameStarted)
                {
                    if (!timer.timer.Enabled)
                    {
                        timer.Start();
                    }
                    Game.eventsCheck();
                    if (pl.IsActive)
                    {
                        pl.startMoving();
                    }

                    foreach (MovableObject ghost in ghosts)
                    {
                        if (ghost.IsActive)
                        {
                            ghost.startMoving();
                        }
                    }
                }

                System.Threading.Thread.Sleep(FrameRate);

                Console.SetCursorPosition(0, 0);
                Console.CursorVisible = false;
                Console.WriteLine("ChaseMode:  " + timer.ChaseMode);
                Console.WriteLine("Lives:  " + pl.LivesRemain);
                // Console.WriteLine("Player " + (float)pl.Xpos + "  " + (float)pl.Ypos);
                Console.WriteLine("Shadow " + (float)ghosts[0].Xpos + "  " + (float)ghosts[0].Ypos);
                Console.WriteLine("Speedy  " + (float)ghosts[1].Xpos + "  " + (float)ghosts[1].Ypos);
                Console.WriteLine("Bashfull " + (float)ghosts[2].Xpos + "  " + (float)ghosts[2].Ypos);
                Console.WriteLine("Pokey  " + (float)ghosts[3].Xpos + "  " + (float)ghosts[3].Ypos);
                for (int i = 0; i < Width; i++)
                {
                    for (int j = 0; j < Length; j++)
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        if (maze[i, j].ObjOnPlate.Count != 0)
                        {
                            Console.ForegroundColor = GetTypeColor(maze[i, j].ObjOnPlate[maze[i, j].ObjOnPlate.Count - 1].GetType().ToString());
                        }
                        ch = getSymb(maze[i, j]);
                        Console.Write(ch);
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("Score:  " + Game.Score);
            }
        }
示例#2
0
        public static void Setup(string gameId, int mapId)
        {
            GameEngine game;

            if (games.Keys.Contains(gameId))
            {
                games[gameId].MapInit(mapId);
                games[gameId].mapJSON = games[gameId].Map.MapJSON;
                games[gameId].Maze1.fillMaze(games[gameId].Map.maze);
                games[gameId].Maze1.addCheries();
                games[gameId].Maze1.GameOver = false;
                games[gameId].RunMaze();
                return;
            }
            game        = new GameEngine();
            game.GameId = gameId;
            game.MapInit(mapId);
            game.mapJSON       = game.Map.MapJSON;
            int[,] testMazeMat = game.Map.maze;

            game.Maze1            = new Maze();
            game.Maze1.Game       = game;
            game.Maze1.timer.Game = game;
            game.Maze1.fillMaze(testMazeMat);
            game.Maze1.addCheries();

            Player pl = new Player(game);

            game.Player = pl;
            Shadow shadow = new Shadow(game);

            Monsters.Speedy   speedy   = new Monsters.Speedy(game);
            Monsters.Bashfull bashfull = new Monsters.Bashfull(game);
            Monsters.Pokey    pokey    = new Monsters.Pokey(game);
            GhostCollcection  ghosts   = new GhostCollcection(gameId, game);

            ghosts.Add(shadow);
            ghosts.Add(speedy);
            ghosts.Add(bashfull);
            ghosts.Add(pokey);
            ghosts.setTarget(pl);
            game.GhostsCol = ghosts;
            game.startGame();
            games.Add(gameId, game);
        }