Exemple #1
0
        public GameLevel(Game game, GamePlayState gameState, string levenName)
            : base(game)
        {
            this.gameState = gameState;
            levelRaw = ContentPreImporter.GetLevel(levenName);
            levelRend = new LevelRenderer(game, levelRaw);
            levelCollisions = new LevelCollisions(game, levelRaw);
            font = ContentPreImporter.GetFont("TextFont");

            Vector3 playerPos = Vector3.Zero;
            int enemyFound = 0;
            //Build the game level creating the enemies, player and pickups
            for (int y = 0; y < levelRaw.Depth; y++)
            {
                for (int x = 0; x < levelRaw.Width; x++)
                {
                    if (levelRaw.GetAt(x, y).ToString().ToLower() == "p")
                        player = new Player(game, new Vector3(x, 0, y));
                    else if (levelRaw.GetAt(x, y).ToString().ToLower() == "e")
                    {
                        //Depending on the difficulty only add certain enemies
                        enemyFound++;
                        if ((enemyFound % GlobalSettings.EnemyFrequency) == 0)
                        {
                            objects.Add(new RedHead(game, new Vector3(x, 0, y), levelRaw));
                            enemies++;
                        }
                    }
                    else if (levelRaw.GetAt(x, y).ToString().ToLower() == "g")
                    {
                        enemyFound++;
                        if ((enemyFound % GlobalSettings.EnemyFrequency) == 0)
                        {
                            objects.Add(new GreenGhost(game, new Vector3(x, 0, y), levelRaw));
                            enemies++;
                        }
                    }
                    else if (levelRaw.GetAt(x, y).ToString().ToLower() == "h")
                    {
                        objects.Add(new Health(game, new Vector3(x, 0, y)));
                    }
                }
            }

            skybox = new Skybox(Game, 50, ContentPreImporter.GetTexture("grimmnight_small"));
            //Corner of the box if front left, so to place player in right place we need to add .5 to the left and .5 to the front
            objects.Add(player);
            // TODO: Construct any child components here
        }
Exemple #2
0
 public LoseState(Game game, GamePlayState gameState)
     : base(game)
 {
     this.gameState = gameState;
     // TODO: Construct any child components here
 }