Beispiel #1
0
 private void Swap(UI_ItemSlot slot1, UI_ItemSlot slot2)
 {
     if (slot1.TrySetItem(slot2.Item))
     {
         slot2.Clear();
     }
 }
Beispiel #2
0
 public void SwapItem(UI_ItemSlot itemSlot)
 {
     if (hands.currentSlot != itemSlot)
     {
         hands.currentSlot.TryToSwapItem(itemSlot);
     }
 }
Beispiel #3
0
        public void Drop()
        {
            PlayerScript lps = PlayerManager.LocalPlayerScript;

            if (!lps || lps.canNotInteract())
            {
                return;
            }
            UI_ItemSlot currentSlot = UIManager.Hands.CurrentSlot;
            Vector3     dropPos     = lps.gameObject.transform.position;

            if (!currentSlot.CanPlaceItem())
            {
                return;
            }
            //            if ( isNotMovingClient(lps) )
            //            {
            //               // Full client simulation(standing still)
            //                var placedOk = currentSlot.PlaceItem(dropPos);
            //                if ( !placedOk )
            //                {
            //                    Debug.Log("Client dropping error");
            //                }
            //            }
            //            else
            //            {
            //Only clear slot(while moving, as prediction is shit in this situation)
            currentSlot.Clear();
            //            }
            //Message
            lps.playerNetworkActions.DropItem(currentSlot.eventName);
            SoundManager.Play("Click01");
            Debug.Log("Drop Button");
        }
        /// Throw mode toggle. Actual throw is in
        /// <see cref="InputController.CheckThrow()"/>
        public void Throw()
        {
            PlayerScript lps         = PlayerManager.LocalPlayerScript;
            UI_ItemSlot  currentSlot = UIManager.Hands.CurrentSlot;

            if (!lps || lps.canNotInteract() || !currentSlot.CanPlaceItem())
            {
                UIManager.IsThrow = false;
                throwImage.sprite = throwSprites[0];
                return;
            }

            SoundManager.Play("Click01");
//			Logger.Log("Throw Button");

            if (!UIManager.IsThrow)
            {
                UIManager.IsThrow = true;
                throwImage.sprite = throwSprites[1];
            }
            else
            {
                UIManager.IsThrow = false;
                throwImage.sprite = throwSprites[0];
            }
        }
 void Start()
 {
     beltSlot        = transform.FindChild("Belt").FindChild("itemSlot").GetComponent <UI_ItemSlot>();
     bagSlot         = transform.FindChild("Bag").FindChild("itemSlot").GetComponent <UI_ItemSlot>();
     IDSlot          = transform.FindChild("ID").FindChild("itemSlot").GetComponent <UI_ItemSlot>();
     suitStorageSlot = transform.FindChild("SuitStorage").FindChild("itemSlot").GetComponent <UI_ItemSlot>();
     storage01Slot   = transform.FindChild("Storage01").FindChild("itemSlot").GetComponent <UI_ItemSlot>();
     storage02Slot   = transform.FindChild("Storage02").FindChild("itemSlot").GetComponent <UI_ItemSlot>();
 }
Beispiel #6
0
        private void Swap(UI_ItemSlot slot1, UI_ItemSlot slot2)
        {
            if (PlayerManager.LocalPlayerScript != null)
            {
                if (!PlayerManager.LocalPlayerScript.playerMove.allowInput || PlayerManager.LocalPlayerScript.playerMove.isGhost)
                {
                    return;
                }
            }

            UIManager.TryUpdateSlot(new UISlotObject(slot1.eventName, slot2.Item));
        }
 public void UI_ItemDrag(UI_ItemSlot fromSlot)
 {
     if (fromSlot.Item != null && !isDragging)
     {
         DropInteracted    = false;
         FromSlotCache     = fromSlot;
         isDragging        = true;
         dragDummy.enabled = true;
         dragDummy.sprite  = fromSlot.Image.MainSprite;
         fromSlot.Clear();
         DraggedItem = fromSlot.ItemObject;
     }
 }
Beispiel #8
0
 public void SwapItem(UI_ItemSlot itemSlot)
 {
     if (CurrentSlot != itemSlot)
     {
         if (!CurrentSlot.IsFull)
         {
             Swap(CurrentSlot, itemSlot);
         }
         else
         {
             Swap(itemSlot, CurrentSlot);
         }
     }
 }
Beispiel #9
0
        /// <summary>
        /// Tries to add item from another slot
        /// </summary>
        /// <param name="otherSlot"></param>
        /// <returns></returns>
        public bool TryToSwapItem(UI_ItemSlot otherSlot)
        {
            if (!isFull && TryToAddItem(otherSlot.currentItem))
            {
                var item = otherSlot.RemoveItem();

                if (slotType == SlotType.LeftHand || slotType == SlotType.RightHand)
                {
                    playerSprites.PickedUpItem(item);
                }
                return(true);
            }
            return(false);
        }
Beispiel #10
0
        private void Swap(UI_ItemSlot slot1, UI_ItemSlot slot2)
        {
            if (PlayerManager.LocalPlayerScript != null)
            {
                if (!PlayerManager.LocalPlayerScript.playerMove.allowInput || PlayerManager.LocalPlayerScript.playerMove.isGhost)
                {
                    return;
                }
            }

            if (slot1.TrySetItem(slot2.Item))
            {
//				slot2.Clear();
            }
        }
        public static bool CanPutItemToSlot(UISlotObject proposedSlotInfo)
        {
            if (proposedSlotInfo.IsEmpty() || !SendUpdateAllowed(proposedSlotInfo.SlotContents))
            {
                return(false);
            }
            UI_ItemSlot  uiItemSlot = InventorySlots[proposedSlotInfo.Slot];
            PlayerScript lps        = PlayerManager.LocalPlayerScript;

            if (!lps || lps.canNotInteract() ||
                uiItemSlot == null || uiItemSlot.IsFull ||
                !uiItemSlot.CheckItemFit(proposedSlotInfo.SlotContents))
            {
                return(false);
            }
            return(true);
        }
Beispiel #12
0
        // whether selector should be on the right hand or the left
        public void SelectorState(bool isRight)
        {
            if (UIManager.control != null)
            {
                PlayClick01();

                if (isRight)
                {
                    selector.transform.position = rightHand.transform.position;
                    currentSlot = rightSlot;
                }
                else
                {
                    selector.transform.position = leftHand.transform.position;
                    currentSlot = leftSlot;
                }
            }
        }
Beispiel #13
0
        public void Use()
        {
            if (PlayerManager.LocalPlayerScript != null)
            {
                if (!PlayerManager.LocalPlayerScript.playerMove.allowInput ||
                    PlayerManager.LocalPlayerScript.playerMove.isGhost)
                {
                    return;
                }
            }

            if (!CurrentSlot.IsFull)
            {
                return;
            }

            //Is the item edible?
            if (CheckEdible())
            {
                return;
            }

            //This checks which UI slot the item can be equiped too and swaps it there
            ItemType   type       = Slots.GetItemType(CurrentSlot.Item);
            SpriteType masterType = Slots.GetItemMasterType(CurrentSlot.Item);

            switch (masterType)
            {
            case SpriteType.Clothing:
                UI_ItemSlot slot = Slots.GetSlotByItem(CurrentSlot.Item);
                SwapItem(slot);
                break;

            case SpriteType.Items:
                UI_ItemSlot itemSlot = Slots.GetSlotByItem(CurrentSlot.Item);
                SwapItem(itemSlot);
                break;

            case SpriteType.Guns:
                break;
            }
        }
Beispiel #14
0
        public void Drop()
        {
            PlayerScript lps = PlayerManager.LocalPlayerScript;

            if (!lps || lps.canNotInteract())
            {
                return;
            }
            UI_ItemSlot currentSlot = UIManager.Hands.CurrentSlot;
            Vector3     dropPos     = lps.gameObject.transform.position;

            if (!currentSlot.CanPlaceItem())
            {
                return;
            }
            //            if ( isNotMovingClient(lps) )
            //            {
            //               // Full client simulation(standing still)
            //                var placedOk = currentSlot.PlaceItem(dropPos);
            //                if ( !placedOk )
            //                {
            //                    Debug.Log("Client dropping error");
            //                }
            //            }
            //            else
            //            {
            //Only clear slot(while moving, as prediction is shit in this situation)
            GameObject         dropObj = currentSlot.Item;
            CustomNetTransform cnt     = dropObj.GetComponent <CustomNetTransform>();

            //It is converted to LocalPos in transformstate struct
            cnt.AppearAtPosition(PlayerManager.LocalPlayer.transform.position);
            currentSlot.Clear();
            //            }
            //Message
            lps.playerNetworkActions.RequestDropItem(currentSlot.eventName, false);
            SoundManager.Play("Click01");
            Debug.Log("Drop Button");
        }
Beispiel #15
0
        public void SwapItem(UI_ItemSlot itemSlot)
        {
            if (PlayerManager.LocalPlayerScript != null)
            {
                if (!PlayerManager.LocalPlayerScript.playerMove.allowInput || PlayerManager.LocalPlayerScript.playerMove.isGhost)
                {
                    return;
                }
            }

            if (CurrentSlot != itemSlot)
            {
                if (!CurrentSlot.IsFull)
                {
                    Swap(CurrentSlot, itemSlot);
                }
                else
                {
                    Swap(itemSlot, CurrentSlot);
                }
            }
        }
Beispiel #16
0
 private void Start()
 {
     itemSlot = GetComponentInChildren <UI_ItemSlot>();
 }
Beispiel #17
0
 // Use this for initialization
 void Start()
 {
     actions     = gameObject.AddComponent <HandActions>();
     currentSlot = rightSlot;
 }
Beispiel #18
0
 private void Awake()
 {
     itemSlot = GetComponentInChildren <UI_ItemSlot>();
 }