public static void GetHit() { characterController.GetHit(); Health -= 10; if (Health <= 0) { characterController.Death(); } }
public static void AIHit() { characterController.GetHit(); health -= 10; if (health <= 0) { characterController.Death(); AIDead = true; } }
void OnTriggerEnter(Collider col) { //Attach key to player back if (col.gameObject.tag == "Player") { hpScript = col.GetComponentInChildren <HealthBarScript>(); animScript = col.GetComponentInChildren <RPGCharacterControllerFREE>(); //remove heart from player if (hpScript.health >= 0) { hpScript.RemoveHearth(hpScript.health); hpScript.health--; } //play hit animation animScript.GetHit(); //play sound //stop firing new projectiles if health is lower than 0 if (hpScript.health > 0) { enemyScript.playerAlive = false; Destroy(gameObject); } //destroy gameobject Destroy(gameObject); } if (col.gameObject.tag == "Obstacle") { if (col.name == "Mirror") { gameObject.transform.Rotate(new Vector3(180f, 0, 0)); speed = speed * -1; bounced = true; } else { Destroy(gameObject); } } if (col.gameObject.tag == "EnemyT1") { Destroy(gameObject); } }
void OnGUI() { if (!rpgCharacter.isDead) { if (rpgCharacter.canAction && !rpgCharacter.isRelax && !rpgCharacter.useNavMesh) { if (rpgCharacter.isGrounded) { if (GUI.Button(new Rect(25, 15, 100, 30), "Roll Forward")) { rpgCharacter.targetDashDirection = transform.forward; StartCoroutine(rpgCharacter._Roll(1)); } if (GUI.Button(new Rect(130, 15, 100, 30), "Roll Backward")) { rpgCharacter.targetDashDirection = -transform.forward; StartCoroutine(rpgCharacter._Roll(3)); } if (GUI.Button(new Rect(25, 45, 100, 30), "Roll Left")) { rpgCharacter.targetDashDirection = -transform.right; StartCoroutine(rpgCharacter._Roll(4)); } if (GUI.Button(new Rect(130, 45, 100, 30), "Roll Right")) { rpgCharacter.targetDashDirection = transform.right; StartCoroutine(rpgCharacter._Roll(2)); } //ATTACK LEFT if (GUI.Button(new Rect(25, 85, 100, 30), "Attack L")) { rpgCharacter.Attack(1); } //ATTACK RIGHT if (GUI.Button(new Rect(130, 85, 100, 30), "Attack R")) { rpgCharacter.Attack(2); } if (rpgCharacter.weapon == Weapon.UNARMED) { if (GUI.Button(new Rect(25, 115, 100, 30), "Left Kick")) { rpgCharacter.AttackKick(1); } if (GUI.Button(new Rect(130, 115, 100, 30), "Right Kick")) { rpgCharacter.AttackKick(2); } } if (GUI.Button(new Rect(30, 240, 100, 30), "Get Hit")) { rpgCharacter.GetHit(); } } if (rpgCharacter.canJump || rpgCharacter.canDoubleJump) { if (rpgCharacter.isGrounded) { if (GUI.Button(new Rect(25, 165, 100, 30), "Jump")) { if (rpgCharacter.canJump && rpgCharacter.isGrounded) { StartCoroutine(rpgCharacter._Jump()); } } } else { if (GUI.Button(new Rect(25, 165, 100, 30), "Double Jump")) { if (rpgCharacter.canDoubleJump && !rpgCharacter.isDoubleJumping) { StartCoroutine(rpgCharacter._Jump()); } } } } if (rpgCharacter.isGrounded) { if (GUI.Button(new Rect(30, 270, 100, 30), "Death")) { rpgCharacter.Death(); } } } //Character NavMesh navigation useNav = GUI.Toggle(new Rect(25, 200, 100, 30), useNav, "Use NavMesh"); if (useNav) { if (navToggle == false) { rpgCharacter.useNavMesh = true; navToggle = true; } } else { rpgCharacter.useNavMesh = false; navToggle = false; } } if (rpgCharacter.isDead) { if (GUI.Button(new Rect(30, 270, 100, 30), "Revive")) { rpgCharacter.Revive(); } } }