/// <summary> /// Constructs a weapon pickup /// </summary> /// <param name="weapon">Weapon</param> /// <param name="spawnPoint">Spawn point</param> /// <param name="entity">Entity</param> /// <param name="remainingRespawnTime">Remaining respawn time</param> public WeaponPickup(IWeapon weapon, ISpawnPoint spawnPoint, double respawnTime, IServerLobby serverLobby) { if (weapon == null) { throw new ArgumentNullException(nameof(weapon)); } if (!weapon.IsValid) { throw new ArgumentException("Weapon is not valid.", nameof(weapon)); } if (respawnTime < 0.0f) { throw new ArgumentException("Respawn time can't be negative", nameof(respawnTime)); } if (serverLobby == null) { throw new ArgumentNullException(nameof(serverLobby)); } if (!serverLobby.IsValid) { throw new ArgumentException("Server lobby is not valid.", nameof(serverLobby)); } Weapon = weapon; SpawnPoint = spawnPoint ?? throw new ArgumentNullException(nameof(spawnPoint)); RespawnTime = respawnTime; this.serverLobby = serverLobby; Respawn(); }
/// <summary> /// Game mode has been initialized /// </summary> /// <param name="gameResource">Game resource</param> /// <param name="serverLobby">Server lobby</param> public void OnInitialized(IGameResource gameResource, IServerLobby serverLobby) { this.serverLobby = serverLobby; if (gameResource is IDeathmatchGameResource deathmatch_game_resource) { Characters = deathmatch_game_resource.Assets.Get <string[], ICharacters>("./Assets/Deathmatch/characters.json"); Rules = deathmatch_game_resource.Assets.Get <RulesData, IRules>("./Assets/Deathmatch/rules.json"); PlayerCharacterSpawnPoints = deathmatch_game_resource.Assets.Get <SpawnPointData[], ISpawnPoints>("./Assets/Deathmatch/player-character-spawn-points.json"); WeaponSpawnPoints = deathmatch_game_resource.Assets.Get <SpawnPointData[], ISpawnPoints>("./Assets/Deathmatch/weapon-spawn-points.json"); Weapons = deathmatch_game_resource.Assets.Get <WeaponData[], IWeapons>("./Assets/Deathmatch/weapons.json"); if (WeaponSpawnPoints.Count > 0) { weaponPickups = new WeaponPickup[WeaponSpawnPoints.Count]; for (int index = 0; index < WeaponSpawnPoints.Count; index++) { weaponPickups[index] = new WeaponPickup(Weapons.RandomWeapon, WeaponSpawnPoints[index], Rules.WeaponPickupRespawnTime, serverLobby); } } else { weaponPickups = Array.Empty <WeaponPickup>(); } } else { Characters = new Characters(); Rules = new Rules(); PlayerCharacterSpawnPoints = new SpawnPoints(); WeaponSpawnPoints = new SpawnPoints(); Weapons = new Weapons(); } RemainingRoundTime = Rules.RoundTime; weaponPickupRadiusSquared = Rules.WeaponPickupRadius * Rules.WeaponPickupRadius; Console.WriteLine("========================================================="); Console.WriteLine("= ="); Console.WriteLine("= ElectrodZ Deathmatch ="); Console.WriteLine("= GitHub: https://github.com/BigETI/ElectrodZDeathmatch ="); Console.WriteLine("= ="); Console.WriteLine("========================================================="); Console.WriteLine("= ="); Console.WriteLine("= by Ethem Kurt ="); Console.WriteLine("= ="); Console.WriteLine("= loaded! ="); Console.WriteLine("= ="); Console.WriteLine("========================================================="); }
/// <summary> /// Sends a join lobby acknowledged message /// </summary> /// <param name="lobby">Lobby</param> public void SendJoinLobbyAcknowledgedMessage(IServerLobby lobby) => SendMessage(new JoinLobbyAcknowledgedMessageData(lobby));
/// <summary> /// Game mode has been initialized /// </summary> /// <param name="gameResource">Game resource</param> /// <param name="serverLobby">Server lobby</param> public void OnInitialized(IGameResource gameResource, IServerLobby serverLobby) => Console.WriteLine("Example game mode has been initialized!");