Exemplo n.º 1
0
        private async void RequestDailySignState()
        {
            UINetLoadingComponent.showNetLoading();
            G2C_DailySignState g2cDailySignState = (G2C_DailySignState)await SessionComponent.Instance.Session.Call(new C2G_DailySignState { Uid = PlayerInfoComponent.Instance.uid });

            UINetLoadingComponent.closeNetLoading();

            bool TodayIsSign = g2cDailySignState.TodayIsSign;

            if (TodayIsSign)
            {
                Button btn = Item2.transform.Find("Button").GetComponent <Button>();
                btn.interactable = false;
                btn.GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("image_main", "DayDo_tomorrow");

                string TomorrowReward = g2cDailySignState.TomorrowReward;
                int    prop_id        = CommonUtil.splitStr_Start(TomorrowReward, ':');
                int    prop_num       = CommonUtil.splitStr_End(TomorrowReward, ':');
                Item2.transform.Find("Text").GetComponent <Text>().text = ("奖励 <color=#FF8604FF>" + prop_num + "</color>金币");
            }
            else
            {
                string TodayReward = g2cDailySignState.TodayReward;
                int    prop_id     = CommonUtil.splitStr_Start(TodayReward, ':');
                int    prop_num    = CommonUtil.splitStr_End(TodayReward, ':');
                Item2.transform.Find("Text").GetComponent <Text>().text = ("奖励 <color=#FF8604FF>" + prop_num + "</color>金币");
            }
        }
Exemplo n.º 2
0
        private async void RequestDailySign()
        {
            UINetLoadingComponent.showNetLoading();

            G2C_DailySign g2cDailySign = (G2C_DailySign)await SessionComponent.Instance.Session.Call(new C2G_DailySign { Uid = PlayerInfoComponent.Instance.uid });

            UINetLoadingComponent.closeNetLoading();

            if (g2cDailySign.Error != ErrorCode.ERR_Success)
            {
                ToastScript.createToast(g2cDailySign.Message);

                return;
            }

            string reward = g2cDailySign.Reward;

            GameUtil.changeDataWithStr(reward);

            ShowRewardUtil.Show(reward);

            PlayerInfoComponent.Instance.GetPlayerInfo().IsSign = true;

            {
                Button btn = Item2.transform.Find("Button").GetComponent <Button>();
                btn.interactable = false;
                btn.GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("image_main", "DayDo_tomorrow");

                string TomorrowReward = g2cDailySign.TomorrowReward;
                int    prop_id        = CommonUtil.splitStr_Start(TomorrowReward, ':');
                int    prop_num       = CommonUtil.splitStr_End(TomorrowReward, ':');
                Item2.transform.Find("Text").GetComponent <Text>().text = ("奖励 <color=#FF8604FF>" + prop_num + "</color>金币");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 购买物品
        /// </summary>
        private async void BuyItem()
        {
            GetItemInfo info   = new GetItemInfo();
            int         shopId = CommonUtil.splitStr_Start(shopInfo.Items.ToString(), ':');
            int         count  = CommonUtil.splitStr_End(shopInfo.Items.ToString(), ':');

            UINetLoadingComponent.showNetLoading();
            G2C_BuyItem g2cBuyItem = (G2C_BuyItem)await SessionComponent.Instance.
                                     Session.Call(new C2G_BuyItem { UId = PlayerInfoComponent.Instance.uid, ShopId = shopInfo.Id });

            UINetLoadingComponent.closeNetLoading();

            ToastScript.createToast("购买成功");
            GameUtil.changeData(shopId, (int)g2cBuyItem.Count);
            if (g2cBuyItem.ShopType == 2)
            {
                PlayerInfoComponent.Instance.GetPlayerInfo().GoldNum = g2cBuyItem.Wealth;
            }
            if (g2cBuyItem.ShopType == 1)
            {
                PlayerInfoComponent.Instance.GetPlayerInfo().WingNum = g2cBuyItem.Wealth;
            }
            Log.Debug("==" + g2cBuyItem.Wealth);
            Log.Debug("--" + PlayerInfoComponent.Instance.GetPlayerInfo().WingNum);
            Game.Scene.GetComponent <UIComponent>().Get(UIType.UIMain).GetComponent <UIMainComponent>
                ().refreshUI();
            buyTip.SetActive(false);
        }
Exemplo n.º 4
0
        public void SetItem(ShopInfo info, int index, ShopType shopType)
        {
            SetCommonItem(info);
            int prop_id  = CommonUtil.splitStr_Start(info.Items, ':');
            int prop_num = CommonUtil.splitStr_End(info.Items, ':');

            this.index = index;
            float height = 0;

            if (openBtn == null && closeBtn == null)
            {
                openBtn  = rc.Get <GameObject>("OpenBtn").GetComponent <Button>();
                closeBtn = rc.Get <GameObject>("CloseBtn").GetComponent <Button>();
                switch (shopType)
                {
                case ShopType.Prop:
                    Text descTxt     = rc.Get <GameObject>("DescTxt").GetComponent <Text>();
                    Text disCountTxt = rc.Get <GameObject>("DisCountTxt").GetComponent <Text>();
                    if (prop_id == 112 && info.CurrencyType == 1)
                    {
                        this.GetParent <UI>().GameObject.transform.Find("Yuan").GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("Image_Shop", "icon_jinbi");
                    }
                    else
                    {
                        this.GetParent <UI>().GameObject.transform.Find("Yuan").GetComponent <Image>().sprite = CommonUtil.getSpriteByBundle("Image_Shop", "icon_yb");
                    }
                    string[] strArr = info.Desc.Split(';');
                    descTxt.text     = strArr[0];
                    disCountTxt.text = strArr[1];
                    height           = 150;
                    break;

                case ShopType.Vip:
                    nameTxt.text = info.Desc;
                    height       = 200;
                    break;
                }
                openBtn.onClick.Add(() =>
                {
                    openBtn.gameObject.SetActive(false);
                    closeBtn.gameObject.SetActive(true);
                    Game.Scene.GetComponent <UIComponent>().Get(UIType.UIShop).GetComponent <UIShopComponent>().SetOpenItemPos(index, shopType, height);
                });
                closeBtn.onClick.Add(() =>
                {
                    closeBtn.gameObject.SetActive(false);
                    openBtn.gameObject.SetActive(true);
                    Game.Scene.GetComponent <UIComponent>().Get(UIType.UIShop).GetComponent <UIShopComponent>().SetCloseItemPos(index, shopType, height);
                });
            }
        }
Exemplo n.º 5
0
        public void SetGoldItem(ShopInfo info)
        {
            SetCommonItem(info);
            Text disCountTxt = rc.Get <GameObject>("DisCountTxt").GetComponent <Text>();
            Text descTxt     = rc.Get <GameObject>("DescTxt").GetComponent <Text>();

            string[] strArr   = info.Desc.Split(';');
            string[] itemsArr = info.Items.Split(';');
            int      prop_id  = CommonUtil.splitStr_Start(info.Items, ':');
            int      prop_num = CommonUtil.splitStr_End(info.Items, ':');

            descTxt.text     = strArr[0];
            disCountTxt.text = strArr[1];
        }
Exemplo n.º 6
0
        public void SetEmailData(Email email)
        {
            this.email   = email;
            title.text   = email.EmailTitle;
            content.text = email.Content;
            date.text    = email.Date.Substring(0, 10);
            state        = email.State;
            string reward = email.RewardItem;

            flag.SetActive(state == 0);
            if (state == 0)
            {
                Delete.gameObject.SetActive(false);
            }
            Delete.gameObject.SetActive(state == 1);
            rewardList.Clear();
            if (reward != null && !reward.Equals(""))
            {
                get.gameObject.SetActive(state == 0);
                List <string> rewardArr = new List <string>();
                CommonUtil.splitStr(reward, rewardArr, ';');
                for (int i = 0; i < rewardArr.Count; ++i)
                {
                    int          itemId       = CommonUtil.splitStr_Start(rewardArr[i], ':');
                    int          rewardNum    = CommonUtil.splitStr_End(rewardArr[i], ':');
                    RewardStruct rewardStruct = new RewardStruct();
                    rewardStruct.itemId    = itemId;
                    rewardStruct.rewardNum = rewardNum;
                    rewardList.Add(rewardStruct);
                }
                SetRewardItemInfo();
            }
            else
            {
                if (rewardItemList.Count > 0)
                {
                    SetMoreItemHide(0);
                    get.gameObject.SetActive(false);
                }
            }
        }
Exemplo n.º 7
0
        protected override async void Run(Session session, C2G_BuyItem message, Action <G2C_BuyItem> reply)
        {
            G2C_BuyItem response = new G2C_BuyItem();

            try
            {
                DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();

                ShopConfig config = ConfigHelp.Get <ShopConfig>(message.ShopId);
                int        shopId = CommonUtil.splitStr_Start(config.Items.ToString(), ':');
                int        count  = CommonUtil.splitStr_End(config.Items.ToString(), ':');
                int        cost   = 0;
                if (await DBCommonUtil.IsVIP(message.UId))
                {
                    cost = config.VipPrice;
                }
                else
                {
                    cost = config.Price;
                }

                await DBCommonUtil.ChangeWealth(message.UId, config.CurrencyType, -cost, $"花费{cost}元宝购买商品{config.Name}");

                List <PlayerBaseInfo> playerBaseInfos = await proxyComponent.QueryJson <PlayerBaseInfo>($"{{_id:{message.UId}}}");

                switch (config.CurrencyType)
                {
                //金币
                case 1:
                    response.Wealth   = playerBaseInfos[0].GoldNum;
                    response.ShopType = 2;
                    break;

                //元宝
                case 2:
                    response.Wealth   = playerBaseInfos[0].WingNum;
                    response.ShopType = 1;
                    break;
                }
                //购买金币
                if (shopId == 1)
                {
                    await DBCommonUtil.ChangeWealth(message.UId, 1, count, $"商城购买{count}金币");
                }
                else if (shopId == 112)
                {
                    await DBCommonUtil.AddFriendKey(message.UId, count, "-1", $"商城购买{count}个{config.Name}道具");
                }
                else
                {
                    List <UserBag> itemInfos = await proxyComponent.QueryJson <UserBag>($"{{UId:{message.UId},BagId:{shopId}}}");

                    await DBCommonUtil.ChangeWealth(message.UId, shopId, count, $"商城购买{count}个{config.Name}道具");
                }

                response.Count = count;
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Exemplo n.º 8
0
 public void SetWingItem(ShopInfo info)
 {
     SetCommonItem(info);
     int prop_id  = CommonUtil.splitStr_Start(info.Items, ':');
     int prop_num = CommonUtil.splitStr_End(info.Items, ':');
 }