public void SetupAndDisplay() { int state = PlayerPrefs.GetInt("Music"); if (state == 1) { musicButton.image.sprite = musicOn; } else { musicButton.image.sprite = musicOff; } state = PlayerPrefs.GetInt("Effects"); if (state == 1) { effectsButton.image.sprite = effectsOn; } else { effectsButton.image.sprite = effectsOff; } FadeShow fadeShowScript = (FadeShow)GetComponent("FadeShow"); controlsDisplayed = !controlsDisplayed; if (controlsDisplayed) { fadeShowScript.ShowMe(100); } else { fadeShowScript.FadeMe(100); } }
public void UserAnswerButton(int answer) // 0 = <, 1 = between, 2 = > { GameObject manager = GameObject.Find("_Manager"); StartGame startGameScript = (StartGame)manager.GetComponent("StartGame"); quizText.text = startGameScript.quizRank.ToString(); topText.text = startGameScript.topRank.ToString(); bottomText.text = startGameScript.bottomRank.ToString(); RightWrongNone rightWrongNoneScript; rightWrongNoneScript = (RightWrongNone)lessRightWrong.GetComponent("RightWrongNone"); rightWrongNoneScript.ShowRightWrongNone(2); rightWrongNoneScript = (RightWrongNone)betweenRightWrong.GetComponent("RightWrongNone"); rightWrongNoneScript.ShowRightWrongNone(2); rightWrongNoneScript = (RightWrongNone)moreRightWrong.GetComponent("RightWrongNone"); rightWrongNoneScript.ShowRightWrongNone(2); bool correct = false; switch (answer) { case 0: // < rightWrongNoneScript = (RightWrongNone)lessRightWrong.GetComponent("RightWrongNone"); if (startGameScript.quizRank < startGameScript.topRank) { rightWrongNoneScript.ShowRightWrongNone(0); correct = true; } else { rightWrongNoneScript.ShowRightWrongNone(1); } break; case 1: // < rightWrongNoneScript = (RightWrongNone)betweenRightWrong.GetComponent("RightWrongNone"); if ((startGameScript.topRank < startGameScript.quizRank) && (startGameScript.quizRank < startGameScript.bottomRank)) { rightWrongNoneScript.ShowRightWrongNone(0); correct = true; } else { rightWrongNoneScript.ShowRightWrongNone(1); } break; case 2: // < rightWrongNoneScript = (RightWrongNone)moreRightWrong.GetComponent("RightWrongNone"); if (startGameScript.bottomRank < startGameScript.quizRank) { rightWrongNoneScript.ShowRightWrongNone(0); correct = true; } else { rightWrongNoneScript.ShowRightWrongNone(1); } break; } int currentScore = PlayerPrefs.GetInt("CurrentScore"); int bestScore = PlayerPrefs.GetInt("BestScore"); if (correct) { currentScore = currentScore + 1; if (currentScore > bestScore) { bestScore = currentScore; } } else { currentScore = 0; } currentText.text = currentScore.ToString(); bestText.text = bestScore.ToString(); PlayerPrefs.SetInt("CurrentScore", currentScore); PlayerPrefs.SetInt("BestScore", bestScore); FadeShow fadeShowScript = (FadeShow)rightWrongNoneCanvas.GetComponent("FadeShow"); fadeShowScript.ShowMe(10); }
public IEnumerator ccGetImage() { float scaleFactor; float newWidth; //float unitPixels; //float widthInUnits; //float ScreenWidthInUnits; downloading = true; WWW www = new WWW(url); yield return(www); SpriteRenderer renderer = gameObject.GetComponent <SpriteRenderer>(); //Camera camera = Camera.main; //Vector3 screenPos0 = camera.WorldToScreenPoint(new Vector3(0.0f, 0.0f, 0.0f)); //Vector3 screenPos1 = camera.WorldToScreenPoint(new Vector3(1.0f, 0.0f, 0.0f)); //unitPixels = screenPos1.x - screenPos0.x; //Vector3 ScreenDims = camera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0)); //ScreenWidthInUnits = ScreenDims.x * 2; scaleFactor = 200.0f / www.texture.height; newWidth = www.texture.width * scaleFactor; if (newWidth > 240.0f) { scaleFactor = 240.0f / www.texture.width; } newWidth = www.texture.width * scaleFactor; //widthInUnits = newWidth / unitPixels; Sprite sprite = new Sprite(); sprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0, 0), 100.0f); transform.localScale = new Vector3(scaleFactor, scaleFactor, scaleFactor); float yPos = transform.position.y; transform.position = new Vector3((-(sprite.bounds.extents.x / 2.0f)), yPos, 0); renderer.sprite = sprite; downloading = false; GameController quiz_script = (GameController)quiz_image.GetComponent("GameController"); GameController top_script = (GameController)top_image.GetComponent("GameController"); GameController bottom_script = (GameController)bottom_image.GetComponent("GameController"); if ((!quiz_script.downloading && !top_script.downloading) && !bottom_script.downloading) { Renderer ren = quiz_image.GetComponent <Renderer>(); ren.enabled = true; ren = top_image.GetComponent <Renderer>(); ren.enabled = true; ren = bottom_image.GetComponent <Renderer>(); ren.enabled = true; ren = quiz_spinner.GetComponent <Renderer>(); ren.enabled = false; ren = top_spinner.GetComponent <Renderer>(); ren.enabled = false; ren = bottom_spinner.GetComponent <Renderer>(); ren.enabled = false; FadeShow buttons_script = (FadeShow)answer_buttons_canvas.GetComponent("FadeShow"); buttons_script.ShowMe(10); } }