public AntiFactory(GestionScreen instance) { sucre = vitC = gras = maxSucre = maxGras = maxVitC = 100; manager = new UiManager(); _instance = instance; position = new Vector2(200, 200); texture = Utils.CreateTexture(1000, 400, Color.Gray); Bounds = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height); manager.AddParticle(new UiButton(new Vector2(position.X + 300, position.Y + 100), () => { BuyAnticorps(AntiType.Normal); }, Assets.AddAnti)); manager.AddParticle(new UiButton(new Vector2(position.X + 300, position.Y + 200), () => { BuyAnticorps(AntiType.Neighbour); }, Assets.AddAnti)); manager.AddParticle(new UiButton(new Vector2(position.X + 300, position.Y + 300), () => { BuyAnticorps(AntiType.Leader); }, Assets.AddAnti)); listProgress = new ProgressBar[3]; sucreBar = new ProgressBar(new Vector2(position.X + 50, position.Y + 100), 200, 50, Color.Red, maxSucre, true); grasBar = new ProgressBar(new Vector2(position.X + 50, position.Y + 200), 200, 50, Color.Yellow, maxGras, true); vitCBar = new ProgressBar(new Vector2(position.X + 50, position.Y + 300), 200, 50, Color.Green, maxVitC, true); listProgress[0] = sucreBar; listProgress[1] = grasBar; listProgress[2] = vitCBar; }
public override void Create() { Main.Instance.IsMouseVisible = false; _areneBounds = new Rectangle(92, 92, Assets.Arene.Width - 92 * 2, Assets.Arene.Height - 92 * 2); _gameOver = false; _camera = new Camera(); _weapons = new List <Weapon>(); _enemies = new List <Enemy>(); _uiManager = new UiManager(); ReplayDelegate replay = Replay; QuitDelegate quit = Quit; _uiManager.AddParticle(new UiButton(_camera.ScreenToWorld(new Vector2(Utils.WIDTH / 2 - 250, .7f * Utils.HEIGHT)), Replay, Assets.ReplayButton)); _uiManager.AddParticle(new UiButton(_camera.ScreenToWorld(new Vector2(Utils.WIDTH / 2 + 50, .7f * Utils.HEIGHT)), Quit, Assets.QuitButton)); _loots = new List <Loot>(); _player = new Player(Assets.Player, new Vector2(Utils.WIDTH / 2 - 25, Utils.HEIGHT / 2 - 25), _camera); var nbLoot = Utils.RANDOM.Next(5, 16); for (var i = 0; i < nbLoot; i++) { Loot potentialLoot; bool intersectWithEntity; do { intersectWithEntity = false; var lootX = Utils.RANDOM.Next(_areneBounds.Left, _areneBounds.Right - 150); var lootY = Utils.RANDOM.Next(_areneBounds.Top, _areneBounds.Bottom - 150); potentialLoot = new Loot(new Vector2(lootX, lootY)); foreach (var enemy in _enemies) { if (potentialLoot.Hitbox.Intersects(enemy.Hitbox)) { intersectWithEntity = true; break; } } if (potentialLoot.Hitbox.Intersects(Player.Hitbox)) { intersectWithEntity = true; } } while (intersectWithEntity); _loots.Add(potentialLoot); } var nbWeapon = Utils.RANDOM.Next(10, 31); for (var i = 0; i < nbWeapon; i++) { Weapon potentialWeapon; bool intersectWithEntity; do { intersectWithEntity = false; var weaponX = Utils.RANDOM.Next(_areneBounds.Left, _areneBounds.Right - 150); var weaponY = Utils.RANDOM.Next(_areneBounds.Top, _areneBounds.Bottom - 150); var rnd = Utils.RANDOM.Next(3); switch (rnd) { case 0: potentialWeapon = new Gun(new Vector2(weaponX, weaponY), WeaponState.OnFloor, _camera); break; case 1: potentialWeapon = new SubMachine(new Vector2(weaponX, weaponY), WeaponState.OnFloor, _camera); break; case 2: potentialWeapon = new Sniper(new Vector2(weaponX, weaponY), WeaponState.OnFloor, _camera); break; default: potentialWeapon = new Gun(new Vector2(weaponX, weaponY), WeaponState.OnFloor, _camera); break; } foreach (var enemy in _enemies) { if (potentialWeapon.Hitbox.Intersects(enemy.Hitbox)) { intersectWithEntity = true; break; } } if (potentialWeapon.Hitbox.Intersects(Player.Hitbox)) { intersectWithEntity = true; } } while (intersectWithEntity); _weapons.Add(potentialWeapon); } for (var i = 0; i < 15; i++) { Enemy potentialEnemy; bool intersectWithEntity; do { intersectWithEntity = false; var enemyX = Utils.RANDOM.Next(_areneBounds.Left, _areneBounds.Right - 50); var enemyY = Utils.RANDOM.Next(_areneBounds.Top, _areneBounds.Bottom - 50); potentialEnemy = new Enemy(Assets.Enemy, new Vector2(enemyX, enemyY), _player, _camera); foreach (var enemy in _enemies) { if (potentialEnemy.Hitbox.Intersects(enemy.Hitbox)) { intersectWithEntity = true; break; } } if (potentialEnemy.Hitbox.Intersects(Player.Hitbox)) { intersectWithEntity = true; } } while (intersectWithEntity); _enemies.Add(potentialEnemy); } Assets.MusicShooter.Volume = 0.5f; Assets.MusicShooter.IsLooped = true; Assets.MusicShooter.Play(); }