/// <summary> /// 安全移除所有list中对象 /// 封装了对list内button事件的移除 /// </summary> /// <param name="_list"></param> /// <param name="_callback"></param> public static void SafeRemoveChildrenToPool(this GList _list, Action <object> _callback = null) { if (null == _list) { return; } // 清空list的中button子对象的事件 var children = _list.GetChildren(); if (null != children && children.Length > 0) { for (int index = 0; index < children.Length; index++) { var child = children[index]; if (null == child) { continue; } if (null != _callback) { _callback(child.data); } child.data = null; if (true == child is GButton) { child.RemoveEventListeners(); } } } _list.RemoveChildrenToPool(); }
private void Item_Render(int index, GObject go) { ComCard cc = go.asCom.GetChild("n0") as ComCard; cc.SetData(ld [index]); cc.RemoveEventListeners(); cc.onClick.Add(() => { chatModel.support_Id = ld [index].ToString(); GObject[] os = list.GetChildren(); foreach (GObject oo in os) { if (go == oo) { oo.asCom.GetController("c1").selectedIndex = 1; } else { oo.asCom.GetController("c1").selectedIndex = 0; } } }); }
public PackageList(GObject obj,CommonPackage package) { CellList = obj.asList; var sel = from cellCom in CellList.GetChildren() select new PackageCell(cellCom.asCom); _Cells = sel.ToArray(); _Package = package; _Package.OnItemChanged += UpdateCell; CellList.numItems = _Package.Capacity; }
private bool getGoods(Goods goods) { GList goodsList = goods.type == "bullet" ? mulGoodsList : sinGoodsList; GObject[] goodsButton = goodsList.GetChildren(); foreach (GObject obj in goodsButton) { GButton button = (GButton)obj; string goodsUrl = goods.icon; if (!goods.icon.StartsWith("ui")) { goodsUrl = UIPackage.GetItemURL("BattleCity8102", "goods-" + goods.icon); } if (button.icon == goodsUrl) { int count = int.Parse(button.GetChild("countTextField").asTextField.text); count += goods.count; button.GetChild("countTextField").asTextField.text = count + ""; return(true); } } GButton btn = chooseEmptyIndex(goods); if (btn == null) { Debug.Log("背包满"); // 播放提示动效 playAlert("背包已满"); return(false); } btn.visible = true; btn.title = goods.type; // 判断icon是否为具体路径 string url = goods.icon; if (!url.StartsWith("ui")) { url = UIPackage.GetItemURL("BattleCity8102", "goods-" + goods.icon); } btn.icon = url; btn.GetChild("descriptionTextField").asTextField.text = goods.description; btn.GetChild("countTextField").asTextField.text = goods.count + ""; btn.GetChild("nameTextField").asTextField.text = goods.goodsName; btn.GetChild("coldDownTextField").asTextField.text = goods.coldDownTime + ""; return(true); }
// events. private void OnEnterClicked() { foreach (var obj in ConfigList.GetChildren()) { var item = obj.asButton; var type = item.GetController("type"); var mod = item.GetChild("mod").text; var id = item.GetChild("id").text; if (id != "Title") { var config = ListItems[mod][id]; switch (type.selectedIndex) { case 1: var cb = (CheckBox)config; var checkbox = item.GetChild("cb").asButton; cb.Checked = checkbox.selected; break; case 2: var ip = (Input)config; ip.Value = item.GetChild("ip").asLabel.text; break; case 3: var dd = (DropDown)config; var dropdown = item.GetChild("dd").asComboBox; dd.Value = dropdown.value; break; default: break; } } } OnConfigClicked(); Hide(); }
public int GetBuffCount() { return(m_BuffList.GetChildren().Length); }
// Use this for initialization void Start() { battleComponent = GetComponent <UIPanel>().ui; boxButton = battleComponent.GetChild("boxButton").asButton; boxButton.visible = false; boxButton.onClick.Add(() => { boxWindow = new BoxWindow(box); boxWindow.Show(); }); // 坦克将碰撞到的盒子传递过来,通过判断盒子是否为空表示远离或接近 Box.boxDelegate += (Box box) => { boxButton.visible = box == null ? false : true; // 远离盒子时关闭窗口 if (!boxButton.visible && boxWindow != null) { boxWindow.Hide(); boxWindow.Dispose(); boxWindow = null; boxButton.selected = false; } this.box = box; }; Tank.goodsDelegate += (List <Goods> goodsList) => { // 清除旧窗口 if (goodsWindow != null) { goodsWindow.Hide(); goodsWindow.Dispose(); goodsWindow = null; } // 新建新窗口 createGoodsWindow(goodsList); }; // 注册拖拽事件 GGroup footer = battleComponent.GetChild("footer").asGroup; mulGoodsList = battleComponent.GetChildInGroup(footer, "buttleList").asList; sinGoodsList = battleComponent.GetChildInGroup(footer, "goodsList").asList; GObject[] mulGoodsButtons = mulGoodsList.GetChildren(); GObject[] sinGoodsButtons = sinGoodsList.GetChildren(); getGoodsDelegate += getGoods; dragIcon = battleComponent.GetChild("dragIcon").asLoader; touchID = -1; bulletEmptyList = new List <GButton>(); medecineEmptyList = new List <GButton>(); for (int i = 0; i < mulGoodsButtons.Length; i++) { GButton btn = (GButton)mulGoodsButtons[i]; btn.visible = false; addDragAndDrop(btn); bulletEmptyList.Add(btn); } for (int i = 0; i < sinGoodsButtons.Length; i++) { GButton btn = (GButton)sinGoodsButtons[i]; btn.visible = false; addDragAndDrop(btn); // 包含药品、道具 medecineEmptyList.Add(btn); } coldDownTable = new Hashtable(); bulletColdDownTime = 0; medecineColdDownTime = 0; }
/// <summary> /// 响应手牌点击事件的函数 /// </summary> public void OnClickHandCard(EventContext context) { // 如果不是玩家回合,则无法使用卡牌 if (!Gameplay.Instance().roundProcessController.IsPlayerRound()) { return; } // int index = _handcardList.GetChildIndex(context.data as GObject); // BaseCard baseCardReference = handcardInstanceList[index].GetComponent<BaseCard>(); // if (!Player.Instance().CanConsumeAp(baseCardReference.cost)) // { // Debug.Log("Ran out of AP, cant use this one"); // return; // } GObject item = context.data as GObject; // 确认当前点击的卡牌和上次点击的不同,此时表明用户想使用这张卡牌 if (item != lastClicked) { // 改变记录 lastClicked = item; // 动效 //DoSpecialEffect(item); // 设置当前选中的卡牌 CardManager.Instance().SetSelectingCard(_handcardList.GetChildIndex(item)); } else // 此时用户点击的牌和上次相同,表示用户想取消使用 { // 恢复原大小 foreach (GObject litem in _handcardList.GetChildren()) { StartCoroutine(FancyHandCardEffect(litem, 1)); } // 重置上次选择项 lastClicked = null; // 调用取消使用方法 CardManager.Instance().CancleUseCurrentCard(); // 结束函数执行,因为用户取消使用 return; } CardManager.Instance().OnUseCurrentCard(); // // 若是效果牌 // if (baseCardReference.type.Equals("Order")) // { //// // 判断使用结果 //// if (baseCardReference.Use()) //// { //// // 使用成功则移除手牌 //// CardManager.Instance().RemoveCardToCd(index); //// return; //// } // // baseCardReference.Use(); // // } // else // { // if (Gameplay.Instance().gamePlayInput.IsSelectingCard == false) // { // Gameplay.Instance().gamePlayInput. OnPointerDownUnitCard(handcardInstanceList[index]); // BattleMap.BattleMap.Instance().IsColor = true; // } // } }