12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package pathgame.gameplay.menu;
- import pathgame.gameplay.Gamestates;
- import pathgame.gameplay.PlayerAbilities;
- /**
- * A container for holding all options of the CharacterMenu
- *
- * @author julia
- */
- public class CharacterMenu extends BaseMenu
- {
- private final MenuButton[] options;
- /**
- * Contructor generating and initializing the CharacterMenu
- *
- * @param id the id of the CharacterMenu
- * @param mainId the id to the MainMenu
- */
- public CharacterMenu(int id, int mainId)
- {
- super(id);
- options = new MenuButton[PlayerAbilities.ABILITIES.length + 1];
- for(int i = 0; i < options.length - 1; ++i)
- {
- options[i] = getAbilityOption(PlayerAbilities.ABILITIES[i]);
- }
- options[options.length - 1] = new MenuButton("Back", (gamestate) ->
- {
- setReturnId(mainId);
- });
- }
- private static MenuButton getAbilityOption(PlayerAbilities pa)
- {
- return new MenuButton(pa.getName(), (gamestate, level) ->
- {
- level.reset();
- level.getPlayer().setAbilities(pa);
- gamestate.setState(Gamestates.GAMEPLAY);
- });
- }
- /**
- * Returns the options of the CharacterMenu
- *
- * @return the options of the CharacterMenu
- */
- @Override
- public MenuButton[] getOptions()
- {
- return options;
- }
- }
|