-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from Our-Magic-Journey/turn-system
create turn system
- Loading branch information
Showing
13 changed files
with
169 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
package xyz.magicjourney.nebulaquest.player; | ||
|
||
import com.badlogic.gdx.assets.AssetManager; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.TextureRegion; | ||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; | ||
|
||
public class Player { | ||
private static int nextID = 0; | ||
|
||
protected int id; | ||
protected String name; | ||
|
||
public Player(String name) { | ||
this.name = name; | ||
this.id = generateId(); | ||
} | ||
|
||
private int generateId() { | ||
return Player.nextID++; | ||
} | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public TextureRegionDrawable getShip(AssetManager assets) { | ||
return new TextureRegionDrawable(new TextureRegion(assets.get("images/player" + id + ".png", Texture.class))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
core/src/xyz/magicjourney/nebulaquest/ui/dialog/MessageBox.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package xyz.magicjourney.nebulaquest.ui.dialog; | ||
|
||
import com.badlogic.gdx.assets.AssetManager; | ||
import com.badlogic.gdx.scenes.scene2d.Stage; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Label; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Window; | ||
|
||
import xyz.magicjourney.nebulaquest.event.Event; | ||
import xyz.magicjourney.nebulaquest.event.EventGetter; | ||
import xyz.magicjourney.nebulaquest.listener.Listener; | ||
|
||
public class MessageBox extends Window { | ||
protected Skin skin; | ||
protected Label message; | ||
protected TextButton okBtn; | ||
protected Event acceptedEvent; | ||
|
||
public MessageBox(String text, AssetManager assets) { | ||
super("", assets.get("skin/ui.skin.json", Skin.class)); | ||
|
||
this.skin = super.getSkin(); | ||
this.acceptedEvent = new Event(); | ||
this.message = new Label(text, this.skin, "small"); | ||
this.okBtn = new TextButton("Ok", this.skin, "orange"); | ||
|
||
this.setWidth(300); | ||
this.setHeight(100); | ||
|
||
this.clear(); | ||
this.pad(6); | ||
this.add(this.message).expandX().center().row(); | ||
this.add(okBtn).minWidth(100).expandX().center().pad(10); | ||
|
||
this.okBtn.addListener(new Listener(this::handleOkButtonClick)); | ||
} | ||
|
||
public EventGetter onAccepted() { | ||
return this.acceptedEvent; | ||
} | ||
|
||
public void show(Stage stage) { | ||
stage.addActor(this); | ||
|
||
this.center(stage.getWidth(), stage.getHeight()); | ||
} | ||
|
||
protected void center(float width, float height) { | ||
this.setX((width - this.getWidth()) / 2); | ||
this.setY((height - this.getHeight()) / 2); | ||
} | ||
|
||
protected void handleOkButtonClick() { | ||
this.remove(); | ||
this.acceptedEvent.emit(); | ||
} | ||
|
||
public void setText(String text) { | ||
this.message.setText(text); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters