Example #1
0
    void BuySuccess(TBData data)
    {
        string order = ShopOrderManager.getInstance().getOrderDes(data.order);

        for (int i = 0; i < szIAPData.Count; i++)
        {
            if (order.Equals(szIAPData[i].proid))
            {
                ShopOrderManager.getInstance().setOrderStatu(order, ShopOrderManager.BuyEndStates);
                ShopOrderManager.getInstance().saveShopOrder();

                _dataPlayer.Jewel += szIAPData[i].get_num;
                                #if Add_AD
                if (!szIAPData[i].proid.Equals("Coins_60"))
                {
                    WGGameWorld.Instance.RemoveAd();
                }
                                #endif
#if Umeng
                Umeng.GA.Pay(szIAPData[i].cost_num, Umeng.GA.PaySource.TongBu, szIAPData[i].get_num);
#endif

                DataPlayerController.getInstance().saveDataPlayer();
                WGGameUIView.Instance.freshPlayerUI(UI_FRESH.BCOIN);
                WGAlertViewController.Self.showTipView(1001);
            }
        }
    }
Example #2
0
    //start battle
    public static void StartBattle()
    {
        //create a data list and fill it up with selectedUnitList
        List <TBDataUnit> dataList = new List <TBDataUnit>();

        for (int i = 0; i < instance.selectedUnitList.Count; i++)
        {
            dataList.Add(new TBDataUnit(instance.selectedUnitList[i]));
        }
        //set the data list as the start data, use 0 as the data ID, the faction in demo has been set to load data with ID-0
        TBData.SetStartData(0, dataList);

        //load the battle scene
        LoadLevel("DemoCampaignBattle");
        //LoadLevel("Battle_Scene_"+Random.Range(0, 1000).ToString());
    }
Example #3
0
    void Awake()
    {
        instance = this;

        PerkManager perkManager = (PerkManager)FindObjectOfType(typeof(PerkManager));

        if (perkManager != null)
        {
            perkManager.Init();
        }

        AbilityManagerUnit abManagerUnit = (AbilityManagerUnit)FindObjectOfType(typeof(AbilityManagerUnit));

        if (abManagerUnit != null)
        {
            abManagerUnit.Init();
        }


        availableUnitList = new List <Unit>(UnitDB.Load());             //load the unit from DB, you manually assign this if you want

        //since we are loading from DB, we dont want the AI unit, which started from 6 (so we remove them)
        while (availableUnitList.Count > 9)
        {
            availableUnitList.RemoveAt(availableUnitList.Count - 1);
        }

        //if this there isn't any save
        if (!PlayerPrefs.HasKey("TBTK_Demo"))
        {
            //for demo purpose, we are using perk currency as the universal currency
            //so we set the perk currency to our starting value and let PerkManager keep track of it
            PerkManager.SetPerkCurrency(startingCurrency);

            PlayerPrefs.SetInt("TBTK_Demo", 1);
        }
        else
        {
            //check with data to see if the scene is loaded from a battle
            if (TBData.BattleEndDataExist())
            {
                List <TBDataUnit> dataList = TBData.GetEndData(0);              //get the data, the ID is zero, since we start the battle with 0
                //note that the faction in the battle scene is configured to load data from 0 too

                if (dataList != null)                   //add the unit based on the dataList
                {
                    for (int i = 0; i < dataList.Count; i++)
                    {
                        selectedUnitList.Add(dataList[i].unit);
                    }
                }

                for (int i = 0; i < selectedUnitList.Count; i++)                        //fill up the availableUnitMapList (for saving)
                {
                    bool match = false;
                    for (int n = 0; n < availableUnitList.Count; n++)                           //find the corresponding unit in availableList and add the index to selectedUnitMapList
                    {
                        if (selectedUnitList[i] == availableUnitList[n])
                        {
                            selectedUnitMapList.Add(n);
                            match = true;
                            break;
                        }
                    }
                    //if there's no match in availableUnitList, unit no longer available in game, remove it from selected list
                    if (!match)
                    {
                        selectedUnitList.RemoveAt(i);
                        i -= 1;
                    }
                }

                _SaveLoadOut();
            }
            else                //if we are not loading the scene from a battle, load the selectedUnitList from previous save in stead of getting it from data
            {
                _LoadLoadOut();
            }
        }
    }
Example #4
0
    void TBMessage(string msg)
    {
        Debug.Log(msg);
        TBData data = SDK.Deserialize <TBData>(msg);

        Debug.Log(SDK.Serialize(data));


        if (data.act == TBACT.TBInitDidFinish)
        {
        }
        else if (data.act == TBACT.TBLoginResult)
        {
            WGAlertViewController.Self.hiddenConnecting();
        }
        else if (data.act == TBACT.TBBuyGoodsDidSuccessWithOrder)
        {
            WGAlertViewController.Self.hiddenConnecting();
            BuySuccess(data);
        }
        else if (data.act == TBACT.TBBuyGoodsDidFailedWithOrder)
        {
            WGAlertViewController.Self.showAlertView(1800 + data.status).alertViewBehavriour = (ab, view) => {
                switch (ab)
                {
                case MDAlertBehaviour.CLICK_OK:
                    view.hiddenView();
                    break;

                case MDAlertBehaviour.DID_HIDDEN:
                    WGAlertViewController.Self.hiddeAlertView(view.gameObject);
                    break;
                }
            };
            WGAlertViewController.Self.hiddenConnecting();
            ShopOrderManager.getInstance().setOrderStatu(data.order, ShopOrderManager.BuyFail);
            ShopOrderManager.getInstance().saveShopOrder();
        }
        else if (data.act == TBACT.TBBuyGoodsDidStartRechargeWithOrder)
        {
//			TBSDK.TBCheckOrder(data.order);
//			WGAlertViewController.Self.showConnecting();
        }
        else if (data.act == TBACT.TBBuyGoodsDidCancelByUser)
        {
            WGAlertViewController.Self.showAlertView(1810).alertViewBehavriour = (ab, view) => {
                switch (ab)
                {
                case MDAlertBehaviour.CLICK_OK:
                    view.hiddenView();
                    break;

                case MDAlertBehaviour.DID_HIDDEN:
                    WGAlertViewController.Self.hiddeAlertView(view.gameObject);
                    break;
                }
            };
            ShopOrderManager.getInstance().setOrderStatu(data.order, ShopOrderManager.BuyCancel);
            ShopOrderManager.getInstance().saveShopOrder();
            WGAlertViewController.Self.hiddenConnecting();
        }
        else if (data.act == TBACT.TBDidLogout)
        {
        }
        else if (data.act == TBACT.TBLeavedPlatform)
        {
            if (!string.IsNullOrEmpty(data.order))
            {
#if TBSDK
                TBSDK.TBCheckOrder(data.order);
#endif
            }
            else
            {
                WGAlertViewController.Self.hiddenConnecting();
            }
        }
        else if (data.act == TBACT.TBCheckOrderFinishedWithOrder)
        {
            WGAlertViewController.Self.hiddenConnecting();
            if (data.status == 1 || data.status == 3)
            {
                BuySuccess(data);
            }
            else if (data.status == 0 || data.status == 2 || data.status == -1)
            {
                ShopOrderManager.getInstance().setOrderStatu(data.order, ShopOrderManager.BuyFail);
                WGAlertViewController.Self.showAlertView(1820 + data.status).alertViewBehavriour = (ab, view) => {
                    switch (ab)
                    {
                    case MDAlertBehaviour.CLICK_OK:
                        view.hiddenView();
                        break;

                    case MDAlertBehaviour.DID_HIDDEN:
                        WGAlertViewController.Self.hiddeAlertView(view.gameObject);
                        break;
                    }
                };
            }
        }
        else if (data.act == TBACT.TBCheckOrderDidFailed)
        {
            WGAlertViewController.Self.showAlertView(1811).alertViewBehavriour = (ab, view) => {
                switch (ab)
                {
                case MDAlertBehaviour.CLICK_OK:
                    view.hiddenView();
                    break;

                case MDAlertBehaviour.DID_HIDDEN:
                    WGAlertViewController.Self.hiddeAlertView(view.gameObject);
                    break;
                }
            };
            WGAlertViewController.Self.hiddenConnecting();
        }
    }