} // end of Update() #endregion Public #region Internal protected override void ProcessPoint( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { bool saveRestore = false; if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { saveRestore = TouchInput.TouchCount > 0 && Boku.InGame.inGame.TouchEdit.HasNonUITouch(); } else { saveRestore = MouseInput.Right.IsPressed || MouseInput.Left.IsPressed; } int wasType = Water.CurrentType; if (saveRestore) { int waterType = Terrain.GetWaterType(shared.editBrushPosition); if (waterType != Water.InvalidType) { Water.CurrentType = waterType; } } base.ProcessPoint(rightMode, aButton, leftMode); Water.CurrentType = wasType; }
/// <summary> /// Apply commands in stretched brush mode. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected virtual void ProcessStretched( Terrain.EditMode left, Terrain.EditMode middle, Terrain.EditMode right) { ProcessStretchedOpen(); ProcessStretchedReady(); ProcessStretchedGoing(left, middle, right); }
/// <summary> /// Apply commands in stretched brush mode. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected virtual void ProcessStretched( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { ProcessStretchedOpen(); ProcessStretchedReady(); ProcessStretchedGoing(rightMode, aButton, leftMode); }
/// <summary> /// Override to make the A button do a snap in Stretch mode, instead of the usual /// blend in other modes. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> /// <summary> /// If we're using the right trigger, then null out the a button action. /// It will still advance the cursor, but we don't want to do a road snap over it. /// If we're not doing right trigger, make a button instant. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected override void ProcessStretched( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { rightMode = Terrain.EditMode.Road; aButton = Terrain.EditMode.RoadSnap; base.ProcessStretched(rightMode, aButton, leftMode); }
protected override void ProcessPoint( Terrain.EditMode left, Terrain.EditMode middle, Terrain.EditMode right) { if (MouseInput.Left.IsPressed) { BuildSelected(); DeleteSelected(); } base.ProcessPoint(left, middle, right); }
} // end of DeleteObjectsTool Update() #endregion Public protected override void ProcessTouch( Terrain.EditMode left, Terrain.EditMode middle, Terrain.EditMode right) { if (TouchInput.TouchCount > 0 && Boku.InGame.inGame.TouchEdit.HasNonUITouch()) { if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baDelete) { BuildSelected(); DeleteSelected(); } } base.ProcessTouch(left, middle, right); }
public void HandleTouchInput() { if (GamePadInput.ActiveMode != GamePadInput.InputMode.Touch) { return; } inGame.Cursor3D.Rep = Cursor3D.Visual.Pointy; if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baPaintMaterial) { if (TouchInput.TouchCount > 0 && TouchInput.GetTouchContactByIndex(0).phase == TouchPhase.Began) { editMode = Terrain.EditMode.PaintAndAddMaterial; } } }
/// <summary> /// Pass off commands as appropriate to the right handlers, depending on /// the current game pad and brush states. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected void ProcessTriggers( Terrain.EditMode left, Terrain.EditMode middle, Terrain.EditMode right) { /// If any of the toolbox pickers are active, disable our selves. if (shared.ToolBox.PickersActive || Boku.InGame.inGame.mouseEditUpdateObj.ToolBox.PickersActive) { return; } Brush2DManager.Brush2D brush = Brush2DManager.GetBrush(shared.editBrushIndex); bool isSelection = (brush != null) && ((brush.Type & Brush2DManager.BrushType.Selection) != 0); // Size timer is used for changing selection brush size. Required for both mouse and touch sizeTimer += Time.WallClockFrameSeconds; if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { if (isSelection) { ProcessTouchSelection(left, middle, right); } else { ProcessTouch(left, middle, right); } } else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { if (isSelection) { ProcessSelection(left, middle, right); } else if (InStretchMode) { ProcessStretched(left, middle, right); } else { ProcessPoint(left, middle, right); } } }
/// <summary> /// If we're using the right trigger, then null out the a button action. /// It will still advance the cursor, but we don't want to do a road snap over it. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected override void ProcessStretched( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { GamePadInput pad = GamePadInput.GetGamePad1(); if (StretchGoing && RightTriggerOn) { rightTriggered = true; } aButton = rightTriggered ? Terrain.EditMode.Noop : Terrain.EditMode.RoadSnap; base.ProcessStretched(Terrain.EditMode.Road, aButton, Terrain.EditMode.Smooth); if (pad.ButtonA.WasPressed) { rightTriggered = false; } }
} // end of WaterAdd Update() #endregion Public #region Internal protected override void ProcessPoint( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { bool saveRestore = (RightRate > kSmallRate) || (LeftRate > kSmallRate); int wasType = Water.CurrentType; if (saveRestore) { int waterType = Terrain.GetWaterType(shared.editBrushPosition); if (waterType != Water.InvalidType) { Water.CurrentType = waterType; } } base.ProcessPoint(rightMode, aButton, leftMode); Water.CurrentType = wasType; }
/// <summary> /// Pass off commands as appropriate to the right handlers, depending on /// the current game pad and brush states. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected void ProcessTriggers( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { /// If any of the toolbox pickers are active, disable our selves. if (shared.ToolBox.PickersActive) { return; } Brush2DManager.Brush2D brush = Brush2DManager.GetBrush(shared.editBrushIndex); bool isSelection = (brush != null) && ((brush.Type & Brush2DManager.BrushType.Selection) != 0); if (isSelection) { ProcessSelection( rightMode, aButton, leftMode); } else if (InStretchMode) { ProcessStretched( rightMode, aButton, leftMode); } else { ProcessPoint( rightMode, aButton, leftMode); } }
public void HandleMouseInput() { if (GamePadInput.ActiveMode != GamePadInput.InputMode.KeyboardMouse) { return; } // In eyedropper mode, show the pointy cursor. if (KeyboardInput.AltIsPressed) { inGame.Cursor3D.Rep = Cursor3D.Visual.Pointy; inGame.Cursor3D.Hidden = false; } else { inGame.Cursor3D.Hidden = true; } if (KeyboardInput.AltIsPressed) { // Sample the current terrain. if (MouseEdit.TriggerSample()) { MouseInput.Left.IgnoreUntilReleased = true; // Prevent terrain from being painted when Alt is being used to select material. editMode = Terrain.EditMode.Noop; Vector3 p = MouseEdit.HitInfo.TerrainPosition; Vector2 pos = new Vector2(p.X, p.Y); ushort matIdx = Terrain.GetMaterialType(pos); if (TerrainMaterial.IsValid(matIdx, false, false)) { Terrain.CurrentMaterialIndex = matIdx; Foley.PlayCut(); } } } else if (!PickerXInUse && !PickerYInUse) { if (DebouncePending) { return; } if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse) { // Set the mode based on whether or not // option keys are pressed. if (MouseInput.Left.WasPressed) { editMode = Terrain.EditMode.PaintAndAddMaterial; if (KeyboardInput.ShiftIsPressed) { editMode = Terrain.EditMode.PaintMaterial; } else if (KeyboardInput.CtrlIsPressed) { editMode = Terrain.EditMode.AddAtCenter; } } } } }
/// <summary> /// Apply commands to single brush region. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected virtual void ProcessPoint( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { // Up if (RightRate > kSmallRate) { float rate = RightRate; inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, rightMode, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; RightAudioStart(); } else { RightAudioEnd(); } // Smooth if (AButtonOn) { float rate = aButtonRate; inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, aButton, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; MiddleAudioStart(); } else { MiddleAudioEnd(); } // Down if (LeftRate > kSmallRate) { float rate = LeftRate; inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, leftMode, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; LeftAudioStart(); } else { LeftAudioEnd(); } }
protected virtual void ProcessStretchedGoing( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { if (StretchPhase == Phase.Going) { float distSq = Vector2.DistanceSquared(endPos, shared.editBrushPosition); bool gamePadMoved = distSq > kSmallMoveSq; bool mouseMoved = MouseInput.PrevPosition != MouseInput.Position; bool moved = GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse ? mouseMoved : gamePadMoved; if (moved && !RightTriggerOn && !AButtonOn && !LeftTriggerOn) { StretchPhase = Phase.Ready; shared.editBrushStart = shared.editBrushPosition; RightAudioEnd(); MiddleAudioEnd(); LeftAudioEnd(); } else { if (RightTriggerOn) { float editSpeed = RightRate; inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushStart, shared.editBrushPosition, shared.editBrushRadius, rightMode, editSpeed * editSpeed * terrainSpeed); RightAudioStart(); } else { RightAudioEnd(); } if (AButtonOn) { float editSpeed = aButtonRate; inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushStart, shared.editBrushPosition, shared.editBrushRadius, aButton, editSpeed * editSpeed * terrainSpeed); MiddleAudioStart(); } else { MiddleAudioEnd(); } if (LeftTriggerOn) { float editSpeed = LeftRate; inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushStart, shared.editBrushPosition, shared.editBrushRadius, leftMode, editSpeed * editSpeed * terrainSpeed); LeftAudioStart(); } else { LeftAudioEnd(); } shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; } ProcessBButton(); } }
/// <summary> /// Apply commands in material select mode. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected virtual void ProcessTouchSelection( Terrain.EditMode left, Terrain.EditMode middle, Terrain.EditMode right) { isInAction = false; if (TouchInput.TouchCount == 1 && TouchInput.Touches[0].phase != TouchPhase.Ended && shared.currentTouchAction != ToolBar.TouchControls.BrushActionIDs.NUMBER_OF_Buttons && shared.editBrushAllowedForTouch) { if ((shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baBrushMore) || (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baBrushLess)) { const float kMinResizeTime = 0.3f; if (sizeTimer >= kMinResizeTime) { sizeTimer = 0.0f; if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baBrushMore) { inGame.Terrain.ExpandSelection(); } else if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baBrushLess) { inGame.Terrain.ShrinkSelection(); } } } // Left if ((shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baPaintMaterial) || (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baTerrainRaise) || (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baFlatten) || (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baSpikey)) { #if !NETFX_CORE Debug.Print("Painting with selection..."); #endif float rate = 1.0f; inGame.Terrain.RenderToSelection(left, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; LeftAudioStart(); isInAction = true; } else { LeftAudioEnd(); } // Middle if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baSmooth) { float rate = 1.0f; inGame.Terrain.RenderToSelection(middle, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; MiddleAudioStart(); isInAction = true; } else { MiddleAudioEnd(); } // Right if ((shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baDelete) || (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baTerrainLower) || (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baHilly)) { float rate = 1.0f; inGame.Terrain.RenderToSelection(right, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; RightAudioStart(); isInAction = true; } else { RightAudioEnd(); } } else if (!shared.editBrushAllowedForTouch) { LeftAudioEnd(); MiddleAudioEnd(); RightAudioEnd(); } }
/// <summary> /// Apply commands to single brush region. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected virtual void ProcessPoint( Terrain.EditMode left, Terrain.EditMode middle, Terrain.EditMode right) { float rate = 0.5f; isInAction = false; if (MouseInput.Left.IsPressed) { inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, left, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; LeftAudioStart(); isInAction = true; } else { LeftAudioEnd(); } // Smooth if (MouseInput.Middle.IsPressed) { inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, middle, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; MiddleAudioStart(); isInAction = true; } else { MiddleAudioEnd(); } // Down if (MouseInput.Right.IsPressed) { inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, right, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; RightAudioStart(); isInAction = true; } else { RightAudioEnd(); } if (oldInAction != isInAction) { #if !NETFX_CORE Console.WriteLine(this.ToString() + ":" + ":" + MouseInput.Left.IsPressed.ToString() + ":" + MouseInput.Middle.IsPressed.ToString() + ":" + MouseInput.Right.IsPressed.ToString() ); #endif oldInAction = isInAction; } }
/// <summary> /// Apply commands in material select mode. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected virtual void ProcessSelection( Terrain.EditMode left, Terrain.EditMode middle, Terrain.EditMode right) { isInAction = false; CheckResizeSelection(); if (MouseInput.Left.IsPressed) { float rate = 1.0f; inGame.Terrain.RenderToSelection(left, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; LeftAudioStart(); isInAction = true; } else { LeftAudioEnd(); } if (MouseInput.Middle.IsPressed) { float rate = 1.0f; inGame.Terrain.RenderToSelection(middle, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; MiddleAudioStart(); isInAction = true; } else { MiddleAudioEnd(); } if (MouseInput.Right.IsPressed) { float rate = 1.0f; inGame.Terrain.RenderToSelection(right, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; RightAudioStart(); isInAction = true; } else { RightAudioEnd(); } if (Actions.MaterialFabric.WasPressed) { Actions.MaterialFabric.ClearAllWasPressedState(); inGame.Terrain.SetSelectionToFabric(); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; } if (Actions.MaterialCubic.WasPressed) { Actions.MaterialCubic.ClearAllWasPressedState(); inGame.Terrain.SetSelectionToCubic(); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; } }
/// <summary> /// Apply commands in material select mode. /// </summary> /// <param name="rightMode"></param> /// <param name="aButton"></param> /// <param name="leftMode"></param> protected virtual void ProcessSelection( Terrain.EditMode rightMode, Terrain.EditMode aButton, Terrain.EditMode leftMode) { CheckResizeSelection(); if (RightRate > kSmallRate) { float rate = RightRate; inGame.Terrain.RenderToSelection(rightMode, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; RightAudioStart(); } else { RightAudioEnd(); } if (AButtonOn) { float rate = aButtonRate; inGame.Terrain.RenderToSelection(aButton, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; MiddleAudioStart(); } else { MiddleAudioEnd(); } if (LeftRate > kSmallRate) { float rate = LeftRate; inGame.Terrain.RenderToSelection(leftMode, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; LeftAudioStart(); } else { LeftAudioEnd(); } if (Actions.MaterialFabric.WasPressed) { Actions.MaterialFabric.ClearAllWasPressedState(); inGame.Terrain.SetSelectionToFabric(); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; } if (Actions.MaterialCubic.WasPressed) { Actions.MaterialCubic.ClearAllWasPressedState(); inGame.Terrain.SetSelectionToCubic(); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; } }
/// <summary> /// Apply commands to single brush region. /// </summary> protected virtual void ProcessTouch( Terrain.EditMode left, Terrain.EditMode middle, Terrain.EditMode right) { float rate = 0.5f; isInAction = false; if ((shared.currentTouchAction != ToolBar.TouchControls.BrushActionIDs.NUMBER_OF_Buttons) && shared.editBrushAllowedForTouch) { if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baTerrainRaise || shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baPaintMaterial || shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baSpikey || shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baWaterRaise) { inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, left, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; LeftAudioStart(); isInAction = true; } else { LeftAudioEnd(); } if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baFlatten || shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baDelete) { inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, right, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; LeftAudioStart(); isInAction = true; } //This if check is to prevent the left audio from always ending when we're raising water. else if (shared.currentTouchAction != ToolBar.TouchControls.BrushActionIDs.baWaterRaise) { LeftAudioEnd(); } // Smooth if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baSmooth) { inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, middle, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; MiddleAudioStart(); isInAction = true; } else { MiddleAudioEnd(); } // Down if (shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baTerrainLower || shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baWaterLower || shared.currentTouchAction == ToolBar.TouchControls.BrushActionIDs.baHilly) { inGame.Terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, right, rate * rate * terrainSpeed); shared.heightMapModified = true; Boku.InGame.IsLevelDirty = true; RightAudioStart(); isInAction = true; } else { RightAudioEnd(); } if (TouchInput.WasReleased) { LeftAudioEnd(); MiddleAudioEnd(); RightAudioEnd(); } } else if (!shared.editBrushAllowedForTouch) { LeftAudioEnd(); MiddleAudioEnd(); RightAudioEnd(); } }