Exemple #1
0
    public void PlaceItemOnCharacterSlot(InventoryItemCard itemCard, CharacterItemSlot characterSlot)
    {
        Debug.Log("InventoryController.PlaceItemOnCharacterSlot() called, placing item " + itemCard.myItemData.Name +
                  " on character slot " + characterSlot.mySlotType.ToString());

        itemCard.transform.position   = characterSlot.transform.position;
        itemCard.transform.localScale = new Vector3(1, 1, 1);
        if (itemCard.myInventorySlot != null)
        {
            itemCard.myInventorySlot.occupied   = false;
            itemCard.myInventorySlot.myItemCard = null;
            itemCard.myInventorySlot            = null;
        }

        itemCard.equipted = true;
        itemCard.transform.SetParent(characterSlot.transform);
        characterSlot.myItem          = itemCard;
        itemCard.transform.localScale = new Vector3(1, 1, 1);

        // Weapon specific set up
        if (characterSlot.mySlotType == CharacterItemSlot.SlotType.MainHand)
        {
            characterSlot.myCharacterData.mainHandWeapon = itemCard.myItemData;
        }
        else if (characterSlot.mySlotType == CharacterItemSlot.SlotType.OffHand)
        {
            characterSlot.myCharacterData.offHandWeapon = itemCard.myItemData;
        }

        // Check for weapon slot changes, then update weapon related abilities
        if (itemCard.myItemData.itemType == ItemDataSO.ItemType.MeleeOneHand ||
            itemCard.myItemData.itemType == ItemDataSO.ItemType.MeleeTwoHand ||
            itemCard.myItemData.itemType == ItemDataSO.ItemType.RangedTwoHand ||
            itemCard.myItemData.itemType == ItemDataSO.ItemType.Shield)
        {
            UpdateCharacterAbilitiesFromWeapons(characterSlot.myCharacterData);
        }

        // apply item view to char data model
        CharacterModelController.ApplyItemDataAppearanceToModel(itemCard.myItemData, characterSlot.myCharacterData.myCharacterModel, characterSlot.mySlotType);
        // apply to char data model ON BUTTON
        CharacterModelController.ApplyItemDataAppearanceToModel(itemCard.myItemData, characterSlot.myCharacterData.myModelOnButton, characterSlot.mySlotType);

        itemCard.SetRayCastingState(true);
    }