This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #36 from NaulaN/develop
-= Sprint n°4 finish =-
- Loading branch information
Showing
87 changed files
with
2,496 additions
and
1,539 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
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
104 changes: 71 additions & 33 deletions
104
src/main/java/fr/sae/terraria/controller/MenuController.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 |
---|---|---|
@@ -1,57 +1,95 @@ | ||
package fr.sae.terraria.controller; | ||
|
||
import fr.sae.terraria.Terraria; | ||
import fr.sae.terraria.modele.Environment; | ||
import fr.sae.terraria.modele.entities.player.Player; | ||
import javafx.animation.Animation; | ||
import javafx.animation.KeyFrame; | ||
import javafx.animation.Timeline; | ||
import fr.sae.terraria.modele.entities.player.craft.Craft; | ||
import fr.sae.terraria.modele.entities.tools.MaterialSet; | ||
import javafx.event.Event; | ||
import javafx.fxml.FXML; | ||
import javafx.fxml.Initializable; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.Pane; | ||
import javafx.stage.Stage; | ||
import javafx.util.Duration; | ||
|
||
import java.net.URL; | ||
import java.util.Objects; | ||
import java.util.ResourceBundle; | ||
|
||
|
||
public class MenuController implements Initializable | ||
{ | ||
@FXML public Pane root; | ||
@FXML public Pane displayInventory; | ||
@FXML public Pane displayLexique; | ||
@FXML public HBox HBoxText; | ||
@FXML public HBox recipeRock; | ||
@FXML public HBox recipeTorch; | ||
|
||
public Timeline loop; | ||
private Stage stage; | ||
public Player player = null; | ||
public double scaleMultiplicatorWidth; | ||
public double scaleMultiplicatorHeight; | ||
@FXML public HBox recipeWoodPickaxe; | ||
@FXML public HBox recipeStonePickaxe; | ||
@FXML public HBox recipeIronPickaxe; | ||
|
||
@FXML public HBox recipeWoodAxe; | ||
@FXML public HBox recipeStoneAxe; | ||
@FXML public HBox recipeIronAxe; | ||
|
||
@FXML public HBox recipeWoodSword; | ||
@FXML public HBox recipeStoneSword; | ||
@FXML public HBox recipeIronSword; | ||
|
||
public Environment environment = null; | ||
public Player player = null; | ||
|
||
public MenuController(final Stage stage) | ||
{ | ||
super(); | ||
this.stage = stage; | ||
} | ||
|
||
@Override public void initialize(URL location, ResourceBundle resources) | ||
{ | ||
this.scaleMultiplicatorWidth = (this.root.getPrefWidth() / Terraria.DISPLAY_RENDERING_WIDTH); | ||
this.scaleMultiplicatorHeight = ((this.root.getPrefHeight()-this.HBoxText.getPrefHeight()) / Terraria.DISPLAY_RENDERING_HEIGHT); | ||
// Craft de la roche à partir de 3 pierres | ||
this.recipeRock.addEventFilter(Event.ANY, event -> { | ||
if (event.getEventType().getName().equalsIgnoreCase("MOUSE_PRESSED")) | ||
this.player.pickup(Craft.rock(this.environment)); | ||
}); | ||
|
||
this.recipeTorch.addEventFilter(Event.ANY, event -> { | ||
if (event.getEventType().getName().equalsIgnoreCase("MOUSE_PRESSED")) | ||
this.player.pickup(Craft.torch(this.environment)); | ||
}); | ||
|
||
|
||
// LES PIOCHES | ||
this.recipeWoodPickaxe.addEventFilter(Event.ANY, event -> { | ||
if (event.getEventType().getName().equalsIgnoreCase("MOUSE_PRESSED")) | ||
this.player.pickup(Craft.pickaxe(this.environment, MaterialSet.WOOD)); | ||
}); | ||
|
||
this.recipeStonePickaxe.addEventFilter(Event.ANY, event -> { | ||
if (event.getEventType().getName().equalsIgnoreCase("MOUSE_PRESSED")) | ||
this.player.pickup(Craft.pickaxe(this.environment, MaterialSet.STONE)); | ||
}); | ||
|
||
this.recipeIronPickaxe.addEventFilter(Event.ANY, event -> { | ||
if (event.getEventType().getName().equalsIgnoreCase("MOUSE_PRESSED")) | ||
this.player.pickup(Craft.pickaxe(this.environment, MaterialSet.IRON)); | ||
}); | ||
|
||
|
||
// LES HACHES | ||
this.recipeWoodAxe.addEventFilter(Event.ANY, event -> { | ||
|
||
}); | ||
|
||
this.recipeStoneAxe.addEventFilter(Event.ANY, event -> { | ||
|
||
}); | ||
|
||
this.recipeIronAxe.addEventFilter(Event.ANY, event -> { | ||
|
||
}); | ||
|
||
|
||
// LES EPEES | ||
this.recipeWoodSword.addEventFilter(Event.ANY, event -> { | ||
|
||
}); | ||
|
||
this.recipeStoneSword.addEventFilter(Event.ANY, event -> { | ||
|
||
this.loop = new Timeline(); | ||
this.loop.setCycleCount(Animation.INDEFINITE); | ||
}); | ||
|
||
KeyFrame keyFrame = new KeyFrame(Duration.seconds(Terraria.TARGET_FPS), (ev -> { | ||
if (!Objects.isNull(this.player)) { | ||
System.out.println(this.player.getInventory()); | ||
} | ||
})); | ||
this.recipeIronSword.addEventFilter(Event.ANY, event -> { | ||
|
||
this.loop.getKeyFrames().add(keyFrame); | ||
this.loop.play(); | ||
}); | ||
} | ||
} |
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.