public void CollisionFaker(bullet bulletScript) { if (canSub) { GameObject newStump = (GameObject)Instantiate(fireStump, gameObject.transform.position, gameObject.transform.rotation); newStump.SetActive(true); } HUDInfo.UpdateDestruction(5); //AudioDB.destroyTree.Play(); Destroy(gameObject); }
void OnCollisionEnter(Collision col) { if (col.gameObject.layer == 11) { bullet bulletScript = col.gameObject.GetComponent <bullet>(); if (bulletScript != null) { bulletScript.OnCollided(col); HUDInfo.UpdateDestruction(1); } } }
public void abductCitizen() { if (citizenCount >= 2) { HUDInfo.UpdateDestruction(HUDInfo.citizenWorth * 4); citizenCount = citizenCount - 2; } else if (citizenCount == 1) { HUDInfo.UpdateDestruction(HUDInfo.citizenWorth * 2); citizenCount = citizenCount - 1; } }
public void CollisionFaker(bullet bulletScript) { if (canSub) { GameObject newStump = (GameObject)Instantiate(deadCar, gameObject.transform.position, gameObject.transform.rotation); newStump.transform.localScale = scale; newStump.GetComponent <Renderer>().materials = gameObject.GetComponent <Renderer>().materials; newStump.SetActive(true); } HUDInfo.UpdateDestruction(5); AudioDB.destroyTree.Play(); Destroy(gameObject); }
//adds points for each citizen kill private void killCitizens() { HUDInfo.UpdateDestruction(citizenCount * HUDInfo.citizenWorth); }
public void CollisionFaker(bullet bulletScript) { if (bulletScript == null) { Debug.Log("CollisionFaker null bulletScript!"); return; } //Debug.Log("Calling CollisionFaker()"); Debug.Log("bulletScript_type: " + bulletScript.getType()); switch (bulletScript.getType()) { case -1: break; case 0: //Right Trigger rightBulletHitCount++; if (rightBulletHitCount >= rightHitDestructionAmount && !isDestroyed) { Debug.Log("Destroying the building: " + name); destructMesh.SetActive(true); GameObject.Destroy(gameObject); HUDInfo.UpdateDestruction(destructionAmount); AudioDB.destroyBuilding.Play(); isDestroyed = true; if (fountainQuitScript != null) { fountainQuitScript.quitParticles(); } killCitizens(); } else { HUDInfo.UpdateDestruction(destructionBit / rightHitDestructionAmount); } break; case 1: //A weapon weapon1HitCount++; //Debug.Log("A weapon hit, count: " + weapon1HitCount); if (weapon1HitCount >= weapon1HitDestructionAmount && !isDestroyed) { Debug.Log("Destroying the building: " + name); destructMesh.SetActive(true); GameObject.Destroy(gameObject); HUDInfo.UpdateDestruction(destructionAmount); isDestroyed = true; AudioDB.destroyBuilding.Play(); if (fountainQuitScript != null) { fountainQuitScript.quitParticles(); } killCitizens(); } else { HUDInfo.UpdateDestruction(Mathf.Clamp((int)(destructionBit / weapon1HitDestructionAmount), (int)1, (int)100)); } break; case 2: //B weapon weapon2HitCount++; //Debug.Log("B weapon hit, count: " + weapon2HitCount); if (weapon2HitCount >= weapon2HitDestructionAmount && !isDestroyed) { Debug.Log("Destroying the building: " + name); destructMesh.SetActive(true); GameObject.Destroy(gameObject); HUDInfo.UpdateDestruction(destructionAmount); isDestroyed = true; AudioDB.destroyBuilding.Play(); if (fountainQuitScript != null) { fountainQuitScript.quitParticles(); } killCitizens(); } else { HUDInfo.UpdateDestruction(Mathf.Clamp((int)(destructionBit / weapon2HitDestructionAmount), (int)1, (int)100)); } break; case 3: break; case 4: break; default: Debug.Log("building collision: unsupported weaponType. Type: " + bulletScript.getType()); break; } }
void OnCollisionEnter(Collision col) { Debug.Log("Colliding!"); if (col.rigidbody.gameObject.name == gameObject.name) { //colliding with ourselves, ignore Debug.Log("Colliding with ourselves"); } else { //Colliding on impactable if (col.gameObject.layer == 11) { //Debug.Log(gameObject.name + " collided with " + col.gameObject.name); bullet bulletScript = col.gameObject.GetComponent <bullet>(); int weaponType = -2; if (bulletScript != null) { weaponType = bulletScript.getType(); } switch (weaponType) { case -1: break; case 0: //Right Trigger rightBulletHitCount++; if (bulletScript != null) { bulletScript.OnCollided(col); } if (rightBulletHitCount >= rightHitDestructionAmount) { Debug.Log("Destroying the building: " + name); destructMesh.SetActive(true); GameObject.Destroy(gameObject); HUDInfo.UpdateDestruction(destructionAmount); } else { HUDInfo.UpdateDestruction(destructionBit); } break; case 1: //A weapon break; case 2: break; case 3: break; case 4: break; default: Debug.Log("building collision: unsupported weaponType. Type: " + weaponType); break; } bulletScript.OnCollided(col); } } }