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

public class Act_Door : ActivableObject {

	public float OpenDistance = 6.0f;
	float BaseHeight = 0.0f;
	public Transform Indicator;
	float Follow = 0.0f;

	void Start () {
		BaseHeight = transform.position.y;
	}

	public void Update() {
		Vector3 Pos = transform.position;
		Follow = Mathf.Clamp01(Follow + (IsOn ? 0.1f : -0.3f) * Time.deltaTime );
		Pos.y = BaseHeight + Follow * OpenDistance;
		transform.position = Pos;
	}

	public override void SetGauge(Switcher Obj, float Gauge) {
		float Flash = Gauge>0.9 ? Mathf.Clamp01( Mathf.Sin(Time.time * 30.0f) * 10.0f ) : 1.0f;
		//MainLight.intensity = MainLightBaseIntensity * Flash;
		if(Indicator) Indicator.gameObject.SetActive(Flash>0.5f);
	}

	public override void SetState(Switcher Obj, bool NewState) {
		base.SetState(Obj, NewState);
		if(Indicator) Indicator.gameObject.SetActive(NewState);
	}
}
