// Manage score computation when the ball enters the cave void OnCollisionEnter(Collision collision) { GameObject obj = collision.gameObject; if (obj.tag == "Ball") { /***************** Ball collision control *****************/ // Return the ball to the storage Debug.Log("Ball " + obj.name + " in the cave"); obj.transform.position = GameObject.Find("RightLane/Lane/ball_recovery_vertical_tunel_001/ball return gate").transform.position; obj.GetComponent <Rigidbody>().AddForce(new Vector3(0, 60, 0), ForceMode.Impulse); // Start fallen pins accounting, by recoverying them so that they could be countable recoveryFallenPins(); if (!parameters.IsLastFrame) { // Go to the next frame parameters.initNextRound(); } else { // End the game and send the player to the menu endGame(); sendPlayerToMenu(); } } if (obj.tag == "Pin") { /***************** Pin collision control *****************/ Debug.Log("Pin felt: " + obj.name); // Increment the fallen pins of the frame's round parameters.incrementFallenPins(); } }
// Manage score computation when the ball enters the cave void OnCollisionEnter(Collision collision) { GameObject obj = collision.gameObject; if (obj.tag == "Ball") { /***************** Ball collision control *****************/ // Return the ball to the storage Debug.Log("Ball " + obj.name + " in the cave"); obj.transform.position = GameObject.Find("RightLane/Lane/ball_recovery_vertical_tunel_001/ball return gate").transform.position; obj.GetComponent <Rigidbody>().AddForce(new Vector3(0, 73, 0), ForceMode.Impulse); // Tell the system to recover the pin performPinRecovery = true; } if (obj.tag == "Pin" && !fallenPins.Contains(obj)) { /***************** Pin collision control *****************/ Debug.Log("Pin felt: " + obj.name); // Register the fallen Pin fallenPins.Add(obj); // Increment the fallen pins of the frame's round parameters.incrementFallenPins(); string rounds = ""; foreach (int r in parameters.Rounds) { rounds += r + ";"; } Debug.Log("Fallen Pins rounds: " + rounds); } }