/** Makes crud wait for the animation to play out. */ public void watchAnimation() { // Decrement the number of remaining frames. And when we're out of remaining frames move on. if (frameCount > damagePoint) { attackerBarDone = attackerHealthBar.runFrame(); defenderBarDone = defenderHealthBar.runFrame(); } if (frameCount < animationLength) frameCount++; if (frameCount >= animationLength && attackerBarDone && defenderBarDone) controlState = 5; }
/** * Draws to the graphics. * * @param g The graphics */ public void draw(Graphics2D g) { // always check this if (visible) { if (graphics) { } else { attackerHealthBar.draw(g); defenderHealthBar.draw(g); } } }
/** * Simulates 1 attack, from a to b * * @param a The unit attacking. Not necessarily attacker * @param b The unit defending. Not necessarily defender */ public void attack(Unit a, Unit b) { // Get the RNG int d100 = (int) Math.ceil(Math.random() * 100); // Do we hit? boolean hit = d100 < hitChance(a, b, map); if (hit) { // Get the RNG d100 = (int) Math.ceil(Math.random() * 100); // Deterimine raw damage attackDamage = determineDamage(a, b); // (Insert Damage Resist abilities) // Do we crit? boolean crit = d100 < critChance(a, b); if (crit) { attackDamage = attackDamage * 3; attackResult = 2; } else { attackResult = 1; } // Take Damage b.takeDamage(attackDamage); if (attackerTurn) defenderHealthBar.damage(attackDamage); else attackerHealthBar.damage(attackDamage); a.getEquppedWeapon().dull(); } // we missed else attackResult = 0; }