private TapResult singleTapRemoveComponentMenu(Vector2 tapLocation, ref ActorManager gameActorMgr) { TapResult menuResult = removeMenu.HandleSingleTap(tapLocation); if (menuResult == TapResult.removeComponent) { this.hideRemoveComponentMenu(); ComponentType removedComponent = gameActorMgr.RemoveCurrentComponent(); addMenu.ComponentRemovedFromStage(removedComponent); return TapResult.removeComponent; } if (menuResult == TapResult.closedMenu) { this.hideRemoveComponentMenu(); } return TapResult.tappedNothing; }
private TapResult singleTapAddComponentMenu(Vector2 tapLocation, ref ActorManager gameActorMgr) { TapResult menuResult = addMenu.handleSingleTap(tapLocation); if (menuResult == TapResult.addComponent) { // hide the addComponent menu. this.hideAddComponentMenu(); MachineComponent newComponent = addMenu.getNewComponent(); gameActorMgr.AddComponent(newComponent); // zoom the view in. //FinalGame.zoomIn(); this.zoomButton.Label = "Zoom-Out"; return TapResult.addComponent; } return TapResult.tappedNothing; }
// handle when the user has single-tapped on the screen. public TapResult HandleSingleTap(Vector2 tapLocation, ref ActorManager gameActorMgr) { tapLocation = screenToWorld(tapLocation); switch (this.currentState) { case (InGameMenuState.noMenu): return this.singleTapNoMenuState(tapLocation); break; //Is break really needed when we're returning? --Tony case (InGameMenuState.addComponentMenu): return this.singleTapAddComponentMenu(tapLocation, ref gameActorMgr); break; case (InGameMenuState.removeComponentMenu): return this.singleTapRemoveComponentMenu(tapLocation, ref gameActorMgr); break; default: return TapResult.tappedNothing; } }
private void dblTapNoMenuState(Vector2 tapLocation, ref ActorManager gameActorMgr) { // test to see if the tapLocation touched any of the buttons in the hudbar. float tapY = tapLocation.Y; float tapX = tapLocation.X; float componentTop = componentsButton.CenterY + componentsButton.Height / 2; float componentBottom = componentsButton.CenterY - componentsButton.Height / 2; float componentLeft = componentsButton.CenterX - componentsButton.Width / 2; float componentRight = componentsButton.CenterX + componentsButton.Width / 2; // did user touch outside componentsButton button? if (tapY > componentTop || tapY < componentBottom || tapX < componentLeft || tapX > componentRight) { //removeButtonState = false; } else { //this.remove.Color = Color.Green; if (FinalGame.allowMovement == true) { this.showAddComponentMenu(); } } float zoomTop = zoomButton.CenterY + zoomButton.Height / 2; float zoomBottom = zoomButton.CenterY - zoomButton.Height / 2; float zoomLeft = zoomButton.CenterX - zoomButton.Width / 2; float zoomRight = zoomButton.CenterX + zoomButton.Width / 2; // did user touch outside zoomButton button? if (tapY > zoomTop || tapY < zoomBottom || tapX < zoomLeft || tapX > zoomRight) { //removeButtonState = false; } else { if (FinalGame.allowMovement == true) { //FinalGame.ToggleZoom(); // toggle visible text. if (zoomButton.Label == "Zoom-In") { zoomButton.Label = "Zoom-Out"; } else { zoomButton.Label = "Zoom-In"; } } } float goStopTop = goStopButton.CenterY + goStopButton.Height / 2; float goStopBottom = goStopButton.CenterY - goStopButton.Height / 2; float goStopLeft = goStopButton.CenterX - goStopButton.Width / 2; float goStopRight = goStopButton.CenterX + goStopButton.Width / 2; // did user touch outside goStopButton button? if (tapY > goStopTop || tapY < goStopBottom || tapX < goStopLeft || tapX > goStopRight) { // do nothing. } else { // zoom out view //FinalGame.zoomOut(); this.zoomButton.Label = "Zoom-In"; // start spawner gameActorMgr.ToggleSpawner(); // toggle button art. if (goStopButton.Texture == "goButton") { goStopButton.Texture = "stopButton"; } else { goStopButton.Texture = "goButton"; } } }
// handle when the user has double-tapped on the screen. public void handleDoubleTap(Vector2 tapLocation, ref ActorManager gameActorMgr) { tapLocation = screenToWorld(tapLocation); switch (this.currentState) { case (InGameMenuState.noMenu): this.dblTapNoMenuState(tapLocation, ref gameActorMgr); break; case (InGameMenuState.addComponentMenu): this.dblTapAddComponentMenu(tapLocation); break; case (InGameMenuState.removeComponentMenu): this.dblTapRemoveComponentMenu(tapLocation); break; } }