Exemplo n.º 1
0
    private void AttemptRemoveFromInventory(PointerEventData eventData)
    {
        if (eventData == null)
        {
            return;
        }
        Text t = eventData.pointerEnter.GetComponent <Text> ();

        if (t != null)
        {
            InventoryContent ic = getInventoryContentFromName(t.text);
            if (ic != null && ic.obj != null)
            {
                DropAtCurrentLocation(ic.obj);
                if (RemoveFromInventory(ic.obj))
                {
                    Debug.Log("Remove Succeeded.");
                }
                else
                {
                    Debug.Log("Remove Not Succeeded.");
                }
                returnToGameStateFromInventory();
            }
        }
    }
 // Get InventoryContent in child.
 void Start()
 {
     content = GetComponentInChildren <InventoryContent>();
     if (content == null)
     {
         Debug.LogError("Content not found in " + this.transform.parent.transform.parent.name);
     }
 }
Exemplo n.º 3
0
        private Packet CreatePe(byte messageId, ReadOnlyMemory <byte> buffer)
        {
            Packet packet = null;

            try
            {
                switch (messageId)
                {
                case 111:     //Fixes entity delta
                    packet = new EntityDelta();
                    break;

                //The following are only here so we can join.
                case 49:
                    packet = new InventoryContent();
                    break;

                case 31:
                    packet = new MobEquipment();
                    break;

                case 122:
                    packet = new BiomeDefinitionList();
                    break;

                case 119:
                    packet = new AvailableEntityIdentifiers();
                    break;

                case 32:
                    packet = new MobArmorEquipment();
                    break;

                case 50:
                    packet = new InventorySlot();
                    break;

                case 7:
                    packet = new McpeResourcePackStack();
                    break;

                case 39:
                    packet = new McpeSetEntityData();
                    break;
                }

                packet?.Decode(buffer);
            }
            catch (Exception ex)
            {
                if (messageId != 39)
                {
                    //    Log.Error(ex, $"Processing error: {ex.ToString()}");
                }
            }

            return(packet);
        }
Exemplo n.º 4
0
 public bool AddToInventory(GameObject objToAdd)
 {
     for (int i = 0; i < contents.Length; i++)
     {
         if (contents [i].obj == null)
         {
             Debug.Log("Add " + objToAdd.name + " to Inventory slot " + i.ToString() + ".");
             Text t = GetComponentsInChildren <Text> () [i];
             t.text       = objToAdd.name;
             contents [i] = new InventoryContent(t, objToAdd);
             return(true);
         }
     }
     Debug.Log("Cannot add " + objToAdd.name + " to Inventory. Inventory full.");
     return(false);
 }