In my Code i’m trying to implement stages. But once it gets to certain stages it auto loops back.
Any Help?
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class Cthulu : MonoBehaviour
{
public Text text;
private enum Stages { s0, Dead, No, s1, s2, Split, BR1, BRPeople, BRTav };
private Stages myStage;
private enum Class { None, Barbarian, Ranger, Wizard, Rogue, Bard }
private Class myClass;
// Use this for initialization
void Start() {
myStage = Stages.s0;
myClass = Class.None;
Application.targetFrameRate = 10;
}
// Update is called once per frame
void Update() {
print(myStage);
if (myStage == Stages.s0)
{
Stage_0();
}
else if (myStage == Stages.No)
{
Stage_No();
}
else if (myStage == Stages.Dead)
{
Stage_Death();
}
else if (myStage == Stages.s1)
{
Stage_1();
}
else if (myStage == Stages.s2)
{
Stage_2();
}
else if (myStage == Stages.Split)
{
Stage_Split();
}
else if (myStage == Stages.BR1)
{
Stage_BR1();
}
else if (myStage == Stages.BRPeople)
{
Stage_BRPeople();
}
else if (myStage == Stages.BRTav)
{
Stage_BRTav();
}
}
void Stage_0()
{
text.text = "Good Guy, Bad Guy, sword. You get the gist, Continue? \n\n" + "Press 1 for yes, Press 2 for No";
if (Input.GetKeyDown(KeyCode.Alpha1))
{
myStage = Stages.s1;
}
else if (Input.GetKeyDown(KeyCode.Alpha2))
{
myStage = Stages.No;
}
}
void Stage_No()
{
text.text = "No? what do you mean no. You are the one who wanted to play this game. Don't be a wimp \n\n" + "Press 1 to Continue";
if (Input.GetKeyDown(KeyCode.Alpha1))
{
myStage = Stages.s0;
}
}
void Stage_Death()
{
text.text = "You are dead, Git gud nerd \n\n" + "Press R to Restart";
if (Input.GetKeyDown(KeyCode.R))
{
myStage = Stages.s0;
}
}
void Stage_1()
{
text.text = "You are faced with a squid man, What would you like to do \n\n" + "Press F to fight, or R to Run";
if (Input.GetKeyDown(KeyCode.F))
{
text.text = "You fight the squidman and win \n\n" + "Press R to Run, press L to Loot";
if (Input.GetKeyDown(KeyCode.R))
{
myStage = Stages.s2;
}
else if (Input.GetKeyDown(KeyCode.L))
{
text.text = "The squid man was faking it, he stabs you in the head \n\n" + "Press C to Continue";
if (Input.GetKeyDown(KeyCode.C))
{
myStage = Stages.Dead;
}
}
}
else if (Input.GetKeyDown(KeyCode.R))
{
text.text = "Wimp \n\n" + "Don't be a Bitch \n\n" + "Press C to Continue";
if (Input.GetKeyDown(KeyCode.C))
{
myStage = Stages.Dead;
}
}
}