void OnSlotDrop(guiSlot slot) { if (GUImain.DragObject == null) return; //ResourceData data = _shopData.List[(int)slot.Data]; slot.Worker.id = GUImain.DragObject.Resource.id; slot.Refresh(); }
void OnTransportClick(guiSlot slot) { CurrentSlot = (int)slot.Data; guiSlot s = TransportPanel.GetItem<guiSlot>(CurrentSlot); Debug.Log(s.ToString()); CurrentTransport = TransportBuilding.Transports[CurrentSlot]; AvalableList.ClearItems(); for (int i = 0; i < CurrentTransport.Slots.Count; i++) { ResourceData data = CurrentTransport.Slots[i]; GameObject obj = AvalableList.AddItem(); guiSlot slt = obj.GetComponent<guiSlot>(); slt.Data = i; slt.Type = guiSlot.SlotType.TEXT; slt.Drag = guiSlot.DragType.DROP; slt.Worker = data; slt.AddonText.text = data.amount > 0 ? data.amount.ToString() : ""; slt.OnSlotEndDrag = AvailableEndDrag; } if (CurrentTransport.Source == null) { SourceSlot.Worker = new ResourceData(); } else { SourceSlot.Worker = new ResourceData(CurrentTransport.Source.resource_id); } if (CurrentTransport.Destination == null) { DestinationSlot.Worker = new ResourceData(); } else { DestinationSlot.Worker = new ResourceData(CurrentTransport.Destination.resource_id); } SelectedTransport.SetActive(true); //Debug.Log("Select transport id:" + CurrentTransport.ID); }
void AvailableEndDrag(guiSlot slot) { if (GUImain.DragObject == null) return; ResourceObject res = ResourceManager.GetResoucreObject(GUImain.DragObject.Resource.id); if (res == null || res.Type != ResourceTypes.RESOURCE) return; int slotID = (int)slot.Data; CurrentTransport.Slots[slotID].id = GUImain.DragObject.Resource.id; CurrentTransport.Slots[slotID].amount = 0; //slot.Icon.sprite = CurrentTransport.Slots[slotID].Image; slot.Worker = CurrentTransport.Slots[slotID]; slot.AddonText.text = ""; }
void OnWorkerClick(guiSlot slot) { SelectedWorker.Worker = CurrentBuilding.ActiveWorks.List[(int)slot.Data]; SelectedWorker.ListID = (int)slot.Data; SelectedWorker.Redraw(); SelectedWorker.gameObject.SetActive(true); }