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

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