Пример #1
0
    void LoadWeaponIds()
    {
        WeaponScriptableObject obj = Resources.Load("WeaponScriptableObject") as WeaponScriptableObject;

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

        for (int i = 0; i < obj.weapons.Count; i++)
        {
            if (weaponIds.ContainsKey(obj.weapons[i].item_id))
            {
                Debug.Log(obj.weapons[i].item_id + " item is a duplicate");
            }
            else
            {
                weaponIds.Add(obj.weapons[i].item_id, i);
            }
        }

        for (int i = 0; i < obj.weaponStats.Count; i++)
        {
            if (weaponStatsIds.ContainsKey(obj.weaponStats[i].weaponId))
            {
                Debug.Log(obj.weaponStats[i].weaponId + " item is a duplicate");
            }
            else
            {
                weaponStatsIds.Add(obj.weaponStats[i].weaponId, i);
            }
        }
    }
Пример #2
0
        /// <summary>
        /// Метод обработки попадения пули
        /// </summary>
        /// <param name="weaponDesc">Описание оружия, которым нанесли урон</param>
        private void Harm(WeaponScriptableObject weaponDesc)
        {
            CurrentHealth = _currentHealth - weaponDesc.Damage * _enemyDescription.Defence;

            //Гасим действующие силы
            _rigidBody.velocity        = Vector3.zero;
            _rigidBody.angularVelocity = Vector3.zero;
        }
Пример #3
0
        public Weapon GetWeapon(string id)
        {
            WeaponScriptableObject obj = Resources.Load("Gazzotto.Inventory.WeaponScriptableObject") as WeaponScriptableObject;

            int index = GetItemIDFromString(id);

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

            return(obj.weapons_all[index]);
        }
Пример #4
0
        static void MakeXMLFromWeaponItems()
        {
            WeaponScriptableObject obj = Resources.Load("SS.WeaponScriptableObject") as WeaponScriptableObject;

            if (obj == null)
            {
                Debug.Log("No WeaponScriptableObject found! Aborting operation");
                return;
            }

            string xml = "<?xml version = \"1.0\" encoding = \"UTF-8\" ?>";

            xml += "\b";
            xml += "<root>";

            foreach (Weapon w in obj.weaponsAll)
            {
                xml += "<weapon>" + "\n";

                xml += "<itemName>" + w.itemName + "</itemName>" + "\n";
                xml += "<itemDescription>" + w.itemDescription + "</itemDescription>" + "\n";
                xml += "<oh_idle>" + w.oh_idle + "</oh_idle>" + "\n";
                xml += "<th_idle>" + w.th_idle + "</th_idle>" + "\n";

                xml += ActionListToString(w.actions, "actions");
                xml += ActionListToString(w.two_handedActions, "two_handed");

                xml += "<parryMultiplier>" + w.parryMultiplier + "</parryMultiplier>" + "\n";
                xml += "<backstabMultiplier>" + w.backstabMultiplier + "</backstabMultiplier>" + "\n";
                xml += "<LeftHandMirror>" + w.leftHandMirror + "</LeftHandMirror>" + "\n";

                xml += VectorToXml(w.r_model_pos, "rmp");
                xml += VectorToXml(w.r_model_eulers, "rme");
                xml += VectorToXml(w.l_model_pos, "lmp");
                xml += VectorToXml(w.l_model_eulers, "lme");
                xml += VectorToXml(w.model_scale, "ms");

                xml += "</weapon>" + "\n";
            }

            xml += "</root>";

            string path = StaticStrings.SaveLocation() + StaticStrings.itemFolder;

            path += "weapons_database.xml";

            File.WriteAllText(path, xml);
            Debug.Log("weapons_database.xml created!");
        }
Пример #5
0
        private void Update()
        {
            if (!saveWeapon)
            {
                return;
            }
            saveWeapon = false;

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

            WeaponScriptableObject obj = Resources.Load("Gazzotto.Inventory.WeaponScriptableObject") as WeaponScriptableObject;

            if (obj == null)
            {
                return;
            }

            for (int i = 0; i < obj.weapons_all.Count; i++)
            {
                if (obj.weapons_all[i].itemName.Equals(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;
                    print("Successfully saved " + ((leftHand) ? "left hand" : "right hand") + " weapon position.");
                    return;
                }
            }

            Debug.Log(weaponId + " was not found in inventory.");
        }
Пример #6
0
        void LoadIds()
        {
            WeaponScriptableObject obj = Resources.Load("Gazzotto.Inventory.WeaponScriptableObject") as WeaponScriptableObject;

            for (int i = 0; i < obj.weapons_all.Count; i++)
            {
                if (item_ids.ContainsKey(obj.weapons_all[i].itemName))
                {
                    Debug.LogWarning("Item is already in the dictionary!");
                }
                else
                {
                    item_ids.Add(obj.weapons_all[i].itemName, i);
                }
            }
        }
Пример #7
0
    //Weapons

    public Weapon GetWeapon(string id)
    {
        WeaponScriptableObject obj = Resources.Load("WeaponScriptableObject") as WeaponScriptableObject;

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

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

        return(obj.weapons[index]);
    }
Пример #8
0
        void SaveWeapon()
        {
            if (itemModel == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(itemId))
            {
                return;
            }


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

            if (obj == null)
            {
                return;
            }

            for (int i = 0; i < obj.weapons.Count; i++)
            {
                if (obj.weapons[i].item_id == itemId)
                {
                    Weapon w = obj.weapons[i];
                    if (leftHand)
                    {
                        w.l_model_eulers = itemModel.transform.localEulerAngles;
                        w.l_model_pos    = itemModel.transform.localPosition;
                    }
                    else
                    {
                        w.r_model_eulers = itemModel.transform.localEulerAngles;
                        w.r_model_pos    = itemModel.transform.localPosition;
                    }

                    w.model_scale = itemModel.transform.localScale;

                    return;
                }
            }

            Debug.Log(itemId + " wasn't found in inventory.");
        }
Пример #9
0
        public static void LoadWeaponData()
        {
            string filePath = StaticStrings.SaveLocation() + StaticStrings.itemFolder;

            filePath += "weapons_database.xml";

            if (!File.Exists(filePath))
            {
                Debug.Log("weapons_database.xml doesnt exist! Aborting.");
                return;
            }

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

            if (obj == null)
            {
                Debug.Log("WeaponScriptableObject doesn't exist! Aborting.");
                return;
            }


            XmlDocument doc = new XmlDocument();

            doc.Load(filePath);

            foreach (XmlNode w in doc.DocumentElement.SelectNodes("//weapon"))
            {
                Weapon _w = new Weapon();
                _w.actions           = new List <Action>();
                _w.two_handedActions = new List <Action>();

                XmlNode itemName = w.SelectSingleNode("itemName");
                _w.itemName = itemName.InnerText;

                XmlNode itemDescription = w.SelectSingleNode("itemDescription");
                _w.itemDescription = itemDescription.InnerText;

                XmlNode oh_idle = w.SelectSingleNode("oh_idle");
                _w.oh_idle = oh_idle.InnerText;
                XmlNode th_idle = w.SelectSingleNode("th_idle");
                _w.th_idle = th_idle.InnerText;

                XmlNode parryMultiplier = w.SelectSingleNode("parryMultiplier");
                float.TryParse(parryMultiplier.InnerText, out _w.parryMultiplier);
                XmlNode backstabMultiplier = w.SelectSingleNode("backstabMultiplier");
                float.TryParse(backstabMultiplier.InnerText, out _w.backstabMultiplier);

                XmlToActions(doc, "actions", ref _w);
                XmlToActions(doc, "two_handed", ref _w);

                XmlNode LeftHandMirror = w.SelectSingleNode("LeftHandMirror");
                _w.leftHandMirror = (LeftHandMirror.InnerText == "True");

                _w.r_model_pos    = XmlToVector(w, "rmp");
                _w.r_model_eulers = XmlToVector(w, "rme");
                _w.l_model_pos    = XmlToVector(w, "lmp");
                _w.l_model_eulers = XmlToVector(w, "lme");
                _w.model_scale    = XmlToVector(w, "ms");

                obj.weaponsAll.Add(_w);
            }
        }
Пример #10
0
 public void SwapWeapon(WeaponScriptableObject weapon)
 {
     Destroy(item.transform.GetChild(0).gameObject);
     currentWeapon = weapon;
 }