protected override void Update(GameTime gameTime) { timeRuler.StartFrame(); updateMarker.Begin(); KeyboardState keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Escape)) { Exit(); } float dt = (float)gameTime.ElapsedGameTime.TotalSeconds; // スペースキーで次の描画手法に変更する if (keyState.IsKeyDown(Keys.Space)) { if (!pressedSpaceKey) { MoveToNextTechnique(); } pressedSpaceKey = true; } else { pressedSpaceKey = false; } // ゲームオブジェクト数を増やす float trigger = keyState.IsKeyDown(Keys.Up) ? 0.1f : 0.0f; if (trigger > 0.0f) { int addCount = Math.Max(1, (int)(trigger * 2000.0f * dt)); targetObjectCount = Math.Min(targetObjectCount + addCount, MaxGameObjectCount); UpdateStatusString(); } // ゲームオブジェクト数を減らす trigger = keyState.IsKeyDown(Keys.Down) ? 0.1f : 0.0f; if (trigger > 0.0f) { int subCount = Math.Max(1, (int)(trigger * 2000.0f * dt)); targetObjectCount = Math.Max(targetObjectCount - subCount, 1); UpdateStatusString(); } // 全ゲームオブジェクトの更新 UpdateGameObjects(dt); updateMarker.End(); base.Update(gameTime); }
protected override void Update(GameTime gameTime) { timeRuler.StartFrame(); updateMarker.Begin(); base.Update(gameTime); updateMarker.End(); }
public static void StartFrame() { if (_firstFrame) { _firstFrame = false; _debugCommandUI.ExecuteCommand("tr on log:on"); _debugCommandUI.ExecuteCommand("fps on"); _debugCommandUI.ExecuteCommand("memory on"); } _currentRuler.StartFrame(); _currentRuler.Update(null); }
protected override void Update(GameTime gameTime) { timeRuler.StartFrame(); updateMarker.Begin(); if (storageManager.RootDirectory == null) { storageManager.Select("BlockViewer"); } base.Update(gameTime); updateMarker.End(); }
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(); }