Description:
Move over remainder of Camera movement.
(grafted from 558b1277915195c77357ed82ceee5e8619f1a535)
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 | 7 | namespace isometricparkfna.Engines { |
|
8 | 8 | |
|
9 |
[Receives(typeof(ZoomCameraMessage), typeof(MoveCameraMessage) |
|
|
9 | [Receives(typeof(ZoomCameraMessage), typeof(MoveCameraMessage), | |
|
10 | typeof(JumpCameraMessage))] | |
|
10 | 11 | class CameraBridgeEngine : Engine |
|
11 | 12 | { |
|
12 | 13 | private Camera Camera; |
@@ -34,7 +35,10 | |||
|
34 | 35 | foreach (ref readonly var message in ReadMessages<MoveCameraMessage>()) |
|
35 | 36 | { |
|
36 | 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 | 14 | [Sends( typeof(ZoomCameraMessage), |
|
15 | 15 | typeof(MoveCameraMessage), |
|
16 | typeof(JumpCameraMessage), | |
|
16 | 17 | typeof(ToggleWindowMessage), |
|
17 | 18 | typeof(ToggleVisibilityMessage), |
|
18 | 19 | typeof(TogglePauseMessage), |
@@ -23,11 +24,16 | |||
|
23 | 24 | |
|
24 | 25 | //Area to ignore: |
|
25 | 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 | 32 | //initialize to blank for now |
|
29 | 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 | 39 | public override void Update(double dt) { |
@@ -63,6 +69,11 | |||
|
63 | 69 | { |
|
64 | 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 | 77 | #endregion camera_movement_keys |
|
67 | 78 | #region gamerate_keys |
|
68 | 79 | if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P) ) |
@@ -153,11 +164,27 | |||
|
153 | 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 | 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 | 189 | this.keyboardPrev = keyboardCur; |
|
163 | 190 | } |
@@ -184,7 +184,7 | |||
|
184 | 184 | |
|
185 | 185 | |
|
186 | 186 | // WorldBuilder.AddGeneralRenderer(new BudgetWindowRenderer(this.batch, this.monoFont)); |
|
187 | WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT)); | |
|
187 | WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, FNAGame.width, FNAGame.height)); | |
|
188 | 188 | WorldBuilder.AddEngine(new GameBridgeEngine(this)); |
|
189 | 189 | WorldBuilder.AddEngine(new SimulationBridgeEngine(this.simulation)); |
|
190 | 190 | WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera)); |
@@ -344,11 +344,6 | |||
|
344 | 344 | #region input |
|
345 | 345 | // |
|
346 | 346 | #region misc_keys |
|
347 | if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C)) | |
|
348 | { | |
|
349 | this.camera.Jump(Vector2.Zero); | |
|
350 | ||
|
351 | } | |
|
352 | 347 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) |
|
353 | 348 | { |
|
354 | 349 | sound.Play(volume, pitch, pan); |
@@ -358,26 +353,6 | |||
|
358 | 353 | MouseState mouseCur = Mouse.GetState(); |
|
359 | 354 | this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice))); |
|
360 | 355 | |
|
361 | var menuBarHeight = Menu.MENU_BAR_HEIGHT; | |
|
362 | ||
|
363 | ||
|
364 | if (MathUtils.Between(mouseCur.X, 0, 50)) | |
|
365 | { | |
|
366 | this.camera.Move(new Vector2(-4, 0)); | |
|
367 | } | |
|
368 | else if (MathUtils.Between(mouseCur.X, (FNAGame.width - 50), FNAGame.width)) | |
|
369 | { | |
|
370 | this.camera.Move(new Vector2(4, 0)); | |
|
371 | } | |
|
372 | ||
|
373 | if (MathUtils.Between(mouseCur.Y, menuBarHeight, 50 + menuBarHeight)) | |
|
374 | { | |
|
375 | this.camera.Move(new Vector2(0, -4)); | |
|
376 | } | |
|
377 | else if (MathUtils.Between(mouseCur.Y, (FNAGame.height - 50 -menuBarHeight), FNAGame.height-menuBarHeight)) | |
|
378 | { | |
|
379 | this.camera.Move(new Vector2(0, 4)); | |
|
380 | } | |
|
381 | 356 | |
|
382 | 357 | #if DEBUG |
|
383 | 358 | if (mouseCur.RightButton == ButtonState.Pressed) |
You need to be logged in to leave comments.
Login now