So the idea is there are 3 arrays. xFlipObject, yFlipObject, and xyFlipObject. These objects mirror the parent the are assigned to in the inspector. How the function works, if the parent is clicked once, it flips horizontally, if double clicked, then it will flip vertically. So, if there is an object in the xFlipObject slot. Then when the parent is single clicked, the xFlipObjects will flip horizontally, but if the parent is double clicked the xFlipObjects will do nothing. Then for the yFlipObject, same principle. if the parent is double clicked, then the yFlipObjects will flip vertically, and if the parent is single clicked, the yFlipObjects will do nothing. But for the xyFlipObject, the will mirror bolth axis. So the will mirror on single click, and double click. What am I doing wrong? To me my logic seems correct. Here is the script.
using UnityEngine;
using System.Collections;
public class TransformTiles : MonoBehaviour
{
//First slot flips Horizontally.
//Second slot flips Vertically.
//Third slot flips bolth Horizontally and Vertically.
public GameObject[] xFlipObject;
public GameObject[] yFlipObject;
public GameObject[] xyFlipObject;
static float clickDelta = 0.35f; // Max between two click to be considered a double click
private bool click = false;
private float clickTime;
public int transformer;
void OnMouseDown()
{
if (click && Time.time <= (clickTime + clickDelta))
{
//Rotate Vertically.
click = false;
foreach (GameObject obj in yFlipObject)
{
if (obj != null)
{
obj.GetComponent<NumberMatch>().turnVertically();
}
}
foreach (GameObject obj in xyFlipObject)
{
if (obj != null)
{
obj.GetComponent<NumberMatch>().turnVertically();
}
}
}
else
{
//Rotate Horizontally.
click = true;
clickTime = Time.time;
foreach (GameObject obj in xFlipObject)
{
if (obj != null)
{
obj.GetComponent<NumberMatch>().turnHorizontally();
}
}
foreach (GameObject obj in xyFlipObject)
{
if (obj != null)
{
obj.GetComponent<NumberMatch>().turnHorizontally();
}
}
}
}
}