public override void Impact() { if (!solved) { // Check if it was the correct color. if (currentColor == correctColorIndex) { hitRenderers[hits].material.color = hitColor; hits++; if (hits == hitRenderers.Length) { solved = true; controller.OpenDoor(); rend.material.color = colors[correctColorIndex]; } else { ChangeColor(); } ShuffleColors(); // Shuffle the colors again. } else { // Reset the impacts. hits = 0; foreach (Renderer r in hitRenderers) { r.material.color = startHitColor; } ChangeColor(); } } }
private void OnTriggerEnter(Collider other) { if (!solved && other.gameObject.tag == "Player") { solved = true; Vector3 directorVector = other.transform.position - transform.position; if (Vector3.Cross(startForward, directorVector).y < 0.0f) { transform.parent.Rotate(0.0f, 30.0f, 0.0f); } else { transform.parent.Rotate(0.0f, -30.0f, 0.0f); } controller.OpenDoor(); } }
public override void Impact() { if (currentColorIndex == 0) // The 0 is the correct color. { value += chargeAmount; if (value >= 1.0f) { value = 1.0f; solved = true; ChangeBarSize(); controller.OpenDoor(); } } else { value -= chargeAmount * 2.0f; if (value < 0.01f) { value = 0.01f; } } }