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

public class HostileShip : Ship {

    public GameObject playerShip;

	// Use this for initialization
	void Start () 
    {
        hullHealth = maxHullHealth;
        sailHealth = maxSailHealth;
        curSpeed = baseSpeed;
	}
	
	// Update is called once per frame
	void Update () 
    {
		
	}

    public override void DealDamage()
    {
        int hitRoll = UnityEngine.Random.Range(1, 100);
        // if hitRoll <= accuracy, target is hit.
        if (hitRoll <= baseAccuracy)
        {
            if (hitRoll % 2 == 0)
            {
                // even roll - hit sail
                playerShip.GetComponent<PlayerShip>().TakeDamage(CombatSceneManager.damageType.Sail, cannonDamage);
                Debug.Log("Enemy Hits Sail!");
            }
            else
            {
                // Odd roll - Hit hull
                playerShip.GetComponent<PlayerShip>().TakeDamage(CombatSceneManager.damageType.Hull, cannonDamage);
                Debug.Log("Enemy Hits Hull!");
            }
        }
    }

    //public void TakeDamage(CombatSceneManager.damageType dmgType, float damage)
    //{
    //    if (dmgType == CombatSceneManager.damageType.Hull)
    //    {
    //        hullHealth -= damage;
    //    }
    //    else if (dmgType == CombatSceneManager.damageType.Sail)
    //    {
    //        sailHealth -= damage;
    //        UpdateSpeed();
    //    }
    //    else
    //        Debug.Log("Unrecognised damage type: " + dmgType.ToString());
    //}

    //protected override void UpdateSpeed()
    //{
    //    float percentSailEfficiency = (sailHealth / maxSailHealth) * 100;
    //    Debug.Log("Sail health %: " + percentSailEfficiency);
    //    curSpeed = (baseSpeed / 100) * percentSailEfficiency;
    //    Debug.Log("New ships speed: " + curSpeed);
    //}



}
