|
1 | 1 | package com.khomsi.game.main.tools; |
2 | 2 |
|
3 | 3 | import com.khomsi.game.entity.Entity; |
4 | | -import com.khomsi.game.enviroment.Lightning; |
5 | 4 | import com.khomsi.game.main.GameManager; |
6 | 5 | import com.khomsi.game.objects.gui.HeartObject; |
7 | 6 | import com.khomsi.game.objects.gui.ManaObject; |
|
14 | 13 | import java.util.ArrayList; |
15 | 14 | import java.util.List; |
16 | 15 |
|
| 16 | +import static com.khomsi.game.enviroment.Lightning.*; |
| 17 | + |
17 | 18 | public class UI { |
18 | 19 | GameManager gameManager; |
19 | 20 | Graphics2D graphics2D; |
| 21 | + Tools tools = new Tools(); |
20 | 22 | public Font playMeGames; |
21 | 23 | BufferedImage heartFull, heartHalf, heartEmpty, manaFull, manaEmpty, coin; |
| 24 | + private BufferedImage arrow, sun, moon, line, nightFall; |
22 | 25 | List<String> message = new ArrayList<>(); |
23 | 26 | List<Integer> messageCounter = new ArrayList<>(); |
24 | 27 | public String currentDialog = ""; |
@@ -125,7 +128,7 @@ private void drawSleepScreen() { |
125 | 128 | if (gameManager.enManagement.lightning.filterAlfa <= 0F) { |
126 | 129 | gameManager.enManagement.lightning.filterAlfa = 0F; |
127 | 130 | counter = 0; |
128 | | - gameManager.enManagement.lightning.dayState = Lightning.DAY; |
| 131 | + gameManager.enManagement.lightning.dayState = DAY; |
129 | 132 | gameManager.enManagement.lightning.dayCounter = 0; |
130 | 133 | gameManager.gameState = GameManager.PLAY_STATE; |
131 | 134 | gameManager.player.getImage(); |
@@ -903,6 +906,75 @@ private void fullScreenNotification(int frameX, int frameY) { |
903 | 906 | } |
904 | 907 | } |
905 | 908 |
|
| 909 | + public void drawClock(Graphics2D g2d, int dayState, float filterAlfa) { |
| 910 | + int clockX = 730; |
| 911 | + int clockY = 50; |
| 912 | + int clockGap = 42; |
| 913 | + int clockWidth = GameManager.TILE_SIZE * 6; |
| 914 | + int clockHeight = (int) (GameManager.TILE_SIZE * 1.3); |
| 915 | + final int LINE_COUNT = 5; |
| 916 | + final int WINDOW_OFFSET_X = 20; |
| 917 | + final int WINDOW_OFFSET_Y = 4; |
| 918 | + int startX = clockX - WINDOW_OFFSET_X - 1; |
| 919 | + int endX = clockX + (clockGap * 4 + 1) + WINDOW_OFFSET_X; |
| 920 | + |
| 921 | + moon = tools.setup("/clock/clock_moon"); |
| 922 | + sun = tools.setup("/clock/clock_sun"); |
| 923 | + arrow = tools.setup("/clock/clock_arrow"); |
| 924 | + line = tools.setup("/clock/clock_line"); |
| 925 | + //Add the NightFall day |
| 926 | + nightFall = tools.setup("/clock/clock_nightfall"); |
| 927 | + |
| 928 | + if (gameManager.gameState != GameManager.CHARACTER_STATE) { |
| 929 | + //Draw window for clocks |
| 930 | + drawRoundUiWindow(clockX - WINDOW_OFFSET_X, clockY - WINDOW_OFFSET_Y, clockWidth, clockHeight, g2d); |
| 931 | + // Draw lines |
| 932 | + for (int i = 0; i < LINE_COUNT; i++) { |
| 933 | + int xPos = clockX + (clockGap * i); |
| 934 | + g2d.drawImage(line, xPos, clockY + WINDOW_OFFSET_Y, null); |
| 935 | + } |
| 936 | + int xPos = clockX + (clockGap * 4 + 1); |
| 937 | + int yPos = (int) (clockY - WINDOW_OFFSET_Y * 3.2); |
| 938 | + g2d.drawImage(moon, xPos + WINDOW_OFFSET_X, yPos, null); |
| 939 | + |
| 940 | + xPos = (xPos - clockGap * 2); |
| 941 | + yPos = yPos - WINDOW_OFFSET_Y; |
| 942 | + g2d.drawImage(nightFall, xPos, yPos, null); |
| 943 | + |
| 944 | + xPos = startX + 1; |
| 945 | + g2d.drawImage(sun, xPos, yPos, null); |
| 946 | + |
| 947 | + // Calculate arrow position based on dayState and filterAlfa |
| 948 | + int arrowX; |
| 949 | + int arrowY = clockY + WINDOW_OFFSET_Y * 6; |
| 950 | + |
| 951 | + if (dayState == DAY) { |
| 952 | + arrowX = startX; |
| 953 | + } else if (dayState == NIGHTFALL || dayState == NIGHT) { |
| 954 | + arrowX = (int) (startX + (endX - startX) * filterAlfa); |
| 955 | + } else { // DAWN |
| 956 | + arrowX = endX - (int) ((endX - startX) * filterAlfa); |
| 957 | + |
| 958 | + // Reverse the arrow movement during the dawn phase |
| 959 | + arrowX = endX - (arrowX - startX); |
| 960 | + |
| 961 | + if (arrowX < startX) { |
| 962 | + arrowX = startX; |
| 963 | + } |
| 964 | + } |
| 965 | + g2d.drawImage(arrow, arrowX, arrowY, null); |
| 966 | + } |
| 967 | + } |
| 968 | + |
| 969 | + //TODO Move setup to separate class and call here |
| 970 | + public void drawRoundUiWindow(int x, int y, int width, int height, Graphics2D g2d) { |
| 971 | + //Less %, more transparent |
| 972 | + int alpha = 120; // % transparent |
| 973 | + Color color = new Color(36, 36, 36, alpha); |
| 974 | + g2d.setColor(color); |
| 975 | + g2d.fillRoundRect(x, y, width, height, 8, 8); |
| 976 | + } |
| 977 | + |
906 | 978 | private void showControl(int frameX, int frameY) { |
907 | 979 | int textX; |
908 | 980 | int textY; |
|
0 commit comments