Pause() public method

public Pause ( ) : void
return void
Example #1
0
 private void Awake()
 {
     if (GameTime.IsPaused())
     {
         GameTime.Pause(false);
     }
 }
Example #2
0
    private IEnumerator LoadLevelAsync(string levelName, GameManager.GameState nextState, bool enableGUIAfterLoad = true)
    {
        Singleton <GuiManager> .Instance.IsEnabled = false;
        yield return(null);

        if (!levelName.Equals("DailyChallenge") && !levelName.Equals("CakeRaceIntro") && (levelName.Equals("LevelStub") || nextState == GameManager.GameState.Cutscene || nextState == GameManager.GameState.StarLevelCutscene))
        {
            LevelLoader levelLoader = Singleton <GameManager> .instance.CurrentLevelLoader();

            string bundleId = (!(levelLoader != null)) ? string.Empty : levelLoader.AssetBundleName;
            if (!string.IsNullOrEmpty(bundleId) && Bundle.HasBundle(bundleId))
            {
                Bundle.LoadBundleAsync(bundleId, null);
                while (!Bundle.IsBundleLoaded(bundleId))
                {
                    yield return(null);
                }
            }
        }
        CoroutineRunner.Instance.StartCoroutine(this.DelayLoadLevelEvent(Singleton <GameManager> .Instance.GetGameState(), nextState, levelName));
        Singleton <GameManager> .Instance.SetLoadingLevelGameState(nextState);

        AsyncOperation async = SceneManager.LoadSceneAsync(levelName);

        yield return(async);

        if (Singleton <GameManager> .Instance.GetGameState() == GameManager.GameState.LevelSelection || Singleton <GameManager> .Instance.GetGameState() == GameManager.GameState.SandboxLevelSelection || Singleton <GameManager> .Instance.GetGameState() == GameManager.GameState.EpisodeSelection)
        {
            GameTime.Pause(false);
        }
        Singleton <GuiManager> .Instance.IsEnabled = enableGUIAfterLoad;
        Loader.isLoadingLevel = false;
        yield break;
    }
Example #3
0
 private void OnDestroy()
 {
     if (GameTime.IsPaused())
     {
         GameTime.Pause(false);
     }
     this.SendKingPigFeedingExitFlurryEvent();
 }
Example #4
0
 public void UnlockUI()
 {
     GameTime.Pause(false);
     Singleton <GuiManager> .Instance.enabled = true;
     this.isWatchingAd = false;
     if (this.unlockGo != null)
     {
         this.unlockGo.SetActive(false);
     }
 }
Example #5
0
    protected override bool HandleUIEvent(UIEvent data)
    {
        UIEvent.Type type = data.type;
        if (type == UIEvent.Type.ReplayLevel)
        {
            base.StopRunningContraption();
            this.levelManager.SetGameState(LevelManager.GameState.Building);
            return(true);
        }
        if (type != UIEvent.Type.NextLevel && type != UIEvent.Type.LevelSelection)
        {
            return(false);
        }
        if (this.levelManager.gameState != LevelManager.GameState.PausedWhileRunning)
        {
            if (this.levelManager.gameState == LevelManager.GameState.PausedWhileBuilding)
            {
                if (this.levelManager.ContraptionProto.HasSuperGlue)
                {
                    GameProgress.AddSuperGlue(1);
                }
                if (this.levelManager.ContraptionProto.HasSuperMagnet)
                {
                    GameProgress.AddSuperMagnet(1);
                }
                if (this.levelManager.ContraptionProto.HasTurboCharge)
                {
                    GameProgress.AddTurboCharge(1);
                }
                if (this.levelManager.ContraptionProto.HasNightVision)
                {
                    GameProgress.AddNightVision(1);
                }
            }
            else if (this.levelManager.gameState == LevelManager.GameState.Completed)
            {
            }
        }
        if (GameTime.IsPaused())
        {
            GameTime.Pause(false);
        }
        if (data.type == UIEvent.Type.NextLevel)
        {
            CakeRaceMenu.FindNewPlayer = true;
        }
        this.levelManager.SetGameState(LevelManager.GameState.Undefined);
        Singleton <GameManager> .Instance.LoadCakeRaceMenu(true);

        return(true);
    }
Example #6
0
    private IEnumerator BulletTime(bool pause)
    {
        float fade     = 0f;
        float fromTime = (!pause) ? 0f : 1f;
        float toTime   = (!pause) ? 1f : 0f;

        while (fade < 1f)
        {
            Time.timeScale = Mathf.Lerp(fromTime, toTime, fade);
            fade          += GameTime.RealTimeDelta * this.bulletTimeSpeed;
            yield return(null);
        }
        GameTime.Pause(pause);
        yield break;
    }
Example #7
0
    private void Awake()
    {
        if (GameTime.IsPaused())
        {
            GameTime.Pause(false);
        }
        this.m_page = UserSettings.GetInt(Singleton <GameManager> .Instance.CurrentSceneName + "_active_page", 0);
        if (GameProgress.GetBool("show_content_limit_popup", false, GameProgress.Location.Local, null))
        {
            GameProgress.DeleteKey("show_content_limit_popup", GameProgress.Location.Local);
            if (Singleton <BuildCustomizationLoader> .Instance.IsContentLimited)
            {
                if (this.m_page == 0)
                {
                    EventManager.SendOnNextUpdate(this, new PulseButtonEvent(UIEvent.Type.OpenUnlockFullVersionIapMenu, false));
                    LevelInfo.DisplayContentLimitNotification();
                }
            }
            else
            {
                LevelInfo.DisplayContentLimitNotification();
            }
        }
        this.Levels                = WPFMonoBehaviour.gameData.m_episodeLevels[this.EpisodeIndex].m_levelInfos;
        this.StarLevelLimits       = WPFMonoBehaviour.gameData.m_episodeLevels[this.EpisodeIndex].StarLevelLimits;
        this.m_pageCount           = Mathf.RoundToInt((float)(this.m_levels.Count / this.m_levelsPerPage));
        this.m_buttonGrid          = base.transform.Find("ButtonGrid").GetComponent <ButtonGrid>();
        this.m_currentScreenWidth  = Screen.width;
        this.m_currentScreenHeight = Screen.height;
        this.m_page                = Mathf.Min(this.m_page, this.m_pageCount);
        Singleton <GameManager> .Instance.OpenEpisode(this);

        this.CreateButtons();
        this.CreatePageDots();
        this.LayoutButtons(this.m_page);
        if (DeviceInfo.UsesTouchInput)
        {
            this.m_leftScroll.SetActive(false);
            this.m_rightScroll.SetActive(false);
        }
        if (GameProgress.TotalDessertCount() > 0)
        {
            EventManager.Send(new PulseButtonEvent(UIEvent.Type.None, true));
        }
    }
Example #8
0
 public void ExternalPause(string msg)
 {
     if (msg == "true")
     {
         if (!GameTime.m_isExternalPaused)
         {
             GameTime.m_prevPaused = GameTime.m_paused;
         }
         GameTime.m_isExternalPaused = true;
         GameTime.Pause(true);
     }
     else if (msg == "false")
     {
         GameTime.m_isExternalPaused = false;
         if (!GameTime.m_prevPaused)
         {
             GameTime.Pause(false);
         }
     }
 }
Example #9
0
 private void ReceiveGameStateChange(GameStateChanged uiEvent)
 {
     LevelManager.GameState state = uiEvent.state;
     if (state == LevelManager.GameState.Building)
     {
         this.hideThisSession            = false;
         RewardVideoManager.TimeToReward = 2;
         if (RewardVideoManager.AddTimeRewardOnLevelStart)
         {
             RewardVideoManager.AddTimeRewardOnLevelStart        = false;
             RewardVideoManager.HadRewardAlready                 = true;
             RewardVideoManager.AddTimeRewardCounterOnLevelStart = true;
             if (GameTime.IsPaused())
             {
                 GameTime.Pause(false);
             }
             this.AddTime();
         }
         else if (!base.gameObject.activeInHierarchy && this.IsAllowedToShow())
         {
             this.ShowButton();
         }
     }
 }
Example #10
0
    public override LevelManager.GameState SetGameState(LevelManager.GameState currentState, LevelManager.GameState newState)
    {
        LevelManager.GameState gameState = currentState;
        switch (newState)
        {
        case LevelManager.GameState.Building:
            if (GameTime.IsPaused())
            {
                GameTime.Pause(false);
            }
            if (currentState == LevelManager.GameState.Running || currentState == LevelManager.GameState.PausedWhileRunning)
            {
                base.StopRunningContraption();
                this.retries++;
                if (this.retries == 3 && !this.levelManager.m_sandbox && !this.tutorialBookOpened)
                {
                    int num = GameProgress.GetInt("Tutorial_Promotion_Count", 0, GameProgress.Location.Local, null);
                    if (num < 3 && !GameProgress.IsLevelCompleted(Singleton <GameManager> .Instance.CurrentSceneName) && GameProgress.GetInt(this.TutorialPromotionCount, 0, GameProgress.Location.Local, null) == 0)
                    {
                        this.openTutorial = true;
                        num++;
                        GameProgress.SetInt("Tutorial_Promotion_Count", num, GameProgress.Location.Local);
                        GameProgress.SetInt(this.TutorialPromotionCount, 1, GameProgress.Location.Local);
                    }
                }
                bool @bool = GameProgress.GetBool(Singleton <GameManager> .Instance.CurrentSceneName + "_autobuild_available", false, GameProgress.Location.Local, null);
                bool bool2 = GameProgress.GetBool("PermanentBlueprint", false, GameProgress.Location.Local, null);
                if (!this.levelManager.m_sandbox && this.retries % 5 == 0 && AdvertisementHandler.GetRewardNativeTexture() != null)
                {
                    int @int = GameProgress.GetInt("branded_reward_gifts_today", 0, GameProgress.Location.Local, null);
                    int num2 = 2;
                    if (Singleton <GameConfigurationManager> .IsInstantiated() && Singleton <GameConfigurationManager> .Instance.HasValue("branded_reward_gift_count", "count"))
                    {
                        num2 = Singleton <GameConfigurationManager> .Instance.GetValue <int>("branded_reward_gift_count", "count");
                    }
                    if (@int < num2)
                    {
                        if (!GameProgress.HasKey("branded_reward_gift_time", GameProgress.Location.Local, null))
                        {
                            GameProgress.SetInt("branded_reward_gift_time", Singleton <TimeManager> .Instance.CurrentEpochTime, GameProgress.Location.Local);
                        }
                        GameProgress.SetInt("branded_reward_gifts_today", @int + 1, GameProgress.Location.Local);
                        this.openMechanicGift = true;
                    }
                }
            }
            if (this.levelManager.m_toolboxOpenUponShopActivation)
            {
                this.levelManager.InGameGUI.BuildMenu.ToolboxButton.OnPressed();
            }
            this.levelManager.SetupDynamicObjects();
            base.ContraptionProto.SetVisible(true);
            if (this.levelManager.ConstructionUI)
            {
                this.levelManager.ConstructionUI.SetEnabled(true, true);
            }
            if (GameProgress.GetString("REPLAY_LEVEL", string.Empty, GameProgress.Location.Local, null) == SceneManager.GetActiveScene().name&& LightManager.enabledLightPositions != null && LightManager.enabledLightPositions.Count > 0)
            {
                PointLightSource[] array = UnityEngine.Object.FindObjectsOfType <PointLightSource>();
                for (int i = 0; i < array.Length; i++)
                {
                    if (LightManager.enabledLightPositions.Contains(array[i].transform.position))
                    {
                        array[i].isEnabled = true;
                    }
                }
                GameProgress.SetString("REPLAY_LEVEL", string.Empty, GameProgress.Location.Local);
            }
            break;

        case LevelManager.GameState.Preview:
            this.levelManager.m_previewSpeed = 1f;
            this.levelManager.m_previewTime  = 0f;
            base.ContraptionProto.SetVisible(false);
            if (this.levelManager.ConstructionUI)
            {
                this.levelManager.ConstructionUI.SetEnabled(false, true);
            }
            break;

        case LevelManager.GameState.PreviewMoving:
            this.levelManager.m_previewTime = 0f;
            base.ContraptionProto.SetVisible(false);
            if (this.levelManager.ConstructionUI)
            {
                this.levelManager.ConstructionUI.SetEnabled(false, true);
            }
            this.levelManager.SetupDynamicObjects();
            break;

        case LevelManager.GameState.PreviewWhileBuilding:
            if (this.levelManager.EggRequired)
            {
                this.levelManager.InGameGUI.PreviewMenu.SetGoal(base.gameData.m_eggTransportGoal);
            }
            else if (this.levelManager.PumpkinRequired)
            {
                this.levelManager.InGameGUI.PreviewMenu.SetGoal(base.gameData.m_pumpkinTransportGoal);
            }
            else
            {
                this.levelManager.InGameGUI.PreviewMenu.SetGoal(base.gameData.m_basicGoal);
            }
            this.levelManager.InGameGUI.PreviewMenu.SetChallenges(this.levelManager.Challenges);
            if (this.levelManager.ConstructionUI)
            {
                this.levelManager.ConstructionUI.SetEnabled(false, true);
            }
            this.levelManager.PreviewCenter     = base.ContraptionProto.transform.position;
            this.levelManager.m_previewDragging = false;
            break;

        case LevelManager.GameState.PreviewWhileRunning:
            this.levelManager.PreviewCenter = base.ContraptionRunning.transform.position;
            GameTime.Pause(true);
            this.levelManager.m_previewDragging = false;
            break;

        case LevelManager.GameState.Running:
            if (GameTime.IsPaused())
            {
                GameTime.Pause(false);
            }
            this.levelManager.TimeElapsed = 0f;
            this.levelManager.PartsInGoal.Clear();
            this.levelManager.TimeStarted      = false;
            this.levelManager.PigStartPosition = base.ContraptionProto.FindPig().transform.position;
            if (this.levelManager.ConstructionUI)
            {
                this.levelManager.ConstructionUI.SetEnabled(false, false);
            }
            base.ContraptionRunning = base.ContraptionProto.Clone();
            base.ContraptionProto.SetVisible(false);
            if (base.ContraptionProto.HasRegularGlue)
            {
                if (!base.ContraptionProto.HasGluedParts)
                {
                    GameProgress.AddSuperGlue(1);
                }
                base.ContraptionProto.RemoveSuperGlue();
            }
            if (base.ContraptionProto.HasSuperMagnet)
            {
                base.ContraptionProto.HasSuperMagnet = false;
            }
            if (base.ContraptionProto.HasNightVision)
            {
                this.levelManager.LightManager.ToggleNightVision();
                base.ContraptionProto.HasNightVision = false;
            }
            base.ContraptionRunning.StartContraption();
            if (base.ContraptionProto.HasTurboCharge)
            {
                base.ContraptionProto.HasTurboCharge = false;
            }
            base.ContraptionRunning.SaveContraption(base.GetCurrentContraptionName());
            break;

        case LevelManager.GameState.Continue:
            if (GameTime.IsPaused())
            {
                GameTime.Pause(false);
            }
            if (gameState == LevelManager.GameState.Building || gameState == LevelManager.GameState.PausedWhileBuilding)
            {
                newState = LevelManager.GameState.Building;
            }
            else if (gameState == LevelManager.GameState.CustomizingPart)
            {
                newState = LevelManager.GameState.CustomizingPart;
            }
            else if (!this.levelManager.HasCompleted && gameState == LevelManager.GameState.LootCrateOpening)
            {
                newState = LevelManager.GameState.Running;
            }
            else
            {
                newState = ((!this.levelManager.HasCompleted) ? LevelManager.GameState.Running : LevelManager.GameState.Completed);
            }
            break;

        case LevelManager.GameState.Completed:
            this.levelManager.InGameGUI.ShowCurrentMenu(false);
            base.ContraptionRunning.TurnOffAllPoweredParts();
            this.levelManager.PlayVictorySound();
            if (this.levelManager.EggRequired)
            {
                this.levelManager.InGameGUI.LevelCompleteMenu.SetGoal(base.gameData.m_eggTransportGoal);
            }
            else if (this.levelManager.PumpkinRequired)
            {
                this.levelManager.InGameGUI.LevelCompleteMenu.SetGoal(base.gameData.m_pumpkinTransportGoal);
            }
            else
            {
                this.levelManager.InGameGUI.LevelCompleteMenu.SetGoal(base.gameData.m_basicGoal);
            }
            this.levelManager.InGameGUI.LevelCompleteMenu.SetChallenges(this.levelManager.Challenges);
            break;

        case LevelManager.GameState.PausedWhileRunning:
            GameTime.Pause(true);
            break;

        case LevelManager.GameState.PausedWhileBuilding:
            GameTime.Pause(true);
            break;

        case LevelManager.GameState.AutoBuilding:
            this.levelManager.StartAutoBuild(this.levelManager.m_oneStarContraption);
            break;

        case LevelManager.GameState.ShowingUnlockedParts:
            GameTime.Pause(false);
            this.levelManager.UnlockedParts     = new List <ConstructionUI.PartDesc>(this.levelManager.ConstructionUI.UnlockedParts);
            this.levelManager.UnlockedPartIndex = -1;
            this.levelManager.PartShowTimer     = 0f;
            break;

        case LevelManager.GameState.Snapshot:
            GameTime.Pause(true);
            this.levelManager.InGameGUI.ShowCurrentMenu(false);
            WPFMonoBehaviour.ingameCamera.TakeSnapshot(new Action(this.levelManager.HandleSnapshotFinished));
            break;

        case LevelManager.GameState.SuperAutoBuilding:
            this.levelManager.StartAutoBuild(this.levelManager.m_threeStarContraption[this.levelManager.CurrentSuperBluePrint]);
            if (Singleton <SocialGameManager> .IsInstantiated())
            {
                Singleton <SocialGameManager> .Instance.ReportAchievementProgress("grp.CHIPS_FOR_WHIPS", 100.0);
            }
            break;
        }
        currentState = newState;
        return(currentState);
    }
Example #11
0
 public void LoadRaceLevelSelection()
 {
     GameTime.Pause(false);
     Singleton <Loader> .Instance.LoadLevel("RaceLevelSelection", GameManager.GameState.RaceLevelSelection, true, true);
 }
Example #12
0
 public void LoadSandboxLevelSelection()
 {
     GameTime.Pause(false);
     UserSettings.SetBool(CompactEpisodeSelector.IsEpisodeToggledKey, true);
     Singleton <Loader> .Instance.LoadLevel("EpisodeSelection", GameManager.GameState.EpisodeSelection, true, true);
 }