Exemplo n.º 1
0
        public void SaveWeapon()
        {
            if (targetModel == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(itemID))
            {
                return;
            }

            WeaponScriptableObject weaponObj = Resources.Load(StaticStrings.WeaponScriptableObject_FileName) as WeaponScriptableObject;

            if (weaponObj == null)
            {
                return;
            }

            for (int i = 0; i < weaponObj.weaponsAll.Count; i++)
            {
                //Check weapon id
                if (weaponObj.weaponsAll[i].item_id == itemID)
                {
                    Weapon w = weaponObj.weaponsAll[i];

                    //Save either left or right hand weapon transforms
                    if (leftHand)
                    {
                        w.left_model_eulerRot = targetModel.transform.localEulerAngles;
                        w.left_model_pos      = targetModel.transform.localPosition;
                        w.left_model_scale    = targetModel.transform.localScale;
                    }
                    else
                    {
                        w.right_model_eulerRot = targetModel.transform.localEulerAngles;
                        w.right_model_pos      = targetModel.transform.localPosition;
                        w.right_model_scale    = targetModel.transform.localScale;
                    }
                    return;
                }
            }
        }
        public WeaponStats GetWeaponStats(string weaponID)
        {
            WeaponScriptableObject weaponObj = Resources.Load(StaticStrings.WeaponScriptableObject_FileName) as WeaponScriptableObject;

            if (weaponObj == null)
            {
                Debug.Log(StaticStrings.WeaponScriptableObject_FileName + "cant be laoded");
                return(null);
            }

            int index = GetIndexFromString(weaponStat_IDs, weaponID);

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

            return(weaponObj.weaponStats[index]);
        }
        void LoadWeaponIDs()
        {
            WeaponScriptableObject weaponObj = Resources.Load(StaticStrings.WeaponScriptableObject_FileName) as WeaponScriptableObject;

            if (weaponObj == null)
            {
                Debug.Log("Couldn't load weapon item from: " + StaticStrings.WeaponScriptableObject_FileName);
                return;
            }

            for (int i = 0; i < weaponObj.weaponsAll.Count; i++)
            {
                if (weapon_IDs.ContainsKey(weaponObj.weaponsAll[i].item_id))
                {
                    Debug.Log("Weapon Item already exists in the resource manager dictionary!");
                }
                else
                {
                    weapon_IDs.Add(weaponObj.weaponsAll[i].item_id, i);
                }
            }

            //Load weapon stats
            for (int i = 0; i < weaponObj.weaponStats.Count; i++)
            {
                if (weaponStat_IDs.ContainsKey(weaponObj.weaponStats[i].weaponID))
                {
                    Debug.Log("Weapon stat for " + weaponObj.weaponStats[i].weaponID + "  already exists in the resource manager dictionary!");
                }
                else
                {
                    //Debug.Log("Adding: " + weaponObj.weaponStats[i].weaponID + " @ index: " + i);
                    weaponStat_IDs.Add(weaponObj.weaponStats[i].weaponID, i);
                }
            }
        }