protected virtual void TryDrop() { var dragInventoryData = UIDragDropHandler.CurrentData.Get <InventoryItem>(); if (dragInventoryData.Inventory == Player.MainInventory) { if (World.Get <ContainerSystem>().TrySwap(Player.MainInventory, dragInventoryData.Index, Index)) { StatusMessages("TrySwap"); UIDragDropHandler.Take(); } else { StatusMessages("Rejected same inventory"); RejectDrag(); } return; } if (World.Get <ContainerSystem>().TryAdd(Player.MainInventory, UIDragDropHandler.CurrentData, Index)) { StatusMessages("TryAdd)"); UIDragDropHandler.Take(); } else { StatusMessages("Rejected different inventory"); RejectDrag(); } }
public override void OnDrop(PointerEventData eventData) { if (UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemReturn, transform.position, 0, AudioVolume); } UIDragDropHandler.Return(); } return; } if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemClick, transform.position, 0, AudioVolume); } if (Data != null) { TrySwap(); } else { TryDrop(); } }
protected override void OnDropEvent() { if (UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } return; } if (UIDragDropHandler.CurrentData.Get <InventoryItem>()?.Identified ?? false) { UIFloatingText.Spawn("Doesn't need to be identified", transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); UIDragDropHandler.Return(); return; } var price = GameOptions.IdentifyEstimate(UIDragDropHandler.CurrentData); if (Player.Currency.Value < price) { UIFloatingText.Spawn(string.Format("Identify Cost: {0} Not enough {1}", price, GameLabels.Currency), transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); UIDragDropHandler.Return(); return; } UIModalQuestion.Set(ConfirmIdentify, string.Format("Identify for {0} {1}?", price, GameLabels.Currency)); }
protected virtual void TrySwap() { if (InventoryItem.CanStack(UIDragDropHandler.CurrentData)) { UIDragDropHandler.Take(); return; } Entity oldItem = Data; UIDragDropHandler.CurrentData.Get <InventoryItem>(i => i.Index = Index); if (Player.MainInventory.TryAdd(UIDragDropHandler.CurrentData)) { UIDragDropHandler.Take(); UIDragDropHandler.SetItem(oldItem); } else { if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemReturn, transform.position, 0, AudioVolume); } UIDragDropHandler.Return(); Player.MainInventory.TryAdd(oldItem); } }
private void TryAddPlayer() { UIDragDropHandler.ClearData(); if (Player.MainInventory.TryAdd(Data)) { Clear(); } }
private void TryAddPlayer() { UIDragDropHandler.ClearData(); if (World.Get <ContainerSystem>().TryAdd(Player.MainInventory, Data)) { Clear(); } }
protected void RejectDrag() { if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemReturn, transform.position, 0, AudioVolume); } UIDragDropHandler.Return(); }
public void OnDrop(PointerEventData eventData) { if (UIDragDropHandler.CurrentData == null) { return; } if (!_enabled || Game.InTown) { UIDragDropHandler.Return(); return; } TryThrow(UIDragDropHandler.CurrentData); }
protected override void TryDrop() { var newItem = UIDragDropHandler.CurrentData; if (World.Get<EquipmentSystem>().TryEquip(_slot, newItem)) { UIDragDropHandler.Take(); } else { if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemReturn, transform.position, 0, AudioVolume); } UIFloatingText.InventoryMessage(_slot.LastEquipStatus, RectTransform); UIDragDropHandler.Return(); } }
public override void OnDrop(PointerEventData eventData) { if (UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } } else { //UIInventoryShop.TrySellDrag(transform); } }
protected override void OnDropEvent() { if (UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } } else { //UIInventoryShop.TrySellDrag(transform); } }
public override void OnDrop(PointerEventData eventData) { if (!UIDragDropHandler.Active) { return; } if (UIDragDropHandler.CurrentData != null && !(UIDragDropHandler.CurrentData.GetParent()?.HasComponent <PlayerComponent>() ?? false)) { UIDragDropHandler.Return(); return; } Set(UIDragDropHandler.CurrentData); UIDragDropHandler.Return(); }
protected virtual void TryDrop() { if (Player.MainInventory.TryAdd(UIDragDropHandler.CurrentData)) { UIDragDropHandler.Take(); } else { if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemReturn, transform.position, 0, AudioVolume); } UIDragDropHandler.Return(); } }
public void OnDrop(PointerEventData eventData) { if (UIDragDropHandler.CurrentData == null) { return; } if (!_active) { UIDragDropHandler.Return(); return; } if (Player.MainInventory.Add(UIDragDropHandler.CurrentData)) { UIDragDropHandler.Take(); } }
public void OnDrop(PointerEventData eventData) { if (UIDragDropHandler.CurrentData == null) { return; } if (!_active) { UIDragDropHandler.Return(); return; } if (World.Get <ContainerSystem>().TryAdd(Player.MainInventory, UIDragDropHandler.CurrentData)) { UIDragDropHandler.Take(); } }
protected override void StartDrag() { base.StartDrag(); if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemClick, transform.position, 0, AudioVolume); } if (Data.Get <InventoryItem>()?.Inventory?.Owner.HasComponent <PlayerComponent>() ?? false) { UIDragDropHandler.SetItem(Data, StopDrag, StopDrag, Clear); } else { UIDragDropHandler.SetItem(Data, TryAddPlayer, StopDrag, Clear); } DisableSlotDetails(); }
private void ConfirmRepair(int id) { if (id > 0 || UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } return; } var price = GameOptions.RepairEstimate(UIDragDropHandler.CurrentData); UIFloatingText.Spawn(string.Format("Repaired for {0} {1}", price, GameText.DefaultCurrencyLabel), transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); Player.DefaultCurrencyHolder.AddToValue(-price); //UIDragDropHandler.CurrentData.Durability.SetMax(); UIDragDropHandler.Return(); }
private void ConfirmIdentify(int id) { if (id > 0 || UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } return; } var price = GameOptions.IdentifyEstimate(UIDragDropHandler.CurrentData); UIFloatingText.Spawn(string.Format("Identified for {0} {1}", price, GameLabels.Currency), transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); Player.Currency.AddToValue(-price); UIDragDropHandler.CurrentData.Get <InventoryItem>(i => i.Identified = true); UIDragDropHandler.Return(); }
public void TryThrow(Entity item) { var mouseRay = Player.Cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(mouseRay, out hit, _dropDistance, LayerMasks.DropPanel)) { var use = hit.transform.GetComponent <EntityIdentifier>(); if (use != null) { var interaction = EntityController.GetEntity(use.EntityID).Get <ItemInteraction>(); if (interaction != null && interaction.Interaction(item)) { UIDragDropHandler.Take(); return; } } var screenPnt = Player.Cam.ScreenToViewportPoint(Input.mousePosition); if (screenPnt.y < _maxPlaceScreenY) { var inventoryItem = item.Get <InventoryItem>(); if (inventoryItem != null && inventoryItem.Inventory.Remove(item)) { UIDragDropHandler.Take(); World.Get <ItemSceneSystem>().Drop(hit.point + new Vector3(0, 0.5f, 0)); return; } } if (hit.distance < _minDistance) { UIDragDropHandler.Return(); return; } } UIDragDropHandler.Take(); var pos = Player.Cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 20)); World.Get <ItemSceneSystem>().Throw(pos); }
protected virtual void TrySwap() { if (InventorySystem.CanStack(InventoryItem, UIDragDropHandler.CurrentData)) { UIDragDropHandler.Take(); return; } Entity oldItem = Data; var currentInventoryData = oldItem.Get <InventoryItem>(); if (World.Get <ContainerSystem>().TryReplace(Player.MainInventory, UIDragDropHandler.CurrentData, currentInventoryData.Index)) { StatusMessages("World.Get<ContainerSystem>().TryReplace(Player.MainInventory, UIDragDropHandler.CurrentData, currentInventoryData.Index)"); UIDragDropHandler.Take(); UIDragDropHandler.SetItem(oldItem); } else { StatusMessages("Rejected different inventory"); RejectDrag(); } }
protected virtual void TrySwap() { if (InventorySystem.CanStack(InventoryItem, UIDragDropHandler.CurrentData)) { UIDragDropHandler.Take(); return; } Entity oldItem = Data; var dragInventoryData = UIDragDropHandler.CurrentData.Get <InventoryItem>(); var currentInventoryData = oldItem.Get <InventoryItem>(); if (dragInventoryData == null || currentInventoryData == null) { RejectDrag(); return; } if (dragInventoryData.Inventory == Player.MainInventory && currentInventoryData.Inventory == Player.MainInventory) { if (Player.MainInventory.TrySwap(dragInventoryData.Index, currentInventoryData.Index)) { UIDragDropHandler.Take(); Player.MainInventory.ContainerChanged(); return; } } if (Player.MainInventory.TryReplace(UIDragDropHandler.CurrentData, currentInventoryData.Index)) { UIDragDropHandler.Take(); UIDragDropHandler.SetItem(oldItem); Player.MainInventory.ContainerChanged(); } else { RejectDrag(); Player.MainInventory.TryAdd(oldItem); } }
protected virtual void TryDrop() { var dragInventoryData = UIDragDropHandler.CurrentData.Get <InventoryItem>(); if (dragInventoryData.Inventory == Player.MainInventory && Player.MainInventory.TryChangeIndex(dragInventoryData.Index, Index, dragInventoryData)) { Player.MainInventory.ContainerChanged(); UIDragDropHandler.Take(); return; } if (Player.MainInventory.Add(UIDragDropHandler.CurrentData, Index)) { UIDragDropHandler.Take(); } else { if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemReturn, transform.position, 0, AudioVolume); } UIDragDropHandler.Return(); } }
protected override void OnDropEvent() { if (UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } return; } //if (UIDragDropHandler.CurrentData.Durability.CurrentPercent > 0.99f) { // UIFloatingText.Spawn("Doesn't need repairs", transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); // UIDragDropHandler.Return(); // return; //} //var price = RpgSystem.RepairEstimate(UIDragDropHandler.CurrentData); //if (Player.Currency.Value < price) { // UIFloatingText.Spawn(string.Format("Repair Cost: {0} Not enough {1}", price, GameLabels.Currency), transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); // UIDragDropHandler.Return(); // return; //} //UIModalQuestion.Set(ConfirmRepair, string.Format("Repair for {0} {1}?", price, GameLabels.Currency)); }
protected override void StartDrag() { base.StartDrag(); UIDragDropHandler.Set(Data, StopDrag, StopDrag, Clear); }
private void StopDrag() { UIDragDropHandler.ClearData(); SetSpriteStatus(true); RefreshItem(); }