//================================================================================================================================================ void OnTriggerEnter(Collider other) { if (other.tag == "bolt") { Destroy(other.gameObject); controller.decreaseHealth(2, controller.playerDamage); Instantiate(NormalExplosion, other.transform.position, other.transform.rotation); if (gameControllerModeVs.health[1] - controller.playerDamage <= 0) { Destroy(gameObject); Instantiate(playerExplosion, other.transform.position, other.transform.rotation); player2loscounter++; if (player2loscounter == 1) { gameControllerModeVs.round++; Application.LoadLevel("Vs"); } if (player2loscounter == 2) { gameControllerModeVs.round = 1; Application.LoadLevel("Wvs1"); player2loscounter = 0; } //win player2 screen } } else if (other.tag == "asteroid1") { Destroy(other.gameObject); controller.decreaseHealth(2, controller.hazards.asteroidsDamage[0]); Instantiate(NormalExplosion, other.transform.position, other.transform.rotation); if (gameControllerModeVs.health[1] - controller.hazards.asteroidsDamage[0] <= 0) { Destroy(gameObject); Instantiate(playerExplosion, other.transform.position, other.transform.rotation); player2loscounter++; if (player2loscounter == 1) { gameControllerModeVs.round++; Application.LoadLevel("Vs"); } if (player2loscounter == 2) { gameControllerModeVs.round = 1; Application.LoadLevel("Wvs1"); player2loscounter = 0; } //win player2 screen } } else if (other.tag == "asteroid2") { Destroy(other.gameObject); controller.decreaseHealth(2, controller.hazards.asteroidsDamage[1]); Instantiate(NormalExplosion, other.transform.position, other.transform.rotation); if (gameControllerModeVs.health[1] - controller.hazards.asteroidsDamage[1] <= 0) { Destroy(gameObject); Instantiate(playerExplosion, other.transform.position, other.transform.rotation); player2loscounter++; if (player2loscounter == 1) { gameControllerModeVs.round++; Application.LoadLevel("Vs"); } if (player2loscounter == 2) { gameControllerModeVs.round = 1; Application.LoadLevel("Wvs1"); player2loscounter = 0; } //win player2 screen } } else if (other.tag == "asteroid3") { Destroy(other.gameObject); controller.decreaseHealth(2, controller.hazards.asteroidsDamage[1]); Instantiate(NormalExplosion, other.transform.position, other.transform.rotation); if (gameControllerModeVs.health[1] - controller.hazards.asteroidsDamage[1] <= 0) { Destroy(gameObject); Instantiate(playerExplosion, other.transform.position, other.transform.rotation); player2loscounter++; if (player2loscounter == 1) { gameControllerModeVs.round++; Application.LoadLevel("Vs"); } if (player2loscounter == 2) { gameControllerModeVs.round = 1; Application.LoadLevel("Wvs1"); player2loscounter = 0; } //win player2 screen } } else if (other.tag == "powerUp1") { Destroy(other.gameObject); powerUp1Counter++; } else if (other.tag == "powerUp2") { Destroy(other.gameObject); if (gameControllerModeVs.health[1] + 15 <= 100) { gameControllerModeVs.health[1] += 15; } else { gameControllerModeVs.health[1] = 100; } controller.guiManger.healthBar[1].value = gameControllerModeVs.health[1]; } else if (other.tag == "powerUp3") { Destroy(other.gameObject); if (gameControllerModeVs.health[1] + 25 <= 100) { gameControllerModeVs.health[1] += 25; } else { gameControllerModeVs.health[1] = 25; } controller.guiManger.healthBar[1].value = gameControllerModeVs.health[1]; } }
//=============================================================================================================================================== void OnTriggerEnter(Collider other) { if (other.tag == "bolt2") //bullet from player 2 hit player 1 { Destroy(other.gameObject); //destroy bullet controller.decreaseHealth(1, controller.playerDamage); //decrease health of player 1 Instantiate(NormalExplosion, other.transform.position, other.transform.rotation); //bullet explosion if (gameControllerModeVs.health[0] - controller.playerDamage <= 0) //to check if the hit can destroy the player or not { Destroy(gameObject); //destroy player1 Instantiate(playerExplosion, other.transform.position, other.transform.rotation); //player explosion player1loscounter++; if (player1loscounter == 1) { gameControllerModeVs.round++; Application.LoadLevel("Vs"); } if (player1loscounter == 2) { gameControllerModeVs.round = 1; Application.LoadLevel("Wvs2"); player1loscounter = 0; } //win player2 screen } } else if (other.tag == "asteroid1") // rocks hit player 1 { Destroy(other.gameObject); //destroy the rock controller.decreaseHealth(1, controller.hazards.asteroidsDamage[0]); //decrease health of player 1 Instantiate(NormalExplosion, other.transform.position, other.transform.rotation); //explosion if (gameControllerModeVs.health[0] - controller.hazards.asteroidsDamage[0] <= 0) //to check if the hit can destroy the player or not { Destroy(gameObject); Instantiate(playerExplosion, other.transform.position, other.transform.rotation); player1loscounter++; if (player1loscounter == 1) { gameControllerModeVs.round++; Application.LoadLevel("Vs"); } if (player1loscounter == 2) { //flag=true; gameControllerModeVs.round = 1; Application.LoadLevel("Wvs2"); //time2=Time.time; player1loscounter = 0; } } } else if (other.tag == "asteroid2") // rocks hit player 1 { Destroy(other.gameObject); controller.decreaseHealth(1, controller.hazards.asteroidsDamage[1]); Instantiate(NormalExplosion, other.transform.position, other.transform.rotation); if (gameControllerModeVs.health[0] - controller.hazards.asteroidsDamage[1] <= 0) { Destroy(gameObject); Instantiate(playerExplosion, other.transform.position, other.transform.rotation); player1loscounter++; if (player1loscounter == 1) { gameControllerModeVs.round++; Application.LoadLevel("Vs"); } if (player1loscounter == 2) { gameControllerModeVs.round = 1; Application.LoadLevel("Wvs2"); player1loscounter = 0; } } } else if (other.tag == "asteroid3") // rocks hit player 1 { Destroy(other.gameObject); controller.decreaseHealth(1, controller.hazards.asteroidsDamage[2]); Instantiate(NormalExplosion, other.transform.position, other.transform.rotation); if (gameControllerModeVs.health[0] - controller.hazards.asteroidsDamage[2] <= 0) { Destroy(gameObject); Instantiate(playerExplosion, other.transform.position, other.transform.rotation); player1loscounter++; if (player1loscounter == 1) { gameControllerModeVs.round++; Application.LoadLevel("Vs"); } if (player1loscounter == 2) { Application.LoadLevel("Wvs2"); gameControllerModeVs.round = 1; player1loscounter = 0; } } } else if (other.tag == "powerUp1") //to add the fire shot { Destroy(other.gameObject); PowerUps.powerUpCounter++; } else if (other.tag == "powerUp2") //power up 2 increase health by 15 { Destroy(other.gameObject); if (gameControllerModeVs.health[0] + 15 <= 100) { gameControllerModeVs.health[0] += 15; } else { gameControllerModeVs.health[0] = 100; } controller.guiManger.healthBar[0].value = gameControllerModeVs.health[0]; } else if (other.tag == "powerUp3") //power up 2 increase health by 25 { Destroy(other.gameObject); if (gameControllerModeVs.health[0] + 25 <= 100) { gameControllerModeVs.health[0] += 25; } else { gameControllerModeVs.health[0] = 100; } controller.guiManger.healthBar[0].value = gameControllerModeVs.health[0]; } }