Sunday, 9 October 2016

Player Select

public Button Playerokay;
public int btnvalue;
public Button Lft,Rgt;
public GameObject mario,archer,wizard,Q_mark;
int mylock;
public GameObject W_text,A_text;

void Awake()
{
//PlayerPrefs.DeleteAll();

}

void Start()
{
btnvalue = 0;

mylock = PlayerPrefs.GetInt("levellock") ;

if (PlayerPrefs.GetInt ("Check") == 0) {
if (mylock > 1) {
PlayerPrefs.SetInt ("WizardUnlock", 1);
}
if (mylock > 5) {
PlayerPrefs.SetInt ("ArcherUnlock", 1);
PlayerPrefs.SetInt ("WizardUnlock", 1);
}
PlayerPrefs.SetInt ("Check" , 1);
}
}

void Update()
{

if (btnvalue == 0) {
mario.transform.localPosition = new Vector3 (0, 22, 0);
wizard.transform.localPosition = new Vector3 (500, 22, 0);
archer.transform.localPosition = new Vector3 (1000, 22, 0);
Q_mark.transform.localPosition = new Vector3 (1500, 22, 0);
Lft.interactable = false;
Rgt.interactable = true;
}
else if (btnvalue == 1) {
mario.transform.localPosition = new Vector3 (-500, 22, 0);
wizard.transform.localPosition = new Vector3 (0, 22, 0);
archer.transform.localPosition = new Vector3 (500, 22, 0);
Q_mark.transform.localPosition = new Vector3 (1000, 22, 0);
Lft.interactable = true;
Rgt.interactable = true;
} else if (btnvalue == 2) {
mario.transform.localPosition = new Vector3 (-1000, 22, 0);
wizard.transform.localPosition = new Vector3 (-500, 22, 0);
archer.transform.localPosition = new Vector3 (0, 22, 0);
Q_mark.transform.localPosition = new Vector3 (500, 22, 0);
Lft.interactable = true;
Rgt.interactable = true;
}else if (btnvalue == 3) {
mario.transform.localPosition = new Vector3 (-1500, 22, 0);
wizard.transform.localPosition = new Vector3 (-1000, 22, 0);
archer.transform.localPosition = new Vector3 (-500, 22, 0);
Q_mark.transform.localPosition = new Vector3 (0, 22, 0);
Lft.interactable = true;
Rgt.interactable = false;
}

if (PlayerPrefs.GetInt("WizardUnlock") == 0 && btnvalue == 1) {
Playerokay.interactable = false;
W_text.SetActive (true);

}else if (PlayerPrefs.GetInt("ArcherUnlock") == 0 && btnvalue == 2) {
Playerokay.interactable = false;
A_text.SetActive (true);
} else if(btnvalue == 3)
{
Playerokay.interactable = false;
} else{
Playerokay.interactable = true;
A_text.SetActive (false);
W_text.SetActive (false);
}
}
public void playerokay()
{
PlayerPrefs.SetInt ("Player",btnvalue);
Application.LoadLevel ("MainMenu");
}

public void BackToHomeScene()
{
Application.LoadLevel("MainMenu");
}

public void LeftBtn()
{
btnvalue = btnvalue - 1;
}
public void RightBtn()
{
btnvalue = btnvalue + 1;
}

No comments:

Post a Comment