public void Throw(int direction, EnemyHurtbox owner) { _originalDirection = direction; _owner = owner; _rigidbody2D.velocity = new Vector2(_originalDirection * XSpeed, YSpeed); }
public void Throw(int direction, float xForce, float yForce, EnemyHurtbox owner) { _originalDirection = direction; _owner = owner; _rigidbody2D.velocity = new Vector2(_originalDirection * xForce, yForce); }
private void OnTriggerEnter2D(Collider2D other) { Player player = other.GetComponent <Player>(); if (player == null) { return; } RaycastHit2D[] raycastHit2Ds = Physics2D.CircleCastAll(transform.position, Range, Vector2.zero); foreach (RaycastHit2D raycastHit in raycastHit2Ds) { EnemyHurtbox enemyHurtbox = raycastHit.collider.GetComponent <EnemyHurtbox>(); if (enemyHurtbox == null) { continue; } enemyHurtbox.TakeDamage(Damage); } AudioSource.PlayClipAtPoint(ItemTakenSfx, transform.position, GameManager.Instance.Volume); Instantiate(ItemTakenEffectPrefab, transform.position, Quaternion.identity); Destroy(gameObject); }
// Use this for initialization void Start() { health = GetComponentInParent <EnemyHealth>(); eac = GetComponentInParent <EnemyAttackController>(); emc = GetComponentInParent <EnemyMovementController>(); hurtbox = GetComponent <EnemyHurtbox>(); }
private void Awake() { _animator = GetComponent <Animator>(); _rigidbody2D = GetComponent <Rigidbody2D>(); _owner = null; _canHurtOwner = false; }
IEnumerator ApplyHit(float damage, float knockback, Vector2 knockbackDir) { // Apply damage and knockback from hit enemyHurtbox = null; playerHealth.TakeDamage(damage); yield return(StartCoroutine(ApplyKnockback(knockback, knockbackDir))); yield return(StartCoroutine(EndKnockback())); EndHit(); }
/// <summary> /// Sent when another object enters a trigger collider attached to this /// object (2D physics only). /// </summary> /// <param name="other">The other Collider2D involved in this collision.</param> void OnTriggerStay2D(Collider2D other) { if (other.gameObject.GetComponent <EnemyHurtbox>() && enemyHurtbox == null && state.condState.Missing(PlayerState.Condition.Hit) && state.condState.Missing(PlayerState.Condition.Recovering)) { if (hitbox.vulnerable && other.gameObject.GetComponentInParent <EnemyAttackController>().touchDamageEnabled) { enemyHurtbox = other.gameObject.GetComponent <EnemyHurtbox>(); enemyHurtbox.knockbackDirection = (transform.position.x > other.transform.position.x) ? Vector2.right : Vector2.left; } } }
private void OnTriggerEnter2D(Collider2D other) { EnemyHurtbox enemyHurtbox = other.GetComponent <EnemyHurtbox>(); if (enemyHurtbox != null) { enemyHurtbox.TakeDamage(1f); Destroy(gameObject); } else if (other.gameObject.layer == LayerMask.NameToLayer("Ground")) { Destroy(gameObject); } }
private void OnTriggerEnter2D(Collider2D other) { EnemyHitbox enemyHitbox = other.GetComponent <EnemyHitbox>(); if (enemyHitbox != null) { AudioSource.PlayClipAtPoint(ChingSfx, transform.position, GameManager.Instance.Volume); } EnemyHurtbox enemyHurtbox = other.GetComponent <EnemyHurtbox>(); if (enemyHurtbox != null) { enemyHurtbox.TakeDamage(2f); } }
private void OnTriggerEnter2D(Collider2D other) { PlayerHurtbox playerHurtbox = other.GetComponent <PlayerHurtbox>(); if (playerHurtbox != null) { playerHurtbox.TakeDamage(); Destroy(gameObject); return; } PlayerHitbox playerHitbox = other.GetComponent <PlayerHitbox>(); if (playerHitbox != null && !_canHurtOwner) { _canHurtOwner = true; _rigidbody2D.velocity = new Vector2(_originalDirection * XSpeedReflect * -1, YSpeedReflect); AudioSource.PlayClipAtPoint(ChingSfx, transform.position, GameManager.Instance.Volume); return; } if (_canHurtOwner) { EnemyHurtbox enemyHurtbox = other.GetComponent <EnemyHurtbox>(); if (enemyHurtbox != null && enemyHurtbox == _owner) { enemyHurtbox.TakeDamage(1f); Destroy(gameObject); return; } } if (other.gameObject.layer == LayerMask.NameToLayer("Ground")) { AudioSource.PlayClipAtPoint(ChingSfx, transform.position, GameManager.Instance.Volume); Destroy(gameObject); } }
private void Start() { _enemyHurtbox = GetComponentInChildren <EnemyHurtbox>(); }
protected override void OnAwake() { DirectionDefault = Vector2.right; _enemyHurtbox = GetComponentInChildren <EnemyHurtbox>(); }