public void ApplyDamage(float damage) { health -= damage; if (health_UI != null) { health_UI.fillAmount = health / 100f; } if (health <= 0) { soundFX.Die(); GetComponent <Animator>().enabled = false; StartCoroutine(AllowRotate()); if (isPlayer) { GetComponent <KnightController>().enabled = false; Camera.main.transform.SetParent(null); GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG). GetComponent <EnemyController>().enabled = false; GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG). GetComponent <NavMeshAgent>().enabled = false; GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG). GetComponent <Animator>().SetInteger(parameterAnim.condition, 0); } else { GetComponent <EnemyController>().enabled = false; GetComponent <NavMeshAgent>().enabled = false; } } }
public void ApplyDamage(float damage) { if (ShieldActivated) { return; } health -= damage; if (healthUI != null) { healthUI.fillAmount = health / 100f; } if (health <= 0) { soundFX.Die(); StartCoroutine(AllowRotate()); GetComponent <Animator>().enabled = false; if (isPlayer) { GetComponent <PlayeAttackInput>().enabled = false; GetComponent <PlayerMove>().enabled = false; Camera.main.transform.SetParent(null); GameObject.FindGameObjectWithTag("Enemy").GetComponent <EnemyCOntroller>().enabled = false; } else { GetComponent <EnemyCOntroller>().enabled = false; GetComponent <NavMeshAgent>().enabled = false; } } }
public void ApplyDamage(float damage) { if (shieldActivated) { comboSoundCounter = 0; health -= 1; soundFX.Block(); } else { comboSoundCounter++; health -= damage; soundFX.Hurt(); if (comboSoundCounter >= 3) { StartCoroutine(ComboNoiseFunction()); } } if (health_UI != null) { health_UI.fillAmount = health / 100f; } if (health <= 0) { Scene currentScene = SceneManager.GetActiveScene(); string sceneName = currentScene.name; soundFX.Die(); GetComponent <Animator>().enabled = false; //print("the character died"); StartCoroutine(AllowRotate()); if (isPlayer) { GetComponent <PlayerMove>().enabled = false; GetComponent <PlayerAttackInput>().enabled = false; //the player is not the parent game object //for the camera anymore Camera.main.transform.SetParent(null); if (sceneName == "gameplay") { GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG) .GetComponent <EnemyController>().enabled = false; } } else { GetComponent <EnemyController>().enabled = false; GetComponent <NavMeshAgent>().enabled = false; } } }//apply damage
public void ApplyDamage(float damage) { if (shieldActived) { return; } health -= damage; if (healthBar != null) { healthBar.fillAmount = health / 100f; } if (health <= 0) { GetComponent <Animator>().enabled = false; soundFX.Die(); StartCoroutine(AllowRotate()); if (isPlayer) { if (GetComponent <PlayerMove>() != null && GetComponent <PlayerAttack>() != null) { GetComponent <PlayerMove>().enabled = false; GetComponent <PlayerAttack>().enabled = false; } Camera.main.transform.SetParent(null); if (GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG) .GetComponent <EnemyController>() != null) { GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG) .GetComponent <EnemyController>().enabled = false; } GameManager.Instance.Lose(); } else { GetComponent <EnemyController>().enabled = false; GetComponent <NavMeshAgent>().enabled = false; GameManager.Instance.Win(10); } } }
public void applyDamage(float damage) { if (shieldActivated) { return; } health -= damage; if (health_UI != null) { health_UI.fillAmount = health / 100f; // we divide over 100 cause the range of health is between 0 and 1 } if (health <= 0) { soundFX.Die(); GetComponent <Animator>().enabled = false; print("He Died"); // Print in Console StartCoroutine(AllowRotate()); if (isPlayer) { GetComponent <Playermove>().enabled = false; GetComponent <PlayerAttackInput>().enabled = false; // when he died camera will follow him cause it's a chiled of warior so i set it to null // when player die it should make the camera stop following the player (error) and the enemy stop attacking (working) Camera.main.transform.SetParent(null); GameObject.FindWithTag(Tags.ENEMY_TAG).GetComponent <EnemyController>().enabled = false; SceneManager.LoadScene("GameOver"); } else { GetComponent <EnemyController>().enabled = false; GetComponent <NavMeshAgent>().enabled = false; // we must write using UnityEngine.AI; SceneManager.LoadScene("YouWin"); } } }
public void ApplyDamage(float damage) { if (shieldActivated) { return; } health -= damage; if (health_UI != null) { health_UI.fillAmount = health / 100f; } if (health <= 0) { soundFX.Die(); GetComponent <Animator>().enabled = false; StartCoroutine(AllowRotate()); //Starts death animation if (isPlayer) { GetComponent <PlayerMovement>().enabled = false; GetComponent <PlayerAttackInput>().enabled = false; //Camera.main.transform.SetParent(null); //To prevent unnecessary rotation GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG) .GetComponent <EnemyController>().enabled = false; GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG) .GetComponent <NavMeshAgent>().enabled = false; } else { GetComponent <EnemyController>().enabled = false; GetComponent <NavMeshAgent>().enabled = false; } } } //apply damage
public void ApplyDamage(float damage) { if (shieldActivated) { return; } health -= damage; if (health_UI != null) { health_UI.fillAmount = health / 100f; } if (health <= 0) { soundFX.Die(); GetComponent <Animator>().enabled = false; StartCoroutine(AllowRotate()); if (isPlayer) { GetComponent <PlayerMove>().enabled = false; GetComponent <PlayerAttackInput>().enabled = false; Camera.main.transform.SetParent(null); GameObject.FindGameObjectWithTag(Tags.ENEMY_TAG) .GetComponent <EnemyController>().enabled = false; LevelControlScript.instance.youLose(); } else { GetComponent <EnemyController>().enabled = false; GetComponent <NavMeshAgent>().enabled = false; LevelControlScript.instance.youWin(); } } }