Esempio n. 1
0
        public TankController(Game1 game)
        {
            GD          = game.GraphicsDevice;
            spriteBatch = new SpriteBatch(GD);
            rand        = new Random();

            this.game = game;
            //Create instances and load their content
            tanksInGame = new List <Tank>();
            for (int i = 0; i < Game1.GameParameters.NumberOfPlayers; ++i)
            {
                TanksInGame.Add(new Tank());
                TanksInGame[i].LoadContent(game.Content);
                tanksInGame[i].PlayerName = Game1.GameParameters.PlayerNames[i];
            }

            missleInGame = new TankMissle();
            MissleInGame.LoadContent(game.Content);

            InfoFont               = game.Content.Load <SpriteFont>("SpriteFont1");
            explosionSound         = game.Content.Load <SoundEffect>("cinema boom impact");
            shotSound              = game.Content.Load <SoundEffect>("shoot");
            turretMoveSound        = game.Content.Load <SoundEffect>("turret").CreateInstance();
            cannonMoveSound        = game.Content.Load <SoundEffect>("turret").CreateInstance();
            morePowerSound         = game.Content.Load <SoundEffect>("morepower").CreateInstance();
            lessPowerSound         = game.Content.Load <SoundEffect>("lesspower").CreateInstance();
            danseMacabre           = game.Content.Load <SoundEffect>("Danse Macabre - Big Hit 2").CreateInstance();
            missileFlight          = game.Content.Load <SoundEffect>("151914__carroll27__rocket-taking-off").CreateInstance();
            missileFlight.IsLooped = true;
            ambience               = game.Content.Load <Song>("nosferatu ambience_96");
        }
Esempio n. 2
0
        //ExplosionSystem Explosion;

        public TankController(Game game, int numOfPlayers)
            : base(game)
        {
            GD          = game.GraphicsDevice;
            spriteBatch = new SpriteBatch(GD);
            rand        = new Random();
            bool bNotSpawnedCorrectly;

            //Create instances and load their content
            tanksInGame = new List <Tank>();
            for (int i = 0; i < numOfPlayers; ++i)
            {
                TanksInGame.Add(new Tank());
                TanksInGame[i].LoadContent(game.Content);
                tanksInGame[i].PlayerName = "Player " + i.ToString();
                do
                {
                    bNotSpawnedCorrectly = false;
                    do
                    {
                        TanksInGame[i].SpawnAt(new Vector3(rand.Next(0, (Game1.heightMap.Width - 1) * Game1.Scale), 0, rand.Next((-Game1.heightMap.Height + 1) * Game1.Scale, 0))); // Y should be calculated
                    } while (!TanksInGame[i].IsOnMap);
                    for (int j = 0; j < TanksInGame.Count; ++j)
                    {
                        // make sure the tanks don't intersect with themselves at the beginning
                        if (i != j && TanksInGame[i].CollisionCheckWith(TanksInGame[j]))
                        {
                            bNotSpawnedCorrectly = true;
                        }
                    }
                } while (bNotSpawnedCorrectly);
            }
            missleInGame = new TankMissle();
            MissleInGame.LoadContent(game.Content);

            InfoFont        = game.Content.Load <SpriteFont>("SpriteFont1");
            explosionSound  = game.Content.Load <SoundEffect>("cinema boom impact");
            shotSound       = game.Content.Load <SoundEffect>("shoot");
            turretMoveSound = game.Content.Load <SoundEffect>("turret").CreateInstance();
            cannonMoveSound = game.Content.Load <SoundEffect>("turret").CreateInstance();
            morePowerSound  = game.Content.Load <SoundEffect>("morepower").CreateInstance();
            lessPowerSound  = game.Content.Load <SoundEffect>("lesspower").CreateInstance();
            danseMacabre    = game.Content.Load <SoundEffect>("Danse Macabre - Big Hit 2").CreateInstance();
            //ambience = game.Content.Load<SoundEffect>("nosferatu ambience").CreateInstance();

            //Explosion = new ExplosionSystem();
            //Explosion.LoadContent(game.Content, GD);

            this.Initialize();
        }