Esempio n. 1
0
        public void Init()
        {
            if (_floorItems.Count > 0)
            {
                _floorItems.Clear();
            }

            if (_wallItems.Count > 0)
            {
                _wallItems.Clear();
            }

            if (_petsItems.Count > 0)
            {
                _petsItems.Clear();
            }

            if (_botItems.Count > 0)
            {
                _botItems.Clear();
            }

            var items = ItemLoader.GetItemsForUser(_userId);

            foreach (var item in items.ToList())
            {
                if (item.IsFloorItem)
                {
                    if (!_floorItems.TryAdd(item.Id, item))
                    {
                    }
                }
                else if (item.IsWallItem)
                {
                    if (!_wallItems.TryAdd(item.Id, item))
                    {
                    }
                }
            }

            var pets = PetLoader.GetPetsForUser(Convert.ToInt32(_userId));

            foreach (var pet in pets)
            {
                if (!_petsItems.TryAdd(pet.PetId, pet))
                {
                    Console.WriteLine("Error whilst loading pet x1: " + pet.PetId);
                }
            }

            var bots = BotLoader.GetBotsForUser(Convert.ToInt32(_userId));

            foreach (var bot in bots)
            {
                if (!_botItems.TryAdd(bot.Id, bot))
                {
                    Console.WriteLine("Error whilst loading bot x1: " + bot.Id);
                }
            }
        }
        public void Init()
        {
            if (this._floorItems.Count > 0)
            {
                this._floorItems.Clear();
            }
            if (this._wallItems.Count > 0)
            {
                this._wallItems.Clear();
            }
            if (this._petsItems.Count > 0)
            {
                this._petsItems.Clear();
            }
            if (this._botItems.Count > 0)
            {
                this._botItems.Clear();
            }

            List <Item> Items = ItemLoader.GetItemsForUser(_userId);

            foreach (Item Item in Items.ToList())
            {
                if (Item.IsFloorItem)
                {
                    if (!this._floorItems.TryAdd(Item.Id, Item))
                    {
                        continue;
                    }
                }
                else if (Item.IsWallItem)
                {
                    if (!this._wallItems.TryAdd(Item.Id, Item))
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }
            }

            List <Pet> Pets = PetLoader.GetPetsForUser(Convert.ToInt32(_userId));

            foreach (Pet Pet in Pets)
            {
                if (!this._petsItems.TryAdd(Pet.PetId, Pet))
                {
                    Console.WriteLine("Error whilst loading pet x1: " + Pet.PetId);
                }
            }

            List <Bot> Bots = BotLoader.GetBotsForUser(Convert.ToInt32(_userId));

            foreach (Bot Bot in Bots)
            {
                if (!this._botItems.TryAdd(Bot.Id, Bot))
                {
                    Console.WriteLine("Error whilst loading bot x1: " + Bot.Id);
                }
            }
        }