Skip to content

Commit

Permalink
some final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amirsaeedahmadi committed Jul 10, 2021
1 parent c29bdf9 commit d02dd23
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 23 deletions.
Binary file removed Resources/ProfileImages/main.png
Binary file not shown.
18 changes: 18 additions & 0 deletions Resources/SavedCards/main/am.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"level": 3,
"attack": 1000000,
"defence": 1000000,
"attackBooster": 0,
"defenseBooster": 0,
"attribute": "LIGHT",
"monsterType": "DRAGON",
"affectedCards": [],
"effects": {},
"name": "am",
"cardType": "MONSTER",
"description": "Hello World!",
"price": 7610,
"property": "NORMAL",
"positionIndex": -1,
"position": "DECK"
}
11 changes: 6 additions & 5 deletions Resources/Users/main.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"wallet": {
"cash": 60400,
"cash": 56539,
"cards": [
"The Calculator",
"The Calculator",
Expand All @@ -26,7 +26,8 @@
"Alexandrite Dragon",
"Axe Raider",
"Baby dragon",
"Battle OX"
"Battle OX",
"Axe Raider"
]
},
"activeDeck": "first",
Expand Down Expand Up @@ -102,7 +103,7 @@
"password": "123",
"nickname": "admin1",
"score": 1000,
"rank": 2,
"hasProfilePhoto": true,
"gamesPlayed": 36
"rank": 3,
"hasProfilePhoto": false,
"gamesPlayed": 37
}
2 changes: 2 additions & 0 deletions src/main/java/graphic/EndDuelMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class EndDuelMenu extends Menu {

@FXML
public void initialize() throws InterruptedException {
Medias.GAMEPLAY_BACKGROUND.pause();


text.setText(Request.getMessage());

Expand Down
20 changes: 14 additions & 6 deletions src/main/java/graphic/GamePlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

public class GamePlay extends Menu {

public AnchorPane downPlayerFieldZone, downPlayerDeckZone, downPlayerGraveYard, upperPlayerDeckZone;
public AnchorPane downPlayerFieldZone, downPlayerDeckZone, downPlayerGraveYard,
upperPlayerDeckZone, upperPlayerGraveYard, upperPlayerFieldZone;

public ImageView background;
@FXML
private AnchorPane view;
Expand Down Expand Up @@ -99,7 +101,8 @@ public class GamePlay extends Menu {

@FXML
public void initialize() {

Medias.GAMEPLAY_BACKGROUND.loop();
Medias.GAMEPLAY_BACKGROUND.reduceVolume();
KeyCombination cheat = new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_DOWN, KeyCombination.SHIFT_DOWN);
game = Duel.getCurrentDuel().getGame();

Expand Down Expand Up @@ -178,6 +181,7 @@ public void initialize() {
exit.setOnAction(event -> {
view.setEffect(null);
popupStage.hide();
Medias.GAMEPLAY_BACKGROUND.pause();
MainGraphic.setRoot("MainMenu");
});

Expand All @@ -198,8 +202,8 @@ public void initialize() {
}

private void initGraveYard() {
downPlayerGraveYard.getChildren().add(new GraveYard(view, game, game.getBoard().getMainPlayer()));
// upperPlayerGraveYard.getChildren().add(new GraveYard(view, game, game.getBoard().getRivalPlayer()));
downPlayerGraveYard.getChildren().add(new GraveYard(view, game, true));
upperPlayerGraveYard.getChildren().add(new GraveYard(view, game, false));
}

// private void initLifepointsCircles() {
Expand Down Expand Up @@ -273,10 +277,11 @@ private void initZones() {
downPlayerMonsterZone.getChildren().add(new MonsterZone(game, true, this));
upperPlayerMonsterZone.getChildren().add(new MonsterZone(game, false, this));
downPlayerFieldZone.getChildren().add(new FieldZone(this));
upperPlayerFieldZone.getChildren().add(new FieldZone(this));
upperPlayerSpellZone.getChildren().add(new SpellZone(game, false, this));
downPlayerSpellZone.getChildren().add(new SpellZone(game, true, this));
downPlayerDeckZone.getChildren().add(new DeckZone(game.getBoard().getMainPlayer().getPlayingDeck()));
upperPlayerDeckZone.getChildren().add(new DeckZone(game.getBoard().getRivalPlayer().getPlayingDeck()));
downPlayerDeckZone.getChildren().add(new DeckZone(game, game.getBoard().getMainPlayer(), true));
upperPlayerDeckZone.getChildren().add(new DeckZone(game, game.getBoard().getRivalPlayer(), false));
// initFieldZone();
}

Expand Down Expand Up @@ -329,6 +334,9 @@ public void update() {
((RivalHand) upperPlayerHand.getChildren().get(0)).update();
((DeckZone) downPlayerDeckZone.getChildren().get(0)).update(true);
((DeckZone) upperPlayerDeckZone.getChildren().get(0)).update(false);
((GraveYard) upperPlayerGraveYard.getChildren().get(0)).update(false);
((GraveYard) downPlayerGraveYard.getChildren().get(0)).update(true);

}

public void updateFieldZone(Card card) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/graphic/Medias.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.FloatControl;
import java.net.URL;

public enum Medias {
Expand All @@ -16,6 +17,7 @@ public enum Medias {
PUT_CARD("putcard.wav"),
SNACKBAR_ERROR("snackbarError.wav"),
START_DUEL_CLICK("startDuelClick.wav"),
GAMEPLAY_BACKGROUND("gamePlayBackground.wav"),
USUAL_CLICK("usualClick.wav");


Expand Down Expand Up @@ -49,6 +51,13 @@ private void setMedia() {
public void play(int count) {
if (!mute)
clip.loop(count);

}

public void reduceVolume() {
FloatControl gainControl =
(FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(-25.0f); // Reduce volume by 10 decibels.
}

public void pause() {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/graphic/TossCoinMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import javafx.animation.RotateTransition;
import javafx.animation.ScaleTransition;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.image.Image;
Expand Down Expand Up @@ -41,7 +40,7 @@ public void initialize() {
coinCircle.setFill(new ImagePattern(image));

tossButton.setOnMouseClicked(e -> {
Medias.COIN_FLIP.play(6);
Medias.COIN_FLIP.play(3);
RotateTransition rotator = createRotator(coinCircle);
rotator.play();

Expand Down
9 changes: 7 additions & 2 deletions src/main/java/graphic/component/GraveYard.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class GraveYard extends AnchorPane implements ComponentLoader {

private HBox root;

public GraveYard(AnchorPane view, Game game, Player player) {
public GraveYard(AnchorPane view, Game game, boolean isMain) {
this.game = game;
this.player = player;
this.player = isMain ? game.getBoard().getMainPlayer() : game.getBoard().getRivalPlayer();
load("GraveYard");
image.setImage(new Image(MainGraphic.class.getResource("PNG/deckCards.png").toString()));

Expand Down Expand Up @@ -82,4 +82,9 @@ public void addCard(Card card) {

root.getChildren().add(cardLoader);
}

public void update(boolean isMain) {
this.player = isMain ? game.getBoard().getMainPlayer() : game.getBoard().getRivalPlayer();
addAllCards();
}
}
Binary file not shown.
8 changes: 5 additions & 3 deletions src/main/resources/sample/fxml/GamePlay3.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
stylesheets="@../CSS/DeckInside.css, @../CSS/Snackbar.css" xmlns="http://javafx.com/javafx/8.0.171"
fx:controller="graphic.GamePlay">
<ImageView fx:id="background" fitHeight="800" fitWidth="870"/>
<JFXButton layoutX="31.0" layoutY="24.0" onAction="#back" prefHeight="19.0" prefWidth="43.0" styleClass="backButton"
text="&lt;"/>
<VBox fx:id="sideCard" alignment="CENTER" layoutX="850.0" prefHeight="714.0" prefWidth="360.0">
<VBox>
<VBox.margin>
Expand Down Expand Up @@ -200,7 +198,7 @@
<AnchorPane fx:id="downPlayerFieldZone" layoutX="100" layoutY="410.0"/>
<AnchorPane fx:id="downPlayerDeckZone" layoutX="700" layoutY="410.0"/>
<AnchorPane fx:id="upperPlayerDeckZone" layoutX="100" layoutY="234.0" rotate="180"/>
<JFXButton fx:id="pauseButton" layoutX="27.0" layoutY="74.0" prefHeight="50.0" prefWidth="36.0" text=".">
<JFXButton fx:id="pauseButton" layoutX="27.0" layoutY="34.0" prefHeight="50.0" prefWidth="36.0" text=".">
<graphic>
<FontAwesomeIconView fill="#515468" glyphName="GEARS" size="30" text="" wrappingWidth="27.056627944111824">
<font>
Expand All @@ -210,4 +208,8 @@
</graphic>
</JFXButton>
<AnchorPane fx:id="downPlayerGraveYard" layoutX="700.0" layoutY="520.0" prefHeight="13.0" prefWidth="14.0"/>
<AnchorPane fx:id="upperPlayerGraveYard" layoutX="100.0" layoutY="126.0" prefHeight="13.0" prefWidth="14.0"
rotate="180"/>
<AnchorPane fx:id="upperPlayerFieldZone" layoutX="693.0" layoutY="234.0" prefHeight="19.0" prefWidth="14.0"
rotate="180"/>
</AnchorPane>
10 changes: 5 additions & 5 deletions src/main/resources/sample/fxml/component/graphicCell.fxml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.*?>

<?import javafx.scene.image.ImageView?>
<fx:root style="-fx-border-radius: 5; -fx-border-width: 1; -fx-border-color: SILVER;" type="javafx.scene.layout.AnchorPane"
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
<ImageView fx:id="image" preserveRatio="true" fitHeight="96" fitWidth="74"/>
<?import javafx.scene.layout.AnchorPane?>
<fx:root xmlns:fx="http://javafx.com/fxml/1"
style="-fx-border-radius: 5; -fx-border-width: 1; -fx-border-color: SILVER;"
type="javafx.scene.layout.AnchorPane" xmlns="http://javafx.com/javafx/8.0.171">
<ImageView fx:id="image" fitHeight="96.0" fitWidth="73.0" preserveRatio="true"/>
</fx:root>

0 comments on commit d02dd23

Please sign in to comment.