//Called by interacting with the payphone public void triggerPayphone() { if (moneyHeld < payphonePrice) { notEnoughMoney = true; } else { //unlock achievement if user did not buy water if (!hasBoughtWater) { if (!PlayerPrefs.HasKey("BadStudent")) { mainController.UnlockAchievement("BadStudent", "Rebel: Did not buy water"); } } //update objective and spawn soccer ball moneyHeld -= payphonePrice; notEnoughMoney = false; ObjectiveText.text = "I guess I'll play by myself. Gotta find a spare ball."; spawner.SpawnNewItemRandom(); MoneyText.text = "$" + moneyHeld; } }
// Update is called once per frame. void Update() { if (inTrigger) { if (Input.GetKeyDown(KeyCode.E)) { isFound = true; inTrigger = false; // Makes object invisible. gameObject. GetComponent <BoxCollider> ().enabled = false; gameObject.GetComponent <Renderer> ().enabled = false; //Play pick up sound if (soundEffect != null) { soundEffect.playEffect(); } // Adds to player score. gameController.AddScore(itemScore); gameController.sleepMeter.value += itemScore / 2; // Adds object to inventory. if (inventoryIcons.Length != 0) { GameObject i; i = Instantiate(inventoryIcons [0]); i.transform.SetParent(inventoryPanel.transform); } // Updates game objective. if (hasObjective) { Text tmp = gameController.objectiveText.GetComponent <Text>(); tmp.text = objective; } } } // Once player reads the text destroy object. if (isFound) { if (Input.GetKeyDown(KeyCode.F)) { if (isFinalObject) { levelComplete = true; } if (this.gameObject.tag.Equals("spawnFixed")) { spawner.SpawnNewItemFixed(); } else if (this.gameObject.tag.Equals("spawnRand")) { spawner.SpawnNewItemRandom(); } Destroy(this.gameObject); } } }