public override void knockBack(Vector2 direction, float magnitude, int damage, Entity attacker) { if (disable_movement_time == 0.0) { disable_movement = true; current_skeleton.Animation = current_skeleton.Skeleton.Data.FindAnimation("hurt"); if (Math.Abs(direction.X) > (Math.Abs(direction.Y))) { if (direction.X < 0) { velocity = new Vector2(-2.0f * magnitude, direction.Y / 100 * magnitude); direction_facing = GlobalGameConstants.Direction.Right; } else { velocity = new Vector2(2.0f * magnitude, direction.Y / 100 * magnitude); direction_facing = GlobalGameConstants.Direction.Left; } } else { if (direction.Y < 0) { velocity = new Vector2(direction.X / 100f * magnitude, -2.0f * magnitude); direction_facing = GlobalGameConstants.Direction.Down; } else { velocity = new Vector2((direction.X / 100f) * magnitude, 2.0f * magnitude); direction_facing = GlobalGameConstants.Direction.Up; } } enemy_life = enemy_life - damage; state = SquadLeaderState.Patrol; } if (attacker == null) { return; } else if (attacker.Enemy_Type != enemy_type && attacker.Enemy_Type != EnemyType.NoType) { enemy_found = true; entity_found = attacker; if (enemy_life < 1 && !death && attacker != null & attacker is Player) { GameCampaign.AlterAllegiance(-0.05f); } switch (attacker.Direction_Facing) { case GlobalGameConstants.Direction.Right: direction_facing = GlobalGameConstants.Direction.Left; break; case GlobalGameConstants.Direction.Left: direction_facing = GlobalGameConstants.Direction.Right; break; case GlobalGameConstants.Direction.Up: direction_facing = GlobalGameConstants.Direction.Down; break; default: direction_facing = GlobalGameConstants.Direction.Up; break; } } }
public override void knockBack(Vector2 direction, float magnitude, int damage, Entity attacker) { if (!death) { if (disable_movement_time == 0.0) { if (state != ChargerState.windUp && state != ChargerState.charge) { disable_movement = true; animation_time = 0; AudioLib.playSoundEffect("fleshyKnockBack"); if (Math.Abs(direction.X) > (Math.Abs(direction.Y))) { if (direction.X < 0) { velocity = new Vector2(-5.51f * magnitude, direction.Y / 100 * magnitude); } else { velocity = new Vector2(5.51f * magnitude, direction.Y / 100 * magnitude); } } else { if (direction.Y < 0) { velocity = new Vector2(direction.X / 100f * magnitude, -5.51f * magnitude); } else { velocity = new Vector2((direction.X / 100f) * magnitude, 5.51f * magnitude); } } } enemy_life = enemy_life - damage; if (enemy_life < 1 && !death) { if (attacker != null & attacker is Player) { GameCampaign.AlterAllegiance(0.1f); } } } if (attacker == null) { return; } if (attacker.Enemy_Type != enemy_type && attacker.Enemy_Type != EnemyType.NoType) { enemy_found = true; entity_found = attacker; switch (attacker.Direction_Facing) { case GlobalGameConstants.Direction.Right: direction_facing = GlobalGameConstants.Direction.Left; break; case GlobalGameConstants.Direction.Left: direction_facing = GlobalGameConstants.Direction.Right; break; case GlobalGameConstants.Direction.Up: direction_facing = GlobalGameConstants.Direction.Down; break; default: direction_facing = GlobalGameConstants.Direction.Up; break; } } } parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); }
public override void knockBack(Vector2 direction, float magnitude, int damage, Entity attacker) { if (death == false) { if (molotovState == MolotovState.KnockedBack) { return; } if (molotovState == MolotovState.Dying) { parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); return; } direction.Normalize(); velocity = direction * magnitude; health -= damage; if (health < 1 && !death && attacker != null & attacker is Player) { GameCampaign.AlterAllegiance(0.015f); } knockBackTime = 0.0f; animation_time = 0; parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); AudioLib.playSoundEffect("fleshyKnockBack"); if (health > 0) { molotovState = MolotovState.KnockedBack; } else { molotovState = MolotovState.Dying; death = true; //parentWorld.pushCoin(CenterPoint, Coin.DropItemType.CoinDrop, (int)Coin.CoinValue.Laurier); //parentWorld.pushCoin(CenterPoint, Coin.DropItemType.CoinDrop, (int)Coin.CoinValue.MacDonald); dimensions /= 8; directionAnims[(int)direction_facing].Animation = directionAnims[(int)direction_facing].Skeleton.Data.FindAnimation(deathAnims[Game1.rand.Next() % 3]); parentWorld.pushCoin(this); } if (attacker == null) { return; } else if (attacker.Enemy_Type != enemy_type && attacker.Enemy_Type != EnemyType.NoType) { entity_found = attacker; enemy_found = true; } } }
public override void knockBack(Vector2 direction, float magnitude, int damage, Entity attacker) { if (guardState == PatrolGuardState.KnockBack) { return; } health -= damage; if (health <= 0 && guardState != PatrolGuardState.Dying) { if (attacker is Player) { GameCampaign.AlterAllegiance(-0.01f); } guardState = PatrolGuardState.Dying; animation_time = 0; velocity = Vector2.Zero; dimensions /= 8; parentWorld.pushCoin(this); death = true; return; } else if (guardState == PatrolGuardState.Dying) { parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); if (deadCushySoundTimer > 500f) { AudioLib.playSoundEffect("fleshyKnockBack"); deadCushySoundTimer = 0; } return; } direction.Normalize(); velocity = direction * (magnitude / 2); knockBackTime = 0.0f; guardState = PatrolGuardState.KnockBack; animation_time = 0; parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); parentWorld.Particles.pushBloodParticle(CenterPoint); AudioLib.playSoundEffect("fleshyKnockBack"); //where you look in the entity's direction and start chasing them if (attacker != null && (attacker.Enemy_Type != EnemyType.NoType && attacker.Enemy_Type != enemy_type)) { target = attacker; } }
public override void knockBack(Vector2 direction, float magnitude, int damage, Entity attacker) { if (death == false) { if (disable_movement_time == 0.0) { disable_movement = true; AudioLib.stopFlameSoundEffect(); if (Math.Abs(direction.X) > (Math.Abs(direction.Y))) { if (direction.X < 0) { velocity = new Vector2(-2.0f * magnitude, direction.Y / 100 * magnitude); } else { velocity = new Vector2(2.0f * magnitude, direction.Y / 100 * magnitude); } } else { if (direction.Y < 0) { velocity = new Vector2(direction.X / 100f * magnitude, -2.0f * magnitude); } else { velocity = new Vector2((direction.X / 100f) * magnitude, 2.0f * magnitude); } } enemy_life = enemy_life - damage; if (!death && enemy_life < 1 && attacker != null & attacker is Player) { AudioLib.stopFlameSoundEffect(); GameCampaign.AlterAllegiance(-0.01f); } } if (attacker == null) { return; } else if (attacker.Enemy_Type != enemy_type && attacker.Enemy_Type != EnemyType.NoType) { enemy_found = true; entity_found = attacker; switch (attacker.Direction_Facing) { case GlobalGameConstants.Direction.Right: direction_facing = GlobalGameConstants.Direction.Left; break; case GlobalGameConstants.Direction.Left: direction_facing = GlobalGameConstants.Direction.Right; break; case GlobalGameConstants.Direction.Up: direction_facing = GlobalGameConstants.Direction.Down; break; default: direction_facing = GlobalGameConstants.Direction.Up; break; } } } }