Beispiel #1
0
 public void PlayerSlotLeftClick()
 {
     if (TradeSlot.Locked)
     {
         return;
     }
     if (UWCharacter.Instance.playerInventory.ObjectInHand != "")
     {
         //put the object in hand in this slot.
         if (objectInSlot == "")
         {            //Empty slot
             GameObject objToMove = UWCharacter.Instance.playerInventory.GetGameObjectInHand();
             if (objToMove != null)
             {
                 if (objToMove.transform.parent != GameWorldController.instance.DynamicObjectMarker())
                 {                    //Object needs to be moved to world
                     //objToMove.transform.parent= GameWorldController.instance.DynamicObjectMarker();
                     GameWorldController.MoveToWorld(objToMove);
                     ConversationVM.BuildObjectList();
                 }
                 objectInSlot = UWCharacter.Instance.playerInventory.ObjectInHand;
                 UWCharacter.Instance.playerInventory.ObjectInHand = "";
                 SlotImage.texture         = UWHUD.instance.CursorIcon;
                 UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
                 Selected = true;
             }
         }
         else
         {            //Swap the objects
             GameObject objInSlot = GetGameObjectInteraction().gameObject;
             GameObject objInHand = UWCharacter.Instance.playerInventory.GetGameObjectInHand();
             if (objInSlot != null)
             {
                 objInSlot.transform.parent = GameWorldController.instance.InventoryMarker.transform;
                 GameWorldController.MoveToInventory(objInSlot);                    //This will call rebuild list
             }
             if (objInHand != null)
             {
                 if (objInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker())
                 {                    //Object needs to be moved to world
                     //objInHand.transform.parent= GameWorldController.instance.DynamicObjectMarker();
                     GameWorldController.MoveToWorld(objInHand);
                 }
             }
             objectInSlot              = objInHand.name;
             SlotImage.texture         = objInHand.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
             UWHUD.instance.CursorIcon = objInSlot.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
             UWCharacter.Instance.playerInventory.ObjectInHand = objInSlot.name;
             ConversationVM.BuildObjectList();
             Selected = true;
         }
     }
     else
     {
         if (objectInSlot != "")
         {
             //Pickup the object in the slot
             UWCharacter.Instance.playerInventory.SetObjectInHand(objectInSlot);
             UWHUD.instance.CursorIcon = UWCharacter.Instance.playerInventory.GetGameObject(objectInSlot).GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
             objectInSlot      = "";
             SlotImage.texture = Blank;
             Selected          = false;
             GameObject objToMove = UWCharacter.Instance.playerInventory.GetGameObjectInHand();
             if (objToMove != null)
             {
                 objToMove.transform.parent = GameWorldController.instance.InventoryMarker.transform;
                 GameWorldController.MoveToInventory(objToMove);                    //This will call rebuild list
                 objToMove.GetComponent <object_base>().PickupEvent();
             }
         }
     }
     if (objectInSlot == "")
     {
         Quantity.text = "";
     }
     else
     {
         int qty = GetGameObjectInteraction().GetQty();
         if (qty <= 1)
         {
             Quantity.text = "";
         }
         else
         {
             Quantity.text = qty.ToString();
         }
     }
 }
Beispiel #2
0
    public void PlayerSlotLeftClick()
    {
        if (TradeSlot.Locked)
        {
            return;
        }
        ObjectInteraction objIntAtSlot = GetGameObjectInteraction();

        if (CurrentObjectInHand != null)
        {
            //put the object in hand in this slot.
            if (objectInSlot == null)
            {            //Empty slot
                if (CurrentObjectInHand != null)
                {
                    if (CurrentObjectInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker())
                    {                    //Object needs to be moved to world
                        GameWorldController.MoveToWorld(CurrentObjectInHand);
                        ConversationVM.BuildObjectList();
                    }
                    objectInSlot        = CurrentObjectInHand;
                    SlotImage.texture   = UWHUD.instance.CursorIcon;
                    CurrentObjectInHand = null;
                    Selected            = true;
                }
            }
            else
            {            //Swap the objects
                if (objIntAtSlot != null)
                {
                    objIntAtSlot.transform.parent = GameWorldController.instance.InventoryMarker.transform;
                    GameWorldController.MoveToInventory(objIntAtSlot);                    //This will call rebuild list
                }
                if (CurrentObjectInHand != null)
                {
                    if (CurrentObjectInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker())
                    {                    //Object needs to be moved to world
                        GameWorldController.MoveToWorld(CurrentObjectInHand);
                    }
                }
                objectInSlot        = CurrentObjectInHand;
                SlotImage.texture   = CurrentObjectInHand.GetInventoryDisplay().texture;
                CurrentObjectInHand = objIntAtSlot;
                ConversationVM.BuildObjectList();
                Selected = true;
            }
        }
        else
        {
            if (objectInSlot != null)
            {
                //Pickup the object in the slot
                CurrentObjectInHand = objIntAtSlot;
                objectInSlot        = null;
                SlotImage.texture   = Blank;
                Selected            = false;
                if (CurrentObjectInHand != null)
                {
                    CurrentObjectInHand.transform.parent = GameWorldController.instance.InventoryMarker.transform;
                    GameWorldController.MoveToInventory(CurrentObjectInHand);                    //This will call rebuild list
                    CurrentObjectInHand.GetComponent <object_base>().PickupEvent();
                }
            }
        }
        if (objectInSlot == null)
        {
            Quantity.text = "";
        }
        else
        {
            int qty = GetGameObjectInteraction().GetQty();
            if (qty <= 1)
            {
                Quantity.text = "";
            }
            else
            {
                Quantity.text = qty.ToString();
            }
        }
    }