- Home /
This script is not displaying scenes in unity properly. How would you fix it?
What I want to do is create variables which will be set to one when the buttons to which the scripts will be attached to will be set to one. And then when the integers are set to one it will check whether or not the integers are set to one. If both of the integers would be set to one then it would switch to the "WinScene" and if they would not be set to one then it would check whether the random integer is between 1 or 2. And then it would switch to the scene according to the random integer. Here is my issue: No matter the combination the scenes tend to switch to the win scene. Do I have to clear all the static variables or is there something else wrong with my script? Please help, Thank you.
using UnityEngine; using System.Collections;
public class KnightSwitch : MonoBehaviour {
private static int FMane = 0;
private static int BStallion = 0;
private static int OLance = 0;
private static int BLance = 0;
private static int LoseInt;
void Reset()
{
if (Application.loadedLevel == 18)
{
Debug.Log("Hello");
KnightSwitch.FMane = 0;
KnightSwitch.BStallion = 0;
KnightSwitch.OLance = 0;
KnightSwitch.BLance = 0;
}
}
void Awake()
{
KnightSwitch.LoseInt = (Random.Range(0, 3));
}
public void FieryMane()
{
KnightSwitch.FMane = 1;
}
public void BlackStallion()
{
KnightSwitch.BStallion = 1;
}
public void OrangeLance()
{
KnightSwitch.OLance = 1;
}
public void BlueLance()
{
KnightSwitch.BLance = 1;
}
public void WinnerDecider()
{
if(KnightSwitch.BLance == 1 && KnightSwitch.BStallion == 1)
{
Application.LoadLevel("KnightWin");
}
else if(KnightSwitch.OLance == 1 && KnightSwitch.FMane == 1)
{
Application.LoadLevel("KnightWin");
}
else
{
if (KnightSwitch.LoseInt == 1)
{
Application.LoadLevel("LanceLose");
}
else if (KnightSwitch.LoseInt == 2)
{
Application.LoadLevel("HorseLose");
}
}
}
}