using UnityEngine;
using System.Collections;

public class PressureButton : Switch
{
    private GameObject _collisionObject;

    private void Start()
    {
        _isActivatableOnKey = false;
    }

    private void OnTriggerEnter(Collider collider)
    {
        if(IsActivated)
            return;

        Vector3 normal = collider.gameObject.transform.position - transform.position;
        normal = normal.normalized;

        if (normal.y <= .65f)
            return;

        IsActivated = true;
        _collisionObject = collider.gameObject;
    }

    private void OnTriggerExit(Collider collider)
    {
        if (!IsActivated)
            return;

        if (_collisionObject.Equals(collider.gameObject))
            IsActivated = false;
    }
}
