public override void ResolveCollision(EnemyCollisionResponse other) { Entity enemy = other.entity; // sound effect Sound.PlaySound(Sound.SoundEffects.Enemy_Hit, enemy, !Sound.SOUND_LOOPS); // take damage if (enemy.GetType().Equals(typeof(Stalfo))) { enemy.GetComponent <StalfoHealthManagement>().Damage(Constants.LINK_SWORD_DAMAGE); } else if (enemy.GetType().Equals(typeof(Aquamentus))) { enemy.GetComponent <AquamentusHealthManagement>().Damage(Constants.LINK_SWORD_DAMAGE); } else { enemy.GetComponent <EnemyHealthManagement>().Damage(Constants.LINK_SWORD_DAMAGE); } // Push back enemy.AddComponent(new EnemyKnockback(((SwordProjectile)entity).direction, Constants.ENEMY_KNOCKBACK_DISTANCE, Constants.ENEMY_KNOCKBACK_FRAMES)); Entity.Destroy(entity); }
public override void ResolveCollision(EnemyCollisionResponse other) { Enemy enemy = (Enemy)other.entity; // take damage if (enemy.GetType().Equals(typeof(game_project.GameObjects.Enemy.Stalfo))) { enemy.GetComponent <StalfoHealthManagement>().DeductHealth(Constants.BOMB_DAMAGE); } else if (enemy.GetType().Equals(typeof(game_project.GameObjects.Enemy.Aquamentus))) { enemy.GetComponent <AquamentusHealthManagement>().DeductHealth(Constants.BOMB_DAMAGE); } else { enemy.GetComponent <EnemyHealthManagement>().DeductHealth(Constants.BOMB_DAMAGE); } }
public override void ResolveCollision(EnemyCollisionResponse other) { if (!EnemyCollided) { Enemy enemy = (Enemy)other.entity; Sound.PlaySound(Sound.SoundEffects.Enemy_Hit, entity, !Sound.SOUND_LOOPS); // take damage if (enemy.GetType().Equals(typeof(Stalfo))) { enemy.GetComponent <StalfoHealthManagement>().DeductHealth(Constants.BOMB_DAMAGE); } else if (enemy.GetType().Equals(typeof(Aquamentus))) { enemy.GetComponent <AquamentusHealthManagement>().DeductHealth(Constants.BOMB_DAMAGE); } else { enemy.GetComponent <EnemyHealthManagement>().DeductHealth(Constants.BOMB_DAMAGE); } EnemyCollided = true; } }
public override void ResolveCollision(EnemyCollisionResponse other) { LinkBehavior linkBehavior = entity.GetComponent <LinkBehavior>(); // Trigger drag away and reset animation if WallMaster got him if (!Game1.inBossRush && other.entity.GetType() == typeof(WallMaster)) { if (entity.GetComponent <DragAndReset>() == null) { LevelManager.link.AddComponent(new DragAndReset(other.entity)); } return; } // Change to Hurt Sprite (enables and disables immunity inside) if (!entity.GetComponent <LinkHealthManagement>().immune) { // Take Damage Console.WriteLine("Link is hurt"); entity.GetComponent <LinkHealthManagement>().Damage(other.damage); // Push back Vector2 linkPos = entity.GetComponent <Transform>().position; Vector2 enemyPos = other.entity.GetComponent <Transform>().position; Vector2 diff = linkPos - enemyPos; int distance = Constants.ENEMY_KNOCKBACK_DISTANCE; int frames = Constants.ENEMY_KNOCKBACK_FRAMES; // Enemy is Up from Link // UPWARD && MORE VERTICAL THAN HORIZONTAL if (enemyPos.Y <= linkPos.Y && Math.Abs(diff.Y) >= Math.Abs(diff.X)) { entity.AddComponent(new LinkKnockback(Constants.Direction.DOWN, distance, frames)); // Console.WriteLine("Enemy is up from link!"); } // Enemy is Right from Link // RIGHTWARD && MORE HORIZONTAL THAN VERTICAL else if (enemyPos.X >= linkPos.X && Math.Abs(diff.X) >= Math.Abs(diff.Y)) { entity.AddComponent(new LinkKnockback(Constants.Direction.LEFT, distance, frames)); // Console.WriteLine("Enemy is right from link!"); } // Enemy is Down from Link // DOWNWARD && MORE VERTICAL THAN HORIZONTAL else if (enemyPos.Y >= linkPos.Y && Math.Abs(diff.Y) >= Math.Abs(diff.X)) { entity.AddComponent(new LinkKnockback(Constants.Direction.UP, distance, frames)); // Console.WriteLine("Enemy is down from link!"); } // Enemy is Left from Link // LEFTWARD && MORE HORIZONTAL THAN VERTICAL else if (enemyPos.X <= linkPos.X && Math.Abs(diff.X) >= Math.Abs(diff.Y)) { entity.AddComponent(new LinkKnockback(Constants.Direction.RIGHT, distance, frames)); // Console.WriteLine("Enemy is left from link!"); } // Debug; If this ever gets output, something is wrong. else { Console.WriteLine("Enemy was unrecognized direction!"); } } }
public override void ResolveCollision(EnemyCollisionResponse other) { LinkBehavior linkBehavior = entity.GetComponent <LinkBehavior>(); if (!linkBehavior.attacking) { // Change to Hurt Sprite (enables and disables immunity inside) if (!entity.GetComponent <LinkHealthManagement>().immune) { // Take Damage entity.GetComponent <LinkHealthManagement>().DeductHealth(other.damage); Sound.PlaySound(Sound.SoundEffects.Link_Hurt, entity, !Sound.SOUND_LOOPS); linkBehavior.damaged = true; entity.GetComponent <LinkHealthManagement>().immune = true; // Push back Vector2 linkPos = entity.GetComponent <Transform>().position; Vector2 enemyPos = other.entity.GetComponent <Transform>().position; Vector2 diff = linkPos - enemyPos; int distance = Constants.ENEMY_KNOCKBACK_DISTANCE; int frames = Constants.ENEMY_KNOCKBACK_FRAMES; // Enemy is Up from Link // UPWARD && MORE VERTICAL THAN HORIZONTAL if (enemyPos.Y <= linkPos.Y && Math.Abs(diff.Y) >= Math.Abs(diff.X)) { entity.AddComponent(new LinkKnockback(Constants.Direction.DOWN, distance, frames)); // Console.WriteLine("Enemy is up from link!"); } // Enemy is Right from Link // RIGHTWARD && MORE HORIZONTAL THAN VERTICAL else if (enemyPos.X >= linkPos.X && Math.Abs(diff.X) >= Math.Abs(diff.Y)) { entity.AddComponent(new LinkKnockback(Constants.Direction.LEFT, distance, frames)); // Console.WriteLine("Enemy is right from link!"); } // Enemy is Down from Link // DOWNWARD && MORE VERTICAL THAN HORIZONTAL else if (enemyPos.Y >= linkPos.Y && Math.Abs(diff.Y) >= Math.Abs(diff.X)) { entity.AddComponent(new LinkKnockback(Constants.Direction.UP, distance, frames)); // Console.WriteLine("Enemy is down from link!"); } // Enemy is Left from Link // LEFTWARD && MORE HORIZONTAL THAN VERTICAL else if (enemyPos.X <= linkPos.X && Math.Abs(diff.X) >= Math.Abs(diff.Y)) { entity.AddComponent(new LinkKnockback(Constants.Direction.RIGHT, distance, frames)); // Console.WriteLine("Enemy is left from link!"); } // Debug; If this ever gets output, something is wrong. else { Console.WriteLine("Enemy was unrecognized direction!"); } } } }
public override void ResolveCollision(EnemyCollisionResponse other) { Entity.Destroy(entity); }