Ejemplo n.º 1
0
        private void SpawnItem(Transform parent, Vector3 pos, Looting.API.LootType type, int amount, int[] prms)
        {
            ServiceLocator.GetService <ResourceLoader>().InstantiatePrefabByPathName("Loot/LootItem", go =>
            {
                go.transform.SetParent(parent);
                go.transform.position = pos;

                var curLootData      = go.GetComponent <LootData>();
                curLootData.LootType = type;

                curLootData.Amount = amount;

                curLootData.Params = prms;

                var netId = Server.GetNetId();
                var sub   = go.GetComponent <SubscriberBehaviour>();
                sub.Channel.ChannelIds.Add(SubscribeType.Network, netId);
                sub.ReSubscribe();

                MessageBus.SendMessage(NetBroadcastMessage.Get(Network.API.Messages.CREATE_LOOT_ITEM, UnityEngine.Networking.QosType.Reliable, -1,
                                                               InstanceLootItemData.GetData(pos, curLootData.LootType,
                                                                                            curLootData.Amount, curLootData.Params, netId)));
            });
        }
Ejemplo n.º 2
0
        private void Drop(Message msg)
        {
            InstanceLootItemData data = msg.Data as InstanceLootItemData;

            SpawnItem(_lootPlacesContainer.transform, data.GetVector3(), data.LootType, data.Amout, data.Params);
        }