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

public class WaterZone : MonoBehaviour
{
	void OnTriggerEnter(Collider other){
		VignetteHandler _vignette = other.GetComponent<VignetteHandler>();
		
		if (_vignette)
			_vignette.SetWaterActive(true);
		
		Rigidbody _rb = other.GetComponent<Rigidbody>();
		
		if (_rb)
			_rb.drag += _rb.mass;
			
		PlayerBase _pb = other.GetComponent<PlayerBase>();
		
		if (_pb)
			_pb.AddSlow(0.5f);
	}
	
	void OnTriggerExit(Collider other){
		VignetteHandler _vignette = other.GetComponent<VignetteHandler>();
		
		if (_vignette)
			_vignette.SetWaterActive(false);
			
		Rigidbody _rb = other.GetComponent<Rigidbody>();
		
		if (_rb)
			_rb.drag -= _rb.mass;
			
		PlayerBase _pb = other.GetComponent<PlayerBase>();
		
		if (_pb)
			_pb.RemoveSlow(0.5f);
	}
}
