Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.espeon.game.model.content.combat;
- import org.espeon.game.event.Event;
- import org.espeon.game.model.Animation;
- import org.espeon.game.model.Damage.HitType;
- import org.espeon.game.model.Entity;
- import org.espeon.game.model.World;
- /**
- *
- * @author Encouragin
- *
- * Represents the actual combat.
- *
- * @param <T> The entity this combat system is for.
- */
- public final class Combat<T extends Entity> {
- /**
- * The attacker.
- */
- private T attacker;
- /**
- * Assign a new combat system for a single entity.
- * @param attacker The attacker.
- */
- public Combat(final T attacker) {
- this.attacker = attacker;
- }
- /**
- * Check if we're ready to attack.
- * @param victim The selected victim of the attacker.
- */
- public boolean isAvailableToAttack(final Entity victim) {
- /**
- * Check if either the attacker or victim are
- * returned dead in-game.
- */
- if (attacker.isDead() || victim.isDead()) {
- return false;
- }
- return true;
- }
- /**
- * Attack the attacker's victim with a melee attack.
- * @param victim The selected victim of the attacker.
- */
- public void attackWithMelee(final Entity victim) {
- /**
- * Let the attacker perform a combat animation.
- */
- attacker.playAnimation(Animation.create(422, 0));
- /**
- * Submit a damage delaying event. This event is for
- * in-game combat perfection. We submit a event within
- * the played animation and the appearance of the damage
- * hit.
- */
- World.getWorld().submit(new Event(900) {
- @Override
- public void execute() {
- /**
- * Let a damage hit appear on the victim's
- * virtual body.
- */
- victim.inflictDamage(10, HitType.NORMAL_DAMAGE);
- /**
- * Stop the event.
- */
- this.stop();
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement