private void HandleSupplyItemOptionClick(IInventoryCellView cellView) { int?cellIndex = GetIndex(cellView); if (cellIndex.HasValue) { PlayerInventoryCellData cellData = cellView.CellData as PlayerInventoryCellData; ApplyCell(cellView, cellIndex.Value, null); Debug.LogError("HandleSupplyItemOptionClick"); } }
public void HandleEvent(int key, params object[] args) { switch (key) { case (int)EventID.OnEquipInventroy: PlayerInventoryCellData cellData = (PlayerInventoryCellData)args[0]; if (cellData.item is Equipment equipment) { PlayerEquipmentCellView equipmentCellView = GetCellByEquipmentType(equipment.equipmentType); Equip(equipmentCellView, equipment); } break; } }
public void Init() { var supplys = GamePlayMgr.S.playerMgr.inventoryMgr.LstSupply; supplys.ForEach((item) => { PlayerInventoryCellData cellData = new PlayerInventoryCellData(item); m_SupplyViewData.InsertInventoryItem(m_SupplyViewData.GetInsertableId(cellData).Value, cellData); }); var equips = GamePlayMgr.S.playerMgr.inventoryMgr.LstEquipment; equips.ForEach((item) => { PlayerInventoryCellData cellData = new PlayerInventoryCellData(item); m_EquipmentViewData.InsertInventoryItem(m_EquipmentViewData.GetInsertableId(cellData).Value, cellData); }); m_ViewDataMap.Add(InventoryToggleType.Supplies, m_SupplyViewData); m_ViewDataMap.Add(InventoryToggleType.Equipment, m_EquipmentViewData); }
public override bool OnDrop(IInventoryCellView targetCell, IInventoryCellView effectCell) { if (!itemViews.Any(item => item == targetCell)) { return(false); } // Debug.LogError(GetType().ToString() + "OnDrop" + (effectCell.CellData.GetType())); // check target; var index = GetIndex(targetCell, effectCell.CellData, cellCorner); if (!index.HasValue || index.Value < 0) { return(false); } if (!viewData.CheckInsert(index.Value, effectCell.CellData)) { if (targetCell.CellData == null) { return(false); } if (targetCell.CellData is PlayerInventoryCellData) //如果目标也是道具栏位 { int?targetID = viewData.GetId(targetCell.CellData); // Debug.LogError(index.Value + "---" + targetID.Value); if (targetCell.CellData.size == effectCell.CellData.size)//大小一致 交换 并且完全盖住的时候 { if (originalId.HasValue && originalCellData != null) { itemViews[targetID.Value].Apply(targetCell.CellData); itemViews[originalId.Value].Apply(originalCellData); viewData.InsertInventoryItem(originalId.Value, originalCellData); playerInventoryviewData.ExchangeInventoryItem(targetID.Value, originalId.Value); Debug.LogError("Exchange"); //ReApply(); originalId = null; originalCellData = null; return(true); } } } // // check free space in case // if (targetCell.CellData != null && targetCell.CellData is VariableInventorySystem.IStandardCaseCellData caseData) // { // var id = caseData.CaseData.GetInsertableId(effectCell.CellData); // if (id.HasValue) // { // caseData.CaseData.InsertInventoryItem(id.Value, effectCell.CellData); // originalId = null; // originalCellData = null; // return true; // } // } return(false); } var newCellData = effectCell.CellData; if (effectCell.CellData is PlayerEquipmentCellData equipmentCellData) { newCellData = new PlayerInventoryCellData(equipmentCellData.item); Debug.LogError(newCellData.GetType()); } // place ApplyCell(itemViews[index.Value], index.Value, newCellData); originalId = null; originalCellData = null; return(true); }