Exemplo n.º 1
0
        private void StartNextRound()
        {
            startingLocations.Clear();
            _playersRemaining.Clear();
            SetStartingPositions(MapWidth, MapHeight);

            Tank winner = null;
            for (int i = 0; i < numberOfPlayers; i++)
            {
                if(GameRules.playerScores[i] >= GameRules.numberToWin)
                {
                    winner = _players[i];
                    break;
                }
            }
            ShowWinner(winner);
            return;

            //Make more advanced here
            switch (GameRules._mapSelectionSetting)
            {
                case GameRules.MapSelectionSetting.RandomGenerated:
                    _currentMap = MapGenerator.GenerateRoguelikeMap(MapWidth, MapHeight);
                    break;
                case GameRules.MapSelectionSetting.Shuffle:
                    break;
            }
            _currentMap.LoadContent(_contentManager);
            for (int i = 0; i < numberOfPlayers; i++)
            {
                _players[i].Reset();
                int randomPosition = random.Next(0, startingLocations.Count);
                _players[i].position = startingLocations[randomPosition].Item1;
                _players[i].Rotation = startingLocations[randomPosition].Item2;
                startingLocations.RemoveAt(randomPosition);
                _playersRemaining.Add(_players[i]);
            }
        }
Exemplo n.º 2
0
        public override void LoadContent()
        {
            base.LoadContent();
            screenManager.Game.IsMouseVisible = false;
            ShapeRenderer.graphicsDevice = screenManager.GraphicsDevice;
            screenManager.ClearColor = Color.Black;
            Tile.InitializeTilePreferences();
            usingSplitScreen = false;

            Map.TileSize = cTileSize;
            MapGenerator.Initialize();
            _currentMap = MapGenerator.GenerateRoguelikeMap(MapWidth, MapHeight);
            _currentMap.LoadContent(_contentManager);

            SetStartingPositions(MapWidth, MapHeight);
            SetViewPorts(numberOfPlayers);
            camera.Zoom = 0.99f;
            camera.Move(new Vector2(-16, -80));

            _guiFrame = new MenuFrame(new Rectangle(0, 0, (int)GameSettings.ScreenWidth - 6, (int)GameSettings.ScreenHeight), "Menu", new Rectangle(0, 0, 16, 16));
            _guiFrame.AddHorizontalLine(16, (int)GameSettings.ScreenWidth - 22, (int)(2 * 32));
            _guiFrame.AddSplit(0, (int)(2 * 32), MenuFrame.SplitType.Right);
            _guiFrame.AddSplit((int)GameSettings.ScreenWidth - 22, (int)(2 * 32), MenuFrame.SplitType.Left);
            for (int i = 1; i <= 2; i++)
            {
                _guiFrame.AddSplit((i * 290), 0, MenuFrame.SplitType.Down);
                _guiFrame.AddSplit((i * 290), (int)(2 * 32), MenuFrame.SplitType.Up);
                _guiFrame.AddVerticalLine((i * 290), 16, 2 * 32);
            }
            for (int i = 3; i <= 4; i++)
            {
                _guiFrame.AddSplit((i * 290) - 90, 0, MenuFrame.SplitType.Down);
                _guiFrame.AddSplit((i * 290) - 90, (int)(2 * 32), MenuFrame.SplitType.Up);
                _guiFrame.AddVerticalLine((i * 290) - 90, 16, 2 * 32);
            }

            _guiFrame.LoadContent(_contentManager);
            _guiCamera = new Camera2D();

            _wonText = new SpriteText("BigFont", "Player won", new Vector2(300, 300));
            _wonText.Depth = 1f;
            _wonText.color = Color.White;
            _wonText.LoadContent(_contentManager);
            _wonText.CenterText(new Rectangle((int)camera.Position.X, (int)camera.Position.Y, (int)GameSettings.ScreenWidth, (int)GameSettings.ScreenHeight), true, true);
            _wonText.Hide();

            _timerFont = new SpriteText("HealthFont", "Time: ", new Vector2(0, 0));
            _timerFont.LoadContent(_contentManager, _spriteBatch);
            _timerFont.CenterText(new Rectangle(0, 16, (int)GameSettings.ScreenWidth, 16 * 3), true, true);

            for (int i = 0; i < numberOfPlayers; i++)
            {
                int randomPosition = random.Next(0, startingLocations.Count);
                _players[i] = new Tank(i, startingLocations[randomPosition].Item1, teamsSelected[i], usedControls[i], usedViewPorts[i].Bounds);
                _players[i].Rotation = startingLocations[randomPosition].Item2;
                _players[i].LoadContent(_contentManager, _spriteBatch);
                _players[i].ResetHealth();
                startingLocations.RemoveAt(randomPosition);
                if (!usingSplitScreen)
                {
                    _players[i].camera = this.camera;
                }

                _playersRemaining.Add(_players[i]);
            }

            PooledObjects.Initialize();
            PooledObjects.bullets.ForEach(b => b.LoadContent(_contentManager));
            PooledObjects.fragmentClusters.ForEach(fc => fc.LoadContent(_contentManager));
        }