using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bow : MonoBehaviour, IWeapon
{
//Define serialized game objects
[SerializeField] private WeaponInfo weaponInfo;
[SerializeField] private GameObject arrowPrefab;
[SerializeField] private Transform arrowSpawnPoint;
//Define attack animation
readonly int FIRE_HASH = Animator.StringToHash("Attack");
//Define animator for the bow attacking
private Animator myAnimator;
///
/// This method runs when the game is first awake and
/// it initializes the animator component.
///
private void Awake(){
myAnimator = GetComponent();
}
///
/// This method runs when the player uses the bow to attack and
/// it uses the attack animation and the arrow object to attack
/// with the bow.
///
public void Attack(){
//Call on Attack animation for the bow
myAnimator.SetTrigger(FIRE_HASH);
//Get the arrow object from unity
GameObject newArrow = Instantiate(arrowPrefab, arrowSpawnPoint.position, ActiveWeapon.Instance.transform.rotation);
//Define new projectile object (the arrow)
newArrow.GetComponent().UpdateProjectileRange(weaponInfo.weaponRange);
}
///
/// This method simply returns the information of the current weapon
/// for the player.
///
///
public WeaponInfo GetWeaponInfo(){
return weaponInfo;
}
}