void Start() { myMelee = GetComponent <EnemyMeleeBehavior>(); myRanged = GetComponent <EnemyRangedBehavior>(); myBoss = GetComponent <EnemyBossBehavior>(); spriteRenderer = GetComponent <SpriteRenderer>(); animator = GetComponent <Animator>(); collider2D = GetComponent <BoxCollider2D>(); }
void Attack() { //Bruh //Checks all colliders in circle of radius size 1f right now Collider2D[] colliders = Physics2D.OverlapCircleAll( new Vector2(transform.position.x + .5f * (controller.movement.facingRight? 1f : -1f), transform.position.y), .25f); bool somethingHit = false; SoundFXManager.instance.PlaySound("FX", "Woosh", false, .4f, .7f); for (int rep = 0; rep < colliders.Length; rep++) { EnemyHP hpComponent = colliders[rep].GetComponent <EnemyHP>(); if (hpComponent != null) { hpComponent.TakeDamage(0); somethingHit = true; } EnemyMeleeBehavior meleeBehavior = colliders[rep].GetComponent <EnemyMeleeBehavior>(); EnemyRangedBehavior rangedBehavior = colliders[rep].GetComponent <EnemyRangedBehavior>(); if (meleeBehavior != null) { meleeBehavior.AddToVelocity(12f * (controller.movement.facingRight? Vector3.right : Vector3.left)); somethingHit = true; } if (rangedBehavior != null) { rangedBehavior.AddToVelocity(12f * (controller.movement.facingRight? Vector3.right : Vector3.left)); somethingHit = true; } Statue statue = colliders[rep].GetComponent <Statue>(); if (statue != null) { statue.Break(); somethingHit = true; } } if (somethingHit) { CameraFollow.INSTANCE.ShakeScreen(1f); SoundFXManager.instance.PlaySound("FX", "Shove"); } CameraFollow.INSTANCE.ShakeScreen(.3f); }
void HeavyAttack() { Collider2D[] colliders = Physics2D.OverlapBoxAll( new Vector2(transform.position.x + .75f * (controller.movement.facingRight? 1f : -1f), transform.position.y), new Vector2(1f, .7f), 0f); SoundFXManager.instance.PlaySound("FX", "Woosh", false, .5f, .5f); bool somethingHit = false; for (int rep = 0; rep < colliders.Length; rep++) { EnemyHP hpComponent = colliders[rep].GetComponent <EnemyHP>(); if (hpComponent != null) { hpComponent.TakeDamage(1); somethingHit = true; } EnemyMeleeBehavior meleeBehavior = colliders[rep].GetComponent <EnemyMeleeBehavior>(); EnemyRangedBehavior rangedBehavior = colliders[rep].GetComponent <EnemyRangedBehavior>(); if (meleeBehavior != null) { meleeBehavior.AddToVelocity(1f * (controller.movement.facingRight? Vector3.right : Vector3.left)); somethingHit = true; } if (rangedBehavior != null) { rangedBehavior.AddToVelocity(1f * (controller.movement.facingRight? Vector3.right : Vector3.left)); somethingHit = true; } Statue statue = colliders[rep].GetComponent <Statue>(); if (statue != null) { statue.Break(); somethingHit = true; } } if (somethingHit) { CameraFollow.INSTANCE.ShakeScreen(1f); SoundFXManager.instance.PlaySound("FX", "Player_Attack"); } CameraFollow.INSTANCE.ShakeScreen(1f); }