public void AddLootToPlayer(Loot item, string playerName)
        {
            Player player = CharacterDB.Instance.FindByName(playerName);

            if (player == null)
            {
                player = new Player()
                {
                    Name = playerName, Loots = new List <Loot>()
                };
                CharacterDB.Instance.AddPlayer(player);
            }
            item.LooterName = playerName;

            player.Loots.Add(item);

            if (LootAddedToPlayer != null)
            {
                PlayerLootEventArgs pea = new PlayerLootEventArgs(item, player);
                foreach (EventHandler <PlayerLootEventArgs> e in LootAddedToPlayer?.GetInvocationList())
                {
                    Task.Run(() => e.Invoke(this, pea));
                }
            }
        }
        public void AddLootToPlayer(Loot item, Player player)
        {
            player.Loots.Add(item);

            if (LootAddedToPlayer != null)
            {
                PlayerLootEventArgs pea = new PlayerLootEventArgs(item, player);
                foreach (EventHandler <PlayerLootEventArgs> e in LootAddedToPlayer?.GetInvocationList())
                {
                    Task.Run(() => e.Invoke(this, pea));
                }
            }
        }
示例#3
0
        public void AddLootToPlayer(Loot item, Player player)
        {
            player.Loots.Add(item);

            if (LootAddedToPlayer != null)
            {
                PlayerLootEventArgs pea = new PlayerLootEventArgs(item, player);
                foreach (EventHandler <PlayerLootEventArgs> e in LootAddedToPlayer?.GetInvocationList())
                {
                    e.BeginInvoke(this, pea, e.EndInvoke, null);
                }
            }
        }