Description:
Fix messy indentation.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r101:4f41bd695964 -

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 private KeyboardState keyboardPrev = new KeyboardState();
28 private KeyboardState keyboardPrev = new KeyboardState();
29
29
30 private SpriteBatch batch;
30 private SpriteBatch batch;
31 private SoundEffect sound;
31 private SoundEffect sound;
32 private SpriteFont monoFont;
32 private SpriteFont monoFont;
33
33
34 private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f });
34 private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f });
35
35
36 Random random_generator = new Random();
36 Random random_generator = new Random();
37
37
38 int frameRate = 0;
38 int frameRate = 0;
39 int frameCounter = 0;
39 int frameCounter = 0;
40 TimeSpan elapsedTime = TimeSpan.Zero;
40 TimeSpan elapsedTime = TimeSpan.Zero;
41 TimeSpan drawTime = TimeSpan.Zero;
41 TimeSpan drawTime = TimeSpan.Zero;
42 TimeSpan updateTime = TimeSpan.Zero;
42 TimeSpan updateTime = TimeSpan.Zero;
43
43
44 Queue<float> past_fps = new Queue<float>(100);
44 Queue<float> past_fps = new Queue<float>(100);
45 int tilesDrawn = 0;
45 int tilesDrawn = 0;
46
46
47 private const int width = 1280;
47 private const int width = 1280;
48 private const int height = 640;
48 private const int height = 640;
49
49
50 //new tile stuff
50 //new tile stuff
51 int squaresAcross = 50;
51 int squaresAcross = 50;
52 int squaresDown = 50;
52 int squaresDown = 50;
53 // int baseOffsetX = -14;
53 // int baseOffsetX = -14;
54 // int baseOffsetY = -14;
54 // int baseOffsetY = -14;
55
55
56 Simulation simulation;
56 Simulation simulation;
57
57
58 Vector2 mouseGrid;
58 Vector2 mouseGrid;
59 Vector2 original_point;
59 Vector2 original_point;
60
60
61 private ImGuiRenderer _imGuiRenderer;
61 private ImGuiRenderer _imGuiRenderer;
62 private DebugWindow debugWindow;
62 private DebugWindow debugWindow;
63
63
64 bool show_another_window;
64 bool show_another_window;
65 private bool showInitial;
65 private bool showInitial;
66 int messageIndex;
66 int messageIndex;
67
67
68 //buggy
68 //buggy
69 private static bool enableCulling = false;
69 private static bool enableCulling = false;
70
70
71 private Node<DialogOption> currentNode;
71 private Node<DialogOption> currentNode;
72 private Queue<Node<DialogOption>> remainingDialog;
72 private Queue<Node<DialogOption>> remainingDialog;
73
73
74
74
75 private bool showGrid;
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 #if NETCOREAPP
85 #if NETCOREAPP
86 DllMap.Initialise(false);
86 DllMap.Initialise(false);
87 #endif
87 #endif
88 using FNAGame g = new FNAGame();
88 using FNAGame g = new FNAGame();
89 g.Run();
89 g.Run();
90 }
90 }
91
91
92
92
93
93
94
94
95 private FNAGame()
95 private FNAGame()
96 {
96 {
97 //this.device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.)
97 //this.device = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.)
98
98
99 #if DEBUG
99 #if DEBUG
100 foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
100 foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
101 {
101 {
102 Console.Out.Write(assembly.ToString() + "\n");
102 Console.Out.Write(assembly.ToString() + "\n");
103 }
103 }
104 ;
104 ;
105 #endif
105 #endif
106 this.gdm = new GraphicsDeviceManager(this)
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 foreach (List<Cell> row in this.simulation.map.cells)
118 foreach (List<Cell> row in this.simulation.map.cells)
121 {
119 {
122 foreach (Cell cell in row)
120 foreach (Cell cell in row)
123 {
121 {
124 if (this.random_generator.NextDouble() > 0.75)
122 if (this.random_generator.NextDouble() > 0.75)
125 {
123 {
126 int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR);
124 int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR);
127 int random_month = random_generator.Next(1, 12);
125 int random_month = random_generator.Next(1, 12);
128 DateTime random_date = new DateTime(random_year, random_month, 1);
126 DateTime random_date = new DateTime(random_year, random_month, 1);
129
127
130 cell.addTree(random_date);
128 cell.addTree(random_date);
131 }
129 }
132 }
130 }
133 }
131 }
134
132
135 showInitial = true;
133 showInitial = true;
136 messageIndex = 0;
134 messageIndex = 0;
137 showBudget = false;
135 showBudget = false;
138 showForest = true;
136 showForest = true;
139 showGrid = true;
137 showGrid = true;
140
138
141 this.Window.Title = "Isometric Park";
139 this.Window.Title = "Isometric Park";
142
140
143 Content.RootDirectory = "Content";
141 Content.RootDirectory = "Content";
144
142
145 currentNode = DialogTrees.introTree;
143 currentNode = DialogTrees.introTree;
146
144
147 }
145 }
148
146
149 protected override void Initialize()
147 protected override void Initialize()
150 {
148 {
151 /* This is a nice place to start up the engine, after
149 /* This is a nice place to start up the engine, after
152 * loading configuration stuff in the constructor
150 * loading configuration stuff in the constructor
153 */
151 */
154 this.IsMouseVisible = true;
152 this.IsMouseVisible = true;
155
153
156 _imGuiRenderer = new ImGuiRenderer(this);
154 _imGuiRenderer = new ImGuiRenderer(this);
157 _imGuiRenderer.RebuildFontAtlas(); // Required so fonts are available for rendering
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 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
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 CharacterRange.BasicLatin,
177 CharacterRange.BasicLatin,
180 CharacterRange.Latin1Supplement,
178 CharacterRange.Latin1Supplement,
181 CharacterRange.LatinExtendedA,
179 CharacterRange.LatinExtendedA,
182 CharacterRange.Cyrillic,
180 CharacterRange.Cyrillic,
183 CharacterRange.LatinExtendedB,
181 CharacterRange.LatinExtendedB,
184 new CharacterRange((char) 0x00B7)
182 new CharacterRange((char) 0x00B7)
185 }
183 }
186 );
184 );
187
185
188 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
186 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
189
187
190 var json2 = new FileInfo(@"Content/grammar.json");
188 var json2 = new FileInfo(@"Content/grammar.json");
191
189
192 this.grammar = new TraceryNet.Grammar(json2);
190 this.grammar = new TraceryNet.Grammar(json2);
193
191
194 this.output = grammar.Flatten("#greeting#");
192 this.output = grammar.Flatten("#greeting#");
195 var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#");
193 var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#");
196
194
197 this.remainingDialog = new Queue<Node<DialogOption>>();
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 this.budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0);
202 this.budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0);
205
203
206
204
207 }
205 }
208
206
209 protected override void UnloadContent()
207 protected override void UnloadContent()
210 {
208 {
211 batch.Dispose();
209 batch.Dispose();
212 sound.Dispose();
210 sound.Dispose();
213 Tile.TileSetTexture.Dispose();
211 Tile.TileSetTexture.Dispose();
214 }
212 }
215
213
216 Vector2 calculateMousegrid(Vector2 normalizedMousePos)
214 Vector2 calculateMousegrid(Vector2 normalizedMousePos)
217 {
215 {
218
216
219 //int gridx = (int)(normalizedMousePos.X / Tile.TileSpriteWidth);
217 //int gridx = (int)(normalizedMousePos.X / Tile.TileSpriteWidth);
220 //int gridy = (int)(normalizedMousePos.Y / Tile.TileSpriteHeight);
218 //int gridy = (int)(normalizedMousePos.Y / Tile.TileSpriteHeight);
221 Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight);
219 Vector2 adjust = new Vector2(Tile.TileSpriteWidth / 2, Tile.TileSpriteHeight);
222 Vector2 adjustedMousePos = normalizedMousePos - adjust;
220 Vector2 adjustedMousePos = normalizedMousePos - adjust;
223
221
224 float boardx = ((adjustedMousePos.X / Tile.TileSpriteWidth) + (adjustedMousePos.Y / Tile.TileSpriteHeight));
222 float boardx = ((adjustedMousePos.X / Tile.TileSpriteWidth) + (adjustedMousePos.Y / Tile.TileSpriteHeight));
225 float boardy = ((adjustedMousePos.Y / Tile.TileSpriteHeight) - (adjustedMousePos.X / Tile.TileSpriteWidth));
223 float boardy = ((adjustedMousePos.Y / Tile.TileSpriteHeight) - (adjustedMousePos.X / Tile.TileSpriteWidth));
226
224
227
225
228 return new Vector2((int)boardx, (int)boardy);
226 return new Vector2((int)boardx, (int)boardy);
229 /*
227 /*
230 int gridx = (int)((normalizedMousePos.X + (this.baseOffsetX + 4)) / Tile.TileWidth) ;
228 int gridx = (int)((normalizedMousePos.X + (this.baseOffsetX + 4)) / Tile.TileWidth) ;
231 int gridy = (int)((normalizedMousePos.Y + (this.baseOffsetX + 4) + (2*baseOffsetY)) / (Tile.TileStepY));
229 int gridy = (int)((normalizedMousePos.Y + (this.baseOffsetX + 4) + (2*baseOffsetY)) / (Tile.TileStepY));
232
230
233
231
234
232
235
233
236 int within_gridx = (int)((normalizedMousePos.X) % Tile.TileWidth) - (Tile.TileWidth/2);
234 int within_gridx = (int)((normalizedMousePos.X) % Tile.TileWidth) - (Tile.TileWidth/2);
237 int within_gridy = (int)((normalizedMousePos.Y) % Tile.TileHeight) - (Tile.TileHeight / 2);
235 int within_gridy = (int)((normalizedMousePos.Y) % Tile.TileHeight) - (Tile.TileHeight / 2);
238
236
239 int middle_distance = Math.Abs(within_gridx) + Math.Abs(within_gridx);
237 int middle_distance = Math.Abs(within_gridx) + Math.Abs(within_gridx);
240 Vector2 adjustment_vector;
238 Vector2 adjustment_vector;
241
239
242 return new Vector2(gridx, gridy);
240 return new Vector2(gridx, gridy);
243 if (middle_distance < (Tile.TileWidth / 2))
241 if (middle_distance < (Tile.TileWidth / 2))
244 {
242 {
245 return new Vector2(gridx, gridy);
243 return new Vector2(gridx, gridy);
246 }
244 }
247
245
248 else if ((Math.Sign(within_gridx) == -1) && (Math.Sign(within_gridy) == 1))
246 else if ((Math.Sign(within_gridx) == -1) && (Math.Sign(within_gridy) == 1))
249 {
247 {
250 adjustment_vector = new Vector2(-1, -1);
248 adjustment_vector = new Vector2(-1, -1);
251 return new Vector2(gridx, gridy) + adjustment_vector;
249 return new Vector2(gridx, gridy) + adjustment_vector;
252 }
250 }
253 else if ((Math.Sign(within_gridx) == -1) && (Math.Sign(within_gridy) == -1))
251 else if ((Math.Sign(within_gridx) == -1) && (Math.Sign(within_gridy) == -1))
254 {
252 {
255 adjustment_vector = new Vector2(-1, 1);
253 adjustment_vector = new Vector2(-1, 1);
256 return new Vector2(gridx, gridy) + adjustment_vector;
254 return new Vector2(gridx, gridy) + adjustment_vector;
257 }
255 }
258 else if ((Math.Sign(within_gridx) == 1) && (Math.Sign(within_gridy) == 1))
256 else if ((Math.Sign(within_gridx) == 1) && (Math.Sign(within_gridy) == 1))
259 {
257 {
260 adjustment_vector = new Vector2(0, -1);
258 adjustment_vector = new Vector2(0, -1);
261 return new Vector2(gridx, gridy) + adjustment_vector;
259 return new Vector2(gridx, gridy) + adjustment_vector;
262 }
260 }
263 else if ((Math.Sign(within_gridx) == 1) && (Math.Sign(within_gridy) == -1))
261 else if ((Math.Sign(within_gridx) == 1) && (Math.Sign(within_gridy) == -1))
264 {
262 {
265 adjustment_vector = new Vector2(0, 1);
263 adjustment_vector = new Vector2(0, 1);
266 return new Vector2(gridx, gridy) + adjustment_vector;
264 return new Vector2(gridx, gridy) + adjustment_vector;
267 }
265 }
268 else {
266 else {
269 return new Vector2(gridx, gridy);
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 protected override void Update(GameTime gameTime)
277 protected override void Update(GameTime gameTime)
280 {
278 {
281
279
282 Stopwatch stopWatch = new Stopwatch();
280 Stopwatch stopWatch = new Stopwatch();
283 stopWatch.Start();
281 stopWatch.Start();
284
282
285 float volume = 1.0f;
283 float volume = 1.0f;
286 float pitch = 0.0f;
284 float pitch = 0.0f;
287 float pan = 0.0f;
285 float pan = 0.0f;
288
286
289
287
290 // Run game logic in here. Do NOT render anything here!
288 // Run game logic in here. Do NOT render anything here!
291 KeyboardState keyboardCur = Keyboard.GetState();
289 KeyboardState keyboardCur = Keyboard.GetState();
292
290
293 #region input
291 #region input
294 #region camera_movement_keys
292 #region camera_movement_keys
295 if (keyboardCur.IsKeyDown(Keys.Down))
293 if (keyboardCur.IsKeyDown(Keys.Down))
296 {
294 {
297 this.camera.Move(new Vector2(0, 2));
295 this.camera.Move(new Vector2(0, 2));
298 }
296 }
299 else if (keyboardCur.IsKeyDown(Keys.Up))
297 else if (keyboardCur.IsKeyDown(Keys.Up))
300 {
298 {
301 this.camera.Move(new Vector2(0, -2));
299 this.camera.Move(new Vector2(0, -2));
302
300
303 }
301 }
304 else if (keyboardCur.IsKeyDown(Keys.Left))
302 else if (keyboardCur.IsKeyDown(Keys.Left))
305 {
303 {
306 this.camera.Move(new Vector2(-2, 0));
304 this.camera.Move(new Vector2(-2, 0));
307
305
308 }
306 }
309 else if (keyboardCur.IsKeyDown(Keys.Right))
307 else if (keyboardCur.IsKeyDown(Keys.Right))
310 {
308 {
311 this.camera.Move(new Vector2(2, 0));
309 this.camera.Move(new Vector2(2, 0));
312
310
313 }
311 }
314 else if (keyboardCur.IsKeyDown(Keys.Subtract) && keyboardPrev.IsKeyUp(Keys.Subtract))
312 else if (keyboardCur.IsKeyDown(Keys.Subtract) && keyboardPrev.IsKeyUp(Keys.Subtract))
315 {
313 {
316 this.camera.ZoomOut();
314 this.camera.ZoomOut();
317 }
315 }
318 else if (keyboardCur.IsKeyDown(Keys.Add) && keyboardPrev.IsKeyUp(Keys.Add))
316 else if (keyboardCur.IsKeyDown(Keys.Add) && keyboardPrev.IsKeyUp(Keys.Add))
319 {
317 {
320
318
321 this.camera.ZoomIn();
319 this.camera.ZoomIn();
322 }
320 }
323 #endregion camera_movement_keys
321 #endregion camera_movement_keys
324
322
325 #region misc_keys
323 #region misc_keys
326 if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q))
324 if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q))
327 {
325 {
328 System.Console.WriteLine("Quitting");
326 System.Console.WriteLine("Quitting");
329 Environment.Exit(0);
327 Environment.Exit(0);
330 }
328 }
331 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash))
329 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash))
332 {
330 {
333 this.show_another_window = !this.show_another_window;
331 this.show_another_window = !this.show_another_window;
334
332
335 }
333 }
336
334
337 if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G))
335 if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G))
338 {
336 {
339 this.showGrid = !this.showGrid;
337 this.showGrid = !this.showGrid;
340
338
341 }
339 }
342 if (keyboardCur.IsKeyDown(Keys.B) && keyboardPrev.IsKeyUp(Keys.B))
340 if (keyboardCur.IsKeyDown(Keys.B) && keyboardPrev.IsKeyUp(Keys.B))
343 {
341 {
344 this.showBudget = !this.showBudget;
342 this.showBudget = !this.showBudget;
345
343
346 }
344 }
347 if (keyboardCur.IsKeyDown(Keys.F) && keyboardPrev.IsKeyUp(Keys.F))
345 if (keyboardCur.IsKeyDown(Keys.F) && keyboardPrev.IsKeyUp(Keys.F))
348 {
346 {
349 this.showForest = !this.showForest;
347 this.showForest = !this.showForest;
350
348
351 }
349 }
352 if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C))
350 if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C))
353 {
351 {
354 this.camera.Jump(Vector2.Zero);
352 this.camera.Jump(Vector2.Zero);
355
353
356 }
354 }
357 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift))
355 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift))
358 {
356 {
359 sound.Play(volume, pitch, pan);
357 sound.Play(volume, pitch, pan);
360 }
358 }
361 #endregion misc_keys
359 #endregion misc_keys
362
360
363
361
364 #region gamerate_keys
362 #region gamerate_keys
365 if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0) )
363 if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0) )
366 {
364 {
367 this.simulation.paused = !this.simulation.paused;
365 this.simulation.paused = !this.simulation.paused;
368
366
369 }
367 }
370 #endregion gamerate_keys
368 #endregion gamerate_keys
371
369
372
370
373
371
374
372
375 //if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P))
373 //if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P))
376 // {
374 // {
377 // this.player_state = !this.player_state;
375 // this.player_state = !this.player_state;
378 // }
376 // }
379
377
380 //if (player_state )
378 //if (player_state )
381 //{
379 //{
382 // MediaPlayer.Play(music);
380 // MediaPlayer.Play(music);
383 //}
381 //}
384
382
385
383
386 MouseState mouseCur = Mouse.GetState();
384 MouseState mouseCur = Mouse.GetState();
387 this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice)));
385 this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice)));
388
386
389 if (MathUtils.Between(mouseCur.X, 0, 50))
387 if (MathUtils.Between(mouseCur.X, 0, 50))
390 {
388 {
391 this.camera.Move(new Vector2(-4, 0));
389 this.camera.Move(new Vector2(-4, 0));
392 }
390 }
393 else if (MathUtils.Between(mouseCur.X, (FNAGame.width - 50), FNAGame.width))
391 else if (MathUtils.Between(mouseCur.X, (FNAGame.width - 50), FNAGame.width))
394 {
392 {
395 this.camera.Move(new Vector2(4, 0));
393 this.camera.Move(new Vector2(4, 0));
396 }
394 }
397
395
398 if (MathUtils.Between(mouseCur.Y, 0, 50))
396 if (MathUtils.Between(mouseCur.Y, 0, 50))
399 {
397 {
400 this.camera.Move(new Vector2(0, -4));
398 this.camera.Move(new Vector2(0, -4));
401 }
399 }
402 else if (MathUtils.Between(mouseCur.Y, (FNAGame.height - 50), FNAGame.height))
400 else if (MathUtils.Between(mouseCur.Y, (FNAGame.height - 50), FNAGame.height))
403 {
401 {
404 this.camera.Move(new Vector2(0, 4));
402 this.camera.Move(new Vector2(0, 4));
405 }
403 }
406
404
407 if (mouseCur.RightButton == ButtonState.Pressed)
405 if (mouseCur.RightButton == ButtonState.Pressed)
408 {
406 {
409 Vector2 cameraMiddle = this.camera.position + new Vector2(FNAGame.width / 2, FNAGame.height / 2);
407 Vector2 cameraMiddle = this.camera.position + new Vector2(FNAGame.width / 2, FNAGame.height / 2);
410 Vector2 delta = this.camera.position - this.original_point;
408 Vector2 delta = this.camera.position - this.original_point;
411 this.camera.Jump(this.original_point);
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 if (elapsedTime > TimeSpan.FromSeconds(1))
442 if (elapsedTime > TimeSpan.FromSeconds(1))
445 {
443 {
446 elapsedTime -= TimeSpan.FromSeconds(1);
444 elapsedTime -= TimeSpan.FromSeconds(1);
447 frameRate = frameCounter;
445 frameRate = frameCounter;
448 frameCounter = 0;
446 frameCounter = 0;
449 }
447 }
450
448
451 this.keyboardPrev = keyboardCur;
449 this.keyboardPrev = keyboardCur;
452
450
453 stopWatch.Stop();
451 stopWatch.Stop();
454 this.updateTime = stopWatch.Elapsed;
452 this.updateTime = stopWatch.Elapsed;
455
453
456 base.Update(gameTime);
454 base.Update(gameTime);
457
455
458 }
456 }
459
457
460 protected float calculateDepth() {
458 protected float calculateDepth() {
461 return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
459 return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
462 }
460 }
463
461
464 protected Boolean cull(int gridX, int gridY)
462 protected Boolean cull(int gridX, int gridY)
465 {
463 {
466 int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2;
464 int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2;
467 int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2;
465 int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2;
468
466
469 Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice));
467 Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice));
470
468
471 return (!FNAGame.enableCulling ||
469 return (!FNAGame.enableCulling ||
472 (MathUtils.Between(original.X, -Tile.TileSpriteWidth, FNAGame.width)
470 (MathUtils.Between(original.X, -Tile.TileSpriteWidth, FNAGame.width)
473 && MathUtils.Between(original.Y, -Tile.TileSpriteHeight, FNAGame.height)));
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 float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
477 float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
480
478
481 float depthOffset = 0.7f - ((0 + (0 * Tile.TileWidth)) / maxdepth);
479 float depthOffset = 0.7f - ((0 + (0 * Tile.TileWidth)) / maxdepth);
482
480
483 Tile.drawTileAt(this.batch, x, y, tileIndex, height, depthOffset);
481 Tile.drawTileAt(this.batch, x, y, tileIndex, height, depthOffset);
484 }
482 }
485
483
486
484
487
485
488 protected override void Draw(GameTime gameTime)
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 BlendState.AlphaBlend,
498 BlendState.AlphaBlend,
501 null,
499 null,
502 null,
500 null,
503 null,
501 null,
504 null,
502 null,
505 camera.get_transformation(GraphicsDevice));
503 camera.get_transformation(GraphicsDevice));
506
504
507 //New tile stuff
505 //New tile stuff
508 /*
506 /*
509 Vector2 firstSquare = Vector2.Zero;
507 Vector2 firstSquare = Vector2.Zero;
510 int firstX = (int)firstSquare.X;
508 int firstX = (int)firstSquare.X;
511 int firstY = (int)firstSquare.Y;
509 int firstY = (int)firstSquare.Y;
512
510
513 Vector2 squareOffset = Vector2.Zero;
511 Vector2 squareOffset = Vector2.Zero;
514
512
515 int offsetX = (int)squareOffset.X;
513 int offsetX = (int)squareOffset.X;
516 int offsetY = (int)squareOffset.Y;
514 int offsetY = (int)squareOffset.Y;
517
515
518
516
519 for (int y = 0; y < this.squaresDown; y++)
517 for (int y = 0; y < this.squaresDown; y++)
520 {
518 {
521 int rowOffset = 0;
519 int rowOffset = 0;
522 if ((firstY + y) % 2 == 1)
520 if ((firstY + y) % 2 == 1)
523 rowOffset = Tile.OddRowXOffset;
521 rowOffset = Tile.OddRowXOffset;
524
522
525 for (int x = 0; x < this.squaresAcross; x++) {
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 ((x * Tile.TileStepX) - offsetX + rowOffset + baseOffsetX),
529 ((x * Tile.TileStepX) - offsetX + rowOffset + baseOffsetX),
532 ((y * Tile.TileStepY) - offsetY + baseOffsetY),
530 ((y * Tile.TileStepY) - offsetY + baseOffsetY),
533 Tile.TileWidth, Tile.TileHeight),
531 Tile.TileWidth, Tile.TileHeight),
534 Tile.GetSourceRectangle(1),
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 #region draw_tiles
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 #endregion draw_tiles
576 #endregion draw_tiles
579
577
580 #region draw_gridlines
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 new Vector2(((0 - y) * Tile.TileSpriteWidth / 2), (0 + y) * Tile.TileSpriteHeight / 2) + adjust,
589 new Vector2(((0 - y) * Tile.TileSpriteWidth / 2),
592 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
590 (0 + y) * Tile.TileSpriteHeight / 2) + adjust,
593 new Vector2((this.squaresAcross - (y)) * Tile.TileSpriteWidth / 2, (this.squaresAcross + (y)) * Tile.TileSpriteHeight / 2) + adjust,
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 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
605 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
605 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
606 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
606 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
607 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
607 Color.White, 0.8f);
608 Color.White, 0.8f);
608
609
609 }
610 }
610 }
611 }
611 #endregion draw_gridlines
612 #endregion draw_gridlines
612
613
613
614
614 //Gridlines
615 //Gridlines
615 //Lines going down and to the right:
616 //Lines going down and to the right:
616 /*
617 /*
617 for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++)
618 for (int x = (int)(-this.squaresAcross/2); x < this.squaresAcross; x++)
618 {
619 {
619 int rowOffset = 0;
620 int rowOffset = 0;
620
621
621 float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2);
622 float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2);
622
623
623 Vector2 start = new Vector2(startX, -baseOffsetY+4);
624 Vector2 start = new Vector2(startX, -baseOffsetY+4);
624 Vector2 stop = new Vector2(startX + this.squaresAcross* Tile.TileStepX/2,
625 Vector2 stop = new Vector2(startX + this.squaresAcross* Tile.TileStepX/2,
625 this.squaresDown*Tile.TileStepY- baseOffsetY+4);
626 this.squaresDown*Tile.TileStepY- baseOffsetY+4);
626
627
627
628
628
629
629 Line.drawLine(batch,
630 Line.drawLine(batch,
630 Line.departurePoint(stop, start, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
631 Line.departurePoint(stop, start, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
631 Line.departurePoint(start, stop, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
632 Line.departurePoint(start, stop, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
632 Color.White, 0.8f);
633 Color.White, 0.8f);
633
634
634 }
635 }
635 //Lines going down and to the left:
636 //Lines going down and to the left:
636 for (int x = 0; x < (int)(1.5*this.squaresAcross); x++)
637 for (int x = 0; x < (int)(1.5*this.squaresAcross); x++)
637 {
638 {
638
639
639 float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2);
640 float startX = (x * Tile.TileStepX) + baseOffsetX - (Tile.TileStepX / 2);
640
641
641 Vector2 start_reverse = new Vector2(startX, -baseOffsetY + 4);
642 Vector2 start_reverse = new Vector2(startX, -baseOffsetY + 4);
642 Vector2 stop_reverse = new Vector2(startX + -(this.squaresAcross * Tile.TileStepX / 2),
643 Vector2 stop_reverse = new Vector2(startX + -(this.squaresAcross * Tile.TileStepX / 2),
643 (this.squaresDown * Tile.TileStepY) - baseOffsetY + 4);
644 (this.squaresDown * Tile.TileStepY) - baseOffsetY + 4);
644
645
645 Line.drawLine(batch,
646 Line.drawLine(batch,
646 Line.departurePoint(stop_reverse, start_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
647 Line.departurePoint(stop_reverse, start_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
647 Line.departurePoint(start_reverse, stop_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
648 Line.departurePoint(start_reverse, stop_reverse, this.squaresAcross * Tile.TileWidth, this.squaresDown * Tile.TileHeight),
648 Color.White, 0.8f);
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 #region draw_cursor
661 #region draw_cursor
661 //drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines
662 //drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines
662
663
663 //TODO figure out why it has to be -1
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 && MathUtils.Between(this.mouseGrid.Y, -1, this.simulation.map.MapHeight))
666 && MathUtils.Between(this.mouseGrid.Y, -1, this.simulation.map.MapHeight))
666 {
667 {
667 Tile.OutlineSquare(batch, this.mouseGrid.X, this.mouseGrid.Y, Color.Yellow, 1);
668 Tile.OutlineSquare(batch, this.mouseGrid.X, this.mouseGrid.Y, Color.Yellow, 1);
668 }
669 }
669
670
670 #if DEBUG
671 #if DEBUG
671 Tile.OutlineSquare(batch, 1, 1, Color.Red, 2);
672 Tile.OutlineSquare(batch, 1, 1, Color.Red, 2);
672 Tile.OutlineSquare(batch, 3, 1, Color.Blue, 2);
673 Tile.OutlineSquare(batch, 3, 1, Color.Blue, 2);
673 Tile.OutlineSquare(batch, 5, 1, Color.Green, 2);
674 Tile.OutlineSquare(batch, 5, 1, Color.Green, 2);
674 Tile.OutlineSquare(batch, 7, 1, Color.Orange, 2);
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 for (int i = 0; i< 80; i++)
683 for (int i = 0; i< 80; i++)
683 {
684 {
684 for (int j = 0; j < 50; j += 1)
685 for (int j = 0; j < 50; j += 1)
685 {
686 {
686 //Warning: creates a flashing effect because tree positions update every 1/60th of a second
687 //Warning: creates a flashing effect because tree positions update every 1/60th of a second
687
688
688 if (this.random_generator.NextDouble() > 0.75)
689 if (this.random_generator.NextDouble() > 0.75)
689 {
690 {
690 drawTileAt(i, j, 142, 2);
691 drawTileAt(i, j, 142, 2);
691 }
692 }
692
693
693 if ((i + j) % 3 == 0)
694 if ((i + j) % 3 == 0)
694 {
695 {
695 drawTileAt(i, j, 142, 2);
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 for (int i = 0; i < this.simulation.map.MapHeight; i++)
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 drawTileAt(i, j, 142, 2);
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 else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree) {
720 else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree) {
720 drawTileAt(i, j, 141, 2);
721 drawTileAt(i, j, 141, 2);
721 // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j));
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 BlendState.AlphaBlend,
737 BlendState.AlphaBlend,
737 null,
738 null,
738 null,
739 null,
739 null,
740 null,
740 null);
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 #endregion draw_header
770 #endregion draw_header
770
771
771
772
772 #region budget
773 #region budget
773
774
774 if (this.showBudget)
775 if (this.showBudget)
775 {
776 {
776 budgetWindow.draw(batch);
777 budgetWindow.draw(batch);
777
778
778 }
779 }
779
780
780 #endregion budget
781 #endregion budget
781
782
782 batch.End();
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 updateTime = this.updateTime,
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 Vector2 cameraMiddle = this.camera.position + new Vector2(FNAGame.width / 2, FNAGame.height / 2);
813 Vector2 cameraMiddle = this.camera.position + new Vector2(FNAGame.width / 2, FNAGame.height / 2);
814 var state = Mouse.GetState();
814 var state = Mouse.GetState();
815 Vector2 delta = this.camera.position - this.original_point;
815 Vector2 delta = this.camera.position - this.original_point;
816
816
817 additionalInfo.Add("cameraMiddle", cameraMiddle.ToString());
817 additionalInfo.Add("cameraMiddle", cameraMiddle.ToString());
818 additionalInfo.Add("mouse ", String.Format("{0}, {1}", state.X, state.Y));
818 additionalInfo.Add("mouse ", String.Format("{0}, {1}", state.X, state.Y));
819 additionalInfo.Add("mouse delta", delta.ToString());
819 additionalInfo.Add("mouse delta", delta.ToString());
820
820
821 additionalInfo.Add("Tracery Test", this.output);
821 additionalInfo.Add("Tracery Test", this.output);
822
822
823 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
823 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
824
824
825
825
826 //debugWindow.ImGuiLayout();
826 //debugWindow.ImGuiLayout();
827 //String[] messages = { "Message1", "Message2" };
827 //String[] messages = { "Message1", "Message2" };
828
828
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" },
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 // 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?" },
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 // new DialogOption{ response="Oh yeah, of course.", choice="..." }};
831 // new DialogOption{ response="Oh yeah, of course.", choice="..." }};
832
832
833
833
834 if (this.currentNode != null)
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 if (this.showForest)
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