示例#1
0
 public void RefreshPowerUpCounts()
 {
     this.SetSuperAutoBuildButtonAmount(new InGameBuildMenu.AutoBuildEvent(GameProgress.BluePrintCount(), false));
     this.SetSuperGlueButtonAmount(new InGameBuildMenu.ApplySuperGlueEvent(GameProgress.SuperGlueCount(), false));
     this.SetSuperMagnetButtonAmount(new InGameBuildMenu.ApplySuperMagnetEvent(GameProgress.SuperMagnetCount(), false));
     this.SetTurboChargeButtonAmount(new InGameBuildMenu.ApplyTurboChargeEvent(GameProgress.TurboChargeCount(), false));
     this.SetNightVisionButtonAmount(new InGameBuildMenu.ApplyNightVisionEvent(GameProgress.NightVisionCount(), false));
 }
示例#2
0
    private void OnEnable()
    {
        if (WPFMonoBehaviour.levelManager != null)
        {
            this.m_SuperAutoBuildButton.GetComponent <Button>().Lock(!WPFMonoBehaviour.levelManager.SuperBluePrintsAllowed);
            this.m_SuperAutoBuildButton.transform.Find("Disabled").gameObject.SetActive(!WPFMonoBehaviour.levelManager.SuperBluePrintsAllowed);
            this.m_SuperAutoBuildButton.transform.Find("Disabled").GetComponent <Renderer>().enabled = true;
            int num = GameProgress.BluePrintCount();
            if (WPFMonoBehaviour.levelManager.SuperBluePrintsAllowed && num > 0)
            {
                GameObject gameObject  = this.m_SuperAutoBuildButton.transform.Find("AmountText").gameObject;
                GameObject gameObject2 = this.m_SuperAutoBuildButton.transform.Find("AmountTextShadow").gameObject;
                if (gameObject && gameObject2)
                {
                    gameObject.GetComponent <TextMesh>().text  = num.ToString();
                    gameObject2.GetComponent <TextMesh>().text = num.ToString();
                }
            }
        }
        Singleton <KeyListener> .Instance.GrabFocus(this);

        KeyListener.keyReleased += this.HandleKeyListenerkeyReleased;
    }
示例#3
0
    protected override bool HandleUIEvent(UIEvent data)
    {
        switch (data.type)
        {
        case UIEvent.Type.Building:
            this.levelManager.ConstructionUI.transform.position   = this.levelManager.StartingPosition;
            this.levelManager.ContraptionProto.transform.position = this.levelManager.StartingPosition;
            this.levelManager.ConstructionUI.CheckUnlockedParts();
            break;

        case UIEvent.Type.LevelSelection:
            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);
                }
            }
            break;

        case UIEvent.Type.NextLevel:
            break;

        case UIEvent.Type.Pause:
            break;

        case UIEvent.Type.Blueprint:
            if (GameProgress.GetBool("PermanentBlueprint", false, GameProgress.Location.Local, null))
            {
                if (this.levelManager.m_threeStarContraption.Count == 1)
                {
                    GameProgress.SetBool(Singleton <GameManager> .Instance.CurrentSceneName + "_autobuild_available", true, GameProgress.Location.Local);
                }
                this.levelManager.SetGameState(LevelManager.GameState.AutoBuilding);
            }
            break;

        case UIEvent.Type.ReplayLevel:
            break;

        case UIEvent.Type.ContinueFromPause:
            break;

        case UIEvent.Type.CloseMechanicInfo:
            this.levelManager.SetGameState(LevelManager.GameState.Building);
            break;

        case UIEvent.Type.CloseMechanicInfoAndUseMechanic:
            this.levelManager.SetGameState(LevelManager.GameState.Building);
            Singleton <GuiManager> .Instance.IsEnabled = false;
            this.levelManager.UseBlueprint             = true;
            break;

        case UIEvent.Type.SuperBlueprint:
            if (this.levelManager.SuperBluePrintsAllowed && this.levelManager.m_threeStarContraption.Count > 0 && this.levelManager.gameState == LevelManager.GameState.Building && WPFMonoBehaviour.ingameCamera.IsShowingBuildGrid(1f))
            {
                bool flag = GameProgress.GetBool(Singleton <GameManager> .Instance.CurrentSceneName + "_autobuild_available", false, GameProgress.Location.Local, null);
                int  num  = GameProgress.BluePrintCount();
                if (num == 0 && !flag)
                {
                    Singleton <GuiManager> .Instance.IsEnabled = true;
                    this.levelManager.ShowPurchaseDialog(IapManager.InAppPurchaseItemType.BlueprintSingle);
                }
                else
                {
                    if (!flag && num > 0)
                    {
                        GameProgress.SetBluePrintCount(--num);
                        GameProgress.SetBool(Singleton <GameManager> .Instance.CurrentSceneName + "_autobuild_available", true, GameProgress.Location.Local);
                        flag = true;
                        GameProgress.Save();
                        EventManager.Send(new InGameBuildMenu.AutoBuildEvent(num, true));
                    }
                    GameObject superBuildSelection = this.levelManager.InGameGUI.BuildMenu.SuperBuildSelection;
                    if (flag && !superBuildSelection.gameObject.activeSelf)
                    {
                        GameObject autoBuildButton = this.levelManager.InGameGUI.BuildMenu.AutoBuildButton;
                        autoBuildButton.SetActive(false);
                        superBuildSelection.SetActive(true);
                    }
                    if (flag)
                    {
                        EventManager.Send(new UIEvent(UIEvent.Type.RotateSuperBluePrints));
                    }
                }
            }
            break;

        case UIEvent.Type.RotateSuperBluePrints:
        {
            int    count = this.levelManager.m_threeStarContraption.Count;
            string text  = "ABCDEFGH";
            this.levelManager.CurrentSuperBluePrint++;
            if (this.levelManager.CurrentSuperBluePrint >= count)
            {
                this.levelManager.CurrentSuperBluePrint = 0;
            }
            GameObject superBuildSelection2 = this.levelManager.InGameGUI.BuildMenu.SuperBuildSelection;
            if (superBuildSelection2 != null)
            {
                Transform transform  = superBuildSelection2.transform.Find("AmountText");
                Transform transform2 = superBuildSelection2.transform.Find("AmountTextShadow");
                if (transform.GetComponent <TextMesh>().text == string.Empty)
                {
                    this.levelManager.CurrentSuperBluePrint = 0;
                }
                transform.GetComponent <TextMesh>().text  = text[this.levelManager.CurrentSuperBluePrint].ToString();
                transform2.GetComponent <TextMesh>().text = text[this.levelManager.CurrentSuperBluePrint].ToString();
            }
            this.levelManager.SetGameState(LevelManager.GameState.SuperAutoBuilding);
            if (!this.levelManager.FirstTime)
            {
                this.levelManager.FastBuilding = true;
            }
            else
            {
                this.levelManager.FirstTime = false;
            }
            break;
        }

        case UIEvent.Type.CloseMechanicInfoAndUseSuperMechanic:
            this.levelManager.SetGameState(LevelManager.GameState.Building);
            if (this.levelManager.SuperBluePrintsAllowed && this.levelManager.m_threeStarContraption.Count > 0)
            {
                Singleton <GuiManager> .Instance.IsEnabled = false;
                this.levelManager.UseSuperBlueprint        = true;
            }
            else
            {
                Singleton <GuiManager> .Instance.IsEnabled = true;
            }
            break;
        }
        return(false);
    }
示例#4
0
 private void HandleIapManageronPurchaseSucceeded(IapManager.InAppPurchaseItemType type)
 {
     this.autoBuildButton.transform.Find("AmountText").GetComponent <TextMesh>().text = GameProgress.BluePrintCount().ToString();
 }
示例#5
0
    private void OnEnable()
    {
        this.cakeRaceMode = (WPFMonoBehaviour.levelManager.CurrentGameMode as CakeRaceMode);
        if (WPFMonoBehaviour.levelManager.CurrentGameMode.ContraptionProto.HasPart(BasePart.PartType.Egg, BasePart.PartTier.Legendary))
        {
            WPFMonoBehaviour.levelManager.CurrentGameMode.ContraptionProto.ApplySuperGlue(Glue.Type.Alien);
        }
        if (DeviceInfo.ActiveDeviceFamily == DeviceInfo.DeviceFamily.Ios)
        {
            IapManager.onPurchaseSucceeded += this.HandleIapManageronPurchaseSucceeded;
        }
        this.SetButtonAmountText(this.superBluePrintButton, GameProgress.BluePrintCount());
        this.SetButtonAmountText(this.superGlueButton, GameProgress.SuperGlueCount());
        this.SetButtonAmountText(this.superMagnetButton, GameProgress.SuperMagnetCount());
        this.SetButtonAmountText(this.turboChargeButton, GameProgress.TurboChargeCount());
        this.SetButtonAmountText(this.nightVisionButton, GameProgress.NightVisionCount());
        if (WPFMonoBehaviour.levelManager && WPFMonoBehaviour.levelManager.ContraptionProto)
        {
            this.superGlueButton.SetUsedState(WPFMonoBehaviour.levelManager.ContraptionProto.HasRegularGlue);
            this.superMagnetButton.SetUsedState(WPFMonoBehaviour.levelManager.ContraptionProto.HasSuperMagnet);
            this.turboChargeButton.SetUsedState(WPFMonoBehaviour.levelManager.ContraptionProto.HasTurboCharge);
            this.nightVisionButton.SetUsedState(WPFMonoBehaviour.levelManager.ContraptionProto.HasNightVision);
        }
        else
        {
            this.superGlueButton.SetUsedState(false);
            this.superMagnetButton.SetUsedState(false);
            this.turboChargeButton.SetUsedState(false);
            this.nightVisionButton.SetUsedState(false);
        }
        bool @bool = GameProgress.GetBool(Singleton <GameManager> .Instance.CurrentSceneName + "_autobuild_available", false, GameProgress.Location.Local, null);

        this.superBluePrintButton.SetUsedState(@bool);
        this.SetSuperAutoBuildAvailable(@bool);
        EventManager.Connect <InGameBuildMenu.AutoBuildEvent>(new EventManager.OnEvent <InGameBuildMenu.AutoBuildEvent>(this.SetSuperAutoBuildButtonAmount));
        EventManager.Connect <InGameBuildMenu.ApplySuperGlueEvent>(new EventManager.OnEvent <InGameBuildMenu.ApplySuperGlueEvent>(this.SetSuperGlueButtonAmount));
        EventManager.Connect <InGameBuildMenu.ApplySuperMagnetEvent>(new EventManager.OnEvent <InGameBuildMenu.ApplySuperMagnetEvent>(this.SetSuperMagnetButtonAmount));
        EventManager.Connect <InGameBuildMenu.ApplyTurboChargeEvent>(new EventManager.OnEvent <InGameBuildMenu.ApplyTurboChargeEvent>(this.SetTurboChargeButtonAmount));
        EventManager.Connect <InGameBuildMenu.ApplyNightVisionEvent>(new EventManager.OnEvent <InGameBuildMenu.ApplyNightVisionEvent>(this.SetNightVisionButtonAmount));
        OnPurchaseSucceeded component = this.superGlueButton.GetComponent <OnPurchaseSucceeded>();

        if (component != null)
        {
            component.buildMenu = this;
        }
        component = this.superMagnetButton.GetComponent <OnPurchaseSucceeded>();
        if (component != null)
        {
            component.buildMenu = this;
        }
        component = this.turboChargeButton.GetComponent <OnPurchaseSucceeded>();
        if (component != null)
        {
            component.buildMenu = this;
        }
        component = this.nightVisionButton.GetComponent <OnPurchaseSucceeded>();
        if (component != null)
        {
            component.buildMenu = this;
        }
        component = this.superBluePrintButton.GetComponent <OnPurchaseSucceeded>();
        if (component != null)
        {
            component.buildMenu = this;
        }
        if (this.editorButtons)
        {
            this.editorButtons.SetActive(false);
        }
    }