using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Projectile : MonoBehaviour {
    public Player Owner;
    public float Speed;
    public Vector3 Direction;
    public float Lifetime;
    private float timer;
    // Start is called before the first frame update
    void Start() {
        transform.right = Direction;
    }

    // Update is called once per frame
    void Update() {
        transform.position += Direction * Speed * Time.deltaTime;
        timer += Time.deltaTime;
        if (timer > Lifetime) {
            Destroy(gameObject);
        }
    }

    private void OnTriggerEnter2D(Collider2D collision) {
        if (collision.CompareTag("Monster")) {
            Owner.Money += 5; 
            Destroy(collision.gameObject);
            Destroy(gameObject);
        }
    }
}
