/** Dessine l'UI */ @Override public void render(GameContainer container, StateBasedGame base, Graphics g) { super.render(container, base, g); g.drawString("Place tes bateaux", 200, this.height - 100); g.drawString( "Il te reste " + (3 - this.finalBoats.size()) + (this.finalBoats.size() < 2 ? " bateaux" : " bateau") + " à placer !", 200, this.height - 80); }
/** Gère les updates de couleurs sur les composants */ @Override public void update(GameContainer container, StateBasedGame base, int delta) { super.update(container, base, delta); if (this.isFirstLaunch) { this.hook.getSoundPlayer().playVoice(SoundType.P21); Config.PHRASES_DICTIONARY.get(PhraseType.PH2).play(Arrays.asList(SoundType.N3)); this.isFirstLaunch = false; } Input input = container.getInput(); for (Entry<Integer, Case> maCase : cases.entrySet()) { maCase.getValue().setColor(Color.white); if (input.isKeyDown(maCase.getKey())) { if (!tmpBoat.contains(maCase.getValue()) && !isCaseInFinalBoats(maCase.getValue())) { if (tmpBoat.size() >= 3) tmpBoat.removeFirst(); tmpBoat.addLast(maCase.getValue()); } break; } if (tmpBoat.contains(maCase.getValue())) if (isBoatCorrect(tmpBoat)) maCase.getValue().setColor(Color.orange); else maCase.getValue().setColor(Color.green); for (LinkedList<Case> lc : this.finalBoats) if (lc.contains(maCase.getValue())) maCase.getValue().setColor(Color.red); } if (input.isKeyDown(Input.KEY_ENTER) || input.isKeyDown(Input.KEY_SPACE)) { if (this.isBoatCorrect(this.tmpBoat)) this.finalBoats.addLast(this.tmpBoat); this.tmpBoat = new LinkedList<>(); this.hook.checkPlacement(this.finalBoats); } if (input.isKeyDown(Input.KEY_BACK)) this.tmpBoat = new LinkedList<>(); }