Ejemplo n.º 1
0
    //Hand item sprites after picking up an item (server)
    public void SetHandItem(string slotName, GameObject obj)
    {
        ItemAttributes att = obj.GetComponent <ItemAttributes>();

        EquipmentPool.AddGameObject(gameObject, obj);
        SetHandItemSprite(att);
        RpcSendMessage(slotName, obj);
    }
Ejemplo n.º 2
0
    public bool AddItem(GameObject itemObject, string slotName = null, bool replaceIfOccupied = false, bool forceInform = true)
    {
        string eventName = slotName ?? UIManager.Hands.CurrentSlot.eventName;

        if (Inventory[eventName] != null && Inventory[eventName] != itemObject && !replaceIfOccupied)
        {
            Debug.LogFormat("{0}: Didn't replace existing {1} item {2} with {3}", gameObject.name, eventName, Inventory[eventName].name, itemObject.name);
            return(false);
        }
        EquipmentPool.AddGameObject(gameObject, itemObject);
        SetInventorySlot(slotName, itemObject);
        UpdateSlotMessage.Send(gameObject, eventName, itemObject, forceInform);
        return(true);
    }
Ejemplo n.º 3
0
 public void CmdTryToPickUpObject(string eventName, GameObject obj)
 {
     if (ServerCache.ContainsKey(eventName))
     {
         if (ServerCache[eventName] == null || ServerCache[eventName] == obj)
         {
             EquipmentPool.AddGameObject(gameObject, obj);
             ServerCache[eventName] = obj;
             equipment.SetHandItem(eventName, obj);
         }
         else
         {
             Debug.Log("ServerCache slot is full");
         }
     }
 }
Ejemplo n.º 4
0
 public void CmdTryToInstantiateInHand(string eventName, GameObject prefab)
 {
     if (_inventory.ContainsKey(eventName))
     {
         if (_inventory[eventName] == null)
         {
             GameObject item = Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject;
             NetworkServer.Spawn(item);
             EquipmentPool.AddGameObject(gameObject, item);
             _inventory[eventName] = item;
             equipment.SetHandItem(eventName, item);
             RpcInstantiateInHand(gameObject.name, item);
         }
         else
         {
             Debug.Log("Inventory slot is full");
         }
     }
 }
Ejemplo n.º 5
0
 public void AddToEquipmentPool(GameObject obj)
 {
     EquipmentPool.AddGameObject(gameObject, obj);
 }