Esempio n. 1
0
    private void AddUnlockPopup(Button button, string levelName, string collectable, int collected, int required, int cost, Func <bool> requirements)
    {
        GameData gameData = Singleton <GameManager> .Instance.gameData;

        if (gameData.m_specialSandboxUnlockDialog != null && gameData.m_genericButtonPrefab != null)
        {
            GameObject gameObject             = UnityEngine.Object.Instantiate <GameObject>(gameData.m_specialSandboxUnlockDialog);
            SpecialSandboxUnlockDialog dialog = gameObject.GetComponent <SpecialSandboxUnlockDialog>();
            gameObject.transform.position = new Vector3(0f, 0f, -10f);
            button.MethodToCall.SetMethod(dialog, "Open");
            dialog.Type               = ((!collectable.Equals("Skulls")) ? SpecialSandboxUnlockDialog.UnlockType.Statue : SpecialSandboxUnlockDialog.UnlockType.Skull);
            dialog.Collected          = collected;
            dialog.Required           = required;
            dialog.Cost               = cost;
            dialog.ShowConfirmEnabled = (() => true);
            dialog.RebuildTexts();
            dialog.Close();
            CompactEpisodeTarget target = base.GetComponent <CompactEpisodeTarget>();
            dialog.SetOnConfirm(delegate
            {
                if (!GameProgress.GetSandboxUnlocked(levelName) && requirements() && GameProgress.UseSnoutCoins(cost))
                {
                    GameProgress.SetSandboxUnlocked(levelName, true);
                    GameProgress.SetButtonUnlockState("SandboxLevelButton_" + levelName, GameProgress.ButtonUnlockState.Locked);
                    target.SetAsLastTarget();
                    Singleton <GameManager> .Instance.ReloadCurrentLevel(true);
                    EventManager.Connect(new EventManager.OnEvent <LevelLoadedEvent>(this.DelayedPurchaseSound));
                    dialog.Close();
                }
                else if (!requirements() && Singleton <IapManager> .IsInstantiated())
                {
                    dialog.Close();
                    Singleton <IapManager> .Instance.OpenShopPage(new Action(dialog.Open), "SnoutCoinShop");
                }
                else
                {
                    dialog.Close();
                }
            });
        }
        if (this.collectSet != null)
        {
            string     text = string.Format("[snout] {0}", cost);
            TextMesh[] componentsInChildren = this.collectSet.GetComponentsInChildren <TextMesh>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                componentsInChildren[i].text = text;
                TextMeshSpriteIcons.EnsureSpriteIcon(componentsInChildren[i]);
            }
        }
    }
Esempio n. 2
0
    private void Awake()
    {
        this.m_leftLimit  = 0f;
        this.m_rightLimit = 0f;
        CompactEpisodeSelector.instance = this;
        Singleton <GameManager> .Instance.CreateMenuBackground();

        this.m_hudCamera   = GameObject.FindGameObjectWithTag("HUDCamera").GetComponent <Camera>();
        this.m_scrollPivot = base.transform.Find("ScrollPivot").gameObject;
        this.SetCenterEpisode(null);
        for (int i = 0; i < this.m_episodes.Count; i++)
        {
            this.m_episodes[i] = UnityEngine.Object.Instantiate <GameObject>(this.m_episodes[i]);
            this.m_episodes[i].transform.parent = this.m_scrollPivot.transform;
            CompactEpisodeTarget component = this.m_episodes[i].GetComponent <CompactEpisodeTarget>();
            if (component != null)
            {
                component.episodeSelector = this;
            }
        }
        for (int j = 0; j < this.m_episodesToggled.Count; j++)
        {
            this.m_episodesToggled[j] = UnityEngine.Object.Instantiate <GameObject>(this.m_episodesToggled[j]);
            this.m_episodesToggled[j].transform.parent = this.m_scrollPivot.transform;
            this.m_episodesToggled[j].SetActive(false);
            CompactEpisodeTarget component2 = this.m_episodesToggled[j].GetComponent <CompactEpisodeTarget>();
            if (component2 != null)
            {
                component2.episodeSelector = this;
            }
        }
        if (this.m_preButtons != null && this.m_preButtons.Count > 0)
        {
            for (int k = 0; k < this.m_preButtons.Count; k++)
            {
                this.m_preButtons[k] = UnityEngine.Object.Instantiate <GameObject>(this.m_preButtons[k]);
                this.m_preButtons[k].transform.parent = this.m_scrollPivot.transform;
                CompactEpisodeTarget component3 = this.m_preButtons[k].GetComponent <CompactEpisodeTarget>();
                if (component3 != null)
                {
                    component3.episodeSelector = this;
                }
            }
        }
        this.m_screenWidth  = Screen.width;
        this.m_screenHeight = Screen.height;
        this.isInitialized  = true;
        this.Layout();
    }
Esempio n. 3
0
    private void Update()
    {
        if (this.m_screenWidth != Screen.width || this.m_screenHeight != Screen.height)
        {
            this.m_screenWidth  = Screen.width;
            this.m_screenHeight = Screen.height;
            this.Layout();
        }
        GuiManager.Pointer pointer = GuiManager.GetPointer();
        if (pointer.down)
        {
            this.m_initialInputPos = pointer.position;
            this.m_lastInputPos    = pointer.position;
            this.m_interacting     = true;
            RaycastHit raycastHit;
            if (Physics.Raycast(this.m_hudCamera.ScreenPointToRay(pointer.position), out raycastHit))
            {
                if (raycastHit.collider.transform.name.Equals("SliderToggle"))
                {
                    this.m_interacting = false;
                }
                Transform            parent    = raycastHit.collider.transform.parent;
                CompactEpisodeTarget component = raycastHit.collider.transform.GetComponent <CompactEpisodeTarget>();
                if (component || (raycastHit.collider.transform.GetComponent <Button>() == null && parent && parent.GetComponent <CompactEpisodeTarget>()))
                {
                    if (component)
                    {
                        this.SetCenterEpisode(raycastHit.collider.transform.gameObject);
                    }
                    else
                    {
                        this.SetCenterEpisode(parent.gameObject);
                    }
                    if (this.m_centerEpisode == this.CurrentEpisodes[0] && this.m_preButtons != null)
                    {
                        this.SetCenterEpisode(this.m_preButtons[0]);
                    }
                    else if (this.m_centerEpisode == this.CurrentEpisodes[this.EpisodeCount - 1])
                    {
                        this.SetCenterEpisode(this.CurrentEpisodes[this.EpisodeCount - 2]);
                    }
                    if (this.m_isRotated)
                    {
                        for (int i = 0; i < this.m_episodesToggled.Count; i++)
                        {
                            if (this.m_centerEpisode == this.m_episodesToggled[i])
                            {
                                int value = Mathf.Clamp(i, 0, this.m_episodesToggled.Count - 1);
                                UserSettings.SetInt(CompactEpisodeSelector.CurrentSandboxEpisodeKey, value);
                            }
                        }
                    }
                }
            }
        }
        bool flag = TextDialog.DialogOpen || DailyChallengeDialog.DialogOpen || SnoutCoinShopPopup.DialogOpen || LootWheelPopup.DialogOpen;

        if (pointer.dragging && this.m_interacting && !flag && this.m_movableEpisodes)
        {
            Vector3 vector  = this.m_hudCamera.ScreenToWorldPoint(this.m_lastInputPos);
            Vector3 vector2 = this.m_hudCamera.ScreenToWorldPoint(pointer.position);
            this.m_lastInputPos = pointer.position;
            this.m_deltaX       = vector2.x - vector.x;
            if (Mathf.Abs(this.m_deltaX) > 0f)
            {
                this.MoveEpisodes(this.m_deltaX, true);
            }
            Vector3 vector3 = this.m_hudCamera.ScreenToWorldPoint(this.m_initialInputPos);
            if (!this.m_focusIsReset && Mathf.Abs(vector2.x - vector3.x) > 0.1f)
            {
                this.m_focusIsReset = true;
            }
            if (this.m_focusIsReset)
            {
                Singleton <GuiManager> .Instance.ResetFocus();
            }
        }
        if (pointer.up && this.m_interacting)
        {
            this.m_focusIsReset = false;
            this.m_interacting  = false;
            this.m_moveToCenter = true;
        }
        if (!this.m_interacting && this.m_movableEpisodes && this.m_momentumSlide > 0 && this.m_centerEpisode)
        {
            float x = this.m_centerEpisode.transform.position.x;
            if (Mathf.Abs(this.m_deltaX) > 0.1f)
            {
                this.MoveEpisodes(this.m_deltaX, true);
                this.m_deltaX -= this.m_deltaX / (float)this.m_momentumSlide;
            }
            else if (this.m_centerEpisode != null && this.m_moveToCenter)
            {
                float num = Mathf.SmoothDamp(x, 0f, ref this.xVelocity, 0.2f);
                this.MoveEpisodes(num - x, false);
            }
        }
        this.ScaleEpisodes();
    }