public RuntimeItem LoadRuntimeItem(Item item, int playerID)
    {
        RuntimeItem runtimeItem = new RuntimeItem(item);

        StartCoroutine(LoadItem(runtimeItem, playerID));
        return(runtimeItem);
    }
    public void InitializePlayer(Dictionary <string, Item> items, int playerID)
    {
        _playerID = playerID;

        foreach (var pair in items)
        {
            RuntimeItem runtimeItem = _loadControl.LoadRuntimeItem(pair.Value, _playerID);
        }
    }
 public void AddLoadedWear(RuntimeItem runItem)
 {
     if (Wear.ContainsKey(runItem.Item.Slot))
     {
         Destroy(Wear[runItem.Item.Slot]);
         Wear[runItem.Item.Slot] = runItem.Prefab;
         Wear[runItem.Item.Slot] = _boneCombine.AddLimb(runItem.Prefab).gameObject;
     }
 }
Beispiel #4
0
    public void AddItemToPlayer(RuntimeItem runItem)
    {
        if (!Inventory.ContainsKey(runItem.Item.Slot))
        {
            Inventory.Add(runItem.Item.Slot, runItem);
        }
        else
        {
            Inventory[runItem.Item.Slot] = runItem;
        }

        if (runItem.Item is Wearable)
        {
            for (int i = 0; i < NetInventory.Wearables.Length; i++)
            {
                if (NetInventory.Wearables[i].Slot == runItem.Item.Slot)
                {
                    NetInventory.Wearables[i] = runItem.Item as Wearable;
                }
            }
        }
        if (runItem.Item is Holdable)
        {
            for (int i = 0; i < NetInventory.Wearables.Length; i++)
            {
                if (NetInventory.Holdables[i].Slot == runItem.Item.Slot)
                {
                    NetInventory.Holdables[i] = runItem.Item as Holdable;
                }
            }
        }
        if (runItem.Item is Consumable)
        {
            for (int i = 0; i < NetInventory.Wearables.Length; i++)
            {
                if (NetInventory.Consumable[i].Slot == runItem.Item.Slot)
                {
                    NetInventory.Consumable[i] = runItem.Item as Consumable;
                }
            }
        }
        if (runItem.Item is Misc)
        {
            for (int i = 0; i < NetInventory.Wearables.Length; i++)
            {
                if (NetInventory.Misc[i].Slot == runItem.Item.Slot)
                {
                    NetInventory.Misc[i] = runItem.Item as Misc;
                }
            }
        }

        _player.playerData = JsonConvert.SerializeObject(NetInventory, _settings);
    }
        public void RetrieveAdditionalInformationTest_withInvalidID(string value)
        {
            // Arrange
            RuntimeItem item = new RuntimeItem("_aa1", "Runtime");

            item.BaseTableName = value;

            // Act
            int count = item.RetrieveAdditionalInformation();

            // Assert
            Assert.AreEqual(0, count);
        }
Beispiel #6
0
    public void LoadLoot(List <Item> items, int ownerID, int lootID)
    {
        int lootI = 0;

        foreach (var item in items)
        {
            item.Slot = lootI.ToString();
            RuntimeItem runtimeItem = _loadControl.LoadRuntimeItem(item, ownerID);
            LootSlots[lootI].RuntimeItem = runtimeItem;
            lootI++;
        }
        _lootID = lootID;
        ToggleInventory(true);
    }
    public void SendSwapRequest(RuntimeItem newWear, RuntimeItem oldWear)
    {
        Debug.Log("Send swap wear request to server: " + newWear.Item.Name);
        JsonSerializerSettings settings = new JsonSerializerSettings {
            TypeNameHandling = TypeNameHandling.All, ReferenceLoopHandling = ReferenceLoopHandling.Ignore
        };
        Netwearable netItem     = newWear.Item.MakeNetWear();
        Netwearable netItemOld  = oldWear.Item.MakeNetWear();
        string      newWearjson = JsonConvert.SerializeObject(netItem, settings);
        string      oldWearjson = JsonConvert.SerializeObject(netItemOld, settings);

        ClientSend.SendJsonPackage(newWearjson);
        ClientSend.SendJsonPackage(oldWearjson);
    }
Beispiel #8
0
    public void SwapWear(RuntimeItem runItem)
    {
        Debug.Log(runItem.Item.Name);
        if (Wear.ContainsKey(runItem.Item.Slot))
        {
            if (Wear[runItem.Item.Slot] != null)
            {
                GameObject.Destroy(Wear[runItem.Item.Slot].gameObject);
            }

            Wear[runItem.Item.Slot] = runItem.Prefab;
            Wear[runItem.Item.Slot] = _boneCombine.AddLimb(runItem.Prefab).gameObject;
        }
        else
        {
            Debug.Log($"Itemslot missmatch Item: {runItem.Item.Name}, Slot: {runItem.Item.Slot}");
        }
    }
        public void RuntimeItemTest_withID()
        {
            // Arrange
            RuntimeItem item = new RuntimeItem("_xx1", "Runtime");

            // Act
            // Assert
            Assert.IsNotNull(item);
            Assert.IsNotNull(item.Reader);
            Assert.AreEqual("", item.BaseTableName);
            Assert.AreEqual("Runtime", item.TargetTableName);

            Assert.AreEqual("_xx1", item.ID);
            Assert.AreEqual(0, item.Runtime);
            Assert.IsNull(item.Edition);
            Assert.IsNull(item.Details);
            Assert.IsNull(item.Status);
            Assert.IsNull(item.LastUpdated);
        }
        public void RetrieveBasicInformationTest_withValidID_AdditionalInfo(string value)
        {
            // Arrange
            RuntimeItem item = new RuntimeItem("_xx1", "Runtime");

            item.BaseTableName = value;

            // Act
            int count = item.RetrieveBasicInformation(false);

            // Assert
            Assert.AreEqual(1, count);

            Assert.AreEqual("_xx1", item.ID);
            Assert.AreEqual(11, item.Runtime);
            Assert.AreEqual("_xxx", item.Edition.ID);
            Assert.AreEqual($"{value} Runtime Details X1", item.Details);
            Assert.AreEqual("_xxx", item.Status.ID);
            Assert.AreEqual($"{value} Runtime LastUpdated X1", item.LastUpdated);
        }
        public void RetrieveTest_withInvalidID_AdditionalInfo(string value)
        {
            // Arrange
            RuntimeItem item = new RuntimeItem("_aa1", "Runtime");

            item.BaseTableName = value;

            // Act
            int count = item.Retrieve(false);

            // Assert
            Assert.AreEqual(0, count);

            Assert.AreEqual("_aa1", item.ID);
            Assert.AreEqual(0, item.Runtime);
            Assert.IsNull(item.Edition);
            Assert.IsNull(item.Details);
            Assert.IsNull(item.Status);
            Assert.IsNull(item.LastUpdated);
        }
    public virtual void OnItemDropped(ItemView draggable, bool isLoot)
    {
        if (_currentView != null)
        {
            _currentView.transform.position = draggable.currentParent.position;
            _currentView.transform.SetParent(draggable.currentParent);
            _currentView.RuntimeItem.Item.Slot = draggable.currentParent.gameObject.name;
            if (!isLoot)
            {
                _currentView.CanDrag = true;
            }
        }
        draggable.currentParent.GetComponent <ItemSlot>().RuntimeItem = null;

        draggable.transform.position = transform.position;

        draggable.transform.SetParent(transform);

        RuntimeItem = draggable.RuntimeItem;
        draggable.RuntimeItem.Item.Slot = gameObject.name;
        _currentView = draggable;
    }
    IEnumerator LoadItem(RuntimeItem rItem, int playerID)
    {
        UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <Sprite>     iconHandle   = Addressables.LoadAssetAsync <Sprite>(rItem.Item.IconAddress);
        UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle <GameObject> prefabHandle = Addressables.LoadAssetAsync <GameObject>(rItem.Item.PrefabAddress);
        yield return(iconHandle);

        yield return(prefabHandle);

        while (!prefabHandle.IsDone || !iconHandle.IsDone)
        {
            yield return(new WaitForEndOfFrame());
        }


        if (iconHandle.Result != null)
        {
            rItem.Icon = iconHandle.Result;
        }
        else
        {
            Debug.Log($"Failed to load {rItem.Item.PrefabAddress}");
        }

        if (prefabHandle.Result != null)
        {
            rItem.Prefab = prefabHandle.Result;
        }
        else
        {
            Debug.Log($"Failed to load {rItem.Item.PrefabAddress}");
        }


        _signalBus.Fire(new ItemLoadedSignal()
        {
            LoadedItem = rItem, PlayerID = playerID
        });
    }
 public void Inject(SignalBus bus)
 {
     bus.Subscribe <PlayerSpawned>(PopulateSlot);
     RuntimeItem = null;
 }
 public void PrepWearable(RuntimeItem wearable)
 {
 }