private void Readxml() { List <SXML> sXMLList = XMLMgr.instance.GetSXMLList("golden_shop.golden_shop", ""); foreach (SXML current in sXMLList) { shopDatas shopDatas = new shopDatas(); shopDatas.id = current.getInt("id"); shopDatas.type = current.getInt("type"); shopDatas.itemid = current.getInt("itemid"); shopDatas.money_type = current.getInt("money_type"); shopDatas.value = current.getInt("value"); shopDatas.itemName = current.getString("itemname"); bool flag = current.getInt("limit") != -1; if (flag) { shopDatas.limiteD = current.getInt("limit"); shopDatas.limiteNum = current.getInt("limit"); } bool flag2 = current.getInt("limit_w") != -1; if (flag2) { shopDatas.limiteD = current.getInt("limit_w"); shopDatas.limiteNum = current.getInt("limit_w"); } this.itemsdic[shopDatas.id] = shopDatas; } }
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); } }; }
void RefreshInfo(shopDatas datas, GameObject go) { Transform icon = go.transform.FindChild("bg/bg1/icon").transform; GameObject gos = IconImageMgr.getInstance().createA3ItemIcon((uint)datas.itemid, false, -1, 1f); gos.transform.SetParent(icon, false); Text name = go.transform.FindChild("bg/bg1/name").GetComponent <Text>(); name.text = datas.itemName; Text price = go.transform.FindChild("bg/bg1/price_now").GetComponent <Text>(); price.text = datas.value.ToString(); }
//!--商店物品购买(金币购买) public void BuyStoreItems(uint tpid, uint num) { Variant msg = new Variant(); msg["op"] = 2;//原为4,4为特卖价格 shopDatas shopData = Shop_a3Model.getInstance().GetShopDataById((int)tpid); msg["id"] = shopData.id; msg["item_num"] = num; sendRPC(PKG_NAME.C2S_A3_SHOP, msg); //提示购买药水 flytxt.instance.fly(ContMgr.getCont("shop_a3_buyself") + num + ContMgr.getCont("employer1") + shopData.itemName);//a3_BagModel.getInstance().getItemDataById(tpid).item_name); }
public void BuyStoreItems(uint tpid, uint num) { Variant variant = new Variant(); variant["op"] = 2; shopDatas shopDataById = ModelBase <Shop_a3Model> .getInstance().GetShopDataById((int)tpid); variant["id"] = shopDataById.id; variant["item_num"] = num; this.sendRPC(62u, variant); flytxt.instance.fly(string.Concat(new object[] { "自动购买", num, "个", shopDataById.itemName }), 0, default(Color), null); }
void Readxml() { List <SXML> xml = XMLMgr.instance.GetSXMLList("golden_shop.golden_shop"); foreach (SXML x in xml) { shopDatas infos = new shopDatas(); infos.id = x.getInt("id"); infos.type = x.getInt("type"); infos.itemid = x.getInt("itemid"); infos.money_type = x.getInt("money_type"); infos.value = x.getInt("value"); infos.itemName = x.getString("itemname"); if (x.getInt("limit") != -1) { infos.limiteD = x.getInt("limit"); infos.limiteNum = x.getInt("limit"); } if (x.getInt("limit_w") != -1) { infos.limiteD = x.getInt("limit_w"); infos.limiteNum = x.getInt("limit_w"); } if (x.getInt("limit_f") != -1) { infos.limiteD = x.getInt("limit_f"); infos.limiteNum = x.getInt("limit_f"); infos.isover = true; } if (x.getInt("npc_id") != -1) { infos.npc_id = x.getInt("npc_id"); } if (x.getInt("limit_day") != -1) { infos.day = x.getInt("limit_day"); } itemsdic[infos.id] = infos; if (infos.npc_id != -1) { itemsdic_npcitem[infos.npc_id] = infos; } } }
private void TryNormalHp() { this.cdtime++; bool flag = ModelBase <PlayerModel> .getInstance().hp >= ModelBase <AutoPlayModel> .getInstance().NHpLower *ModelBase <PlayerModel> .getInstance().max_hp / 100; if (!flag) { int normalHpID = this.GetNormalHpID(); bool flag2 = normalHpID == -1; if (flag2) { bool flag3 = ModelBase <AutoPlayModel> .getInstance().BuyDrug == 0; if (!flag3) { SXML autoplayXml = ModelBase <AutoPlayModel> .getInstance().AutoplayXml; List <SXML> nodeList = autoplayXml.GetNodeList("supply_hp", "playlimit==" + ModelBase <PlayerModel> .getInstance().up_lvl); uint num = 0u; uint num2 = 0u; foreach (SXML current in nodeList) { int @int = current.getInt("playerlevel"); num = current.getUint("hp_id"); num2 = current.getUint("max_num"); bool flag4 = (ulong)ModelBase <PlayerModel> .getInstance().lvl < (ulong)((long)@int); if (flag4) { break; } } bool flag5 = num > 0u; if (flag5) { shopDatas shopDataById = ModelBase <Shop_a3Model> .getInstance().GetShopDataById((int)num); bool flag6 = shopDataById == null || shopDataById.value <= 0; if (!flag6) { bool flag7 = (ulong)ModelBase <PlayerModel> .getInstance().money < (ulong)((long)shopDataById.value); if (flag7) { flytxt.instance.fly(err_string.get_Err_String(-4000), 0, default(Color), null); } else { bool flag8 = !ModelBase <a3_BagModel> .getInstance().getHaveRoom(); if (!flag8) { bool flag9 = (ulong)num2 * (ulong)((long)shopDataById.value) <= (ulong)ModelBase <PlayerModel> .getInstance().money; uint num3; if (flag9) { num3 = num2; } else { num3 = (uint)((ulong)ModelBase <PlayerModel> .getInstance().money / (ulong)((long)shopDataById.value)); } bool flag10 = this.buyhptimer > 2f; if (flag10) { BaseProxy <Shop_a3Proxy> .getInstance().BuyStoreItems(num, num3); this.buyhptimer = 0f; } } } } } } } else { SXML sXML = XMLMgr.instance.GetSXML("item", ""); SXML node = sXML.GetNode("item", "id==" + (uint)normalHpID); a3_ItemData a3_ItemData = default(a3_ItemData); a3_ItemData.tpid = (uint)normalHpID; a3_ItemData.cd_time = node.getFloat("cd"); bool flag11 = this.cdtime == 0; if (flag11) { ModelBase <a3_BagModel> .getInstance().useItemByTpid((uint)normalHpID, 1); } bool flag12 = (float)this.cdtime > a3_ItemData.cd_time; if (flag12) { ModelBase <a3_BagModel> .getInstance().useItemByTpid((uint)normalHpID, 1); this.cdtime = 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; } } }