// Use this for initialization void Start() { // Use 1x1 pixels to draw the health bars m_Background = new Texture2D(1,1); m_Background.SetPixel(0,0, Color.red); m_Background.Apply(); m_Foreground = new Texture2D(1,1); m_Foreground.SetPixel(0,0, Color.green); m_Foreground.Apply(); m_Health = GetComponent<ObjectHealth>(); }
void ShootRay() { Ray ray = cam.GetComponent <Camera>().ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { ObjectHealth health = hit.transform.GetComponent <ObjectHealth>(); if (health != null) { health.UpdateHealth(-1); } } }
void Awake() { pAnim = GameObject.Find("PlayerAnimation"); animPlayer = pAnim.GetComponent <Animator> (); player = GameObject.FindGameObjectWithTag("Player"); playerTrans = player.transform; trackingTransform = player.transform; playerHealth = this.GetComponentInChildren <ObjectHealth>(); shootingRef = this.GetComponentInChildren <Shooting>(); soundValue = 0f; }
//Cuando el jugador este en el collider, el método se activa private void OnTriggerStay2D(Collider2D other) { //Con el transcurso de los segundos, se añade 1 al contador time += Time.deltaTime; ObjectHealth hp = other.gameObject.GetComponent <ObjectHealth>(); PlayerController player = other.gameObject.GetComponent <PlayerController>(); //Si el contador es mayor que 2, el objeto que ha impactado con el collider //posee el elemento PlayerController y posee vida, entonces resta salud if (time > 2 && hp != null && player != null) { hp.ApplyDamage(damage); } }
void Awake() { animEnemy = this.GetComponentInChildren <Animator> (); enemyHealth = this.GetComponentInChildren <ObjectHealth> (); elapsedTime = 0.0f; PlayerGO = GameObject.FindGameObjectWithTag("Player"); playerTransform = PlayerGO.transform; sightDetector = new SightDetection(sightRange, sightAngle); soundDetector = new SoundDetection(hearingSensitivity); InitializeFSM(); }
private void OnTriggerEnter(Collider other) { ObjectHealth targetHealth = other.GetComponent <ObjectHealth>(); CarHealth carHealth = other.GetComponent <CarHealth>(); if (targetHealth) { targetHealth.TakeDamage(m_Damage); } else if (carHealth) { carHealth.TakeDamage(m_Damage); } Destroy(gameObject); }
void OnGUI() { clipboard = (MonoBehaviour)EditorGUILayout.ObjectField("Clipboard:", clipboard, typeof(MonoBehaviour), true); if (GUI.Button(new Rect(position.width - 90, 30, 75, 15), "Clear")) { clipboard = null; return; } GUILayout.Space(25); if (Selection.activeGameObject) { if (clipboard != null) { if (Selection.activeGameObject.GetComponent <ObjectHealth>()) { GUILayout.Label("Selection has component"); } else { GUILayout.Button("Selected object requires a valid script to paste to", GUILayout.ExpandWidth(false)); return; } if (GUILayout.Button("Paste MonoBehaviour to selected object", GUILayout.ExpandWidth(false))) { GameObject shit = Selection.activeGameObject; if (shit.GetComponent <ObjectHealth>()) { ObjectHealth oh = shit.GetComponent <ObjectHealth>(); MonoBehaviour[] ohList = oh.disableScripts; oh.disableScripts = new MonoBehaviour[oh.disableScripts.Length + 1]; for (int i = 0; i < ohList.Length; i++) { oh.disableScripts[i] = ohList[i]; } oh.disableScripts[oh.disableScripts.Length - 1] = clipboard; } } } else { GUILayout.Button("Please assign a clipboard monobehaviour!", GUILayout.ExpandWidth(false)); } } }
public override void Act(GameObject player, GameObject npc) { if (!actionFinished) { ObjectHealth npcHealth = npc.GetComponent <ObjectHealth>(); AINavAgent npcNav = npc.GetComponent <AINavAgent>(); Rigidbody npcRB = npc.GetComponent <Rigidbody>(); if (npcHealth.isDead) { npcNav.enabled = false; npc.GetComponent <ZombieController>().StartCoroutine("death"); npcRB.isKinematic = true; actionFinished = true; } } }
public IEnumerator attackBehavior() { Debug.Log("Attacking"); RaycastHit attackHit = new RaycastHit(); Vector3 attackDirection = playerTransform.position - transform.position; if (Vector3.Angle(attackDirection, transform.forward) < attackAngle) { if (Physics.Raycast(transform.position, attackDirection, out attackHit, attackRange)) { ObjectHealth objectHealth = attackHit.collider.GetComponent <ObjectHealth>(); if (objectHealth != null) { objectHealth.TakeDamage(attackDamage, attackHit.point); } } } yield return(new WaitForSeconds(1.5f)); }
public override void Reason(GameObject player, GameObject npc) { Transform playerTrans = player.transform; Transform npcTrans = npc.transform; ObjectHealth npcHealth = npc.GetComponent <ObjectHealth>(); destination = playerTrans.position; float playerDist = Vector3.Distance(npcTrans.position, destination); if (playerDist > 0.8f) { npc.GetComponent <ZombieController>().SetTransition(Transition.PlayerOutOfRange); } if (npcHealth.isDead) { Debug.Log("Switch to Dead state"); npc.GetComponent <ZombieController>().SetTransition(Transition.NoHealth); } }
void CheckForObject() { RaycastHit hitInfo; if (Physics.Raycast(rayOrigin.position, rayOrigin.forward, out hitInfo, laserRange)) { if (hitInfo.collider != null) { // Debug.Log(hitInfo.transform.name); Debug.DrawLine(rayOrigin.position, hitInfo.point, Color.red); lineRenderer.SetPosition(1, hitInfo.point); lineRenderer.colorGradient = redColor; ObjectHealth objectHealth = hitInfo.transform.GetComponent <ObjectHealth>(); // CharacterHealth characterHealth = hitInfo.transform.GetComponent<CharacterHealth>(); if (objectHealth != null /* || characterHealth != null */) { // Debug.Log("ObjectSeen"); foundObject = true; } else { foundObject = false; // Debug.Log("WrongObject"); } } } else { Debug.DrawLine(rayOrigin.position, rayOrigin.position + rayOrigin.forward * laserRange, Color.green); foundObject = false; // Debug.Log("No hit"); lineRenderer.SetPosition(1, rayOrigin.position + rayOrigin.forward * laserRange); lineRenderer.colorGradient = greenColor; } lineRenderer.SetPosition(0, rayOrigin.transform.position); }
public override void Reason(GameObject player, GameObject npc) { playerTrans = player.transform; npcTrans = npc.transform; npcHealth = npc.GetComponent <ObjectHealth>(); destination = playerTrans.position; float playerDist = Vector3.Distance(npcTrans.position, destination); if (playerDist < 12) { playerInSight = npc.GetComponent <ZombieController>().sightDetector.Detect(player, npcTrans); } //if (playerDist < 15) //{ // playerHeard = npc.GetComponent<ZombieController>().soundDetector.Detect(player.GetComponent<PlayerController>(), playerDist); //} if (playerHeard && !playerInSight) { Debug.Log("Switch to Alert state"); npc.GetComponent <ZombieController>().SetTransition(Transition.PlayerHeard); } if (playerInSight) { Debug.Log("Switch to Chase state"); npc.GetComponent <ZombieController>().SetTransition(Transition.PlayerSpotted); } if (npcHealth.isDead) { Debug.Log("Switch to Dead state"); npc.GetComponent <ZombieController>().SetTransition(Transition.NoHealth); } }
private void OnCollisionEnter2D(Collision2D collision) { //get the health compenent ObjectHealth otherHealth = collision.gameObject.GetComponent <ObjectHealth>(); //check to see if invul peroid is over if (timer >= cooldown) { timer = 0; //check if otherhealth exists if (otherHealth != null) { //damage the player otherHealth.ChangeHealth(-damage); } for (int i = 0; i < ObjectsToSpawn.Length; ++i) { //make the on damage sound effect Instantiate(ObjectsToSpawn[i], transform.position, Quaternion.identity); } //unity event setup OnCollide.Invoke(); //destory the damaged thing? if (DestroyOnCollide) { Destroy(gameObject); } // To help with sound script (Owen Whitehouse) if (collision.gameObject.tag == "Player") { sound.PlaySound("Hurt"); } } }
void Fire() { approxDeltaShotTime = System.Math.Round((Mathf.Abs(lastShot - Time.time)), 2); if ((approxDeltaShotTime - lockTime) < 0.1f) { return; } //Instantiates the prefab at the CasingSpawner loc, and sets it as a child of the handgun casing = Instantiate(prefabCasing) as GameObject; casing.transform.SetParent(this.transform, true); casing.transform.position = ejectionLoc; //Sends a reference of the just spawned casing to the GlobalBehavior Script for tracking GlobalBehavior.CasingSpawned(casing); //setup the rigidbody details for the casing casingRB = casing.GetComponent <Rigidbody>(); Vector3 casingCOM = Vector3.zero; casingCOM.y = 0.008f; casingRB.centerOfMass = casingCOM; //Sets the ejection angle, then adds a bit of randomness to it. Vector3 ejectionVelocity; ejectionVelocity = (-transform.forward + (0.8f * transform.right)) * 1.25f; ejectionVelocity.y = 1f; Vector3 randVelocity = Random.insideUnitSphere; ejectionVelocity += (randVelocity * 0.4f); //Makes the casing spin a bit Vector3 randAngularVelocity = Random.insideUnitSphere; randAngularVelocity.x = -500; //Sets the ejection velocity to a random Vec3 times the multiplier casingRB.AddForce(ejectionVelocity * ejectionMult); casingRB.AddRelativeTorque(randAngularVelocity * 10, ForceMode.VelocityChange); casing.transform.SetParent(null, true); //plays the GunSmoke particlesystem smoke.Play(); if (pelletGO != null) { pellets.Play(); } /* temp comment out for testing */ // gunLine.enabled = true; gunLine.SetPosition(0, transform.position); // Set the shootRay so that it starts at the end of the gun and points forward from the barrel. shootRay.origin = transform.position; shootRay.direction = transform.forward; if (Physics.Raycast(shootRay, out shootHit, 50f, shootableMask)) { ObjectHealth objectHealth = shootHit.collider.GetComponent <ObjectHealth>(); if (objectHealth != null) { objectHealth.TakeDamage(damageAmt, shootHit.point); } gunLine.SetPosition(1, shootHit.point); } else { gunLine.SetPosition(1, shootRay.origin + shootRay.direction * 50f); } //Sets the time of the last time this method was called lastShot = Time.time; }
private void OnPartChange(ObjectHealth item) { if (_enabled && PartChanged != null) PartChanged(item); }
public void Shoot() { currentAmmo--; //Instantiate muzzleFlash at barrel position. if (barrel) { var muzzleFlashInstance = Instantiate(muzzleFlash, barrel.transform.position, barrel.transform.rotation) as GameObject; Destroy(muzzleFlashInstance, 4); } // Instantiate spent bullet shells at shellEjectPosition. if (shell && shellEjectSpot) { Vector3 shellEjectPosition = shellEjectSpot.position; Quaternion shellEjectRotation = shellEjectSpot.rotation; GameObject shellInstance = Instantiate(shell, shellEjectPosition, shellEjectRotation); if (shellInstance.GetComponent <Rigidbody>()) { Rigidbody rigidB = shellInstance.GetComponent <Rigidbody>(); rigidB.AddForce(shellEjectSpot.forward * shellEjectSpeed, ForceMode.Impulse); } Destroy(shellInstance, 7); } //Instantiate bullet object at barrel position. if (bulletPrefab && barrel) { Instantiate(bulletPrefab, barrel.transform.position, barrel.transform.rotation); } //Play shooting sound. if (shootingSound.Length > 0) { if (audio) { audio.PlayOneShot(shootingSound [Random.Range(0, shootingSound.Length)]); } } //Raycast is instantiated at barrel position. RaycastHit hit; if (Physics.Raycast(barrel.transform.position, barrel.transform.forward, out hit, range)) { // Debug.Log(hit.transform.name); //Cause damage to object health. ObjectHealth objecthealth = hit.transform.GetComponent <ObjectHealth>(); if (objecthealth != null && objecthealth.isAlive == true) { objecthealth.TakeDamage(damage); } //Playes impact sounds, via MyHitSounds script on object hit by the raycast. MaterialType materialType = hit.transform.GetComponent <MaterialType>(); MyHitSounds myHitSounds = GetComponentInChildren <MyHitSounds>(); if (materialType != null && myHitSounds != null) { if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Brick) { var clips = myHitSounds.Brick [UnityEngine.Random.Range(0, myHitSounds.Brick.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Concrete) { var clips = myHitSounds.Concrete [UnityEngine.Random.Range(0, myHitSounds.Concrete.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Dirt) { var clips = myHitSounds.Dirt [UnityEngine.Random.Range(0, myHitSounds.Dirt.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Folliage) { var clips = myHitSounds.Folliage [UnityEngine.Random.Range(0, myHitSounds.Folliage.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } /* if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Glass) * { * var clips = myHitSounds.Glass [UnityEngine.Random.Range (0, myHitSounds.Glass.Length)]; * AudioSource.PlayClipAtPoint (clips, hit.point); * } */ if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Metall) { var clips = myHitSounds.Metall [UnityEngine.Random.Range(0, myHitSounds.Metall.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Plaster) { var clips = myHitSounds.Plaster [UnityEngine.Random.Range(0, myHitSounds.Plaster.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Rock) { var clips = myHitSounds.Rock [UnityEngine.Random.Range(0, myHitSounds.Rock.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } /* if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Water) * { * var clips = myHitSounds.Water [UnityEngine.Random.Range (0, myHitSounds.Water.Length)]; * AudioSource.PlayClipAtPoint (clips, hit.point); * }*/ if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Wood) { var clips = myHitSounds.Wood [UnityEngine.Random.Range(0, myHitSounds.Wood.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } if (materialType.TypeOfMaterial == MaterialType.MaterialTypeEnum.Flesh) { var clips = myHitSounds.Flesh [UnityEngine.Random.Range(0, myHitSounds.Flesh.Length)]; AudioSource.PlayClipAtPoint(clips, hit.point); } } //Applies force to rigidbody on bullet impact. if (hit.rigidbody != null) { hit.rigidbody.AddForce(-hit.normal * BulletImpactForce, ForceMode.Impulse); } //Instantiate hit effects on object hit via MyHitEffect script var effect = myHitEffects.GetImpactEffect(hit.transform.gameObject); if (effect == null) { return; } var effectIstance = Instantiate(effect, hit.point, new Quaternion()) as GameObject; effectIstance.transform.LookAt(hit.point + hit.normal); Destroy(effectIstance, impactLife); } //Plays an animation only when useAnimation is true. if (useAnimation) { animator.Play(fireAnimationName); } }
private void AddPartUpdate(ObjectHealth part) { _currentPlayer.HitBuffer.Add(new HealthData(part.ID, part.Health)); }
// Use this for initialization void Start() { health = GetComponent <ObjectHealth>(); spawnpoint = transform.position; }
// Update is called once per frame void Update() { if (!GameController.inCoroutine) { if (this.tag == "PowerUp") { if (teamColor == "red") { foreach (Transform spawnedObject in Spawner.redClones) { ObjectHealth curHealth = spawnedObject.GetComponent <ObjectHealth> (); if (Vector3.Distance(gameObject.transform.position, spawnedObject.transform.position) <= powerUpDistance && spawnedObject != gameObject.transform) { if (!curHealth.healthBoosted) { GameController.inCoroutine = true; curHealth.health = curHealth.health * 2; GameObject poweredUp = Instantiate(poweredParticle_health, spawnedObject.transform.position, Quaternion.identity) as GameObject; poweredUp.transform.parent = spawnedObject; curHealth.healthBoosted = true; GameController.inCoroutine = false; } } else if (curHealth.healthBoosted) { curHealth.health = curHealth.health / 2; GameObject rays = spawnedObject.FindChild("Lightshafts_Magic_Health(Clone)").gameObject; if (rays) { Destroy(rays); } curHealth.healthBoosted = false; } } } else if (teamColor == "blue") { foreach (Transform spawnedObject in Spawner.blueClones) { ObjectHealth curHealth = spawnedObject.GetComponent <ObjectHealth> (); if (Vector3.Distance(gameObject.transform.position, spawnedObject.transform.position) <= powerUpDistance && spawnedObject != gameObject.transform) { if (!curHealth.healthBoosted) { GameController.inCoroutine = true; curHealth.health = curHealth.health * 2; GameObject poweredUp = Instantiate(poweredParticle_health, spawnedObject.transform.position, Quaternion.identity) as GameObject; poweredUp.transform.parent = spawnedObject; curHealth.healthBoosted = true; GameController.inCoroutine = false; } } else if (curHealth.healthBoosted) { curHealth.health = curHealth.health / 2; GameObject rays = spawnedObject.FindChild("Lightshafts_Magic_Health(Clone)").gameObject; if (rays) { Destroy(rays); } curHealth.healthBoosted = false; } } } } else if (this.tag == "PowerUpAttack") { if (teamColor == "red") { foreach (Transform spawnedObject in Spawner.redClones) { if (spawnedObject.gameObject.tag == "Cannon" || spawnedObject.gameObject.tag == "Catapult") { ObjectHealth curHealth = spawnedObject.GetComponent <ObjectHealth> (); WeaponBehavior curWB = spawnedObject.GetComponent <WeaponBehavior> (); if (Vector3.Distance(gameObject.transform.position, spawnedObject.transform.position) <= powerUpDistance) { if (!curHealth.attackBoosted) { GameController.inCoroutine = true; curWB.cannonDamage = curWB.cannonDamage * 2; curWB.catapultDamage = curWB.catapultDamage * 2; GameObject poweredUp = Instantiate(poweredParticle_attack, spawnedObject.transform.position, Quaternion.identity) as GameObject; poweredUp.transform.parent = spawnedObject; curHealth.attackBoosted = true; GameController.inCoroutine = false; } } else if (curHealth.attackBoosted) { curWB.cannonDamage = curWB.cannonDamage / 2; curWB.catapultDamage = curWB.catapultDamage / 2; GameObject rays = spawnedObject.FindChild("Lightshafts_Magic(Clone)").gameObject; if (rays) { Destroy(rays); } curHealth.attackBoosted = false; } } } } else if (teamColor == "blue") { foreach (Transform spawnedObject in Spawner.blueClones) { if (spawnedObject.gameObject.tag == "Cannon" || spawnedObject.gameObject.tag == "Catapult") { ObjectHealth curHealth = spawnedObject.GetComponent <ObjectHealth> (); WeaponBehavior curWB = spawnedObject.GetComponent <WeaponBehavior> (); if (Vector3.Distance(gameObject.transform.position, spawnedObject.transform.position) <= powerUpDistance) { if (!curHealth.attackBoosted) { GameController.inCoroutine = true; curWB.cannonDamage = curWB.cannonDamage * 2; curWB.catapultDamage = curWB.catapultDamage * 2; GameObject poweredUp = Instantiate(poweredParticle_attack, spawnedObject.transform.position, Quaternion.identity) as GameObject; poweredUp.transform.parent = spawnedObject; curHealth.attackBoosted = true; GameController.inCoroutine = false; } } else if (curHealth.attackBoosted) { curWB.cannonDamage = curWB.cannonDamage / 2; curWB.catapultDamage = curWB.catapultDamage / 2; GameObject rays = spawnedObject.FindChild("Lightshafts_Magic(Clone)").gameObject; if (rays) { Destroy(rays); } curHealth.attackBoosted = false; } } } } } } }
void OnDestroy() { if (this.tag == "PowerUp") { if (teamColor == "red") { foreach (Transform spawnedObject in Spawner.redClones) { ObjectHealth curHealth = spawnedObject.GetComponent <ObjectHealth> (); if (curHealth.healthBoosted) { curHealth.health = curHealth.health / 2; GameObject rays = spawnedObject.FindChild("Lightshafts_Magic_Health(Clone)").gameObject; if (rays) { Destroy(rays); } curHealth.healthBoosted = false; } } } else { foreach (Transform spawnedObject in Spawner.blueClones) { ObjectHealth curHealth = spawnedObject.GetComponent <ObjectHealth> (); if (curHealth.healthBoosted) { curHealth.health = curHealth.health / 2; GameObject rays = spawnedObject.FindChild("Lightshafts_Magic_Health(Clone)").gameObject; if (rays) { Destroy(rays); } curHealth.healthBoosted = false; } } } } else if (this.tag == "PowerUpAttack") { if (teamColor == "red") { foreach (Transform spawnedObject in Spawner.redClones) { ObjectHealth curHealth = spawnedObject.GetComponent <ObjectHealth> (); WeaponBehavior curWB = spawnedObject.GetComponent <WeaponBehavior> (); if (curHealth.attackBoosted) { curWB.cannonDamage = curWB.cannonDamage / 2; curWB.catapultDamage = curWB.catapultDamage / 2; GameObject rays = spawnedObject.FindChild("Lightshafts_Magic(Clone)").gameObject; if (rays) { Destroy(rays); } curHealth.attackBoosted = false; } } } else { foreach (Transform spawnedObject in Spawner.blueClones) { ObjectHealth curHealth = spawnedObject.GetComponent <ObjectHealth> (); WeaponBehavior curWB = spawnedObject.GetComponent <WeaponBehavior> (); if (curHealth.attackBoosted) { curWB.cannonDamage = curWB.cannonDamage / 2; curWB.catapultDamage = curWB.catapultDamage / 2; GameObject rays = spawnedObject.FindChild("Lightshafts_Magic(Clone)").gameObject; if (rays) { Destroy(rays); } curHealth.attackBoosted = false; } } } } }
private void Start() { playerHealth = PlayerInfo.Instance.GetComponent <ObjectHealth>(); enemyMng = EnemyManager.Instance; }
void OnTriggerEnter(Collider co) { //Collider entered Debug.Log("Trigger entered"); bool cannonHit = GameController.onProbability(80); bool arrowHit = GameController.onProbability(90); string critAnswer = GameController.critHitEval(); if (teamColor == "red" && Spawner.blueClones.Contains(co.transform)) { Debug.Log(this.gameObject.tag); ObjectHealth health = co.GetComponent <ObjectHealth> (); if (health) { if (this.gameObject.tag == "Cannonball") { if (cannonHit) { if (critAnswer == "ultra") { health.onAttack(damage * 100); StartCoroutine(GameController.displayMessageOver(co.transform, "ULTRA CRITICAL!")); } else if (critAnswer == "crit") { health.onAttack(damage * 2); StartCoroutine(GameController.displayMessageOver(co.transform, "Critical Hit!")); } else { health.onAttack(damage); StartCoroutine(GameController.displayMessageOver(co.transform, "Hit!")); } } else { StartCoroutine(GameController.displayMessageOver(co.transform, "Miss!")); } } else { if (arrowHit) { if (critAnswer == "ultra") { health.onAttack(damage * 100); StartCoroutine(GameController.displayMessageOver(co.transform, "ULTRA CRITICAL!")); } else if (critAnswer == "crit") { health.onAttack(damage * 2); StartCoroutine(GameController.displayMessageOver(co.transform, "Critical Hit!")); } else { health.onAttack(damage); StartCoroutine(GameController.displayMessageOver(co.transform, "Hit!")); } } else { StartCoroutine(GameController.displayMessageOver(co.transform, "Miss!")); } } Destroy(gameObject); GameController.hitExecuted = true; } } else if (teamColor == "blue" && Spawner.redClones.Contains(co.transform)) { ObjectHealth health = co.GetComponent <ObjectHealth> (); if (health) { Debug.Log(this.gameObject.tag); if (this.gameObject.tag == "Cannonball") { if (cannonHit) { if (critAnswer == "ultra") { health.onAttack(damage * 100); StartCoroutine(GameController.displayMessageOver(co.transform, "ULTRA CRITICAL!")); } else if (critAnswer == "crit") { health.onAttack(damage * 2); StartCoroutine(GameController.displayMessageOver(co.transform, "Critical Hit!")); } else { health.onAttack(damage); StartCoroutine(GameController.displayMessageOver(co.transform, "Hit!")); } } else { StartCoroutine(GameController.displayMessageOver(co.transform, "Miss!")); } } else { if (arrowHit) { if (critAnswer == "ultra") { health.onAttack(damage * 100); StartCoroutine(GameController.displayMessageOver(co.transform, "ULTRA CRITICAL!")); } else if (critAnswer == "crit") { health.onAttack(damage * 2); StartCoroutine(GameController.displayMessageOver(co.transform, "Critical Hit!")); } else { health.onAttack(damage); StartCoroutine(GameController.displayMessageOver(co.transform, "Hit!")); } } else { StartCoroutine(GameController.displayMessageOver(co.transform, "Miss!")); } } Destroy(gameObject); GameController.hitExecuted = true; } } }
private void Awake() { player = PlayerInfo.Instance; anim = GetComponent <Animator>(); health = GetComponent <ObjectHealth>(); }