예제 #1
0
        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();
            }
        }
예제 #2
0
 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();
     }
 }
예제 #3
0
        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));
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
 private void TryAddPlayer()
 {
     UIDragDropHandler.ClearData();
     if (Player.MainInventory.TryAdd(Data))
     {
         Clear();
     }
 }
예제 #6
0
 private void TryAddPlayer()
 {
     UIDragDropHandler.ClearData();
     if (World.Get <ContainerSystem>().TryAdd(Player.MainInventory, Data))
     {
         Clear();
     }
 }
예제 #7
0
 protected void RejectDrag()
 {
     if (PlayAudio)
     {
         AudioPool.PlayClip(StringConst.AudioDefaultItemReturn, transform.position, 0, AudioVolume);
     }
     UIDragDropHandler.Return();
 }
예제 #8
0
 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();
     }
 }
예제 #10
0
 public override void OnDrop(PointerEventData eventData)
 {
     if (UIDragDropHandler.CurrentData == null)
     {
         if (UIDragDropHandler.Active)
         {
             UIDragDropHandler.Return();
         }
     }
     else
     {
         //UIInventoryShop.TrySellDrag(transform);
     }
 }
예제 #11
0
 protected override void OnDropEvent()
 {
     if (UIDragDropHandler.CurrentData == null)
     {
         if (UIDragDropHandler.Active)
         {
             UIDragDropHandler.Return();
         }
     }
     else
     {
         //UIInventoryShop.TrySellDrag(transform);
     }
 }
예제 #12
0
 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();
 }
예제 #13
0
 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();
     }
 }
예제 #14
0
 public void OnDrop(PointerEventData eventData)
 {
     if (UIDragDropHandler.CurrentData == null)
     {
         return;
     }
     if (!_active)
     {
         UIDragDropHandler.Return();
         return;
     }
     if (Player.MainInventory.Add(UIDragDropHandler.CurrentData))
     {
         UIDragDropHandler.Take();
     }
 }
예제 #15
0
 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();
     }
 }
예제 #16
0
 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();
 }
예제 #17
0
        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();
        }
예제 #18
0
        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();
        }
예제 #19
0
        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);
        }
예제 #20
0
        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();
            }
        }
예제 #21
0
        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);
            }
        }
예제 #22
0
        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();
            }
        }
예제 #23
0
 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));
 }
예제 #24
0
 protected override void StartDrag()
 {
     base.StartDrag();
     UIDragDropHandler.Set(Data, StopDrag, StopDrag, Clear);
 }
예제 #25
0
 private void StopDrag()
 {
     UIDragDropHandler.ClearData();
     SetSpriteStatus(true);
     RefreshItem();
 }