using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateBlue : 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 RotateRed red;
public maincontroller main;
public bool isActive = true;
// 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("Blue");
Swap();
}
}
if (isActive == true && hasclicked == false)
{
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;
main.OnSwap();
//move oposite colour
//red.isActive = true;
//.hasclicked = false;
}
}