void FixedUpdate() { // Debug.Log (fireRotation); if (shooting) { fireTime += Time.deltaTime; shooting = false; RaycastHit hit; Vector3 fireDirection = bulletSpawn.forward; fireRotation = Quaternion.LookRotation(fireDirection); Quaternion randomRotation = Random.rotation; float currentSpread = Mathf.Lerp(0.0f, maxBulletSpreadAngle, fireTime / timeToSpread); fireRotation = Quaternion.RotateTowards(fireRotation, randomRotation, Random.Range(0.0f, currentSpread)); if (Physics.Raycast(bulletSpawn.position, fireRotation * Vector3.forward, out hit, distance, myLayMask)) { if (hit.transform.tag == "Cover") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } } if (hit.transform.tag == "Environment") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } } if (hit.transform.tag == "Target Practice") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } CauseDamage causeD = hit.transform.GetComponent <CauseDamage>(); CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>(); if (causeD.addPoints >= 125 && causeD.addPoints <= 400) { HUDScoreText.currentScore += 125; } if (causeD.addPoints >= 401 && causeD.addPoints <= 1001) { HUDScoreText.currentScore += 1000; } else if (causeD.addPoints >= 100 && causeD.addPoints <= 124) { HUDScoreText.currentScore += 100; } else if (causeD.addPoints >= 26 && causeD.addPoints <= 99) { HUDScoreText.currentScore += 50; } else if (causeD.addPoints >= 6 && causeD.addPoints <= 25) { HUDScoreText.currentScore += 25; } else if (causeD.addPoints >= 2 && causeD.addPoints <= 5) { HUDScoreText.currentScore += 5; } else if (causeD.addPoints >= 1 && causeD.addPoints <= 2) { HUDScoreText.currentScore += 1; } causeDD.shots++; } else if (hit.collider.tag == "TutorialDoors") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>(); if (causeDD != null) { causeDD.shots++; } } else if (hit.collider.tag == "Head") { GameMasterObject.totalHeadShots++; GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 7; blockCharLife.gotShot = true; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(headDamage * attackBooster, hit.transform.position); //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position); } } else if (hit.collider.tag == "Doors") { //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 100, hit.transform.position); } else if (hit.collider.tag == "Body") { GameMasterObject.totalBodyShots++; GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 4; blockCharLife.gotShot = true; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(bodyDamage * attackBooster, hit.transform.position); //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position); } } else if (hit.collider.tag == "Weapon") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } RocketDamage rocketDamage = hit.collider.GetComponent <RocketDamage> (); if (rocketDamage != null) { rocketDamage.TakeDamage(3 * attackBooster); } } else if (hit.collider.tag == "Poppy") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> (); if (poppyLife != null) { poppyLife.TakeDamage(1); } } else if (hit.collider.tag == "Bobby") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> (); if (poppyLife != null) { poppyLife.TakeDamage(75); } PoppyLife poppyLife2 = hit.collider.GetComponentInParent <PoppyLife> (); if (poppyLife2 != null) { poppyLife2.TakeDamage(75); } } else if (hit.collider.tag == "Mask") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } TalkingHeadLife headLift = hit.collider.GetComponent <TalkingHeadLife> (); if (headLift != null) { headLift.TakeDamage(75); } } else if (hit.collider.tag == "Legs") { GameMasterObject.totalLegShots++; GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharlife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharlife != null) { blockCharlife.shots += 3; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(legDamage * attackBooster, hit.transform.position); //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position); } } else if (hit.collider.tag == "Arms") { GameMasterObject.totalArmShots++; GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharlife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharlife != null) { blockCharlife.shots += 2; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(armDamage * attackBooster, hit.transform.position); //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position); } } } } }
void OnTriggerEnter(Collider gotEm) { if (gotEm && !hitYet) { //sounds.PlayOneShot (groundHit); CameraShake.InstanceSM1.ShakeSM1(amplitude, duration); Collider[] cols = Physics.OverlapSphere(transform.position, radius /*, m_HitMask*/); for (int i = 0; i < cols.Length; i++) { Rigidbody targetRigidBody = cols[i].GetComponentInParent <Rigidbody>(); if (!targetRigidBody) { //continue; BlockCharacterLife causeDDD = cols[i].GetComponentInParent <BlockCharacterLife>(); if (causeDDD != null) { causeDDD.shots += damage; } continue; } targetRigidBody.AddExplosionForce(force, transform.position, radius); if (targetRigidBody != null) { targetRigidBody.GetComponentInParent <Rigidbody> ().AddExplosionForce(force, transform.position, radius, 5.9f, ForceMode.Impulse); // impacts[currentImpact].transform.position = targetRigidBody.transform.position; // impacts[currentImpact].GetComponent<ParticleSystem>().Play(); // // if(++currentImpact >= maxImpacts) // { // currentImpact = 0; // } CauseDamageDestroy causeDD = targetRigidBody.GetComponentInParent <CauseDamageDestroy>(); if (causeDD != null) { causeDD.shots += damage; } RocketDamage rocketDamage = targetRigidBody.GetComponent <RocketDamage> (); if (rocketDamage != null) { rocketDamage.shots += damage; } BlockCharacterLife causeDDDD = targetRigidBody.GetComponentInParent <BlockCharacterLife>(); if (causeDDDD != null) { causeDDDD.shots += damage; } BlockCharacterLife causeNinja = targetRigidBody.GetComponent <BlockCharacterLife>(); if (causeNinja != null) { causeNinja.shots += damage; } PoppyLife popLife = targetRigidBody.GetComponent <PoppyLife> (); if (popLife != null) { popLife.TakeDamage(365 * damageBooster); } TalkingHeadLife headLife = targetRigidBody.GetComponent <TalkingHeadLife> (); if (headLife != null) { headLife.TakeDamage(365 * damageBooster); } EnemyHealth1 enemyHealth = targetRigidBody.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(damage * damageBooster, cols[i].transform.position); } } } hitYet = true; Instantiate(impactToUse, instanPoint.position, Quaternion.identity); this.gameObject.SetActive(false); } }
void OnCollisionEnter(Collision other) { // Debug.Log (other.collider.tag); if (other.collider.tag == "Enemy") { EnemyHealth1 enemyHealth = other.gameObject.GetComponent <EnemyHealth1>(); if (enemyHealth != null) { enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position); Instantiate(explosion, transform.position, transform.rotation); } } if (other.collider.tag == "Body") { // Debug.Log ("body"); EnemyHealth1 enemyHealth = other.collider.GetComponentInParent <EnemyHealth1>(); if (enemyHealth != null) { enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position); Instantiate(explosion, transform.position, transform.rotation); } BlockCharacterLife blockLife = other.gameObject.GetComponentInParent <BlockCharacterLife> (); if (blockLife != null) { // Debug.Log ("notnull2"); blockLife.shots += 75; } BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> (); if (blockLife2 != null) { // Debug.Log ("notnull2"); blockLife2.shots += 75; } } else if (other.collider.tag == "Head") { EnemyHealth1 enemyHealth = other.collider.GetComponentInParent <EnemyHealth1>(); if (enemyHealth != null) { enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position); Instantiate(explosion, transform.position, transform.rotation); } BlockCharacterLife blockLife = other.gameObject.GetComponentInParent <BlockCharacterLife> (); if (blockLife != null) { blockLife.shots += 150; } BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> (); if (blockLife2 != null) { blockLife2.shots += 150; } } else if (other.collider.tag == "Arms") { EnemyHealth1 enemyHealth = other.collider.GetComponentInParent <EnemyHealth1>(); if (enemyHealth != null) { enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position); Instantiate(explosion, transform.position, transform.rotation); } BlockCharacterLife blockLife = other.gameObject.GetComponentInParent <BlockCharacterLife> (); if (blockLife != null) { blockLife.shots += 10; } BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> (); if (blockLife2 != null) { blockLife2.shots += 10; } } else if (other.collider.tag == "Target Practice") { CauseDamage causeD = other.collider.transform.GetComponent <CauseDamage>(); CauseDamageDestroy causeDD = other.gameObject.GetComponentInParent <CauseDamageDestroy>(); if (causeD.addPoints >= 125 && causeD.addPoints <= 400) { HUDScoreText.currentScore += 125; } if (causeD.addPoints >= 401 && causeD.addPoints <= 1001) { HUDScoreText.currentScore += 1000; } else if (causeD.addPoints >= 100 && causeD.addPoints <= 124) { HUDScoreText.currentScore += 100; } else if (causeD.addPoints >= 26 && causeD.addPoints <= 99) { HUDScoreText.currentScore += 50; } else if (causeD.addPoints >= 6 && causeD.addPoints <= 25) { HUDScoreText.currentScore += 25; } else if (causeD.addPoints >= 2 && causeD.addPoints <= 5) { HUDScoreText.currentScore += 5; } else if (causeD.addPoints >= 1 && causeD.addPoints <= 2) { HUDScoreText.currentScore += 1; } causeDD.shots++; } else if (other.collider.tag == "Poppy") { PoppyLife poppyLife = other.gameObject.GetComponent <PoppyLife> (); if (poppyLife != null) { poppyLife.TakeDamage(attackDamage); } } else if (other.collider.tag == "Bobby") { PoppyLife poppyLife = other.gameObject.GetComponent <PoppyLife> (); if (poppyLife != null) { poppyLife.TakeDamage(attackDamage * 2); } } else if (other.collider.tag == "Mask") { TalkingHeadLife headLift = other.gameObject.GetComponent <TalkingHeadLife> (); if (headLift != null) { headLift.TakeDamage(attackDamage * 2); } } else if (other.collider.tag == "Legs") { EnemyHealth1 enemyHealth = other.collider.GetComponentInParent <EnemyHealth1>(); if (enemyHealth != null) { enemyHealth.TakeDamage(attackDamage * attackBoost, other.transform.position); Instantiate(explosion, transform.position, transform.rotation); } BlockCharacterLife blockLife = other.gameObject.GetComponentInParent <BlockCharacterLife> (); if (blockLife != null) { blockLife.shots += 10; } BlockCharacterLife blockLife2 = other.gameObject.GetComponentInParent <BlockCharacterLife> (); if (blockLife2 != null) { blockLife2.shots += 10; } } else if (other.gameObject.tag == "Cover") { Destroy(this.gameObject); Instantiate(explosion, transform.position, transform.rotation); } else { Destroy(this.gameObject); } Destroy(this.gameObject); }
void FixedUpdate() { if (shooting) { shooting = false; RaycastHit hit; if (Physics.Raycast(bulletSpawn.position, bulletSpawn.forward, out hit, distance, myLayerMask)) { // Debug.Log (hit.collider.tag); if (hit.transform.tag == "Cover") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } } if (hit.transform.tag == "Environment") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } } if (hit.transform.tag == "Target Practice") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } CauseDamage causeD = hit.transform.GetComponent <CauseDamage>(); CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>(); if (causeD.addPoints >= 125 && causeD.addPoints <= 400) { HUDScoreText.currentScore += 125; } if (causeD.addPoints >= 401 && causeD.addPoints <= 1001) { HUDScoreText.currentScore += 1000; } else if (causeD.addPoints >= 100 && causeD.addPoints <= 124) { HUDScoreText.currentScore += 100; } else if (causeD.addPoints >= 26 && causeD.addPoints <= 99) { HUDScoreText.currentScore += 50; } else if (causeD.addPoints >= 6 && causeD.addPoints <= 25) { HUDScoreText.currentScore += 25; } else if (causeD.addPoints >= 2 && causeD.addPoints <= 5) { HUDScoreText.currentScore += 5; } else if (causeD.addPoints >= 1 && causeD.addPoints <= 2) { HUDScoreText.currentScore += 1; } causeDD.shots += 1 * attackBooster; } else if (hit.collider.tag == "TutorialDoors") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>(); if (causeDD != null) { causeDD.shots += 2 * attackBooster; } } else if (hit.collider.tag == "Head") { GameMasterObject.totalHeadShots++; GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 15 * attackBooster; blockCharLife.gotShot = true; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(headDamage * attackBooster, hit.transform.position); //hit.rigidbody.AddForceAtPosition(new Vector3(Random.Range(1,10), Random.Range(1, 10), Random.Range(1, 10)) * 10, hit.transform.position); } } else if (hit.collider.tag == "Weapon") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } RocketDamage rocketDamage = hit.collider.GetComponent <RocketDamage> (); if (rocketDamage != null) { rocketDamage.TakeDamage(6 * attackBooster); } } else if (hit.collider.tag == "Poppy") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> (); if (poppyLife != null) { poppyLife.TakeDamage(2 * attackBooster); } } else if (hit.collider.tag == "Bobby") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> (); if (poppyLife != null) { poppyLife.TakeDamage(125 * attackBooster); } PoppyLife poppyLife2 = hit.collider.GetComponentInParent <PoppyLife> (); if (poppyLife2 != null) { poppyLife2.TakeDamage(125 * attackBooster); } } else if (hit.collider.tag == "Mask") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } TalkingHeadLife headLift = hit.collider.GetComponent <TalkingHeadLife> (); if (headLift != null) { headLift.TakeDamage(75 * attackBooster); } } else if (hit.collider.tag == "Body") { GameMasterObject.totalBodyShots++; GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.collider.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 5 * attackBooster; blockCharLife.gotShot = true; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(bodyDamage * attackBooster, hit.transform.position); //other.rigidbody.AddForceAtPosition(Vector3.forward * 10, other.transform.position); } } else if (hit.collider.tag == "Legs") { GameMasterObject.totalLegShots++; GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 4 * attackBooster; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(legDamage * attackBooster, hit.transform.position); //other.rigidbody.AddForceAtPosition(Vector3.forward * 10, other.transform.position); } } else if (hit.collider.tag == "Arms") { GameMasterObject.totalArmShots++; GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 3 * attackBooster; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(armDamage * attackBooster, hit.transform.position); //other.rigidbody.AddForceAtPosition(Vector3.forward * 10, other.transform.position); } } } } }
void FixedUpdate() { if (shooting) { shooting = false; for (int i = 0; i < shotFragments; i++) { RaycastHit hit; Vector3 fireDirection = bulletSpawn.forward; Quaternion fireRotation = Quaternion.LookRotation(fireDirection); Quaternion randomRotation = Random.rotation; //float currentSpread = Mathf.Lerp (0.0f, maxBulletSpreadAngle, fireTime / timeToSpread); fireRotation = Quaternion.RotateTowards(fireRotation, randomRotation, Random.Range(0.0f, spreadAngle)); if (Physics.Raycast(bulletSpawn.position, fireRotation * Vector3.forward, out hit, distance, myLayerMask)) { if (hit.transform.tag == "Cover") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } } if (hit.transform.tag == "Environment") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } } if (hit.transform.tag == "Target Practice") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } CauseDamage causeD = hit.transform.GetComponent <CauseDamage>(); CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>(); if (causeD.addPoints >= 125 && causeD.addPoints <= 400) { HUDScoreText.currentScore += 125; } if (causeD.addPoints >= 401 && causeD.addPoints <= 1001) { HUDScoreText.currentScore += 1000; } else if (causeD.addPoints >= 100 && causeD.addPoints <= 124) { HUDScoreText.currentScore += 100; } else if (causeD.addPoints >= 26 && causeD.addPoints <= 99) { HUDScoreText.currentScore += 50; } else if (causeD.addPoints >= 6 && causeD.addPoints <= 25) { HUDScoreText.currentScore += 25; } else if (causeD.addPoints >= 2 && causeD.addPoints <= 5) { HUDScoreText.currentScore += 5; } else if (causeD.addPoints >= 1 && causeD.addPoints <= 2) { HUDScoreText.currentScore += 1; } causeDD.shots++; } else if (hit.collider.tag == "TutorialDoors") { impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } CauseDamageDestroy causeDD = hit.transform.GetComponentInParent <CauseDamageDestroy>(); if (causeDD != null) { causeDD.shots += 2; } } else if (hit.collider.tag == "Head") { GameMasterObject.totalShotGunHits++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 10; if (!blockCharLife.reallyGotShot) { blockCharLife.reallyGotShot = true; } } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(headDamage * attackBooster, hit.transform.position); //hit.transform.GetComponentInParent<Rigidbody> ().AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force); } //hit.collider.attachedRigidbody.AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force); } else if (hit.collider.tag == "Weapon") { GameMasterObject.totalShotGunHits++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } RocketDamage rocketDamage = hit.collider.GetComponent <RocketDamage> (); if (rocketDamage != null) { rocketDamage.TakeDamage(11 * attackBooster); } } else if (hit.collider.tag == "Poppy") { GameMasterObject.totalShotGunHits++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> (); if (poppyLife != null) { poppyLife.TakeDamage(3); } } else if (hit.collider.tag == "Bobby") { GameMasterObject.totalShotGunHits++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } PoppyLife poppyLife = hit.collider.GetComponent <PoppyLife> (); if (poppyLife != null) { poppyLife.TakeDamage(255); } PoppyLife poppyLife2 = hit.collider.GetComponentInParent <PoppyLife> (); if (poppyLife2 != null) { poppyLife2.TakeDamage(255); } } else if (hit.collider.tag == "Mask") { GameMasterObject.totalHitShots++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } TalkingHeadLife headLift = hit.collider.GetComponent <TalkingHeadLife> (); if (headLift != null) { headLift.TakeDamage(75); } } else if (hit.collider.tag == "Body") { GameMasterObject.totalShotGunHits++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.collider.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 6; if (!blockCharLife.reallyGotShot) { blockCharLife.reallyGotShot = true; } } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(bodyDamage * attackBooster, hit.transform.position); //hit.transform.GetComponentInParent<Rigidbody>().AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force); } //hit.collider.attachedRigidbody.AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force); } else if (hit.collider.tag == "Legs") { GameMasterObject.totalShotGunHits++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 3; } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(legDamage * attackBooster, hit.transform.position); //hit.transform.GetComponentInParent<Rigidbody>().AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force); } //hit.collider.attachedRigidbody.AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force); } else if (hit.collider.tag == "Arms") { GameMasterObject.totalShotGunHits++; impacts[currentImpact].transform.position = hit.point; impacts[currentImpact].GetComponent <ParticleSystem>().Play(); if (++currentImpact >= maxImpacts) { currentImpact = 0; } BlockCharacterLife blockCharLife = hit.transform.GetComponentInParent <BlockCharacterLife>(); if (blockCharLife != null) { blockCharLife.shots += 2; if (!blockCharLife.reallyGotShot) { blockCharLife.reallyGotShot = true; } } EnemyHealth1 enemyHealth = hit.collider.GetComponentInParent <EnemyHealth1> (); if (enemyHealth != null) { enemyHealth.TakeDamage(armDamage * attackBooster, hit.transform.position); //hit.transform.GetComponentInParent<Rigidbody>().AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force); } //hit.collider.attachedRigidbody.AddForceAtPosition (hit.collider.transform.position - hit.point * pushForce, hit.point, ForceMode.Force); } } } } }