示例#1
0
    public void OnQuitClicked()
    {
        m_mainMenuExtend.HideWindow();
        if (UIWindowManager.Singleton.GetUIWindow <UIFTUE>() != null && UIWindowManager.Singleton.GetUIWindow <UIFTUE>().Visible)
        {
            UIWindowManager.Singleton.GetUIWindow <UIFTUE>().HideWindow();
        }
        if (CapsApplication.Singleton.CurStateEnum == StateEnum.Game)
        {
            if (UIWindowManager.Singleton.GetUIWindow <UIStageEditor>() != null && UIWindowManager.Singleton.GetUIWindow <UIStageEditor>().Visible)
            {
                UIWindowManager.Singleton.GetUIWindow <UIStageEditor>().HideWindow();
            }

            //若非时间关且没消耗步数,不用弹GameEnd界面,直接返回并恢复心
            if (GlobalVars.CurStageData.StepLimit > 0 && GameLogic.Singleton.PlayingStageData.StepLimit == GlobalVars.CurStageData.StepLimit)
            {
                if (CapsApplication.Singleton.CurStateEnum == StateEnum.Game)
                {
                    GameLogic.Singleton.ResumeGame();
                }

                GlobalVars.AddHeart(1);

                GameLogic.Singleton.PlayEndGameAnim();
                GameLogic.Singleton.ClearGame();
                CapsApplication.Singleton.ChangeState((int)StateEnum.Login);    //返回地图界面
                UIWindowManager.Singleton.GetUIWindow <UIMap>().ShowWindow();
                LoginState.Instance.CurFlow = TLoginFlow.LoginFlow_Map;         //切换流程到显示地图
            }
            else
            {
                UIWindowManager.Singleton.GetUIWindow <UIGameEnd>().ShowWindow();
            }
        }
        else if (UIWindowManager.Singleton.GetUIWindow <UIMap>().Visible)
        {
            if (GlobalVars.InMapFTUE)                                       //若再FTUE中
            {
                UIWindowManager.Singleton.GetUIWindow <UIFTUE>().EndFTUE(); //结束FTUE
            }
            UIWindowManager.Singleton.GetUIWindow <UIMap>().HideWindow();
            UIWindowManager.Singleton.GetUIWindow <UILogin>().ShowWindow();
            LoginState.Instance.CurFlow = TLoginFlow.LoginFlow_LoginScreen;
        }
        else
        {
            UIWindowManager.Singleton.GetUIWindow <UIQuitConfirm>().ShowWindow();
        }
    }
示例#2
0
文件: UILogin.cs 项目: vcan/CapsUnity
    int m_clickDebugCount = 0;      //用来记录点击隐藏的debug按钮几次,点击3次才起作用

    public override void OnCreate()
    {
        base.OnCreate();

        AddChildComponentMouseClick("PlayBtn", OnPlayBtnClick);
        AddChildComponentMouseClick("ClearBtn", delegate()
        {
            PlayerPrefs.DeleteAll();            //删除进度
            Unibiller.DebitBalance("gold", Unibiller.GetCurrencyBalance("gold"));
        });

        AddChildComponentMouseClick("RecoverHeartBtn", delegate()
        {
            GlobalVars.AddHeart(5);
        });

        AddChildComponentMouseClick("AddCoinBtn", delegate()
        {
            Unibiller.CreditBalance("gold", 100);
        });

        AddChildComponentMouseClick("DebugBtn", delegate()
        {
            ++m_clickDebugCount;
            if (m_clickDebugCount >= 3 && (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer))
            {
                m_debugBoard.SetActive(true);
            }
        });

        m_developerMode       = UIToolkits.FindComponent <UIToggle>(mUIObject.transform, "DeveloperCheck");
        m_developerMode.value = false;

        m_testLabel  = GetChildComponent <UILabel>("TestNotice");
        m_debugBoard = mUIObject.transform.FindChild("DebugBoard").gameObject;
    }
示例#3
0
文件: UIRetry.cs 项目: vcan/CapsUnity
    public void RefreshData()
    {
        if (GameLogic.Singleton.IsStageFinish() && GameLogic.Singleton.CheckGetEnoughScore())         //检查关卡是否结束
        {
            m_bWin = true;
        }
        else
        {
            m_bWin = false;
            if (GlobalVars.CurStageData.Target == GameTarget.ClearJelly)
            {
                m_infoLabel.text = Localization.instance.Get("DidNotClearIce");
            }
            else if (GlobalVars.CurStageData.Target == GameTarget.BringFruitDown)
            {
                m_infoLabel.text = Localization.instance.Get("DidNotBringNuts");
            }
            else if (GlobalVars.CurStageData.Target == GameTarget.Collect)
            {
                m_infoLabel.text = Localization.instance.Get("DidNotCollectEnough");
            }
            else if (GlobalVars.CurStageData.Target == GameTarget.GetScore)             //分数要求的情况
            {
                m_infoLabel.text = Localization.instance.Get("NotEnoughScore");
            }
            else
            {
                m_infoLabel.text = Localization.instance.Get("EndGameByHimSelf");
            }
        }

        if (m_bWin)
        {
            GlobalVars.AddHeart(1);          //若关卡成功,需要把之前扣的心恢复回来
        }

        if (m_bWin)
        {
            if (GlobalVars.AvailabeStageCount == GlobalVars.CurStageNum)
            {
                if (GlobalVars.AvailabeStageCount < GlobalVars.TotalStageCount)
                {
                    ++GlobalVars.AvailabeStageCount;            //开启下一关
                }
                //UIWindowManager.Singleton.GetUIWindow<UIMap>().OpenNewButton(GlobalVars.AvailabeStageCount);
            }

            for (int i = 2; i >= 0; --i)
            {
                if (GameLogic.Singleton.GetProgress() >= GlobalVars.CurStageData.StarScore[i])
                {
                    m_starCount = i + 1;
                    break;
                }
            }

            if (GlobalVars.StageStarArray[GlobalVars.CurStageNum] == 0)                         //if it's the first time of finishing the stage
            {
                float scorePercent = (float)GameLogic.Singleton.GetProgress() / GameLogic.Singleton.PlayingStageData.StarScore[0];
                if (CapsConfig.EnableGA)                                                                                                                 //游戏过关后的记录
                {
                    GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:StepLeft", GameLogic.Singleton.m_stepCountWhenReachTarget); //
                    GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:Score_Percent", scorePercent);                              //记录当前开始的关卡的百分比
                    GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:StarCount", m_starCount);
                    GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:FailedTimes", GlobalVars.StageFailedArray[GlobalVars.CurStageNum]);
                    GA.API.Design.NewEvent("Stage" + GlobalVars.CurStageNum + ":FirstSucceed:PlayTime", GameLogic.Singleton.GetStagePlayTime());
                }

#if UNITY_ANDROID || UNITY_IPHONE
                if (CapsConfig.EnableTalkingData)
                {
                    Dictionary <string, object> param = new Dictionary <string, object>();
                    if (GameLogic.Singleton.m_stepCountWhenReachTarget > 10)
                    {
                        param["StepLeft"] = ">10";
                    }
                    else if (GameLogic.Singleton.m_stepCountWhenReachTarget > 5)
                    {
                        param["StepLeft"] = ">5";
                    }
                    else
                    {
                        param["StepLeft"] = GameLogic.Singleton.m_stepCountWhenReachTarget.ToString();
                    }

                    param["StarCount"] = m_starCount.ToString();

                    if (scorePercent > 5)
                    {
                        param["ScorePercent"] = ">5";
                    }
                    else if (scorePercent > 3)
                    {
                        param["ScorePercent"] = ">3";
                    }
                    else if (scorePercent > 2)
                    {
                        param["ScorePercent"] = ">2";
                    }
                    else if (scorePercent > 1.5)
                    {
                        param["ScorePercent"] = ">1.5";
                    }
                    else
                    {
                        param["ScorePercent"] = ">1";
                    }

                    float playTime = GameLogic.Singleton.GetStagePlayTime();

                    if (playTime > 600)
                    {
                        param["PlayTime"] = ">10min";
                    }
                    else if (playTime > 60)
                    {
                        param["PlayTime"] = ((int)(playTime / 60)).ToString() + "min";
                    }
                    else
                    {
                        param["PlayTime"] = "<1min";
                    }

                    int failedTimes = GlobalVars.StageFailedArray[GlobalVars.CurStageNum];

                    if (failedTimes > 20)
                    {
                        param["FailedTime"] = ">20";
                    }
                    else if (failedTimes > 10)
                    {
                        param["PlayTime"] = ">10";
                    }
                    else if (failedTimes > 5)
                    {
                        param["PlayTime"] = ">5";
                    }
                    else
                    {
                        param["PlayTime"] = failedTimes.ToString();
                    }


                    TalkingDataPlugin.TrackEventWithParameters("Stage" + GlobalVars.CurStageNum + ":FirstSucceed", "", param);
                }
#endif
            }

            PlayerPrefs.SetInt("StageAvailableCount", GlobalVars.AvailabeStageCount);       //保存进度
            if (m_starCount > GlobalVars.StageStarArray[GlobalVars.CurStageNum - 1])
            {
                GlobalVars.StageStarArray[GlobalVars.CurStageNum - 1] = m_starCount;            //保存星数
                PlayerPrefsExtend.SetIntArray("StageStars", GlobalVars.StageStarArray);         //保存进度
            }

            if (GameLogic.Singleton.GetProgress() > GlobalVars.StageScoreArray[GlobalVars.CurStageNum - 1])     //记录分数记录
            {
                GlobalVars.StageScoreArray[GlobalVars.CurStageNum - 1] = GameLogic.Singleton.GetProgress();
                PlayerPrefsExtend.SetIntArray("StageScores", GlobalVars.StageScoreArray);
            }

            UIWindowManager.Singleton.GetUIWindow <UIMap>().RefreshButtonStar(GlobalVars.CurStageNum);       //刷新当前关卡的星星
            UIWindowManager.Singleton.GetUIWindow <UIMap>().RefreshButton(GlobalVars.CurStageNum - 1);       //刷新当前关卡的星星
        }
        else
        {
            GlobalVars.StageFailedArray[GlobalVars.CurStageNum]++;
            PlayerPrefsExtend.SetIntArray("StageFailed", GlobalVars.StageFailedArray);
        }

        m_levelLabel.SetNumberRapid(GlobalVars.CurStageNum);
    }
示例#4
0
    public override void OnCreate()
    {
        base.OnCreate();
        AddChildComponentMouseClick("CloseBtn", Close);

        m_minNumber   = GetChildComponent <NumberDrawer>("MinNumber");
        m_secNumber   = GetChildComponent <NumberDrawer>("SecNumber");
        m_heartSprite = GetChildComponent <UISprite>("HeartToCull");

        //AddChildComponentMouseClick("Buy1HeartBtn", delegate()
        //{
        //    if (Unibiller.DebitBalance("gold", 25))
        //    {
        //        UIWindowManager.Singleton.GetUIWindow<UIMessageBox>().SetString(Localization.instance.Get("PurchaseSucceed"));
        //        UIWindowManager.Singleton.GetUIWindow<UIMessageBox>().SetFunc(delegate()
        //        {
        //            GlobalVars.AddHeart(1);
        //            ContinuePlay();
        //        });
        //        UIWindowManager.Singleton.GetUIWindow<UIMessageBox>().ShowWindow();
        //    }
        //    else
        //    {
        //        HideWindow();
        //        UIWindowManager.Singleton.GetUIWindow<UIStore>().ShowWindow();
        //        GlobalVars.OnPurchaseFunc = delegate()
        //        {
        //            UIWindowManager.Singleton.GetUIWindow<UIMessageBox>().SetString(Localization.instance.Get("PurchaseSucceed"));
        //            UIWindowManager.Singleton.GetUIWindow<UIMessageBox>().SetFunc(delegate()
        //            {
        //                Unibiller.DebitBalance("gold", 25);
        //                GlobalVars.AddHeart(1);
        //                ContinuePlay();
        //            });
        //            UIWindowManager.Singleton.GetUIWindow<UIMessageBox>().ShowWindow();
        //        };
        //        GlobalVars.OnCancelFunc = delegate()
        //        {
        //            Close();
        //        };
        //    }
        //});

        AddChildComponentMouseClick("Buy5HeartBtn", delegate()
        {
            if (Unibiller.DebitBalance("gold", 60))
            {
                UIWindowManager.Singleton.GetUIWindow <UIMessageBox>().SetString(Localization.instance.Get("PurchaseSucceed"));
                UIWindowManager.Singleton.GetUIWindow <UIMessageBox>().SetFunc(delegate()
                {
                    CapsApplication.Singleton.SubmitUseItemData("BuyHearts");
                    GlobalVars.AddHeart(5);
                    ContinuePlay();
                });
                UIWindowManager.Singleton.GetUIWindow <UIMessageBox>().ShowWindow();
            }
            else
            {
                HideWindow();
                GlobalVars.UsingItem = PurchasedItem.Item_Hearts;
                UIWindowManager.Singleton.GetUIWindow <UIPurchaseNotEnoughMoney>().ShowWindow();
                GlobalVars.OnPurchaseFunc = delegate()
                {
                    GlobalVars.UsingItem = PurchasedItem.None;
                    Unibiller.DebitBalance("gold", 60);
                    CapsApplication.Singleton.SubmitUseItemData("BuyHearts");
                    GlobalVars.AddHeart(5);
                    ContinuePlay();
                };
                GlobalVars.OnCancelFunc = delegate()
                {
                    GlobalVars.UsingItem = PurchasedItem.None;
                    Close();
                };
            }
        });
    }