Example #1
0
        public Weapon GetWeapon(string id)
        {
            WeaponScriptableObject obj = Resources.Load("SA.WeaponScriptableObject") as WeaponScriptableObject;

            int index = GetItemIdFromString(id);

            if (index == -1)
            {
                return(null);
            }

            return(obj.weapons_all [index]);
        }
Example #2
0
        void LoadIds()
        {
            WeaponScriptableObject obj = Resources.Load("SA.WeaponScriptableObject") as WeaponScriptableObject;

            for (int i = 0; i < obj.weapons_all.Count; i++)
            {
                if (item_ids.ContainsKey(obj.weapons_all [i].itemName))
                {
                    Debug.Log("Item is a duplicate!");
                }
                else
                {
                    item_ids.Add(obj.weapons_all [i].itemName, i);
                }
            }
        }
        void Update()
        {
            if (!saveWeapon)
            {
                return;
            }

            saveWeapon = false;

            if (weaponModel == null || string.IsNullOrEmpty(weaponId))
            {
                return;
            }

            WeaponScriptableObject obj = Resources.Load("SA.WeaponScriptableObject") as WeaponScriptableObject;

            if (obj == null)
            {
                return;
            }

            for (int i = 0; i < obj.weapons_all.Count; i++)
            {
                if (obj.weapons_all [i].itemName == weaponId)
                {
                    Weapon w = obj.weapons_all [i];

                    if (leftHand)
                    {
                        w.l_model_eulers = weaponModel.transform.localEulerAngles;
                        w.l_model_pos    = weaponModel.transform.localPosition;
                    }
                    else
                    {
                        w.r_model_eulers = weaponModel.transform.localEulerAngles;
                        w.r_model_pos    = weaponModel.transform.localPosition;
                    }
                    w.model_scale = weaponModel.transform.localScale;

                    return;
                }
            }

            Debug.Log(weaponId + " wasn't found!");
        }