Пример #1
0
 /// <summary>
 /// Closes game (playing) and returns to main Menu -> asks if you want to save first
 /// </summary>
 private void ProcessGameReturn()
 {
     Debug.LogFormat("[Ctrl] ControlManager.cs -> ProcessGameReturn: ProcessGameReturn to MainMenu selected{0}", "\n");
     //stop animations
     GameManager.i.animateScript.StopAnimations();
     //save dialogue if there is unsaved progress
     if (GameManager.i.fileScript.CheckSaveRequired() == true)
     {
         ModalConfirmDetails details = new ModalConfirmDetails()
         {
             topText     = "Any recent progress will be lost unless Saved",
             bottomText  = "Save progress?",
             buttonFalse = "Don't Save",
             buttonTrue  = "SAVE",
             eventFalse  = EventType.OpenMainMenu,
             eventTrue   = EventType.SaveGameAndReturn
         };
         //open confirmation dialogue
         EventManager.i.PostNotification(EventType.ConfirmOpen, this, details, "ControlManager.cs -> ProcessGameReturn");
     }
     else
     {
         //returns to main menu (nothing to save, hence no save dialogue
         EventManager.i.PostNotification(EventType.OpenMainMenu, this, MainMenuType.Main, "ControlManager.cs -> ProcessGameReturn");
     }
 }
Пример #2
0
    public void Start()
    {
        Debug.Assert(confirmObject != null, "Invalid confirmObject (Null)");
        Debug.Assert(topText != null, "Invalid topText (Null)");
        Debug.Assert(bottomText != null, "Invalid bottomText (Null)");
        Debug.Assert(buttonFalse != null, "Invalid buttonLeft (Null)");
        Debug.Assert(buttonTrue != null, "Invalid buttonRight (Null)");
        //buttons -> interaction components
        ButtonInteraction interactLeft = buttonFalse.GetComponent <ButtonInteraction>();

        if (interactLeft != null)
        {
            interactLeft.SetButton(EventType.ConfirmCloseLeft);
        }
        ButtonInteraction interactRight = buttonTrue.GetComponent <ButtonInteraction>();

        if (interactRight != null)
        {
            interactRight.SetButton(EventType.ConfirmCloseRight);
        }
        //details empty
        confirmDetails = null;
        //register a listener
        EventManager.i.AddListener(EventType.ConfirmCloseLeft, OnEvent, "ModalConfirm");
        EventManager.i.AddListener(EventType.ConfirmCloseRight, OnEvent, "ModalConfirm");
        EventManager.i.AddListener(EventType.ConfirmOpen, OnEvent, "ModalConfirm");
    }
Пример #3
0
    /// <summary>
    /// Initialise and display ModalConfirm window
    /// </summary>
    /// <param name="details"></param>
    private void SetModalConfirm(ModalConfirmDetails details)
    {
        if (details != null)
        {
            confirmDetails = details;
            //close tooltips
            GameManager.i.guiScript.SetTooltipsOff();

            topText.text         = details.topText;
            bottomText.text      = details.bottomText;
            buttonFalseText.text = details.buttonFalse;
            buttonTrueText.text  = details.buttonTrue;

            //set modal true
            GameManager.i.guiScript.SetIsBlocked(true, details.modalLevel);
            //pass through data for when the confirm window is closed
            modalLevel = details.modalLevel;
            modalState = details.modalState;
            //set states
            GameManager.i.inputScript.SetModalState(new ModalStateData()
            {
                mainState = ModalSubState.Confirm
            });
            Debug.LogFormat("[UI] ModalConfirm.cs -> SetModalConfirm{0}", "\n");
            //switch on object
            confirmObject.SetActive(true);
        }
        else
        {
            Debug.LogError("Invalid ModalConfirmDetails (Null)");
        }
    }
Пример #4
0
    /// <summary>
    /// Save the current game and Exit. Special Save operation during gameState.MetaGame)
    /// </summary>
    private void ProcessSaveAndExit(RestorePoint restorePointInput)
    {
        Debug.LogFormat("[Ctrl] ControlManager.cs -> ProcessSaveAndExit: Save and Exit selected{0}", "\n");
        //save restore point in case user changes their mind (update InputManager.cs as save/load is keyed off this value)
        restorePoint = restorePointInput;

        /*GameManager.i.inputScript.RestorePoint = restorePointInput;*/

        //toggle on modal block
        GameManager.i.guiScript.SetIsBlocked(true);
        //Save Game -> open background
        GameManager.i.modalGUIScript.SetBackground(Background.SaveGame);
        //Close any open background
        GameManager.i.modalGUIScript.CloseBackgrounds(Background.SaveGame);
        //change game state
        GameManager.i.inputScript.GameState = GameState.SaveAndExit;
        //Debug -> time load game process
        GameManager.i.testScript.StartTimer();
        GameManager.i.fileScript.WriteSaveData(new LoadGameState()
        {
            gameState = GameState.MetaGame, restorePoint = restorePointInput
        }, SaveType.PlayerSave);
        GameManager.i.fileScript.SaveGame(SaveType.PlayerSave);
        //how long did it take?
        long timeElapsed = GameManager.i.testScript.StopTimer();

        Debug.LogFormat("[Per] ControlManager.cs -> ProcessSaveGame: SAVE GAME took {0} ms", timeElapsed);
        //Game saved, ask user if they want to exit
        ModalConfirmDetails details = new ModalConfirmDetails();

        details.topText     = string.Format("Your game has been {0}. You are about to Exit", GameManager.Formatt("SAVED", ColourType.neutralText));
        details.bottomText  = "Are you sure?";
        details.buttonFalse = "EXIT";
        details.buttonTrue  = "RESUME";
        details.eventFalse  = EventType.ExitGame;
        details.eventTrue   = EventType.ResumeMetaGame;
        details.modalState  = ModalSubState.MetaGame;
        //open confirm
        EventManager.i.PostNotification(EventType.ConfirmOpen, this, details, "MetaManager.cs -> ProcessMetaGame");
    }
Пример #5
0
    /// <summary>
    /// Event Handler
    /// </summary>
    /// <param name="eventType"></param>
    /// <param name="Sender"></param>
    /// <param name="Param"></param>
    public void OnEvent(EventType eventType, Component Sender, object Param = null)
    {
        //detect event type
        switch (eventType)
        {
        case EventType.ConfirmOpen:
            ModalConfirmDetails details = Param as ModalConfirmDetails;
            SetModalConfirm(details);
            break;

        case EventType.ConfirmCloseLeft:
            ConfirmCloseLeft();
            break;

        case EventType.ConfirmCloseRight:
            ConfirmCloseRight();
            break;

        default:
            Debug.LogError(string.Format("Invalid eventType {0}{1}", eventType, "\n"));
            break;
        }
    }