Esempio n. 1
0
    void Awake()
    {
        startingPosition = transform.position;

        daysRemaining = GameObject.Find("RemainingDays").GetComponent <DayCounterScript>();
        eventSystem   = GameObject.Find("EventSystem");
        mplayer       = GameObject.Find("PersistentDataObject").GetComponent <MusicPlayer>();
        clock         = GameObject.Find("Clock").GetComponent <ClockManager>();
        pointer       = GetComponent <SliderController>();
        animator      = GetComponent <Animator>();
        gameManager   = FindObjectOfType <GameManager>();
        dialogController.gameObject.SetActive(true);
        playerOrientation = PlayerOrientation.Down;
        screenFader       = GameObject.Find("Fader").GetComponent <ScreenFader>();

        isForceSleeping = (PlayerPrefs.GetInt(Constants.Prefs.FORCE_SLEEPING, Constants.Prefs.Defaults.FORCE_SLEEPING) == 1);

        bool hasSavedGame = (PlayerPrefs.GetFloat(Constants.Prefs.GAME_TIME, Constants.Prefs.Defaults.GAME_TIME) > 0);

        if (hasSavedGame)
        {
            LoadPlayerData();
        }

        bool hasChangedFloor = PlayerPrefs.GetInt(Constants.Prefs.CHANGING_FLOOR, Constants.Prefs.Defaults.CHANGING_FLOOR) == 1;

        if (isForceSleeping)
        {
            gameManager.Reset();
            daysRemaining.ShowRemainingDays();
            StartCoroutine(DisplayDailyMessage());
            isForceSleeping = false;
            PlayerPrefs.SetInt(Constants.Prefs.FORCE_SLEEPING, Constants.Prefs.Defaults.FORCE_SLEEPING);
            SavePlayerData();
        }
        else if (hasChangedFloor)
        {
            mplayer.StopLoopedFootsteps();
            transform.position = new Vector3(-0.86f, 3.88f, 0f);
            playerOrientation  = PlayerOrientation.Right;

            PlayerPrefs.SetInt(Constants.Prefs.CHANGING_FLOOR, Constants.Prefs.Defaults.CHANGING_FLOOR);

            SavePlayerData();
        }

        UpdatePlayerAnimation(playerOrientation, false);
    }
Esempio n. 2
0
    IEnumerator Interact()
    {
        Action action = dialogController.currentAction;

        if (action != null && action.active && action.interactable)
        {
            interacting = true;
            mplayer.PlayInteraction();

            walking = false;
            animator.SetBool("walking", walking);

            if (action.tag == Constants.Actions.SUBMIT_THESIS)
            {
                yield return(GameObject.FindObjectOfType <GameManager>().EndGame(true));
            }
            else if (action.tag == Constants.Actions.READ_LETTER)
            {
                interacting   = false;
                action.active = false;

                Action letterAction = gameManager.GetActionWithTag(Constants.Actions.OPENED_LETTER);
                letterAction.text   = Constants.Strings.LETTER_MESSAGE;
                letterAction.active = true;
                interactiveObject   = null;

                dialogController.background.rectTransform.sizeDelta += new Vector2(200, 200);
                dialogController.dialogText.rectTransform.sizeDelta += new Vector2(200, 200);
            }
            else
            {
                if (gameManager.CanExecuteAction(action))
                {
                    if (action.tag == Constants.Actions.SLEEP_NIGHT)
                    {
                        yield return(screenFader.FadeToColor(Constants.Colors.FADE, 0.25f));

                        interactiveObject = null;
                        dialogController.Hide();

                        transform.position = startingPosition;
                        playerOrientation  = PlayerOrientation.Down;

                        UpdatePlayerAnimation(playerOrientation, false);
                        UpdateSpriteZOrder();
                        UpdateStats(action);

                        daysRemaining.ShowRemainingDays();
                        StartCoroutine(DisplayDailyMessage());
                    }
                    else
                    {
                        yield return(screenFader.FadeToColor(Constants.Colors.FADE, 0.25f));

                        UpdateStats(action);
                        yield return(screenFader.FadeToColor(Color.clear, 0.25f));
                    }
                }
                else
                {
                    interacting = false;
                    dialogController.currentAction = null;

                    lastActionInteractable = action.interactable;
                    lastActionText         = action.text;
                    action.interactable    = false;
                    action.text            = Constants.Strings.WAIT_MESSAGE;
                }
            }
        }

        interacting = false;

        yield return(null);
    }
    void Awake()
    {
        startingPosition = transform.position;

        daysRemaining = GameObject.Find("RemainingDays").GetComponent<DayCounterScript>();
        eventSystem = GameObject.Find("EventSystem");
        mplayer = GameObject.Find("PersistentDataObject").GetComponent<MusicPlayer>();
        clock = GameObject.Find("Clock").GetComponent<ClockManager>();
        pointer = GetComponent<SliderController>();
        animator = GetComponent<Animator>();
        gameManager = FindObjectOfType<GameManager>();
        dialogController.gameObject.SetActive(true);
        playerOrientation = PlayerOrientation.Down;
        screenFader = GameObject.Find("Fader").GetComponent<ScreenFader>();

        isForceSleeping = (PlayerPrefs.GetInt(Constants.Prefs.FORCE_SLEEPING, Constants.Prefs.Defaults.FORCE_SLEEPING) == 1);

        bool hasSavedGame = (PlayerPrefs.GetFloat(Constants.Prefs.GAME_TIME, Constants.Prefs.Defaults.GAME_TIME) > 0);
        if(hasSavedGame)
        {
            LoadPlayerData();
        }

        bool hasChangedFloor = PlayerPrefs.GetInt(Constants.Prefs.CHANGING_FLOOR, Constants.Prefs.Defaults.CHANGING_FLOOR) == 1;
        if(isForceSleeping)
        {
            gameManager.Reset();
            daysRemaining.ShowRemainingDays();
            StartCoroutine(DisplayDailyMessage());
            isForceSleeping = false;
            PlayerPrefs.SetInt(Constants.Prefs.FORCE_SLEEPING, Constants.Prefs.Defaults.FORCE_SLEEPING);
            SavePlayerData();
        }
        else if (hasChangedFloor)
        {
            mplayer.StopLoopedFootsteps();
            transform.position = new Vector3(-0.86f, 3.88f, 0f);
            playerOrientation = PlayerOrientation.Right;

            PlayerPrefs.SetInt(Constants.Prefs.CHANGING_FLOOR, Constants.Prefs.Defaults.CHANGING_FLOOR);

            SavePlayerData();
        }

        UpdatePlayerAnimation(playerOrientation, false);
    }