Esempio n. 1
0
 public bool this[TypeOfGun gun]
 {
     get
     {
         return weaponCache.IsSetWeapon(gun);
     }
 }
Esempio n. 2
0
 public bool this[TypeOfGun gun]
 {
     get
     {
         return(weaponCache.IsSetWeapon(gun));
     }
 }
Esempio n. 3
0
 public override void ChooseWeapon(TypeOfGun gun)
 {
     if (weaponCache.IsSetWeapon(gun) == true)
     {
         weaponCache.Add(Weapon.GunType, Weapon);
         Weapon = weaponCache.GetWeapon(gun);
     }
 }
Esempio n. 4
0
        public override void ChooseWeapon(TypeOfGun gun)
        {
            if (weaponCache.IsSetWeapon(gun) == true)
            {
                weaponCache.Add(Weapon.GunType,Weapon);
                Weapon = weaponCache.GetWeapon(gun);
            }

        }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
 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);
 }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
 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);
         }
     }
 }
Esempio n. 12
0
        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;
        }
Esempio n. 13
0
    // 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();
    }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
 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;
 }
Esempio n. 16
0
        public override Gun CreateGun(TypeOfGun type)
        {
            switch (type)
            {
            case TypeOfGun.Artillery:
            {
                return(new ArtilleryGun());
            }

            case TypeOfGun.Tank:
            {
                return(new TankGun());
            }

            default:
            {
                return(new TankGun());
            }
            }
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
 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;
 }
Esempio n. 20
0
 abstract public bool IsSetWeapon(TypeOfGun type);
Esempio n. 21
0
 abstract public IWeapon GetProduct(TypeOfGun gun);
Esempio n. 22
0
 abstract public bool Buy(TypeOfGun gun, IShip ship, IPlayer player);
Esempio n. 23
0
 abstract public IWeapon GetProduct(TypeOfGun gun);
Esempio n. 24
0
 public override void SetWeaponFromShop(TypeOfGun gun, IWeapon weapon)
 {
     weaponCache.Add(gun, weapon);
 }
Esempio n. 25
0
 abstract public IWeapon GetWeapon(TypeOfGun type);
Esempio n. 26
0
 /// <summary>
 /// Создать оружие
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public abstract Gun CreateGun(TypeOfGun type);
Esempio n. 27
0
 public override void SetWeaponFromShop(TypeOfGun gun, IWeapon weapon)
 {
     weaponCache.Add(gun, weapon);
 }
Esempio n. 28
0
 abstract public IWeapon GetWeapon(TypeOfGun type);
Esempio n. 29
0
 abstract public void SetWeaponFromShop(TypeOfGun gun, IWeapon weapon);
Esempio n. 30
0
 abstract public void ChooseWeapon(TypeOfGun gun);
Esempio n. 31
0
        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));
        }
Esempio n. 32
0
 abstract public bool IsSetWeapon(TypeOfGun type);
Esempio n. 33
0
 abstract public void Add(TypeOfGun type, IWeapon weapon);
Esempio n. 34
0
 abstract public void ChooseWeapon(TypeOfGun gun);
Esempio n. 35
0
 abstract public void SetWeaponFromShop(TypeOfGun gun, IWeapon weapon);
Esempio n. 36
0
 abstract public bool Buy(TypeOfGun gun, IShip ship, IPlayer player);
Esempio n. 37
0
 abstract public void Add(TypeOfGun type, IWeapon weapon);