Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        if(!PlayerPrefs.HasKey("Terror Nights Slept"))
        {
            PlayerPrefs.SetInt("Terror Nights Slept", 0);
        }

        _nightTerrorNightsSlept = PlayerPrefs.GetInt("Terror Nights Slept");

        _am = transform.GetComponent<ActionsManager>();
        _character = GameObject.Find("Character").GetComponent<Character>();

        FirstPlay = CheckFirstPlay();
        if(FirstPlay)
        {
            Debug.Log("Setting hint wait time to 2.");
            _am.SetHintWaitTime(2);
        }

        if(PlayerPrefs.GetInt("Games Played") == 3)
        {
            NightTerrorState = true;
        }

        // During a night terror.
        if (NightTerrorState)
        {
            Debug.Log("Terror Night Event Active!");
            // Saves current emotional state temporarily.
            if (_savedState == false)
            {
                _tempEmotionalStateValue = _character.GetEmotionalStateValue();
                _savedState = true;
            }

            switch (_nightTerrorNightsSlept)
            {
                // First Night
                // Set hint time to 5 and character state to terror if it's the first night terror event night.
                case 0:
                    Debug.Log("First night of terror!");
                    if (_am.HintWaitTime != 5)
                    {
                        _am.SetHintWaitTime(5);
                    }
                    _character.SetEmotionalStateValue(10);
                    break;
                // Second Night
                case 1:
                    Debug.Log("Second night of terror!");
                    if (_am.HintWaitTime != 5)
                    {
                        _am.SetHintWaitTime(5);
                    }
                    break;
                // Third Night
                case 2:
                    Debug.Log("Third night of terror!");
                    if (_am.HintWaitTime != 5)
                    {
                        _am.SetHintWaitTime(5);
                    }
                    break;
                // End the night terror event here.
                case 3:
                    Debug.Log("Ending night of terror!");
                    if (_am.HintWaitTime != 5)
                    {
                        _am.SetHintWaitTime(5);
                    }
                    SetNightTerrorState(false);
                    ResetNightTerrorSlept();
                    _character.SetEmotionalStateValue(120f);
                    break;
                default:
                    if (_am.HintWaitTime != 5)
                    {
                        Debug.Log("DEFAULT CASE:");
                        Debug.Log("Nights slept: " + _nightTerrorNightsSlept + ". Setting Hint timer to: 5.");
                        _am.SetHintWaitTime(5);
                    }
                    _character.SetEmotionalStateValue(_tempEmotionalStateValue);
                    NightTerrorState = false;
                    break;
             }
        } else
        {
            if(!FirstPlay)
            {
                _am.SetHintWaitTime(5);
            }
            SetNightTerrorSlept(0);
            CheckForRandomNightTerrorEvent();
        }
    }