Esempio n. 1
0
    //activate weapon
    public void SwitchWeapons(E_WeaponID weaponType)
    {
        //Debug.Log(Owner.name +  "CW Add to owner, weapon " + weaponType);
        if (Weapons.ContainsKey(weaponType) == false)
        {
            return;
        }

        float busyTime = Weapons[CurrentWeapon].GetBusyTime();

        Weapons[CurrentWeapon].SetDefaultMaterial();
        Weapons[CurrentWeapon].UnlinkFromOwner();

        CurrentWeapon = weaponType;
        Weapons[weaponType].LinkToOwner(Owner, Hand);

        Owner.WorldState.SetWSProperty(E_PropKey.WeaponLoaded, Weapons[weaponType].ClipAmmo > 0);

        if (Owner.GadgetsComponent.IsBoostActive(E_ItemBoosterBehaviour.Invisible))
        {
            float power = Owner.GadgetsComponent.GetActiveBoostPower(E_ItemBoosterBehaviour.Invisible);

            Weapons[weaponType].SetInvisibleMaterial(power);
        }

        Weapons[weaponType].WeaponArm(busyTime);
    }
Esempio n. 2
0
    public void AddWeapon(Weapon.Model model)
    {
        if (!Weapons.ContainsKey(model))
        {
            GameObject weaponGO = Instantiate(Resources.Load <GameObject>(
                                                  Paths.Prefabs.WEAPONS + model.ToString()));
            weaponGO.transform.SetParent(weaponPoint);
            weaponGO.transform.localPosition    = Vector3.zero;
            weaponGO.transform.localEulerAngles = Vector3.zero;
            Weapon weapon = weaponGO.GetComponent <Weapon>();

            Weapons.Add(model, weapon);

            CurrentWeaponModel = model;
            SetCurrentWeaponGameObject();
        }
        else
        {
            Weapons[model].Reload();
            if (model == CurrentWeaponModel)
            {
                CurrentWeaponModel = model;
            }
        }
    }
Esempio n. 3
0
 public void EquipWeapon(string name)
 {
     if (Weapons.ContainsKey(name))
     {
         m_weapon = Weapons[name];
         Console.WriteLine("Player equip " + name);
     }
 }
Esempio n. 4
0
        public Weapon GetWeapon(string id)
        {
            if (!Weapons.ContainsKey(id))
            {
                throw new GameDataException("Could not find weapon with id " + id);
            }

            return(new Weapon(Weapons[id]));
        }
Esempio n. 5
0
 public void ChangeWaponTo(WeaponType type)
 {
     //lock (Weapon)
     {
         if (Weapons.ContainsKey(type))
         {
             Weapon = Weapons[type];
         }
     }
 }
Esempio n. 6
0
        public void AddWeapon(Weapon weapon)
        {
            if (!Weapons.ContainsKey(weapon.Name))
            {
                Weapons.Add(weapon.Name, weapon);
            }

            if (m_weapon == null)
            {
                EquipWeapon(weapon.Name);
            }
        }
 /// <summary>
 /// Method to receive a weapon instance
 /// </summary>
 /// <param name="weaponName">Name (ID) of the Weapon</param>
 /// <returns>Weapon object</returns>
 ///
 public Weapon getWeapon(string weaponName)
 {
     if (Weapons.ContainsKey(weaponName))
     {
         return(Weapons[weaponName]);
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("Weapon {0} not found", weaponName);
         return(new Weapon());
     }
 }
Esempio n. 8
0
    //private Dictionary<string, List<string>> AddStringToStringDict(TextAsset textAsset)
    //{
    //    string data = textAsset.text;

    //    string[] lines = Regex.Split(data, "\n|\r|\r\n");

    //    Dictionary<string, string> temp = new Dictionary<string, string>();

    //    for (int i = 0; i < lines.Length; i++)
    //    {
    //        if (!string.IsNullOrWhiteSpace(lines[i]) && !string.IsNullOrEmpty(lines[i]))
    //        {
    //            lines[i] = lines[i].Replace(" ", string.Empty);
    //            string[] parts = lines[i].Split(':');

    //            if (!temp.ContainsKey(parts[0]))
    //            {
    //                temp.Add(parts[0], parts[1]);
    //            }
    //        }
    //    }

    //    return temp;
    //}

    public string GetRandomWeapon(string rarity)
    {
        if (Weapons.ContainsKey(rarity))
        {
            if (Weapons[rarity].Count > 0)
            {
                int i = Random.Range(0, Weapons[rarity].Count);
                return(Weapons[rarity][i]);
            }
        }

        return(string.Empty);
    }
Esempio n. 9
0
    public void AddWeaponAndSelect(E_WeaponID weapon)
    {
        if (Weapons.ContainsKey(weapon))
        {
            Weapons[weapon].AddAmmo(-1);
            return;
        }

        WeaponBase newWeapon = WeaponManager.Instance.GetWeapon(Owner, weapon);

        Weapons.Add(newWeapon.WeaponID, newWeapon);
        Owner.BlackBoard.Desires.Weapon = weapon;
    }
Esempio n. 10
0
        internal ItemTemplate GetItem(int id)
        {
            if (Armors.ContainsKey(id))
            {
                return(Armors[id]);
            }

            if (Weapons.ContainsKey(id))
            {
                return(Weapons[id]);
            }

            if (EtcItems.ContainsKey(id))
            {
                return(EtcItems[id]);
            }

            return(null);
        }
Esempio n. 11
0
    //add weapon to list only
    public virtual void AddWeapon(E_WeaponID weapon)
    {
        if (Weapons == null)
        {
            throw new System.MissingMemberException();
        }

        if (WeaponManager.Instance == null)
        {
            throw new System.ArgumentNullException();
        }

        if (Weapons.ContainsKey(weapon))
        {
            throw new System.Exception(weapon + " already exist in the list");
        }

        Weapons.Add(weapon, WeaponManager.Instance.GetWeapon(Owner, weapon));
    }
Esempio n. 12
0
    public override void AddAmmoToWeapon(AmmoBox a)
    {
        if (Owner.IsServer == false)
        {
            return;
        }

        if (Weapons.ContainsKey(a.ForWeaponType) && Weapons[a.ForWeaponType].IsFull == false)
        {
            Weapons[a.ForWeaponType].AddAmmo(a.Ammo);

            a.Disable();

            Owner.NetworkView.RPC("ClientSetAmmo",
                                  Owner.NetworkView.owner,
                                  a.ForWeaponType,
                                  Weapons[a.ForWeaponType].ClipAmmo,
                                  Weapons[a.ForWeaponType].WeaponAmmo);
        }
    }
Esempio n. 13
0
    public void SwitchWeaponWithDirection(int direction)
    {
        if (Weapons.Count > 0)
        {
            int current = (int)currentWeaponModel;
            int next    = (current + direction);
            if (next < 0)
            {
                current = Weapon.ModelsNumber + next;
            }
            else
            {
                current = next % Weapon.ModelsNumber;
            }

            currentWeaponModel = (Weapon.Model)current;
            if (!Weapons.ContainsKey(currentWeaponModel))
            {
                SwitchWeaponWithDirection(direction);
            }
            CurrentWeaponModel = currentWeaponModel;
            SetCurrentWeaponGameObject();
        }
    }
Esempio n. 14
0
 public WeaponBase GetWeapon(E_WeaponID t)
 {
     return(Weapons.ContainsKey(t) ? Weapons[t] : null);
 }
 /// <summary>
 /// Checks if the weapon exists in the factory
 /// </summary>
 /// <param name="weaponName">Name (ID) of the Weapon</param>
 /// <returns></returns>
 public bool isWeaponAvailable(string weaponName)
 {
     return(Weapons.ContainsKey(weaponName));
 }
Esempio n. 16
0
 public static bool IsValidWeapon(string weapon)
 {
     return(Weapons.ContainsValue(weapon) || Weapons.ContainsKey(weapon.ToLower()));
 }