Wave[] _waves; //collection of all trickle waves and active burst wave

        #endregion Fields

        #region Constructors

        public Level(ContentManager content, int levelNumber, InventoryManager im)
            : base(content, false, "Level")
        {
            LevelData data = DataManager.GetData<LevelData>(String.Format(c_levelNameFormat, levelNumber));
            _levelBounds = new Rectangle(0, 0, data.Width, data.Height);
            _player = new Spaceman(new Vector2(data.PlayerX, data.PlayerY));
            _blackHole = new BlackHole(data.BlackHole);
            //store active burst wave as last tricklewave
            _waves = new Wave[data.TrickleWaves.Length + data.BurstWaves.Length];
            _camera = new Camera2D(_player.Position, _levelBounds.Width, _levelBounds.Height);
            //construct waves
            for (int i = 0; i < data.TrickleWaves.Length; i++)
            {
                _waves[i] = new TrickleWave(data.TrickleWaves[i], _levelBounds);
            }
            for (int i = 0; i < data.BurstWaves.Length; i++)
            {
                BurstWave prevWave = (i == 0) ? null : (BurstWave)_waves[i + data.TrickleWaves.Length - 1];
                _waves[i + data.TrickleWaves.Length] = new BurstWave(data.BurstWaves[i], _levelBounds, prevWave);
            }
            //Test code to set weapons 1-6 to created weapons
            im.setPrimaryGadget(new Gadget("Teleporter", this));
            im.setSecondaryGadget(new Gadget("Stopwatch", this));
            im.setSlot(1, new ThrowableWeapon("Cryonade", _player));

            if (data.Unicorns == null)
            {
                _unicorns = new Unicorn[0];
            }
            else
            {
                _unicorns = new Unicorn[data.Unicorns.Length];
                for (int j = 0; j < data.Unicorns.Length; j++)
                {
                    _unicorns[j] = new Unicorn(data.Unicorns[j]);
                }
            }

            _primaryGadget = im.getPrimaryGadget();
            _secondaryGadget = im.getSecondaryGadget();
            _inventoryManager = im;

            userInterface = new Hud(_player, _blackHole, _waves);

            _cursorTextureCenter = new Vector2(s_CursorTexture.Width / 2 , s_CursorTexture.Height / 2);
            selectRandomWeapons();
        }
Exemple #2
0
        public Level(int levelNumber, InventoryManager im)
            : base(false)
        {
            LevelData data = DataLoader.LoadLevel(levelNumber);
            _levelBounds = new Rectangle(0, 0, data.Width, data.Height);
            _player = new Spaceman(data.PlayerStartLocation);
            _blackHole = data.BlackHole;
            _waves = new Wave[data.TrickleWaveData.Length + data.BurstWaveData.Length];
            _camera = new Camera2D(_player.Position, _levelBounds.Width, _levelBounds.Height);
            //construct waves
            for (int i = 0; i < data.TrickleWaveData.Length; i++)
            {
                _waves[i] = new Wave(data.TrickleWaveData[i], true, _levelBounds);
            }
            for (int i = 0; i < data.BurstWaveData.Length; i++)
            {
                _waves[i + data.TrickleWaveData.Length] = new Wave(data.BurstWaveData[i], false, _levelBounds);
            }
            //Test code to set weapons 1-6 to created weapons
            im.setPrimaryWeapon(new ProjectileWeapon("Rocket", _player));
            im.setSecondaryWeapon(new ThrowableWeapon("Cryonade", _player));
            im.setPrimaryGadget(new Gadget("Teleporter", this));
            im.setSlot(1, new ThrowableWeapon("Cryonade", _player));

            //Set Weapon holders in level
            _primaryWeapon = im.getPrimaryWeapon();
            _secondaryWeapon = im.getSecondaryWeapon();

            _unicorns = new Unicorn[data.Unicorns.Length];
            for (int j = 0; j < data.Unicorns.Length; j++)
            {
                _unicorns[j] = new Unicorn(data.Unicorns[j]);
            }

            _foodCarts = data.FoodCarts;

            _primaryGadget = im.getPrimaryGadget();
            _inventoryManager = im;

            userInterface = new GUI(_player, _blackHole);
        }