public static void SendSlotbars(GameSession gameSession)
        {
            var player      = gameSession.Player;
            var gameHandler = gameSession.Client;

            var counterValue = 0;

            var categories       = new List <SlotbarCategoryModule>();
            var slotbarItemsTest = new List <SlotbarQuickslotItem>
            {
                new SlotbarQuickslotItem(1, "ammunition_laser_ucb-100"),
                new SlotbarQuickslotItem(2, "ammunition_laser_rsb-75"),
                new SlotbarQuickslotItem(3, "ammunition_laser_mcb-50"),
                new SlotbarQuickslotItem(4, "ammunition_laser_ucb-100"),
                new SlotbarQuickslotItem(5, "ammunition_laser_sab-50"),
                new SlotbarQuickslotItem(6, "ammunition_mine_smb-01"),
                new SlotbarQuickslotItem(7, "equipment_extra_cpu_ish-01"),
                new SlotbarQuickslotItem(8, "ammunition_specialammo_emp-01"),
            };

            var premium = new List <SlotbarQuickslotItem>
            {
                new SlotbarQuickslotItem(1, "drone_formation_f-3d-rg"),
                new SlotbarQuickslotItem(2, "drone_formation_f-10-cr"),
                new SlotbarQuickslotItem(3, "drone_formation_f-09-mo")
            };


            var slotbars = new List <SlotbarQuickslotModule>
            {
                new SlotbarQuickslotModule("standardSlotBar", slotbarItemsTest, "50,85|0,40", "0", true),
                new SlotbarQuickslotModule("premiumSlotBar", premium, "50,85|0,80", "0", true)
            };
            var items = new List <SlotbarCategoryItemModule>();

            //LASERS
            var maxCounter = 1000;

            foreach (var itemId in ItemStorage.LaserIds)
            {
                var item = new LaserItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                try
                {
                    item.CounterValue = player.Hangar.Configurations[player.CurrentConfig].Consumables[itemId].Amount;
                }
                catch (Exception)
                {
                    item.CounterValue = 0;
                }

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("lasers", items));

            //ROCKETS
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 200;
            foreach (var itemId in ItemStorage.RocketIds)
            {
                var item = new RocketItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("rockets", items));

            //ROCKET LAUNCHER
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 200;
            foreach (var itemId in ItemStorage.RocketLauncherIds)
            {
                var item = new RocketLauncherItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("rocket_launchers", items));

            //SPECIAL ITEMS
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 100;
            foreach (var itemId in ItemStorage.SpecialItemsIds)
            {
                var item = new SpecialItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                try
                {
                    item.CounterValue = player.Hangar.Configurations[player.CurrentConfig].Consumables[itemId].Amount;
                }
                catch (Exception)
                {
                    item.CounterValue = 0;
                }

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("special_items", items));

            //MINES
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 100;
            foreach (var itemId in ItemStorage.MinesIds)
            {
                var item = new MineItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("mines", items));

            //CPUS
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 0;
            foreach (var itemId in ItemStorage.CpusIds)
            {
                //TODO
            }
            categories.Add(new SlotbarCategoryModule("cpus", items));

            //BUY NOW
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 0;
            foreach (var itemId in ItemStorage.BuyNowIds)
            {
                var item = new BuyItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("buy_now", items));

            //TECH ITEMS
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 0;
            foreach (var itemId in ItemStorage.TechIds)
            {
                var item = new TechItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("tech_items", items));

            //SHIP ABILITIES
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 0;
            foreach (var itemId in ItemStorage.ShipAbilitiesIds)
            {
                var item = new ShipAbilityItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("ship_abilities", items));

            //DRONE FORMATION
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 0;
            foreach (var itemId in ItemStorage.FormationIds)
            {
                var item = new FormationItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                player.SlotbarItems[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("drone_formations", items));

            gameHandler.Send(new SlotbarsCommand(categories, "50,85", slotbars).getBytes());
        }
Пример #2
0
        public List <SlotbarCategoryModule> GetCategories(Player player)
        {
            var counterValue = 0;

            var categories = new List <SlotbarCategoryModule>();
            var items      = new List <SlotbarCategoryItemModule>();

            //LASERS
            var maxCounter = 1000;

            foreach (var itemId in Items.LaserIds)
            {
                if (!player.Information.Ammunitions.ContainsKey(itemId))
                {
                    continue;
                }
                var ammo = player.Information.Ammunitions[itemId];

                var item = new LaserItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.CounterValue = ammo.Get();

                item.Create();
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("lasers", items));

            //ROCKETS
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 200;
            foreach (var itemId in Items.RocketIds)
            {
                if (!player.Information.Ammunitions.ContainsKey(itemId))
                {
                    continue;
                }
                var ammo = player.Information.Ammunitions[itemId];

                counterValue = ammo.Get();

                var item = new RocketItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("rockets", items));

            //ROCKET LAUNCHER
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 200;
            foreach (var itemId in Items.RocketLauncherIds)
            {
                var item = new RocketLauncherItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("rocket_launchers", items));

            //SPECIAL ITEMS
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 100;
            foreach (var itemId in Items.SpecialItemsIds)
            {
                var item = new SpecialItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.CounterValue = 100;

                item.Create();
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("special_items", items));

            //MINES
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 100;
            foreach (var itemId in Items.MinesIds)
            {
                var item = new MineItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("mines", items));

            //CPUS
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 100;
            foreach (var itemId in Items.CpusIds)
            {
                var item = new CpuItem(
                    itemId,
                    counterValue,
                    maxCounter,
                    null,
                    1,
                    false,
                    false
                    );

                item.Create();
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("cpus", items));

            //BUY NOW
            //items = new List<SlotbarCategoryItemModule>();
            //maxCounter = 0;
            //foreach (var itemId in Items.BuyNowIds)
            //{
            //    var item = new BuyItem(
            //        itemId,
            //        counterValue,
            //        maxCounter
            //    );

            //    item.Create();
            //    items.Add(item.Object);
            //    _items[item.ClickedId] = item;
            //}
            //categories.Add(new SlotbarCategoryModule("buy_now", items));

            //TECH ITEMS
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 99;
            foreach (var itemId in Items.TechIds)
            {
                var item = new TechItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                item.CounterValue = 99;
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("tech_items", items));

            //SHIP ABILITIES
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 0;
            foreach (var itemId in Items.ShipAbilitiesIds)
            {
                var item = new ShipAbilityItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("ship_abilities", items));

            //DRONE FORMATION
            items      = new List <SlotbarCategoryItemModule>();
            maxCounter = 0;
            foreach (var itemId in Items.FormationIds)
            {
                var item = new FormationItem(
                    itemId,
                    counterValue,
                    maxCounter
                    );

                item.Create();
                items.Add(item.Object);
                _items[item.ClickedId] = item;
            }
            categories.Add(new SlotbarCategoryModule("drone_formations", items));

            return(categories);
        }