Пример #1
0
    void Awake()
    {
        // Initialization
        timerCounter = GameManager.instance.timerCounter;
        button       = GetComponent <Button>();

        // Get references from GameManager
        timerCounter = GameManager.instance.timerCounter;
        saveGame     = GameManager.instance.saveGame;
        // Get data from saveGame
        currentNumRewards = saveGame.numDailyHeroRewards;

        // If the timer has not been initialized yet (app is opened for the first time)
        // Since timerCounter is a singleton instance under GameManager, when this scene is reloaded later
        // after the app has been opened, the timer will already be initialized and therefore InitTimer() will
        // not be run.
        if (timerCounter.GetTimer(TIMER_KEY) == null)
        {
            InitTimer();
        }
        else
        {
            timerView.timer = timerCounter.GetTimer(TIMER_KEY);
        }
        // Timer has counted down past 0 since last login
        UpdateRewards();
    }
Пример #2
0
 private void SavePawnTimers()
 {
     foreach (Pawn pawn in saveGame.pawnWallet.pawns)
     {
         if (pawn != null && pawn.unlockTime > 0)
         {
             RealtimeTimer timer = timerCounter.GetTimer(pawn.GetTimerID());
             pawn.unlockTime = timer.time;
         }
     }
     foreach (Pawn pawn in saveGame.pawnWallet.extraPawns)
     {
         if (pawn != null && pawn.unlockTime > 0)
         {
             RealtimeTimer timer = timerCounter.GetTimer(pawn.GetTimerID());
             pawn.unlockTime = timer.time;
         }
     }
     SaveLoad.Save();
 }
Пример #3
0
 private IEnumerator ClaimRewardsRoutine()
 {
     if (currentNumRewards > 0)
     {
         heroesRescuedMenu.Reset();
         // Play a dialogue and wait for it to finish
         dialogueView.Init(dialogueSuccess);
         while (dialogueView.dialoguePlaying)
         {
             yield return(null);
         }
         // Get rewards
         List <Pawn> rewards = new List <Pawn>();
         for (int i = 0; i < currentNumRewards; i++)
         {
             Pawn p = PawnGenerator.GenerateCrystalDrop(1);
             saveGame.pawnWallet.AddPawn(p);
             rewards.Add(p);
         }
         // View the rewards in the heroesRescuedMenu
         heroesRescuedMenu.gameObject.SetActive(true);
         heroesRescuedMenu.Init(rewards);
         // Reset the timer and the number of rewards
         if (timerCounter.GetTimer(TIMER_KEY).time <= 0)
         {
             timeUntilNextReward = REWARD_INTERVAL;
             ResetTimer();
         }
         currentNumRewards = 0;
     }
     else
     {
         dialogueView.Init(dialogueFailure);
     }
     yield return(null);
 }