//Resets the Colour Points to 0 void ClearColours(PickUpColours colour) { if (colour != PickUpColours.NONE) { PlayerPrefs.SetInt("RedPickUp", 0); PlayerPrefs.SetInt("BluePickUp", 0); PlayerPrefs.SetInt("OrangePickUp", 0); PlayerPrefs.SetInt("YellowPickUp", 0); PlayerPrefs.SetInt("GreenPickUp", 0); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.name == "Ball") { AddPoint(); transform.position = Vector3.one * 9999999f; if (PlayerPrefs.GetInt("Sound") >= 1) { soundSource.PlayOneShot(collectPoints, 1f); } PickUpColours selectedColour = AddPickUpPoint(gameObject.tag); ClearColours(selectedColour); ChangeBallColour(ball, selectedColour); Destroy(gameObject, collectPoints.length + 2); } }
void ChangeBallColour(GameObject ball, PickUpColours colour) { GameObject baller = GameObject.Find("Ball"); switch (colour) { case PickUpColours.RED: baller.gameObject.GetComponent <Renderer>().material = _RedMaterial; if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _RedMaterial) { baller.gameObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePositionY; } break; case PickUpColours.BLUE: baller.gameObject.GetComponent <Renderer>().material = _BlueMaterial; PlayerPrefs.SetInt("SuckerPower", 1); break; case PickUpColours.ORANGE: baller.gameObject.GetComponent <Renderer>().material = _OrangeMaterial; if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _YellowMaterial) { baller.gameObject.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 2); } break; case PickUpColours.YELLOW: baller.gameObject.GetComponent <Renderer>().material = _YellowMaterial; if (baller.gameObject.GetComponent <Renderer>().sharedMaterial == _YellowMaterial) { baller.gameObject.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 4); } break; case PickUpColours.GREEN: baller.gameObject.GetComponent <Renderer>().material = _GreenMaterial; break; } }