// Use this for initialization void Start() { if (score == null) { score = GameObject.Find("score").GetComponent <Text> (); } if (player == null) { player = GameObject.Find("playername").GetComponent <Text> (); } score.text = "Score: " + PlayerPrefsHelper.getPlayerScore().ToString(); player.text = "Player: " + PlayerPrefsHelper.getPlayerName(); }
// Update is called once per frame void Update() { text.text = "Score : " + PlayerPrefsHelper.getPlayerScore(); nametext.text = "Player : " + PlayerPrefsHelper.getPlayerName(); }
// ScoreKeeper keeper; //-- Use this for initialization void Start() { // keeper = new ScoreKeeper(); // keeper. //--------------------------------------------------------------- //-- if the object is null the populate it. //--------------------------------------------------------------- if (rigidBody == null) { rigidBody = GetComponent <Rigidbody2D>(); myAnimator = GetComponent <Animator>(); } if (text == null) { text = GameObject.Find("score").GetComponent <Text>(); } if (nametext == null) { nametext = GameObject.Find("playername").GetComponent <Text>(); } if (block1 == null) { block1 = GameObject.FindGameObjectWithTag("blockA"); if (GameObject.FindGameObjectWithTag("blockA") != null) { num++; } } if (block2 == null) { block2 = GameObject.FindGameObjectWithTag("blockB"); if (GameObject.FindGameObjectWithTag("blockB") != null) { num++; } } if (block3 == null) { block3 = GameObject.FindGameObjectWithTag("blockC"); if (GameObject.FindGameObjectWithTag("blockC") != null) { num++; } } if (block4 == null) { block4 = GameObject.FindGameObjectWithTag("blockD"); if (GameObject.FindGameObjectWithTag("blockD") != null) { num++; } } if (block5 == null) { block5 = GameObject.FindGameObjectWithTag("blockE"); if (GameObject.FindGameObjectWithTag("blockE") != null) { num++; } } if (block6 == null) { block6 = GameObject.FindGameObjectWithTag("blockF"); if (GameObject.FindGameObjectWithTag("blockF") != null) { num++; } } if (block7 == null) { block7 = GameObject.FindGameObjectWithTag("blockG"); if (GameObject.FindGameObjectWithTag("blockG") != null) { num++; } } if (block8 == null) { block8 = GameObject.FindGameObjectWithTag("blockH"); if (GameObject.FindGameObjectWithTag("blockH") != null) { num++; } } if (block9 == null) { block9 = GameObject.FindGameObjectWithTag("blockI"); if (GameObject.FindGameObjectWithTag("blockI") != null) { num++; } } if (collisionSound == null) { collisionSound = GetComponent <AudioSource>(); } //--------------------------------------------------------------- //--------------------------------------------------------------- //-- //--------------------------------------------------------------- i = 0; force = 350.0f; isJumping = false; movementSpeed = 4.0f; isFacingRight = true; //--------------------------------------------------------------- //-- //--------------------------------------------------------------- win = new List <string>(); order = ""; //--------------------------------------------------------------- //-- winning chemical combinations. //--------------------------------------------------------------- win.Add("carbon"); win.Add("sodiumchlorine"); win.Add("hydrogenhydrogenoxygen"); win.Add("heliumneonargonkrypton"); win.Add("carboncarbonhydrogenhydrogenhydrogenhydrogenoxygen"); win.Add("carboncarbonhydrogenhydrogenhydrogenhydrogenhydrogennitrogenoxygen"); //--------------------------------------------------------------- nametext.text = "Player : " + PlayerPrefsHelper.getPlayerName(); }