Пример #1
0
        public void SaveConsumable()
        {
            if (targetModel == null)
            {
                return;
            }

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

            ConsumablesScriptableObject consumableObj = Resources.Load(StaticStrings.ConsumableScriptableObject_FileName) as ConsumablesScriptableObject;

            if (consumableObj == null)
            {
                return;
            }

            for (int i = 0; i < consumableObj.consumables.Count; i++)
            {
                //Check weapon id
                if (consumableObj.consumables[i].item_id == itemID)
                {
                    Consumable w = consumableObj.consumables[i];

                    w.model_eulerRot = targetModel.transform.localEulerAngles;
                    w.model_pos      = targetModel.transform.localPosition;
                    w.model_scale    = targetModel.transform.localScale;
                    Debug.Log(w.item_id + " saved!");
                    return;
                }
            }
        }
        public Consumable GetConsumable(string consumableID)
        {
            ConsumablesScriptableObject obj = Resources.Load(StaticStrings.ConsumableScriptableObject_FileName) as ConsumablesScriptableObject;

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

            int index = GetIndexFromString(consumable_IDs, consumableID);

            if (index == -1)
            {
                Debug.Log("Cant find consumable: " + consumableID);
                return(null);
            }

            return(obj.consumables[index]);
        }
        void LoadConsumables()
        {
            ConsumablesScriptableObject obj = Resources.Load(StaticStrings.ConsumableScriptableObject_FileName) as ConsumablesScriptableObject;

            if (obj == null)
            {
                Debug.Log("Couldn't load spell item from: " + StaticStrings.ConsumableScriptableObject_FileName);
            }

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