So, I have a c# script that, decides where the “player” goes if they roll, lets say, a 2. But the variable Index, that contains that number works perfect. Just, the if functions do not appear to be running. There are no errors or warnings, and I have used many Debug.Log statements to make sure that the index variable works. Here is my script:
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class rotation : MonoBehaviour
{
public int nextNumber;
public Text money1t;
public Text money2t;
public int seq;
public int p1m = 2500;
public int p2m = 2500;
public GameObject b1;
public GameObject b2;
public Text propName;
public GameObject proName;
public GameObject maa;
public Text mA;
public GameObject dice1;
public GameObject dice2;
public Transform d1;
public Transform d2;
public Transform d11;
public Transform d22;
public int d1v;
public int d2v;
public Text haha;
public GameObject hahago;
public Animator anim;
public int mi;
public string chanceCard;
public GameObject c1;
public GameObject c2;
public GameObject player;
public GameObject player2;
public GameObject pos1;
public GameObject pos2;
public GameObject pos3;
public GameObject pos4;
public GameObject pos4andahalf;
public GameObject pos5;
public GameObject pos6;
public GameObject pos7;
public GameObject pos8;
public GameObject pos9;
public GameObject pos10;
public GameObject pos11;
public GameObject pos12;
public GameObject pos13;
public GameObject pos14;
public GameObject pos15;
public GameObject pos16;
public GameObject pos17;
public GameObject pos18;
public GameObject pos19;
public GameObject pos20;
public GameObject pos21;
public GameObject pos22;
public GameObject pos23;
public GameObject pos24;
public GameObject pos25;
public GameObject pos26;
public GameObject pos27;
public GameObject pos28;
public GameObject pos29;
public GameObject pos30;
public GameObject pos31;
public GameObject pos32;
public GameObject pos33;
public GameObject pos34;
public GameObject pos35;
public GameObject pos36;
public GameObject pos37;
public GameObject pos38;
public GameObject pos39;
public bool b1q;
public bool b2q;
public bool lb1q;
public bool lb2q;
public bool lb3q;
public bool p1q;
public bool p2q;
public bool p3q;
public bool util1;
public bool util2;
public bool o1q;
public bool o2q;
public bool o3q;
public bool r1q;
public bool r2q;
public bool r3q;
public bool y1q;
public bool y2q;
public bool y3q;
public bool g1q;
public bool g2q;
public bool g3q;
public bool db1q;
public bool db2q;
private string p1props;
private string p2props;
public bool rail1;
public bool rail2;
public bool rail3;
public bool rail4;
//
//
public int b1qhouse = 1;
public int b2qhouse = 1;
public int lb1qhouse = 1;
public int lb2qhouse = 1;
public int lb3qhouse = 1;
public int o1qhouse = 1;
public int o2qhouse = 1;
public int o3qhouse = 1;
public int r1qhouse = 1;
public int r2qhouse = 1;
public int r3qhouse = 1;
public int db1qhouse = 1;
public int db2qhouse = 1;
//
//
private int index;
public bool player1;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.R))
{
if (player1 == true)
{
player1 = false;
}
else if (player1 == false)
{
player1 = true;
}
hahago.SetActive(false);
int r1 = Random.Range(1, 366);
int r2 = Random.Range(1, 366);
int r3 = Random.Range(1, 366);
int o1 = Random.Range(1, 366);
int o2 = Random.Range(1, 366);
int o3 = Random.Range(1, 366);
dice1.transform.rotation = new Quaternion(r1, r2, r3, 1);
dice2.transform.rotation = new Quaternion(o1, o2, o3, 1);
if (player1 == true)
{
dice1.transform.position = d1.position;
dice2.transform.position = d2.position;
player.tag = "Player";
player2.tag = "Untagged";
c2.SetActive(false);
c1.SetActive(true);
}
if (player1 == false)
{
dice1.transform.position = d11.position;
dice2.transform.position = d22.position;
player.tag = "Untagged";
player2.tag = "Player";
c1.SetActive(false);
c2.SetActive(true);
}
StartCoroutine(waiter());
}
}
void Start()
{
c2.SetActive(false);
hahago.SetActive(false);
index = 0;
b1.SetActive(false);
b2.SetActive(false);
proName.SetActive(false);
maa.SetActive(false);
p2m = 2500;
p1m = 2500;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
Debug.Log(p2m);
Debug.Log(p2m.ToString());
Debug.Log(money2t.text);
}
public void buy()
{
b1.SetActive(false);
b2.SetActive(false);
proName.SetActive(false);
maa.SetActive(false);
if (player1 == false)
{
if (seq == 1)
{
p2props += " brown1";
p2m -= 60;
b1q = false;
}
if (seq == 3)
{
p2props += " brown2";
p2m -= 60;
b2q = false;
}
if (seq == 4)
{
p2props += " rail1";
p2m -= 200;
rail1 = false;
}
if (seq == 5)
{
p2props += " rail1";
p2m -= 200;
rail1 = false;
}
if (seq == 6)
{
p2props += " teepe1";
lb1q = false;
p2m -= 100;
}
if (seq == 8)
{
p2props += " teepe2";
lb2q = false;
p2m -= 100;
}
if (seq == 9)
{
p2props += " teepe3";
lb3q = false;
p2m -= 120;
}
if (seq == 11)
{
p2props += " bomb1";
p1q = false;
p2m -= 140;
}
if (seq == 12)
p2props += " utility1";
p1q = false;
p2m -= 150;
util1 = false;
}
if (seq == 13)
{
p2props += " bomb2";
util1 = false;
p2m -= 140;
}
if (seq == 14)
{
p2props += " bomb3";
p2q = false;
p2m -= 160;
}
if (seq == 15)
{
p2props += " rail2";
rail1 = false;
p2m -= 200;
}
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
}
IEnumerator waiter()
{
b1.SetActive(false);
b2.SetActive(false);
Debug.Log(player1);
// -200 -130
mi = 0;
yield return new WaitForSeconds(3);
Debug.Log(dice1.transform.rotation.eulerAngles.x);
Debug.Log(dice1.transform.rotation.eulerAngles.z);
if (dice1.transform.rotation.eulerAngles.x <= 20 && dice1.transform.rotation.eulerAngles.x >= -20)
{
if (dice1.transform.rotation.eulerAngles.z <= 20 && dice1.transform.rotation.eulerAngles.z >= -20)
{
Debug.Log("2 working");
hahago.SetActive(true);
mi += 2;
}
if (dice1.transform.rotation.eulerAngles.z >= 230 && dice1.transform.rotation.eulerAngles.z <= 300)
{
Debug.Log("3 working");
hahago.SetActive(true);
mi += 3;
}
if (dice1.transform.rotation.eulerAngles.z >= 171 && dice1.transform.rotation.eulerAngles.z <= 365)
{
Debug.Log("5 working");
hahago.SetActive(true);
mi += 5;
}
if (dice1.transform.rotation.eulerAngles.z >= 55 && dice1.transform.rotation.eulerAngles.z <= 105)
{
Debug.Log("4 working");
hahago.SetActive(true);
mi += 4;
}
}
if (dice1.transform.rotation.eulerAngles.x >= 265 && dice1.transform.rotation.eulerAngles.x <= 285)
{
if (dice1.transform.rotation.eulerAngles.z >= 100 && dice1.transform.rotation.eulerAngles.z <= 230)
{
Debug.Log("1 working");
hahago.SetActive(true);
mi += 1;
}
}
if (dice1.transform.rotation.eulerAngles.x >= 65 && dice2.transform.rotation.eulerAngles.x <= 110)
{
Debug.Log("6 working");
hahago.SetActive(true);
mi += 6;
}
//
//
if (dice2.transform.rotation.eulerAngles.x >= 65 && dice2.transform.rotation.eulerAngles.x <= 110)
{
Debug.Log("6 working");
hahago.SetActive(true);
mi += 6;
}
if (dice2.transform.rotation.eulerAngles.x <= 20 && dice2.transform.rotation.eulerAngles.x >= -20)
{
if (dice2.transform.rotation.eulerAngles.z <= 20 && dice2.transform.rotation.eulerAngles.z >= -20)
{
Debug.Log("2 working");
hahago.SetActive(true);
mi += 2;
}
if (dice2.transform.rotation.eulerAngles.z >= 230 && dice2.transform.rotation.eulerAngles.z <= 300)
{
Debug.Log("3 working");
hahago.SetActive(true);
mi += 3;
}
if (dice2.transform.rotation.eulerAngles.z >= 171 && dice2.transform.rotation.eulerAngles.z <= 365)
{
Debug.Log("5 working");
hahago.SetActive(true);
mi += 5;
}
if (dice2.transform.rotation.eulerAngles.z >= 55 && dice2.transform.rotation.eulerAngles.z <= 105)
{
Debug.Log("4 working");
hahago.SetActive(true);
mi += 4;
}
}
if (dice2.transform.rotation.eulerAngles.x >= 265 && dice2.transform.rotation.eulerAngles.x <= 285)
{
if (dice2.transform.rotation.eulerAngles.z >= 100 && dice2.transform.rotation.eulerAngles.z <= 230)
{
Debug.Log("1 working");
hahago.SetActive(true);
mi += 1;
}
}
haha.text = mi.ToString();
anim.Play("shrink");
index += mi;
if (player1 == true)
{
if (index > 39)
{
index = index - 38;
}
if (index == 1)
{
player.transform.position = pos1.transform.position;
}
if (index == 2)
{
player.transform.position = pos2.transform.position;
}
if (index == 3)
{
player.transform.position = pos3.transform.position;
}
if (index == 4)
{
player.transform.position = pos4.transform.position;
}
if (index == 5)
{
player.transform.position = pos4andahalf.transform.position;
}
if (index == 6)
{
player.transform.position = pos5.transform.position;
}
if (index == 7)
{
player.transform.position = pos6.transform.position;
}
if (index == 8)
{
player.transform.position = pos7.transform.position;
}
if (index == 9)
{
player.transform.position = pos8.transform.position;
}
if (index == 10)
{
player.transform.position = pos9.transform.position;
}
if (index == 11)
{
player.transform.position = pos10.transform.position;
}
if (index == 12)
{
player.transform.position = pos11.transform.position;
}
if (index == 13)
{
player.transform.position = pos12.transform.position;
}
if (index == 14)
{
player.transform.position = pos13.transform.position;
}
if (index == 15)
{
player.transform.position = pos14.transform.position;
}
if (index == 16)
{
player.transform.position = pos15.transform.position;
}
if (index == 17)
{
player.transform.position = pos16.transform.position;
}
if (index == 18)
{
player.transform.position = pos17.transform.position;
}
if (index == 19)
{
player.transform.position = pos18.transform.position;
}
if (index == 20)
{
player.transform.position = pos19.transform.position;
}
if (index == 21)
{
player.transform.position = pos20.transform.position;
}
if (index == 22)
{
player.transform.position = pos21.transform.position;
}
if (index == 23)
{
player.transform.position = pos22.transform.position;
}
if (index == 24)
{
player.transform.position = pos23.transform.position;
}
if (index == 25)
{
player.transform.position = pos24.transform.position;
}
if (index == 26)
{
player.transform.position = pos25.transform.position;
}
if (index == 27)
{
player.transform.position = pos26.transform.position;
}
if (index == 28)
{
player.transform.position = pos27.transform.position;
}
if (index == 29)
{
player.transform.position = pos28.transform.position;
}
if (index == 30)
{
player.transform.position = pos29.transform.position;
}
if (index == 31)
{
player.transform.position = pos30.transform.position;
}
if (index == 32)
{
player.transform.position = pos31.transform.position;
}
if (index == 33)
{
player.transform.position = pos32.transform.position;
}
if (index == 34)
{
player.transform.position = pos33.transform.position;
}
if (index == 35)
{
player.transform.position = pos34.transform.position;
}
if (index == 36)
{
player.transform.position = pos35.transform.position;
}
if (index == 37)
{
player.transform.position = pos36.transform.position;
}
if (index == 38)
{
player.transform.position = pos38.transform.position;
}
if (index == 39)
{
player.transform.position = pos39.transform.position;
}
}
//
//
//
if (player1 != true)
{
int chanceNumber = Random.Range(1, 6);
if (chanceNumber == 0)
{
chanceCard = "Protest Matures. Recive 150$";
}
if (chanceNumber == 1)
{
chanceCard = "White Settlers invade. Lose 200$";
}
if (chanceNumber == 2)
{
chanceCard = "You have been elected as taxpayer. Pay $100 to the bank.";
}
if (chanceNumber == 3)
{
chanceCard = "Taxes. Pay $90";
}
if (chanceNumber == 4)
{
chanceCard = "You have won 1st place in a hunting contest. Collect $50";
}
if (chanceNumber == 5)
{
chanceCard = "You have been payed 500$ from an anonymous settler.";
}
if (chanceNumber == 6)
{
chanceCard = "It is your birthday! Collect 100$.";
}
Debug.Log(index);
Debug.Log(index);
Debug.Log(index);
if (index > 39)
{
index = index - 38;
}
if (index == 0)
{
if (b1q == false)
{
seq = 1;
b1.SetActive(true);
b2.SetActive(true);
propName.text = "Temporary property";
mA.text = "$60";
player2.transform.position = pos2.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
b2q = true;
}
else
{
p1m += 5 * b1qhouse * 2;
p2m -= 5 * b2qhouse * 2;
}
}
if (index == 1)
{
seq = 0;
player2.transform.position = pos1.transform.position;
}
if (index == 2)
{
if (b1q == true)
{
seq = 3;
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
propName.text = "Temporary property";
mA.text = "$60";
player2.transform.position = pos2.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
}
else
{
p1m += 5 * b1qhouse * 2;
p2m -= 5 * b2qhouse * 2;
}
}
if (index == 3)
{
proName.SetActive(true);
maa.SetActive(true);
seq = 2;
b1.SetActive(true);
b2.SetActive(true);
propName.text = chanceCard;
mA.text = "Chance";
player2.transform.position = pos3.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
if (chanceNumber == 0)
{
p2m += 150;
}
if (chanceNumber == 1)
{
p2m -= 200;
}
}
if (index == 4)
{
if (b2q == true)
{
proName.SetActive(true);
maa.SetActive(true);
seq = 3;
b1.SetActive(true);
b2.SetActive(true);
propName.text = "Temporary property";
mA.text = "$60";
player2.transform.position = pos4.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
}
else
{
p1m += 5 * b2qhouse * 2;
p2m -= 5 * b2qhouse * 2;
}
}
if (index == 5)
{
proName.SetActive(true);
maa.SetActive(true);
seq = 4;
b1.SetActive(true);
b2.SetActive(true);
propName.text = "Income Tax";
mA.text = "-200$";
player2.transform.position = pos4andahalf.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
}
if (index == 6)
{
proName.SetActive(true);
maa.SetActive(true);
seq = 5;
b1.SetActive(true);
b2.SetActive(true);
propName.text = "Hunting Ground";
mA.text = "$200";
player2.transform.position = pos5.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
}
if (index == 7)
{
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
seq = 6;
propName.text = "Teepe";
mA.text = "$100";
player2.transform.position = pos6.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
}
if (index == 8)
{
proName.SetActive(true);
maa.SetActive(true);
propName.text = chanceCard;
mA.text = "Chance...";
player2.transform.position = pos7.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
seq = 7;
}
if (index == 9)
{
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
seq = 8;
propName.text = "Teepe";
mA.text = "$100";
player2.transform.position = pos8.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
}
if (index == 10)
{
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
seq = 9;
propName.text = "Teepe";
mA.text = "$120";
player2.transform.position = pos9.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
}
if (index == 11)
{
player2.transform.position = pos10.transform.position;
}
if (index == 12)
{
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
seq = 11;
propName.text = "Bomb";
mA.text = "$140$";
player2.transform.position = pos9.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
player2.transform.position = pos11.transform.position;
}
if (index == 13)
{
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
seq = 12;
propName.text = "Builder?";
mA.text = "$150$";
player2.transform.position = pos9.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
player2.transform.position = pos12.transform.position;
}
if (index == 14)
{
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
seq = 13;
propName.text = "Bomb";
mA.text = "$140$";
player2.transform.position = pos9.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
player2.transform.position = pos13.transform.position;
}
if (index == 15)
{
if (p3q == true)
{
if (p1props.Contains("bomb3") == false)
{
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
seq = 14;
propName.text = "Bomb";
mA.text = "$140$";
player2.transform.position = pos9.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
player2.transform.position = pos14.transform.position;
}
}
if (p3q == false)
{
if (p1props.Contains("bomb3") == true)
{
p1m += 250;
p2m -= 250;
p3q = true;
}
else
{
}
}
if (index == 16)
{
if (rail1 == true)
{
proName.SetActive(true);
maa.SetActive(true);
b1.SetActive(true);
b2.SetActive(true);
seq = 15;
propName.text = "Railroad";
mA.text = "$200$";
player2.transform.position = pos9.transform.position;
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
player2.transform.position = pos15.transform.position;
}
if (rail1 == false)
{
if (p1props.Contains("rail2") == true)
{
p1m += 100;
p2m -= 100;
}
else
{
}
}
}
if (index == 17)
{
player2.transform.position = pos16.transform.position;
}
if (index == 18)
{
player2.transform.position = pos17.transform.position;
}
if (index == 19)
{
player2.transform.position = pos18.transform.position;
}
if (index == 20)
{
Debug.Log("running 20");
player2.transform.position = pos19.transform.position;
}
if (index == 21)
{
player2.transform.position = pos20.transform.position;
}
if (index == 22)
{
player2.transform.position = pos21.transform.position;
}
if (index == 23)
{
player2.transform.position = pos22.transform.position;
}
if (index == 24)
{
player2.transform.position = pos23.transform.position;
}
if (index == 25)
{
player2.transform.position = pos24.transform.position;
}
if (index == 26)
{
player2.transform.position = pos25.transform.position;
}
if (index == 27)
{
player2.transform.position = pos26.transform.position;
}
if (index == 28)
{
player2.transform.position = pos27.transform.position;
}
if (index == 29)
{
player2.transform.position = pos28.transform.position;
}
if (index == 30)
{
player2.transform.position = pos29.transform.position;
}
if (index == 31)
{
player2.transform.position = pos30.transform.position;
}
if (index == 32)
{
player2.transform.position = pos31.transform.position;
}
if (index == 33)
{
player2.transform.position = pos32.transform.position;
}
if (index == 34)
{
player2.transform.position = pos33.transform.position;
}
if (index == 35)
{
player2.transform.position = pos34.transform.position;
}
if (index == 36)
{
player2.transform.position = pos35.transform.position;
}
if (index == 37)
{
player2.transform.position = pos36.transform.position;
}
if (index == 38)
{
player2.transform.position = pos38.transform.position;
}
if (index == 39)
{
player2.transform.position = pos39.transform.position;
}
// Where the auctioning system starts...
//
//
//
//
//
//
//
//
}
money1t.text = p1m.ToString();
money2t.text = p2m.ToString();
//Rotate 40 deg
// 65 110
}
}
}