using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateRed : MonoBehaviour
{
public GameObject Anchor;
public float speed;
public Vector3 Axis = new Vector3(0, 0, 1);
public bool onTile = false;
public bool hasclicked = false;
public Vector3 TileLocation;
public RotateBlue blue;
public maincontroller main;
public bool isActive = false;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (onTile == true && isActive == true)
{
if (Input.GetMouseButtonDown(0))
{
Debug.Log("Red");
Swap();
}
}
if (isActive == true && hasclicked == false)
{
this.transform.RotateAround(Anchor.transform.localPosition, Axis, Time.deltaTime * speed);
}
}
public void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("tile"))
{
onTile = true;
TileLocation = collision.transform.localPosition;
TileLocation.z = -1;
}
}
public void OnTriggerExit2D(Collider2D collision)
{
if (collision.CompareTag("tile"))
{
onTile = false;
collision.gameObject.tag = "Untagged";
}
}
public void Swap()
{
//hasclicked = true; //stops from moving
//isActive = false;
this.transform.position = TileLocation;
//move oposite colour
//blue.isActive = true;
//blue.hasclicked = false;
main.OnSwap();
}
}