Split() public static method

public static Split ( ObjectInteraction splitFrom ) : void
splitFrom ObjectInteraction
return void
    /// <summary>
    /// Handle player choosing how many items to pick up in a stack
    /// </summary>
    /// <param name="quant"></param>
    public void OnSubmitPickup(int quant)
    {
        InputField inputctrl = UWHUD.instance.InputControl;

        inputctrl.text = "";
        inputctrl.gameObject.SetActive(false);
        WindowDetect.WaitingForInput = false;
        ConversationVM.EnteringQty   = false;
        if (ConversationVM.InConversation == false)
        {
            UWHUD.instance.MessageScroll.Clear();
            Time.timeScale = 1.0f;
        }
        else
        {
            UWHUD.instance.ConversationButtonParent.SetActive(true);
            UWHUD.instance.MessageScroll.Set("");
            // UWHUD.instance.MessageScroll.NewUIOUt.text = InventorySlot.TempLookAt;//Restore original text
        }

        if (quant == 0)
        {//cancel
            QuantityObj = null;
        }
        if (QuantityObj != null)
        {//Just do a normal pickup.
            if (quant >= QuantityObj.GetComponent <ObjectInteraction>().link)
            {
                CurrentObjectInHand = QuantityObj;
                if (this.slotIndex >= 11)
                {
                    UWCharacter.Instance.playerInventory.currentContainer.RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11);
                }
                UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex);
            }
            else
            {
                //split the obj.
                ObjectInteraction objI = QuantityObj.GetComponent <ObjectInteraction>();
                objI.link = objI.link - quant;
                ObjectLoaderInfo newObj = ObjectLoader.newWorldObject(objI.item_id, objI.quality, objI.owner, quant, -1);
                newObj.is_quant = 1;
                ObjectInteraction NewObjI = ObjectInteraction.CreateNewObject(CurrentTileMap(), newObj, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker, GameWorldController.instance.InventoryMarker.transform.position);
                GameWorldController.MoveToInventory(NewObjI);
                CurrentObjectInHand = NewObjI;
                ObjectInteraction.Split(objI, NewObjI);
                UWCharacter.Instance.playerInventory.Refresh();
                QuantityObj = null;
            }
        }
    }
Beispiel #2
0
    public void OnSubmitPickup(int quant)
    {
        InputField inputctrl = UWHUD.instance.InputControl;       //UWHUD.instance.MessageScroll.gameObject.GetComponent<UIInput>();

        Time.timeScale = 1.0f;
        inputctrl.gameObject.SetActive(false);
        WindowDetectUW.WaitingForInput = false;
        inputctrl.text = "";
        inputctrl.text = "";
        UWHUD.instance.MessageScroll.Clear();
        //int quant= int.Parse(inputctrl.text);
        if (quant == 0)
        {        //cancel
            QuantityObj = null;
        }
        if (QuantityObj != null)
        {
            if (quant >= QuantityObj.link)
            {
                Pickup(QuantityObj, playerInventory);
            }
            else
            {
                //split the obj.


                ObjectLoaderInfo newobjt = ObjectLoader.newObject(QuantityObj.item_id, QuantityObj.quality, QuantityObj.owner, quant, 256);
                newobjt.is_quant    = QuantityObj.isquant;
                newobjt.flags       = QuantityObj.flags;
                newobjt.enchantment = QuantityObj.enchantment;
                newobjt.doordir     = QuantityObj.doordir;
                newobjt.invis       = QuantityObj.invis;
                ObjectInteraction Split = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.LevelMarker().gameObject, QuantityObj.transform.position);
                newobjt.InUseFlag = 1;
                QuantityObj.link -= quant;

                //GameObject Split = Instantiate(QuantityObj.gameObject);//What we are picking up.
                //Split.GetComponent<ObjectInteraction>().link =quant;
                //Split.name = Split.name+"_"+summonCount++;
                //QuantityObj.link=QuantityObj.link-quant;
                Pickup(Split, playerInventory);
                ObjectInteraction.Split(Split, QuantityObj);
                QuantityObj = null;              //Clear out to avoid weirdness.
            }
        }
    }
    public void OnSubmitPickup(int quant)
    {
        InputField inputctrl = UWHUD.instance.InputControl;

        inputctrl.text = "";
        inputctrl.gameObject.SetActive(false);
        WindowDetect.WaitingForInput = false;
        ConversationVM.EnteringQty   = false;
        if (ConversationVM.InConversation == false)
        {
            UWHUD.instance.MessageScroll.Clear();
            Time.timeScale = 1.0f;
        }
        else
        {
            UWHUD.instance.MessageScroll.NewUIOUt.text = InventorySlot.TempLookAt;            //Restore original text
        }

        if (quant == 0)
        {        //cancel
            QuantityObj = null;
        }
        if (QuantityObj != null)
        {        //Just do a normal pickup.
            if (quant >= QuantityObj.GetComponent <ObjectInteraction>().link)
            {
                UWCharacter.Instance.playerInventory.ObjectInHand = QuantityObj.name;
                UWHUD.instance.CursorIcon = QuantityObj.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
                if (this.slotIndex >= 11)
                {
                    UWCharacter.Instance.playerInventory.GetCurrentContainer().RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11);
                }
                UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex);
            }
            else
            {
                //split the obj.
                ObjectInteraction objI = QuantityObj.GetComponent <ObjectInteraction>();
                objI.link = objI.link - quant;
                ObjectLoaderInfo newObj = ObjectLoader.newObject(objI.item_id, objI.quality, objI.owner, quant, -1);
                newObj.is_quant = 1;
                ObjectInteraction NewObjI = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newObj, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker, GameWorldController.instance.InventoryMarker.transform.position);
                GameWorldController.MoveToInventory(NewObjI);
                UWCharacter.Instance.playerInventory.ObjectInHand = NewObjI.name;
                UWHUD.instance.CursorIcon = NewObjI.GetInventoryDisplay().texture;
                ObjectInteraction.Split(objI, NewObjI);
                UWCharacter.Instance.playerInventory.Refresh(slotIndex);
                QuantityObj = null;


                /*	GameObject Split = Instantiate(QuantityObj);//What we are picking up.
                 *      Split.GetComponent<ObjectInteraction>().link =quant;
                 *      Split.name = Split.name+"_"+UWCharacter.Instance.summonCount++;
                 *      Split.transform.parent=UWCharacter.Instance.playerInventory.InventoryMarker.transform;//this.transform.parent;
                 *      QuantityObj.GetComponent<ObjectInteraction>().link=QuantityObj.GetComponent<ObjectInteraction>().link-quant;
                 *      UWCharacter.Instance.playerInventory.ObjectInHand= Split.name;
                 *      UWHUD.instance.CursorIcon= Split.GetComponent<ObjectInteraction>().GetInventoryDisplay().texture;
                 *      ObjectInteraction.Split (Split.GetComponent<ObjectInteraction>(),QuantityObj.GetComponent<ObjectInteraction>());
                 *      UWCharacter.Instance.playerInventory.Refresh (slotIndex);
                 *      QuantityObj=null;//Clear out to avoid weirdness.*/
            }
        }
    }