Description:
Move over remainder of Camera movement.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,11 | |||||
|
|
1 | |||
|
|
2 | |||
|
|
3 | using Microsoft.Xna.Framework; | ||
|
|
4 | using Encompass; | ||
|
|
5 | |||
|
|
6 | namespace isometricparkfna.Messages { | ||
|
|
7 | public struct JumpCameraMessage : IMessage | ||
|
|
8 | { | ||
|
|
9 | public Vector2 Movement; | ||
|
|
10 | } | ||
|
|
11 | } |
@@ -6,7 +6,8 | |||||
|
6 |
|
6 | ||
|
7 | namespace isometricparkfna.Engines { |
|
7 | namespace isometricparkfna.Engines { |
|
8 |
|
8 | ||
|
9 |
[Receives(typeof(ZoomCameraMessage), typeof(MoveCameraMessage) |
|
9 | [Receives(typeof(ZoomCameraMessage), typeof(MoveCameraMessage), |
|
|
10 | typeof(JumpCameraMessage))] | ||
|
10 | class CameraBridgeEngine : Engine |
|
11 | class CameraBridgeEngine : Engine |
|
11 | { |
|
12 | { |
|
12 | private Camera Camera; |
|
13 | private Camera Camera; |
@@ -34,7 +35,10 | |||||
|
34 | foreach (ref readonly var message in ReadMessages<MoveCameraMessage>()) |
|
35 | foreach (ref readonly var message in ReadMessages<MoveCameraMessage>()) |
|
35 | { |
|
36 | { |
|
36 | this.Camera.Move(message.Movement); |
|
37 | this.Camera.Move(message.Movement); |
|
37 |
|
38 | } | |
|
|
39 | foreach (ref readonly var message in ReadMessages<JumpCameraMessage>()) | ||
|
|
40 | { | ||
|
|
41 | this.Camera.Jump(message.Movement); | ||
|
38 | } |
|
42 | } |
|
39 |
|
43 | ||
|
40 | } |
|
44 | } |
@@ -13,6 +13,7 | |||||
|
13 |
|
13 | ||
|
14 | [Sends( typeof(ZoomCameraMessage), |
|
14 | [Sends( typeof(ZoomCameraMessage), |
|
15 | typeof(MoveCameraMessage), |
|
15 | typeof(MoveCameraMessage), |
|
|
16 | typeof(JumpCameraMessage), | ||
|
16 | typeof(ToggleWindowMessage), |
|
17 | typeof(ToggleWindowMessage), |
|
17 | typeof(ToggleVisibilityMessage), |
|
18 | typeof(ToggleVisibilityMessage), |
|
18 | typeof(TogglePauseMessage), |
|
19 | typeof(TogglePauseMessage), |
@@ -23,11 +24,16 | |||||
|
23 |
|
24 | ||
|
24 | //Area to ignore: |
|
25 | //Area to ignore: |
|
25 | private int menuBarHeight; |
|
26 | private int menuBarHeight; |
|
|
27 | |||
|
|
28 | private int viewWidth; | ||
|
|
29 | private int viewHeight; | ||
|
26 |
|
30 | ||
|
27 | public InputEngine(int menuBarHeight) { |
|
31 | public InputEngine(int menuBarHeight, int viewWidth, int viewHeight) { |
|
28 | //initialize to blank for now |
|
32 | //initialize to blank for now |
|
29 | this.keyboardPrev = new KeyboardState(); |
|
33 | this.keyboardPrev = new KeyboardState(); |
|
30 | menuBarHeight = menuBarHeight; |
|
34 | this.menuBarHeight = menuBarHeight; |
|
|
35 | this.viewWidth = viewWidth; | ||
|
|
36 | this.viewHeight = viewHeight; | ||
|
31 | } |
|
37 | } |
|
32 |
|
38 | ||
|
33 | public override void Update(double dt) { |
|
39 | public override void Update(double dt) { |
@@ -63,6 +69,11 | |||||
|
63 | { |
|
69 | { |
|
64 | SendMessage(new ZoomCameraMessage {ZoomIn = true}); |
|
70 | SendMessage(new ZoomCameraMessage {ZoomIn = true}); |
|
65 | } |
|
71 | } |
|
|
72 | if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C)) | ||
|
|
73 | { | ||
|
|
74 | SendMessage(new JumpCameraMessage {Movement = Vector2.Zero }); | ||
|
|
75 | |||
|
|
76 | } | ||
|
66 | #endregion camera_movement_keys |
|
77 | #endregion camera_movement_keys |
|
67 | #region gamerate_keys |
|
78 | #region gamerate_keys |
|
68 | if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P) ) |
|
79 | if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P) ) |
@@ -153,11 +164,27 | |||||
|
153 | // this.camera.Jump(Vector2.Zero); |
|
164 | // this.camera.Jump(Vector2.Zero); |
|
154 |
|
165 | ||
|
155 | } |
|
166 | } |
|
156 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) |
|
||
|
157 | { |
|
||
|
158 | // sound.Play(volume, pitch, pan); |
|
||
|
159 | } |
|
||
|
160 | #endregion misc_keys |
|
167 | #endregion misc_keys |
|
|
168 | #region mouse_movement | ||
|
|
169 | |||
|
|
170 | |||
|
|
171 | if (MathUtils.Between(mouseCur.Y, menuBarHeight, 50 + menuBarHeight)) | ||
|
|
172 | { | ||
|
|
173 | SendMessage(new MoveCameraMessage {Movement = new Vector2(0, -4)}); | ||
|
|
174 | } | ||
|
|
175 | else if (MathUtils.Between(mouseCur.Y, (this.viewHeight - 50 -menuBarHeight), this.viewHeight-menuBarHeight)) | ||
|
|
176 | { | ||
|
|
177 | SendMessage(new MoveCameraMessage {Movement = new Vector2(0, 4)}); | ||
|
|
178 | } | ||
|
|
179 | if (MathUtils.Between(mouseCur.X, 0, 50)) | ||
|
|
180 | { | ||
|
|
181 | SendMessage(new MoveCameraMessage {Movement = new Vector2(-4, 0)}); | ||
|
|
182 | } | ||
|
|
183 | else if (MathUtils.Between(mouseCur.X, (this.viewWidth - 50), this.viewWidth)) | ||
|
|
184 | { | ||
|
|
185 | SendMessage(new MoveCameraMessage {Movement = new Vector2(4, 0)}); | ||
|
|
186 | } | ||
|
|
187 | #endregion | ||
|
161 |
|
188 | ||
|
162 | this.keyboardPrev = keyboardCur; |
|
189 | this.keyboardPrev = keyboardCur; |
|
163 | } |
|
190 | } |
@@ -196,7 +196,7 | |||||
|
196 |
|
196 | ||
|
197 |
|
197 | ||
|
198 | // WorldBuilder.AddGeneralRenderer(new BudgetWindowRenderer(this.batch, this.monoFont)); |
|
198 | // WorldBuilder.AddGeneralRenderer(new BudgetWindowRenderer(this.batch, this.monoFont)); |
|
199 | WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT)); |
|
199 | WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, FNAGame.width, FNAGame.height)); |
|
200 | WorldBuilder.AddEngine(new GameBridgeEngine(this)); |
|
200 | WorldBuilder.AddEngine(new GameBridgeEngine(this)); |
|
201 | WorldBuilder.AddEngine(new SimulationBridgeEngine(this.simulation)); |
|
201 | WorldBuilder.AddEngine(new SimulationBridgeEngine(this.simulation)); |
|
202 | WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera)); |
|
202 | WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera)); |
@@ -356,11 +356,6 | |||||
|
356 | #region input |
|
356 | #region input |
|
357 | // |
|
357 | // |
|
358 | #region misc_keys |
|
358 | #region misc_keys |
|
359 | if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C)) |
|
||
|
360 | { |
|
||
|
361 | this.camera.Jump(Vector2.Zero); |
|
||
|
362 |
|
|||
|
363 | } |
|
||
|
364 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) |
|
359 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) |
|
365 | { |
|
360 | { |
|
366 | sound.Play(volume, pitch, pan); |
|
361 | sound.Play(volume, pitch, pan); |
@@ -370,26 +365,6 | |||||
|
370 | MouseState mouseCur = Mouse.GetState(); |
|
365 | MouseState mouseCur = Mouse.GetState(); |
|
371 | this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); |
|
366 | this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); |
|
372 |
|
367 | ||
|
373 | var menuBarHeight = Menu.MENU_BAR_HEIGHT; |
|
||
|
374 |
|
|||
|
375 |
|
|||
|
376 | if (MathUtils.Between(mouseCur.X, 0, 50)) |
|
||
|
377 | { |
|
||
|
378 | this.camera.Move(new Vector2(-4, 0)); |
|
||
|
379 | } |
|
||
|
380 | else if (MathUtils.Between(mouseCur.X, (FNAGame.width - 50), FNAGame.width)) |
|
||
|
381 | { |
|
||
|
382 | this.camera.Move(new Vector2(4, 0)); |
|
||
|
383 | } |
|
||
|
384 |
|
|||
|
385 | if (MathUtils.Between(mouseCur.Y, menuBarHeight, 50 + menuBarHeight)) |
|
||
|
386 | { |
|
||
|
387 | this.camera.Move(new Vector2(0, -4)); |
|
||
|
388 | } |
|
||
|
389 | else if (MathUtils.Between(mouseCur.Y, (FNAGame.height - 50 -menuBarHeight), FNAGame.height-menuBarHeight)) |
|
||
|
390 | { |
|
||
|
391 | this.camera.Move(new Vector2(0, 4)); |
|
||
|
392 | } |
|
||
|
393 |
|
368 | ||
|
394 | #if DEBUG |
|
369 | #if DEBUG |
|
395 | if (mouseCur.RightButton == ButtonState.Pressed) |
|
370 | if (mouseCur.RightButton == ButtonState.Pressed) |
You need to be logged in to leave comments.
Login now