Esempio 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);
    }
Esempio n. 2
0
 public void OnRemoveFromPool()
 {
     if (CurrentMagazine != null)
     {
         EquipmentPool.DisposeOfObject(NetworkServer.FindLocalObject(ControlledByPlayer).gameObject, CurrentMagazine.gameObject);
     }
     ControlledByPlayer = NetworkInstanceId.Invalid;
 }
Esempio n. 3
0
    private IEnumerator InitiateRespawn(int timeout)
    {
        //Debug.LogFormat("{0}: Initiated respawn in {1}s", gameObject.name, timeout);
        yield return(new WaitForSeconds(timeout));

        RpcAdjustForRespawn();

        EquipmentPool.ClearPool(gameObject);

        SpawnHandler.RespawnPlayer(connectionToClient, playerControllerId, playerScript.JobType);
    }
Esempio n. 4
0
    public void RespawnPlayer()
    {
        RpcAdjustForRespawn();
        var spawn     = CustomNetworkManager.Instance.GetStartPosition();
        var newPlayer = ( GameObject)Instantiate(CustomNetworkManager.Instance.playerPrefab, spawn.position, spawn.rotation);

//		NetworkServer.Destroy( this.gameObject );
        EquipmentPool.ClearPool(gameObject.name);
        PlayerList.Instance.connectedPlayers[gameObject.name] = newPlayer;
        NetworkServer.ReplacePlayerForConnection(this.connectionToClient, newPlayer, this.playerControllerId);
    }
 public void Consume(GameObject item)
 {
     foreach (var slot in Inventory)
     {
         if (item == slot.Value)
         {
             ClearInventorySlot(slot.Key);
             break;
         }
     }
     EquipmentPool.DisposeOfObject(gameObject, item);
 }
Esempio n. 6
0
    public override void OnStartServer()
    {
        InitEquipment();

        EquipmentPool equipPool = FindObjectOfType <EquipmentPool>();

        if (equipPool == null)
        {
            Instantiate(Resources.Load("EquipmentPool") as GameObject, Vector2.zero, Quaternion.identity);
        }

        base.OnStartServer();
    }
Esempio n. 7
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);
    }
Esempio n. 8
0
    private IEnumerator initiateRespawn(int timeout)
    {
        Debug.LogFormat("{0}: Initiated respawn in {1}s", gameObject.name, timeout);
        yield return(new WaitForSeconds(timeout));

        RpcAdjustForRespawn();
        var spawn     = CustomNetworkManager.Instance.GetStartPosition();
        var newPlayer =
            Instantiate(CustomNetworkManager.Instance.playerPrefab, spawn.position, spawn.rotation);

        //		NetworkServer.Destroy( this.gameObject );
        EquipmentPool.ClearPool(gameObject.name);
        PlayerList.Instance.connectedPlayers[gameObject.name] = newPlayer;
        NetworkServer.ReplacePlayerForConnection(connectionToClient, newPlayer, playerControllerId);
    }
Esempio n. 9
0
    public bool ValidateDropItem(string slot, bool forceClientInform /* = false*/)
    {
        //decline if not dropped from hands?
        if (_inventory.ContainsKey(slot) && _inventory[slot])
        {
            EquipmentPool.DropGameObject(gameObject, _inventory[slot]);

            //            RpcAdjustItemParent(_inventory[slot], null);
            _inventory[slot] = null;
            equipment.ClearItemSprite(slot);
            UpdateSlotMessage.Send(gameObject, slot, null, forceClientInform);
            return(true);
        }
        Debug.Log("Object not found in Inventory for: " + gameObject.name);
        return(false);
    }
Esempio n. 10
0
 [Command][Obsolete]//see placeitem
 public void CmdPlaceItemCupB(string eventName, Vector3 pos, GameObject newParent)
 {
     if (_inventory.ContainsKey(eventName))
     {
         if (_inventory[eventName] != null)
         {
             GameObject item = _inventory[eventName];
             EquipmentPool.DropGameObject(gameObject, _inventory[eventName], pos);
             _inventory[eventName] = null;
             ClosetControl closetCtrl = newParent.GetComponent <ClosetControl>();
             item.transform.parent = closetCtrl.items.transform;
             RpcAdjustItemParentCupB(item, newParent);
             equipment.ClearItemSprite(eventName);
         }
     }
 }
Esempio n. 11
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");
         }
     }
 }
Esempio n. 12
0
    public void PlaceItem(string slotName, Vector3 pos, GameObject newParent)
    {
        if (!SlotNotEmpty(slotName))
        {
            return;
        }
        GameObject item = _inventory[slotName];

        EquipmentPool.DropGameObject(gameObject, _inventory[slotName], pos);
        ClearInventorySlot(slotName);
        if (item != null && newParent != null)
        {
            item.transform.parent = newParent.transform;
            World.ReorderGameobjectsOnTile(pos);
        }
    }
    private IEnumerator InitiateRespawn(int timeout)
    {
        Debug.LogFormat("{0}: Initiated respawn in {1}s", gameObject.name, timeout);
        yield return(new WaitForSeconds(timeout));

        RpcAdjustForRespawn();

        EquipmentPool.ClearPool(gameObject.name);

        //Remove player objects
        PlayerList.Instance.RemovePlayer(gameObject.name);
        //Re-add player to name list because a respawning player didn't disconnect
        PlayerList.Instance.CheckName(gameObject.name);

        SpawnHandler.RespawnPlayer(connectionToClient, playerControllerId, playerScript.JobType);
    }
Esempio n. 14
0
    public void CmdDropItem(string eventName)
    {
        if (ServerCache.ContainsKey(eventName))
        {
            if (ServerCache[eventName] != null)
            {
                GameObject item = ServerCache[eventName];
                EquipmentPool.DropGameObject(gameObject.name, ServerCache[eventName]);

                RpcAdjustItemParent(ServerCache[eventName], null);
                ServerCache[eventName] = null;
                equipment.ClearItemSprite(eventName);
            }
            else
            {
                Debug.Log("Object not found in ServerCache");
            }
        }
    }
Esempio n. 15
0
    public void CmdDropItem(string eventName)
    {
        if (_inventory.ContainsKey(eventName))
        {
            if (_inventory[eventName] != null)
            {
                GameObject item = _inventory[eventName];
                EquipmentPool.DropGameObject(gameObject, _inventory[eventName]);

                RpcAdjustItemParent(_inventory[eventName], null);
                _inventory[eventName] = null;
                equipment.ClearItemSprite(eventName);
            }
            else
            {
                Debug.Log("Object not found in Inventory");
            }
        }
    }
Esempio n. 16
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");
         }
     }
 }
Esempio n. 17
0
 public void CmdPlaceItem(string eventName, Vector3 pos, GameObject newParent)
 {
     if (ServerCache.ContainsKey(eventName))
     {
         if (ServerCache[eventName] != null)
         {
             GameObject item = ServerCache[eventName];
             EquipmentPool.DropGameObject(gameObject.name, ServerCache[eventName], pos);
             ServerCache[eventName] = null;
             if (item != null && newParent != null)
             {
                 item.transform.parent = newParent.transform;
                 World.ReorderGameobjectsOnTile(pos);
             }
             RpcAdjustItemParent(item, newParent);
             equipment.ClearItemSprite(eventName);
         }
     }
 }
 public void DropItem(string slot = "", bool forceClientInform = true)
 {
     //Drop random item
     if (slot == "")
     {
         slot = "uniform";
         foreach (var key in Inventory.Keys)
         {
             if (Inventory[key])
             {
                 slot = key;
                 break;
             }
         }
     }
     EquipmentPool.DropGameObject(gameObject, Inventory[slot]);
     Inventory[slot] = null;
     equipment.ClearItemSprite(slot);
     UpdateSlotMessage.Send(gameObject, slot, null, forceClientInform);
 }
    public ShopSelection GenerateSelection(ShopCardPool cards, EquipmentPool equipment, PartyAdventureState party)
    {
        var partyClasses = new HashSet <string>(party.BaseHeroes.Select(h => h.Class.Name).Concat(CharacterClass.All));

        var selectedCards = PickCards(party, cards, NumCards);

        var weightedEquipment = equipment
                                .All
                                .Where(x => x.Classes.Any(c => partyClasses.Contains(c)))
                                .FactoredByRarity(x => x.Rarity)
                                .ToArray()
                                .Shuffled();

        var selectedEquipment = new HashSet <Equipment>();

        for (var i = 0; i < weightedEquipment.Length && selectedEquipment.Count < NumEquipment; i++)
        {
            selectedEquipment.Add(weightedEquipment[i]);
        }

        return(new ShopSelection(selectedEquipment.ToList(), selectedCards.ToList()));
    }
Esempio n. 20
0
 public void AddToEquipmentPool(GameObject obj)
 {
     EquipmentPool.AddGameObject(gameObject, obj);
 }
Esempio n. 21
0
 public void CmdDropItemNotInUISlot(GameObject obj)
 {
     EquipmentPool.DropGameObject(gameObject, obj);
 }
Esempio n. 22
0
 public void RemoveFromEquipmentPool(GameObject obj)
 {
     EquipmentPool.DropGameObject(gameObject, obj);
 }
Esempio n. 23
0
 public void DisposeOfChildItem(GameObject obj)
 {
     EquipmentPool.DisposeOfObject(gameObject, obj);
 }