public bool this[TypeOfGun gun] { get { return weaponCache.IsSetWeapon(gun); } }
public bool this[TypeOfGun gun] { get { return(weaponCache.IsSetWeapon(gun)); } }
public override void ChooseWeapon(TypeOfGun gun) { if (weaponCache.IsSetWeapon(gun) == true) { weaponCache.Add(Weapon.GunType, Weapon); Weapon = weaponCache.GetWeapon(gun); } }
public override void ChooseWeapon(TypeOfGun gun) { if (weaponCache.IsSetWeapon(gun) == true) { weaponCache.Add(Weapon.GunType,Weapon); Weapon = weaponCache.GetWeapon(gun); } }
public override void Add(TypeOfGun type, IWeapon weapon) { KeyValuePair<TypeOfGun, IWeapon> tmp = new KeyValuePair<TypeOfGun, IWeapon>(type, weapon); if (weaponRepository.Contains(tmp) == false) { weaponRepository.Add(tmp); } }
public override void Add(TypeOfGun type, IWeapon weapon) { KeyValuePair <TypeOfGun, IWeapon> tmp = new KeyValuePair <TypeOfGun, IWeapon>(type, weapon); if (weaponRepository.Contains(tmp) == false) { weaponRepository.Add(tmp); } }
override public IWeapon GetProduct(TypeOfGun gun) { for (int i = 0; i < weapons.Count; i++) { if (weapons[i].GunType == gun) { bought = weapons[i]; weapons.RemoveAt(i); break; } } return bought; }
override public IWeapon GetProduct(TypeOfGun gun) { for (int i = 0; i < weapons.Count; i++) { if (weapons[i].GunType == gun) { bought = weapons[i]; weapons.RemoveAt(i); break; } } return(bought); }
public override bool IsSetWeapon(TypeOfGun type) { bool detector = false; foreach (KeyValuePair<TypeOfGun, IWeapon> itm in weaponRepository) { if (itm.Key == type) { detector = true; break; } } return detector; }
public override bool IsSetWeapon(TypeOfGun type) { bool detector = false; foreach (KeyValuePair <TypeOfGun, IWeapon> itm in weaponRepository) { if (itm.Key == type) { detector = true; break; } } return(detector); }
public void ChangeWeapon(int index) { for (int i = 0; i < transform.childCount; i++) { if (i == index) { gun = transform.GetChild(i).GetComponent <TypeOfGun>(); gun.gameObject.SetActive(true); } else { transform.GetChild(i).gameObject.SetActive(false); } } }
public Tank(Factory factoryType, TypeOfArmor armorType, TypeOfGun gunType, TypeOfEngine engineType) { name = factoryType.SetName(); gun = factoryType.CreateGun(gunType); SetComponent(gun); engine = factoryType.CreateEngine(engineType); SetComponent(engine); armor = factoryType.CreateArmor(armorType); SetComponent(armor); factory = factoryType; typeOfArmor = armorType; typeOfGun = gunType; typeOfEngine = engineType; }
// Use this for initialization void Start() { _rb = GetComponent <Rigidbody>(); if (!hasAuthority) { this.enabled = false; return; } gun = transform.Find("Pistol").GetComponent <TypeOfGun>(); gun.gameObject.SetActive(true); _shoottimer = 0; new PacketBase(PacketIDs.Server_StartPlayer).Add(myname).Add(connectionId).SendAsClient(); }
public override IWeapon GetWeapon(TypeOfGun type) { bool detector = false; int index = 0; foreach (KeyValuePair<TypeOfGun, IWeapon> itm in weaponRepository) { if (itm.Key == type) { detector = true; break; } index++; } if (detector == true) { return weaponRepository[index].Value; } return null; }
public override bool Buy(TypeOfGun gun, IShip ship, IPlayer player) { IWeapon weapon = shop.GetProduct(gun); if (weapon != null) { ship.SetWeaponFromShop(weapon.GunType, weapon); player.Money -= shop.GetPrice(gun.ToString()); if (gun == TypeOfGun.Catapult) { ship.NumOfStones = 5; } else { ship.NumOfRockets = 5; } return true; } return false; }
public override Gun CreateGun(TypeOfGun type) { switch (type) { case TypeOfGun.Artillery: { return(new ArtilleryGun()); } case TypeOfGun.Tank: { return(new TankGun()); } default: { return(new TankGun()); } } }
public override IWeapon GetWeapon(TypeOfGun type) { bool detector = false; int index = 0; foreach (KeyValuePair <TypeOfGun, IWeapon> itm in weaponRepository) { if (itm.Key == type) { detector = true; break; } index++; } if (detector == true) { return(weaponRepository[index].Value); } return(null); }
public override bool Buy(TypeOfGun gun, IShip ship, IPlayer player) { IWeapon weapon = shop.GetProduct(gun); if (weapon != null) { ship.SetWeaponFromShop(weapon.GunType, weapon); player.Money -= shop.GetPrice(gun.ToString()); if (gun == TypeOfGun.Catapult) { ship.NumOfStones = 5; } else { ship.NumOfRockets = 5; } return(true); } return(false); }
void SetPlayer(int id) { if (id == 1) { GetComponent <SpriteRenderer>().color = Color.red; for (int i = 1; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(false); } } else if (id == 2) { GetComponent <SpriteRenderer>().color = Color.green; for (int i = 1; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(false); } } gun = transform.Find("Pistol").GetComponent <TypeOfGun>(); gun.gameObject.SetActive(true); _initialLife = life; }
abstract public bool IsSetWeapon(TypeOfGun type);
abstract public IWeapon GetProduct(TypeOfGun gun);
abstract public bool Buy(TypeOfGun gun, IShip ship, IPlayer player);
public override void SetWeaponFromShop(TypeOfGun gun, IWeapon weapon) { weaponCache.Add(gun, weapon); }
abstract public IWeapon GetWeapon(TypeOfGun type);
/// <summary> /// Создать оружие /// </summary> /// <param name="type"></param> /// <returns></returns> public abstract Gun CreateGun(TypeOfGun type);
abstract public void SetWeaponFromShop(TypeOfGun gun, IWeapon weapon);
abstract public void ChooseWeapon(TypeOfGun gun);
public static Tank CreateFromFile(string path) { var info = File.ReadAllLines(path); TypeOfArmor armorType = TypeOfArmor.Composite; TypeOfEngine engineType = TypeOfEngine.Gasturbine; TypeOfGun gunType = TypeOfGun.Tank; Factory factoryType = new RussianFactory(); try { switch (info[0]) { case "Russian": { factoryType = new RussianFactory(); break; } case "American": { factoryType = new AmericanFactory(); break; } } switch (info[1]) { case "Artillery": { gunType = TypeOfGun.Artillery; break; } case "Tank": { gunType = TypeOfGun.Tank; break; } } switch (info[2]) { case "Dynamic": { armorType = TypeOfArmor.Dynamic; break; } case "Composite": { armorType = TypeOfArmor.Composite; break; } } switch (info[3]) { case "Diesel": { engineType = TypeOfEngine.Diesel; break; } case "Gasturbine": { engineType = TypeOfEngine.Gasturbine; break; } } } catch (FormatException) { throw new FileFormatException("Входной файл имел неверный формат"); } return(new Tank(factoryType, armorType, gunType, engineType)); }
abstract public void Add(TypeOfGun type, IWeapon weapon);