using UnityEngine;
using System.Collections;

[CreateAssetMenu(fileName = "Weapon", menuName = "Weapons/Weapon: Thrown", order = 2)]
public class WeaponThrown : Weapon
{
    public float LaunchForce = 20.0f;
    public ProjectileAmmo Ammo;
    private float timestamp;
    private float cooldown = 0.5f;

    protected override void FireInternal(WeaponHolder owner)
    {
    	if (Time.time < timestamp) {
    		return;
    	}

    	timestamp = Time.time + cooldown;

        Rigidbody2D projectile = Instantiate<Rigidbody2D>(Ammo.Projectile, owner.throwTransform.position, Quaternion.identity);
        projectile.velocity = LaunchForce * owner.throwTransform.forward;

        Ammo.OnStart(owner, projectile.gameObject);

		AudioManager.Play(AudioManager.Sounds.WEAPON_THROWN_1);
    }
}