protected override void Update(GameTime gameTime) { // タイム ルーラの計測開始 timeRuler.StartFrame(); // これをしないとデバッグできない。 if (!IsActive) { return; } // モニタ Instrument.Begin(InstrumentUpdate); //---------------------------------------------------------------- // マウスとキーボード状態の取得 currentKeyboardState = Keyboard.GetState(); var mouseState = Mouse.GetState(); //---------------------------------------------------------------- // アプリケーション終了 // TODO if (!worldManager.ChunkManager.Closing && !worldManager.ChunkManager.Closed && currentKeyboardState.IsKeyDown(Keys.Escape)) { worldManager.ChunkManager.Close(); logger.Info("Wait until all chunks are passivated..."); } if (worldManager.ChunkManager.Closed) { Exit(); } //---------------------------------------------------------------- // ビューの操作 viewInput.Update(gameTime, worldManager.SceneManager.ActiveCamera.View); if (currentKeyboardState.IsKeyDown(Keys.PageUp)) { viewInput.MoveVelocity += 10; } if (currentKeyboardState.IsKeyDown(Keys.PageDown)) { viewInput.MoveVelocity -= 10; if (viewInput.MoveVelocity < 10) { viewInput.MoveVelocity = 10; } } //---------------------------------------------------------------- // ワールドの更新 worldManager.Update(gameTime); //---------------------------------------------------------------- // ブラシ マネージャ // 右ボタン押下でペイント モードの開始。 if (mouseState.RightButton == ButtonState.Pressed && lastMouseState.RightButton == ButtonState.Released) { brushManager.StartPaintMode(); } // 右ボタン解放でペイント モードの終了。 if (mouseState.RightButton == ButtonState.Released && lastMouseState.RightButton == ButtonState.Pressed) { brushManager.EndPaintMode(); } // ブラシ マネージャを更新。 // 内部でブラシの位置が決定される。 brushManager.Update(); // 左ボタンでブロック消去。 // ブロック消去は消去対象の判定との兼ね合いから、 // ボタンの押下から解放を行った時にだけ実行。 if (mouseState.LeftButton == ButtonState.Released && lastMouseState.LeftButton == ButtonState.Pressed && mouseState.RightButton == ButtonState.Released) { brushManager.Erase(); } // 右ボタン押下でペイント。 if (mouseState.RightButton == ButtonState.Pressed && mouseState.LeftButton == ButtonState.Released) { brushManager.Paint(); } // Undo。 if (currentKeyboardState.IsKeyDown(Keys.LeftControl) && IsKeyPressed(Keys.Z)) { commandManager.RequestUndo(); } // Redo。 if (currentKeyboardState.IsKeyDown(Keys.LeftControl) && IsKeyPressed(Keys.Y)) { commandManager.RequestRedo(); } // マウス中ボタン押下でブラシのある位置のブロックを選択 (スポイト)。 // TODO // ホイール クリックが反応してくれない。 // 手の打ちようがないのでキー [O] で対応。 if ((mouseState.MiddleButton == ButtonState.Released && lastMouseState.MiddleButton == ButtonState.Pressed) || IsKeyPressed(Keys.O)) { brushManager.Pick(); } if (IsKeyPressed(Keys.D1)) { brushManager.SetBrush(brushManager.FreeBrush); } if (IsKeyPressed(Keys.D2)) { brushManager.SetBrush(brushManager.StickyBrush); } // コマンド実行。 commandManager.Update(); //---------------------------------------------------------------- // その他 // F1 if (IsKeyPressed(Keys.F1)) { helpVisible = !helpVisible; } // F2 if (IsKeyPressed(Keys.F2)) { SceneManager.DebugBoxVisible = !SceneManager.DebugBoxVisible; } // F3 if (IsKeyPressed(Keys.F3)) { RegionManager.Wireframe = !RegionManager.Wireframe; } // F4 if (IsKeyPressed(Keys.F4)) { worldManager.SceneSettings.FogEnabled = !worldManager.SceneSettings.FogEnabled; } // F5 if (IsKeyPressed(Keys.F5)) { textureDisplay.Visible = !textureDisplay.Visible; } // F6 if (IsKeyPressed(Keys.F6)) { timeRuler.Visible = !timeRuler.Visible; } //---------------------------------------------------------------- // マウスとキーボード状態の記録 lastKeyboardState = currentKeyboardState; lastMouseState = mouseState; base.Update(gameTime); // モニタ Instrument.End(); }