void InitDress() { for (int i = 0; i < dress_bg.transform.childCount; i++) { lst_dresspos.Add(dress_bg.transform.GetChild(i).gameObject); } Dictionary <uint, a3_BagItemData> dic = A3_RuneStoneModel.getInstance().dressup_runestones; foreach (uint i in dic.Keys) { DressUp(dic[i], i); } }
int this_id = -1; //当前所选物品id void refreBynumAndMoney(int id) { List <int> lst = new List <int>(); int num; bool canby = false; for (int i = 0; i < dic_allrune_data[id].compose_data.Count; i++) { if (a3_BagModel.getInstance().getItemNumByTpid((uint)dic_allrune_data[id].compose_data[i].id) > 0) { num = (int)Mathf.Floor(a3_BagModel.getInstance().getItemNumByTpid((uint)dic_allrune_data[id].compose_data[i].id) / dic_allrune_data[id].compose_data[i].num); if (num <= 0) { canby = false; break; } else { canby = true; lst.Add(num); } } else { break; } } lst.Sort(); if (canby) { min_num = 1; max_num = lst[0] > 1 ? lst[0] : 1; nub = 1; this_id = id; needmoney_num = A3_RuneStoneModel.getInstance().getNeedMoney(id); getComponentByPath <Button>("compose/left/need_money").interactable = true; } else { min_num = 0; max_num = 0; nub = 0; this_id = -1; needmoney_num = 0; getComponentByPath <Button>("compose/left/need_money").interactable = false; } buy_num.text = nub.ToString(); money.text = needmoney_num.ToString(); }
/*选择条件的按钮*/ void InitchosebtnOnclick(List <GameObject> list_contain, int type) { for (int i = 0; i < list_contain.Count; i++) { for (int j = 0; j < list_contain[i].transform.childCount; j++) { new BaseButton(list_contain[i].transform.GetChild(j).transform).onClick = (GameObject go) => ClosechoseOnClick(go, type); } } int lv = A3_RuneStoneModel.getInstance().nowlv; for (int i = 2; i < lv + 1; i++) { RefreScrollLv(i); } }
/*创建符石*/ void InitBagHaveRunestones() { Dictionary <uint, a3_BagItemData> dic = new Dictionary <uint, a3_BagItemData>(); if (A3_RuneStoneModel.getInstance().getHaveRunestones() == null || dic == A3_RuneStoneModel.getInstance().getHaveRunestones()) { return; } dic = A3_RuneStoneModel.getInstance().getHaveRunestones(); int index = 0; RefreshSccrollHaveRunestonsGrid(); foreach (a3_BagItemData data in A3_RuneStoneModel.getInstance().getHaveRunestones().Values) { CreatrveIcons(data, index); index++; } }
void compose_bymonry() { if (this_id == -1) { return; } else { SXML xml = XMLMgr.instance.GetSXML("item.item", "id==" + this_id); int neednum = xml.getInt("stamina_use"); if (A3_RuneStoneModel.getInstance().nowstamina < neednum) { flytxt.instance.fly(ContMgr.getCont("a3_runestone_nolive"), 1); } else { a3_RuneStoneProxy.getInstance().sendporxy(2, this_id, nub); } } }
void RefreshSccrollHaveRunestonsGrid() { int count = A3_RuneStoneModel.getInstance().getHaveRunestones().Keys.Count; if (count <= grids_nub) { if (contain_haveRunestones.transform.childCount <= grids_nub) { return; } else { RefreshSccrollHaveRunestonsGrid(false, contain_haveRunestones.transform.childCount - grids_nub); } } else { int x = (count - grids_nub) % 5; int num = x % 5 == 0 ? x : (int)Mathf.Ceil(x / 5); RefreshSccrollHaveRunestonsGrid(true, x <= 5?5: num * 5); } }
//初始化的一些数据 /*等级体力*/ void LvStaminaInfos() { int Stamina = A3_RuneStoneModel.getInstance().nowstamina; stamin.text = ContMgr.getCont("a3_runestone_live") + " " + Stamina; stamin_obj.value = Stamina / 50; int lv = A3_RuneStoneModel.getInstance().nowlv; int nowexp = A3_RuneStoneModel.getInstance().nowexp; uint nextexp; SXML xml = XMLMgr.instance.GetSXML("rune_stone.compose", "level==" + lv); if (xml.getUint("exp") != 0) { nextexp = xml.getUint("exp"); } else { nextexp = XMLMgr.instance.GetSXML("rune_stone.compose", "level==" + (lv - 1)).getUint("exp"); } exp.text = lv + ContMgr.getCont("ji") + " " + nowexp + "/" + nextexp; exp_obj.value = (float)nowexp / nextexp; }
public void onLoadRunestone(Variant data) { debug.Log("a3符石信息:" + data.dump()); int res = data["res"]; switch (res) { case 1: if (data.ContainsKey("fushi")) //穿上 { if (a3_runestone._instance != null) { a3_BagItemData dat = A3_RuneStoneModel.getInstance().DressupInfos(data); a3_runestone._instance.DressUp(dat, dat.id); } } else //脱下 { if (a3_runestone._instance != null) { a3_runestone._instance.DressDown(data["part_id"]); } } break; case 2: if (data.ContainsKey("fushi_stamina")) { A3_RuneStoneModel.getInstance().nowStamina(data["fushi_stamina"]); } if (data.ContainsKey("fushi_level")) { if (a3_runestone._instance != null && data["fushi_level"] != A3_RuneStoneModel.getInstance().nowlv) { a3_runestone._instance.RefreScrollLv(data["fushi_level"]); } A3_RuneStoneModel.getInstance().nowLv(data["fushi_level"]); } if (data.ContainsKey("fushi_exp")) { A3_RuneStoneModel.getInstance().nowExp(data["fushi_exp"]); } dispatchEvent(GameEvent.Create(INFOS, this, data)); break; case 3: if (a3_runestonetip._instance != null) { if (a3_BagModel.getInstance().getItems().ContainsKey(data["id"])) { a3_BagItemData b = a3_BagModel.getInstance().getItems()[data["id"]]; b.ismark = data["mark"]; a3_BagModel.getInstance().addItem(b); } if (a3_bag.isshow) { a3_bag.isshow.refreshMarkRuneStones(data["id"]); } if (a3_runestone._instance != null) { a3_runestone._instance.RefreshMark(data["id"], data["mark"]); } } break; default: Globle.err_output(data["res"]); break; } }
void showInfos(GameObject contain, Dictionary <int, GameObject> dic) { if (dic == null) { return; } List <GameObject> list_item; foreach (int id in dic.Keys) { //等级锁 if (dic[id].transform.FindChild("lock") != null) { Text txt_lock = dic[id].transform.FindChild("lock").GetComponent <Text>(); txt_lock.text = ContMgr.getCont("a3_runestone_lv") + dic_allrune_data[id].stone_level + ContMgr.getCont("a3_runestone_oplock"); txt_lock.gameObject.SetActive(dic_allrune_data[id].stone_level >= A3_RuneStoneModel.getInstance().nowlv ? true : false); } //选中图片 if (dic[id].transform.FindChild("this") != null) { } //icon GameObject icon = IconImageMgr.getInstance().createA3ItemIcon(a3_BagModel.getInstance().getItemDataById((uint)id), false, -1, 0.6f); icon.transform.SetParent(dic[id].transform.FindChild("icon").transform, false); //name Text txt_name = dic[id].transform.FindChild("name").GetComponent <Text>(); txt_name.text = dic_allrune_data[id].item_name; //材料显示 GameObject item1 = dic[id].transform.FindChild("1").gameObject; GameObject item2 = dic[id].transform.FindChild("2").gameObject; list_item = new List <GameObject> { item1, item2 }; item2.SetActive(dic_allrune_data[id].compose_data.Count > 1 ? true : false); for (int i = 0; i < dic_allrune_data[id].compose_data.Count; i++) { string file = a3_BagModel.getInstance().getItemDataById((uint)dic_allrune_data[id].compose_data[i].id).file; list_item[i].transform.FindChild("icon").GetComponent <Image>().sprite = GAMEAPI.ABUI_LoadSprite(file); list_item[i].transform.FindChild("num").GetComponent <Text>().text = a3_BagModel.getInstance().getItemNumByTpid((uint)dic_allrune_data[id].compose_data[i].id) + "/" + dic_allrune_data[id].compose_data[i].num; } } commonScroview(contain, dic.Keys.Count); }
void ClosechoseOnClick(GameObject go, int type) { if (go == null) { lv_type = 0; quality_type = 0; name_type = 0; /*type * 1:合成 * 2:list */ string quan = ContMgr.getCont("quan"); if (type == 1) { compose_lv_txt.text = quan; compose_quality_txt.text = quan; compose_name_txt.text = quan; } else if (type == 2) { list_lv_txt.text = quan; list_quality_txt.text = quan; list_name_txt.text = quan; } } else { go.transform.parent.transform.DOScaleY(0, 0.1f); imageInstanceid = (uint)go.GetInstanceID(); if (imageInstanceid == old_imageInstanceid) { return; } old_imageInstanceid = imageInstanceid; string str = go.transform.FindChild("Text").GetComponent <Text>().text; GameObject obj = go.transform.parent.parent.parent.gameObject; obj.transform.FindChild("chose").GetComponent <Text>().text = str; switch (obj.name) { case "lv": lv_type = int.Parse(go.name); break; case "quality": quality_type = int.Parse(go.name); break; case "name": name_type = int.Parse(go.name); break; default: break; } } if (type == 1) { RefreshRunes(contain_compose_obj, image_compose_obj, dic_compose_showobjs, A3_RuneStoneModel.getInstance().nowlv); } else if (type == 2) { RefreshRunes(contain_list_obj, image_list_obj, dic_list_showobjs); } }