示例#1
0
    public override void OnCreate()
    {
        base.OnCreate();

        m_levelNumber     = GetChildComponent <NumberDrawer>("LevelNumber");
        m_totalCostNumber = GetChildComponent <NumberDrawer>("ItemTotalCost");

        m_stageIcon      = GetChildComponent <UISprite>("StageIcon");
        m_stageInfoLabel = GetChildComponent <UILabel>("StageInfoLabel");

        for (int i = 0; i < 3; ++i)
        {
            m_itemCostLabels[i] = GetChildComponent <UILabel>("Item" + (i + 1).ToString() + "Cost");
            m_itemToggles[i]    = GetChildComponent <UIToggle>("Item" + (i + 1).ToString() + "Btn");
            m_itemToggles[i].SetWithoutTrigger(false);
            m_lockItemSprite[i] = GetChildComponent <UISprite>("LockItem" + (i + 1).ToString());

            m_background[i] = GetChildComponent <UISprite>("Background" + (i + 1).ToString());

            EventDelegate.Set(m_itemToggles[i].onChange, OnToggle);
        }

        m_playBtn        = UIToolkits.FindChild(mUIObject.transform, "PlayBtn").gameObject;
        m_playPayCoinBtn = UIToolkits.FindChild(mUIObject.transform, "PlayPlayCoinBtn").gameObject;

        m_itemBoard          = UIToolkits.FindChild(mUIObject.transform, "Board").gameObject;
        m_itemBoardWithArrow = UIToolkits.FindChild(mUIObject.transform, "BoardWithArrow").gameObject;

        AddChildComponentMouseClick("CloseBtn", OnCloseClicked);
        AddChildComponentMouseClick("PlayBtn", OnPlayClicked);
        AddChildComponentMouseClick("PlayPlayCoinBtn", OnPlayClicked);
    }
示例#2
0
    public override void OnCreate()
    {
        base.OnCreate();

        for (int i = 0; i < 3; ++i)
        {
            m_starsSprites[i] = GetChildComponent <UISprite>("Star" + (i + 1)); //查找sprite
        }
        m_progressSprite = GetChildComponent <UISprite>("Progress");            //查找sprite

        stageBoard = GetChildComponent <UISprite>("StageBoard");

        m_speedSlider = GetChildComponent <UISlider>("SpeedSlider");
        m_speedLabel  = GetChildComponent <UILabel>("SpeedLabel");

        m_timeBar = GetChildComponent <UISprite>("TimeBar");

        m_scoreDrawer = GetChildComponent <NumberDrawer>("ScoreDrawer");
        m_stepDrawer  = GetChildComponent <NumberDrawer>("StepDrawer");

        m_timeNumber = UIToolkits.FindChild(mUIObject.transform, "TimeNumber").gameObject;
        m_minNumber  = GetChildComponent <NumberDrawer>("MinNumber");
        m_secNumber  = GetChildComponent <NumberDrawer>("SecNumber");

        m_stepChangeAnim  = m_stepDrawer.GetComponent <Animation>();
        m_scoreChangeAnim = m_scoreDrawer.GetComponent <Animation>();

        m_hurryStepParticle = UIToolkits.FindChild(mUIObject.transform, "Effect_HurryStep").gameObject;
        m_hurryStepParticle.SetActive(false);

        m_hurryTimeParticle = UIToolkits.FindChild(mUIObject.transform, "Effect_HurryTime").gameObject;
        m_hurryTimeParticle.SetActive(false);
    }
示例#3
0
文件: UIRetry.cs 项目: vcan/CapsUnity
    public override void OnCreate()
    {
        base.OnCreate();

        //m_resultLabel = UIToolkits.FindComponent<UILabel>(mUIObject.transform, "ResultLabel");
        m_infoLabel = UIToolkits.FindComponent <UILabel>(mUIObject.transform, "EndInfomation");

        m_levelLabel = GetChildComponent <NumberDrawer>("LevelLabel");

        m_winBoard    = UIToolkits.FindChild(mUIObject.transform, "WinBoard");
        m_failedBoard = UIToolkits.FindChild(mUIObject.transform, "FailedBoard");

        m_retryBtn = GetChildComponent <UIButton>("RetryBtn");

        AddChildComponentMouseClick("CloseBtn", OnCloseClicked);
        AddChildComponentMouseClick("RetryBtn", OnRetryClicked);
        AddChildComponentMouseClick("NextLevelBtn", OnNextLevelClicked);

        for (int i = 0; i < 3; ++i)
        {
            m_starsSprites[i]  = GetChildComponent <UISprite>("Star" + (i + 1));    //查找sprite
            m_starParticles[i] = GetChildComponent <ParticleSystem>("StarEffect" + (i + 1));
            m_starParticles[i].Stop(true);
            //m_starParticles[i].gameObject.SetActive(false);
            //for (int index = 0; index < m_starParticles[i].transform.childCount; ++index)
            //{
            //    m_starParticles[i].transform.GetChild(index).gameObject.SetActive(false);
            //}
        }
    }
示例#4
0
    public override void OnCreate()
    {
        base.OnCreate();
        AddChildComponentMouseClick("CloseBtn", OnCloseBtn);

        AddChildComponentMouseClick("BuyItem1Btn", delegate()
        {
            HideWindow();
            Unibiller.initiatePurchase("com.linkrstudio.jellycraft.60coins");
            GlobalVars.PurchasingItemName  = "60Coins";
            GlobalVars.PurchasingItemPrice = 99;
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().ShowWindow();
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().SetString(Localization.instance.Get("WaitForPurchase"));
        });

        AddChildComponentMouseClick("BuyItem2Btn", delegate()
        {
            HideWindow();
            Unibiller.initiatePurchase("com.linkrstudio.jellycraft.130coins");
            GlobalVars.PurchasingItemName  = "130Coins";
            GlobalVars.PurchasingItemPrice = 199;
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().ShowWindow();
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().SetString(Localization.instance.Get("WaitForPurchase"));
        });

        AddChildComponentMouseClick("BuyItem3Btn", delegate()
        {
            HideWindow();
            Unibiller.initiatePurchase("com.linkrstudio.jellycraft.360coins");
            GlobalVars.PurchasingItemName  = "360Coins";
            GlobalVars.PurchasingItemPrice = 499;
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().ShowWindow();
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().SetString(Localization.instance.Get("WaitForPurchase"));
        });

        AddChildComponentMouseClick("BuyItem4Btn", delegate()
        {
            HideWindow();
            Unibiller.initiatePurchase("com.linkrstudio.jellycraft.860coins");
            GlobalVars.PurchasingItemName  = "860Coins";
            GlobalVars.PurchasingItemPrice = 999;
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().ShowWindow();
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().SetString(Localization.instance.Get("WaitForPurchase"));
        });

        AddChildComponentMouseClick("BuyItem5Btn", delegate()
        {
            HideWindow();
            Unibiller.initiatePurchase("com.linkrstudio.jellycraft.1680coins");
            GlobalVars.PurchasingItemName  = "1680Coins";
            GlobalVars.PurchasingItemPrice = 1999;
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().ShowWindow();
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().SetString(Localization.instance.Get("WaitForPurchase"));
        });

        m_disableBtn = UIToolkits.FindChild(mUIObject.transform, "DisableBtn").gameObject;
    }
示例#5
0
    public static bool AddChildComponentMouseClick(Transform paneltransform, string name, EventDelegate.Callback action)
    {
        Transform tansform = UIToolkits.FindChild(paneltransform, name);

        if (null == tansform)
        {
            return(false);
        }
        return(AddChildComponentMouseClick(tansform.gameObject, action));
    }
示例#6
0
 void Refresh()
 {
     for (int i = 0; i < pageCount; ++i)
     {
         Transform help = UIToolkits.FindChild(mUIObject.transform, "Help" + (i + 1));
         if (i == m_curPicNum)
         {
             help.gameObject.SetActive(true);
         }
         else
         {
             help.gameObject.SetActive(false);
         }
     }
 }
示例#7
0
文件: UIRetry.cs 项目: vcan/CapsUnity
    public override void OnShow()
    {
        base.OnShow();
        Transform nextBtn = UIToolkits.FindChild(mUIObject.transform, "NextLevelBtn");

        if (PlayerPrefs.GetInt("StageFTUEFinished") < GlobalVars.CurStageNum)
        {
            PlayerPrefs.SetInt("StageFTUEFinished", GlobalVars.CurStageNum);
        }
        if (m_bWin)
        {
            nextBtn.gameObject.SetActive(true);

            m_winBoard.gameObject.SetActive(true);
            m_failedBoard.gameObject.SetActive(false);

            NumberDrawer number = GetChildComponent <NumberDrawer>("StageScore");
            number.SetNumber(GameLogic.Singleton.GetProgress());
            m_showTime = Time.realtimeSinceStartup;
            //根据starCount显示星星
            for (int i = 0; i < 3; ++i)
            {
                if (i < m_starCount)
                {
                    m_starsSprites[i].spriteName = "Star_Large";
                }
                else
                {
                    m_starsSprites[i].spriteName = "Grey_Star_Large";
                }
            }

            m_retryBtn.transform.LocalPositionX(-105);
        }
        else
        {
            nextBtn.gameObject.SetActive(false);
            m_winBoard.gameObject.SetActive(false);
            m_failedBoard.gameObject.SetActive(true);
            m_retryBtn.transform.LocalPositionX(0);
        }

        if (UIWindowManager.Singleton.GetUIWindow <UIFTUE>().Visible)
        {
            UIWindowManager.Singleton.GetUIWindow <UIFTUE>().EndFTUE();      //结束FTUE
        }
    }
示例#8
0
    public override void OnCreate()
    {
        base.OnCreate();

        AddChildComponentMouseClick("EditorBtn", OnEditStageClicked);

        m_fruitBoard   = UIToolkits.FindChild(mUIObject.transform, "FruitBoard").gameObject;
        m_jellyBoard   = UIToolkits.FindChild(mUIObject.transform, "JellyBoard").gameObject;
        m_scoreBoard   = UIToolkits.FindChild(mUIObject.transform, "ScoreBoard").gameObject;
        m_collectBoard = UIToolkits.FindChild(mUIObject.transform, "CollectBoard").gameObject;

        for (int i = 0; i < 3; ++i)
        {
            m_collectSprite[i]  = GetChildComponent <UISprite>("Collect" + i);
            m_collectLabel[i]   = GetChildComponent <UILabel>("CollectLabel" + i);
            m_coolDownSprite[i] = GetChildComponent <UISprite>("CoolDown" + (i + 1).ToString());

            m_coolDownSprite[i].gameObject.SetActive(false);

            m_itemBtn[i] = GetChildComponent <UIButton>("UseItem" + (i + 1).ToString() + "Btn");

            m_background[i] = GetChildComponent <UISprite>("Background" + (i + 1).ToString());
        }

        UIToolkits.AddChildComponentMouseClick(m_itemBtn[0].gameObject, delegate()
        {
            UserOrBuyItem(PurchasedItem.ItemInGame_Resort);
        });
        UIToolkits.AddChildComponentMouseClick(m_itemBtn[1].gameObject, delegate()
        {
            UserOrBuyItem(PurchasedItem.ItemInGame_Hammer);
        });
        UIToolkits.AddChildComponentMouseClick(m_itemBtn[2].gameObject, delegate()
        {
            if (GlobalVars.CurStageData.TimeLimit > 0 && !GameLogic.Singleton.IsStoppingTime)
            {
                UserOrBuyItem(PurchasedItem.ItemInGame_TimeStoper);
            }
            else if (GlobalVars.CurStageData.ChocolateCount > 0 && !GameLogic.Singleton.IsStopingChocoGrow)
            {
                UserOrBuyItem(PurchasedItem.ItemInGame_ChocoStoper);
            }
        });

        m_showCoinTweener = mUIObject.GetComponent <TweenPosition>();
        m_debugBtn        = GetChildComponent <UIButton>("EditorBtn");
    }
示例#9
0
文件: UIMap.cs 项目: vcan/CapsUnity
    public override void OnShow()
    {
        base.OnShow();
        m_heartUI.ShowWindow();
        m_coinNumber.SetNumber((int)Unibiller.GetCurrencyBalance("gold"));
        UIWindowManager.Singleton.GetUIWindow <UIMainMenu>().ShowWindow();

        m_cloud2Sprite.gameObject.SetActive(true);
        m_cloudSprite.gameObject.SetActive(true);
        m_lastClickStageTime = Timer.GetRealTimeSinceStartUp();             //更新关卡点击时间
        m_inputBlocker.SetActive(false);
        if (GlobalVars.DeveloperMode)
        {
            RefreshButtons();
        }
        Transform curStageTrans = UIToolkits.FindChild(mUIObject.transform, "Stage" + GlobalVars.LastStage);                      //找到对象

        MoveTo(new Vector2(curStageTrans.localPosition.x, curStageTrans.localPosition.y));
    }
示例#10
0
 public GameObject FindUIControll(string name)
 {
     foreach (KeyValuePair <string, UIWindow> pair in mWindowMap)
     {
         if (!pair.Value.Visible)
         {
             continue;
         }
         if (pair.Value.mUIObject.transform.localPosition.x < -1000)
         {
             continue;
         }
         Transform trans = UIToolkits.FindChild(pair.Value.mUIObject.transform, name);
         if (trans != null)
         {
             return(trans.gameObject);
         }
     }
     return(null);
 }
示例#11
0
文件: UIMap.cs 项目: vcan/CapsUnity
 public void RefreshButtonStar(int stageNum)
 {
     for (int j = 1; j <= 3; ++j)
     {
         if (GlobalVars.StageStarArray[stageNum - 1] >= j)       //若得到了星星
         {
             Transform starTrans = UIToolkits.FindChild(m_stageBtns[stageNum - 1], "Star" + j);
             if (starTrans)
             {
                 starTrans.gameObject.SetActive(true);
             }
         }
         else
         {
             Transform starTrans = UIToolkits.FindChild(m_stageBtns[stageNum - 1], "Star" + j);
             if (starTrans)
             {
                 starTrans.gameObject.SetActive(false);
             }
         }
     }
 }
示例#12
0
    public override void OnCreate()
    {
        base.OnCreate();
        AddChildComponentMouseClick("GetCoinBtn", delegate()
        {
            HideWindow();
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().ShowWindow();
            //UIWindowManager.Singleton.GetUIWindow<UIWait>().SetString(Localization.instance.Get("WaitForPurchase"));

            int coinNeeded = CapsConfig.GetItemPrice(GlobalVars.UsingItem) - (int)Unibiller.GetCurrencyBalance("gold");
            if (coinNeeded <= 60)
            {
                Unibiller.initiatePurchase("com.linkrstudio.jellycraft.60coins");
                GlobalVars.PurchasingItemName  = "60Coins";
                GlobalVars.PurchasingItemPrice = 99;
            }
            else
            {
                Unibiller.initiatePurchase("com.linkrstudio.jellycraft.130coins");
                GlobalVars.PurchasingItemName  = "130Coins";
                GlobalVars.PurchasingItemPrice = 199;
            }
        });
        AddChildComponentMouseClick("ShopBtn", delegate()
        {
            HideWindow(delegate()
            {
                UIWindowManager.Singleton.GetUIWindow <UIStore>().ShowWindow();
            });
        });

        AddChildComponentMouseClick("CloseBtn", OnCloseBtn);

        m_msgLabel   = GetChildComponent <UILabel>("IntroduceLabel");
        m_costLabel  = GetChildComponent <UILabel>("CostLabel");
        m_itemIcon   = GetChildComponent <UISprite>("ItemIcon");
        m_buy6Board  = UIToolkits.FindChild(mUIObject.transform, "Price6").gameObject;
        m_buy12Board = UIToolkits.FindChild(mUIObject.transform, "Price12").gameObject;
    }
示例#13
0
文件: UIMap.cs 项目: vcan/CapsUnity
    public override void OnCreate()
    {
        base.OnCreate();

        m_newStageNumber = -1;

        m_heartUI = UIWindowManager.Singleton.CreateWindow <UIWindow>("UIMapHeart", UIWindowManager.Anchor.TopLeft);

        m_backGroundTrans = mUIObject.transform;

        m_stageBtns    = new Transform[GlobalVars.TotalStageCount];
        m_stageNumbers = new Transform[GlobalVars.TotalStageCount];

        GlobalVars.AvailabeStageCount = PlayerPrefs.GetInt("StageAvailableCount");
        GlobalVars.HeadStagePos       = PlayerPrefs.GetInt("HeadStagePos");

        if (GlobalVars.AvailabeStageCount == 0)
        {
            GlobalVars.AvailabeStageCount = 1;
        }
        if (GlobalVars.AvailabeStageCount > GlobalVars.TotalStageCount)
        {
            GlobalVars.AvailabeStageCount = GlobalVars.TotalStageCount;
        }
        if (GlobalVars.HeadStagePos > GlobalVars.TotalStageCount)
        {
            GlobalVars.HeadStagePos = GlobalVars.TotalStageCount;
        }
        if (GlobalVars.HeadStagePos == 0)
        {
            GlobalVars.HeadStagePos = 1;
        }
        GlobalVars.StageStarArray   = PlayerPrefsExtend.GetIntArray("StageStars", 0, 100);
        GlobalVars.StageScoreArray  = PlayerPrefsExtend.GetIntArray("StageScores", 0, 100);
        GlobalVars.StageFailedArray = PlayerPrefsExtend.GetIntArray("StageFailed", 0, 100);
        GlobalVars.LastStage        = GlobalVars.AvailabeStageCount;

        if (!PlayerPrefs.HasKey("Coins"))
        {
            GlobalVars.Coins = 10;
            PlayerPrefs.SetInt("Coins", 0);
        }
        else
        {
            GlobalVars.Coins = PlayerPrefs.GetInt("Coins");
        }

        GlobalVars.PurchasedItemArray = PlayerPrefsExtend.GetIntArray("PurchasedItemArray", 0, 2);

        m_mapObj             = mUIObject.transform.FindChild("MapObj").gameObject;
        springPanel          = m_mapObj.AddComponent <SpringPanel>();
        springPanel.strength = 1000;
        UIPanel panel = m_mapObj.GetComponent <UIPanel>();

        //panel.baseClipRegion = new Vector4(0, 0, CapsApplication.Singleton.Width, CapsApplication.Singleton.Height);

        //心面板
        m_timeNumber = UIToolkits.FindChild(m_heartUI.mUIObject.transform, "TimeNumber").gameObject;
        m_minNumber  = m_heartUI.GetChildComponent <NumberDrawer>("MinNumber");
        m_secNumber  = m_heartUI.GetChildComponent <NumberDrawer>("SecNumber");
        UIButton heartBtn = m_heartUI.GetChildComponent <UIButton>("HeartBtn");

        EventDelegate.Set(heartBtn.onClick, delegate()
        {
            if (GlobalVars.HeartCount == 5)
            {
                return;
            }

            if (GlobalVars.UseSFX)
            {
                NGUITools.PlaySound(CapsConfig.CurAudioList.ButtonClip);
            }

            UINoMoreHearts noMoreHeartUI = UIWindowManager.Singleton.GetUIWindow <UINoMoreHearts>();
            UIStageInfo stageInfoUI      = UIWindowManager.Singleton.GetUIWindow <UIStageInfo>();

            if (stageInfoUI.Visible)
            {
                stageInfoUI.HideWindow();
            }

            noMoreHeartUI.NeedOpenStageInfoAfterClose = false;
            noMoreHeartUI.ShowWindow();
        });

        //金币面板
        m_coinNumber = m_heartUI.GetChildComponent <NumberDrawer>("MoneyNumber");
        UIButton button = m_heartUI.GetChildComponent <UIButton>("StoreBtn");

        EventDelegate.Set(button.onClick, delegate()
        {
            if (GlobalVars.UseSFX)
            {
                NGUITools.PlaySound(CapsConfig.CurAudioList.ButtonClip);
            }

            UIStore storeUI         = UIWindowManager.Singleton.GetUIWindow <UIStore>();
            UIStageInfo stageInfoUI = UIWindowManager.Singleton.GetUIWindow <UIStageInfo>();

            if (stageInfoUI.Visible)
            {
                stageInfoUI.HideWindow();
                GlobalVars.OnCancelFunc = delegate()
                {
                    stageInfoUI.ShowWindow();
                };
                GlobalVars.OnPurchaseFunc = delegate()
                {
                    stageInfoUI.ShowWindow();
                };
            }


            storeUI.ShowWindow();
        }
                          );

        m_headSprite = GetChildComponent <UISprite>("Head");


        GameObject obj = GameObject.Find("Cloud");

        m_cloudSprite = obj.GetComponent <UISprite>();
        m_cloudSprite.gameObject.SetActive(false);

        obj            = GameObject.Find("Cloud2");
        m_cloud2Sprite = obj.GetComponent <UISprite>();
        m_cloud2Sprite.gameObject.SetActive(false);

        m_inputBlocker = mUIObject.transform.Find("Blocker").gameObject;

        m_stageUI = UIWindowManager.Singleton.GetUIWindow <UIStageInfo>();

        for (int i = 0; i < 3; ++i)
        {
            m_blurSprites[i] = UIToolkits.FindChild(mUIObject.transform, "MapPicBlur" + i).gameObject;
            m_blurSprites[i].SetActive(false);
        }

        for (int i = 0; i < GlobalVars.TotalStageCount; ++i)
        {
            Transform transform = UIToolkits.FindChild(mUIObject.transform, "Stage" + (i + 1));                  //找到对象

            if (transform == null)
            {
                Debug.LogError("There's no " + "Stage" + (i + 1).ToString() + " Button");
                continue;
            }

            m_stageBtns[i]    = transform;
            m_stageNumbers[i] = transform.FindChild("StageNumber");
        }
    }
示例#14
0
文件: UIMap.cs 项目: vcan/CapsUnity
    public void RefreshButton(int i)
    {
        int numberCount = 1;

        if (i >= 9)
        {
            numberCount = 2;
        }
        if (i >= 99)
        {
            numberCount = 3;
        }

        bool bAvailable = false;

        if (!GlobalVars.DeveloperMode && i >= GlobalVars.HeadStagePos)             //隐藏超出范围的按钮
        {
            bAvailable = false;
        }
        else
        {
            bAvailable = true;                                                            //显示对象
        }

        for (int j = 1; j <= 3; ++j)
        {
            if (GlobalVars.StageStarArray[i] >= j)                   //若得到了星星
            {
                Transform starTrans = UIToolkits.FindChild(m_stageBtns[i], "Star" + j);
                if (starTrans)
                {
                    starTrans.gameObject.SetActive(true);
                }
            }
            else
            {
                Transform starTrans = UIToolkits.FindChild(m_stageBtns[i], "Star" + j);
                if (starTrans)
                {
                    starTrans.gameObject.SetActive(false);
                }
            }
        }

        UISprite sprite = m_stageBtns[i].FindChild("BtnBackground").GetComponent <UISprite>();
        UIButton button = m_stageBtns[i].GetComponent <UIButton>();

        if (bAvailable)
        {
            if (i == GlobalVars.HeadStagePos - 1)                   //当前关卡
            {
                sprite.spriteName = "CurMapPoint_Type" + CapsConfig.StageTypeArray[i] + "Num" + numberCount;
                sprite.width      = 122;
                sprite.height     = 112;
                sprite.LocalPositionX(2);
                sprite.LocalPositionY(25);
            }
            else
            {
                sprite.spriteName = "MapPoint_Type" + CapsConfig.StageTypeArray[i] + "Num" + numberCount;
                sprite.width      = 74;
                sprite.height     = 74;
                sprite.LocalPositionX(4);
                sprite.LocalPositionY(18);
            }

            m_stageNumbers[i].gameObject.SetActive(true);
            button.enabled = true;

            m_stageBtns[i].gameObject.SetActive(true);
        }
        else
        {
            //截图时用的,发布版本不显示未开启的关卡,直接放在背景图上

            //sprite.spriteName = "MapPoint_NotOpen_Type" + CapsConfig.StageTypeArray[i];
            //sprite.width = 74;
            //sprite.height = 74;
            //sprite.LocalPositionX(4);
            //sprite.LocalPositionY(18);
            //m_stageNumbers[i].gameObject.SetActive(false);
            //button.enabled = false;

            m_stageBtns[i].gameObject.SetActive(false);
        }
        EventDelegate.Set(button.onClick, OnStageClicked);
    }
示例#15
0
    public override void OnShow()
    {
        base.OnShow();

        m_items[0] = PurchasedItem.ItemInGame_Resort;
        m_items[1] = PurchasedItem.ItemInGame_Hammer;
        if (GlobalVars.CurStageData.TimeLimit > 0)
        {
            m_items[2] = PurchasedItem.ItemInGame_TimeStoper;
        }
        else if (GlobalVars.CurStageData.ChocolateCount > 0)
        {
            m_items[2] = PurchasedItem.ItemInGame_ChocoStoper;
        }

        if (GlobalVars.CurStageData.Target == GameTarget.BringFruitDown)
        {
            m_fruitBoard.SetActive(true);
            m_jellyBoard.SetActive(false);
            m_scoreBoard.SetActive(false);
            m_collectBoard.SetActive(false);

            Transform fruit1Trans = UIToolkits.FindChild(m_fruitBoard.transform, "Fruit1Board");
            Transform fruit2Trans = UIToolkits.FindChild(m_fruitBoard.transform, "Fruit2Board");
            if (GlobalVars.CurStageData.Nut1Count > 0)
            {
                fruit1Trans.gameObject.SetActive(true);
                UIToolkits.FindComponent <UISprite>(m_fruitBoard.transform, "FruitNumTotal1").spriteName = "BaseNum" + GlobalVars.CurStageData.Nut1Count.ToString();
            }
            else
            {
                fruit1Trans.gameObject.SetActive(false);
            }
            if (GlobalVars.CurStageData.Nut2Count > 0)
            {
                fruit2Trans.gameObject.SetActive(true);
                UIToolkits.FindComponent <UISprite>(m_fruitBoard.transform, "FruitNumTotal2").spriteName = "BaseNum" + GlobalVars.CurStageData.Nut2Count.ToString();
            }
            else
            {
                fruit2Trans.gameObject.SetActive(false);
            }
            //居中对齐
            if (GlobalVars.CurStageData.Nut1Count > 0 && GlobalVars.CurStageData.Nut2Count > 0)     //若两个水果都有
            {
                fruit1Trans.LocalPositionX(10);
                fruit2Trans.LocalPositionX(201);
            }
            else if (GlobalVars.CurStageData.Nut1Count > 0)
            {
                fruit1Trans.LocalPositionX(111);
            }
            else if (GlobalVars.CurStageData.Nut2Count > 0)
            {
                fruit2Trans.LocalPositionX(111);
            }

            if (GlobalVars.CurStageData.Nut1Count > 0)
            {
                GameLogic.Singleton.CollectTargetUIPos[0] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + fruit1Trans.localPosition.x, 1.562183f - 38.568f, 0);
            }
            if (GlobalVars.CurStageData.Nut2Count > 0)
            {
                GameLogic.Singleton.CollectTargetUIPos[1] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + fruit2Trans.localPosition.x, 1.562183f - 38.5681f, 0);
            }
        }
        else if (GlobalVars.CurStageData.Target == GameTarget.ClearJelly)
        {
            m_fruitBoard.SetActive(false);
            m_jellyBoard.SetActive(true);
            m_scoreBoard.SetActive(false);
            m_collectBoard.SetActive(false);
            if (GlobalVars.CurStageData.GetDoubleJellyCount() > 0)
            {
                UIToolkits.FindChild(m_jellyBoard.transform, "DoubleJellyBoard").gameObject.SetActive(true);
            }
            else
            {
                UIToolkits.FindChild(m_jellyBoard.transform, "DoubleJellyBoard").gameObject.SetActive(false);
            }

            if (GlobalVars.CurStageData.GetDoubleJellyCount() > 0)
            {
                UIToolkits.FindChild(m_jellyBoard.transform, "JellyBoard").LocalPositionX(27);
                UIToolkits.FindChild(m_jellyBoard.transform, "DoubleJellyBoard").LocalPositionX(187);
            }
            else
            {
                UIToolkits.FindChild(m_jellyBoard.transform, "JellyBoard").LocalPositionX(123);
            }
        }
        else if (GlobalVars.CurStageData.Target == GameTarget.Collect)          //处理搜集关的显示
        {
            m_fruitBoard.SetActive(false);
            m_jellyBoard.SetActive(false);
            m_scoreBoard.SetActive(false);
            m_collectBoard.SetActive(true);
            int collectTypeCount = 0;
            for (int i = 0; i < 3; ++i)
            {
                if (GlobalVars.CurStageData.CollectCount[i] > 0)
                {
                    m_collectLabel[i].gameObject.SetActive(true);
                    ++collectTypeCount;

                    switch (GlobalVars.CurStageData.CollectSpecial[i])
                    {
                    case TSpecialBlock.ESpecial_Normal:
                    {
                        m_collectSprite[i].spriteName = "Item" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None);
                    }
                    break;

                    case TSpecialBlock.ESpecial_NormalPlus6:
                    {
                        m_collectSprite[i].spriteName = "TimeAdded" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None);
                    }
                    break;

                    case TSpecialBlock.ESpecial_EatLineDir0:
                        m_collectSprite[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_3";
                        break;

                    case TSpecialBlock.ESpecial_EatLineDir1:
                        m_collectSprite[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_1";
                        break;

                    case TSpecialBlock.ESpecial_EatLineDir2:
                        m_collectSprite[i].spriteName = "Line" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None) + "_2";
                        break;

                    case TSpecialBlock.ESpecial_Bomb:
                        m_collectSprite[i].spriteName = "Bomb" + (int)(GlobalVars.CurStageData.CollectColors[i] - TBlockColor.EColor_None);
                        break;

                    case TSpecialBlock.ESpecial_EatAColor:
                        m_collectSprite[i].spriteName = "Rainbow";
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    m_collectLabel[i].gameObject.SetActive(false);
                }
            }

            if (collectTypeCount == 3)
            {
                int interval = 130;
                for (int i = 0; i < 3; ++i)
                {
                    m_collectLabel[i].transform.LocalPositionX(i * interval);
                }
            }
            else if (collectTypeCount == 2)
            {
                int interval = 150;
                int curPosX  = 30;
                for (int i = 0; i < 3; ++i)
                {
                    if (GlobalVars.CurStageData.CollectCount[i] > 0)
                    {
                        m_collectLabel[i].transform.LocalPositionX(curPosX);
                        curPosX += interval;
                    }
                }
            }
            else if (collectTypeCount == 1)
            {
                for (int i = 0; i < 3; ++i)
                {
                    if (GlobalVars.CurStageData.CollectCount[i] > 0)
                    {
                        m_collectLabel[i].transform.LocalPositionX(144);
                        break;
                    }
                }
            }

            GameLogic.Singleton.CollectTargetUIPos[0] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + m_collectLabel[0].transform.localPosition.x, 1.562183f - 38.568f, 0);
            GameLogic.Singleton.CollectTargetUIPos[1] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + m_collectLabel[1].transform.localPosition.x, 1.562183f - 38.5681f, 0);
            GameLogic.Singleton.CollectTargetUIPos[2] = new Vector3(-59.63453f + CapsApplication.Singleton.Width / 2 + m_collectLabel[2].transform.localPosition.x, 1.562183f - 38.5681f, 0);
        }
        if (GlobalVars.CurStageData.Target == GameTarget.GetScore)
        {
            m_fruitBoard.SetActive(false);
            m_jellyBoard.SetActive(false);
            m_scoreBoard.SetActive(true);
            m_collectBoard.SetActive(false);
            UIToolkits.FindComponent <NumberDrawer>(m_scoreBoard.transform, "ScoreNum").SetNumber(GlobalVars.CurStageData.StarScore[0]);
        }

        UISprite item3Icon = GetChildComponent <UISprite>("Item3Icon");

        for (int i = 0; i < 3; ++i)
        {
            if (CapsConfig.ItemUnLockLevelArray[(int)m_items[i]] <= GlobalVars.AvailabeStageCount || GlobalVars.DeveloperMode)
            {
                if (i == 2)
                {
                    if (GlobalVars.CurStageData.TimeLimit > 0)
                    {
                        item3Icon.spriteName = PurchasedItem.ItemInGame_TimeStoper.ToString();
                        m_itemBtn[2].gameObject.SetActive(true);
                    }
                    else if (GlobalVars.CurStageData.ChocolateCount > 0)
                    {
                        item3Icon.spriteName = PurchasedItem.ItemInGame_ChocoStoper.ToString();
                        m_itemBtn[2].gameObject.SetActive(true);
                    }
                    else
                    {
                        m_itemBtn[2].gameObject.SetActive(false);
                    }
                }
                else
                {
                    m_itemBtn[i].gameObject.SetActive(true);
                }
            }
            else
            {
                m_itemBtn[i].gameObject.SetActive(false);
            }
        }


        UpdateItemButtons();

        RefreshTarget();

        if (GlobalVars.DeveloperMode)
        {
            m_debugBtn.gameObject.SetActive(true);
        }
        else
        {
            m_debugBtn.gameObject.SetActive(false);
        }
    }