示例#1
0
        public GameState()
        {
            this.BigText = new Label("Player 1 is out", Controller.FontController.GetFont("bigFont"));
            this.BigText.HorizontalAlign = HorizontalAlign.CENTER;
            this.BigText.Visable = false;
            this.BigText.Width = 1800;
            this.BigText.Height = 1000;

            Controller.LayerController.AddLayer("bombLayer");
            FatBomb.state = this;
            Vetbol.state = this;
            CapturePoint.state = this;
            TiledSprite bg = new TiledSprite(2000, 2000);

            bg.LoadTexture("background");
            bg.Depth = 0f;

            tilemap = new Tilemap();
            tilemap.LoadMap("Content/testmap.tmx", 32, 32);
            this.AddChild(bg);
            this.AddChild(tilemap);

            this.players = new List<Vetbol>();

            playerSpawn = tilemap.RemoveTiles(7);
            int playerRespawn = rnd.Next(playerSpawn.Count);

            List<Tile> capturePointTiles = tilemap.RemoveTiles(3);
            foreach (Tile tile in capturePointTiles)
            {
                CapturePoint capturepoint = new CapturePoint();
                capturepoint.Position = tile.Position + ( new Vector2(-27, -61));
                capturePoints.Add(capturepoint);
                AddChild(capturepoint);
            }

            NotUsedSpawnPoints = new List<Tile>();
            NotUsedSpawnPoints.AddRange(playerSpawn);

            for (int i = 0; i < Controller.Input.getPadStateList.Where(c => c.IsConnected).Count(); i++)
            {
                this.players.Add(new Vetbol((PlayerIndex)i));
            }

            for (int j = 0; j < players.Count; j++)
            {
                this.players[j].score = playerStartScore;
                this.players[j].Position = this.getAvailablePosition();
                this.AddChild(this.players[j]);
            }
            lastPlayerAlive = players[0];

            this.BombPool = new Pool<FatBomb>(50, false, FatBomb.IsValid, this.NewBomb);

            soundEffectBomb = Controller.Content.Load<SoundEffect>("sounds/explode");

            this.AddChild(this.BigText);

            this.hud = new HUD(this.players, respawnTime);
            this.AddChild(hud);

            deadSound = Controller.Content.Load<SoundEffect>("sounds/dead");
            ECGsound = Controller.Content.Load<SoundEffect>("sounds/ecg");
        }