public override void init() { getComponentByPath <Text>("Get_tab_shop/Text").text = ContMgr.getCont("a3_sports_0"); getComponentByPath <Text>("scroll_view/contain/sports_jjc/name").text = ContMgr.getCont("a3_sports_1"); getComponentByPath <Text>("scroll_view/contain/sports_jdzc/name").text = ContMgr.getCont("a3_sports_2"); _instantiate = this; Con_view = this.transform.FindChild("scroll_view/contain"); contents = this.transform.FindChild("contents"); CheckLock(); new BaseButton(this.transform.FindChild("btn_close")).onClick = (GameObject go) => { Toclose = true; InterfaceMgr.getInstance().close(InterfaceMgr.A3_SPORTS); }; for (int i = 0; i < Con_view.childCount; i++) { new BaseButton(Con_view.GetChild(i)).onClick = (GameObject go) => { onTab(go.name); }; } new BaseButton(transform.FindChild("Get_tab_shop")).onClick = (GameObject go) => { InterfaceMgr.getInstance().close(InterfaceMgr.A3_SPORTS); goback = true; Shop_a3Model.getInstance().selectType = 6; Shop_a3Model.getInstance().toSelect = true; InterfaceMgr.getInstance().ui_async_open(InterfaceMgr.SHOP_A3); }; }
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); } }; }
public override void onShowed() { instance = this; InterfaceMgr.getInstance().changeState(InterfaceMgr.STATE_FUNCTIONBAR); if (uiData != null) { dic_info = Shop_a3Model.getInstance().GetinfoByNPC_id((int)uiData[0]); } CreatrveObj(); // change(); //Invoke("ShowFirstItem", 0.2f); }
//!--商店物品购买(金币购买) 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); }
private void GetInfos(Variant data) { debug.Log("七日目标:" + data.dump()); int res = data["res"]._int; switch (res) { case 1: A3_SevendayModel.getInstance().can_num = 0; A3_SevendayModel.getInstance().thisday = data["total_day"]; A3_SevendayModel.getInstance().have_point = data["point"]; A3_SevendayModel.getInstance().today_cost = data["today_cost"]; //登陆奖励的state是0和1 if (data["today_awd"].Count > 0) { for (int halflogin = 0; halflogin < data["today_awd"].Count; halflogin++) { A3_SevendayModel.getInstance().RefreshLg(data["today_awd"][halflogin]["day"], data["today_awd"][halflogin]["state"]); if (data["today_awd"][halflogin]["state"] == 0) { A3_SevendayModel.getInstance().can_num += 1; } } } //任务奖励 A3_SevendayModel.getInstance().RefreshHb(data["today_buy"]); List <Variant> lst = data["every_day_awd"]._arr; if (lst.Count > 0) { for (int i = 0; i < lst.Count; i++) { A3_SevendayModel.getInstance().Refreshs(lst[i]["id"], lst[i]["state"], lst[i]["reach_num"]); if (lst[i]["state"] == 1 && (lst[i]["id"]._int / 100 == int.Parse(data["total_day"])) /*(发的是整个七天的)*/) { A3_SevendayModel.getInstance().can_num += 1; } } } //点数奖励 List <Variant> lsts = data["point_awd"]._arr; if (lsts.Count > 0) { for (int i = 0; i < lsts.Count; i++) { A3_SevendayModel.getInstance().Refresh_fourbox(lsts[i]["id"], lsts[i]["state"]); A3_SevendayModel.getInstance().pointshow[lsts[i]["id"] - 1] = lsts[i]["state"] == 1 ? true : false; if (lsts[i]["state"] == 1) { A3_SevendayModel.getInstance().can_num += 1; } } } //任务进度 List <Variant> lst_reach_num = data["reach_list"]._arr; if (lst_reach_num.Count > 0) { for (int i = 0; i < lst_reach_num.Count; i++) { A3_SevendayModel.getInstance().RefreshRach_num(lst_reach_num[i]["awd_type"], lst_reach_num[i]["reach_num"]); } } dispatchEvent(GameEvent.Create(SEVENDAYINFO, this, data)); A3_SevendayModel.getInstance().showOrHideFire(); break; case 2: A3_SevendayModel.getInstance().can_num -= 1; A3_SevendayModel.getInstance().RefreshPoint(0); A3_SevendayModel.getInstance().RefreshLg(data["day"], 1); if (a3_sevenday._instance) { a3_sevenday._instance.RefreshData_lgAndbuy(0, /*A3_SevendayModel.getInstance().thisday*/ data["day"]); } A3_SevendayModel.getInstance().showOrHideFire(); break; case 3: A3_SevendayModel.getInstance().RefreshPoint(1); A3_SevendayModel.getInstance().RefreshHb(data["today_buy"]); if (a3_sevenday._instance) { a3_sevenday._instance.RefreshData_lgAndbuy(1, A3_SevendayModel.getInstance().thisday); } break; case 4: A3_SevendayModel.getInstance().can_num -= 1; A3_SevendayModel.getInstance().have_point = data["point"]; A3_SevendayModel.getInstance().Refreshs(data["awd_id"], 2); if (a3_sevenday._instance) { a3_sevenday._instance.Refresh_other(data["awd_id"], /*A3_SevendayModel.getInstance().thisday*/ (int)(data["awd_id"]._int / 100)); } A3_SevendayModel.getInstance().showOrHideFire(); break; case 5: A3_SevendayModel.getInstance().can_num -= 1; A3_SevendayModel.getInstance().Refresh_fourbox(data["awd_id"], 2); A3_SevendayModel.getInstance().pointshow[data["awd_id"] - 1] = false; if (a3_sevenday._instance) { a3_sevenday._instance.Refresh_FourBox(); a3_sevenday._instance.RefreshPointLight(); } A3_SevendayModel.getInstance().showOrHideFire(); break; case 7: if (data.ContainsKey("changed")) { for (int i = 0; i < data["changed"].Count; i++) { A3_SevendayModel.getInstance().Refreshs(data["changed"][i]["id"], data["changed"][i]["state"], data["changed"][i]["reach_num"]); int thisays = data["changed"][i]["id"]._int / 100; int thisday = A3_SevendayModel.getInstance().thisday; if (data["changed"][i]["state"] == 1 && thisday == thisays /*(其他天的也发)*/) { A3_SevendayModel.getInstance().can_num += 1; } if (a3_sevenday._instance) { a3_sevenday._instance.Refresh_other(data["changed"][i]["id"], /*A3_SevendayModel.getInstance().thisday*/ thisays); } } A3_SevendayModel.getInstance().showOrHideFire(); } break; case 8: if (data["changed"] != null) { for (int i = 0; i < data["changed"].Count; i++) { A3_SevendayModel.getInstance().pointshow[data["changed"][i]["id"] - 1] = data["changed"][i]["state"] == 1 ? true : false; } } if (a3_sevenday._instance) { a3_sevenday._instance.RefreshPointLight(); } break; case 9: if (data["today_cost"] != null) { A3_SevendayModel.getInstance().today_cost = data["today_cost"]; } if (data["awd_type"] != null) { A3_SevendayModel.getInstance().RefreshRach_num(data["awd_type"], data["reach_num"]); } if (a3_sevenday._instance) { a3_sevenday._instance.RefreshData(A3_SevendayModel.getInstance().thisday); } break; case -6904: tinmesover = true; //活动过期,隐藏图标 if (a3_sevenday._instance) { a3_sevenday._instance.Refresh_time(); } InterfaceMgr.doCommandByLua("a1_low_fightgame.hideSevendays", "ui/interfaces/low/a1_low_fightgame", 0); return; default: Globle.err_output(res); return; } if (res != -6904 && a3_timegifs.showover == false) { //是不是买过了 foreach (shopDatas item in Shop_a3Model.getInstance().itemsdic.Values) { if (item.day == A3_SevendayModel.getInstance().thisday) { if (item.limiteD == 0) { return; } } } tinmesover = false; /*暂时关闭*/ //InterfaceMgr.getInstance().ui_async_open(InterfaceMgr.A3_TIMEGIFS); a3_timegifs.instance?.transform.SetAsLastSibling(); } }
public void onLoadShop(Variant data) { debug.Log("商城信息:" + data.dump()); int res = data["res"]; if (res == 0) { if (data["confs"].Length > 0) { foreach (Variant v in data["confs"]._arr) { Shop_a3Model.getInstance().bundinggem(v["id"], v["item_num"]); } } if (shop_a3.instance && shop_a3.instance.isbangding) { shop_a3.instance.tab3(); } } else if (res == 1) { debug.Log("收到的a3显示抢购刷新信息:" + data.dump()); dispatchEvent(GameEvent.Create(LIMITED, this, data)); } else if (res == 2) { debug.Log("收到的3购买信息:" + data.dump()); if (a3_npc_shop.instance != null && a3_npc_shop.instance.isnpcshop) { flytxt.instance.fly(ContMgr.getCont("a3_npcshop1")); } else { if (data["left_num"] != null) { Shop_a3Model.getInstance().bundinggem(data["id"], data["item_num"], data["left_num"]); } else { Shop_a3Model.getInstance().bundinggem(data["id"], data["item_num"]); } if (data.ContainsKey("donate")) { dispatchEvent(GameEvent.Create(DONATECHANGE, this, data)); } if (shop_a3._instance != null) { shop_a3._instance.Refresh(data["id"], data["item_num"]); } InterfaceMgr.getInstance().close(InterfaceMgr.A3_DYETIP); } } else if (res == 3) { debug.Log("收到的a3限时特卖购买信息:" + data.dump()); shop_a3._instance.Refresh_limited(data["id"], data["shop_id"], data["left_num"]); } else if (res == 4) { debug.Log("收到的a3新增或变更限时特卖购买活动:" + data.dump()); dispatchEvent(GameEvent.Create(CHANGELIMITED, this, data)); } else if (res == 5) { debug.Log("收到的a3限时特卖更改活动信息:" + data.dump()); dispatchEvent(GameEvent.Create(DELETELIMITED, this, data)); } else if (res < 0) { Globle.err_output(data["res"]); return; } }
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; } } }