} // end of HillTool GetInstance() public override void Update() { if (Active && !PickerXInUse && !PickerYInUse) { CheckSelectCursor(); if (DebouncePending) { return; } GamePadInput pad = GamePadInput.GetGamePad1(); if (LeftRate < kSmallRate) { /// Reseed everytime they switch modes. Terrain.Reseed(); } ProcessTriggers( Terrain.EditMode.Hill, Terrain.EditMode.Noop, Terrain.EditMode.Smooth); SelectOverlay(); } base.Update(); } // end of HillTool Update()
} // end of EditTextureUpdateObj c'tor /// <summary> /// EditTextureUpdateObj Update() /// </summary> /// <param name="camera"></param> public override void Update() { float secs = Time.WallClockFrameSeconds; // Check if we have input focus. Don't do any input // related update if we don't. if (CommandStack.Peek() == commandMap) { // Grab the current state of the gamepad. GamePadInput pad = GamePadInput.GetGamePad1(); // Switch to Mini-Hub? if (pad.Back.WasPressed) { parent.SwitchToMiniHub(); return; } // Cycle through textures. /* * if (pad.ButtonB.WasPressed) * { * Foley.PlayProgrammingClick(); * shared.editBrushTextureIndex = (shared.editBrushTextureIndex + 1) % 4; // Move to the right. * } */ if (pad.ButtonX.WasPressed) { Foley.PlayProgrammingClick(); //shared.editBrushTextureIndex = (shared.editBrushTextureIndex + 3) % 4; // Move to the left. shared.editBrushTextureIndex = (shared.editBrushTextureIndex + 1) % 4; // Move to the right. } // Texture picker. if (pad.ButtonY.WasPressed) { parent.CurrentUpdateMode = UpdateMode.TexturePicker; return; } // Paint texture? if (pad.ButtonA.WasPressed || (pad.ButtonA.IsPressed && shared.editBrushMoved)) { parent.terrain.UpdateSelectTexture(shared.editBrushTextureIndex, shared.editBrushPosition, shared.editBrushRadius, shared.editBrushIndex); shared.textureSelectModified = true; InGame.inGame.IsLevelDirty = true; } } // end if we have input focus. // Do the common bits of the Update(). UpdateCamera(); UpdateWorld(); UpdateEditBrush(); } // end of EditTextureUpdateObj Update()
public override bool MatchAction(Reflex reflex, out object param) { GamePadSensor.PlayerId playerIdSensor = (GamePadSensor.PlayerId)reflex.targetSet.Param; if (this.playerId != playerIdSensor) { this.playerId = playerIdSensor; } GamePadInput pad = null; // Get the correct game pad. switch (playerId) { case GamePadSensor.PlayerId.All: pad = GamePadInput.GetGamePad0(); break; case GamePadSensor.PlayerId.One: pad = GamePadInput.GetGamePad1(); break; case GamePadSensor.PlayerId.Two: pad = GamePadInput.GetGamePad2(); break; case GamePadSensor.PlayerId.Three: pad = GamePadInput.GetGamePad3(); break; case GamePadSensor.PlayerId.Four: pad = GamePadInput.GetGamePad4(); break; } if (trigger == GamePadTrigger.LeftTrigger) { triggerValue = pad.LeftTrigger; } else if (trigger == GamePadTrigger.RightTrigger) { triggerValue = pad.RightTrigger; } // Return as a parameter a vector that can be used for input to the movement system, so // that players can drive and turn bots using gamepad triggers. param = new Vector2(0, triggerValue); return(triggerValue > 0); // only if pressed }
/// <summary> /// Grab snapshot terrain heights as appropriate. /// </summary> private void CheckLevel() { GamePadInput pad = GamePadInput.GetGamePad1(); if (pad.ButtonA.WasPressed) { inGame.Terrain.LevelStart = Terrain.GetTerrainHeight(shared.editBrushStart); } if (shared.editBrushMoved) { inGame.Terrain.LevelHeight = Terrain.GetTerrainHeight(shared.editBrushPosition); } }
/// <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; } }
/// <summary> /// Take snapshot of terrain height at appropriate times. /// </summary> private void CheckLevel() { GamePadInput pad = GamePadInput.GetGamePad1(); if (pad.ButtonA.WasPressed || RightWasPressed) { float height = Terrain.GetTerrainHeight(shared.editBrushStart); inGame.Terrain.LevelHeight = height; } /// If we have a point selected, hide the cursor float startToEnd = Vector2.DistanceSquared(shared.editBrushPosition, shared.editBrushStart); const float kMaxDist = 0.1f * 0.1f; if (pad.ButtonA.IsPressed || RightTriggerOn || (startToEnd > kMaxDist)) { inGame.HideCursor(); } else { inGame.ShowCursor(); } }
public override bool MatchAction(Reflex reflex, out object param) { bool result = false; // Only jump through hoops the first time to get the pad. if (ButtonState == null) { GamePadInput pad = null; // See if there's a filter defining which player we should be. If not, use pad0. if (playerId == GamePadSensor.PlayerId.Dynamic) { playerId = GamePadSensor.PlayerId.All; ReflexData data = reflex.Data; for (int i = 0; i < data.Filters.Count; i++) { if (data.Filters[i] is PlayerFilter) { playerId = ((PlayerFilter)data.Filters[i]).playerIndex; } } } // Get the correct game pad. switch (playerId) { case GamePadSensor.PlayerId.All: pad = GamePadInput.GetGamePad0(); break; case GamePadSensor.PlayerId.One: pad = GamePadInput.GetGamePad1(); break; case GamePadSensor.PlayerId.Two: pad = GamePadInput.GetGamePad2(); break; case GamePadSensor.PlayerId.Three: pad = GamePadInput.GetGamePad3(); break; case GamePadSensor.PlayerId.Four: pad = GamePadInput.GetGamePad4(); break; } // Get the correct game pad button. switch (button) { case GamePadButton.A: ButtonState = pad.ButtonA; break; case GamePadButton.B: ButtonState = pad.ButtonB; break; case GamePadButton.X: ButtonState = pad.ButtonX; break; case GamePadButton.Y: ButtonState = pad.ButtonY; break; case GamePadButton.LeftTrigger: ButtonState = pad.LeftTriggerButton; break; case GamePadButton.RightTrigger: ButtonState = pad.RightTriggerButton; break; } } result = ButtonState.IsPressed; // Return as a parameter a vector that can be used for input to the movement system, so // that players can drive and turn bots using gamepad buttons. param = new Vector2(0, 1); return(result); }
public override void Update() { // Our children have input focus but we can still steal away the buttons we care about. GamePadInput pad = GamePadInput.GetGamePad1(); UIGrid curGrid = shared.GetGridFromCurTab(); bool sortNeeded = false; // Do we or our children have input focus? This is so we can steal some inputs from them. if (CommandStack.Peek() == parent.commandMap || (curGrid != null && CommandStack.Peek() == curGrid.commandMap)) { if (pad.RightShoulder.WasPressed || pad.DPadRight.WasPressed || pad.LeftStickRight.WasPressed) { parent.curTab = (Tab)(((int)parent.curTab + 1) % (int)Tab.NumTabs); #if HIDE_MISSIONS if (parent.curTab == Tab.Missions) { parent.curTab = (Tab)(((int)parent.curTab + 1) % (int)Tab.NumTabs); } #endif // Update active state. if (curGrid != null) { curGrid.Active = false; } curGrid = shared.GetGridFromCurTab(); if (curGrid != null) { curGrid.Active = true; } sortNeeded = true; } if (pad.LeftShoulder.WasPressed || pad.DPadLeft.WasPressed || pad.LeftStickLeft.WasPressed) { parent.curTab = (Tab)(((int)parent.curTab + (int)Tab.NumTabs - 1) % (int)Tab.NumTabs); #if HIDE_MISSIONS if (parent.curTab == Tab.Missions) { parent.curTab = (Tab)(((int)parent.curTab + (int)Tab.NumTabs - 1) % (int)Tab.NumTabs); } #endif // Update active state. if (curGrid != null) { curGrid.Active = false; } curGrid = shared.GetGridFromCurTab(); if (curGrid != null) { curGrid.Active = true; } sortNeeded = true; } if (pad.ButtonY.WasPressed) { shared.curSortOrder = (LevelSort.SortBy)(((int)shared.curSortOrder + 1) % (int)LevelSort.SortBy.NumSorts); sortNeeded = true; shared.bottomBarDirty = true; BokuGame.Audio.GetCue("programming add").Play(); } if (shared.curSortOrder == LevelSort.SortBy.UnSorted) { shared.curSortOrder = LevelSort.SortBy.Date; sortNeeded = true; } if (sortNeeded && curGrid != null) { LevelSort.SortGrid(curGrid, shared.curSortOrder); sortNeeded = false; } if (pad.ButtonB.WasPressed) { // Back to Main Menu. parent.Deactivate(); MainMenu.Instance.Activate(); } // Only allow deletions from Downloads or MyWorlds. if (pad.ButtonX.WasPressed && (parent.curTab == Tab.Downloads || parent.curTab == Tab.MyWorlds)) { // TODO delete file. Ask are you sure??? // Delete the file. If curGrid is null then there's no file to delete. if (curGrid != null) { UIGridWorldTile tile = (UIGridWorldTile)curGrid.SelectionElement; String filename = tile.FullPath; if (Storage.Exists(filename)) { // NOTE: It is not safe to delete the following files since they could // be shared by multiple worlds: // // - The "stuff" file // - The terrain heightmap file // - The terrain texture select file // Delete world xml file Storage.Delete(filename); // Delete thumbnail image Storage.TextureDelete(Path.GetDirectoryName(filename) + @"\" + Path.GetFileNameWithoutExtension(filename)); if (InGame.CurrentWorldId.ToString() == Path.GetFileNameWithoutExtension(filename)) { // Reset the current world information InGame.AutoSaved = false; InGame.XmlWorldData = null; } } // Remove the shared render targets from all elements. UIGridWorldTile.SharedRenderTarget.ResetAll(); // Remove the element from the grid. if (curGrid.RemoveAndCollapse(curGrid.SelectionIndex)) { // This was last element in grid. Delete it. // Pop its command map. CommandStack.Pop(curGrid.commandMap); // Remove the grid itself. switch (parent.curTab) { case Tab.Missions: shared.missionsGrid = null; break; case Tab.MyWorlds: shared.myWorldsGrid = null; break; case Tab.StarterWorlds: shared.starterWorldsGrid = null; break; case Tab.Downloads: shared.downloadsGrid = null; break; } curGrid = null; } } // end if curGrid != null } // end if 'X' was pressed. } // end of if we have input focus // If we're not shutting down, update the tabs and the child grids. if (parent.pendingState != States.Inactive) { Matrix world = Matrix.Identity; // Set the backdrop color and unfade current tab. switch (parent.curTab) { case Tab.Missions: shared.missionsTab.Selected = true; shared.myWorldsTab.Selected = false; shared.starterWorldsTab.Selected = false; shared.downloadsTab.Selected = false; break; case Tab.MyWorlds: shared.missionsTab.Selected = false; shared.myWorldsTab.Selected = true; shared.starterWorldsTab.Selected = false; shared.downloadsTab.Selected = false; break; case Tab.StarterWorlds: shared.missionsTab.Selected = false; shared.myWorldsTab.Selected = false; shared.starterWorldsTab.Selected = true; shared.downloadsTab.Selected = false; break; case Tab.Downloads: shared.missionsTab.Selected = false; shared.myWorldsTab.Selected = false; shared.starterWorldsTab.Selected = false; shared.downloadsTab.Selected = true; break; } shared.missionsTab.Update(); shared.myWorldsTab.Update(); shared.starterWorldsTab.Update(); shared.downloadsTab.Update(); shared.UpdateBottomBarTexture(); shared.bottomBar.Update(); if (shared.missionsGrid != null) { shared.missionsGrid.Update(ref world); } if (shared.myWorldsGrid != null) { shared.myWorldsGrid.Update(ref world); } if (shared.starterWorldsGrid != null) { shared.starterWorldsGrid.Update(ref world); } if (shared.downloadsGrid != null) { shared.downloadsGrid.Update(ref world); } // Make sure the visible elements for the current grid have render targets. if (curGrid != null) { int focus = curGrid.SelectionIndex.Y; int start = Math.Max(focus - 3, 0); int end = Math.Min(focus + 3, curGrid.ActualDimensions.Y - 1); for (int i = start; i <= end; i++) { UIGridWorldTile tile = (UIGridWorldTile)curGrid.Get(0, i); if (tile.SRT == null) { // Get a rendertarget and assign to current tile. UIGridWorldTile.SharedRenderTarget srt = UIGridWorldTile.SharedRenderTarget.Get(curGrid); srt.Grid = curGrid; srt.Index = i; tile.SRT = srt; } } } } // end if not shutting down. } // end of Update()
} // end of EditHeightMapUpdateObj c'tor /// <summary> /// EditHeightMapUpdateObj Update() /// </summary> /// <param name="camera"></param> public override void Update() { float secs = Time.WallClockFrameSeconds; /// Do the common bits of the Update(). /// Do these first, as they are input to any editing below. UpdateCamera(); UpdateWorld(); UpdateEditBrush(); // Check if we have input focus. Don't do any input // related update if we don't. if (CommandStack.Peek() == commandMap) { // Grab the current state of the gamepad. GamePadInput pad = GamePadInput.GetGamePad1(); // Switch to Mini-Hub? if (pad.Back.WasPressed) { parent.SwitchToMiniHub(); return; } /// Debounce. Make sure the button press that brought /// us up is released before using it to make changes. if (starting) { if (pad.ButtonY.IsPressed || pad.ButtonA.IsPressed || pad.ButtonX.IsPressed) { return; } starting = false; } int modeShift = shared.editBrushBase; // Up if (pad.ButtonY.IsPressed) { InGame.inGame.terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, 0 + modeShift); shared.heightMapModified = true; InGame.inGame.IsLevelDirty = true; } // Smooth if (pad.ButtonX.IsPressed) { InGame.inGame.terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, 2 + modeShift); shared.heightMapModified = true; InGame.inGame.IsLevelDirty = true; } // Down if (pad.ButtonA.IsPressed) { InGame.inGame.terrain.RenderToHeightMap( shared.editBrushIndex, shared.editBrushPosition, shared.editBrushRadius, 1 + modeShift); shared.heightMapModified = true; InGame.inGame.IsLevelDirty = true; } } // end if we have input focus. } // end of EditHeightMapUpdateObj Update()
/// <summary> /// TopLevelPaletteUpdateObj Update() /// </summary> /// <param name="camera"></param> public override void Update() { float secs = Time.WallClockFrameSeconds; // Check if we have input focus. Don't do any input // related update if we don't. if (CommandStack.Peek() == commandMap) { // Grab the current state of the gamepad. GamePadInput pad = GamePadInput.GetGamePad1(); // Switch to Mini-Hub? if (pad.Back.WasPressed) { GamePadInput.ClearAllWasPressedState(); parent.ResetSim(CurrentLevelFilename()); // Needed to make sure that deactivated objects are actually removed from // the list otherwise they may get saved along with the newly activated ones. parent.Refresh(BokuGame.gameListManager.updateList, BokuGame.gameListManager.renderList); parent.SwitchToMiniHub(); return; } // The start button should always return to run mode. if (pad.Start.WasPressed) { BokuGame.Audio.GetCue("programming add").Play(); parent.CurrentUpdateMode = UpdateMode.RunSim; HelpOverlay.Pop(); return; } // Return to previous mode if (pad.ButtonB.WasPressed) { parent.CurrentUpdateMode = UpdateMode.RunSim; HelpOverlay.Pop(); return; } // Select current mode. if (pad.ButtonA.WasPressed) { BokuGame.Audio.GetCue("programming add").Play(); parent.CurrentUpdateMode = curMode; HelpOverlay.Pop(); // Remove whichever help overlay is active. } // Change selected mode. if (pad.LeftTriggerButton.WasPressed || pad.DPadLeft.WasPressed) { BokuGame.Audio.GetCue("programming click").Play(); MoveToPreviousMode(); SetHelpOverlay(); } if (pad.RightTriggerButton.WasPressed || pad.DPadRight.WasPressed) { BokuGame.Audio.GetCue("programming click").Play(); MoveToNextMode(); SetHelpOverlay(); } } // end if we have input focus. UpdateCamera(); UpdateWorld(); UpdateEditBrush(); } // end of TopLevelPaletteUpdateObj Update()
} // end of TexturePicker InitFileList() public void Update() { if (active) { GamePadInput pad = GamePadInput.GetGamePad1(); // Switch active grid? bool changed = false; if (pad.LeftStickLeft.WasPressed || pad.DPadLeft.WasPressed) { activeGrid = (activeGrid + 3) % 4; changed = true; Foley.PlayProgrammingClick(); } if (pad.LeftStickRight.WasPressed || pad.DPadRight.WasPressed) { activeGrid = (activeGrid + 1) % 4; changed = true; Foley.PlayProgrammingClick(); } if (changed) { Vector3 newPosition = new Vector3(-2.25f + 1.5f * activeGrid, 0.0f, 0.0f); TwitchManager.GetVector3 get = delegate(Object param) { return(selectionPlate.Position); }; TwitchManager.SetVector3 set = delegate(Vector3 value, Object param) { selectionPlate.Position = value; }; TwitchManager.Vector3Twitch twitch = new TwitchManager.Vector3Twitch(get, set, newPosition, 0.25f, TwitchCurve.Shape.OvershootOut); twitch.Start(); grid0.Active = false; grid1.Active = false; grid2.Active = false; grid3.Active = false; switch (activeGrid) { case 0: grid0.Active = true; break; case 1: grid1.Active = true; break; case 2: grid2.Active = true; break; case 3: grid3.Active = true; break; } changed = false; } backPlate.Update(); selectionPlate.Update(); grid0.Update(ref worldGrid); grid1.Update(ref worldGrid); grid2.Update(ref worldGrid); grid3.Update(ref worldGrid); // See if any of the grids have changed which texture is in focus. // If so, change what the terrain sees. if (grid0.SelectionIndex.Y != curFocusIndex0) { curFocusIndex0 = grid0.SelectionIndex.Y; InGame.inGame.Terrain.ChangeTerrainTexture(0, files[curFocusIndex0]); InGame.inGame.IsLevelDirty = true; } if (grid1.SelectionIndex.Y != curFocusIndex1) { curFocusIndex1 = grid1.SelectionIndex.Y; InGame.inGame.Terrain.ChangeTerrainTexture(1, files[curFocusIndex1]); InGame.inGame.IsLevelDirty = true; } if (grid2.SelectionIndex.Y != curFocusIndex2) { curFocusIndex2 = grid2.SelectionIndex.Y; InGame.inGame.Terrain.ChangeTerrainTexture(2, files[curFocusIndex2]); InGame.inGame.IsLevelDirty = true; } if (grid3.SelectionIndex.Y != curFocusIndex3) { curFocusIndex3 = grid3.SelectionIndex.Y; InGame.inGame.Terrain.ChangeTerrainTexture(3, files[curFocusIndex3]); InGame.inGame.IsLevelDirty = true; } float outerRowAlpha = 0.3f; float innerRowAlpha = 0.7f; // Update the alpha values of the visible tiles. for (int i = 0; i < grid0.ActualDimensions.Y; i++) { UIGrid2DTextureElement e = null; e = grid0.Get(0, i) as UIGrid2DTextureElement; if (e != null) { int delta = Math.Abs(i - grid0.SelectionIndex.Y); if (delta < 2) { e.Alpha = 1.0f; } else if (delta < 3) { e.Alpha = innerRowAlpha; } else { e.Alpha = outerRowAlpha; } } e = grid1.Get(0, i) as UIGrid2DTextureElement; if (e != null) { int delta = Math.Abs(i - grid1.SelectionIndex.Y); if (delta < 2) { e.Alpha = 1.0f; } else if (delta < 3) { e.Alpha = innerRowAlpha; } else { e.Alpha = outerRowAlpha; } } e = grid2.Get(0, i) as UIGrid2DTextureElement; if (e != null) { int delta = Math.Abs(i - grid2.SelectionIndex.Y); if (delta < 2) { e.Alpha = 1.0f; } else if (delta < 3) { e.Alpha = innerRowAlpha; } else { e.Alpha = outerRowAlpha; } } e = grid3.Get(0, i) as UIGrid2DTextureElement; if (e != null) { int delta = Math.Abs(i - grid3.SelectionIndex.Y); if (delta < 2) { e.Alpha = 1.0f; } else if (delta < 3) { e.Alpha = innerRowAlpha; } else { e.Alpha = outerRowAlpha; } } } } } // end of TexturePicker Update()