void OnCollisionEnter(Collision col) { if (!isServer) { return; } if (col.gameObject.CompareTag("VehicleTeam0") && gameObject.CompareTag("BulletTeam1") || col.gameObject.CompareTag("VehicleTeam1") && gameObject.CompareTag("BulletTeam0")) { GuiVehicle gui = col.gameObject.GetComponent <GuiVehicle> (); gui.TakeDamage(hitPoints); CmdDoExplosionHitPlayer(); Destroy(gameObject); } else if (!col.gameObject.CompareTag("VehicleTeam0") && !col.gameObject.CompareTag("VehicleTeam1")) // && !col.gameObject.transform.parent.gameObject.CompareTag ("Vehicle") // && !col.gameObject.CompareTag ("Vehicle") { CmdDoExplosion(); Destroy(gameObject); } //Destroy (gameObject); }
void OnCollisionEnter(Collision col) { if (!isServer) { return; } if (col.gameObject.CompareTag("VehicleTeam0") && gameObject.CompareTag("BulletTeam1") || col.gameObject.CompareTag("VehicleTeam1") && gameObject.CompareTag("BulletTeam0")) { //Physics.IgnoreCollision(col.gameObject.GetComponent<Collider>(), GetComponent<Collider>()); bool found = false; //for (int i = 0; i < hitEnemies.Count; i++) { if (hitEnemies.Contains(col.gameObject)) { found = true; } else { hitEnemies.Add(col.gameObject); } //} if (!found) { GuiVehicle gui = col.gameObject.GetComponent <GuiVehicle> (); gui.TakeDamage(hitPoints); CmdDoExplosion(); } //Destroy (gameObject); } // else if (!col.gameObject.CompareTag ("VehicleTeam0") && !col.gameObject.CompareTag ("VehicleTeam1")) { //print ("collision " + col.gameObject.name); //Destroy (gameObject); //} }
void OnCollisionEnter(Collision col) { if (!isServer) { return; } if (col.gameObject.CompareTag("VehicleTeam0") && gameObject.CompareTag("BulletTeam1") || col.gameObject.CompareTag("VehicleTeam1") && gameObject.CompareTag("BulletTeam0")) { GuiVehicle gui = col.gameObject.GetComponent <GuiVehicle> (); //gui.life -= hitPoints; gui.TakeDamage(hitPoints); CmdDoExplosionHitPlayer(); //detonator.Explode (); } else if (!col.gameObject.CompareTag("VehicleTeam0") && !col.gameObject.CompareTag("VehicleTeam1")) { //detonator.Explode (); CmdDoExplosion(); } }
void OnCollisionEnter(Collision col) { if (!isServer) { return; } if (col.gameObject.CompareTag("VehicleTeam0") && gameObject.CompareTag("BulletTeam1") || col.gameObject.CompareTag("VehicleTeam1") && gameObject.CompareTag("BulletTeam0")) { GuiVehicle gui = col.gameObject.GetComponent <GuiVehicle> (); gui.TakeDamage((int)(hitPoints * FACTOR_HIT_PLAYER)); CmdDoExplosionHitPlayer(); Destroy(gameObject); } else if (!col.gameObject.CompareTag("VehicleTeam0") && !col.gameObject.CompareTag("VehicleTeam1")) // && !col.gameObject.CompareTag ("Vehicle") { if (gameObject.CompareTag("BulletTeam1")) { GameObject[] playersEnemy = GameObject.FindGameObjectsWithTag("VehicleTeam0"); for (int i = 0; i < playersEnemy.Length; i++) { if (Vector3.Distance(playersEnemy[i].transform.position, transform.position) <= radius) { GuiVehicle gui = playersEnemy[i].GetComponent <GuiVehicle> (); if (gui != null) { gui.TakeDamage(hitPoints); CmdDoExplosion(); //Destroy (gameObject); } //break; } } } else if (gameObject.CompareTag("BulletTeam0")) { GameObject[] playersEnemy = GameObject.FindGameObjectsWithTag("VehicleTeam1"); for (int i = 0; i < playersEnemy.Length; i++) { if (Vector3.Distance(playersEnemy[i].transform.position, transform.position) <= radius) { GuiVehicle gui = playersEnemy[i].GetComponent <GuiVehicle> (); if (gui != null) { gui.TakeDamage(hitPoints); CmdDoExplosion(); //Destroy (gameObject); } //break; } } } CmdDoExplosionGround(); Destroy(gameObject); //print ("onground"); } }
// Update is called once per frame void Update() { if (!isServer) { return; } timerMineExplosion += Time.deltaTime; if (timerMineExplosion >= timerMine) { CmdDoExplosionHitPlayer(); Destroy(gameObject); } else { body.velocity = Vector3.zero; body.angularVelocity = Vector3.zero; if (gameObject.CompareTag("BulletTeam1")) { bool damage = false; GameObject[] playersEnemy = GameObject.FindGameObjectsWithTag("VehicleTeam0"); for (int i = 0; i < playersEnemy.Length; i++) { if (Vector3.Distance(playersEnemy[i].transform.position, transform.position) <= radius) { GuiVehicle gui = playersEnemy[i].GetComponent <GuiVehicle>(); if (gui != null) { gui.TakeDamage(hitPoints); damage = true; } //break; } } if (damage) { CmdDoExplosionHitPlayer(); Destroy(gameObject); } } else if (gameObject.CompareTag("BulletTeam0")) { bool damage = false; GameObject[] playersEnemy = GameObject.FindGameObjectsWithTag("VehicleTeam1"); for (int i = 0; i < playersEnemy.Length; i++) { if (Vector3.Distance(playersEnemy[i].transform.position, transform.position) <= radius) { GuiVehicle gui = playersEnemy[i].GetComponent <GuiVehicle>(); if (gui != null) { gui.TakeDamage(hitPoints); damage = true; } //break; } } if (damage) { CmdDoExplosionHitPlayer(); Destroy(gameObject); } } } }