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

public class WaterTrigger : MonoBehaviour
{
    public Color waterColor = new Color(0.0f, 0.7f, 1.0f);
    public Vector3 triggerSize = new Vector3(10.0f, 2.0f, 10.0f);
    public Vector3 offset = new Vector3(0.0f, -2.0f, 0.0f);
    [HideInInspector]
    public float height;
    public bool canSwim = true;

    public void Start() {
        Vector3 pos = transform.position + offset;
        height = pos.y + triggerSize.y;
    }

    public bool Inside(Vector3 interactorPosition)
    {
        bool inside;
        Vector3 pos = transform.position + offset;
        if (canSwim &&
            interactorPosition.x > pos.x + (triggerSize.x * -1) &&
            interactorPosition.x < pos.x + triggerSize.x &&
            interactorPosition.y > pos.y + (triggerSize.y * -1) &&
            interactorPosition.y < pos.y + triggerSize.y &&
            interactorPosition.z > pos.z + (triggerSize.z * -1) &&
            interactorPosition.z < pos.z + triggerSize.z) {
            inside = true;
        }
        else {
            inside = false;
        }
        return inside;
    }

    void OnDrawGizmosSelected() {
        Gizmos.DrawWireCube(transform.position + offset, triggerSize * 2.0f);
    }
}
