private void DropToBoxinventoryFromCharacterInventory(DragAndDropParam dragAndDropParam) { ItemCell itemCellInventory = dragAndDropParam.dragCell as ItemCell; ItemCell itemCellBox = dragAndDropParam.dropCell as ItemCell; PanelBoxInventory panelBoxInventory = dragAndDropParam.dragToPanel.GetComponent <PanelBoxInventory>(); if (itemCellInventory != null) { Debug.Log("Drop to stuck"); } else { ItemInventory itemInventory = panelBoxInventory.sceneObject.GetItemInventory(); for (int i = 0; i < itemCellBox.count; i++) { if (!itemInventory.AddItem(itemCellBox.item)) { break; } CharacterParam.itemInventory.RemoveItem(itemCellBox.item); } } // Update Box Inventory Panel panelBoxInventory.UpdatePanel(panelBoxInventory.sceneObject); // Update All Panels UIBuilder.UpdateAllPanels(); }
// Public // Private private void DropCellToHotBar(DragAndDropParam dragAndDropParam) { HotBarCell hotBarCell = dragAndDropParam.dragCell as HotBarCell; hotBarCell.baseCell = dragAndDropParam.dropCell; UIBuilder.UpdateAllPanels(); }
virtual public void Awake() { // Set Params baseCell = new BaseCell(); dragAndDropParam = new DragAndDropParam(); isDrag = false; }
private void EquipItemFromICharacterInventory(DragAndDropParam dragAndDropParam) { EquipCell equipCell = dragAndDropParam.dragCell as EquipCell; ItemCell itemCell = dragAndDropParam.dropCell as ItemCell; equipCell.item = itemCell.item; CharacterParam.itemInventory.RemoveItem(itemCell.item); // Update Chaeacre Param CharacterParam.UpadateParam(itemCell.item); // Update All Panels UIBuilder.UpdateAllPanels(); }
private void EquipItemFromIBoxInventory(DragAndDropParam dragAndDropParam) { EquipCell equipCell = dragAndDropParam.dragCell as EquipCell; ItemCell itemCell = dragAndDropParam.dropCell as ItemCell; equipCell.item = itemCell.item; PanelBoxInventory panelBoxInventory = dragAndDropParam.dragFromPanel.GetComponent <PanelBoxInventory>(); panelBoxInventory.sceneObject.GetItemInventory().RemoveItem(itemCell.item); // Update Character Param CharacterParam.UpadateParam(itemCell.item); // Update Box Inventory Panel panelBoxInventory.UpdatePanel(panelBoxInventory.sceneObject); // Update All Panels UIBuilder.UpdateAllPanels(); }
private IEnumerator StartAction(float actionTime, DragAndDropParam dragAndDropParam, Action <DragAndDropParam> action) { BaseCell dropCell = dragAndDropParam.dragCell; BaseCell dragCell = dragAndDropParam.dropCell; BasePanel dragFromPanel = dragAndDropParam.dragFromPanel; BasePanel dragToPanel = dragAndDropParam.dragToPanel; isAction = true; if (actionTime <= 0) { isAction = false; } // Cloase Old Panel if (panelAction != null) { Destroy(panelAction); } // Create Action Panel panelAction = Instantiate(panelActionPrefab, UIBuilder.GetCanvasTransform()); float actionDelta = actionTime; while (isAction) { actionDelta -= Time.deltaTime; if (actionDelta <= 0) { isAction = false; } // Get Action Time float percent = actionTime / 100; float doneTime = actionTime - actionDelta; float timer = (doneTime / percent) / 100; panelAction.GetComponent <PanelAction>().SetTimer(timer); yield return(null); } Destroy(panelAction); dragAndDropParam.dragCell = dragCell; dragAndDropParam.dropCell = dropCell; dragAndDropParam.dragToPanel = dragToPanel; dragAndDropParam.dragFromPanel = dragFromPanel; action?.Invoke(dragAndDropParam); isAction = false; }
private void UnEquipItemToCharacterInventory(DragAndDropParam dragAndDropParam) { EquipCell equipCell = dragAndDropParam.dropCell as EquipCell; ItemCell itemCell = dragAndDropParam.dropCell as ItemCell; if (itemCell != null) { Debug.Log("Drop to stuck"); } else { CharacterParam.itemInventory.AddItem(equipCell.item); // Update Character Param CharacterParam.UpadateParam(equipCell.item); equipCell.item = null; } // Update All Panels UIBuilder.UpdateAllPanels(); }
private void UnEquipItemToBoxInventory(DragAndDropParam dragAndDropParam) { EquipCell equipCell = dragAndDropParam.dropCell as EquipCell; ItemCell itemCell = dragAndDropParam.dropCell as ItemCell; PanelBoxInventory panelBoxInventory = dragAndDropParam.dragToPanel.GetComponent <PanelBoxInventory>(); if (itemCell != null) { Debug.Log("Drop to stuck"); } else { panelBoxInventory.sceneObject.GetItemInventory().AddItem(equipCell.item); // Update Character Param CharacterParam.UpadateParam(equipCell.item); equipCell.item = null; } // Update Box Inventory Panel panelBoxInventory.UpdatePanel(panelBoxInventory.sceneObject); // Update All Panels UIBuilder.UpdateAllPanels(); }
private void ActionCellDrop(DragAndDropParam dragAndDropParam) { // Stop Prev Action StopAllCoroutines(); /// Hot Bar if (dragAndDropParam.dragToPanel != null && dragAndDropParam.dragToPanel.panelName == "PanelHotBar") { // Drop Cell if (dragAndDropParam.dropCell == null) { return; } // Create Action StartCoroutine(StartAction(0, dragAndDropParam, this.DropCellToHotBar)); } /// Equip from Character Inventory if (dragAndDropParam.dragToPanel != null && dragAndDropParam.dragToPanel.panelName == "PanelCharacter" && dragAndDropParam.dragFromPanel != null && dragAndDropParam.dragFromPanel.panelName == "PanelCharacterInventory") { if (dragAndDropParam.dropCell is EquipCell) { // Drop Cell if (dragAndDropParam.dropCell == null || dragAndDropParam.dropCell.baseCell != null) { return; } EquipCell equipCell = dragAndDropParam.dropCell as EquipCell; ItemCell itemCell = dragAndDropParam.dragCell as ItemCell; // Cell Not Empty if (equipCell.equipType != itemCell.item.itemType || equipCell.item != null) { return; } // Create Action StartCoroutine(StartAction(GameParams.equipTime, dragAndDropParam, this.EquipItemFromICharacterInventory)); } } /// Equip from Box Inventory if (dragAndDropParam.dragToPanel != null && dragAndDropParam.dragToPanel.panelName == "PanelCharacter" && dragAndDropParam.dragFromPanel != null && dragAndDropParam.dragFromPanel.panelName == "PanelBoxInventory") { if (dragAndDropParam.dropCell is EquipCell) { // Drop Cell if (dragAndDropParam.dropCell == null || dragAndDropParam.dropCell.baseCell != null) { return; } EquipCell equipCell = dragAndDropParam.dropCell as EquipCell; ItemCell itemCell = dragAndDropParam.dragCell as ItemCell; // Cell Not Empty if (equipCell.equipType != itemCell.item.itemType || equipCell.item != null) { return; } // Create Action StartCoroutine(StartAction(GameParams.equipTime, dragAndDropParam, this.EquipItemFromIBoxInventory)); } } /// UnEquip to Character Inventory if (dragAndDropParam.dragToPanel != null && dragAndDropParam.dragToPanel.panelName == "PanelCharacterInventory" && dragAndDropParam.dragFromPanel != null && dragAndDropParam.dragFromPanel.panelName == "PanelCharacter") { EquipCell equipCell = dragAndDropParam.dragCell as EquipCell; // Full Inventory if (!CharacterParam.itemInventory.IsAdd(equipCell.item)) { return; } StartCoroutine(StartAction(GameParams.equipTime, dragAndDropParam, this.UnEquipItemToCharacterInventory)); } /// UnEquip to Box Inventory if (dragAndDropParam.dragToPanel != null && dragAndDropParam.dragToPanel.panelName == "PanelBoxInventory" && dragAndDropParam.dragFromPanel != null && dragAndDropParam.dragFromPanel.panelName == "PanelCharacter") { EquipCell equipCell = dragAndDropParam.dragCell as EquipCell; PanelBoxInventory panelBoxInventory = dragAndDropParam.dragToPanel.GetComponent <PanelBoxInventory>(); // Full Inventory if (!panelBoxInventory.sceneObject.GetItemInventory().IsAdd(equipCell.item)) { return; } StartCoroutine(StartAction(GameParams.equipTime, dragAndDropParam, this.UnEquipItemToBoxInventory)); } /// Drop from Box Inventory to Character Inventory if (dragAndDropParam.dragFromPanel != null && dragAndDropParam.dragFromPanel.panelName == "PanelBoxInventory" && dragAndDropParam.dragToPanel != null && dragAndDropParam.dragToPanel.panelName == "PanelCharacterInventory") { ItemCell itemCell = dragAndDropParam.dragCell as ItemCell; // Full Inventory if (!CharacterParam.itemInventory.IsAdd(itemCell.item)) { return; } StartCoroutine(StartAction(GameParams.equipTime, dragAndDropParam, this.DropToCharacterInventoryFromBoxInventory)); } /// Drop from Character Inventory to Box Inventory if (dragAndDropParam.dragFromPanel != null && dragAndDropParam.dragFromPanel.panelName == "PanelCharacterInventory" && dragAndDropParam.dragToPanel != null && dragAndDropParam.dragToPanel.panelName == "PanelBoxInventory") { ItemInventory itemInventory = dragAndDropParam.dragToPanel.GetComponent <PanelBoxInventory>().sceneObject.GetItemInventory(); ItemCell itemCell = dragAndDropParam.dragCell as ItemCell; // Full Inventory if (!itemInventory.IsAdd(itemCell.item)) { return; } StartCoroutine(StartAction(GameParams.equipTime, dragAndDropParam, this.DropToBoxinventoryFromCharacterInventory)); } }