private void resetCart() { this.transform.position = new Vector3(this.transform.position.x, this.transform.position.y, startPos); cartStage = CART_STAGES.entry; pebleCount = 0; setRandomColor(); RainBow.currentColor = pebleColor; setPropColors(); disableProps(); setHealth(3); health = 3; correctCount = 0; counter.text = "0/20"; pebleImage.color = RainBow.getColor(pebleColor); }
void Start() { audioSource = this.GetComponent <AudioSource>(); leftMax = maxLocation.transform.position.z; rightMin = minLocation.transform.position.z; middlePos = midLocation.transform.position.z; startPos = startLocation.transform.position.z; maxLocation = null; minLocation = null; midLocation = null; startLocation = null; disableProps(); cartStage = CART_STAGES.Idle; // resetCart(); }
private void OnTriggerEnter(Collider other) { if (cartStage.Equals(CART_STAGES.gameplay)) { if (other.tag == "Peble") { Destroy(other.gameObject); pebleProps[pebleCount].gameObject.SetActive(true); pebleProps[pebleCount].GetComponent <Renderer>().material.color = other.GetComponent <Renderer>().material.color; pebleCount++; if (other.GetComponent <Renderer>().material.color != RainBow.getColor(pebleColor)) { health--; setHealth(health); audioSource.PlayOneShot(wrongSound); if (health <= 0) { cartStage = CART_STAGES.leave; endGame = true; } } else { correctCount++; counter.text = correctCount.ToString() + "/20"; if (pebleCount > pebleProps.Length - 1) { pebleCount = 0; cartStage = CART_STAGES.leave; audioSource.PlayOneShot(winSound); } else { audioSource.PlayOneShot(collectSound); } } } } }
private void cartEnter() { if (this.transform.position.z < middlePos) { moveDirection = Vector3.Lerp(moveDirection, Vector3.left * Speed, Time.deltaTime * 5); rotatingAngle = Mathf.Lerp(rotatingAngle, 90, Time.deltaTime * 5); } else { moveDirection = Vector3.Lerp(moveDirection, Vector3.zero, Time.deltaTime * 20); rotatingAngle = Mathf.Lerp(rotatingAngle, 0, Time.deltaTime * 20); cartStage = CART_STAGES.gameplay; } this.transform.Translate(moveDirection); foreach (Transform wheel in wheels) { wheel.Rotate(Vector3.forward, rotatingAngle); } }