Esempio n. 1
0
        public void SendLootItem(Item item, int itemAmount, Vector2 position)
        {
            GameAudioManager.Instance.PlaySoundEffect(GameSound.PickUpItem);
            ClientPlayerView view = (ClientPlayerView)playerManager.GetViewById(Id);

            ClientPacketHandler.Instance.SendPacketSerializable(PacketType.PickUpItem,
                                                                new PickUpItemPacket
            {
                Player     = Id,
                ItemId     = item.Id,
                ItemAmount = itemAmount,
                Position   = position
            },
                                                                DeliveryMethod.ReliableUnordered);
        }
Esempio n. 2
0
        // TODO: Move out of this class
        private void OnReceiveItemData(PlayerInitialDataPacket itemDatabasePacket)
        {
            int[] itemIds     = itemDatabasePacket.InventoryItemIds;
            int[] itemAmounts = itemDatabasePacket.InventoryItemAmounts;

            // Inventory
            for (int i = 0; i < itemDatabasePacket.InventoryItemIds.Length; i++)
            {
                OnReceivedInventoryItem?.Invoke(ClientItemDatabase.Instance.GetItemById(itemIds[i]), i, itemAmounts[i]);
            }

            // Equipment
            foreach (int itemId in itemDatabasePacket.EquippedItems)
            {
                OnReceivedEquippedItem?.Invoke(_playerManager.OurPlayer, ClientItemDatabase.Instance.GetItemById(itemId), -1, true);
            }

            ClientPlayerView clientPlayerView = (ClientPlayerView)_playerManager.GetViewById(_playerManager.OurPlayer.Id);

            clientPlayerView.Player.InitializePlayerHealth(itemDatabasePacket.MaxHealth, itemDatabasePacket.CurrentHealth);
        }