Пример #1
0
    public void EquipItem(EquipmentItemSlot equipmentSlot, BaseItemSlot itemSlot, ItemTemplate equipmentToAccept)
    {
        if (equipmentSlot.slotEquipmentType == equipmentToAccept.GetItemType())
        {
            equipmentSlot.SlotItem = equipmentToAccept;
            equipmentSlot.SlotItemAmount++;

            itemSlot.SlotItem       = null;
            itemSlot.SlotItemAmount = 0;
        }
    }
Пример #2
0
        private void SetEquipItemTemplate(Inventory inventory, uint templateId, EquipmentItemSlot slot, byte grade)
        {
            Item item = null;

            if (templateId > 0)
            {
                item          = ItemManager.Instance.Create(templateId, 1, grade);
                item.SlotType = SlotType.Equipment;
                item.Slot     = (int)slot;
            }

            inventory.Equip[(int)slot] = item;
        }
Пример #3
0
        private void SetEquipItemTemplate(Npc npc, uint templateId, EquipmentItemSlot slot, byte grade = 0)
        {
            Item item = null;

            if (templateId > 0)
            {
                item          = ItemManager.Instance.Create(templateId, 1, grade, false);
                item.SlotType = SlotType.Equipment;
                item.Slot     = (int)slot;
            }

            npc.Equip[(int)slot] = item;
        }
Пример #4
0
    private void Start()
    {
        Instance = this;

        TextAsset data = Resources.Load("data/ItemData") as TextAsset;

        string[] lines = Regex.Split(data.text, "\r\n|\n\r|\n|\r");
        foreach (string line in lines)
        {
            if (line.StartsWith("#"))
            {
                continue;
            }
            string[] values = line.Split(';');
            if (values.Length < 20)
            {
                continue;
            }

            int itemId = int.Parse(values[0]);
            EquipmentItemSlot itemSlot     = (EquipmentItemSlot)Enum.Parse(typeof(EquipmentItemSlot), values[1]);
            ItemType          itemType     = (ItemType)Enum.Parse(typeof(ItemType), values[2]);
            string            name         = values[3];
            string            description  = values[4];
            string            recipeMale   = values[5];
            string            recipeFemale = values[6];
            int        prefabId            = int.Parse(values[7]);
            string[]   positionMaleSplit   = values[8].Split(',');
            Vector3    positionMale        = new Vector3(float.Parse(positionMaleSplit[0], CultureInfo.InvariantCulture), float.Parse(positionMaleSplit[1], CultureInfo.InvariantCulture), float.Parse(positionMaleSplit[2], CultureInfo.InvariantCulture));
            string[]   positionFemaleSplit = values[9].Split(',');
            Vector3    positionFemale      = new Vector3(float.Parse(positionFemaleSplit[0], CultureInfo.InvariantCulture), float.Parse(positionFemaleSplit[1], CultureInfo.InvariantCulture), float.Parse(positionFemaleSplit[2], CultureInfo.InvariantCulture));
            string[]   rotationMaleSplit   = values[10].Split(',');
            Quaternion rotationMale        = Quaternion.Euler(float.Parse(rotationMaleSplit[0], CultureInfo.InvariantCulture), float.Parse(rotationMaleSplit[1], CultureInfo.InvariantCulture), float.Parse(rotationMaleSplit[2], CultureInfo.InvariantCulture));
            string[]   rotationFemaleSplit = values[11].Split(',');
            Quaternion rotationFemale      = Quaternion.Euler(float.Parse(rotationFemaleSplit[0], CultureInfo.InvariantCulture), float.Parse(rotationFemaleSplit[1], CultureInfo.InvariantCulture), float.Parse(rotationFemaleSplit[2], CultureInfo.InvariantCulture));
            string[]   scaleMaleSplit      = values[12].Split(',');
            Vector3    scaleMale           = new Vector3(float.Parse(scaleMaleSplit[0], CultureInfo.InvariantCulture), float.Parse(scaleMaleSplit[1], CultureInfo.InvariantCulture), float.Parse(scaleMaleSplit[2], CultureInfo.InvariantCulture));
            string[]   scaleFemaleSplit    = values[13].Split(',');
            Vector3    scaleFemale         = new Vector3(float.Parse(scaleFemaleSplit[0], CultureInfo.InvariantCulture), float.Parse(scaleFemaleSplit[1], CultureInfo.InvariantCulture), float.Parse(scaleFemaleSplit[2], CultureInfo.InvariantCulture));
            bool       stackable           = bool.Parse(values[14]);
            bool       tradable            = bool.Parse(values[15]);
            int        stamina             = int.Parse(values[16]);
            int        strength            = int.Parse(values[17]);
            int        dexterity           = int.Parse(values[18]);
            int        intelect            = int.Parse(values[19]);
            ITEMS.Add(itemId, new ItemHolder(itemId, itemSlot, itemType, name, description, recipeMale, recipeFemale, prefabId, positionMale, positionFemale, rotationMale, rotationFemale, scaleMale, scaleFemale, stackable, tradable, stamina, strength, dexterity, intelect));

            Sprite icon = Resources.Load <Sprite>("ItemIcons/Equipment/" + recipeFemale.Replace("_Recipe", ""));
            itemDB.Add(itemId, new Item(itemId, itemSlot, itemType, name, description, icon, stackable, stamina, strength, dexterity, intelect));
        }
    }
Пример #5
0
 public Item(int itemId, EquipmentItemSlot itemSlot, ItemType itemType, string itemName, string description, Sprite icon, bool stackable, int stamina, int strength, int dexterity, int intelect)
 {
     this.itemId        = itemId;
     this.EquipmentType = itemSlot;
     this.ItemType      = itemType;
     this.ItemName      = itemName;
     this.Description   = description;
     this.Icon          = icon;
     this.Stackable     = stackable;
     this.Stamina       = stamina;
     this.Strength      = strength;
     this.Dexterity     = dexterity;
     this.Intelect      = intelect;
 }
Пример #6
0
        private void SetEquipItemTemplate(Inventory inventory, uint templateId, EquipmentItemSlot slot, byte grade)
        {
            Item item = null;

            if (templateId > 0)
            {
                item = ItemManager.Instance.Create(templateId, 1, grade);
                if (item != null) // в 3.0.3.0 для гномов для значений Hair в таблице нет значений, т.е. возывращается null
                {
                    item.SlotType = SlotType.Equipment;
                    item.Slot     = (int)slot;
                }
            }
            inventory.Equip[(int)slot] = item;
        }
Пример #7
0
 /// <summary>
 /// itemId: the item id.
 /// itemSlot: the ItemSlot enum value.
 /// itemType: the ItemType enum value.
 /// name: UI name information.
 /// description: UI description information.
 /// recipeMale: the recipe for male avatars.
 /// recipeFemale: the recipe for female avatars.
 /// prefabId: prefab for mounted item.
 /// positionMale: mounted item position for male avatars.
 /// positionFemale: mounted item position for female avatars.
 /// rotationMale: mounted item rotation for male avatars.
 /// rotationFemale: mounted item rotation for female avatars.
 /// scaleMale: mounted item scale for male avatars.
 /// scaleFemale: mounted item scale for female avatars.
 /// stackable: UI stackable information.
 /// tradable: UI tradable information.
 /// stamina: UI stamina information.
 /// strength: UI strength information.
 /// dexterity: UI dexterity information.
 /// intelect: UI intelect information.
 /// </summary>
 public ItemHolder(int itemId, EquipmentItemSlot itemSlot, ItemType itemType, string name, string description, string recipeMale, string recipeFemale, int prefabId, Vector3 positionMale, Vector3 positionFemale, Quaternion rotationMale, Quaternion rotationFemale, Vector3 scaleMale, Vector3 scaleFemale, bool stackable, bool tradable, int stamina, int strength, int dexterity, int intelect)
 {
     this.itemId         = itemId;
     this.itemSlot       = itemSlot;
     this.itemType       = itemType;
     this.name           = name;
     this.description    = description;
     this.recipeMale     = recipeMale;
     this.recipeFemale   = recipeFemale;
     this.prefabId       = prefabId;
     this.positionMale   = positionMale;
     this.positionFemale = positionFemale;
     this.rotationMale   = rotationMale;
     this.rotationFemale = rotationFemale;
     this.scaleMale      = scaleMale;
     this.scaleFemale    = scaleFemale;
     this.stackable      = stackable;
     this.tradable       = tradable;
     this.stamina        = stamina;
     this.strength       = strength;
     this.dexterity      = dexterity;
     this.intelect       = intelect;
 }
Пример #8
0
    public void UnEquipItem(DynamicCharacterAvatar avatar, EquipmentItemSlot itemSlot)
    {
        // UMAData must not be null, so wait until it is not.
        UMAData umaData = null;

        while (umaData == null)
        {
            umaData = avatar.gameObject.GetComponent <UMAData>();
        }

        switch (itemSlot)
        {
        case EquipmentItemSlot.HEAD:
            avatar.ClearSlot("Helmet");
            avatar.BuildCharacter();
            break;

        case EquipmentItemSlot.CHEST:
            avatar.ClearSlot("Chest");
            avatar.BuildCharacter();
            break;

        case EquipmentItemSlot.LEGS:
            avatar.ClearSlot("Legs");
            avatar.BuildCharacter();
            break;

        case EquipmentItemSlot.HANDS:
            avatar.ClearSlot("Hands");
            avatar.BuildCharacter();
            break;

        case EquipmentItemSlot.FEET:
            avatar.ClearSlot("Feet");
            avatar.BuildCharacter();
            break;

        case EquipmentItemSlot.LEFT_HAND:
            // Find left hand bone.
            GameObject boneObjL = umaData.GetBoneGameObject("LeftHand");
            // If previous item exists remove it.
            Transform objTransformL = boneObjL.transform.Find("LeftHandItem");
            if (objTransformL != null)
            {
                Destroy(objTransformL.gameObject);
            }
            // Find right hand bone.
            GameObject boneObjLR = umaData.GetBoneGameObject("RightHand");
            // If previous two hand item exists remove it.
            Transform objTransformL2 = boneObjLR.transform.Find("TwoHandItem");
            if (objTransformL2 != null)
            {
                Destroy(objTransformL2.gameObject);
            }
            break;

        case EquipmentItemSlot.RIGHT_HAND:
            // Find right hand bone.
            GameObject boneObjR = umaData.GetBoneGameObject("RightHand");
            // If previous item exists remove it.
            Transform objTransformR = boneObjR.transform.Find("RightHandItem");
            if (objTransformR != null)
            {
                Destroy(objTransformR.gameObject);
            }
            // If previous two hand item exists remove it.
            Transform objTransformR2 = boneObjR.transform.Find("TwoHandItem");
            if (objTransformR2 != null)
            {
                Destroy(objTransformR2.gameObject);
            }
            break;

        case EquipmentItemSlot.TWO_HAND:
            // Find left hand bone.
            GameObject boneObjTHL = umaData.GetBoneGameObject("LeftHand");
            // If previous left hand item exists remove it.
            Transform objTransformTH1 = boneObjTHL.transform.Find("LeftHandItem");
            if (objTransformTH1 != null)
            {
                Destroy(objTransformTH1.gameObject);
            }
            // Find right hand bone.
            GameObject boneObjTHR = umaData.GetBoneGameObject("RightHand");
            // If previous right hand item exists remove it.
            Transform objTransformTH2 = boneObjTHR.transform.Find("RightHandItem");
            if (objTransformTH2 != null)
            {
                Destroy(objTransformTH2.gameObject);
            }
            // If previous two hand item exists remove it.
            Transform objTransformTH3 = boneObjTHR.transform.Find("TwoHandItem");
            if (objTransformTH3 != null)
            {
                Destroy(objTransformTH3.gameObject);
            }
            break;
        }
    }