Description:
Fix messy indentation.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
|
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
This diff has been collapsed as it changes many lines, (960 lines changed) Show them Hide them | |||||
@@ -25,54 +25,54 | |||||
|
25 |
|
25 | ||
|
26 | class FNAGame : Game |
|
26 | class FNAGame : Game |
|
27 | { |
|
27 | { |
|
28 |
|
|
28 | private KeyboardState keyboardPrev = new KeyboardState(); |
|
29 |
|
29 | ||
|
30 |
|
|
30 | private SpriteBatch batch; |
|
31 |
|
|
31 | private SoundEffect sound; |
|
32 |
|
|
32 | private SpriteFont monoFont; |
|
33 |
|
33 | ||
|
34 |
|
|
34 | private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f }); |
|
35 |
|
35 | ||
|
36 |
|
|
36 | Random random_generator = new Random(); |
|
37 |
|
37 | ||
|
38 |
|
|
38 | int frameRate = 0; |
|
39 |
|
|
39 | int frameCounter = 0; |
|
40 |
|
|
40 | TimeSpan elapsedTime = TimeSpan.Zero; |
|
41 |
|
|
41 | TimeSpan drawTime = TimeSpan.Zero; |
|
42 |
|
|
42 | TimeSpan updateTime = TimeSpan.Zero; |
|
43 |
|
43 | ||
|
44 |
|
|
44 | Queue<float> past_fps = new Queue<float>(100); |
|
45 |
|
|
45 | int tilesDrawn = 0; |
|
46 |
|
46 | ||
|
47 |
|
|
47 | private const int width = 1280; |
|
48 |
|
|
48 | private const int height = 640; |
|
49 |
|
49 | ||
|
50 |
|
|
50 | //new tile stuff |
|
51 |
|
|
51 | int squaresAcross = 50; |
|
52 |
|
|
52 | int squaresDown = 50; |
|
53 |
|
|
53 | // int baseOffsetX = -14; |
|
54 |
|
|
54 | // int baseOffsetY = -14; |
|
55 |
|
55 | ||
|
56 |
|
|
56 | Simulation simulation; |
|
57 |
|
57 | ||
|
58 |
|
|
58 | Vector2 mouseGrid; |
|
59 |
|
|
59 | Vector2 original_point; |
|
60 |
|
60 | ||
|
61 |
|
|
61 | private ImGuiRenderer _imGuiRenderer; |
|
62 |
|
|
62 | private DebugWindow debugWindow; |
|
63 |
|
63 | ||
|
64 |
|
|
64 | bool show_another_window; |
|
65 | private bool showInitial; |
|
65 | private bool showInitial; |
|
66 |
|
|
66 | int messageIndex; |
|
67 |
|
67 | ||
|
68 |
|
|
68 | //buggy |
|
69 | private static bool enableCulling = false; |
|
69 | private static bool enableCulling = false; |
|
70 |
|
70 | ||
|
71 |
|
|
71 | private Node<DialogOption> currentNode; |
|
72 |
|
|
72 | private Queue<Node<DialogOption>> remainingDialog; |
|
73 |
|
73 | ||
|
74 |
|
74 | ||
|
75 |
|
|
75 | private bool showGrid; |
|
76 | private Grammar grammar; |
|
76 | private Grammar grammar; |
|
77 | private string output; |
|
77 | private string output; |
|
78 | private GraphicsDeviceManager gdm; |
|
78 | private GraphicsDeviceManager gdm; |
@@ -81,411 +81,409 | |||||
|
81 | private bool showForest; |
|
81 | private bool showForest; |
|
82 |
|
82 | ||
|
83 | private static void Main(string[] args) |
|
83 | private static void Main(string[] args) |
|
84 | { |
|
84 | { |
|
85 |
|
|
85 | #if NETCOREAPP |
|
86 |
|
|
86 | DllMap.Initialise(false); |
|
87 | #endif |
|
87 | #endif |
|
88 |
|
|
88 | using FNAGame g = new FNAGame(); |
|
89 |
|
|
89 | g.Run(); |
|
90 | } |
|
90 | } |
|
91 |
|
91 | ||
|
92 |
|
92 | ||
|
93 |
|
93 | ||
|
94 |
|
94 | ||
|
95 |
|
|
95 | private FNAGame() |
|
96 | { |
|
96 | { |
|
97 |
|
|
97 | //this.device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.) |
|
98 |
|
98 | ||
|
99 | #if DEBUG |
|
99 | #if DEBUG |
|
100 |
|
|
100 | foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) |
|
101 | { |
|
101 | { |
|
102 |
|
|
102 | Console.Out.Write(assembly.ToString() + "\n"); |
|
103 | } |
|
103 | } |
|
104 | ; |
|
104 | ; |
|
105 | #endif |
|
105 | #endif |
|
106 |
|
|
106 | this.gdm = new GraphicsDeviceManager(this) { |
|
107 | { |
|
107 | // Typically you would load a config here... |
|
|
108 | PreferredBackBufferWidth = width, | ||
|
|
109 | PreferredBackBufferHeight = height, | ||
|
|
110 | IsFullScreen = false, | ||
|
|
111 | SynchronizeWithVerticalRetrace = true | ||
|
|
112 | }; | ||
|
|
113 | //gdm.SynchronizeWithVerticalRetrace = false; | ||
|
|
114 | IsFixedTimeStep = false; | ||
|
108 |
|
115 | ||
|
109 | // Typically you would load a config here... |
|
116 | this.simulation = new Simulation(this.squaresAcross, this.squaresDown, 16.66667f*30); |
|
110 | PreferredBackBufferWidth = width, |
|
||
|
111 | PreferredBackBufferHeight = height, |
|
||
|
112 | IsFullScreen = false, |
|
||
|
113 | SynchronizeWithVerticalRetrace = true |
|
||
|
114 | }; |
|
||
|
115 | //gdm.SynchronizeWithVerticalRetrace = false; |
|
||
|
116 | IsFixedTimeStep = false; |
|
||
|
117 |
|
|||
|
118 | this.simulation = new Simulation(this.squaresAcross, this.squaresDown, 16.66667f*30); |
|
||
|
119 |
|
117 | ||
|
120 |
|
|
118 | foreach (List<Cell> row in this.simulation.map.cells) |
|
121 | { |
|
119 | { |
|
122 |
|
|
120 | foreach (Cell cell in row) |
|
123 | { |
|
121 | { |
|
124 |
|
|
122 | if (this.random_generator.NextDouble() > 0.75) |
|
125 | { |
|
123 | { |
|
126 |
|
|
124 | int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR); |
|
127 |
|
|
125 | int random_month = random_generator.Next(1, 12); |
|
128 |
|
|
126 | DateTime random_date = new DateTime(random_year, random_month, 1); |
|
129 |
|
127 | ||
|
130 |
|
|
128 | cell.addTree(random_date); |
|
131 | } |
|
129 | } |
|
132 | } |
|
130 | } |
|
133 | } |
|
131 | } |
|
134 |
|
132 | ||
|
135 |
|
|
133 | showInitial = true; |
|
136 |
|
|
134 | messageIndex = 0; |
|
137 |
|
|
135 | showBudget = false; |
|
138 |
|
|
136 | showForest = true; |
|
139 |
|
|
137 | showGrid = true; |
|
140 |
|
138 | ||
|
141 |
|
|
139 | this.Window.Title = "Isometric Park"; |
|
142 |
|
140 | ||
|
143 |
|
|
141 | Content.RootDirectory = "Content"; |
|
144 |
|
142 | ||
|
145 |
|
|
143 | currentNode = DialogTrees.introTree; |
|
146 |
|
144 | ||
|
147 | } |
|
145 | } |
|
148 |
|
146 | ||
|
149 |
|
|
147 | protected override void Initialize() |
|
150 | { |
|
148 | { |
|
151 |
|
|
149 | /* This is a nice place to start up the engine, after |
|
152 |
|
|
150 | * loading configuration stuff in the constructor |
|
153 | */ |
|
151 | */ |
|
154 |
|
|
152 | this.IsMouseVisible = true; |
|
155 |
|
153 | ||
|
156 |
|
|
154 | _imGuiRenderer = new ImGuiRenderer(this); |
|
157 |
|
|
155 | _imGuiRenderer.RebuildFontAtlas(); // Required so fonts are available for rendering |
|
158 |
|
|||
|
159 | base.Initialize(); |
|
||
|
160 | } |
|
||
|
161 |
|
156 | ||
|
162 | protected override void LoadContent() |
|
157 | base.Initialize(); |
|
163 | { |
|
158 | } |
|
164 | // Create the batch... |
|
||
|
165 | batch = new SpriteBatch(GraphicsDevice); |
|
||
|
166 |
|
159 | ||
|
167 | sound = Content.Load<SoundEffect>("FNASound"); |
|
160 | protected override void LoadContent() |
|
168 | Tile.TileSetTexture = Content.Load<Texture2D>(@"part4_tileset"); |
|
161 | { |
|
|
162 | // Create the batch... | ||
|
|
163 | batch = new SpriteBatch(GraphicsDevice); | ||
|
169 |
|
164 | ||
|
170 | Line.initialize(GraphicsDevice); |
|
165 | sound = Content.Load<SoundEffect>("FNASound"); |
|
|
166 | Tile.TileSetTexture = Content.Load<Texture2D>(@"part4_tileset"); | ||
|
|
167 | |||
|
|
168 | Line.initialize(GraphicsDevice); | ||
|
171 |
|
169 | ||
|
172 |
|
170 | ||
|
173 |
|
|
171 | var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), |
|
174 | 15, |
|
172 | 15, |
|
175 | 1024, |
|
173 | 1024, |
|
176 | 1024, |
|
174 | 1024, |
|
177 | new[] |
|
175 | new[] |
|
178 | { |
|
176 | { |
|
179 |
|
|
177 | CharacterRange.BasicLatin, |
|
180 |
|
|
178 | CharacterRange.Latin1Supplement, |
|
181 |
|
|
179 | CharacterRange.LatinExtendedA, |
|
182 |
|
|
180 | CharacterRange.Cyrillic, |
|
183 |
|
|
181 | CharacterRange.LatinExtendedB, |
|
184 |
|
|
182 | new CharacterRange((char) 0x00B7) |
|
185 | } |
|
183 | } |
|
186 | ); |
|
184 | ); |
|
187 |
|
185 | ||
|
188 |
|
|
186 | this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice); |
|
189 |
|
187 | ||
|
190 |
|
|
188 | var json2 = new FileInfo(@"Content/grammar.json"); |
|
191 |
|
189 | ||
|
192 |
|
|
190 | this.grammar = new TraceryNet.Grammar(json2); |
|
193 |
|
191 | ||
|
194 |
|
|
192 | this.output = grammar.Flatten("#greeting#"); |
|
195 |
|
|
193 | var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#"); |
|
196 |
|
194 | ||
|
197 |
|
|
195 | this.remainingDialog = new Queue<Node<DialogOption>>(); |
|
|
196 | |||
|
|
197 | this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar)); | ||
|
198 |
|
198 | ||
|
199 | this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar)); |
|
199 | //font = fontBakeResult.CreateSpriteFont(GraphicsDevice); |
|
200 |
|
200 | monoFont = bakedMono.CreateSpriteFont(GraphicsDevice); | |
|
201 | //font = fontBakeResult.CreateSpriteFont(GraphicsDevice); |
|
||
|
202 | monoFont = bakedMono.CreateSpriteFont(GraphicsDevice); |
|
||
|
203 |
|
201 | ||
|
204 |
|
|
202 | this.budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0); |
|
205 |
|
203 | ||
|
206 |
|
204 | ||
|
207 | } |
|
205 | } |
|
208 |
|
206 | ||
|
209 |
|
|
207 | protected override void UnloadContent() |
|
210 | { |
|
208 | { |
|
211 |
|
|
209 | batch.Dispose(); |
|
212 |
|
|
210 | sound.Dispose(); |
|
213 |
|
|
211 | Tile.TileSetTexture.Dispose(); |
|
214 | } |
|
212 | } |
|
215 |
|
213 | ||
|
216 |
|
|
214 | Vector2 calculateMousegrid(Vector2 normalizedMousePos) |
|
217 | { |
|
215 | { |
|
218 |
|
216 | ||
|
219 |
|
|
217 | //int gridx = (int)(normalizedMousePos.X / Tile.TileSpriteWidth); |
|
220 |
|
|
218 | //int gridy = (int)(normalizedMousePos.Y / Tile.TileSpriteHeight); |
|
221 |
|
|
219 | Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); |
|
222 |
|
|
220 | Vector2 adjustedMousePos = normalizedMousePos - adjust; |
|
223 |
|
221 | ||
|
224 |
|
|
222 | float boardx = ((adjustedMousePos.X / Tile.TileSpriteWidth) + (adjustedMousePos.Y / Tile.TileSpriteHeight)); |
|
225 |
|
|
223 | float boardy = ((adjustedMousePos.Y / Tile.TileSpriteHeight) - (adjustedMousePos.X / Tile.TileSpriteWidth)); |
|
226 |
|
224 | ||
|
227 |
|
225 | ||
|
228 |
|
|
226 | return new Vector2((int)boardx, (int)boardy); |
|
229 | /* |
|
227 | /* |
|
230 |
|
|
228 | int gridx = (int)((normalizedMousePos.X + (this.baseOffsetX + 4)) / Tile.TileWidth) ; |
|
231 |
|
|
229 | int gridy = (int)((normalizedMousePos.Y + (this.baseOffsetX + 4) + (2*baseOffsetY)) / (Tile.TileStepY)); |
|
232 |
|
230 | ||
|
233 |
|
231 | ||
|
234 |
|
232 | ||
|
235 |
|
233 | ||
|
236 |
|
|
234 | int within_gridx = (int)((normalizedMousePos.X) % Tile.TileWidth) - (Tile.TileWidth/2); |
|
237 |
|
|
235 | int within_gridy = (int)((normalizedMousePos.Y) % Tile.TileHeight) - (Tile.TileHeight / 2); |
|
238 |
|
236 | ||
|
239 |
|
|
237 | int middle_distance = Math.Abs(within_gridx) + Math.Abs(within_gridx); |
|
240 |
|
|
238 | Vector2 adjustment_vector; |
|
241 |
|
239 | ||
|
242 |
|
|
240 | return new Vector2(gridx, gridy); |
|
243 |
|
|
241 | if (middle_distance < (Tile.TileWidth / 2)) |
|
244 | { |
|
242 | { |
|
245 |
|
|
243 | return new Vector2(gridx, gridy); |
|
246 | } |
|
244 | } |
|
247 |
|
245 | ||
|
248 |
|
|
246 | else if ((Math.Sign(within_gridx) == -1) && (Math.Sign(within_gridy) == 1)) |
|
249 | { |
|
247 | { |
|
250 |
|
|
248 | adjustment_vector = new Vector2(-1, -1); |
|
251 |
|
|
249 | return new Vector2(gridx, gridy) + adjustment_vector; |
|
252 | } |
|
250 | } |
|
253 |
|
|
251 | else if ((Math.Sign(within_gridx) == -1) && (Math.Sign(within_gridy) == -1)) |
|
254 | { |
|
252 | { |
|
255 |
|
|
253 | adjustment_vector = new Vector2(-1, 1); |
|
256 |
|
|
254 | return new Vector2(gridx, gridy) + adjustment_vector; |
|
257 | } |
|
255 | } |
|
258 |
|
|
256 | else if ((Math.Sign(within_gridx) == 1) && (Math.Sign(within_gridy) == 1)) |
|
259 | { |
|
257 | { |
|
260 |
|
|
258 | adjustment_vector = new Vector2(0, -1); |
|
261 |
|
|
259 | return new Vector2(gridx, gridy) + adjustment_vector; |
|
262 | } |
|
260 | } |
|
263 |
|
|
261 | else if ((Math.Sign(within_gridx) == 1) && (Math.Sign(within_gridy) == -1)) |
|
264 | { |
|
262 | { |
|
265 |
|
|
263 | adjustment_vector = new Vector2(0, 1); |
|
266 |
|
|
264 | return new Vector2(gridx, gridy) + adjustment_vector; |
|
267 | } |
|
265 | } |
|
268 | else { |
|
266 | else { |
|
269 |
|
|
267 | return new Vector2(gridx, gridy); |
|
270 | } |
|
268 | } |
|
271 | */ |
|
269 | */ |
|
272 |
|
270 | ||
|
273 |
|
271 | ||
|
274 |
|
272 | ||
|
275 | } |
|
273 | } |
|
276 |
|
274 | ||
|
277 |
|
275 | ||
|
278 |
|
276 | ||
|
279 |
|
|
277 | protected override void Update(GameTime gameTime) |
|
280 | { |
|
278 | { |
|
281 |
|
279 | ||
|
282 |
|
|
280 | Stopwatch stopWatch = new Stopwatch(); |
|
283 |
|
|
281 | stopWatch.Start(); |
|
284 |
|
282 | ||
|
285 |
|
|
283 | float volume = 1.0f; |
|
286 |
|
|
284 | float pitch = 0.0f; |
|
287 |
|
|
285 | float pan = 0.0f; |
|
288 |
|
286 | ||
|
289 |
|
287 | ||
|
290 |
|
|
288 | // Run game logic in here. Do NOT render anything here! |
|
291 |
|
|
289 | KeyboardState keyboardCur = Keyboard.GetState(); |
|
292 |
|
290 | ||
|
293 |
|
|
291 | #region input |
|
294 |
|
|
292 | #region camera_movement_keys |
|
295 | if (keyboardCur.IsKeyDown(Keys.Down)) |
|
293 | if (keyboardCur.IsKeyDown(Keys.Down)) |
|
296 | { |
|
294 | { |
|
297 |
|
|
295 | this.camera.Move(new Vector2(0, 2)); |
|
298 | } |
|
296 | } |
|
299 |
|
|
297 | else if (keyboardCur.IsKeyDown(Keys.Up)) |
|
300 | { |
|
298 | { |
|
301 |
|
|
299 | this.camera.Move(new Vector2(0, -2)); |
|
302 |
|
300 | ||
|
303 | } |
|
301 | } |
|
304 |
|
|
302 | else if (keyboardCur.IsKeyDown(Keys.Left)) |
|
305 | { |
|
303 | { |
|
306 |
|
|
304 | this.camera.Move(new Vector2(-2, 0)); |
|
307 |
|
305 | ||
|
308 | } |
|
306 | } |
|
309 |
|
|
307 | else if (keyboardCur.IsKeyDown(Keys.Right)) |
|
310 | { |
|
308 | { |
|
311 |
|
|
309 | this.camera.Move(new Vector2(2, 0)); |
|
312 |
|
310 | ||
|
313 | } |
|
311 | } |
|
314 |
|
|
312 | else if (keyboardCur.IsKeyDown(Keys.Subtract) && keyboardPrev.IsKeyUp(Keys.Subtract)) |
|
315 | { |
|
313 | { |
|
316 |
|
|
314 | this.camera.ZoomOut(); |
|
317 | } |
|
315 | } |
|
318 |
|
|
316 | else if (keyboardCur.IsKeyDown(Keys.Add) && keyboardPrev.IsKeyUp(Keys.Add)) |
|
319 | { |
|
317 | { |
|
320 |
|
318 | ||
|
321 |
|
|
319 | this.camera.ZoomIn(); |
|
322 | } |
|
320 | } |
|
323 |
|
|
321 | #endregion camera_movement_keys |
|
324 |
|
322 | ||
|
325 |
|
|
323 | #region misc_keys |
|
326 |
|
|
324 | if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q)) |
|
327 | { |
|
325 | { |
|
328 |
|
|
326 | System.Console.WriteLine("Quitting"); |
|
329 |
|
|
327 | Environment.Exit(0); |
|
330 | } |
|
328 | } |
|
331 |
|
|
329 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash)) |
|
332 | { |
|
330 | { |
|
333 |
|
|
331 | this.show_another_window = !this.show_another_window; |
|
334 |
|
332 | ||
|
335 | } |
|
333 | } |
|
336 |
|
334 | ||
|
337 |
|
|
335 | if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G)) |
|
338 | { |
|
336 | { |
|
339 |
|
|
337 | this.showGrid = !this.showGrid; |
|
340 |
|
338 | ||
|
341 | } |
|
339 | } |
|
342 |
|
|
340 | if (keyboardCur.IsKeyDown(Keys.B) && keyboardPrev.IsKeyUp(Keys.B)) |
|
343 | { |
|
341 | { |
|
344 |
|
|
342 | this.showBudget = !this.showBudget; |
|
345 |
|
343 | ||
|
346 | } |
|
344 | } |
|
347 |
|
|
345 | if (keyboardCur.IsKeyDown(Keys.F) && keyboardPrev.IsKeyUp(Keys.F)) |
|
348 | { |
|
346 | { |
|
349 |
|
|
347 | this.showForest = !this.showForest; |
|
350 |
|
348 | ||
|
351 | } |
|
349 | } |
|
352 |
|
|
350 | if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C)) |
|
353 | { |
|
351 | { |
|
354 |
|
|
352 | this.camera.Jump(Vector2.Zero); |
|
355 |
|
353 | ||
|
356 | } |
|
354 | } |
|
357 |
|
|
355 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) |
|
358 | { |
|
356 | { |
|
359 |
|
|
357 | sound.Play(volume, pitch, pan); |
|
360 | } |
|
358 | } |
|
361 |
|
|
359 | #endregion misc_keys |
|
362 |
|
360 | ||
|
363 |
|
361 | ||
|
364 |
|
|
362 | #region gamerate_keys |
|
365 |
|
|
363 | if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0) ) |
|
366 | { |
|
364 | { |
|
367 |
|
|
365 | this.simulation.paused = !this.simulation.paused; |
|
368 |
|
366 | ||
|
369 | } |
|
367 | } |
|
370 |
|
|
368 | #endregion gamerate_keys |
|
371 |
|
369 | ||
|
372 |
|
370 | ||
|
373 |
|
371 | ||
|
374 |
|
372 | ||
|
375 |
|
|
373 | //if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P)) |
|
376 |
|
|
374 | // { |
|
377 |
|
|
375 | // this.player_state = !this.player_state; |
|
378 |
|
|
376 | // } |
|
379 |
|
377 | ||
|
380 |
|
|
378 | //if (player_state ) |
|
381 | //{ |
|
379 | //{ |
|
382 |
|
|
380 | // MediaPlayer.Play(music); |
|
383 | //} |
|
381 | //} |
|
384 |
|
382 | ||
|
385 |
|
383 | ||
|
386 |
|
|
384 | MouseState mouseCur = Mouse.GetState(); |
|
387 |
|
|
385 | this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); |
|
388 |
|
386 | ||
|
389 |
|
|
387 | if (MathUtils.Between(mouseCur.X, 0, 50)) |
|
390 | { |
|
388 | { |
|
391 |
|
|
389 | this.camera.Move(new Vector2(-4, 0)); |
|
392 | } |
|
390 | } |
|
393 |
|
|
391 | else if (MathUtils.Between(mouseCur.X, (FNAGame.width - 50), FNAGame.width)) |
|
394 | { |
|
392 | { |
|
395 |
|
|
393 | this.camera.Move(new Vector2(4, 0)); |
|
396 | } |
|
394 | } |
|
397 |
|
395 | ||
|
398 |
|
|
396 | if (MathUtils.Between(mouseCur.Y, 0, 50)) |
|
399 | { |
|
397 | { |
|
400 |
|
|
398 | this.camera.Move(new Vector2(0, -4)); |
|
401 | } |
|
399 | } |
|
402 |
|
|
400 | else if (MathUtils.Between(mouseCur.Y, (FNAGame.height - 50), FNAGame.height)) |
|
403 | { |
|
401 | { |
|
404 |
|
|
402 | this.camera.Move(new Vector2(0, 4)); |
|
405 | } |
|
403 | } |
|
406 |
|
404 | ||
|
407 |
|
|
405 | if (mouseCur.RightButton == ButtonState.Pressed) |
|
408 | { |
|
406 | { |
|
409 |
|
|
407 | Vector2 cameraMiddle = this.camera.position + new Vector2(FNAGame.width / 2, FNAGame.height / 2); |
|
410 |
|
|
408 | Vector2 delta = this.camera.position - this.original_point; |
|
411 |
|
|
409 | this.camera.Jump(this.original_point); |
|
|
410 | } | ||
|
|
411 | |||
|
|
412 | #endregion input | ||
|
|
413 | |||
|
|
414 | |||
|
|
415 | |||
|
|
416 | this.simulation.update(gameTime.ElapsedGameTime); | ||
|
|
417 | |||
|
|
418 | if (this.showBudget) | ||
|
|
419 | { | ||
|
|
420 | this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget); | ||
|
412 | } |
|
421 | } |
|
413 |
|
422 | ||
|
414 | #endregion input |
|
||
|
415 |
|
|||
|
416 |
|
|||
|
417 |
|
|||
|
418 | this.simulation.update(gameTime.ElapsedGameTime); |
|
||
|
419 |
|
423 | ||
|
420 | if (this.showBudget) |
|
424 | if (!this.showInitial && this.remainingDialog.Count > 0) |
|
421 | { |
|
425 | { |
|
422 | this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget); |
|
426 | this.currentNode = this.remainingDialog.Dequeue(); |
|
423 | } |
|
427 | this.showInitial = true; |
|
|
428 | } | ||
|
424 |
|
429 | ||
|
|
430 | this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); | ||
|
425 |
|
431 | ||
|
426 | if (!this.showInitial && this.remainingDialog.Count > 0) |
|
432 | //int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX); |
|
427 | { |
|
433 | /* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */ |
|
428 | this.currentNode = this.remainingDialog.Dequeue(); |
|
434 | //int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2)); |
|
429 | this.showInitial = true; |
|
435 | /* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */ |
|
430 | } |
|
||
|
431 |
|
|||
|
432 | this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); |
|
||
|
433 |
|
436 | ||
|
434 | //int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX); |
|
437 | //this.mouseGrid = new Vector2(gridx, gridy); |
|
435 | /* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */ |
|
438 | this.mouseGrid = this.calculateMousegrid(this.original_point); |
|
436 | //int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2)); |
|
||
|
437 | /* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */ |
|
||
|
438 |
|
439 | ||
|
439 | //this.mouseGrid = new Vector2(gridx, gridy); |
|
440 | elapsedTime += gameTime.ElapsedGameTime; |
|
440 | this.mouseGrid = this.calculateMousegrid(this.original_point); |
|
||
|
441 |
|
|||
|
442 | elapsedTime += gameTime.ElapsedGameTime; |
|
||
|
443 |
|
441 | ||
|
444 |
|
|
442 | if (elapsedTime > TimeSpan.FromSeconds(1)) |
|
445 | { |
|
443 | { |
|
446 |
|
|
444 | elapsedTime -= TimeSpan.FromSeconds(1); |
|
447 |
|
|
445 | frameRate = frameCounter; |
|
448 |
|
|
446 | frameCounter = 0; |
|
449 | } |
|
447 | } |
|
450 |
|
448 | ||
|
451 |
|
|
449 | this.keyboardPrev = keyboardCur; |
|
452 |
|
450 | ||
|
453 |
|
|
451 | stopWatch.Stop(); |
|
454 |
|
|
452 | this.updateTime = stopWatch.Elapsed; |
|
455 |
|
453 | ||
|
456 |
|
|
454 | base.Update(gameTime); |
|
457 |
|
455 | ||
|
458 | } |
|
456 | } |
|
459 |
|
457 | ||
|
460 |
|
|
458 | protected float calculateDepth() { |
|
461 |
|
|
459 | return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; |
|
462 | } |
|
460 | } |
|
463 |
|
461 | ||
|
464 |
|
|
462 | protected Boolean cull(int gridX, int gridY) |
|
465 | { |
|
463 | { |
|
466 |
|
|
464 | int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2; |
|
467 |
|
|
465 | int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2; |
|
468 |
|
466 | ||
|
469 |
|
|
467 | Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice)); |
|
470 |
|
468 | ||
|
471 |
|
|
469 | return (!FNAGame.enableCulling || |
|
472 |
|
|
470 | (MathUtils.Between(original.X, -Tile.TileSpriteWidth, FNAGame.width) |
|
473 |
|
|
471 | && MathUtils.Between(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); |
|
474 | } |
|
472 | } |
|
475 |
|
473 | ||
|
476 | //Convenience method I'm not super sure about anymore. |
|
474 | //Convenience method I'm not super sure about anymore. |
|
477 | protected void drawTileAt(int x, int y, int tileIndex, int height) |
|
475 | protected void drawTileAt(int x, int y, int tileIndex, int height) |
|
478 | { |
|
476 | { |
|
479 |
|
|
477 | float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; |
|
480 |
|
478 | ||
|
481 |
|
|
479 | float depthOffset = 0.7f - ((0 + (0 * Tile.TileWidth)) / maxdepth); |
|
482 |
|
480 | ||
|
483 |
|
|
481 | Tile.drawTileAt(this.batch, x, y, tileIndex, height, depthOffset); |
|
484 | } |
|
482 | } |
|
485 |
|
483 | ||
|
486 |
|
484 | ||
|
487 |
|
485 | ||
|
488 |
|
|
486 | protected override void Draw(GameTime gameTime) |
|
489 | { |
|
487 | { |
|
490 | // Render stuff in here. Do NOT run game logic in here! |
|
488 | // Render stuff in here. Do NOT run game logic in here! |
|
491 |
|
489 | ||
@@ -497,52 +495,52 | |||||
|
497 | stopWatch.Start(); |
|
495 | stopWatch.Start(); |
|
498 | GraphicsDevice.Clear(Color.CornflowerBlue); |
|
496 | GraphicsDevice.Clear(Color.CornflowerBlue); |
|
499 | batch.Begin(SpriteSortMode.BackToFront, |
|
497 | batch.Begin(SpriteSortMode.BackToFront, |
|
500 |
|
|
498 | BlendState.AlphaBlend, |
|
501 |
|
|
499 | null, |
|
502 |
|
|
500 | null, |
|
503 |
|
|
501 | null, |
|
504 |
|
|
502 | null, |
|
505 |
|
|
503 | camera.get_transformation(GraphicsDevice)); |
|
506 |
|
504 | ||
|
507 | //New tile stuff |
|
505 | //New tile stuff |
|
508 | /* |
|
506 | /* |
|
509 |
|
|
507 | Vector2 firstSquare = Vector2.Zero; |
|
510 |
|
|
508 | int firstX = (int)firstSquare.X; |
|
511 |
|
|
509 | int firstY = (int)firstSquare.Y; |
|
512 |
|
510 | ||
|
513 |
|
|
511 | Vector2 squareOffset = Vector2.Zero; |
|
514 |
|
512 | ||
|
515 |
|
|
513 | int offsetX = (int)squareOffset.X; |
|
516 |
|
|
514 | int offsetY = (int)squareOffset.Y; |
|
517 |
|
515 | ||
|
518 |
|
516 | ||
|
519 |
|
|
517 | for (int y = 0; y < this.squaresDown; y++) |
|
520 | { |
|
518 | { |
|
521 |
|
|
519 | int rowOffset = 0; |
|
522 |
|
|
520 | if ((firstY + y) % 2 == 1) |
|
523 |
|
|
521 | rowOffset = Tile.OddRowXOffset; |
|
524 |
|
522 | ||
|
525 |
|
|
523 | for (int x = 0; x < this.squaresAcross; x++) { |
|
526 |
|
524 | ||
|
527 |
|
525 | ||
|
528 | batch.Draw( |
|
526 | batch.Draw( |
|
529 | Tile.TileSetTexture, |
|
527 | Tile.TileSetTexture, |
|
530 | new Rectangle( |
|
528 | new Rectangle( |
|
531 |
|
|
529 | ((x * Tile.TileStepX) - offsetX + rowOffset + baseOffsetX), |
|
532 |
|
|
530 | ((y * Tile.TileStepY) - offsetY + baseOffsetY), |
|
533 |
|
|
531 | Tile.TileWidth, Tile.TileHeight), |
|
534 |
|
|
532 | Tile.GetSourceRectangle(1), |
|
535 | Color.White, |
|
533 | Color.White, |
|
536 | 0.0f, |
|
534 | 0.0f, |
|
537 | Vector2.Zero, |
|
535 | Vector2.Zero, |
|
538 | SpriteEffects.None, |
|
536 | SpriteEffects.None, |
|
539 | 0.9f); |
|
537 | 0.9f); |
|
540 |
|
538 | ||
|
541 |
|
539 | ||
|
542 | } |
|
540 | } |
|
543 | }*/ |
|
541 | }*/ |
|
544 |
|
542 | ||
|
545 |
|
|
543 | #region draw_tiles |
|
546 | //reset |
|
544 | //reset |
|
547 | this.tilesDrawn = 0; |
|
545 | this.tilesDrawn = 0; |
|
548 |
|
546 | ||
@@ -559,25 +557,25 | |||||
|
559 | if (this.cull(x, y)) |
|
557 | if (this.cull(x, y)) |
|
560 | { |
|
558 | { |
|
561 | batch.Draw( |
|
559 | batch.Draw( |
|
562 | Tile.TileSetTexture, |
|
560 | Tile.TileSetTexture, |
|
563 | new Rectangle( |
|
561 | new Rectangle( |
|
564 | screenx, |
|
562 | screenx, |
|
565 | screeny, |
|
563 | screeny, |
|
566 | Tile.TileWidth, Tile.TileHeight), |
|
564 | Tile.TileWidth, Tile.TileHeight), |
|
567 | Tile.GetSourceRectangle(1), |
|
565 | Tile.GetSourceRectangle(1), |
|
568 | Color.White, |
|
566 | Color.White, |
|
569 | 0.0f, |
|
567 | 0.0f, |
|
570 | Vector2.Zero, |
|
568 | Vector2.Zero, |
|
571 | SpriteEffects.None, |
|
569 | SpriteEffects.None, |
|
572 | 0.9f); |
|
570 | 0.9f); |
|
573 |
|
571 | ||
|
574 | this.tilesDrawn++; |
|
572 | this.tilesDrawn++; |
|
575 | } |
|
573 | } |
|
576 | } |
|
574 | } |
|
577 | } |
|
575 | } |
|
578 |
|
|
576 | #endregion draw_tiles |
|
579 |
|
577 | ||
|
580 |
|
|
578 | #region draw_gridlines |
|
581 |
|
579 | ||
|
582 | if (this.showGrid) |
|
580 | if (this.showGrid) |
|
583 | { |
|
581 | { |
@@ -588,10 +586,13 | |||||
|
588 | Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved |
|
586 | Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved |
|
589 |
|
587 | ||
|
590 | Line.drawLine(batch, |
|
588 | Line.drawLine(batch, |
|
591 |
|
|
589 | new Vector2(((0 - y) * Tile.TileSpriteWidth / 2), |
|
592 |
|
|
590 | (0 + y) * Tile.TileSpriteHeight / 2) + adjust, |
|
593 |
|
|
591 | //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight), |
|
594 | Color.White, 0.8f); |
|
592 | new Vector2((this.squaresAcross - (y)) * Tile.TileSpriteWidth / 2, |
|
|
593 | (this.squaresAcross + (y)) * Tile.TileSpriteHeight / 2) + adjust, | ||
|
|
594 | |||
|
|
595 | Color.White, 0.8f); | ||
|
595 |
|
596 | ||
|
596 | } |
|
597 | } |
|
597 |
|
598 | ||
@@ -601,112 +602,112 | |||||
|
601 | Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved |
|
602 | Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight); //TODO figure out why this second value shouldn't be halved |
|
602 |
|
603 | ||
|
603 | Line.drawLine(batch, |
|
604 | Line.drawLine(batch, |
|
604 |
|
|
605 | new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust, |
|
605 |
|
|
606 | //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight), |
|
606 |
|
|
607 | new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust, |
|
607 |
|
|
608 | Color.White, 0.8f); |
|
608 |
|
609 | ||
|
609 | } |
|
610 | } |
|
610 | } |
|
611 | } |
|
611 |
|
|
612 | #endregion draw_gridlines |
|
612 |
|
613 | ||
|
613 |
|
614 | ||
|
614 |
|
|
615 | //Gridlines |
|
615 |
|
|
616 | //Lines going down and to the right: |
|
616 |
|
|
617 | /* |
|
617 |
|
|
618 | for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++) |
|
618 | { |
|
619 | { |
|
619 |
|
|
620 | int rowOffset = 0; |
|
620 |
|
621 | ||
|
621 |
|
|
622 | float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2); |
|
622 |
|
623 | ||
|
623 |
|
|
624 | Vector2 start = new Vector2(startX, -baseOffsetY+4); |
|
624 |
|
|
625 | Vector2 stop = new Vector2(startX + this.squaresAcross* Tile.TileStepX/2, |
|
625 |
|
|
626 | this.squaresDown*Tile.TileStepY- baseOffsetY+4); |
|
626 |
|
627 | ||
|
627 |
|
628 | ||
|
628 |
|
629 | ||
|
629 |
|
|
630 | Line.drawLine(batch, |
|
630 |
|
|
631 | Line.departurePoint(stop, start, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight), |
|
631 |
|
|
632 | Line.departurePoint(start, stop, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight), |
|
632 |
|
|
633 | Color.White, 0.8f); |
|
633 |
|
634 | ||
|
634 | } |
|
635 | } |
|
635 |
|
|
636 | //Lines going down and to the left: |
|
636 |
|
|
637 | for (int x = 0; x < (int)(1.5*this.squaresAcross); x++) |
|
637 | { |
|
638 | { |
|
638 |
|
639 | ||
|
639 |
|
|
640 | float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2); |
|
640 |
|
641 | ||
|
641 |
|
|
642 | Vector2 start_reverse = new Vector2(startX, -baseOffsetY + 4); |
|
642 |
|
|
643 | Vector2 stop_reverse = new Vector2(startX + -(this.squaresAcross * Tile.TileStepX / 2), |
|
643 |
|
|
644 | (this.squaresDown * Tile.TileStepY) - baseOffsetY + 4); |
|
644 |
|
645 | ||
|
645 |
|
|
646 | Line.drawLine(batch, |
|
646 |
|
|
647 | Line.departurePoint(stop_reverse, start_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight), |
|
647 |
|
|
648 | Line.departurePoint(start_reverse, stop_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight), |
|
648 |
|
|
649 | Color.White, 0.8f); |
|
649 |
|
650 | ||
|
650 | } |
|
651 | } |
|
651 | */ |
|
652 | */ |
|
652 |
|
653 | ||
|
653 | #if DEBUG |
|
654 | #if DEBUG |
|
654 | drawTileAt(4, 4, 140, 3); |
|
655 | drawTileAt(4, 4, 140, 3); |
|
655 | drawTileAt(6, 4, 141, 3); |
|
656 | drawTileAt(6, 4, 141, 3); |
|
656 | drawTileAt(8, 4, 142, 2); |
|
657 | drawTileAt(8, 4, 142, 2); |
|
657 | drawTileAt(10, 4, 142, 3); |
|
658 | drawTileAt(10, 4, 142, 3); |
|
658 | #endif |
|
659 | #endif |
|
659 |
|
660 | ||
|
660 |
|
|
661 | #region draw_cursor |
|
661 |
|
|
662 | //drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines |
|
662 |
|
663 | ||
|
663 |
|
|
664 | //TODO figure out why it has to be -1 |
|
664 | if (MathUtils.Between(this.mouseGrid.X, -1, this.simulation.map.MapWidth) |
|
665 | if (MathUtils.Between(this.mouseGrid.X, -1, this.simulation.map.MapWidth) |
|
665 |
|
|
666 | && MathUtils.Between(this.mouseGrid.Y, -1, this.simulation.map.MapHeight)) |
|
666 | { |
|
667 | { |
|
667 |
|
|
668 | Tile.OutlineSquare(batch, this.mouseGrid.X, this.mouseGrid.Y, Color.Yellow, 1); |
|
668 | } |
|
669 | } |
|
669 |
|
670 | ||
|
670 | #if DEBUG |
|
671 | #if DEBUG |
|
671 |
|
|
672 | Tile.OutlineSquare(batch, 1, 1, Color.Red, 2); |
|
672 |
|
|
673 | Tile.OutlineSquare(batch, 3, 1, Color.Blue, 2); |
|
673 |
|
|
674 | Tile.OutlineSquare(batch, 5, 1, Color.Green, 2); |
|
674 |
|
|
675 | Tile.OutlineSquare(batch, 7, 1, Color.Orange, 2); |
|
675 | #endif |
|
676 | #endif |
|
676 |
|
677 | ||
|
677 |
|
678 | ||
|
678 |
|
679 | ||
|
679 | #endregion draw_cursor |
|
680 | #endregion draw_cursor |
|
680 | /* |
|
681 | /* |
|
681 |
|
682 | ||
|
682 |
|
|
683 | for (int i = 0; i< 80; i++) |
|
683 | { |
|
684 | { |
|
684 |
|
|
685 | for (int j = 0; j < 50; j += 1) |
|
685 | { |
|
686 | { |
|
686 |
|
|
687 | //Warning: creates a flashing effect because tree positions update every 1/60th of a second |
|
687 |
|
688 | ||
|
688 |
|
|
689 | if (this.random_generator.NextDouble() > 0.75) |
|
689 | { |
|
690 | { |
|
690 |
|
|
691 | drawTileAt(i, j, 142, 2); |
|
691 | } |
|
692 | } |
|
692 |
|
693 | ||
|
693 |
|
|
694 | if ((i + j) % 3 == 0) |
|
694 | { |
|
695 | { |
|
695 |
|
|
696 | drawTileAt(i, j, 142, 2); |
|
696 | } |
|
697 | } |
|
697 |
|
698 | ||
|
698 | } |
|
699 | } |
|
699 | }//*/ |
|
700 | }//*/ |
|
700 |
|
701 | ||
|
701 | #region draw_trees |
|
702 | #region draw_trees |
|
702 |
|
|
703 | for (int i = 0; i < this.simulation.map.MapHeight; i++) |
|
703 | { |
|
704 | { |
|
704 | for (int j = 0; j < this.simulation.map.MapWidth; j += 1) |
|
705 | for (int j = 0; j < this.simulation.map.MapWidth; j += 1) |
|
705 | { |
|
706 | { |
|
706 |
|
707 | ||
|
707 | if (this.simulation.map.cells[i][j].hasTree) |
|
708 | if (this.simulation.map.cells[i][j].hasTree) |
|
708 | { //until we actually simulate: |
|
709 | { //until we actually simulate: |
|
709 |
|
|
710 | drawTileAt(i, j, 142, 2); |
|
710 | // if ((i + j) % 8 == 0) |
|
711 | // if ((i + j) % 8 == 0) |
|
711 | // { |
|
712 | // { |
|
712 | // drawTileAt(i, j, 141, 2); |
|
713 | // drawTileAt(i, j, 141, 2); |
@@ -716,11 +717,11 | |||||
|
716 | // drawTileAt(i, j, 142, 2); |
|
717 | // drawTileAt(i, j, 142, 2); |
|
717 | // } |
|
718 | // } |
|
718 | } |
|
719 | } |
|
719 |
|
|
720 | else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree) { |
|
720 |
|
|
721 | drawTileAt(i, j, 141, 2); |
|
721 |
|
|
722 | // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j)); |
|
722 |
|
723 | ||
|
723 | } |
|
724 | } |
|
724 | } |
|
725 | } |
|
725 | } |
|
726 | } |
|
726 | #endregion draw_trees |
|
727 | #endregion draw_trees |
@@ -733,11 +734,11 | |||||
|
733 |
|
734 | ||
|
734 | #region draw_header |
|
735 | #region draw_header |
|
735 | batch.Begin(SpriteSortMode.BackToFront, |
|
736 | batch.Begin(SpriteSortMode.BackToFront, |
|
736 |
|
|
737 | BlendState.AlphaBlend, |
|
737 |
|
|
738 | null, |
|
738 |
|
|
739 | null, |
|
739 |
|
|
740 | null, |
|
740 |
|
|
741 | null); |
|
741 |
|
742 | ||
|
742 | bool has_tree = false; |
|
743 | bool has_tree = false; |
|
743 | if (MathUtils.Between(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.Between(this.mouseGrid.Y, 0, this.squaresAcross)) |
|
744 | if (MathUtils.Between(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.Between(this.mouseGrid.Y, 0, this.squaresAcross)) |
@@ -766,22 +767,22 | |||||
|
766 | batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
767 | batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
767 | batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
768 | batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
768 | batch.DrawString(monoFont, header_right, new Vector2(right_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
769 | batch.DrawString(monoFont, header_right, new Vector2(right_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); |
|
769 |
|
|
770 | #endregion draw_header |
|
770 |
|
771 | ||
|
771 |
|
772 | ||
|
772 |
|
|
773 | #region budget |
|
773 |
|
774 | ||
|
774 |
|
|
775 | if (this.showBudget) |
|
775 | { |
|
776 | { |
|
776 |
|
|
777 | budgetWindow.draw(batch); |
|
777 |
|
778 | ||
|
778 | } |
|
779 | } |
|
779 |
|
780 | ||
|
780 |
|
|
781 | #endregion budget |
|
781 |
|
782 | ||
|
782 |
|
|
783 | batch.End(); |
|
783 |
|
784 | ||
|
784 |
|
785 | ||
|
785 |
|
786 | ||
|
786 |
|
787 | ||
|
787 | #region debug_window |
|
788 | #region debug_window |
@@ -793,12 +794,11 | |||||
|
793 | } |
|
794 | } |
|
794 |
|
795 | ||
|
795 | DebugInfo debugInfo = new DebugInfo |
|
796 | DebugInfo debugInfo = new DebugInfo |
|
796 | { |
|
797 | { fps = this.frameRate, |
|
797 | fps = this.frameRate, |
|
||
|
798 | pastFps = past_fps.ToArray(), |
|
798 | pastFps = past_fps.ToArray(), |
|
799 | cameraPosition = camera.position, |
|
799 | cameraPosition = camera.position, |
|
800 | drawTime = this.drawTime, |
|
800 | drawTime = this.drawTime, |
|
801 |
|
|
801 | updateTime = this.updateTime, |
|
802 | treeCount = this.simulation.map.tree_count, |
|
802 | treeCount = this.simulation.map.tree_count, |
|
803 | mouseGrid = this.mouseGrid, |
|
803 | mouseGrid = this.mouseGrid, |
|
804 | hasTree = has_tree, |
|
804 | hasTree = has_tree, |
@@ -810,37 +810,37 | |||||
|
810 |
|
810 | ||
|
811 | var additionalInfo = new Dictionary<string, string>(); |
|
811 | var additionalInfo = new Dictionary<string, string>(); |
|
812 |
|
812 | ||
|
813 |
|
|
813 | Vector2 cameraMiddle = this.camera.position + new Vector2(FNAGame.width / 2, FNAGame.height / 2); |
|
814 |
|
|
814 | var state = Mouse.GetState(); |
|
815 |
|
|
815 | Vector2 delta = this.camera.position - this.original_point; |
|
816 |
|
816 | ||
|
817 |
|
|
817 | additionalInfo.Add("cameraMiddle", cameraMiddle.ToString()); |
|
818 |
|
|
818 | additionalInfo.Add("mouse ", String.Format("{0}, {1}", state.X, state.Y)); |
|
819 |
|
|
819 | additionalInfo.Add("mouse delta", delta.ToString()); |
|
820 |
|
820 | ||
|
821 |
|
|
821 | additionalInfo.Add("Tracery Test", this.output); |
|
822 |
|
822 | ||
|
823 |
|
|
823 | debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window); |
|
824 |
|
824 | ||
|
825 |
|
825 | ||
|
826 |
|
|
826 | //debugWindow.ImGuiLayout(); |
|
827 |
|
|
827 | //String[] messages = { "Message1", "Message2" }; |
|
828 |
|
828 | ||
|
829 |
|
|
829 | //DialogOption[] dialog = { new DialogOption{ response="Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out.", choice="Okay" }, |
|
830 |
|
|
830 | // new DialogOption{ response="Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!", choice="And I need to keep the forest healthy, too, right?" }, |
|
831 |
|
|
831 | // new DialogOption{ response="Oh yeah, of course.", choice="..." }}; |
|
832 |
|
832 | ||
|
833 |
|
833 | ||
|
834 |
|
|
834 | if (this.currentNode != null) |
|
835 | { |
|
835 | { |
|
836 | this.currentNode = DialogInterface.RenderDialog(ref this.showInitial, |
|
836 | this.currentNode = DialogInterface.RenderDialog(ref this.showInitial, |
|
837 | ref this.simulation.paused, debugWindow.monoFont, this.currentNode); |
|
837 | ref this.simulation.paused, debugWindow.monoFont, this.currentNode); |
|
838 | } |
|
838 | } |
|
839 |
|
839 | ||
|
840 |
|
|
840 | if (this.showForest) |
|
841 | { |
|
841 | { |
|
842 | ForestWindow.Render(ref this.showForest, debugWindow.monoFont, this.simulation); |
|
842 | ForestWindow.Render(ref this.showForest, debugWindow.monoFont, this.simulation); |
|
843 | } |
|
843 | } |
|
844 |
|
844 | ||
|
845 |
|
845 | ||
|
846 | _imGuiRenderer.AfterLayout(); |
|
846 | _imGuiRenderer.AfterLayout(); |
@@ -853,5 +853,5 | |||||
|
853 |
|
853 | ||
|
854 | base.Draw(gameTime); |
|
854 | base.Draw(gameTime); |
|
855 | } |
|
855 | } |
|
856 |
|
856 | ||
|
857 | } |
|
857 | } |
You need to be logged in to leave comments.
Login now