void Attack1() { Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, enemyLayers); if (hitEnemies.Length > 0) { animator.SetTrigger("Attack1"); animator.SetBool("IsAttacking", true); foreach (Collider2D enemy in hitEnemies) { Eagle eagle; enemy.TryGetComponent <Eagle>(out eagle); if (eagle != null) { hurtPS.startColor = eagle.GetComponent <EagleCombat>().bloodColor; eagle.GetComponent <EagleCombat>().TakeDamage(damageSystem.Damage(), gameObject.transform.rotation.y == 0 ? 1 : (-1)); } else { hurtPS.startColor = enemy.GetComponent <Enemy>().bloodColor; enemy.GetComponent <Enemy>().TakeDamage(damageSystem.Damage(), 0.2f); } StartCoroutine(DamageEffect(0.15f)); break; } } }
private void OnCollisionEnter2D(Collision2D collision) { var enemy = collision.gameObject.GetComponent <Enemy>(); if (enemy != null) { enemy.TakeDamage(damageSystem.Damage(), 0f); } directionShift = collision.gameObject.transform.position.x - gameObject.transform.position.x > 0 ? 1 : (-1); StartCoroutine(Explosion(0.23f)); GetComponent <EdgeCollider2D>().enabled = false; }
IEnumerator DamageEffect(float time, PlayerCombat playerCombat) { camShake.Shake(camShakeAmount, time, 0.2f); UnityEngine.Vector3 firstPosition = attackPoint.position; yield return(new WaitForSeconds(time)); playerCombat.TakeDamage(damageSystem.Damage(), GetComponent <Eagle>().RotationValue == 0 ? 1 : -1); var hurtPS = Instantiate(hurtEffectPS); hurtPS.transform.position = firstPosition; hurtPS.Play(); yield return(new WaitForSeconds(time)); hurtPS.transform.position = attackPoint.position; }
IEnumerator Attack() { Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, playerLayer); if (hitEnemies.Length > 0) { animator.SetTrigger("Attack"); yield return(new WaitForSeconds(0.2f)); hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, playerLayer); if (hitEnemies.Length > 0) { foreach (Collider2D player in hitEnemies) { hurtEffectPS.startColor = player.GetComponent <PlayerCombat>().bloodColor; StartCoroutine(DamageEffect(0.15f)); player.GetComponent <PlayerCombat>().TakeDamage(damageSystem.Damage(), jumpDirection); break; } } } }
private void OnMouseDown() { m_damageSystem.Damage(20); Debug.Log(name + "血量为" + m_damageSystem.GetCurHealth() + ",状态为" + m_damageSystem.GetCurState()); }
public void Damage() { m_DamageSystem.Damage(damageValue == 0f ? 40 : (int)damageValue); }