-
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.
* chore: add simple equipment system for the player Collected collectibles are now displayed if we click on a non-collectible item * feat: Improve equipment system * add InventoryPopup * Update src/main/java/io/rpg/controller/PopupController.java Co-authored-by: Marcin Hawryluk <[email protected]> * Update src/main/java/io/rpg/model/data/Inventory.java Co-authored-by: Marcin Hawryluk <[email protected]> * Update src/main/java/io/rpg/model/object/CollectibleGameObject.java Co-authored-by: Marcin Hawryluk <[email protected]> * Update src/main/java/io/rpg/view/InventoryPopup.java Co-authored-by: Marcin Hawryluk <[email protected]> * Update src/main/java/io/rpg/viewmodel/InventoryPopupViewModel.java Co-authored-by: Marcin Hawryluk <[email protected]> * Update src/main/java/io/rpg/view/InventoryGameObjectView.java Co-authored-by: Marcin Hawryluk <[email protected]> * fix: make equipment work on current arch Co-authored-by: Marcin Hawryluk <[email protected]> Co-authored-by: Kacper Kafara <[email protected]>
- Loading branch information
1 parent
741d924
commit b7ed447
Showing
17 changed files
with
242 additions
and
9 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
configurations/demo-config-1/locations/location-1/objects/object-2.json
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,4 +1,4 @@ | ||
{ | ||
"tag": "object-2", | ||
"onLeftClick": {"tag": "dialogue-action", "type": "dialogue", "statements": ["A key.,A, keyA, key.A, key.A, key.A, key.A, key.A, key.A key."], "assetPath": "assets/key.png"} | ||
"onLeftClick": {"tag": "dialogue-action", "type": "collect"} | ||
} |
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
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
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,16 @@ | ||
package io.rpg.model.actions; | ||
|
||
import io.rpg.model.object.GameObject; | ||
|
||
public class CollectAction implements Action { | ||
private GameObject owner; | ||
|
||
public void setOwner(GameObject owner) { | ||
this.owner = owner; | ||
} | ||
|
||
public GameObject getOwner() { | ||
return owner; | ||
} | ||
} | ||
|
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,19 @@ | ||
package io.rpg.model.data; | ||
|
||
import io.rpg.model.object.GameObject; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Inventory { | ||
|
||
public List<GameObject> items; | ||
|
||
public Inventory() { | ||
items = new ArrayList<>(); | ||
} | ||
|
||
public void add(GameObject object) { | ||
items.add(object); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -130,4 +130,5 @@ public void onLeftClick() { | |
public int getStrength() { | ||
return strength; | ||
} | ||
|
||
} |
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
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
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,16 @@ | ||
package io.rpg.view; | ||
|
||
import io.rpg.model.object.CollectibleGameObject; | ||
import io.rpg.model.object.GameObject; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.image.ImageView; | ||
|
||
public class InventoryGameObjectView extends ImageView { | ||
GameObject collectibleGameObject; | ||
|
||
public InventoryGameObjectView(GameObject collectibleGameObject) { | ||
this.collectibleGameObject = collectibleGameObject; | ||
Image image = new Image(GameObjectView.resolvePathToJFXFormat("assets/key.png")); | ||
setImage(image); | ||
} | ||
} |
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,78 @@ | ||
package io.rpg.view; | ||
|
||
import io.rpg.model.data.Inventory; | ||
import io.rpg.model.data.Position; | ||
import io.rpg.model.object.Player; | ||
import io.rpg.viewmodel.InventoryPopupViewModel; | ||
import io.rpg.viewmodel.TextPopupViewModel; | ||
import javafx.event.EventHandler; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Group; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.image.ImageView; | ||
import javafx.scene.input.MouseEvent; | ||
import javafx.scene.paint.Color; | ||
import javafx.scene.shape.Rectangle; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class InventoryPopup extends Scene { | ||
final int PADDING_LEFT = 25; | ||
final int PADDING_TOP = 20; | ||
@FXML | ||
private Label label; | ||
|
||
public InventoryPopup(Inventory inventory) { | ||
|
||
super(new Group(), Color.TRANSPARENT); | ||
Group group = new Group(); | ||
//TODO: load asset path from config | ||
ImageView imageView = new ImageView(GameObjectView.resolvePathToJFXFormat("assets/popup-background.png")); | ||
imageView.setX(0); | ||
imageView.setY(0); | ||
label = new Label(); | ||
label.setLayoutX(300); | ||
label.setLayoutY(100); | ||
label.setStyle("-fx-font-family: Monospaced; -fx-text-fill: white; -fx-font-weight: bold; -fx-font-size: " + 18); | ||
group.getChildren().add(imageView); | ||
group.getChildren().add(label); | ||
for (int i = 0; i < inventory.items.size(); i++) { | ||
// String assetPath=inventory.items.get(i).getAssetPath(); | ||
// to display objects in the menu | ||
// wrapperClass to store information about object which we display | ||
InventoryGameObjectView imageGameObjectView = new InventoryGameObjectView(inventory.items.get(i)); | ||
|
||
imageGameObjectView.setX(i * 50 + PADDING_LEFT); | ||
imageGameObjectView.setY(0 + PADDING_TOP); | ||
imageGameObjectView.setOnMouseEntered(event -> { | ||
InventoryGameObjectView src = (InventoryGameObjectView) event.getSource(); | ||
// System.out.println("over the item "+src.collectibleGameObject.getAssetPath()); | ||
label.setText("stub description"); | ||
}); | ||
|
||
imageGameObjectView.setOnMouseExited(event -> { | ||
label.setText(""); | ||
}); | ||
|
||
imageGameObjectView.setOnMouseClicked(event -> { | ||
|
||
System.out.println("Object clicked"); | ||
InventoryGameObjectView src = (InventoryGameObjectView) event.getSource(); | ||
System.out.println(); | ||
}); | ||
group.getChildren().add(imageGameObjectView); | ||
|
||
} | ||
this.setRoot(group); | ||
this.setFill(Color.TRANSPARENT); | ||
} | ||
|
||
} |
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
Oops, something went wrong.