void OnGUI() { int windowID = 0; GameState gameState = Utilities().getGameState(); GUI.skin = guiSkin; GUI.color = currentGUIColor; if(previousGameState != gameState) { // Reset the inputs between states characterNameInput = ""; emailInput = ""; passwordInput = ""; responseMessage = ""; bDoTransition = true; switch(gameState) { case GameState.Title: windowRects["Title"] = new Rect(offScreenRects[Direction.Left]); bThrowingDice = true; // execute the dice throwing, demo code bDoTitleWindow = true; // show the title window break; case GameState.Register: case GameState.Login: windowRects["Login"] = new Rect(offScreenRects[Direction.Right]); bDoLoginWindow = true; GUI.FocusWindow(windowIDs["Login"]); break; case GameState.Instructions: windowRects["Instructions"] = new Rect(offScreenRects[Direction.Right]); bDoInstructionsWindow = true; GUI.FocusWindow(windowIDs["Instructions"]); break; case GameState.WeaponSelection: windowRects["WeaponSelect"] = new Rect(offScreenRects[Direction.Right]); bDoWeaponSelectWindow = true; break; case GameState.PlayerProfile: windowRects["PlayerProfile"] = new Rect(offScreenRects[Direction.Right]); bDoPlayerProfileWindow = true; break; case GameState.BattleMode: bThrowingDice = false; // Wait until the transitioning out of the last window before enabling battlemode GUI_BattleWindows_PlaceOffScreen(); bDoBattleWindow = false; break; case GameState.BattleOver: windowRects["BattleOver"] = new Rect(offScreenRects[Direction.Right]); TransitionBattleWindowsOff(); FadeWindows(true); bDoBattleWindow = false; bThrowingDice = true; bDoBattleOverWindow = true; bFinishedRewarding = false; bChangedWeapon = false; bUpdatingWeapon = false; bRandomWeaponChoicesSet = false; break; } previousGameState = gameState; } windowIDs["Title"] = windowID++; GUI_Title_Window(windowIDs["Title"]); windowIDs["Login"] = windowID++; GUI_Login_Window(windowIDs["Login"]); windowIDs["Instructions"] = windowID++; GUI_Instructions_Window(windowIDs["Instructions"]); windowIDs["WeaponSelect"] = windowID++; GUI_WeaponSelect_Window(windowIDs["WeaponSelect"]); windowIDs["PlayerProfile"] = windowID++; GUI_PlayerProfile_Window(windowIDs["PlayerProfile"]); windowID = GUI_BattleMode_Window(windowID); windowIDs["BattleOver"] = windowID++; GUI_BattleOver_Window(windowIDs["BattleOver"]); }
// -- Game State public void setGameState(GameState newGameState) { GameController().setGameState(newGameState); }
// Use this for initialization void OnEnable() { previousGameState = GameState.NoState; diceIcons = new Dictionary<string, Texture>(); diceIcons.Add("d4",d4Icon); diceIcons.Add("d6",d6Icon); diceIcons.Add("d8",d8Icon); diceIcons.Add("d10",d10Icon); diceIcons.Add("d12",d12Icon); diceIcons.Add("d20",d20Icon); diceIcons.Add("d100",d100Icon); //battleText = ""; characterNameInput = ""; emailInput = ""; passwordInput = ""; responseMessage = ""; bSubmitted = false; bBattleStarted = false; bRewardsAwarded = false; bFinishedRewarding = false; bChangedWeapon = false; bDoTitleWindow = true; bDoLoginWindow = false; bDoWeaponSelectWindow = false; bDoPlayerProfileWindow = false; bDoBattleWindow = false; bDoBattleOverWindow = false; scrollPosition = new Vector2(0, Mathf.Infinity); windowIDs = new Dictionary<string, int>(); windowRects = new Dictionary<string, Rect>(); battleWindowRects = new Dictionary<string, Rect>(); offScreenRects = new Dictionary<Direction, Rect>(); currentGUIColor = GUI.color; // Throw some dice out for fun Utilities().ThrowDice(new Roll("d4", 1), false); Utilities().ThrowDice(new Roll("d6", 1), false); Utilities().ThrowDice(new Roll("d8", 1), false); Utilities().ThrowDice(new Roll("d10", 1), false); Utilities().ThrowDice(new Roll("d12", 1), false); Utilities().ThrowDice(new Roll("d20", 1), false); Utilities().ThrowDice(new Roll("d100", 1), false); gameMenuRect = new Rect(0 + GUI_SCREEN_BORDER, 0 + GUI_SCREEN_BORDER, Screen.width - GUI_SCREEN_BORDER, Screen.height - GUI_SCREEN_BORDER); offScreenRects[Direction.Left] = new Rect(-Screen.width, 0, Screen.width, Screen.height); offScreenRects[Direction.Right] = new Rect(Screen.width, 0, Screen.width, Screen.height); offScreenRects[Direction.Up] = new Rect(0, -Screen.height, Screen.width, Screen.height); offScreenRects[Direction.Down] = new Rect(0, Screen.height, Screen.width, Screen.height); windowRects["Title"] = new Rect(offScreenRects[Direction.Right]); windowRects["Login"] = new Rect(gameMenuRect); windowRects["WeaponSelect"] = new Rect(gameMenuRect); windowRects["PlayerProfile"] = new Rect(gameMenuRect); windowRects["BattleOver"] = new Rect(gameMenuRect); windowRects["Instructions"] = new Rect(gameMenuRect); battleWindowRects["BattleQueueOn"] = new Rect(Screen.width - Screen.width*0.35f, 5f, Screen.width*0.35f, Screen.height*0.3f); battleWindowRects["BattleTextOn"] = new Rect(Screen.width*0.45f, 5f, Screen.width - Screen.width*0.45f, Screen.height*0.45f); battleWindowRects["ActionSelectionOn"] = new Rect(Screen.width*0.008f, Screen.height*0.6f, Screen.width*0.5f, Screen.height*0.4f); battleWindowRects["BattleStatsOn"] = new Rect(Screen.width - Screen.width*0.25f, Screen.height*0.4f, Screen.width*0.25f, Screen.height*0.6f); battleWindowRects["CurrentWeaponOn"] = new Rect(Screen.width*0.008f, 5f, Screen.width*0.3f, Screen.height*0.65f); /*= new Rect(Screen.width*0.5f, Screen.height*0.45f, Screen.width*0.25f, Screen.height*0.55f);*/ battleWindowRects["BattleQueueOff"] = new Rect(Screen.width, -Screen.height*0.2f, Screen.width*0.25f, Screen.height*0.2f); battleWindowRects["BattleTextOff"] = new Rect(Screen.width, -Screen.height*45f, Screen.width*0.45f, Screen.height*0.45f); battleWindowRects["ActionSelectionOff"] = new Rect(Screen.width*0.008f, Screen.height, Screen.width*0.55f, Screen.height*0.45f); battleWindowRects["BattleStatsOff"] = new Rect(-Screen.width*0.2f, -Screen.height*0.6f, Screen.width*0.25f, Screen.height*0.6f); battleWindowRects["CurrentWeaponOff"] = new Rect(Screen.width*0.55f, Screen.height, Screen.width*0.25f, Screen.height*0.55f); windowRects["ActionSelection"] = new Rect(battleWindowRects["ActionSelectionOff"]); windowRects["BattleStats"] = new Rect(battleWindowRects["BattleStatsOff"]); windowRects["BattleQueue"] = new Rect(battleWindowRects["BattleQueueOff"]); windowRects["BattleText"] = new Rect(battleWindowRects["BattleTextOff"]); windowRects["CurrentWeapon"] = new Rect(battleWindowRects["CurrentWeaponOff"]); }