예제 #1
0
    /*
     * Взять снаряжение из инвентаря,
     * заменить старое на новое (при совпадении slotIndex)
     */
    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipSlot; //получить числовое значение EquipmentSlot enum
        //снять выбр экипировку
        Equipment oldItem = Unequip(slotIndex);;

        //Переместить актуальный инвентарь на панель инвентаря, заменить на выбранный
        //чтот грохнуть решили

        /*if (currentEquipment[slotIndex] != null)
         * {
         *  oldItem = currentEquipment[slotIndex];
         *  inventory.Add(oldItem);
         * }*/

        /*if (onEquipmentChanged != null)
         * {*/
        onEquipmentChanged?.Invoke(newItem, oldItem);
        //}
        SetEquipmentBlendShapes(newItem, 100);                                         //Set body blendship to new item equipment

        currentEquipment[slotIndex] = newItem;                                         //set item in current active player equipment
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh); //получить меш из active player equipment

        newMesh.transform.parent = targetMesh.transform;

        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;
    }
예제 #2
0
    public void Equip(Equipment newEquipment)
    {
        int slotIndex = (int)newEquipment.equipSlot;

        Equipment oldEquipment = null;

        if (currentEquipment[slotIndex] != null)
        {
            Equipment oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
            currentEquipment[slotIndex] = null;
        }

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newEquipment, oldEquipment);
        }

        currentEquipment[slotIndex] = newEquipment;

        GameObject newMesh = Instantiate <GameObject>(newEquipment.gameObject);

        newMesh.transform.parent        = target.transform;
        newMesh.transform.localPosition = new Vector3(0, 0, 0);
    }
예제 #3
0
    public void EquipItem(Equipment newItem)
    {
        int       slotIndex = (int)newItem.equipmentType;
        Equipment oldItem   = null;

        if (equiped[slotIndex] == null) //Item Slot Empty
        {
            equiped[slotIndex] = newItem;
            inventory.RemoveFromInventory(newItem);
            if (onEquipmentChangedCallBack != null) //Callback for equipmentChange
            {
                onEquipmentChangedCallBack.Invoke(newItem, oldItem);
            }
        }
        else //Item Slot Ocupied
        {
            oldItem = equiped[slotIndex];
            inventory.RemoveFromInventory(newItem);
            if (inventory.AddToInventory(oldItem)) //What to do if not to heavy
            {
                equiped[slotIndex] = newItem;
                if (onEquipmentChangedCallBack != null) //Callback for equipmentChange
                {
                    onEquipmentChangedCallBack.Invoke(newItem, oldItem);
                }
            }
            else //What to do if to heavy
            {
                inventory.AddToInventory(newItem); //returns item to inventory
            }
        }
    }
예제 #4
0
    public void Equip(Equipment newEquip)
    {
        int slotIndex = (int)newEquip.slotEquipment;

        //Inventory kısmında tıklanan item ile mevcut kullandıgın itemin enum değeri aynı ise
        //tıkladığın item'i kullanmaya başlasın ve kullandığın itemi inventory'e atsın.
        Equipment oldItem = UnEquip(slotIndex);

        //if(currentEquipment[slotIndex] !=null)
        //{
        //    oldItem = currentEquipment[slotIndex];
        //    inventory.AddItem(oldItem);
        //}

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newEquip, oldItem);
        }
        currentEquipment[slotIndex] = newEquip;

        SetEquipmentBlendShapes(newEquip, 100);

        //Oluşturduğumuz SkinnedMeshRenderer nesnesine -> SkinnedMeshRenderer oluşturup bunun içerisine ise almış olduğumuz
        //equipment objesinin içerisinde yer alan mesh'i gönderiyoruz.
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newEquip.mesh);

        //newMesh objesini player objemizin child'ı yapıyoruz ki onla beraber hareket etsin.
        newMesh.transform.parent = targetMesh.transform;
        //Kemik sistemlerini eşitliyoruz.
        newMesh.bones    = targetMesh.bones;
        newMesh.rootBone = targetMesh.rootBone;

        currentMesh[slotIndex] = newMesh;
    }
    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipSlot;

        Equipment oldItem = Unequip(slotIndex);

        /*
         * // We use Unequip(), so we don't need following codes.
         * if(currentEquipment[slotIndex] != null)
         * {
         *     oldItem = currentEquipment[slotIndex];
         *     inventory.Add(oldItem);
         * }
         */

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        SetEquipmentBlendShapes(newItem, 100);

        currentEquipment[slotIndex] = newItem;

        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;
        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;
    }
예제 #6
0
    /// <summary>
    /// Equip a new item
    /// </summary>
    public void Equip(Equipment newItem)
    {
        Equipment oldItem = null;

        // Find out what slot the item fits in
        // and put it there.
        int slotIndex = (int)newItem.equipSlot;

        // If there was already an item in the slot
        // make sure to put it back in the inventory
        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
        }

        // An item has been equipped so we trigger the callback
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        currentEquipment[slotIndex] = newItem;
        Debug.Log(newItem.name + " equipped!");

        if (newItem.prefab)
        {
            AttachToMesh(newItem.prefab, slotIndex);
        }
    }
예제 #7
0
    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipmentSlot;

        Equipment oldItem = Unequip(slotIndex);


        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }
        SetEquipmentBlendShapes(newItem, 100);
        currentEquipment[slotIndex] = newItem;

        SkinnedMeshRenderer newMash = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        currentMeshes[slotIndex] = newMash;

        if (newItem != null && newItem.equipmentSlot == EquipmentSlot.Weapon)
        {
            newMash.rootBone = sword;
            SwordPlayer.SetActive(true);
        }
        else if (newItem != null && newItem.equipmentSlot == EquipmentSlot.Shield)
        {
            newMash.rootBone = shield;
            ShieldPlayer.SetActive(true);
        }
        else
        {
            newMash.transform.parent = targetMesh.transform;
            newMash.bones            = targetMesh.bones;
            newMash.rootBone         = targetMesh.rootBone;
        }
    }
예제 #8
0
    public void Equip(Equipment newItem)
    {
        CurrentInventoryUI.instance.AddItem(newItem);
        //gets at which index of newItem in the EqupmentEnum
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
        }

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }
        currentEquipment[slotIndex] = newItem;
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent     = targerMesh.transform;
        newMesh.bones                = targerMesh.GetComponentInParent <SkinnedMeshRenderer>().bones;
        newMesh.rootBone             = targerMesh.GetComponentInParent <SkinnedMeshRenderer>().rootBone;
        currentMeshes[slotIndex]     = newMesh;
        newMesh.transform.position   = targerMesh.transform.position;
        newMesh.transform.rotation   = targerMesh.transform.rotation;
        newMesh.transform.localScale = targerMesh.transform.localScale;
        //newMesh.transform.localScale = targerMesh.bounds.extents;
        //CurrentInventory'e ekle
    }
예제 #9
0
    public void Equip(Equipment newItem)
    {
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
        }

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        currentEquipment[slotIndex] = newItem;

        if (slotIndex == 0)
        {
            axe.GetComponent <Axe>().ChangeAxe(newItem);
        }
        else if (slotIndex == 1)
        {
            sword.GetComponent <Sword>().SwordChange(newItem);
        }
        else if (slotIndex == 2)
        {
            spell.GetComponent <Spell>().ChangeSpell(newItem);
        }
    }
예제 #10
0
    public void Equip(Equipment newItem)        //equip a new item
    {
        int slotIndex = (int)newItem.equipSlot; //find out whiech equipment slot our item fit in

        Equipment oldItem = Unequip(slotIndex);

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
        }
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }
        SetEquimpentBlendShapes(newItem, 100);
        currentEquipment[slotIndex] = newItem;

        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;

        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;
    }
예제 #11
0
        /// <summary>
        /// Handles the equip of an item
        /// </summary>
        /// <param name="newItem"></param>
        /// <param name="isInitial"></param>
        public void Equip(ArmorItem newItem, bool isInitial = false)
        {
            ArmorItem oldItem = null;


            if (newItem != null)
            {
                if (!isInitial)
                {
                    ArmorItem currentItem = currentEquipment.Where(item => item != null)?.FirstOrDefault(item => item.armor_Type == newItem.armor_Type);

                    if (currentItem != null)
                    {
                        oldItem = currentItem;
                        currentEquipment.Remove(currentItem);
                        inventory.Add(currentItem);
                    }
                }

                currentEquipment.Add(newItem);


                if (onEquipmentChanged != null)
                {
                    onEquipmentChanged.Invoke(newItem, oldItem);
                }
            }
        }
예제 #12
0
    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipSlot;

        Equipment oldItem = Unequip(slotIndex);

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }


        currentEquipment [slotIndex] = newItem;


        MeshRenderer newMesh = Instantiate <MeshRenderer> (newItem.mesh, new Vector3(0, 0, 0), Quaternion.identity);

        switch (slotIndex)            // 3 - Right hand slot, 4 - left hand slot
        {
        case 3:
            newMesh.transform.parent = rHand.transform;
            break;

        case 4:
            newMesh.transform.parent = lHand.transform;
            break;
        }
        e_slots [slotIndex].icon.sprite = newItem.icon;
        newMesh.transform.localPosition = new Vector3(0, 0, 0);
        newMesh.transform.localRotation = Quaternion.identity;
        currentMeshes [slotIndex]       = newMesh;
    }
예제 #13
0
    public void Equip(Equipment newItem)
    {
        // Find out what slot the item fits in
        // We can get index value from Enum(ie. Head =0 , Chest = 1...)
        int slotIndex = (int)newItem.equipSlot;

        Equipment oldItem = Unequip(slotIndex);


        // An item has been equiped, so we notify subcribers of change using callback
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }


        SetEquipmentBlendShapes(newItem, 90);

        currentEquipment[slotIndex] = newItem; // insert item into slot
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;
        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;

        currentMeshes[slotIndex] = newMesh;
    }
예제 #14
0
    // Equip a new item
    public void Equip(Equipment newItem)
    {
        //Find out what slot the item fits in
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = UnEquip(slotIndex);

        //An item has been equipped so we trigger the callback
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }
        currentEquipment[slotIndex] = newItem;

        //SetEquipmentBlendShapes(newItem, 1);
        //insert the item into the slot
        currentEquipment[slotIndex] = newItem;
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;

        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;

        //Todo Update player stats
    }
예제 #15
0
    //to equip new items
    public void Equip(Equipment newItem)
    {
        //enums are associated with an index
        int slotIndex = (int)newItem.equipSlot;


        //for adding the equipment back to inventory - unequip anything in the slot first adding it back to inventory
        Equipment oldItem = Unequip(slotIndex);


        //invoke the delegate qith the relevant variables
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        //insert item into the slot
        currentEquipment[slotIndex] = newItem;

        //instantiate the new mesh into the game world
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;

        //to get the new mesh to deform based on target bones
        newMesh.bones    = targetMesh.bones;
        newMesh.rootBone = targetMesh.rootBone;

        //insert the new mesh in our current mesh's array
        currentMeshes[slotIndex] = newMesh;
    }
예제 #16
0
    public void Equip(Equipment newEquip)
    {
        int       slotIndex = (int)newEquip.GetEquipSlot();
        Equipment oldEquip  = currentEquipment[slotIndex];

        if (oldEquip)
        {
            if (oldEquip.IsDefault)
            {
                Destroy(oldEquip);
            }
            else
            {
                oldEquip.IsEquipped = false;
                inventory.AddToPlayerInventory(oldEquip);
            }
        }
        currentEquipment[slotIndex] = newEquip;
        newEquip.IsEquipped         = true;

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newEquip, oldEquip);
        }

        if (!isLoading && !newEquip.IsDefault)
        {
            SaveEquipment();
        }
        // Debug.Log($"<color=green>{newEquip.GetName()}</color> equipped as <color=green>{newEquip.GetEquipSlot()}</color>");
    }
예제 #17
0
    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipmentSlot;

        Equipment oldItem = Unequip(slotIndex);


        /*niepotrzebne bo robi to unequip
         * if (currentEquipment[slotIndex] != null)
         * {
         *  oldItem = currentEquipment[slotIndex];
         *  inventory.Add(oldItem);
         * }
         *
         */
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        SetEquipmentBlendShapes(newItem, 100);

        currentEquipment[slotIndex] = newItem;
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;
        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;
    }
예제 #18
0
    public void Equip(Equipment newItem)
    {
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = Unequip(slotIndex);        // Take off item in slot

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }
        if ((int)newItem.equipSlot == 3)
        {
            equippedTool = newItem;
        }

        SetEquipmentBlendShapes(newItem, 100);          // This repairs body showing through armor in spots
        currentEquipment[slotIndex] = newItem;

        // Put the mesh for the armor onto the player
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;
        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;
    }
예제 #19
0
    //method for equipping items
    public void Equip(Equipment newItem)
    {
        //inserts item in array *placement matters*
        //hover over EquipmentSlot array to see where it corresponds
        int slotIndex = (int)newItem.equipSlot;


        //adds back previous item
        Equipment oldItem = Unequip(slotIndex);;


        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, null);
        }

        SetEquipmentBlendShapes(newItem, 100);

        //this corresponds your new item to the correct array
        currentEquipment[slotIndex] = newItem;

        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;

        //tells new mewsh how it should deform based on the bones of targetMesh
        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;
    }
예제 #20
0
    // Equip item
    public void Equip (Equipment newItem)
    {
        // Gets the index of the item in the list of Enums
        int slotIndex = (int) newItem.equipSlot;

        // Handles unequipping current item
        Equipment oldItem = Unequip(slotIndex);

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        // Set the blendshapes for the meshes on the player's equipped items
        this.SetEquipmentBlendShapes(newItem, 100);

        // Put the new item into the currentEquipment array
        currentEquipment[slotIndex] = newItem;

        // Add the new item mesh to the player
        SkinnedMeshRenderer newMesh = Instantiate<SkinnedMeshRenderer>(newItem.mesh);
        newMesh.transform.parent = targetMesh.transform;

        // Tell mesh how to deform to character body
        newMesh.bones = targetMesh.bones;
        newMesh.rootBone = targetMesh.rootBone;

        // Add the new mesh to the current mesh array
        meshes[slotIndex] = newMesh;
    }
예제 #21
0
    public void Equip(Equipment newItem)
    {
        int       slotIndex = (int)newItem.eqSlot;
        Equipment oldItem   = Unequip(slotIndex);

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
        }

        //Notify subscribers
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        SetEquipmentBlendShapes(newItem, 100);

        currentEquipment[slotIndex] = newItem;
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;

        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;
    }
예제 #22
0
    public void Equip(Equipment newItem)
    {
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            InventoryManager.instance.Add(oldItem);
        }

        Transform equipSlot = GameObject.Find("EquipmentParent").transform.GetChild(slotIndex);

        equipSlot.GetComponent <EquipmentUISlot>().Equip(newItem);
        currentEquipment[slotIndex] = newItem;

        if (newItem.refObject != null)
        {
            currentWeapon = Instantiate(newItem.refObject);

            if (newItem.equipSlot == EquipmentSlot.Weapon)
            {
                GameObject.Find("Player").GetComponent <PlayerShooting>().NewWeapon(newItem);
            }
        }

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke();
        }
    }
예제 #23
0
    //When icon is clicked in inventory, set new equipment to slot index
    //set blendshapes of new equip, instantiate new mesh, and set transform and bones to target's
    public void Equip(Equipment newItem)
    {
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = Unequip(slotIndex);

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }
        if ((int)newItem.equipSlot == 4)
        {
            weapons [newItem.weaponType].SetActive(true);
            anim.SetInteger("weaponType", newItem.weaponType);
        }
        else if ((int)newItem.equipSlot == 5)
        {
            shields [newItem.weaponType].SetActive(true);
            anim.SetInteger("shieldType", newItem.weaponType);
        }
        currentEquipment [slotIndex] = newItem;
        image[slotIndex].sprite      = currentEquipment[slotIndex].icon;

        armor  += newItem.armorModifier;
        damage += newItem.damageModifier;

        SetEquipmentBlendShapes(newItem, 100);
        if (newItem.mesh != null)
        {
            SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer> (newItem.mesh);
            newMesh.transform.parent  = targetMesh.transform;
            newMesh.bones             = targetMesh.bones;
            newMesh.rootBone          = targetMesh.rootBone;
            currentMeshes [slotIndex] = newMesh;
        }
    }
    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipmentSlot;

        Equipment oldItem = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            Inventory.instance.Add(oldItem);
            //PlayerStats.instance.skill -= oldItem.bonusCrim;
        }

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        if ((int)newItem.equipmentSlot == 0)
        {
            GameObject.Find("sw_equipped").GetComponent <Text>().text = "SMALL WEAPON: \n" + newItem.name;
        }
        if ((int)newItem.equipmentSlot == 1)
        {
            GameObject.Find("lw_equipped").GetComponent <Text>().text = "LARGE WEAPON: \n" + newItem.name;
        }
        currentEquipment[slotIndex] = newItem;
        //PlayerStats.instance.skill += newItem.bonusCrim;
    }
예제 #25
0
    public void Equip(Equipment newItem)
    {
        // Find out what slot the item fits in
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = Unequip(slotIndex);

        // An item has been equipped so we trigger the callback
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, null);
        }

        SetEquipmentBlendShapes(newItem, 200);

        // Insert the item into the slot
        currentEquipment[slotIndex] = newItem;
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        currentMeshes[slotIndex] = newMesh;

        if (newItem != null && newItem.equipSlot == EquipmentSlot.Weapon)
        {
            newMesh.rootBone = Sword;
        }
        else if (newItem != null && newItem.equipSlot == EquipmentSlot.Shield)
        {
            newMesh.rootBone = Shield;
        }
        else
        {
            newMesh.transform.parent = targetMesh.transform;
            newMesh.bones            = targetMesh.bones;
            newMesh.rootBone         = targetMesh.rootBone;
        }
    }
예제 #26
0
    //Equip Item
    public void Equip(Equipment newItem)
    {
        //Get the slot index of the item to equip
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = UnEquip(slotIndex);

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        //Set blendshape so body doesn't intersect with the armour
        SetEquipmentBlendShapes(newItem, 100);

        //Set slotIndex to newItem
        currentEquipment[slotIndex] = newItem;

        //Instantiate the new mesh
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        //Set the mesh's parent object (target: player body mesh)
        newMesh.transform.parent = targetMesh.transform;

        //Set newMesh to deform with the target mesh's bones
        newMesh.bones    = targetMesh.bones;
        newMesh.rootBone = targetMesh.rootBone;

        //Add new mesh to currentMeshes
        currentMeshes[slotIndex] = newMesh;
    }
    // Equip a new item

    public void Equip(Equipment newItem)
    {
        // Find out what slot the item fits in
        int slotIndex = (int)newItem.equipSlot;

        Equipment oldItem = Unequip(slotIndex);

        // An item has been equipped so we trigger the callback
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        // Insert the item into the slot
        currentEquipment[slotIndex] = newItem;
        AttachToMesh(newItem, slotIndex);

        inventory.items.Remove(newItem);

        //Updating equipmentUI
        equipmentUI.UpdateEquipment();

        if (inventory.onItemChangedCallback != null)
        {
            inventory.onItemChangedCallback.Invoke();
        }
    }
예제 #28
0
    public void Equip(Equipment newItem)
    {
        // Find out what slot the item fits in
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = Unequip(slotIndex);

        // If there was already an item in the slot
        // make sure to put it back in the inventory
        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
        }
        // An item has been equipped so we trigger the callback
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }
        SetEquipmentBlendShapes(newItem, 100);
        // Insert the item into the slot
        currentEquipment[slotIndex] = newItem;
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;
        newMesh.bones            = targetMesh.bones;
        newMesh.rootBone         = targetMesh.rootBone;
        currentMeshes[slotIndex] = newMesh;
    }
예제 #29
0
    public void Equip(Equipment newItem)
    {
        int       slotIndex = (int)newItem.equipSlot;
        Equipment oldItem   = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.AddItem(oldItem);
        }
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        currentEquipment[slotIndex] = newItem;
        SkinnedMeshRenderer newMesh = Instantiate <SkinnedMeshRenderer>(newItem.mesh);

        newMesh.transform.parent = targetMesh.transform;

        newMesh.bones    = targetMesh.bones;
        newMesh.rootBone = targetMesh.rootBone;

        currentMeshes[slotIndex] = newMesh;
    }
예제 #30
0
    public void Equip(Item newItem)
    {
        int slotIndex = (int)newItem.equipmentSlot;

        Item oldItem = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            Unequip(slotIndex);

            currentEquipment[slotIndex] = null;
        }

        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        currentEquipment[slotIndex] = newItem;

        if (newItem.equipmentSlot == EquipmentSlotTag.Weapon)
        {
            //TODO: Replace Find() call with something more performant
            GameObject.Find(newItem.name).GetComponent <Collider>().isTrigger = true;
        }
    }