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

public class PassMouseClick : MonoBehaviour {
    public void OnMouseDown()
    {
        var tileTransform = transform.parent;
        var worldTransform = tileTransform.parent;
        var tile = tileTransform.GetComponent<Tile>();
        if (tile != null) tile.OnClick();
        var mdaa = worldTransform.GetComponent<MouseDragAndAttach>();
        if (mdaa != null) mdaa.OnTileClick();
    }

    public void OnMouseOver()
    {
        if (Input.GetMouseButton(1)) {
            var tileTransform = transform.parent;
            var worldTransform = tileTransform.parent;
            var tile = tileTransform.GetComponent<Tile>();
            if (tile != null) tile.OnClick();
        }
    }

    public void OnMouseUp()
    {
        var tileTransform = transform.parent;
        var worldTransform = tileTransform.parent;
        var mdaa = worldTransform.GetComponent<MouseDragAndAttach>();
        if (mdaa != null) mdaa.onTileRelease();
    }
}
