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

public enum WeaponType {
    Kinetic = 0,
    Laser = 1,
    Missile = 2
}

[System.Serializable]
public class WeaponPrototype {
    [SerializeField] string name = "weapon name";
    [SerializeField] WeaponType type  = WeaponType.Kinetic;
    [SerializeField] int damage = 10;
    [SerializeField] int energy = 1;

    public bool IsCanFire(ShipPrototype owner) {
        return (owner.energy >= energy);
    }

    public void Fire(ShipPrototype owner, ShipPrototype enemy) {
        if (IsCanFire(owner)) {
            owner.energy -= energy;
            enemy.Hit(type, damage);
        } else {
            TextEffects.Show(owner.transform.position, "No energy!", Color.yellow);
            // Debug.LogWarning("Not enought energy for " + name);
        }
        owner.UpdateParams();
        enemy.UpdateParams();
    }

    public WeaponPrototype(WeaponType weaponType, string weaponName, int weaponDamage, int energyCost = 1) {
        type = weaponType;
        name = weaponName;
        damage = weaponDamage;
        energy = energyCost;
    }
}
