summary refs log tree commit diff stats
path: root/src/com/fourisland
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/fourisland')
-rw-r--r--src/com/fourisland/fourpuzzle/Database.java95
-rw-r--r--src/com/fourisland/fourpuzzle/GameCharacters.java6
-rw-r--r--src/com/fourisland/fourpuzzle/PuzzleApplication.java4
-rw-r--r--src/com/fourisland/fourpuzzle/SaveFile.java2
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/GameOverGameState.java3
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java2
-rw-r--r--src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java26
-rw-r--r--src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java5
-rw-r--r--src/com/fourisland/fourpuzzle/transition/SlideTransition.java5
-rw-r--r--src/com/fourisland/fourpuzzle/transition/SquareTransition.java5
-rw-r--r--src/com/fourisland/fourpuzzle/transition/Transition.java2
11 files changed, 142 insertions, 13 deletions
diff --git a/src/com/fourisland/fourpuzzle/Database.java b/src/com/fourisland/fourpuzzle/Database.java new file mode 100644 index 0000000..8d51f9a --- /dev/null +++ b/src/com/fourisland/fourpuzzle/Database.java
@@ -0,0 +1,95 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package com.fourisland.fourpuzzle;
7
8import com.fourisland.fourpuzzle.transition.SquareTransition;
9import com.fourisland.fourpuzzle.transition.Transition;
10import com.fourisland.fourpuzzle.transition.TransitionDirection;
11import java.util.HashMap;
12
13/**
14 *
15 * @author hatkirby
16 */
17public class Database {
18
19 private static HashMap<String, String> vocabulary = new HashMap<String, String>();
20 private static GameCharacters heros = GameCharacters.getDefaultParty();
21 private static HashMap<String, String> music = new HashMap<String, String>();
22 private static HashMap<String, Transition> transitions = new HashMap<String, Transition>();
23
24 static {
25 loadDefaultVocabulary();
26 loadDefaultMusic();
27 loadDefaultTransitions();
28 }
29
30 /* Vocabulary */
31
32 private static void loadDefaultVocabulary()
33 {
34 vocabulary.put("Title", "Untitled Game");
35 }
36
37 public static String getVocab(String key)
38 {
39 return vocabulary.get(key);
40 }
41
42 public static void setVocab(String key, String value)
43 {
44 vocabulary.put(key, value);
45 }
46
47 /* Heros */
48
49 public static void addHero(GameCharacter hero)
50 {
51 heros.add(hero);
52 }
53
54 public static GameCharacters createParty()
55 {
56 return GameCharacters.createParty();
57 }
58
59 /* Music */
60
61 public static void loadDefaultMusic()
62 {
63 music.put("Title", "Opening");
64 music.put("GameOver", "GameOver");
65 }
66
67 public static String getMusic(String key)
68 {
69 return music.get(key);
70 }
71
72 public static void setMusic(String key, String value)
73 {
74 music.put(key, value);
75 }
76
77 /* Transitions */
78
79 public static void loadDefaultTransitions()
80 {
81 transitions.put("MapExit", new SquareTransition(TransitionDirection.Out));
82 transitions.put("MapEnter", new SquareTransition(TransitionDirection.In));
83 }
84
85 public static Transition getTransition(String key)
86 {
87 return transitions.get(key).copy();
88 }
89
90 public static void setTransition(String key, Transition value)
91 {
92 transitions.put(key, value);
93 }
94
95}
diff --git a/src/com/fourisland/fourpuzzle/GameCharacters.java b/src/com/fourisland/fourpuzzle/GameCharacters.java index 933b333..211b66d 100644 --- a/src/com/fourisland/fourpuzzle/GameCharacters.java +++ b/src/com/fourisland/fourpuzzle/GameCharacters.java
@@ -17,12 +17,12 @@ public class GameCharacters extends ArrayList<GameCharacter>
17 private GameCharacters() {} 17 private GameCharacters() {}
18 18
19 private static GameCharacters INSTANCE = new GameCharacters(); 19 private static GameCharacters INSTANCE = new GameCharacters();
20 public static GameCharacters getDefaultParty() 20 static GameCharacters getDefaultParty()
21 { 21 {
22 return INSTANCE; 22 return INSTANCE;
23 } 23 }
24 24
25 public static GameCharacters createParty() 25 static GameCharacters createParty()
26 { 26 {
27 GameCharacters temp = new GameCharacters(); 27 GameCharacters temp = new GameCharacters();
28 temp.addAll(INSTANCE); 28 temp.addAll(INSTANCE);
@@ -42,7 +42,7 @@ public class GameCharacters extends ArrayList<GameCharacter>
42 42
43 Game.setGameState(new GameOverGameState()); 43 Game.setGameState(new GameOverGameState());
44 return null; 44 return null;
45 } 45 }
46 46
47 public boolean exists(String heroName) { 47 public boolean exists(String heroName) {
48 for (GameCharacter chara : this) 48 for (GameCharacter chara : this)
diff --git a/src/com/fourisland/fourpuzzle/PuzzleApplication.java b/src/com/fourisland/fourpuzzle/PuzzleApplication.java index 9225c90..80b6cd3 100644 --- a/src/com/fourisland/fourpuzzle/PuzzleApplication.java +++ b/src/com/fourisland/fourpuzzle/PuzzleApplication.java
@@ -40,7 +40,7 @@ public class PuzzleApplication extends Application {
40 INSTANCE = this; 40 INSTANCE = this;
41 41
42 gameFrame = new JDialog(new JFrame(), false); 42 gameFrame = new JDialog(new JFrame(), false);
43 gameFrame.setTitle("The Hat"); 43 gameFrame.setTitle(Database.getVocab("title"));
44 gameFrame.setSize(Game.WIDTH * 2, Game.HEIGHT * 2); 44 gameFrame.setSize(Game.WIDTH * 2, Game.HEIGHT * 2);
45 gameFrame.setResizable(false); 45 gameFrame.setResizable(false);
46 gameFrame.addWindowListener(new WindowAdapter() { 46 gameFrame.addWindowListener(new WindowAdapter() {
@@ -158,7 +158,7 @@ public class PuzzleApplication extends Application {
158 158
159 JFrame errorBox = new JFrame(ex.getClass().getSimpleName()); 159 JFrame errorBox = new JFrame(ex.getClass().getSimpleName());
160 JLabel text = new JLabel(); 160 JLabel text = new JLabel();
161 text.setText("<HTML><CENTER>I'm sorry, but " + INSTANCE.getContext().getResourceMap().getString("Application.title") + 161 text.setText("<HTML><CENTER>I'm sorry, but " + Database.getVocab("Title") +
162 " has run into an error and been forced to quit.<BR>Your save file has not been kept. The error was:<BR><BR>" + 162 " has run into an error and been forced to quit.<BR>Your save file has not been kept. The error was:<BR><BR>" +
163 ex.getMessage() + "</CENTER>"); 163 ex.getMessage() + "</CENTER>");
164 if (ex instanceof Error) 164 if (ex instanceof Error)
diff --git a/src/com/fourisland/fourpuzzle/SaveFile.java b/src/com/fourisland/fourpuzzle/SaveFile.java index 2b99bc5..d079f0f 100644 --- a/src/com/fourisland/fourpuzzle/SaveFile.java +++ b/src/com/fourisland/fourpuzzle/SaveFile.java
@@ -27,7 +27,7 @@ public class SaveFile implements Serializable {
27 public SaveFile() 27 public SaveFile()
28 { 28 {
29 switches = new HashMap<String, Boolean>(); 29 switches = new HashMap<String, Boolean>();
30 party = GameCharacters.createParty(); 30 party = Database.createParty();
31 variables = new HashMap<String, Integer>(); 31 variables = new HashMap<String, Integer>();
32 currentMap = new String(); 32 currentMap = new String();
33 hero = new HeroEvent(); 33 hero = new HeroEvent();
diff --git a/src/com/fourisland/fourpuzzle/gamestate/GameOverGameState.java b/src/com/fourisland/fourpuzzle/gamestate/GameOverGameState.java index d20691f..53cae37 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/GameOverGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/GameOverGameState.java
@@ -6,6 +6,7 @@
6package com.fourisland.fourpuzzle.gamestate; 6package com.fourisland.fourpuzzle.gamestate;
7 7
8import com.fourisland.fourpuzzle.Audio; 8import com.fourisland.fourpuzzle.Audio;
9import com.fourisland.fourpuzzle.Database;
9import com.fourisland.fourpuzzle.Display; 10import com.fourisland.fourpuzzle.Display;
10import com.fourisland.fourpuzzle.Game; 11import com.fourisland.fourpuzzle.Game;
11import com.fourisland.fourpuzzle.SaveFile; 12import com.fourisland.fourpuzzle.SaveFile;
@@ -23,7 +24,7 @@ public class GameOverGameState implements GameState {
23 24
24 public void initalize() 25 public void initalize()
25 { 26 {
26 Audio.playMusic("GameOver"); 27 Audio.playMusic(Database.getMusic("GameOver"));
27 } 28 }
28 29
29 public void deinitalize() 30 public void deinitalize()
diff --git a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java index 0b032eb..9247282 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java +++ b/src/com/fourisland/fourpuzzle/gamestate/TitleScreenGameState.java
@@ -21,7 +21,7 @@ public class TitleScreenGameState implements GameState {
21 21
22 public void initalize() 22 public void initalize()
23 { 23 {
24 Audio.playMusic("Opening"); 24 Audio.playMusic(Database.getMusic("Title"));
25 } 25 }
26 26
27 public void deinitalize() 27 public void deinitalize()
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java index c39082d..c48b312 100644 --- a/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/event/SpecialEvent.java
@@ -166,9 +166,12 @@ public class SpecialEvent {
166 */ 166 */
167 public void StartTransition(OutTransition trans) throws InterruptedException 167 public void StartTransition(OutTransition trans) throws InterruptedException
168 { 168 {
169 startedTransition = true; 169 if (!startedTransition)
170 170 {
171 Display.transition(trans); 171 startedTransition = true;
172
173 Display.transition(trans);
174 }
172 } 175 }
173 176
174 /** 177 /**
@@ -181,10 +184,21 @@ public class SpecialEvent {
181 * @param map The name of the map to move to 184 * @param map The name of the map to move to
182 * @param x The X position on the map to move to 185 * @param x The X position on the map to move to
183 * @param y The Y position on the map to move to 186 * @param y The Y position on the map to move to
187 * @throws InterruptedException
184 */ 188 */
185 public void Teleport(String map, int x, int y) 189 public void Teleport(String map, int x, int y) throws InterruptedException
186 { 190 {
187 throw new UnsupportedOperationException("Not yet implemented"); 191 if (!startedTransition)
192 {
193 Display.transition(Database.getTransition("MapExit"));
194 }
195
196 Game.setGameState(new MapViewGameState(map, x, y));
197
198 if (!startedTransition)
199 {
200 Display.transition(Database.getTransition("MapEnter"));
201 }
188 } 202 }
189 203
190 /** 204 /**
@@ -202,6 +216,8 @@ public class SpecialEvent {
202 if (startedTransition) 216 if (startedTransition)
203 { 217 {
204 Display.transition(trans); 218 Display.transition(trans);
219
220 startedTransition = false;
205 } 221 }
206 } 222 }
207 223
diff --git a/src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java b/src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java index ccdf3f2..027077c 100644 --- a/src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/DoNotEraseTransition.java
@@ -23,5 +23,10 @@ public class DoNotEraseTransition implements OutTransition {
23 { 23 {
24 // Do nothing 24 // Do nothing
25 } 25 }
26
27 public Transition copy()
28 {
29 return new DoNotEraseTransition();
30 }
26 31
27} 32}
diff --git a/src/com/fourisland/fourpuzzle/transition/SlideTransition.java b/src/com/fourisland/fourpuzzle/transition/SlideTransition.java index e40ad99..81031fe 100644 --- a/src/com/fourisland/fourpuzzle/transition/SlideTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/SlideTransition.java
@@ -137,4 +137,9 @@ public class SlideTransition implements MultidirectionalTransition {
137 UpOrDown 137 UpOrDown
138 } 138 }
139 139
140 public Transition copy()
141 {
142 return new SlideTransition(direction, d);
143 }
144
140} 145}
diff --git a/src/com/fourisland/fourpuzzle/transition/SquareTransition.java b/src/com/fourisland/fourpuzzle/transition/SquareTransition.java index 8a74176..6167fc3 100644 --- a/src/com/fourisland/fourpuzzle/transition/SquareTransition.java +++ b/src/com/fourisland/fourpuzzle/transition/SquareTransition.java
@@ -74,4 +74,9 @@ public class SquareTransition implements MultidirectionalTransition {
74 this.postTransition = postTransition; 74 this.postTransition = postTransition;
75 } 75 }
76 76
77 public Transition copy()
78 {
79 return new SquareTransition(direction);
80 }
81
77} 82}
diff --git a/src/com/fourisland/fourpuzzle/transition/Transition.java b/src/com/fourisland/fourpuzzle/transition/Transition.java index 445d75d..8362d1a 100644 --- a/src/com/fourisland/fourpuzzle/transition/Transition.java +++ b/src/com/fourisland/fourpuzzle/transition/Transition.java
@@ -23,4 +23,6 @@ public interface Transition {
23 public boolean render(Graphics2D g); 23 public boolean render(Graphics2D g);
24 24
25 public void setPreTransition(BufferedImage preTransition); 25 public void setPreTransition(BufferedImage preTransition);
26
27 public Transition copy();
26} \ No newline at end of file 28} \ No newline at end of file