using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.Tilemaps;

public class AnimatedHazardFlickering : Hazard
{
    public float ShowingTime;
    public float HiddenTime;

    private Collider2D _collider;
    private float _startTime;
    private Renderer _renderer;

    private void Awake()
    {
        _startTime = Time.time;
        _collider = gameObject.GetComponent<Collider2D>();
        _renderer = GetComponentInChildren<Renderer>();
    }

    private void Update()
    {
        float fullCycle = ShowingTime + HiddenTime;

        if (Time.time % fullCycle > ShowingTime)
        {
            armed = true;
            _collider.enabled = true;
            _renderer.enabled = true;
        }
        else
        {
            armed = false;
            _collider.enabled = false;
            _renderer.enabled = false;
        }
    }
}
