1package com.fs.starfarer.api.impl.campaign.eventide;
4import java.util.ArrayList;
5import java.util.Iterator;
8import org.lwjgl.input.Keyboard;
9import org.lwjgl.opengl.GL11;
10import org.lwjgl.util.vector.Vector2f;
12import com.fs.starfarer.api.Global;
13import com.fs.starfarer.api.campaign.BaseCustomUIPanelPlugin;
14import com.fs.starfarer.api.campaign.CustomVisualDialogDelegate.DialogCallbacks;
15import com.fs.starfarer.api.campaign.InteractionDialogAPI;
16import com.fs.starfarer.api.input.InputEventAPI;
17import com.fs.starfarer.api.ui.CustomPanelAPI;
18import com.fs.starfarer.api.ui.PositionAPI;
19import com.fs.starfarer.api.util.FaderUtil;
20import com.fs.starfarer.api.util.Misc;
24 public static enum AttackResult {
32 public static boolean DEBUG =
true;
42 protected List<QuadParticles>
particles =
new ArrayList<QuadParticles>();
113 panel.tutorialMode =
true;
133 actor.maxHealth = health;
134 actor.health = health;
217 if (
p ==
null)
return;
226 GL11.glDisable(GL11.GL_TEXTURE_2D);
227 GL11.glEnable(GL11.GL_SCISSOR_TEST);
230 GL11.glScissor((
int)(x * s), (
int)(y * s), (
int)(w * s), (
int)(h * s));
237 if (
DEBUG &&
false) {
258 if (centerX < leftX) {
260 }
else if (centerX > rightX) {
271 GL11.glDisable(GL11.GL_TEXTURE_2D);
284 GL11.glTranslatef(offsetX, 0, 0);
289 p.render(alphaMult,
true);
293 boolean playerAttack = player.currAction !=
null && player.currAction.anim !=
null &&
311 p.render(alphaMult,
false);
325 GL11.glDisable(GL11.GL_SCISSOR_TEST);
335 float pipH = 20f / 1.6f;
339 GL11.glDisable(GL11.GL_TEXTURE_2D);
340 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
345 renderPip(x + opad + (pipW + pad) * i, y + h - opad - pipH,
352 renderPip(x + w - opad - (pipW + pad) * (i + 1), y + h - opad - pipH,
359 public void renderPip(
float x,
float y,
float w,
float h, Color c,
float a,
boolean filled) {
376 public static List<String>
cycle =
new ArrayList<String>();
382 public static List<String>
cycleHigh =
new ArrayList<String>();
390 if (
p ==
null)
return;
420 float timeUntilAttack = 0f;
423 timeUntilAttack += f.
dur;
427 player.currAction =
null;
447 Iterator<QuadParticles> iter =
particles.iterator();
448 while (iter.hasNext()) {
505 public void doAI(
float amount) {
530 if (
p ==
null)
return;
533 if (event.isConsumed())
continue;
535 event.isKeyDownEvent() && event.getEventValue() == Keyboard.KEY_ESCAPE) {
541 if (event.isKeyDownEvent() &&
542 (event.getEventValue() == Keyboard.KEY_UP ||
543 event.getEventValue() == Keyboard.KEY_NUMPAD8 ||
544 event.getEventValue() == Keyboard.KEY_W)) {
550 if (event.isKeyDownEvent() &&
551 (event.getEventValue() == Keyboard.KEY_LEFT ||
552 event.getEventValue() == Keyboard.KEY_NUMPAD4 ||
553 event.getEventValue() == Keyboard.KEY_A)) {
564 if (event.isKeyDownEvent() &&
565 (event.getEventValue() == Keyboard.KEY_RIGHT ||
566 event.getEventValue() == Keyboard.KEY_NUMPAD6 ||
567 event.getEventValue() == Keyboard.KEY_D)) {
578 if (event.isKeyDownEvent() &&
579 event.getEventValue() == Keyboard.KEY_SPACE) {
586 event.getEventValue() == Keyboard.KEY_F) {
594 if (event.isKeyDownEvent() &&
595 event.getEventValue() == Keyboard.KEY_G) {
609 if (playerAttackResult == AttackResult.HIT && enemyAttackResult == AttackResult.HIT) {
610 if ((
float) Math.random() < 0.5f) {
611 playerAttackResult = AttackResult.NO_HIT;
613 enemyAttackResult = AttackResult.NO_HIT;
617 if (playerAttackResult == AttackResult.BLOCK) {
619 player.currAction.wasBlocked =
true;
621 enemy.currAction.performedBlock =
true;
624 }
else if (playerAttackResult == AttackResult.HIT) {
626 player.currAction.scoredHit =
true;
629 if (enemyAttackResult == AttackResult.BLOCK) {
631 enemy.currAction.wasBlocked =
true;
633 player.currAction.performedBlock =
true;
636 }
else if (enemyAttackResult == AttackResult.HIT) {
638 enemy.currAction.scoredHit =
true;
649 if (a.
scoredHit)
return AttackResult.NO_HIT;
656 return AttackResult.BLOCK;
666 return AttackResult.HIT;
671 return AttackResult.NO_HIT;
684 p.additiveBlend =
true;
690 p.minColor =
new Color(255, 200, 100, 155);
691 p.maxColor =
new Color(255, 255, 150, 255);
694 Vector2f loc = Vector2f.add(attacker.
loc, defender.
loc,
new Vector2f());
700 if (block !=
null && block.
curr !=
null) {
704 Vector2f loc2 =
new Vector2f(loc);
705 loc2.x = area.x + area.w / 2f + block.actor.facing * area.w * 0.25f;
717 for (
int i = 0; i < num; i++) {
720 p.addParticle(pos.x, pos.y, vel.x, vel.y);
735 actor.health -= damage;
744 Vector2f loc =
new Vector2f(actor.
loc);
762 p.minColor =
new Color(136, 8, 8, 155);
763 p.maxColor =
new Color(238, 75, 43, 255);
768 base -= actor.health * 15;
769 if (base < 20) base = 20;
771 int num = base +
Misc.
random.nextInt((
int) (base * 0.5f));
773 for (
int i = 0; i < num; i++) {
776 p.addParticle(pos.x, pos.y, vel.x, vel.y);
781 p.floorFriction = 100f;
789 return h / 2f * 9.81f;
794 return anim.frameHeight * anim.
scale;
static SettingsAPI getSettings()
static SoundPlayerAPI getSoundPlayer()
static final String IDLE_HIGH
static final String MOVE_BACK
static final String BLOCK
static final String GOT_HIT
static void initActions()
static final String MOVE_FORWARD
static final String ATTACK
static final String ATTACK_HIGH_RECOVERY
static final String MOVE_BACK_HIGH
static Map< String, CharAnim > ANIMATIONS
static final String BLOCK_LOW
static final String RIPOSTE
static final String RIPOSTE_HIGH
static final String MOVE_FORWARD_HIGH
static final String ATTACK_HIGH
static final String ATTACK_RECOVERY
void render(float alphaMult)
void doAction(String action, boolean forceInterruptCurrent)
void advance(float amount)
Map< String, String > actionRemap2
Map< String, String > actionRemap1
List< HitArea > attackArea
List< HitArea > blockArea
List< HitArea > hittableArea
boolean hasAttackFrames()
List< CharAnimFrame > frames
void processInput(List< InputEventAPI > events)
void init(CustomPanelAPI panel, DialogCallbacks callbacks, InteractionDialogAPI dialog)
static Actor createActor(String tex, boolean skilled)
void render(float alphaMult)
void wasHit(Actor actor, Actor by)
PositionAPI getPosition()
void addBlood(Vector2f loc, Actor actor)
static boolean DO_CYCLE_HIGH
static List< String > cycleHigh
void renderBelow(float alphaMult)
void positionChanged(PositionAPI position)
static DuelPanel createTutorial(boolean playerSkilled, String ambienceLoopId)
float getCharacterHeight()
CustomPanelAPI getPanel()
void renderPip(float x, float y, float w, float h, Color c, float a, boolean filled)
void advance(float amount)
static List< String > cycle
void renderHealth(float alphaMult)
void addSparks(Actor attacker, Actor defender)
DialogCallbacks callbacks
DuelBackground background
void addBlood(Actor actor)
static DuelPanel createDefault(boolean playerSkilled, boolean enemySkilled, String ambienceLoopId)
static float SOUND_LOC_MULT
AttackResult checkAttackVsDefense(Actor attacker, Actor defender)
List< QuadParticles > particles
InteractionDialogAPI dialog
void checkBlocksAndHits()
DuelPanel(Actor player, Actor enemy, DuelEnemyAI ai, DuelBackground background)
CustomPanelAPI getPanel()
void init(CustomPanelAPI panel, DialogCallbacks callbacks, InteractionDialogAPI dialog)
void reportAction(String actionId)
boolean intersects(HitArea other)
HitArea getAdjustedForAction(AnimAction action)
void advance(float amount)
void advance(float amount)
static void renderQuad(float x, float y, float width, float height, Color color, float alphaMult)
static float approach(float curr, float dest, float minSpeed, float diffSpeedMult, float amount)
static Color getNegativeHighlightColor()
static float getDistance(SectorEntityToken from, SectorEntityToken to)
static Vector2f getPointWithinRadius(Vector2f from, float r)
static Color getPositiveHighlightColor()
float getScreenScaleMult()
void playUILoop(String id, float pitch, float volume)
void setListenerPosOverrideOneFrame(Vector2f listenerPosOverrideOneFrame)
void renderForeground(DuelPanel panel, float xOffset, float yOffset, float alphaMult)
void render(DuelPanel panel, float xOffset, float yOffset, float alphaMult)
void advance(float amount)
void render(float alphaMult)
void advance(float amount, DuelPanel duel)
CustomPanelAPI createCustomPanel(float width, float height, CustomUIPanelPlugin plugin)
PositionAPI inTL(float xPad, float yPad)
PositionAPI addComponent(UIComponentAPI custom)
void bringComponentToTop(UIComponentAPI c)