using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

public class LinkedClock : Clock
{
    public Clock otherclock;
    
   
    public override void OnCollisionStaychild(Collision collision)
    {
        base.OnCollisionStaychild(collision);
        //Debug.Log("hit!");
        //if(collision.transform.parent.name != "AnObject(Clone)")
        //    Debug.Log(collision.gameObject.name + " wow!");
        if (collision.transform.parent != null)
        {
            var x = collision.transform.parent.gameObject.GetComponent(typeof(Clock)) as Clock;
            if (x != null && x.Equals(otherclock))
            {
                Debug.Log("hit!");
                if (Mathf.Abs((float)(otherclock.GetTime() - time)) <= 2.0f)
                {
                    levelManager.WinState = true;
                }
                else
                {
                    Debug.Log(Mathf.Abs((float)(otherclock.GetTime() - time)));
                }
            }
        }

    }
}


