using UnityEngine;
using System.Collections;
public class PlayerWeaponController : MonoBehaviour
{
public GameObject playerHand;
public GameObject EquippedWeapon { get; set; }
IWeapon equippedWeapon;
CharacterStats characterStats;
void Start()
{
characterStats = GetComponent();
}
public void EquipWeapon(Item itemToEquip)
{
if (EquippedWeapon != null)
{
characterStats.RemoveStatBonus(EquippedWeapon.GetComponent().Stats);
Destroy(playerHand.transform.GetChild(0).gameObject);
}
EquippedWeapon = (GameObject)Instantiate(Resources.Load("Weapon/" + itemToEquip.ObjectSlug),
playerHand.Transform.position, playerHand.transform.rotation);
equippedWeapon = EquippedWeapon.GetComponent();
equippedWeapon.Stats = itemToEquip.Stats;
EquippedWeapon.transform.SetParent(playerHand.transform);
characterStats.AddStatBonus(itemToEquip.Stats);
}
public void PerformWeaponAttack()
{
equippedWeapon.PerformAttack();
}
}
↧