Beispiel #1
0
    // Put anything in here that should happen as a result of the pet using the daily inhaler.
    private void GameDone()
    {
        InhalerGameUIManager.Instance.StopShowHintTimer();
        StatsManager.Instance.ChangeStats(healthDelta: 20, hungerDelta: 80, isInternal: true);
        DateTime now  = LgDateTime.GetTimeNow();
        DateTime then = DataManager.Instance.GameData.Inhaler.LastPlayPeriodUsed;
        TimeSpan lastTimeSinceInhaler = now - then;

        if (lastTimeSinceInhaler.TotalHours > 24)
        {
            DataManager.Instance.GameData.Inhaler.timesUsedInARow = 0;
        }
        DataManager.Instance.GameData.Inhaler.timesUsedInARow++;

        // Save settings into DataManager
        IsFirstTimeRescue = false;
        DataManager.Instance.GameData.Inhaler.LastPlayPeriodUsed  = PlayPeriodLogic.GetCurrentPlayPeriod();
        DataManager.Instance.GameData.Inhaler.LastInhalerPlayTime = LgDateTime.GetTimeNow();

        // Finish inhaler tutorial
        if (!IsTutorialCompleted)
        {
            DataManager.Instance.GameData.Tutorial.ListPlayed.Add(TutorialManagerBedroom.TUT_INHALER);
        }

        // Send out a task completion event for the wellapad
        WellapadMissionController.Instance.TaskCompleted("DailyInhaler");

        // Calculate the next play period for the inhaler
        PlayPeriodLogic.Instance.InhalerGameDonePostLogic();

        // Show ending UI
        InhalerGameUIManager.Instance.GameEndUI();
    }
Beispiel #2
0
    /// <summary>
    /// Depending on how long the player has been away and what time of day it is, return the number of
    /// new triggers that should spawn.
    /// <summary>
    private int GetNewTriggerCount()
    {
        int newTriggers = 0;
        MutableDataDegradation degradationData = DataManager.Instance.GameData.Degradation;
        int playPeriodsOffset = GetNumPlayPeriodsOffset();

        //There are missed play periods
        if (playPeriodsOffset > 1)
        {
            //max of 2 missed play period will be accounted
            if (playPeriodsOffset > 2)
            {
                playPeriodsOffset = 2;
            }

            //calculate num of new triggers
            newTriggers = playPeriodsOffset * 3;

            //update lastTriggerSpawnedPlayPeriod. Important that we update it here
            //otherwise more triggers will be spawned if user return from pause
            degradationData.LastPlayPeriodTriggerSpawned = PlayPeriodLogic.GetCurrentPlayPeriod();
            Debug.Log("Missed play periods spawning " + newTriggers + "triggers");
        }
        //No missed play periods. spawn triggers for Next Play Period
        else
        {
            DateTime now = LgDateTime.GetTimeNow();
            DateTime lastTriggerSpawnedPlayPeriod = degradationData.LastPlayPeriodTriggerSpawned;
            TimeSpan timeSinceLastTriggerSpawned  = now - lastTriggerSpawnedPlayPeriod;

            //only spawn new trigger if time hasn't been rewind somehow
            if (lastTriggerSpawnedPlayPeriod <= now)
            {
                //new play period need to refresh variable
                if (timeSinceLastTriggerSpawned.TotalHours >= 12)
                {
                    degradationData.IsTriggerSpawned = false;
                }

                if (!degradationData.IsTriggerSpawned)
                {
                    newTriggers = 3;
                    degradationData.IsTriggerSpawned             = true;
                    degradationData.LastPlayPeriodTriggerSpawned = PlayPeriodLogic.GetCurrentPlayPeriod();
                }
            }
        }
        return(newTriggers);
    }
 void OnGUI()
 {
     GUI.Label(new Rect(50, 50, 200, 50), "Current PP: " + PlayPeriodLogic.GetCurrentPlayPeriod().ToString(), style);
     GUI.Label(new Rect(80, 100, 200, 50), "Last PP: " + PlayPeriodLogic.Instance.GetLastPlayPeriod().ToString(), style);
 }
 private void Init()
 {
     LastPlayPeriodTriggerSpawned = PlayPeriodLogic.GetCurrentPlayPeriod();
     IsTriggerSpawned             = false;
     UncleanedTriggers            = 0;
 }
Beispiel #5
0
    /// <summary>
    /// Determines whether new minipet locations should be spawned, also flags the datetime automatically
    /// Only call once per a play period all furture calls will be false
    /// </summary>
    public bool CanSpawnNewMinipetLocations()
    {
//		Debug.Log("---Checking can spawn minipets " + DataManager.Instance.GameData.MiniPetLocations.LastestPlayPeriodUpdated + " " + PlayPeriodLogic.GetCurrentPlayPeriod());
        if (DataManager.Instance.GameData.MiniPetLocations.LastestPlayPeriodUpdated < PlayPeriodLogic.GetCurrentPlayPeriod())
        {
            DataManager.Instance.GameData.MiniPetLocations.LastestPlayPeriodUpdated = PlayPeriodLogic.GetCurrentPlayPeriod();
//			Debug.Log("----SPAWN NEW LOCATIONS?: YES");
            if (UnityEngine.Random.Range(0, 4) == 0)
            {
                merchantSpawnChance = true;
                DataManager.Instance.GameData.MiniPetLocations.SetMerchantSpawning(merchantSpawnChance);
            }
            else
            {
                merchantSpawnChance = false;
                DataManager.Instance.GameData.MiniPetLocations.SetMerchantSpawning(merchantSpawnChance);
            }
            return(true);
        }
        else
        {
//			Debug.Log("----SPAWN NEW LOCATIONS?: NO");
            return(false);
        }
    }