コード例 #1
0
    public void EquipWeapoon(Item itemToEquip)
    {
        if (EquipedWeapon != null)
        {
            UnequipWeapon();
        }

        EquipedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug),
                                                PlayerHand.transform.position, PlayerHand.transform.rotation);

        _equippedWeapon = EquipedWeapon.GetComponent <IWeapon>();

        if (EquipedWeapon.GetComponent <IProjectileWeapon>() != null)
        {
            EquipedWeapon.GetComponent <IProjectileWeapon>().ProjectileSpawn = _projectileSpawn;
        }

        EquipedWeapon.transform.SetParent(PlayerHand.transform);

        _equippedWeapon.Stats = itemToEquip.Stats;
        _currentlyEquipedItem = itemToEquip;
        _characterStats.AddStatBonus(itemToEquip.Stats);

        UIEventHandler.ItemEquiped(itemToEquip);
        UIEventHandler.StatsChanged();
    }