// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody2D>(); anim = GetComponent <Animator>(); heading = GetComponent <HasHeading>(); max_speed = Random.Range(MinVel, MaxVel); }
private void Awake() { player_anim = GetComponent <Animator>(); player_weapon = GetComponent <Weapon>(); rigidbody2D = GetComponent <Rigidbody2D>(); stamina = GetComponent <Stamina>(); heading = GetComponent <HasHeading>(); player_health = GetComponent <Health>(); player_status = GetComponent <StatusEffects>(); if (DrunkParticles) { DrunkParticles.Stop(); } }
void Explode() { var colliders = Physics2D.OverlapCircleAll(transform.position, ExplosionRadius); foreach (var collider in colliders) { Health h = collider.gameObject.GetComponent <Health>(); if (h && collider.tag != gameObject.tag) { h.TakeDamage(Damage); var statusEffects = collider.GetComponent <StatusEffects>(); if (statusEffects != null) { HasHeading heading = GetComponent <HasHeading>(); statusEffects.FlashSprite(0.3f); } } } SoundManager.PlaySound(SoundManager.Sound.AOEAtk); Instantiate(Explosion, transform.position, Quaternion.identity); Destroy(gameObject); }
protected override IEnumerator AttackCoroutine(Vector2 direction) { // float angle = Vector2.SignedAngle(Vector2.right, direction); // if (angle > 45 || angle < -135) // { // weapon_anim.SetBool("AttackingRight", false); // } // else // { // weapon_anim.SetBool("AttackingRight", true); // } if (gameObject.CompareTag("Player")) { if (right_handed) { weapon_trans.localScale = new Vector3(1, 1, 1); } else { weapon_trans.localScale = new Vector3(-1, 1, 1); } } right_handed = !right_handed; weapon_anim.SetTrigger("Attacking"); yield return(StartCoroutine(Slide(direction, AttackJumpStrength, AttackDuration))); if (gameObject.CompareTag("Player")) { status?.MakeInvincible(AttackDuration + 0.6f); } if (OptionalOnHitParticles) { SoundManager.PlaySound(SoundManager.Sound.AOEAtk); OptionalOnHitParticles.Play(); } var center = transform.position + (Vector3)direction * AttackAheadDistance; var colliders = Physics2D.OverlapCircleAll(center, AttackRadius); DebugDrawCircle(center, AttackRadius); foreach (var collider in colliders) { Health h = collider.gameObject.GetComponent <Health>(); bool isEnemyAtk = gameObject.CompareTag("Enemy") && collider.CompareTag("Player"); bool isPlayerAtk = gameObject.CompareTag("Player") && collider.tag.StartsWith("Enemy", System.StringComparison.CurrentCulture); if (h && (isEnemyAtk || isPlayerAtk)) { h.TakeDamage(Damage * attack_mod); var statusEffects = collider.GetComponent <StatusEffects>(); if (statusEffects != null) { HasHeading heading = GetComponent <HasHeading>(); if (KnockbackDistance > 0) { statusEffects.Knockback(heading.GetHeading(), KnockbackDistance, 0.05f); } if (statusEffects.tag != "Player" && StunDuration > 0) { statusEffects.Stun(StunDuration); } statusEffects.FlashSprite(0.3f); if (StunDuration > 0) { statusEffects.OnHitStun(2f, 3f); } } } } }