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

public enum ImpactEffect
{
    GoalReached,
    Catastrophic,
    BrokenAxle,
    SlipperyControl,
    WindshieldDamage
};

public class Obstruction : MonoBehaviour
{

    public bool isPersistent;
    public bool moveOnCollision; // Todo this could be an interface bhavior to stay, put, fly away, etc.
    public ImpactEffect impactEffect;

    void OnTriggerEnter2D(Collider2D collider)
    {
        //Debug.Log("Obstacale trigger -- " + gameObject.name);
        //Debug.Log(" Collider: " + collider.gameObject.name + "(" + collider.gameObject.tag + ")");

        if (collider.gameObject.tag == "DeactivationZone")
        {
            //Debug.Log("Checking Deactivation -- " + isPersistent.ToString());
            if (!isPersistent)
            {
                //Debug.Log("DeactivationZone....destroy");
                Destroy(gameObject);
            }
            
        }
    }

    public void HitByCar(Vector2 hitForce)
    {
        //Debug.Log("Hit By Car -- " + gameObject.name);
        if( moveOnCollision )
        {
            //Debug.Log("Trying to move obstacle with force: " + hitForce.ToString());
            //gameObject.transform.parent = null;
            //GetComponent<Rigidbody2D>().AddForce(hitForce);
        }
    }

}
