void AppendGunObjectInCoreGunList(GameObject gun, int i) { if (gun.GetComponent <IGun>() != null) { IGun iGun = gun.gameObject.GetComponent <IGun>(); _iGunList.Add(iGun); if (_isEnemyGun == true) { return; } //Execute for only Player Gun if (i < _minActiveGunNum) { _iGunList[i].SetIsItPrimaryGun(true); _lastGunIndex = i; } else { _iGunList[i].SetIsItPrimaryGun(false); } _iGunList[i].SetShootingCapabilities(_iGunList[i].IsItPrimaryGun()); } }
protected Player(string username, int health, int armor, IGun gun) { this.Username = username; this.Health = health; this.Armor = armor; this.Gun = gun; }
public string AddGunToPlayer(string name) { IGun gun = this.gunRepository.Models.FirstOrDefault(); if (this.gunRepository.Models.Count == 0) { return("There are no guns in the queue!"); } if (name == "Vercetti") { this.mainPlayer.GunRepository.Add(gun); this.gunRepository.Remove(gun); return($"Successfully added {gun.Name} to the Main Player: Tommy Vercetti"); } if (this.PlayersList.FirstOrDefault(n => n.Name == name) == null) { return("Civil player with that name doesn't exists!"); } IPlayer civilPlayer = this.PlayersList.FirstOrDefault(n => n.Name == name); civilPlayer.GunRepository.Add(gun); this.gunRepository.Remove(gun); return($"Successfully added {gun.Name} to the Civil Player: {civilPlayer.Name}"); }
public Upgrade(IGun upgradeTarget, UpgradeType type) { this.upgradeTarget = upgradeTarget; this.upgradeType = type; playerId = upgradeTarget.PlayerId; controller = new UpgradeOption(this, playerId); }
public string AddGunToPlayer(string name) // players name { if (guns.Count == 0) { return("There are no guns in the queue!"); } IGun gun = guns.First(); string message = string.Empty; if (name == "Vercetti") { main.GunRepository.Add(gun); message = $"Successfully added {gun.Name} to the Main Player: Tommy Vercetti"; } else if (civils.FirstOrDefault(x => x.Name == name) == null) { message = "Civil player with that name doesn't exist!"; } else { civils.FirstOrDefault(x => x.Name == name).GunRepository.Add(gun); message = $"Successfully added {gun.Name} to the Civil Player: {name}"; } guns.Remove(gun); return(message); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun playersGun = gunsRep.FindByName(gunName); if (playersGun == null) { throw new ArgumentException("Gun cannot be found!"); } if (type == "Terrorist" || type == "CounterTerrorist") { if (type == "Terrorist") { playerRep.Add(new Terrorist(username, health, armor, playersGun)); } else if (type == "CounterTerrorist") { playerRep.Add(new CounterTerrorist(username, health, armor, playersGun)); } } else { throw new ArgumentException("Invalid player type."); } return($"Successfully added player {username}."); }
public void Add(IGun model) { if (!models.Contains(Count)) { this.models.Add(model); } }
public bool Remove(IGun model) { if (models.Contains(Count)) { this.models.Remove(model); } }
public string AddGun(string type, string name) { if (type != nameof(Pistol) && type != nameof(Rifle)) { return(OutputMessages.InvalidGun); } IGun gun = null; switch (type) { case "Rifle": gun = new Rifle(name); break; case "Pistol": gun = new Pistol(name); break; default: break; } this.gunRepository.Add(gun); return(string.Format(OutputMessages.SuccessfullAddedGun, gun.Name, gun.GetType().Name)); }
public string AddGunToPlayer(string name) { if (this.gunRepository.Models.Count == 0) { return(OutputMessages.NoAvailableWeapon); } if (name == MainPlayerNameKey) { IPlayer playerVercetti = this.players .FirstOrDefault( p => p.Name == FullNameMainPlayer && p.GetType().Name == nameof(MainPlayer)); IGun gunVercetti = this.gunRepository.Models.FirstOrDefault(g => g.CanFire == true); this.gunRepository.Remove(gunVercetti); playerVercetti.GunRepository.Add(gunVercetti); return(string.Format(OutputMessages.SuccessfullAddWeaponToMainPlayer, gunVercetti.Name)); } if (this.players.FirstOrDefault(p => p.Name == name) == null) { return(OutputMessages.PlayerNotExist); } IPlayer player = this.players.FirstOrDefault(p => p.Name == name); IGun gun = this.gunRepository.Models.FirstOrDefault(g => g.CanFire == true); this.gunRepository.Remove(gun); player.GunRepository.Add(gun); return(string.Format(OutputMessages.SuccessfullAddWeaponToCivilPlayer, gun.Name, player.Name)); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IPlayer player; IGun gun = gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } if (type == "Terrorist") { player = new Terrorist(username, health, armor, gun); } else if (type == "CounterTerrorist") { player = new CounterTerrorist(username, health, armor, gun); } else { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } playerRepository.Add(player); return(string.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
public string AddGunToPlayer(string name) { if (this.guns.Count == 0) { return("There are no guns in the queue!"); } IGun gun = this.guns.FirstOrDefault(); IPlayer civilPlayer = this.civilPlayers.FirstOrDefault(p => p.Name == name); string mesage = string.Empty; if (name == "Vercetti") { this.mainPlayer.GunRepository.Add(gun); mesage = $"Successfully added {gun.Name} to the Main Player: Tommy Vercetti"; } else if (civilPlayer != null) { civilPlayer.GunRepository.Add(gun); mesage = $"Successfully added {gun.Name} to the Civil Player: {name}"; } else { return("Civil player with that name doesn't exists!"); } this.guns.Remove(gun); return(mesage); }
public override void Update() { Console.WriteLine("what to do with the gun: 1 single shot, 2 automatic shot, 3 reload"); string key = Console.ReadLine(); //check the key and give the gun his behaviour if (key == "1") { gunBehaviour = new SingleShot(); } else if (key == "2") { gunBehaviour = new AutomaticShot(); } else if (key == "3") { gunBehaviour = new Reload(); } if (key == "1" || key == "2" || key == "3") { performAction(); } }
public void Action(IPlayer mainPlayer, ICollection <IPlayer> civilPlayers) { while (true) { IGun gun = mainPlayer.GunRepository.Models.FirstOrDefault(g => g.CanFire == true); IPlayer target = civilPlayers.FirstOrDefault(t => t.IsAlive == true); if (gun == null || target == null) { break; } int damagePoints = gun.Fire(); target.TakeLifePoints(damagePoints); } while (true) { IPlayer player = civilPlayers.FirstOrDefault(t => t.IsAlive == true); IGun gun = player.GunRepository.Models.FirstOrDefault(g => g.CanFire == true); if (player == null || gun == null) { break; } int damagePoints = gun.Fire(); mainPlayer.TakeLifePoints(damagePoints); if (mainPlayer.IsAlive == false) { break; } } }
private IPlayer CreatePlayer(string type, string username, int health, int armor, string gunName) { IPlayer player = null; IGun gun = this.guns.FindByName(gunName); if (type == "Terrorist") { if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } player = new Terrorist(username, health, armor, gun); } else if (type == "CounterTerrorist") { if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } player = new CounterTerrorist(username, health, armor, gun); } else { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } return(player); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun wantedGun = this.guns.FindByName(gunName); if (wantedGun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } if (type != "Terrorist" && type != "CounterTerrorist") { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } IPlayer player = null; if (type == "Terrorist") { player = new Terrorist(username, health, armor, wantedGun); } else if (type == "CounterTerrorist") { player = new CounterTerrorist(username, health, armor, wantedGun); } this.players.Add(player); return(String.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
public StatePatternExample( IGun gun, IAmmunitionContainer ammunitionContainer) { _gun = gun; _ammunitionContainer = ammunitionContainer; }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun gun = this.gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } if (type != nameof(Terrorist) && type != nameof(CounterTerrorist)) { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } if (type == nameof(Terrorist)) { this.playerRepository.Add(new Terrorist(username, health, armor, gun)); } else { this.playerRepository.Add(new CounterTerrorist(username, health, armor, gun)); } return(string.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
private void PlayerAttack(IPlayer mainPlayer, ICollection <IPlayer> civilPlayers) { var players = civilPlayers.Where(x => x.IsAlive == true).Where(x => x.GunRepository.Models.Count > 0); foreach (IPlayer player in players) { IGun gun = player.GunRepository.Models.FirstOrDefault(x => x.CanFire == true); while (true) { mainPlayer.TakeLifePoints(gun.Fire()); if (!gun.CanFire) { player.GunRepository.Remove(gun); gun = player.GunRepository.Models.FirstOrDefault(x => x.CanFire == true); } if (!mainPlayer.IsAlive) { return; } if (gun == null) { break; } } } }
protected Player(string username, int health, int armor, IGun gun) { Username = username; Health = health; Armor = armor; Gun = gun; }
private void MainPlayerAttack(IPlayer mainPlayer, ICollection <IPlayer> civilPlayers) { IGun gun = mainPlayer.GunRepository.Models.FirstOrDefault(x => x.CanFire == true); IPlayer player = civilPlayers.FirstOrDefault(x => x.IsAlive == true); while (true) { if (player == null || gun == null) { break; } player.TakeLifePoints(gun.Fire()); if (!gun.CanFire) { player.GunRepository.Remove(gun); gun = mainPlayer.GunRepository.Models.FirstOrDefault(x => x.CanFire == true); } if (!player.IsAlive) { civilPlayers.Remove(player); this.deadCivilPlayers++; player = civilPlayers.FirstOrDefault(x => x.IsAlive == true); } if (player == null || gun == null) { break; } } }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun gun = this.guns.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } IPlayer player = null; switch (type) { case "Terrorist": player = new Terrorist(username, health, armor, gun); break; case "CounterTerrorist": player = new CounterTerrorist(username, health, armor, gun); break; default: throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } this.players.Add(player); return(string.Format(OutputMessages.SuccessfullyAddedPlayer, player.Username)); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun gun = this.guns.Models.FirstOrDefault(g => g.Name == gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } IPlayer player; if (type == nameof(Terrorist)) { player = new Terrorist(username, health, armor, gun); } else if (type == nameof(CounterTerrorist)) { player = new CounterTerrorist(username, health, armor, gun); } else { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } this.players.Add(player); var result = string.Format(OutputMessages.SuccessfullyAddedPlayer, username); return(result); }
public string AddGunToPlayer(string name) { string message = String.Empty; if (!guns.Any()) { return("There are no guns in the queue!"); } IGun gun = this.guns.FirstOrDefault(); if (name == MainPlayerNameKey) { mainPlayer.GunRepository.Add(gun); this.guns.Remove(gun); return($"Successfully added {gun.Name} to the Main Player: Tommy Vercetti"); } var civilPlayer = this.civilPlayers.FirstOrDefault(p => p.Name == name); if (civilPlayer != null) { civilPlayer.GunRepository.Add(gun); this.guns.Remove(gun); return($"Successfully added {gun.Name} to the Civil Player: {civilPlayer.Name}"); } else { return("Civil player with that name doesn't exists!"); } //this.guns.Remove(gun); return(message); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun gun = gunRepository.FindByName(gunName); if (gun is null) { throw new ArgumentException("Gun cannot be found!"); } IPlayer player; if (type == "Terrorist") { player = new Terrorist(username, health, armor, gun); } else if (type == "CounterTerrorist") { player = new CounterTerrorist(username, health, armor, gun); } else { throw new ArgumentException("Invalid player type!"); } this.playerRepository.Add(player); return(String.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
public void Action(IPlayer mainPlayer, ICollection <IPlayer> civilPlayers) { IPlayer aliveCivilPlayer = civilPlayers.FirstOrDefault(cp => cp.IsAlive); IGun loadedGun = mainPlayer.GunRepository.Models.FirstOrDefault(g => g.CanFire); while (aliveCivilPlayer != null && loadedGun != null) { int shots = loadedGun.Fire(); aliveCivilPlayer.TakeLifePoints(shots); aliveCivilPlayer = civilPlayers.FirstOrDefault(cp => cp.IsAlive); loadedGun = mainPlayer.GunRepository.Models.FirstOrDefault(g => g.CanFire); } List <IPlayer> alivePlayers = civilPlayers.Where(p => p.IsAlive).ToList(); foreach (IPlayer player in alivePlayers) { loadedGun = player.GunRepository.Models.FirstOrDefault(g => g.CanFire); while (mainPlayer.IsAlive && loadedGun != null) { int shots = loadedGun.Fire(); mainPlayer.TakeLifePoints(shots); } } }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IPlayer Player = null; IGun gun = null; gun = gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } switch (type) { case "Terrorist": Player = new Terrorist(username, health, armor, gun); break; case "CounterTerrorist": Player = new CounterTerrorist(username, health, armor, gun); break; default: throw new ArgumentException(ExceptionMessages.InvalidPlayerType); // exc message-a se razlichava s tova ot faila } playerRepository.Add(Player); return(String.Format(OutputMessages.SuccessfullyAddedPlayer, username)); }
public string AddPlayer (string type, string username, int health, int armor, string gunName) { IGun gun = gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException("Gun cannot be found!"); } if (type == "Terrorist") { Player newPlayer = new Terrorist(username, health, armor, gun); playerRepository.Add(newPlayer); } else if (type == "CounterTerrorist") { Player newPlayer = new CounterTerrorist(username, health, armor, gun); playerRepository.Add(newPlayer); } else { throw new ArgumentException("Invalid player type!"); } return($"Successfully added player {username}."); }
public override void UpdateAbility() { IGun Gun = RC.Active_IMWeapon as IGun; //Store the Current Gun if (Gun == null) { return; } if (Gun.IsAiming != RC.IsAiming) { Gun.IsAiming = RC.IsAiming; } if (RC.Reload.GetInput) //Check For Reload { PistolReload(RC.Active_IMWeapon as IGun); } if (RC.IsAiming && RC.WeaponAction != WeaponActions.Fire_Proyectile) { // && Gun.FireRate < (Time.time - currentFireRateTime)) //If is aiming and is not already firing a proyectile PistolAttack(Gun); //Fire Pistol } //Debug.Log((Time.time - currentFireRateTime)); }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun gun = gunRepository.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } IPlayer player; if (type == "Terrorist") { player = new Terrorist(username, health, armor, gun); playerRepository.Add(player); return($"Successfully added player {player.Username}."); } else if (type == "CounterTerrorist") { player = new CounterTerrorist(username, health, armor, gun); playerRepository.Add(player); return($"Successfully added gun {gun.Name}."); } else { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } }
public string AddPlayer(string type, string username, int health, int armor, string gunName) { IGun gun = guns.FindByName(gunName); if (gun == null) { throw new ArgumentException(ExceptionMessages.GunCannotBeFound); } IPlayer player = null; if (type == nameof(Terrorist)) { player = new Terrorist(username, health, armor, gun); } else if (type == nameof(CounterTerrorist)) { player = new CounterTerrorist(username, health, armor, gun); } else { throw new ArgumentException(ExceptionMessages.InvalidPlayerType); } this.players.Add(player); string message = string.Format(OutputMessages.SuccessfullyAddedPlayer, player.Username); return(message); }
public EffectUpgrade(IGun toUpgrade, Effects newEffects, bool keepExistingEffects, UpgradeType type) : base(toUpgrade, type) { this.newEffects = newEffects; this.keepExistingEffects = keepExistingEffects; }
public StrengthUpgrade(IGun toUpgrade, int strength, UpgradeType type) : base(toUpgrade, type) { this.strength = strength; }
public ShotUpgrade(IGun toUpgrade, ShotPatterns newShotPatterns, bool keepExistingShots, UpgradeType type) : base(toUpgrade, type) { this.newShotPatterns = newShotPatterns; this.keepExistingShots = keepExistingShots; }
/// <summary> /// Let user select a gun of their choice /// </summary> private void GunSelection() { Console.WriteLine("Select a gun: \n" + "1: Rifle\n" + "2: Pistol\n"); try { var selection = int.Parse(Console.ReadLine()); //Ninjects returns an instace of the selected gun switch (selection) { case 1: _selectedGun = _kernel.Get<M16>(); break; case 2: _selectedGun = _kernel.Get<PipeHandGun>(); break; default: GunSelection(); break; } Console.WriteLine(_selectedGun.GetName() + " selected."); } catch (FormatException) { Console.WriteLine("Please select a valid gun."); GunSelection(); } }