private void OnEquipCellSwap(IEvent ievent) { if (!EquipDataModel.OperateTypes[5]) { return; } var e = ievent as EquipCellSwap; var fromIdx = e.FromIdx; if (fromIdx < 0 || fromIdx > 2) { Logger.Error("Illegal fromIdx value!fromIdx = {0}", fromIdx); return; } var toIdx = e.ToIdx; if (toIdx < 0 || toIdx > 2) { Logger.Error("Illegal toIdx value!toIdx = {0}", toIdx); return; } var evoData = DataModel.SmithyEvoData; var fromItem = evoData.EvolveItems[fromIdx]; if (fromItem == null) { return; } var toItem = evoData.EvolveItems[toIdx]; var tmpItem = new BagItemDataModel(); tmpItem.Clone(toItem); toItem.ItemId = fromItem.ItemId; toItem.Count = fromItem.Count; toItem.BagId = fromItem.BagId; toItem.Index = fromItem.Index; toItem.IsGrey = fromItem.IsGrey; fromItem.ItemId = tmpItem.ItemId; fromItem.Count = tmpItem.Count; fromItem.BagId = tmpItem.BagId; fromItem.Index = tmpItem.Index; fromItem.IsGrey = tmpItem.IsGrey; for (int i = 0, imax = fromItem.Exdata.Count; i < imax; i++) { toItem.Exdata[i] = fromItem.Exdata[i]; fromItem.Exdata[i] = tmpItem.Exdata[i]; } if (fromIdx == 0 || toIdx == 0) { RefreshEvolvedItem(); } }
private void SelectAdvanceEquip(int index, BagItemDataModel itemData) { var evoData = DataModel.AdvanceDataModel; if (mEquipCountNow >= evoData.NeedEquipCount) { return; } EquipItemDataModel equipDataModel; if (DataModel.AdvanceSelectPack == 0) { equipDataModel = DataModel.AdvanceEquipItems[index]; } else { equipDataModel = DataModel.AdvanceBagItems[index]; } if (equipDataModel.SelectFlag) { return; } if (equipDataModel.CanAdvance == 0) { EventDispatcher.Instance.DispatchEvent(new ShowUIHintBoard(100002130)); return; } if (evoData.EvolvedItemId == -1 || DataModel.AdvanceSelectPack == 0) { // 主装备 AdvanceChooseMainEquip(itemData); equipDataModel.SelectFlag = true; } else { var choseItem = evoData.EvolveItems[0]; if (choseItem.ItemId == itemData.ItemId) { // 同一物品id equipDataModel.SelectFlag = true; BagItemDataModel item = evoData.EvolveItems[mEquipCountNow]; if (item == null) { Logger.Error("In OnEquipCellSelect(). item == null!"); return; } if (item.IsGrey) { ++mEquipCountNow; evoData.IsEnable = mEquipCountNow == evoData.NeedEquipCount; } item.Clone(itemData); RefreshEvolvedItem(); RefreshEquipPackForItemId(itemData.ItemId); } else { // 不同物品 AdvanceChooseMainEquip(itemData); equipDataModel.SelectFlag = true; } } if (mEquipCountNow == 1) { for (var i = 0; i < 3; i++) { var evolveItem = evoData.EvolveItems[i]; evolveItem.ItemId = itemData.ItemId; } } }
/// <summary> /// </summary> /// <param name="ievent"></param> private void OnEquipCellSelect(IEvent ievent) { if (!EquipDataModel.OperateTypes[5]) { return; } var e = ievent as EquipCellSelect; var index = e.Index; if (index < -1 || index > 2) { Logger.Error("Illegal index value!index = {0}", index); return; } var evoData = DataModel.SmithyEvoData; if ((evoData.EvolvedItemId == -1 && index == -1) || index == 0) { if (evoData.EvolvedItemId == -1) { ++mEquipCountNow; index = 0; } var item = evoData.EvolveItems[index]; var oldItemId = item.ItemId; var tbEquip = Table.GetEquipBase(e.ItemData.ItemId); if (tbEquip == null) { return; } var tbEquipEvo = Table.GetEquipUpdate(tbEquip.EquipUpdateLogic); if (tbEquipEvo == null) { return; } evoData.EvolvedItemId = tbEquip.UpdateEquipID; evoData.NeedEquipCount = tbEquipEvo.NeedEquipCount; item.Clone(e.ItemData); RefreshEvolvedItem(); if (oldItemId != item.ItemId) { var neededItems = new List <ItemIdDataModel>(); for (int i = 0, imax = tbEquipEvo.NeedItemID.Length; i < imax; i++) { if (tbEquipEvo.NeedItemID[i] == -1) { break; } var needItem = new ItemIdDataModel(); needItem.ItemId = tbEquipEvo.NeedItemID[i]; needItem.Count = tbEquipEvo.NeedItemCount[i]; neededItems.Add(needItem); } for (int i = 0, imax = tbEquipEvo.NeedResID.Length; i < imax; i++) { if (tbEquipEvo.NeedResID[i] == -1) { continue; } var needItem = new ItemIdDataModel(); needItem.ItemId = tbEquipEvo.NeedResID[i]; needItem.Count = tbEquipEvo.NeedResCount[i]; neededItems.Add(needItem); if (needItem.ItemId == 10) //魔尘 { evoData.needMochengCount = needItem.Count; break; } } evoData.NeededItems = new ObservableCollection <ItemIdDataModel>(neededItems); RefreshEquipPackForItemId(e.ItemData.ItemId); EventDispatcher.Instance.DispatchEvent(new UIEvent_SmithySetGridCenter(1)); } } else if (mEquipCountNow < evoData.NeedEquipCount || index > 0) { BagItemDataModel item = null; if (index > 0) { item = evoData.EvolveItems[index]; } else { var __enumerator6 = (evoData.EvolveItems).GetEnumerator(); while (__enumerator6.MoveNext()) { item = __enumerator6.Current; { if (item.IsGrey) { break; } } } } if (item == null) { Logger.Error("In OnEquipCellSelect(). item == null!"); return; } if (item.IsGrey) { ++mEquipCountNow; evoData.IsEnable = mEquipCountNow == evoData.NeedEquipCount; } item.Clone(e.ItemData); RefreshEvolvedItem(); RefreshEquipPackForItemId(e.ItemData.ItemId); } if (mEquipCountNow == 1) { for (var i = 0; i < 3; i++) { var evolveItem = evoData.EvolveItems[i]; evolveItem.ItemId = e.ItemData.ItemId; } } }