Here’s the code:
public Color[] color;
public int puyoColor = 4;
public bool pieceRotate = true;
public bool pieceFall = false;
public PuyoScript puyoScript;
public GameObject puyoSpawn;
public SpawnPuyoScript spawnPuyoScript;
int colorCount = 1;
List<int> colors = new List<int>();
public GameObject puyo1;
void Start()
{
if (puyoColor == 3)
this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 3)];
if (puyoColor == 4)
this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 4)];
if (puyoColor == 5)
this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 5)];
}
void Update()
{
if (pieceRotate == true)
if (Input.GetKeyDown(KeyCode.X))
{
transform.eulerAngles += new UnityEngine.Vector3(0, 0, 90);
}
if (pieceFall == true)
{
transform.position -= new UnityEngine.Vector3(0, 0.001f, 0);
}
if (pieceFall == false)
{
transform.position -= new UnityEngine.Vector3(0, 0, 0);
}
if (color[colors.Count] = 4)
{ Debug.Log("Springtime!"); }
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.layer == 2)
{
pieceRotate = false;
pieceFall = false;
}
if (other.gameObject.layer == 3)
{
pieceRotate = false;
pieceFall = false;
}
if (other.gameObject.layer == 4)
{
pieceRotate = false;
pieceFall = false;
}
if (other.gameObject.layer == 5)
{
pieceRotate = false;
pieceFall = false;
}
if (other.gameObject.layer == 6)
{
pieceRotate = false;
pieceFall = false;
}
if (other.gameObject.layer == 7)
{
pieceRotate = false;
pieceFall = false;
}
if (other.gameObject.layer != 2)
{
pieceRotate = true;
pieceFall = true;
puyoScript.Fall = false;
this.gameObject.tag = "Not Falling";
}
if (other.gameObject.layer != 3)
{
pieceRotate = true;
pieceFall = true;
puyoScript.Fall = false;
this.gameObject.tag = "Not Falling";
}
if (other.gameObject.layer != 7)
{
pieceRotate = true;
pieceFall = true;
puyoScript.Fall = false;
this.gameObject.tag = "Not Falling";
}
if (other.gameObject.tag == "Not Falling")
{
pieceFall = true;
Debug.Log("Yes");
}
if (this.gameObject.tag == "Puyo 1")
{
pieceFall = true;
}
if (this.gameObject.tag == "Puyo 2")
{
pieceFall = true;
}
if (this.gameObject.tag == "Not Falling")
{
pieceFall = false;
}
}