Beispiel #1
0
    public override void GetItem(Item item)
    {
        // Sanity check.
        if (item == null)
        {
            return;
        }

        // Handle weapon items.
        ItemWeapon weapon = item as ItemWeapon; // Try to 'cast' Item to type 'ItemWeapon' (Returns null if can't cast)

        if (weapon != null)
        {
            // Add the weapon to this characters' inventory.
            this.inventory.AddItem(weapon);

            // If autoEquipWeapons set to true, then equip the weapon (eg make active)
            if (this.autoEquipWeapons == true)
            {
                this.inventory.MakeActiveItem(weapon);
                weapon.EquipWeapon();
            }
        }

        // Handle pickup items.
        ItemPickup pickup = item as ItemPickup; // Try to 'cast' Item to type 'ItemWeapon' (Returns null if can't cast)

        if (pickup != null)
        {
            // Don't handle here if activateOnTrigger is true (eg will handle itself)
            if (pickup.activateOnTrigger == false)
            {
                // Add the item to the character inventory.
                this.inventory.AddItem(pickup);
            }
        }
    }