protected Enemy(EnemyData data, Rectangle levelBounds) : base(data) { if (data.Weapon != null) { if (data.Ranged) { CurrentWeapon = new ProjectileWeapon(data.Weapon, this); } else { CurrentWeapon = new MeleeWeapon(data.Weapon, this); } } Difficulty = data.Difficulty; _idealRange = data.IdealRange; }
public Level(int levelNumber) : base(false) { LevelData data = DataLoader.LoadLevel(levelNumber); _player = new Spaceman(data.PlayerStartLocation); _blackHole = data.BlackHole; _waves = new Wave[data.TrickleWaveData.Length + data.BurstWaveData.Length]; //construct waves for (int i = 0; i < data.TrickleWaveData.Length; i++) { _waves[i] = new Wave(data.TrickleWaveData[i], true); } for (int i = 0; i < data.BurstWaveData.Length; i++) { _waves[i + data.TrickleWaveData.Length] = new Wave(data.BurstWaveData[i], false); } _primaryWeapon = new ProjectileWeapon("Rocket", _player); _secondaryWeapon = new ProjectileWeapon("Swarmer", _player); _primaryGadget = new Gadget(new Gadget.GadgetData { MaxEnergy = 1000 }); }
void selectRandomWeapons() { Random rand = new Random(); int rand1 = rand.Next(0, 4); int rand2; do { rand2 = rand.Next(0, 4); } while (rand2 == rand1); ProjectileWeapon[] weapons = new ProjectileWeapon[] { new ProjectileWeapon("Shotgun", _player), new ProjectileWeapon("Gatling", _player), new ProjectileWeapon("Flamethrower", _player), new ProjectileWeapon("RocketLauncher", _player), }; _player.PrimaryWeapon = weapons[rand1]; _player.SecondaryWeapon = weapons[rand2]; }