public void AutoBuy()
        {
            uint        num      = 99;
            uint        itm_tpid = GetFeedItemTpid();
            a3_BagModel bag      = a3_BagModel.getInstance();
            a3_ItemData itmdata  = bag.getItemDataById(itm_tpid);
            long        money    = num * itmdata.on_sale;

            if (PlayerModel.getInstance().money < money)
            {
                int i = (int)PlayerModel.getInstance().money / itmdata.on_sale;
                if (i > 0)
                {
                    Shop_a3Proxy.getInstance().BuyStoreItems(itm_tpid, (uint)i);
                    flytxt.instance.fly(ContMgr.getCont("petmodel_addfood", new List <string> {
                        i.ToString(), itmdata.item_name.ToString()
                    }));
                    // flytxt.instance.fly("成功补充了" + i + "个" + itmdata.item_name);
                }
                else if (i <= 0)
                {
                    flytxt.instance.fly(ContMgr.getCont("petmodel_nofood"));
                    //flytxt.instance.fly("金币不足,补充宠物饲料失败");
                }
            }
            else
            {
                Shop_a3Proxy.getInstance().BuyStoreItems(itm_tpid, num);
                flytxt.instance.fly(ContMgr.getCont("petmodel_addfood", new List <string> {
                    num.ToString(), itmdata.item_name.ToString()
                }));
                //flytxt.instance.fly("成功补充了" + num + "个" + itmdata.item_name);
            }
        }
示例#2
0
        void initItemBuy()
        {
            var        objsurebuy   = transform.FindChild("buy");
            var        surebuy_name = objsurebuy.transform.FindChild("bg/contain/name").GetComponent <Text>();
            var        surebuy_des  = objsurebuy.transform.FindChild("bg/contain/des_bg/Text").GetComponent <Text>();
            GameObject icon         = objsurebuy.transform.FindChild("bg/contain/icon").gameObject;

            if (icon.transform.childCount > 0)
            {
                for (int i = 0; i < icon.transform.childCount; i++)
                {
                    Destroy(icon.transform.GetChild(i).gameObject);
                }
            }
            GameObject item = IconImageMgr.getInstance().createA3ItemIcon(item_data);

            item.transform.SetParent(icon.transform, false);
            surebuy_name.text = a3_BagModel.getInstance().getItemDataById((uint)item_data.confdata.tpid).item_name;
            int color = a3_BagModel.getInstance().getItemDataById((uint)item_data.confdata.tpid).quality;

            surebuy_name.color = Globle.getColorByQuality(color);
            surebuy_des.text   = a3_BagModel.getInstance().getItemDataById((uint)item_data.confdata.tpid).desc;
            foreach (var v in Shop_a3Model.getInstance().itemsdic.Values)
            {
                if (v.itemid == (int)item_data.confdata.tpid)
                {
                    sd = v;
                }
            }
            bar.numberOfSteps = (int)PlayerModel.getInstance().gold / sd.value;
            maxnum            = bar.numberOfSteps;

            if (maxnum <= 0)
            {
                bs_bt1.interactable = false;
                bs_bt2.interactable = false;
                bs_buy.interactable = false;
                bs_buy.onClick      = (GameObject go) => flytxt.instance.fly(ContMgr.getCont("a3_dyetip"));
                return;
            }
            else
            {
                buynum          = 1;
                totalMoney.text = (buynum * sd.value).ToString();
                bar.value       = (float)buynum / (float)maxnum;
            }

            bs_buy.onClick = delegate(GameObject goo) {
                if (sd == null)
                {
                    return;
                }
                if (buynum >= 1)
                {
                    Shop_a3Proxy.getInstance().sendinfo(2, sd.id, buynum);
                }
            };
        }
示例#3
0
        private void OnBuy(GameObject go)
        {
            if (itmdata.on_sale <= 0)
            {
                return;
            }

            PlayerModel player = PlayerModel.getInstance();

            if (player.money < slider.value * itmdata.on_sale)
            {
                flytxt.instance.fly(ContMgr.getCont("comm_nomoney") + "!");
                return;
            }

            //TODO 检查背包容量是否足够

            Shop_a3Proxy.getInstance().BuyStoreItems(itmdata.tpid, (uint)slider.value);
            InterfaceMgr.getInstance().close(InterfaceMgr.A3_STORE);
        }
示例#4
0
        public override void init()
        {
            getComponentByPath <Text>("buy/Text").text = ContMgr.getCont("a3_npc_shop_0");

            getComponentByPath <Text>("title").text = ContMgr.getCont("a3_npcshop2");
            #region  button.onclick
            new BaseButton(getTransformByPath("close")).onClick = (GameObject go) =>
            {
                InterfaceMgr.getInstance().close(InterfaceMgr.A3_NPC_SHOP);
            };
            new BaseButton(getTransformByPath("buy")).onClick = (GameObject go) =>
            {
                if (selectItemID == 0)
                {
                    flytxt.instance.fly(ContMgr.getCont("a3_npc_shop_changeitem"));
                }
                else
                {
                    isnpcshop = true;
                    Shop_a3Proxy.getInstance().sendinfo(2, selectItemID, 1);
                }
                //A3_NPCShopProxy.getInstance().sendBuy((uint)A3_NPCShopModel.getInstance().listNPCShop[0].getInt("shop_id"), (uint)selectItemID, (uint)itemType, 1);
            };

            #endregion
            #region 事件监听
            // A3_NPCShopProxy.getInstance().addEventListener(A3_NPCShopProxy.EVENT_NPCSHOP_REFRESH, onRefresh);
            // A3_NPCShopProxy.getInstance().addEventListener(A3_NPCShopProxy.EVENT_NPCSHOP_BUY, onBuy);
            // A3_NPCShopProxy.getInstance().addEventListener(A3_NPCShopProxy.EVENT_NPCSHOP_TIME, onShowFloat);
            #endregion
            //-----------------------------------------
            item     = getGameObjectByPath("panel_right/scroll_rect/changeItem");
            contents = getTransformByPath("panel_right/scroll_rect/contains");
            // haveTimes = A3_NPCShopModel.getInstance().alltimes - NetClient.instance.CurServerTimeStamp - 1;//计时
            //-----------------------------------------
            //InvokeRepeating("time", 0, 1);
            //change();
            // cloneItem(goodsLength);
        }
示例#5
0
        private void TryNormalHp()
        {
            cdtime++;
            if (PlayerModel.getInstance().hp >=
                AutoPlayModel.getInstance().NHpLower *PlayerModel.getInstance().max_hp / 100)
            {
                return;
            }
            if (PlayerModel.getInstance().inSpost)
            {
                return;
            }
            int id = GetNormalHpID();

            if (id == -1)
            {//!--没有药,触发购买
                // 改为不再挂机状态也可自动购买
                //if (!SelfRole.fsm.Autofighting)
                //   return;

                if (AutoPlayModel.getInstance().BuyDrug == 0)
                {
                    return;
                }

                SXML        xml       = AutoPlayModel.getInstance().AutoplayXml;
                List <SXML> supply_hp = xml.GetNodeList("supply_hp", "playlimit==" + PlayerModel.getInstance().up_lvl);
                uint        hp_id     = 0;
                uint        max_num   = 0;
                foreach (SXML x in supply_hp)
                {
                    int playerlevel = x.getInt("playerlevel");
                    hp_id   = x.getUint("hp_id");
                    max_num = x.getUint("max_num");
                    if (PlayerModel.getInstance().lvl < playerlevel)
                    {
                        break;
                    }
                }
                if (hp_id != 0)
                {
                    //a3_ItemData itmdata = a3_BagModel.getInstance().getItemDataById(hp_id);
                    shopDatas itmdata = Shop_a3Model.getInstance().GetShopDataById((int)hp_id);
                    if (itmdata == null || itmdata.value <= 0)
                    {
                        return;
                    }
                    if (PlayerModel.getInstance().money < itmdata.value)
                    {
                        if (remindNotEnoughMoney)
                        {
                            Globle.err_output(-4000);
                            remindNotEnoughMoney = false;
                        }
                        return;
                    }
                    else
                    {
                        remindNotEnoughMoney = true;
                    }
                    if (!a3_BagModel.getInstance().getHaveRoom())
                    {
                        return;
                    }

                    uint num;
                    if (max_num * itmdata.value <= PlayerModel.getInstance().money)
                    {
                        num = max_num;
                    }
                    else
                    {
                        num = (uint)(PlayerModel.getInstance().money / itmdata.value);
                    }
                    if (buyhptimer > 2f)
                    {
                        Shop_a3Proxy.getInstance().BuyStoreItems(hp_id, num);
                        buyhptimer = 0f;
                    }
                }
            }
            else
            {//!--有药==在cd时候不吃药
                SXML        itemsXMl = XMLMgr.instance.GetSXML("item");
                SXML        s_xml    = itemsXMl.GetNode("item", "id==" + (uint)id);
                a3_ItemData item     = new a3_ItemData();
                item.tpid    = (uint)id;
                item.cd_time = s_xml.getFloat("cd");
                if (cdtime == 0)
                {
                    a3_BagModel.getInstance().useItemByTpid((uint)id, 1);
                }
                if (cdtime > item.cd_time)
                {
                    a3_BagModel.getInstance().useItemByTpid((uint)id, 1);
                    cdtime = 0;
                    return;
                }
            }
        }