예제 #1
0
    private void Update()
    {
        string displayString = "";

        // arbitrary end date, will modify when months become objects, not just prefabs
        if (this.totalScore < 0 || this.gameManager.GetDaysPassed() >= 26)
        {
            // game is over, complete game-over string with score and days passed
            displayString = "Days Lasted: " + (this.gameManager.GetDaysPassed() + 1).ToString() + " " +
                            "Money Made: " + this.totalScore.ToString();
            this.modalState = ModalUI.ModalState.GameOver;
        }
        // if the modal is intended to be in a state where it is displayed, display it. Otherwise hide it.
        if (modalState != ModalUI.ModalState.HideModal && modalState != ModalUI.ModalState.NoState)
        {
            SpawnModal(this.modalState, displayString);
            AdjustModalPositionScale();
            BlockInput(true);
        }
        else if (modal.activeSelf && modalState == ModalUI.ModalState.HideModal)
        {
            HideModal();
            BlockInput(false);
        }
    }
예제 #2
0
 private void DisplayModal(ModalUI.ModalState state, string displayString)
 {
     if (modal == null)
     {
         modal = Instantiate(this.modalPrefab, this.backgroundCanvas.transform, false);
         modal.transform.SetAsLastSibling();
     }
     modal.SetActive(true);
     ModalEvent(state, displayString);
 }
예제 #3
0
    public static CameraNotification BlockInput; // used to block user input on all areas of screen except for the modal when spawned

    private void Awake()
    {
        this.gameManager  = GameManager.GetInstance();
        this.monthBuilder = MonthBuilder.GetInstance();

        // spawn the modal but hide it. The modal base size is the size of the entire calendar
        this.modal      = Instantiate(this.modalPrefab, this.gameObject.transform, false);
        this.modalState = ModalUI.ModalState.NoState;
        this.modal.SetActive(false);

        ModalUI.NotifyCaller          += ModalCloseEvent;
        DayUI.NotifyCalendarSelectDay += DaySelected;
        MonthUI.NotifyCurrentDay      += SetCurrentDayTransform;
    }
예제 #4
0
    private void HandleModalEvent(ModalUI.ModalState modalState)
    {
        switch (modalState)
        {
        case ModalUI.ModalState.EndDay:
            SetAndLoadNewState(States.CalendarScene);
            break;

        case ModalUI.ModalState.DaySelect:
            SetAndLoadNewState(States.GameplayScene);
            break;

        case ModalUI.ModalState.GameOver:
            DeleteOldGame();
            SetAndLoadNewState(States.TitleScene);
            break;
        }
    }
예제 #5
0
 /**** Events ****/
 private void SetupStartGame(ModalUI.ModalState state)
 {
     // destroy modal
     HideModal();
     StartGame();
 }
예제 #6
0
 // called when a day is selected, update the modal state to allow display of modal
 // centered on the day
 private void DaySelected()
 {
     this.modalState = ModalUI.ModalState.DaySelect;
 }
예제 #7
0
 // notifies the calendar that the modal should be hidden
 private void ModalCloseEvent(ModalUI.ModalState currentModalState)
 {
     this.modalState = ModalUI.ModalState.HideModal;
 }
예제 #8
0
 // hides the modal to allow interaction with the calendar
 private void HideModal()
 {
     this.modalState = ModalUI.ModalState.NoState;
     this.modal.SetActive(false);
 }
예제 #9
0
 // spawn a modal that will allow an action based on the modal state
 private void SpawnModal(ModalUI.ModalState state, string displayString)
 {
     this.modal.transform.SetAsLastSibling();
     this.modal.SetActive(true);
     ModalNotification(state, displayString);
 }