public QuitSkillTree(QuitDelegate quitDelegate) { m_delegate = quitDelegate; }
/// <summary> /// Create a new worker thread. /// </summary> /// <param name="threadFunction">The enumerator coroutine to call on each thread loop.</param> /// <param name="onQuit">The delegate to called to request the thread complete execution.</param> /// <param name="onStop">The delegate to call after joining the thread in <see cref="Stop()"/></param> public Workthread(IEnumerator threadFunction, QuitDelegate onQuit = null, StopDelegate onStop = null) { _threadFunction = threadFunction; _onStop = onStop; _onQuit = onQuit; }
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(); }