public void EquipBoots(ItemClass item)
    {
        // If a shield is held
        if (wornBoots != null)
        {   // Add current offhand to inventory
            InventoryManager.instance.AddItemToInventory(currentEquippedBoots.itemSlug);
            // Remove offhand stats from player stats
            combatantStats.RemoveStatBoost(wornBoots.GetComponent <IBoots>().Stats);
            // Destroy offhand being held
            Destroy(feet.transform.GetChild(0).gameObject); // Destroys first child of mainHand, which would be offhand held
        }
        // Equip new offhand
        wornBoots = (GameObject)Instantiate(Resources.Load <GameObject>("Items/Boots/" + item.itemSlug), feet.transform.position, feet.transform.rotation); // Finds prefab in resources folder with the same item slug and instantiates it on the main hand

        // Get offhand interface from the held offhand
        equippedBoots = wornBoots.GetComponent <IBoots>();

        // Set new offhand stats
        equippedBoots.Stats = item.stats;
        // Set offhand position to mainhand
        wornBoots.transform.SetParent(feet.transform);
        // Set stats for equipped offhand
        equippedBoots.Stats = item.stats;
        // Set current offhand to new offhand
        currentEquippedBoots = item;
        // Add offhand stats to player
        combatantStats.AddStatBoost(item.stats);
        // Pass item being equipped to UIManager
        UIManager.FeetWorn(item);
        UIManager.StatsChanged();
    }
コード例 #2
0
    public void EquipWeapon(ItemClass item)
    {
        // If a weapon is held
        if (heldWeapon != null)
        {
            RemoveWeapon();
        }
        // Equip new weapon
        heldWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Items/Weapons/" + item.itemSlug), mainHand.transform.position, mainHand.transform.rotation); // Finds prefab in resources folder with the same item slug and instantiates it on the main hand


        // Get weapon interface from the held weapon
        equippedWeapon = heldWeapon.GetComponent <IWeapon>();


        // If the weapon has a projectile interface component
        if (heldWeapon.GetComponent <IProjectiles>() != null)
        {
            // Get Iprojectile component from held weapon and set the spawn position to the player spawn position
            heldWeapon.GetComponent <IProjectiles>().ProjectileSpawnPosition = projectileSpawnPosition;
        }

        // Set new weapon stats
        equippedWeapon.Stats = item.stats;
        // Set weapon position to mainhand
        heldWeapon.transform.SetParent(mainHand.transform);
        // Set stats for equipped weapon
        equippedWeapon.Stats = item.stats;
        // Set current weapon to new weapon
        currentHeldItem = item;
        // Add weapon stats to player
        combatantStats.AddStatBoost(item.stats);
        // Pass item being equipped to UIManager
        UIManager.WeaponEquipped(item);
        UIManager.StatsChanged();

        Debug.Log(equippedWeapon.Stats[0]);
    }