internal void TrySpawnBiped(Biped biped, Vector3 position) { if (AllBipedsSpawned) { return; } if (Physics2D.OverlapCircle(position, Globals.singleton.bipeds.bipedSpawnCheckRadius, ~Globals.singleton.bipeds.bipedSpawnCheckIgnoredLayers) != null) { return; } if (Time.time < _nextAllowBipedSpawnTime) { return; } _nextAllowBipedSpawnTime = Time.time + Globals.singleton.bipeds.bipedSpawnNextDelay; CreateBiped(biped, position); if (AllBipedsSpawned) { _controller.AllowMovement = true; TrySetCameraTarget(); UIEventDelegate.Invoke(SandboxEvent.AllBipedsSpawned); } }
public void CheckTriggerData(uint guideId, UIEventDelegate dlg) { GuideDefine.LocalGuideData localGuideData = null; if (DataManager.Manager <GuideManager>().TryGetGuideLocalData(ID, out localGuideData)) { if (null != localGuideData.GuideTargetObj) { GuideTrigger trigger = localGuideData.GuideTargetObj.GetComponent <GuideTrigger>(); if (null == trigger) { trigger = localGuideData.GuideTargetObj.AddComponent <GuideTrigger>(); trigger.InitTrigger(localGuideData.ID, dlg); } else { trigger.AddTriggerId(localGuideData.ID); } //如果没有事件触发,需要手动添加碰撞器触发引导事件 if (localGuideData.TriggerEventType == GuideDefine.GuideTriggerEventType.None) { BoxCollider boxCollider = localGuideData.GuideTargetObj.GetComponent <BoxCollider>(); if (null == boxCollider) { boxCollider = localGuideData.GuideTargetObj.AddComponent <BoxCollider>(); boxCollider.size = localGuideData.GuideTargetObjLocalBounds.size; boxCollider.center = localGuideData.GuideTargetObjLocalBounds.center; } } } } }
public void ListenEvent(string name, UIEventDelegate callback) { var signal = GetEventSignal(name); if (signal != null) { signal.Delegates += callback; } }
private void OnDestroy() { onClick = null; onDown = null; onEnter = null; onExit = null; onUp = null; onSelect = null; onUpdateSelect = null; onDeSelect = null; onDrag = null; onDragEnd = null; onDrop = null; onScroll = null; onMove = null; }
public virtual void FireEvent(string eventName, RoutingStrategyEnum routingStrategy) { if (routingStrategy == RoutingStrategyEnum.Tunnel) { // Tunnel strategy: All parents first, then this element UIElement parent = VisualParent as UIElement; if (parent != null) { parent.FireEvent(eventName, routingStrategy); } } UIEventDelegate dlgt = EventOccured; if (dlgt != null) { dlgt(eventName); } switch (routingStrategy) { case RoutingStrategyEnum.Bubble: // Bubble strategy: First this element, then all parents UIElement parent = VisualParent as UIElement; if (parent != null) { parent.FireEvent(eventName, routingStrategy); } break; case RoutingStrategyEnum.VisualTree: // VisualTree strategy: First this element, then all children foreach (UIElement child in GetChildren()) { child.FireEvent(eventName, routingStrategy); } break; } }
protected override void OnLoading() { base.OnLoading(); GameObject preObj = UIManager.GetResGameObj(GridID.Uiitemshowgrid); GameObject cloneObj = null; UIEventDelegate dlg = (eventType, data, param) => { if (eventType == UIEventType.Click) { TipsManager.Instance.ShowItemTips(evolveMuhonId); } }; if (null != preObj) { if (null == mShowGrid && null != m_trans_InfoGridRoot) { cloneObj = NGUITools.AddChild(m_trans_InfoGridRoot.gameObject, preObj); if (null != cloneObj) { mShowGrid = cloneObj.GetComponent <UIItemShowGrid>(); if (null == mShowGrid) { mShowGrid = cloneObj.AddComponent <UIItemShowGrid>(); } if (null != mShowGrid && !mShowGrid.Visible) { mShowGrid.SetVisible(true); mShowGrid.RegisterUIEventDelegate(dlg); } } } } Transform tempTrans = null; if (null != m_trans_BaseAttr) { m_lstBaseAttr = new List <Transform>(); for (int i = 1; i <= 4; i++) { tempTrans = m_trans_BaseAttr.Find(i.ToString()); if (null != tempTrans) { m_lstBaseAttr.Add(tempTrans); } } } if (null != m_trans_AdditiveAttr) { m_lstAddtiveAttr = new List <Transform>(); for (int i = 1; i <= 5; i++) { tempTrans = m_trans_AdditiveAttr.Find(i.ToString()); if (null != tempTrans) { m_lstAddtiveAttr.Add(tempTrans); } } } if (null != m_widget_GapWidget) { gapWidget = m_widget_GapWidget.gameObject.transform.localPosition; } }
/// <summary> /// 设置非强制引导数据 /// </summary> /// <param name="panelDepath"></param> /// <param name="id"></param> public void SetData(int panelDepth, uint id, UIEventDelegate dlg) { Init(); if (!Visible) { SetVisible(true); } this.m_uint_id = id; GuideDefine.LocalGuideData localGuideData = null; SetDepth(panelDepth); if (DataManager.Manager <GuideManager>().TryGetGuideLocalData(ID, out localGuideData)) { //设置位置 SetPos(out m_v3ContentOffset); //显示内容 UILabel tempLab = null; RefreshHumanImage(ref tempLab); if (null != tempLab) { tempLab.text = localGuideData.Des; } if (null != localGuideData.GuideTargetObj) { m_sourcePos = localGuideData.GuideTargetObj.transform.position; GuideTrigger trigger = localGuideData.GuideTargetObj.GetComponent <GuideTrigger>(); if (null == trigger) { trigger = localGuideData.GuideTargetObj.AddComponent <GuideTrigger>(); trigger.InitTrigger(localGuideData.ID, dlg); } else { trigger.AddTriggerId(localGuideData.ID); } //如果没有事件触发,需要手动添加碰撞器触发引导事件 if (localGuideData.TriggerEventType == GuideDefine.GuideTriggerEventType.None) { BoxCollider boxCollider = localGuideData.GuideTargetObj.GetComponent <BoxCollider>(); if (null == boxCollider) { boxCollider = localGuideData.GuideTargetObj.AddComponent <BoxCollider>(); boxCollider.size = localGuideData.GuideTargetObjLocalBounds.size; boxCollider.center = localGuideData.GuideTargetObjLocalBounds.center; } } } if (null != m_particle) { m_effectRoot.transform.localPosition = Vector3.zero; m_particle.ReleaseParticle(); m_particle.AddParticle(50042, endCallback: OnParticleDispalyEffectComplete); } //if (null != m_particle && !m_bAddEffect) //{ // m_particle.AddParticle(50041); // m_bAddEffect = true; //} SetVisible(false); SetVisible(true); } }
/// <summary> /// 选择圣魂操作 /// </summary> private void OnSelectEvolveMuhon(EquipDefine.AttrIndex attrIndex) { if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.ItemChoosePanel)) { return; } Muhon currentData = Data; if (null == currentData) { TipsManager.Instance.ShowTips(LocalTextType.Local_TXT_Soul_ChooseEvolveMuhonTips); return; } if (!currentData.IsMaxLv) { TipsManager.Instance.ShowTips(LocalTextType.Local_TXT_Soul_MuhonNeedMaxLvTips); return; } //筛选满足条件的圣魂 List <uint> data = new List <uint>(); List <uint> filterTypes = new List <uint>(); filterTypes.Add((uint)GameCmd.EquipType.EquipType_SoulOne); List <uint> muhonList = imgr.GetItemByType(GameCmd.ItemBaseType.ItemBaseType_Equip, filterTypes, GameCmd.PACKAGETYPE.PACKAGETYPE_MAIN); //过滤 if (null != muhonList && muhonList.Count != 0) { for (int i = 0; i < muhonList.Count; i++) { if (currentData.IsMatchEvolve(muhonList[i], false)) { data.Add(muhonList[i]); } } } if (data.Count == 0) { TipsManager.Instance.ShowTips(tmgr.GetLocalFormatText(LocalTextType.Soul_Star_1 , tmgr.GetMuhonStarName(currentData.StartLevel))); return; } data.Sort((left, right) => { Muhon leftM = imgr.GetBaseItemByQwThisId <Muhon>(left); Muhon rightM = imgr.GetBaseItemByQwThisId <Muhon>(right); if (currentData.IsMatchEvolve(rightM, true)) { if (currentData.IsMatchEvolve(leftM, true)) { return(rightM.Level - leftM.Level); } return(1); } else if (currentData.IsMatchEvolve(leftM, true)) { return(-1); } else { return(rightM.Level - leftM.Level); } return(0); }); Dictionary <EquipDefine.AttrIndex, uint> curSelectDeputyMuhon = new Dictionary <EquipDefine.AttrIndex, uint>(); Dictionary <uint, EquipDefine.AttrIndex> curSelectDeputyMuhonRS = new Dictionary <uint, EquipDefine.AttrIndex>(); List <uint> selectDeputyIds = new List <uint>(); var enumerator = m_dicSelectMuhonDeputy.GetEnumerator(); while (enumerator.MoveNext()) { curSelectDeputyMuhon.Add(enumerator.Current.Key, enumerator.Current.Value); curSelectDeputyMuhonRS.Add(enumerator.Current.Value, enumerator.Current.Key); } UILabel desLabel = null; bool needRefreshLabel = false; Action <UILabel> desLabAction = (des) => { desLabel = des; if (null != desLabel) { desLabel.text = tmgr.GetLocalFormatText(LocalTextType.Local_TXT_Soul_ChooseNum, curSelectDeputyMuhon.Count, currentData.EvolveNeedMuhonNum); } }; UIEventDelegate eventDlg = (eventTye, grid, param) => { if (eventTye == UIEventType.Click) { UIWeaponSoulInfoSelectGrid tempGrid = grid as UIWeaponSoulInfoSelectGrid; if (curSelectDeputyMuhonRS.ContainsKey(tempGrid.QWThisId)) { curSelectDeputyMuhon.Remove(curSelectDeputyMuhonRS[tempGrid.QWThisId]); curSelectDeputyMuhonRS.Remove(tempGrid.QWThisId); tempGrid.SetHightLight(false); } else if (currentData.IsMatchEvolve(tempGrid.QWThisId)) { needRefreshLabel = true; if (curSelectDeputyMuhon.Count < currentData.EvolveNeedMuhonNum) { if (!curSelectDeputyMuhon.ContainsKey(attrIndex)) { curSelectDeputyMuhonRS.Add(tempGrid.QWThisId, attrIndex); curSelectDeputyMuhon.Add(attrIndex, tempGrid.QWThisId); } else { for (EquipDefine.AttrIndex i = EquipDefine.AttrIndex.None + 1; i < EquipDefine.AttrIndex.Max; i++) { if (!Enum.IsDefined(typeof(EquipDefine.AttrIndex), i)) { continue; } if (((int)i) > currentData.EvolveNeedMuhonNum) { break; } if (curSelectDeputyMuhon.ContainsKey(i)) { continue; } curSelectDeputyMuhonRS.Add(tempGrid.QWThisId, i); curSelectDeputyMuhon.Add(i, tempGrid.QWThisId); break; } } tempGrid.SetHightLight(true); } } else { Muhon selectMuhon = imgr.GetBaseItemByQwThisId <Muhon>(tempGrid.QWThisId); if (null != selectedMuhonId) { string txt = ""; if (selectMuhon.IsActive && !selectMuhon.IsMaxLv) { txt = tmgr.GetLocalText(LocalTextType.Local_TXT_Soul_NotMatchLvTips); } else if (!selectMuhon.IsActive && selectMuhon.IsMaxLv) { txt = tmgr.GetLocalText(LocalTextType.Local_TXT_Soul_UnactiveNotice); } else if (!selectMuhon.IsActive && !selectMuhon.IsMaxLv) { txt = tmgr.GetLocalText(LocalTextType.Local_TXT_Soul_NotMatchLvActiveTips); } TipsManager.Instance.ShowTips(txt); } } if (null != desLabel && needRefreshLabel) { desLabel.text = tmgr.GetLocalFormatText(LocalTextType.Local_TXT_Soul_ChooseNum, curSelectDeputyMuhon.Count, currentData.EvolveNeedMuhonNum); } } }; ItemChoosePanel.ItemChooseShowData showData = new ItemChoosePanel.ItemChooseShowData() { createNum = data.Count, title = tmgr.GetLocalText(LocalTextType.Local_TXT_Soul_ChooseMuhon), cloneTemp = UIManager.GetResGameObj(GridID.Uiweaponsoulinfoselectgrid) as GameObject, onChooseCallback = () => { var enumeratorSelect = curSelectDeputyMuhon.GetEnumerator(); m_dicSelectMuhonDeputy.Clear(); while (enumeratorSelect.MoveNext()) { m_dicSelectMuhonDeputy.Add(enumeratorSelect.Current.Key, enumeratorSelect.Current.Value); } UpdateEvolve(Data); }, gridCreateCallback = (obj, index) => { if (index >= data.Count) { Engine.Utility.Log.Error("OnSelectInvokeEquip error,index out of range"); } else { Muhon itemData = imgr.GetBaseItemByQwThisId <Muhon>(data[index]); if (null == itemData) { Engine.Utility.Log.Error("OnSelectInvokeEquip error,get itemData qwThisId:{0}", data[index]); } else { UIWeaponSoulInfoSelectGrid weaponsoulGrid = obj.GetComponent <UIWeaponSoulInfoSelectGrid>(); if (null == weaponsoulGrid) { weaponsoulGrid = obj.AddComponent <UIWeaponSoulInfoSelectGrid>(); } weaponsoulGrid.RegisterUIEventDelegate(eventDlg); weaponsoulGrid.SetGridViewData(itemData.QWThisID, curSelectDeputyMuhonRS.ContainsKey(data[index]) , currentData.IsMatchEvolve(data[index]), false); } } }, desPassCallback = desLabAction, }; DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.ItemChoosePanel, data: showData); }
/// <summary> /// 创建圣魂经验丹格子 /// </summary> private void CreateMuhonExpGrid() { if (null == m_trans_UIMuhonExpGrid) { return; } List <uint> muhonExpItemsId = emgr.MuhonExpItemIds; if (!mbCreateMuhonExp) { m_lst_expGrids = new List <UIMuhonExpGrid>(); if (null == muhonExpItemsId || muhonExpItemsId.Count == 0) { Engine.Utility.Log.Error("获取圣魂经验丹id列表Error"); return; } muhonExpItemsId.Sort(); if (null != m_grid_PromoteExpRoot) { UIEventDelegate dlg = (eventType, data, param) => { switch (eventType) { case UIEventType.Click: case UIEventType.LongPressing: { UIMuhonExpGrid commonGrid = data as UIMuhonExpGrid; UserMuhonExp(commonGrid.BaseId); } break; } }; Transform tempTrans = null; UIMuhonExpGrid expGrid = null; GameObject cloneObj = null; for (int i = 0; i < muhonExpItemsId.Count; i++) { cloneObj = NGUITools.AddChild(m_grid_PromoteExpRoot.gameObject, m_trans_UIMuhonExpGrid.gameObject); if (null == cloneObj) { continue; } tempTrans = cloneObj.transform; if (null == tempTrans) { continue; } tempTrans.name = i.ToString(); expGrid = tempTrans.GetComponent <UIMuhonExpGrid>(); if (null == expGrid) { expGrid = tempTrans.gameObject.AddComponent <UIMuhonExpGrid>(); } expGrid.RegisterUIEventDelegate(dlg); expGrid.SetGridData(muhonExpItemsId[i], 1); m_lst_expGrids.Add(expGrid); } m_grid_PromoteExpRoot.Reposition(); } mbCreateMuhonExp = true; } if (null != m_lst_expGrids) { for (int i = 0, max = m_lst_expGrids.Count; i < max; i++) { m_lst_expGrids[i].SetGridData(muhonExpItemsId[i], 1); } } }
public void RegisterUIEventDelegate(UIEventDelegate dlg) { uiEventDelegate = dlg; }
protected override void Reset() { Delegates = null; }
/// <summary> /// 点击属性提升符石选择 /// </summary> private void OnSelectProcessRuneStone() { if (!IsSelectEquipAttr() || DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.ItemChoosePanel)) { TipsManager.Instance.ShowTips("请勾选需要提升的属性"); return; } GameCmd.PairNumber selectAttrPair = GetEquipAttrByIndex((int)m_em_selectEquipAttrIndex); if (null == selectAttrPair) { Engine.Utility.Log.Error("Get AttrPair faield,promoteid:{0}", 0); return; } uint selectAttrGrade = emgr.GetAttrGrade(selectAttrPair); bool filterEqual = IsProccessMode(ForgingProccessMode.Promote); //筛选满足条件符石 List <uint> baseIdList = emgr.GetMatchProperyRunestone(selectAttrPair, filterEqual); UILabel desLabel = null; Action <UILabel> desLabAction = (des) => { desLabel = des; if (null != desLabel) { if (filterEqual) { desLabel.text = m_tmgr.GetLocalText(LocalTextType.Local_TXT_Rune_1); } else { desLabel.text = m_tmgr.GetLocalText(LocalTextType.Local_TXT_Rune_2); } } }; uint tempSelectGemRuneStoneId = 0; UIRSInfoSelectGrid selectGemRuneStoneGrid = null; UIEventDelegate eventDlg = (eventTye, grid, param) => { if (eventTye == UIEventType.Click) { UIRSInfoSelectGrid tempGrid = grid as UIRSInfoSelectGrid; RuneStone tempRs = DataManager.Manager <ItemManager>() .GetTempBaseItemByBaseID <RuneStone>(tempGrid.BaseId, ItemDefine.ItemDataType.RuneStone); if (tempSelectGemRuneStoneId == tempGrid.BaseId) { tempSelectGemRuneStoneId = 0; tempGrid.SetHightLight(false); } else if (tempGrid.BaseId != 0) { bool enable = (!filterEqual) ? (tempRs.Grade >= selectAttrGrade) : (tempRs.Grade > selectAttrGrade); if (enable) { tempSelectGemRuneStoneId = tempGrid.BaseId; if (null != selectGemRuneStoneGrid) { selectGemRuneStoneGrid.SetHightLight(false); } tempGrid.SetHightLight(true); selectGemRuneStoneGrid = tempGrid; } else if (filterEqual) { TipsManager.Instance.ShowTips(LocalTextType.Rune_Promote1); } else { TipsManager.Instance.ShowTips(LocalTextType.Rune_Eliminate1); } } } }; ItemChoosePanel.ItemChooseShowData showData = new ItemChoosePanel.ItemChooseShowData() { createNum = baseIdList.Count, title = "选择符石", nullTips = "您未拥有该类符石", cloneTemp = m_trans_UIRSInfoSelectGrid.gameObject, onChooseCallback = () => { if (tempSelectGemRuneStoneId != m_uint_selectRSBaseId) { m_uint_selectRSBaseId = tempSelectGemRuneStoneId; UpdateProccess(Data); } }, gridCreateCallback = (obj, index) => { if (index >= baseIdList.Count) { Engine.Utility.Log.Error("OnSelectPromoteRuneStone error,index out of range"); } else { table.ItemDataBase tempItemDataBase = imgr.GetLocalDataBase <table.ItemDataBase>(baseIdList[index]); table.RunestoneDataBase tempRuneStoneDataBase = imgr.GetLocalDataBase <table.RunestoneDataBase>(baseIdList[index]); if (null == tempItemDataBase || null == tempRuneStoneDataBase) { Engine.Utility.Log.Error("OnSelectPromoteRuneStone error,get itemdatabase or tempItemDataBase null baseid:{0}", baseIdList[index]); } else { UIRSInfoSelectGrid gemRuneStoneGrid = obj.GetComponent <UIRSInfoSelectGrid>(); if (null == gemRuneStoneGrid) { gemRuneStoneGrid = obj.AddComponent <UIRSInfoSelectGrid>(); } gemRuneStoneGrid.RegisterUIEventDelegate(eventDlg); RuneStone rs = DataManager.Manager <ItemManager>() .GetTempBaseItemByBaseID <RuneStone>(baseIdList[index], ItemDefine.ItemDataType.RuneStone); bool select = (baseIdList[index] == m_uint_selectRSBaseId); bool enable = (!filterEqual) ? (rs.Grade >= selectAttrGrade) : (rs.Grade > selectAttrGrade); gemRuneStoneGrid.SetGridViewData(baseIdList[index], select, enable); if (select) { selectGemRuneStoneGrid = gemRuneStoneGrid; tempSelectGemRuneStoneId = baseIdList[index]; } } } }, desPassCallback = desLabAction, }; DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.ItemChoosePanel, data: showData); }
/// <summary> /// 初始化合成组件 /// </summary> void InitCompoundWidgets() { if (IsInitStatus(ForgingPanelMode.Compound)) { return; } SetInitStatus(ForgingPanelMode.Compound, true); Transform tempTs = null; GameObject cloneObj = null; //組件 if (null != m_trans_CompoundGrowShowRoot && null == m_compoundGrowShow) { tempTs = UIManager.GetObj(GridID.Uiitemgrowshowgrid); if (null != tempTs) { Util.AddChildToTarget(m_trans_CompoundGrowShowRoot, tempTs); cloneObj = tempTs.gameObject; if (null != cloneObj) { m_compoundGrowShow = cloneObj.GetComponent <UIItemGrowShowGrid>(); if (null == m_compoundGrowShow) { m_compoundGrowShow = cloneObj.AddComponent <UIItemGrowShowGrid>(); } m_compoundGrowShow.RegisterUIEventDelegate(OnUIEventCallback); } } } if (null != m_trans_CompoundMainAttrRoot) { m_compoundAttrTransData = new AttrTransData[5]; AttrTransData tempAttrData = null; StringBuilder strBuilder = new StringBuilder(); for (int i = 0, max = m_compoundAttrTransData.Length; i < max; i++) { tempAttrData = new AttrTransData(); strBuilder.Remove(0, strBuilder.Length); strBuilder.Append(i + 1); tempAttrData.Root = m_trans_CompoundMainAttrRoot.Find(strBuilder.ToString()); if (null == tempAttrData.Root) { continue; } strBuilder.Append("/Content/Grade/Grade"); tempTs = m_trans_CompoundMainAttrRoot.Find(strBuilder.ToString()); if (null != tempTs) { tempAttrData.Grade = tempTs.GetComponent <UILabel>(); } strBuilder.Remove(0, strBuilder.Length); strBuilder.Append(i + 1); strBuilder.Append("/Content/Des"); tempTs = m_trans_CompoundMainAttrRoot.Find(strBuilder.ToString()); if (null != tempTs) { tempAttrData.Des = tempTs.GetComponent <UILabel>(); } m_compoundAttrTransData[i] = tempAttrData; } } //祝福 if (null != m_trans_ZFRoot && null == m_zfGrowShow) { tempTs = m_trans_UIZFGrid; cloneObj = tempTs.gameObject; if (null != tempTs) { Util.AddChildToTarget(m_trans_ZFRoot, tempTs); if (null != cloneObj) { m_zfGrowShow = cloneObj.GetComponent <UIZFGrid>(); if (null == m_zfGrowShow) { m_zfGrowShow = cloneObj.AddComponent <UIZFGrid>(); } } m_zfGrowShow.RegisterUIEventDelegate(OnUIEventCallback); } } //副武器初始化 if (null != m_trans_CompoundDeputyContent) { m_lst_equipSelects = new List <UIEquipDeputySelectGrid>(); UIEventDelegate dpdAction = (eventType, obj, param) => { if (eventType == UIEventType.Click) { UIEquipDeputySelectGrid esg = obj as UIEquipDeputySelectGrid; if (null != param && param is bool) { UnloadCompoundDeputyEquipFill(esg.Index); } else { if (!IsCompoundDeputyEquipFill(esg.Index)) { OnSelectCompoundDeputy(esg.Index); } } } }; UIEquipDeputySelectGrid dps = null; string tempStr = ""; for (int i = 0; i < 3; i++) { tempStr = string.Format("EDSG{0}", i + 1); tempTs = m_trans_CompoundDeputyContent.Find(tempStr); if (null == tempTs) { continue; } cloneObj = tempTs.gameObject; if (null != cloneObj) { dps = cloneObj.GetComponent <UIEquipDeputySelectGrid>(); if (null == dps) { dps = cloneObj.AddComponent <UIEquipDeputySelectGrid>(); } dps.SetIndex(i); dps.RegisterUIEventDelegate(dpdAction); m_lst_equipSelects.Add(dps); } } } ResetCompound(); }
/// <summary> /// 选择合成副装备 /// </summary> /// <param name="gridIndex">当前点击副装备索引</param> private void OnSelectCompoundDeputy(int gridIndex) { if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.ItemChoosePanel)) { return; } Equip data = Data; if (null == data) { TipsManager.Instance.ShowTips("没有可用的主装备"); return; } if (!emgr.IsEquipCanCmpound(data.QWThisID)) { TipsManager.Instance.ShowTips("当前装备无法进行合成操作"); return; } //筛选满足条件的副装备 List <uint> matchDeputyEquips = new List <uint>(); matchDeputyEquips.AddRange(emgr.GetCompoundMatchEquip(selectEquipId)); if (matchDeputyEquips.Count == 0) { TipsManager.Instance.ShowTips("没有找到满足合成条件的副装备"); return; } //临时选中副装备列表 List <uint> tempSelectdDeputyEquipList = new List <uint>(); tempSelectdDeputyEquipList.AddRange(selectCompoundDeputyEquips); UILabel desLabel = null; Action <UILabel> desLabAction = (des) => { desLabel = des; if (null != desLabel) { desLabel.text = m_tmgr.GetLocalFormatText(LocalTextType.Local_TXT_Soul_ChooseNum , GetCompoundDeputyCount(tempSelectdDeputyEquipList), 3); } }; UIEventDelegate eventDlg = (eventTye, grid, param) => { if (eventTye == UIEventType.Click) { UIEquipInfoSelectGrid tempGrid = grid as UIEquipInfoSelectGrid; Equip tempEquip = imgr.GetBaseItemByQwThisId <Equip>(tempGrid.QWThisId); if (null != tempEquip) { if (tempEquip.CanCompound) { int selectNum = GetCompoundDeputyCount(tempSelectdDeputyEquipList); bool refreshLabel = false; if (tempSelectdDeputyEquipList.Contains(tempGrid.QWThisId)) { int clickIndex = tempSelectdDeputyEquipList.IndexOf(tempGrid.QWThisId); tempSelectdDeputyEquipList[clickIndex] = 0; tempGrid.SetHightLight(false); refreshLabel = true; } else if (selectNum < 3) { refreshLabel = true; if (tempSelectdDeputyEquipList[gridIndex] == 0) { tempSelectdDeputyEquipList[gridIndex] = tempGrid.QWThisId; } else { for (int i = 0; i < tempSelectdDeputyEquipList.Count; i++) { if (tempSelectdDeputyEquipList[i] == 0) { tempSelectdDeputyEquipList[i] = tempGrid.QWThisId; break; } } } tempGrid.SetHightLight(true); } if (null != desLabel && refreshLabel) { desLabel.text = desLabel.text = m_tmgr.GetLocalFormatText(LocalTextType.Local_TXT_Soul_ChooseNum , GetCompoundDeputyCount(tempSelectdDeputyEquipList), 3); } } else if (tempEquip.AdditionAttrCount == 0) { DataManager.Manager <EffectDisplayManager>().AddTips(m_tmgr.GetLocalText(LocalTextType.forging_compose_1)); } } } }; ItemChoosePanel.ItemChooseShowData showData = new ItemChoosePanel.ItemChooseShowData() { createNum = matchDeputyEquips.Count, title = "选择副装备", cloneTemp = UIManager.GetResGameObj(GridID.Uiequipinfoselectgrid) as GameObject, onChooseCallback = () => { selectCompoundDeputyEquips = tempSelectdDeputyEquipList; UpdateCompound(Data); }, gridCreateCallback = (obj, index) => { UIEquipInfoSelectGrid equipInfoGrid = obj.GetComponent <UIEquipInfoSelectGrid>(); if (null == equipInfoGrid) { equipInfoGrid = obj.AddComponent <UIEquipInfoSelectGrid>(); } Equip itemData = imgr.GetBaseItemByQwThisId <Equip>(matchDeputyEquips[index]); equipInfoGrid.RegisterUIEventDelegate(eventDlg); equipInfoGrid.SetGridViewData(itemData.QWThisID, selectCompoundDeputyEquips.Contains(itemData.QWThisID) , itemData.CompoundMaskEnable, itemData.AdditionAttrCount > 0); }, desPassCallback = desLabAction, }; DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.ItemChoosePanel, data: showData); }
/// <summary> /// 更新精炼辅助材料UI /// </summary> private void UpdateRefineAssistMaterialUI() { Equip data = Data; if (null == data) { return; } bool isMax = data.IsRefineMax; bool isCanRefine = data.CanRefine; bool needShow = isCanRefine && !isMax; if (null != m_trans_RefineAssist && m_trans_RefineAssist.gameObject.activeSelf != needShow) { m_trans_RefineAssist.gameObject.SetActive(needShow); } if (needShow) { if (null == m_lst_refineAssist) { m_lst_refineAssist = new List <UIItemAssistSelectGrid>(2); } List <uint> assistMaterials = new List <uint>(2); List <uint> assistMaterialsNum = new List <uint>(2); if (data.NextRefineDataBase.assistId1 != 0 && data.NextRefineDataBase.assistNum1 > 0) { assistMaterials.Add(data.NextRefineDataBase.assistId1); assistMaterialsNum.Add(data.NextRefineDataBase.assistNum1); } if (data.NextRefineDataBase.assistId2 != 0 && data.NextRefineDataBase.assistNum2 > 0 && !assistMaterials.Contains(data.NextRefineDataBase.assistId2)) { assistMaterials.Add(data.NextRefineDataBase.assistId2); assistMaterialsNum.Add(data.NextRefineDataBase.assistNum2); } UIEventDelegate dlg = (eventType, obj, param) => { if (eventType == UIEventType.Click) { if (obj is UIItemInfoGrid) { UIItemInfoGrid grid = obj as UIItemInfoGrid; if (grid.NotEnough && param != null && param is uint) { ShowItemGet((uint)param); } } else if (obj is UIItemAssistSelectGrid) { UIItemAssistSelectGrid grid = obj as UIItemAssistSelectGrid; if (param != null && param is bool) { bool select = (bool)param; SetSelectAssistMaterial(select, grid.BaseId); } } } }; GameObject preObj = UIManager.GetResGameObj(GridID.Uiitemassistselectgrid) as GameObject; GameObject cloneObj = null; UIItemAssistSelectGrid assistGrid = null; int size = Mathf.Max(assistMaterials.Count, m_lst_refineAssist.Count); for (int i = 0; i < size; i++) { if (i < assistMaterials.Count) { if (m_lst_refineAssist.Count > i) { assistGrid = m_lst_refineAssist[i]; } else if (null != preObj && null != m_grid_AssistGridContent) { cloneObj = NGUITools.AddChild(m_grid_AssistGridContent.gameObject, preObj); if (null != cloneObj) { assistGrid = cloneObj.GetComponent <UIItemAssistSelectGrid>(); if (null == assistGrid) { assistGrid = cloneObj.AddComponent <UIItemAssistSelectGrid>(); } if (null != assistGrid) { assistGrid.RegisterUIEventDelegate(dlg); m_lst_refineAssist.Add(assistGrid); } } } if (null != assistGrid) { uint dqcost = assistMaterialsNum[i] * DataManager.Manager <MallManager>().GetDQPriceByItem(assistMaterials[i]); if (!assistGrid.Visible) { assistGrid.SetVisible(true); } assistGrid.gameObject.name = i.ToString(); assistGrid.SetGridData(assistMaterials[i] , IsSelectAssistMaterial(assistMaterials[i]) , num: assistMaterialsNum[i] , useDQ: m_bool_refineAutoUseDQ , costNum: dqcost , mType: GameCmd.MoneyType.MoneyType_Coin); } } else if (i < m_lst_refineAssist.Count) { assistGrid = m_lst_refineAssist[i]; if (null != assistGrid && assistGrid.Visible) { assistGrid.SetVisible(false); } } } if (null != m_btn_UseDQToggleRefine) { UIToggle autoUseToggle = m_btn_UseDQToggleRefine.GetComponent <UIToggle>(); if (null != autoUseToggle) { autoUseToggle.value = m_bool_refineAutoUseDQ; } } //重置 if (assistMaterials.Count > 0 && null != m_grid_AssistGridContent) { m_grid_AssistGridContent.Reposition(); } } }
public void ListenEvent(string name, UIEventDelegate callback) { m_Binder.ListenEvent(name, callback); }
/// <summary> /// /// </summary> /// <param name="guideId">引导ID</param> /// <param name="dlg">委托</param> public void InitTrigger(uint guideId, UIEventDelegate dlg) { AddTriggerId(guideId); uiEventDelegate = dlg; }
/// <summary> /// 点击圣魂融合选择 /// </summary> private void OnSelectBlendMuhon() { if (DataManager.Manager <UIPanelManager>().IsShowPanel(PanelID.ItemChoosePanel)) { return; } Muhon itemData = Data; if (null == itemData) { TipsManager.Instance.ShowTips(LocalTextType.Local_TXT_Soul_ChooseBlendMuhonTips); return; } if (!emgr.IsItemHaveAdditiveAttrOrGemHole(itemData.QWThisID, false)) { TipsManager.Instance.ShowTips(LocalTextType.Local_TXT_Soul_ActiveTips); return; } //筛选满足条件的圣魂 List <uint> data = new List <uint>(); List <uint> filterTypes = new List <uint>(); filterTypes.Add((uint)GameCmd.EquipType.EquipType_SoulOne); List <uint> muhonList = imgr.GetItemByType(GameCmd.ItemBaseType.ItemBaseType_Equip, filterTypes, GameCmd.PACKAGETYPE.PACKAGETYPE_MAIN); //过滤 if (null != muhonList && muhonList.Count != 0) { Muhon tempData = null; for (int i = 0; i < muhonList.Count; i++) { if (itemData.IsMatchBlend(muhonList[i], false)) { data.Add(muhonList[i]); } } } if (data.Count == 0) { TipsManager.Instance.ShowTips(string.Format("背包中未找到消耗所需{0}{1}" , ColorManager.GetNGUIColorOfType(ColorType.Red), itemData.Name)); return; } data.Sort((left, right) => { Muhon leftM = imgr.GetBaseItemByQwThisId <Muhon>(left); Muhon rightM = imgr.GetBaseItemByQwThisId <Muhon>(right); if (rightM.IsActive) { if (leftM.IsActive) { return(rightM.Level - leftM.Level); } return(1); } else if (leftM.IsActive) { return(-1); } else { return(rightM.Level - leftM.Level); } return(0); }); UILabel desLabel = null; Action <UILabel> desLabAction = (des) => { desLabel = des; if (null != desLabel) { desLabel.text = DataManager.Manager <TextManager>() .GetLocalText(LocalTextType.Local_TXT_Soul_ChooseActiveMuhonNotice); } }; uint tempSelectMuhonId = blendSelectMuhonId; UIWeaponSoulInfoSelectGrid tempSelectWeaponSoulGrid = null; UIEventDelegate eventDlg = (eventTye, grid, param) => { if (eventTye == UIEventType.Click) { UIWeaponSoulInfoSelectGrid tempGrid = grid as UIWeaponSoulInfoSelectGrid; if (tempSelectMuhonId == tempGrid.QWThisId) { tempSelectMuhonId = 0; tempGrid.SetHightLight(false); } else if (itemData.IsMatchBlend(tempGrid.QWThisId)) { tempSelectMuhonId = tempGrid.QWThisId; if (null != tempSelectWeaponSoulGrid) { tempSelectWeaponSoulGrid.SetHightLight(false); } tempGrid.SetHightLight(true); tempSelectWeaponSoulGrid = tempGrid; } else { TipsManager.Instance.ShowTips(LocalTextType.Local_TXT_Soul_UnactiveNotice); } } }; ItemChoosePanel.ItemChooseShowData showData = new ItemChoosePanel.ItemChooseShowData() { createNum = data.Count, title = "选择圣魂", cloneTemp = UIManager.GetResGameObj(GridID.Uiweaponsoulinfoselectgrid) as GameObject, onChooseCallback = () => { if (tempSelectMuhonId != blendSelectMuhonId) { blendSelectMuhonId = tempSelectMuhonId; UpdateBlend(Data); } }, gridCreateCallback = (obj, index) => { if (index >= data.Count) { Engine.Utility.Log.Error("OnSelectBlendMuhon error,index out of range"); } else { Muhon tempItemData = imgr.GetBaseItemByQwThisId <Muhon>(data[index]); if (null == tempItemData) { Engine.Utility.Log.Error("OnSelectBlendMuhon error,get itemData qwThisId:{0}", data[index]); } else { UIWeaponSoulInfoSelectGrid weaponsoulInfoGrid = obj.GetComponent <UIWeaponSoulInfoSelectGrid>(); if (null == weaponsoulInfoGrid) { weaponsoulInfoGrid = obj.AddComponent <UIWeaponSoulInfoSelectGrid>(); } weaponsoulInfoGrid.RegisterUIEventDelegate(eventDlg); if (!itemData.IsMatchBlend(tempSelectMuhonId)) { tempSelectMuhonId = 0; } bool select = (data[index] == tempSelectMuhonId); weaponsoulInfoGrid.SetGridViewData(tempItemData.QWThisID, select, itemData.IsMatchBlend(data[index]), true); if (select) { tempSelectWeaponSoulGrid = weaponsoulInfoGrid; tempSelectMuhonId = data[index]; } } } }, desPassCallback = desLabAction, }; DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.ItemChoosePanel, data: showData); }
public void UnRegisterUIEventDelegate() { uiEventDelegate = null;; }
private void InitEvolveWidgets() { if (IsInitStatus(TabMode.JinHua)) { return; } SetInitStatus(TabMode.JinHua, true); if (null != m_widget_PreviewCollider) { UIEventListener.Get(m_widget_PreviewCollider.gameObject).onClick = (preViewObj) => { SetEvolvePre(false); }; } Transform clone = null; if (null != m_trans_EvolveGrowRoot && null == m_evolveCurGrow) { clone = UIManager.AddGridTransform(GridID.Uiitemshowgrid, m_trans_EvolveGrowRoot); if (null != clone) { m_evolveCurGrow = clone.GetComponent <UIItemShowGrid>(); if (null == m_evolveCurGrow) { m_evolveCurGrow = clone.gameObject.AddComponent <UIItemShowGrid>(); } } } m_dicStarData = new Dictionary <EquipDefine.AttrIndex, MuhonStarData>(); m_dicMuhonDeputy = new Dictionary <EquipDefine.AttrIndex, UIItemShowGrid>(); Transform tempTrans = null; UIToggle tempToggle = null; string indexStr = ""; UIItemShowGrid tempShowGrid = null; UIEventDelegate deputyAction = (eventType, data, param) => { if (eventType == UIEventType.Click && data is UIItemShowGrid) { UIItemShowGrid showGrid = data as UIItemShowGrid; EquipDefine.AttrIndex index = EquipDefine.AttrIndex.None; if (TryGetEvolveGridAttrIndex(showGrid.CacheTransform.gameObject, out index)) { if (null != param && param is bool) { OnUnloadEvolveMuhon(index); } else if (!IsDeputyEvolveGridFill(index)) { OnSelectEvolveMuhon(index); } } } }; m_dicParticleWidgets = new Dictionary <EquipDefine.AttrIndex, UIParticleWidget>(); UIParticleWidget tempParticleWidget = null; Transform tempParticleTran = null; //星星爆点组件初始化 if (null == m_evolveStarBoomParticleWidget && null != m_trans_EvolveStarLightParticle) { m_evolveStarBoomParticleWidget = m_trans_EvolveStarLightParticle.GetComponent <UIParticleWidget>(); if (null == m_evolveStarBoomParticleWidget) { m_evolveStarBoomParticleWidget = m_trans_EvolveStarLightParticle.gameObject.AddComponent <UIParticleWidget>(); } if (null != m_evolveStarBoomParticleWidget && null != m_label_EvolveEffetDepthLimitMask) { m_evolveStarBoomParticleWidget.depth = m_label_EvolveEffetDepthLimitMask.depth - 1; } } //进化目标组件爆点初始化 if (null == m_evolveTargetParticleWidget && null != m_trans_EvolveTargeParticle) { m_evolveTargetParticleWidget = m_trans_EvolveTargeParticle.GetComponent <UIParticleWidget>(); if (null == m_evolveTargetParticleWidget) { m_evolveTargetParticleWidget = m_trans_EvolveTargeParticle.gameObject.AddComponent <UIParticleWidget>(); } if (null != m_evolveTargetParticleWidget && null != m_label_EvolveEffetDepthLimitMask) { m_evolveTargetParticleWidget.depth = m_label_EvolveEffetDepthLimitMask.depth - 1; } } for (EquipDefine.AttrIndex i = EquipDefine.AttrIndex.None + 1; i < EquipDefine.AttrIndex.Max; i++) { if (!Enum.IsDefined(typeof(EquipDefine.AttrIndex), i)) //|| i == EquipDefine.AttrIndex.Fifth) { continue; } indexStr = ((int)i).ToString(); if (null != m_trans_CostEvolveStar) { tempTrans = m_trans_CostEvolveStar.Find(indexStr); if (null != tempTrans) { tempToggle = tempTrans.GetComponent <UIToggle>(); if (null != tempToggle) { m_dicStarData.Add(i, MuhonStarData.Create(tempToggle, i)); } } } if (null != m_trans_CostEvolveMuhon) { if (null != tempTrans) { tempTrans = m_trans_CostEvolveMuhon.Find(indexStr); tempParticleTran = tempTrans.Find(indexStr); if (null != tempParticleTran) { tempParticleWidget = tempParticleTran.GetComponent <UIParticleWidget>(); if (null == tempParticleWidget) { tempParticleWidget = tempParticleTran.gameObject.AddComponent <UIParticleWidget>(); } if (null != tempParticleWidget) { if (null != m_label_EvolveEffetDepthLimitMask) { tempParticleWidget.depth = m_label_EvolveEffetDepthLimitMask.depth - 1; } if (!m_dicParticleWidgets.ContainsKey(i)) { m_dicParticleWidgets.Add(i, tempParticleWidget); } } } clone = UIManager.AddGridTransform(GridID.Uiitemshowgrid, tempTrans); tempShowGrid = clone.GetComponent <UIItemShowGrid>(); if (null == tempShowGrid) { tempShowGrid = clone.gameObject.AddComponent <UIItemShowGrid>(); } if (null != tempShowGrid) { tempShowGrid.RegisterUIEventDelegate(deputyAction); m_dicMuhonDeputy.Add(i, tempShowGrid); } } } } if (null != m_trans_EvolveMaxGrowRoot && null == m_evolveMaxGrow) { clone = UIManager.AddGridTransform(GridID.Uiitemgrowshowgrid, m_trans_EvolveMaxGrowRoot); if (null != clone) { m_evolveMaxGrow = clone.GetComponent <UIItemGrowShowGrid>(); if (null == m_evolveMaxGrow) { m_evolveMaxGrow = clone.gameObject.AddComponent <UIItemGrowShowGrid>(); } } } m_dicSelectMuhonDeputy = new Dictionary <EquipDefine.AttrIndex, uint>(); }