private void executeOperation() { Operation selectedOperation = r_Operations.ElementAtOrDefault(m_SelectedOperation.Index - 1); if (selectedOperation != null) { foreach (KeyValuePair <string, Func <string, eOperationStatus> > instruction in selectedOperation.Instructions) { eOperationStatus currentOperationStatus = eOperationStatus.Starting; while (currentOperationStatus == eOperationStatus.Starting) { try { Console.WriteLine(instruction.Key); string parameter = Console.ReadLine(); currentOperationStatus = instruction.Value.Invoke(parameter); } catch (Exception e) { Console.WriteLine(e.Message); Console.Write(Environment.NewLine); } } if (currentOperationStatus == eOperationStatus.CanProceedToSubMenu) { currentOperationStatus = executeSubOperations(selectedOperation, currentOperationStatus); } if (currentOperationStatus == eOperationStatus.Completed) { Console.WriteLine(selectedOperation.m_OperationResult); } } } }
public User(int id, string name, int age) { UserId = id; Name = name; Age = age; Status = eOperationStatus.None; }
public eOperationStatus AppendEdge(int Width, int Height, int DeltaX, int DeltaY) { if (MostRecentlySelectedLayer == null) { return(eOperationStatus.NoLayerSelected); } eOperationStatus sts = MostRecentlySelectedLayer.AppendEdge(Width, Height, DeltaX, DeltaY); if (sts != eOperationStatus.OK) { return(sts); } #if false if (MostRecentlySelectedVertex == null) { return(eOperationStatus.NoVertexSelected); } // Add a new point int nextindex = FindNextIndex(); Vertex vP = new Vertex(); vP.Index = nextindex; vP.X = MostRecentlySelectedVertex.X + DeltaX; vP.Y = MostRecentlySelectedVertex.Y + DeltaY; VertexList.Add(vP); // Add an edge Edge oEdge = new Edge(); oEdge.Height = Height; oEdge.Width = Width; oEdge.p1 = MostRecentlySelectedVertex.Index; oEdge.p2 = vP.Index; oEdge.ID = ""; oEdge.HoleGroupID = ""; EdgeList.Add(oEdge); #endif // Redraw shapes DrawShapes(); return(eOperationStatus.OK); }
public eOperationStatus AddHoleInMostRecentlySelectedEdge(int Width) { if (MostRecentlySelectedLayer == null) { return(eOperationStatus.NoLayerSelected); } eOperationStatus sts = MostRecentlySelectedLayer.AddHoleInMostRecentlySelectedEdge(Width); if (sts != eOperationStatus.OK) { return(sts); } // trigger redraw DrawShapes(); return(eOperationStatus.OK); }
public eOperationStatus UnMergeMostRecentlySelectedHandle() { if (MostRecentlySelectedLayer == null) { return(eOperationStatus.NoLayerSelected); } eOperationStatus sts = MostRecentlySelectedLayer.UnMergeMostRecentlySelectedHandle(); if (sts != eOperationStatus.OK) { return(sts); } // trigger a redraw DrawShapes(); return(eOperationStatus.OK); }
public eOperationStatus SplitMostRecentlySelectedEdge(float RelativeDistance) { if (MostRecentlySelectedLayer == null) { return(eOperationStatus.NoLayerSelected); } eOperationStatus sts = MostRecentlySelectedLayer.SplitMostRecentlySelectedEdge(RelativeDistance); if (sts != eOperationStatus.OK) { return(sts); } // trigger redraw DrawShapes(); return(eOperationStatus.OK); }
public eOperationStatus DeleteCurrentEdge() { if (MostRecentlySelectedLayer == null) { return(eOperationStatus.NoLayerSelected); } eOperationStatus sts = MostRecentlySelectedLayer.DeleteCurrentEdge(); if (sts != eOperationStatus.OK) { return(sts); } // Trigger redraw DrawShapes(); return(eOperationStatus.OK); }
private eOperationStatus executeSubOperations(Operation i_SelectedOperation, eOperationStatus i_CurrentOperationStatus) { foreach (KeyValuePair <string, Func <string, eOperationStatus> > selectedOperationSubMenuInstruction in i_SelectedOperation.SubMenuInstructions) { i_CurrentOperationStatus = eOperationStatus.Starting; while (i_CurrentOperationStatus == eOperationStatus.Starting) { try { Console.WriteLine(selectedOperationSubMenuInstruction.Key); string parameter = Console.ReadLine(); i_CurrentOperationStatus = selectedOperationSubMenuInstruction.Value.Invoke(parameter); } catch (Exception e) { Console.WriteLine(e.Message); Console.Write(Environment.NewLine); } } } return(i_CurrentOperationStatus); }
/// <summary> /// Ends current save operation, resumes play /// </summary> private void endOperation() { // Special case if we're returning to main menu if (returningToMainMenu) { loadingUIParentCanvas.SetActive(false); currentOperationStatus = eOperationStatus.IDLE; // We also need to do some small potential clean up to ensure // that any lingering pickups that were in the DoNotDestroyOnLoad // scene are destroyed. mySaveLoadLogic.removeAllPickupsInWorld(true); } else { loadingUIParentCanvas.SetActive(false); currentOperationStatus = eOperationStatus.IDLE; // Unlock player in place and resume interactions FPEInteractionManagerScript.Instance.gameObject.SetActive(true); FPEInteractionManagerScript.Instance.resumePlayerAndInteraction(resetPlayerLook); FPEInputManager.Instance.FlushInputs(); } }
public void SetStatus(eOperationStatus status) { Status = status; }
/// <summary> /// Initializes save/load operation system for specified operation type. /// </summary> /// <param name="opType">The type of operation to initialize</param> private void initializeOperation(eOperationStatus opType) { savingInProgress = false; loadingLevelInProgress = false; restoringDataInProgress = false; returningToMainMenu = false; currentOperationStatus = opType; switch (opType) { case eOperationStatus.SAVING_GAME: savingInProgress = true; resetPlayerLook = false; updateStatusMessage("Saving Game..."); break; case eOperationStatus.LOADING_GAME: currentLoadGameStatus = eLoadGameStatus.LOADING_LAST_SCENE; loadingLevelInProgress = true; restoringDataInProgress = true; resetPlayerLook = false; // We also want to stop all diary playback if loading a saved game FPEInteractionManagerScript.Instance.stopAllDiaryPlayback(); updateStatusMessage("Loading Scene..."); break; case eOperationStatus.CHANGING_SCENE: currentChangeSceneStatus = eChangeSceneStatus.SAVING; savingInProgress = true; loadingLevelInProgress = true; restoringDataInProgress = true; resetPlayerLook = true; updateStatusMessage("Changing Scene..."); break; case eOperationStatus.CHANGING_SCENE_NOSAVE: currentChangeSceneStatus = eChangeSceneStatus.LOADING_NEXT_SCENE; loadingLevelInProgress = true; restoringDataInProgress = true; resetPlayerLook = true; updateStatusMessage("Changing Scene..."); break; case eOperationStatus.RETURN_TO_MAIN_MENU: currentChangeSceneStatus = eChangeSceneStatus.LOADING_NEXT_SCENE; loadingLevelInProgress = true; returningToMainMenu = true; updateStatusMessage("Returning to Main Menu..."); break; default: Debug.LogError("Bad operation type '" + opType + "'"); break; } progressSpinner.transform.rotation = Quaternion.identity; loadingUIParentCanvas.SetActive(true); // Lock player in place and suspend interactions FPEInteractionManagerScript.Instance.suspendPlayerAndInteraction(); FPEInteractionManagerScript.Instance.gameObject.SetActive(false); operationStartTime = Time.time; }
void Update() { #region EDITOR_DEBUG_KEYS #if UNITY_EDITOR if (editorDebugKeys) { // Debug Keys - to simulate menu button actions, etc. // if (Input.GetKeyDown(KeyCode.Alpha1)) { Debug.Log("Debug Key: Save"); SaveGame(); } if (Input.GetKeyDown(KeyCode.Alpha2)) { if (SavedGameExists()) { Debug.Log("Debug Key: Load"); LoadGame(); } else { Debug.Log("Debug Key: Can't do Load, no saved game file was found"); } } if (Input.GetKeyDown(KeyCode.Alpha4)) { Debug.Log("Debug Key: Start a New Game"); StartANewGame(); } } #endif #endregion // If any operation is happening, we keep spinning the progress spinner and keep processing until that operation is complete. if (currentOperationStatus != eOperationStatus.IDLE) { // Animate spinner progressSpinner.transform.Rotate(new Vector3(0f, 0f, -spinnerRotationRate * Time.deltaTime)); // Process current state if (currentOperationStatus == eOperationStatus.SAVING_GAME) { if (savingInProgress == false) { currentOperationStatus = eOperationStatus.UX_WAIT; } } else if (currentOperationStatus == eOperationStatus.LOADING_GAME) { if (currentLoadGameStatus == eLoadGameStatus.LOADING_LAST_SCENE) { if (loadingLevelInProgress == false) { currentLoadGameStatus = eLoadGameStatus.RESTORING_SCENE_DATA; updateStatusMessage("Restoring saved game data..."); StartCoroutine(restoreDataForCurrentScene(true)); } } else if (currentLoadGameStatus == eLoadGameStatus.RESTORING_SCENE_DATA) { if (restoringDataInProgress == false) { currentLoadGameStatus = eLoadGameStatus.IDLE; currentOperationStatus = eOperationStatus.UX_WAIT; } } } else if (currentOperationStatus == eOperationStatus.CHANGING_SCENE) { if (currentChangeSceneStatus == eChangeSceneStatus.SAVING) { if (savingInProgress == false) { // When visiting a level for the first time, there won't be any auto-save data // to restore once we load the new scene. As a result, we won't do the usual // data restoration, which includes an operation to clean up lingering pickups // and inventory items. So, if changing scene and auto-saving, we want to // destroy any left over objects in the DontDestoryOnLoad scene. mySaveLoadLogic.removeAllInventoryInWorld(false); mySaveLoadLogic.removeAllPickupsInWorld(false); currentChangeSceneStatus = eChangeSceneStatus.LOADING_NEXT_SCENE; updateStatusMessage("Loading Scene " + destinationSceneIndex + "..."); StartCoroutine(loadNewScene(destinationSceneIndex)); } } else if (currentChangeSceneStatus == eChangeSceneStatus.LOADING_NEXT_SCENE) { if (loadingLevelInProgress == false) { currentChangeSceneStatus = eChangeSceneStatus.RESTORING_SCENE_DATA; updateStatusMessage("Restoring Data..."); StartCoroutine(restoreDataForCurrentScene(false)); } } else if (currentChangeSceneStatus == eChangeSceneStatus.RESTORING_SCENE_DATA) { if (restoringDataInProgress == false) { movePlayerToSuitableEntranceOrStartPosition(); currentOperationStatus = eOperationStatus.UX_WAIT; } } } else if (currentOperationStatus == eOperationStatus.CHANGING_SCENE_NOSAVE) { if (currentChangeSceneStatus == eChangeSceneStatus.LOADING_NEXT_SCENE) { if (loadingLevelInProgress == false) { currentChangeSceneStatus = eChangeSceneStatus.RESTORING_SCENE_DATA; updateStatusMessage("Restoring Data..."); StartCoroutine(restoreDataForCurrentScene(false)); } } else if (currentChangeSceneStatus == eChangeSceneStatus.RESTORING_SCENE_DATA) { if (restoringDataInProgress == false) { movePlayerToSuitableEntranceOrStartPosition(); currentOperationStatus = eOperationStatus.UX_WAIT; } } } else if (currentOperationStatus == eOperationStatus.RETURN_TO_MAIN_MENU) { if (currentChangeSceneStatus == eChangeSceneStatus.LOADING_NEXT_SCENE) { if (loadingLevelInProgress == false) { currentOperationStatus = eOperationStatus.UX_WAIT; } } } else if (currentOperationStatus == eOperationStatus.UX_WAIT) { if ((Time.time - operationStartTime) > minimumUIDisplayTime) { endOperation(); } } } }
public void SetStatus(eOperationStatus status) { Result.Status = status; }
public eOperationStatus DeleteSelectedVertex() { if (MostRecentlySelectedLayer == null) { return(eOperationStatus.NoLayerSelected); } // If there is not a most recently selected handle return eOperationStatus sts = MostRecentlySelectedLayer.DeleteSelectedVertex(); if (sts != eOperationStatus.OK) { return(sts); } #if false if (MostRecentlySelectedVertex == null) { return(eOperationStatus.NoVertexSelected); } /* * This vertex must have exactly two different edges coming into it */ int ReferenceCount = 0; List <Edge> ConnectingEdgeList = new List <Edge>(); for (int i = 0; i < EdgeList.Count; i++) { Edge oEdge = EdgeList.GetFrom(i); if (oEdge.p1 == MostRecentlySelectedVertex.Index) { ReferenceCount++; ConnectingEdgeList.Add(oEdge); } if (oEdge.p2 == MostRecentlySelectedVertex.Index) { ReferenceCount++; ConnectingEdgeList.Add(oEdge); } } if (ReferenceCount != 2) { return(eOperationStatus.MustBeTwoConnectingEdgesForOperation); } // Get the from and to points of the remade edge int NewP1 = -1; int NewP2 = -1; Edge oEdge0 = ConnectingEdgeList.GetFrom(0); if (oEdge0.p1 == MostRecentlySelectedVertex.Index) { NewP1 = oEdge0.p2; } else { NewP1 = oEdge0.p1; } Edge oEdge1 = ConnectingEdgeList.GetFrom(1); if (oEdge1.p2 == MostRecentlySelectedVertex.Index) { NewP2 = oEdge1.p1; } else { NewP2 = oEdge1.p2; } // Replace the p1 and p2 in the 0th edge and delete the 1th edge. We know that the current handle // will be redundant so we can delete it. oEdge0.p1 = NewP1; oEdge0.p2 = NewP2; // delete the current handle, it the one we're removing for (int i = 0; i < VertexList.Count; i++) { Vertex v = VertexList.GetFrom(i); if (v.Index == MostRecentlySelectedVertex.Index) { VertexList.RemoveAt(i); break; } } // Delete the 1th edge. for (int i = 0; i < EdgeList.Count; i++) { Edge e = EdgeList.GetFrom(i); if (e == oEdge1) { EdgeList.RemoveAt(i); break; } } #endif // trigger redraw DrawShapes(); return(eOperationStatus.OK); }