public Round( GameHandler gameHandlerCtx, int nb_enemies, int stage, int level, List <IStuffFactory> stuffFactories = null, Player actualPlayer = null, Vector?playerSpawn = null, Vector?enemieSpawn = null, float enemiesLife = .1f, float enemiesSpeed = .05f, float enemiesAttack = .75f, float playerLife = 1, float playerSpeed = .1f, Vector?playerDirection = null, float playerLargeur = 0, float playerHauteur = 0, float enemiesLargeur = 0, float enemiesHauteur = 0, Dictionary <int, Vector> enemySpawn = null ) { _gameHandlerCtx = gameHandlerCtx; _stage = stage; _level = level; Console.WriteLine("Level " + _level); Console.WriteLine("Stage " + _stage); _stuffList = new List <IStuff>(); _listPackageEffect = new List <Package>(); _bullets = new List <Shoot>(); _bulletsBoss = new List <Shoot>(); _countSpawn = 1; _random = new Random(); Vector player = playerSpawn ?? new Vector(-0.7, 0.7); if (nb_enemies < 0) { throw new ArgumentException("The number of enemies can't be null or negative.", nameof(nb_enemies)); } if ( player.X < -1 || player.X > 1 || player.Y < -1 || player.Y > 1 ) { throw new ArgumentException("The spawn loaction of enemies or the place of the player can't be out of the map (map (x ; y) coordonate: [-1 ~ 1; -1 ~ 1])"); } if ( enemieSpawn != null && ( enemieSpawn.Value.X < -1 || enemieSpawn.Value.X > 1 || enemieSpawn.Value.Y < -1 || enemieSpawn.Value.Y > 1 ) ) { throw new ArgumentException("The spawn loaction of enemies or the place of the player can't be out of the map (map (x ; y) coordonate: [-1 ~ 1; -1 ~ 1])"); } float[] values = new float[5] { enemiesLife, enemiesSpeed, enemiesAttack, playerLife, playerSpeed }; // foreach (float elem in values) {if (elem < 0 || elem > 1) throw new ArgumentException("Somethings is wrong, you can't have value bigger than 1 and lower than 0.");} // Save the enemies parametres this._enemiesLife = enemiesLife; this._bossLife = enemiesLife * 5; this._enemiesSpeed = enemiesSpeed; this._enemiesAttack = enemiesAttack; this._enemiesLargeur = enemiesLargeur; this._enemiesHauteur = enemiesHauteur; this._spawn = enemySpawn; this._nbennemies = nb_enemies; if (this._spawn == null) { this._count = nb_enemies; } else { this._count = _spawn.Count; } // Create the player and the array of enemies Vector playerDir = playerDirection ?? new Vector(1, 0); if (actualPlayer == null) { this._player = new Player(_weapons, _gameHandlerCtx, player, playerLife, playerSpeed, playerDir, playerLargeur, playerHauteur); this._player.Weapons.Add(new Weapon(_gameHandlerCtx, "USP", 2f, 0, 0f, 60, TimeSpan.MaxValue, "normal")); this._player.CurrentWeapon = this._player.Weapons[0]; this._player.GetNewWeapon(new Weapon(_gameHandlerCtx, "TpGun", 0f, 0, 0f, 60, TimeSpan.MaxValue, "normal")); _stuffFactories = new List <IStuffFactory>(); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "brute", TimeSpan.FromSeconds(30))); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "bossSpawn", TimeSpan.FromSeconds(30))); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "Poison", TimeSpan.FromSeconds(30))); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "Blind", TimeSpan.FromSeconds(30))); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "Slow", TimeSpan.FromSeconds(30))); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "Cookie", TimeSpan.FromSeconds(30))); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "apple", TimeSpan.FromSeconds(30))); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "health", TimeSpan.FromSeconds(30))); _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "speed", TimeSpan.FromSeconds(30))); // indice de rareté _stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "pyro_fruit", TimeSpan.FromSeconds(30))); // indice de rareté _stuffFactories.Add(new WeaponFactory(_gameHandlerCtx, "FreezeGun", 1f, 15f, 0.05f, 1, TimeSpan.FromSeconds(30))); _stuffFactories.Add(new WeaponFactory(_gameHandlerCtx, "HypnoseGun", 0f, 15f, 0.05f, 1, TimeSpan.FromSeconds(30))); _stuffFactories.Add(new WeaponFactory(_gameHandlerCtx, "soulcalibur", 999f, 15f, 0.05f, 1, TimeSpan.FromSeconds(30))); _stuffFactories.Add(new WeaponFactory(_gameHandlerCtx, "SheepGun", 1f, 15f, 0.05f, 1, TimeSpan.FromSeconds(30))); _stuffFactories.Add(new WeaponFactory(_gameHandlerCtx, "BFG", 999f, 0, 0, 1, TimeSpan.FromSeconds(30))); _stuffFactories.Add(new WeaponFactory(_gameHandlerCtx, "Infinity_Gauntlet", 9999999f, 0, 0, 1, TimeSpan.FromSeconds(30))); this._stuffFactories.Add(new PackageFactory(_gameHandlerCtx, "point", TimeSpan.FromSeconds(30))); } else { _player = actualPlayer; _player.LifePlayer = _player.LifePlayerMax; _player.Effect = "nothing"; _player.Place = new Vector(-0.7, 0.7); _stuffFactories = stuffFactories; } if (this._stage == 4) { nb_enemies = 4; } // this._player.GetNewWeapon(new Weapon("shotgun", 0f, 0, 0f, 20)); this._enemies = new Enemies[nb_enemies]; // If the enemies spawn is null (not renseigned) each enemies have a random location Func <Vector> createPosition; // This variable is type "Func" and that return a "Vector" if (enemieSpawn == null) { createPosition = CreateRandomPosition; } else { createPosition = () => CreatePositionOnSpawn(enemieSpawn.Value); // Put enemies in the array } for (int idx = 0; idx < nb_enemies; idx += 1) { this._enemies[idx] = new Enemies(_gameHandlerCtx, idx, createPosition(), this._enemiesLife, this._enemiesSpeed, this._enemiesAttack, this._enemiesLargeur, this._enemiesHauteur); } if (this._stage == 4) { this._boss = new Boss(_gameHandlerCtx, 999, createPosition(), this._bossLife, this._enemiesSpeed, this._enemiesAttack, this._enemiesLargeur, this._enemiesHauteur); } if (this._count > this._enemies.Length) { this._count = this._enemies.Length; } this._obstacles = new List <float[]>(); }
public Player(List <Weapon> weapons, GameHandler gameHandlerCtx, Vector place, float life, float speed, Vector direction, float width = 0, float height = 0) : this(gameHandlerCtx, place, life, speed, direction, width, height) { this._weapons = weapons; }