Example #1
0
    public void EquipWeapon(Item itemToEquip)
    {
        if (equippedWeapon != null)
        {
            charStats.RemoveBonusStat(equippedWeapon.GetComponent <IWeapon>().Stats);
            Destroy(weaponHold.transform.GetChild(0).gameObject);
        }

        equippedWeapon = (GameObject)Instantiate(Resources.Load <GameObject>("Weapons/" + itemToEquip.ObjectSlug),
                                                 weaponHold.position, weaponHold.rotation);
        equippedWeapon.transform.parent = weaponHold;
        equippedWeapon.GetComponent <IWeapon>().Stats = itemToEquip.Stats;
        charStats.AddBonusStat(itemToEquip.Stats);
        Debug.Log("Char stats = " + charStats.stats[StatsList.Power].CalculatedStatValue());
        Debug.Log("Weapon stats = " + equippedWeapon.GetComponent <IWeapon>().Stats[StatsList.Power].CalculatedStatValue());
    }