void OnGUI() { //Counts down the time before the level starts! if ((int)levelCountdown > 0) { GUI.Box(new Rect(Screen.width / 2 - levelCountdownSize / 2, Screen.height / 2 - levelCountdownSize / 2, levelCountdownSize, levelCountdownSize), "" + (int)levelCountdown, countdown); //OnGUI is called twice a frame, Who knew!? levelCountdown -= Time.deltaTime / 2; } //Main Menu Button Sizing and position variables mmButtonWidth = Screen.width / buttonWidthDivider; mmButtonHeight = Screen.height / buttonHeightDivider; mmButtonPosition = new Rect(Screen.width * .5f - mmButtonWidth * .5f, Screen.height * .5f - mmButtonHeight * .5f, mmButtonWidth, mmButtonHeight); //Restart Button Sizing and position variables rButtonWidth = Screen.width / buttonWidthDivider; rButtonHeight = Screen.height / buttonHeightDivider; rButtonPosition = new Rect(Screen.width / 3 - rButtonWidth * .5f, Screen.height * .5f - rButtonHeight * .5f, rButtonWidth, rButtonHeight); //Level Select Button Sizing and position variables lsButtonWidth = Screen.width / buttonWidthDivider; lsButtonHeight = Screen.height / buttonHeightDivider; lsButtonPosition = new Rect(Screen.width / (float)1.5 - rButtonWidth * .5f, Screen.height * .5f - rButtonHeight * .5f, rButtonWidth, rButtonHeight); //Debug.Log(currencyStringRect); //Side Bar GUI fakeIndexer = 0; foreach (GameObject fish in FishSelected) { if (fish != null) { //BE VERY CAREFUL HERE! CHANGING THE FISH SELECTED WILL IN FACT CHANGE THE PREFAB, THE FISH SELECTED PASSES AN INSTANCE OF THE PREFAB TO ALLOW ACCESS FOR ALL ITS INFORMATION Rect rectangle = new Rect(Screen.height / 50, Screen.width / 15 + fakeIndexer * (Screen.width / 10) + fakeIndexer * (Screen.width / 50), Screen.width / 10, Screen.width / 10); Texture texture = fish.GetComponent <UnitStatScript>().tex; if (fish.GetComponent <UnitStatScript>().cost > resourceManager.resource) { myStyle.normal.textColor = Color.red; } else { myStyle.normal.textColor = Color.green; } if (GUI.Button(rectangle, new GUIContent("$" + fish.GetComponent <UnitStatScript>().cost.ToString(), texture), myStyle)) { if (SceneManager.isInSelection) { } else { UnitStatScript scriptRef = fish.GetComponent <UnitStatScript>(); if (resourceManager.resource >= scriptRef.cost) { buildManager.SelectOrDeselectObjectToBuild(fish, scriptRef.cost); AudioManager.Click(); } } } } fakeIndexer++; } if (!SceneManager.isInSelection) { Rect rectangle = new Rect(Screen.width / 30, Screen.height / 150f, Screen.width / 10f, Screen.height / 10f); if (!SceneManager.isPaused) { if (GUI.Button(rectangle, pause, unPauseGUI)) { AudioManager.Click(); shouldShowPauseScreen = true; SceneManager.isPaused = true; } } if (SceneManager.isPaused) { if (SceneManager.hasLostStat || SceneManager.hasWonStat) { shouldShowPauseScreen = false; } if (shouldShowPauseScreen) { if (GUI.Button(rectangle, play, unPauseGUI)) { SceneManager.isPaused = false; shouldShowPauseScreen = false; } //creates Main Menu button if (GUI.Button(mmButtonPosition, mainMenu, unPauseGUI)) { AudioManager.Click(); Application.LoadLevel("SceneStart"); } //creates Level Select button if (GUI.Button(lsButtonPosition, levelSelect, unPauseGUI)) { AudioManager.Click(); Application.LoadLevel("SceneLevelSelect"); } //Creates Restart button if (GUI.Button(rButtonPosition, restart, unPauseGUI)) { AudioManager.Click(); Application.LoadLevel(Application.loadedLevel); } if (GUI.Button(new Rect(0, 0, Screen.width, Screen.height), "", unPauseGUI)) { AudioManager.Click(); SceneManager.isPaused = false; shouldShowPauseScreen = false; } } } else { if (!UnitManager.shouldSell) { treasure.normal.textColor = Color.green; if (GUI.Button(new Rect(Screen.width / 1.5f, -Screen.height / 40, Screen.width / 8, Screen.height / 8), "Sell", treasure)) { AudioManager.Click(); UnitManager.shouldSell = true; } } else { treasure.normal.textColor = Color.red; if (GUI.Button(new Rect(Screen.width / 1.5f, -Screen.height / 20, Screen.width / 8, Screen.height / 8), "Cancel", treasure)) { AudioManager.Click(); UnitManager.shouldSell = false; } } } } //Top Line GUI treasure.normal.textColor = Color.yellow; GUI.Box(new Rect(Screen.width / 1.165f, -Screen.height / 40, Screen.width / 8, Screen.height / 8), currencyString + resourceManager.resource, treasure); }
// Use this for initialization void Start() { script = this.gameObject.GetComponent <UnitStatScript>(); canFire = true; }
// Use this for initialization void Start() { sR = this.gameObject.GetComponent <UnitStatScript>(); distanceModifier = (attackIntervalMax - attackIntervalMin) / maxDistance; }
void OnGUI() { if (SceneManager.isInSelection) { GUI.Box(rectangle, "", Net); GUI.Box(selected, "Choose Your Allies!", Plank); for (int i = 0; i < choices.Count; i++) { if (fishToBeChosen[i] != null) { UnitStatScript fish = fishToBeChosen[i].GetComponent <UnitStatScript>(); myStyle.fontSize = (int)choices[i].height / 7; if (GUI.Button(choices[i], new GUIContent("$" + fish.cost.ToString(), fish.tex), myStyle)) { int numberOfFishSelected = 0; foreach (GameObject obj in gameGUI.FishSelected) { AudioManager.Click(); if (obj != null) { ++numberOfFishSelected; } } if (!gameGUI.FishSelected.Contains(fishToBeChosen[i])) { if (numberOfFishSelected < 4) { gameGUI.FishSelected.Add(fishToBeChosen[i]); AudioManager.Click(); } } else { gameGUI.FishSelected.Remove(fishToBeChosen[i]); AudioManager.Click(); } break; } } else { if (GUI.Button(choices[i], lockTex, myStyle)) { AudioManager.Click(); break; } } } if (GUI.Button(confirm, "Confirm", Plank)) { AudioManager.Click(); if (SceneManager.isInSelection) { if (gameGUI.FishSelected.Count == alliesToSelect) { SceneManager.isPaused = false; SceneManager.isInSelection = false; this.gameObject.GetComponent <GameGUI>().levelCountdown = 5f; } } } } }