private static void CameraSwapAndBallRemoval(GameObject cannonball) { if (cannonball.name == "CannonBall(Clone)") { Cannon1_Start.isActive = false; Cannon2_Start.isActive = true; GameObject p1Camera = GameObject.Find("P1Camera"); GameObject p2Camera = GameObject.Find("P2Camera"); p1Camera.GetComponent <UnityEngine.Camera> ().enabled = Cannon1_Start.isActive; p2Camera.GetComponent <UnityEngine.Camera> ().enabled = Cannon2_Start.isActive; FiringControl.player1Scripts(Cannon1_Start.isActive); FiringControl.player2Scripts(Cannon2_Start.isActive); //cannonball.GetComponent<UnityEngine.Camera> ().enabled = Player1_Control.isActive; //cannonball.GetComponent<AssociatedThingsToDestroy>().deleteAssociatedThings(); Destroy(cannonball); } if (cannonball.name == "CannonBallp2(Clone)") { Cannon1_Start.isActive = true; Cannon2_Start.isActive = false; GameObject p1Camera = GameObject.Find("P1Camera"); GameObject p2Camera = GameObject.Find("P2Camera"); p1Camera.GetComponent <UnityEngine.Camera> ().enabled = Cannon1_Start.isActive; p2Camera.GetComponent <UnityEngine.Camera> ().enabled = Cannon2_Start.isActive; FiringControl.player1Scripts(Cannon1_Start.isActive); FiringControl.player2Scripts(Cannon2_Start.isActive); //cannonball.GetComponent<AssociatedThingsToDestroy>().deleteAssociatedThings(); Destroy(cannonball); } }
// Use this for initialization void Start() { //initialize random start location on x/z axis float randomXDisplacement = Random.Range(-MAX_X_STARTING_DISPLACEMENT, MAX_X_STARTING_DISPLACEMENT); float randomZDisplacement = Random.Range(-MAX_Z_STARTING_DISPLACEMENT, MAX_Z_STARTING_DISPLACEMENT); transform.Translate(randomXDisplacement, randomZDisplacement, 0); isActive = true; FiringControl.player1Scripts(isActive); }
void OnTriggerEnter(Collider cannonball) { if (cannonball.gameObject.name == "CannonBall(Clone)") { GameObject p1Camera = GameObject.Find("P1Camera"); GameObject p2Camera = GameObject.Find("P2Camera"); p1Camera.GetComponent <UnityEngine.Camera> ().enabled = !Cannon1_Start.isActive; p2Camera.GetComponent <UnityEngine.Camera> ().enabled = !Cannon2_Start.isActive; FiringControl.player1Scripts(false); FiringControl.player2Scripts(false); Destroy(cannonball.gameObject); Instantiate(explosion, transform.position, transform.rotation); transform.GetComponent <AudioSource> ().Play(); GlobalVariables.WINNER = 1; GlobalVariables.hasWINNER = true; } }