コード例 #1
0
        public Weapon GetWeapon(string id)
        {
            WeaponScriptableObject obj = Resources.Load("SS.WeaponScriptableObject") as WeaponScriptableObject;

            if (obj == null)
            {
                Debug.Log("WeaponScriptableObject could not be loaded.");
                return(null);
            }
            int index = GetWeaponIdFromString(id);

            if (index == -1)
            {
                return(null);
            }
            return(obj.weaponsAll[index]);
        }
コード例 #2
0
        void Update()
        {
            if (!saveWeapon)
            {
                return;
            }

            saveWeapon = false;

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

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

            if (obj == null)
            {
                return;
            }
            for (int i = 0; i < obj.weaponsAll.Count; i++)
            {
                if (obj.weaponsAll[i].itemName == weaponID)
                {
                    Weapon w = obj.weaponsAll[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 in inventory");
        }
コード例 #3
0
        void LoadWeaponIds()
        {
            WeaponScriptableObject obj = Resources.Load("SS.WeaponScriptableObject") as WeaponScriptableObject;

            if (obj == null)
            {
                Debug.Log("WeaponScriptableObject could not be loaded.");
                return;
            }
            for (int i = 0; i < obj.weaponsAll.Count; i++)
            {
                if (weaponIds.ContainsKey(obj.weaponsAll[i].itemName))
                {
                    Debug.Log(obj.weaponsAll[i].itemName + " item is a duplicate.");
                }
                else
                {
                    weaponIds.Add(obj.weaponsAll[i].itemName, i);
                }
            }
        }