コード例 #1
0
ファイル: GameManager.cs プロジェクト: yazici/FRONTIERS
        public IEnumerator SpawnSaveGameDialog(bool confirmFirst, bool canCancel)
        {
            bool spawnSaveGameDialog = true;

            if (confirmFirst)
            {
                spawnSaveGameDialog = false;
                GameObject              yesNoDialogChildEditor = GUIManager.SpawnNGUIChildEditor(gameObject, GUIManager.Get.NGUIYesNoCancelDialog, false);
                GUIYesNoCancelDialog    confirmDialog          = yesNoDialogChildEditor.GetComponent <GUIYesNoCancelDialog>();
                YesNoCancelDialogResult confirmResult          = new YesNoCancelDialogResult();
                confirmResult.CancelButton = canCancel;
                confirmResult.MessageType  = "Save Current Game?";
                //confirmResult.Message = "Click 'Yes' to save before quitting. Click 'Cancel' to return to the game.";
                GUIManager.SendEditObjectToChildEditor <YesNoCancelDialogResult>(yesNoDialogChildEditor, confirmResult);

                while (!confirmDialog.IsFinished)
                {
                    yield return(null);
                }

                //deal with the result
                switch (confirmResult.Result)
                {
                case DialogResult.Cancel:
                default:
                    //we'll exit without setting the confirm game state
                    spawnSaveGameDialog = false;
                    break;

                case DialogResult.No:
                    Profile.Get.CurrentGame.LastTimeDeclinedToSave = System.DateTime.Now;
                    spawnSaveGameDialog = false;
                    break;

                case DialogResult.Yes:
                    Debug.Log("Save game");
                    spawnSaveGameDialog = true;
                    break;
                }
            }

            if (spawnSaveGameDialog)
            {
                /*
                 *                      GameObject saveGameEditor = GUIManager.SpawnNGUIChildEditor (gameObject, GUIManager.Get.NGUISaveGameDialog, false);
                 *                      GUISaveGameDialog saveGameDialog = saveGameEditor.GetComponent <GUISaveGameDialog> ();
                 *                      SaveGameDialogResult saveGameResult = new SaveGameDialogResult ();
                 *                      GUIManager.SendEditObjectToChildEditor <SaveGameDialogResult> (saveGameEditor, saveGameResult);
                 *                      while (!saveGameDialog.IsFinished) {
                 *                              yield return null;
                 *                      }
                 */
            }

            yield break;
        }
コード例 #2
0
        public bool ActionCancel(double timeStamp)
        {
            if (mDestroyed)
            {
                return(true);
            }

            if (!(WaitingForFade || StartSuspended))
            {
                if (RequireConfirmationToExit)
                {
                    bool spawnDialog = false;
                    switch (State)
                    {
                    case CutsceneState.Idling:
                        spawnDialog = RequireConfirmationDuringIdle;
                        break;

                    case CutsceneState.Finishing:
                        spawnDialog = RequireConfirmationDuringEnd;
                        break;

                    case CutsceneState.Starting:
                        spawnDialog = RequireConfirmationDuringStart;
                        break;

                    default:
                        break;
                    }

                    if (spawnDialog)
                    {
                        Debug.Log("Requires confirmation to exit");
                        if (mConfirmationDialog == null)
                        {
                            Debug.Log("Spawning NGUI manager");
                            mConfirmationDialog = GUIManager.SpawnNGUIChildEditor(gameObject, GUIManager.Get.NGUIYesNoCancelDialog);
                            GUI.YesNoCancelDialogResult result = new GUI.YesNoCancelDialogResult();
                            result.CancelButton = false;
                            result.Message      = ConfirmationMessage;
                            result.MessageType  = "Skip Cutscene";
                            //see if our top interface is using custom vr settings
                            if (VRManager.VRMode && HasActiveInterfaces)
                            {
                                GUIYesNoCancelDialog dialog = mConfirmationDialog.GetComponent <GUIYesNoCancelDialog>();
                                dialog.CustomVRSettings = InterfaceList[0].CustomVRSettings;
                                dialog.AxisLock         = InterfaceList[0].AxisLock;
                                dialog.CursorLock       = InterfaceList[0].CursorLock;
                                dialog.LockOffset       = InterfaceList[0].LockOffset;
                            }
                            GUIManager.SendEditObjectToChildEditor <GUI.YesNoCancelDialogResult>(new ChildEditorCallback <GUI.YesNoCancelDialogResult>(ConfirmCancel), mConfirmationDialog, result);
                        }
                    }
                    else
                    {
                        OnFinished();
                    }
                }
                else
                {
                    OnFinished();
                }
            }
            return(true);
        }