private void drawSkillRectAndBoxes(Graphics g) { // Draw outline g.setColor(goldTrim); // Fill g.drawRect(skillBoxStartX, skillBoxStartY, skillRectWidth, skillRectHeight); g.setColor(Color.darkGray); g.fillRect(skillBoxStartX, skillBoxStartY, skillRectWidth, skillRectHeight); // Values needed to draw int skillBoxX = skillBoxStartX; int skillBoxY = skillBoxStartY; int topAndSideMargin = skillBoxSize / 28; Color coolDownFontColor = Color.RED; Rectangle2D skillRect; Rectangle2D textRect; String skillText; String keyBind; Skill currentSkill; // Draw each box, loop thru each skill for (int i = 0; i < skillCount; i++) { currentSkill = skills.get(i); // Draw skill box g.setColor(goldTrim); g.drawRect(skillBoxX, skillBoxY, skillBoxSize, skillBoxSize); // TODO: Do draw image when have images. Not rly a large priority tbh // Draw item image Image skillImage = currentSkill.getSprite().getImage(); g.drawImage( skillImage, skillBoxX + (skillBoxSize - imgSize) / 2, skillBoxY + (skillBoxSize - imgSize) / 2, imgSize, imgSize, null); // Draw skill image // Draw skill name g.setColor(Color.white); g.setFont(skillLabelFont); skillText = currentSkill.getName(); fm = g.getFontMetrics(skillLabelFont); textRect = fm.getStringBounds(skillText, g); drawSkillName(g, skillText, textRect, skillBoxY, skillBoxX); // Draw Keybind in Upper Left Corner // Only active skils have keybinds if (currentSkill.isActive()) { // Set font g.setFont(keyBindFont); fm = g.getFontMetrics(keyBindFont); g.setColor(goldTrim); // Get keybind ActiveSkill currentActiveSkill = (ActiveSkill) currentSkill; int keyCode = currentActiveSkill.getKeyBind(); keyBind = KeyEvent.getKeyText(keyCode); textRect = fm.getStringBounds(keyBind, g); g.drawString( keyBind, skillBoxX + (int) textRect.getWidth() / 2 + topAndSideMargin, skillBoxY + (int) textRect.getHeight() - 1); } // Set font g.setFont(skillLabelFont); fm = g.getFontMetrics(skillLabelFont); g.setColor(Color.WHITE); // Draw Skill level in Upper Right Corner String skillLvl = "Lvl " + Integer.toString(currentSkill.getLevel()); textRect = fm.getStringBounds(skillLvl, g); g.drawString( skillLvl, skillBoxX + skillBoxSize - (int) textRect.getWidth() - topAndSideMargin, skillBoxY + (int) textRect.getHeight() + topAndSideMargin); // Draw cool down in center, if skill is coolin down if (currentSkill.isCooldown()) { double currentTime = currentSkill.getCooldownTimeRemaining(); drawAndUpdateCoolDown(g, skillBoxX, skillBoxY, currentTime, currentSkill); } // Draw option to level up this skill if have skill points if (stats.getStat(Stats.Type.SKILL_POINTS) > 0) { drawSkillLevelUpBox(g, skillBoxX, skillBoxY); } // Increment x position skillBoxX += skillBoxSize; } }
private void levelUpSkill(Skill skill) { skill.incrementLevel(); stats.decrementSkillPoints(); }