Ejemplo n.º 1
0
        public static Dictionary <int, Equip> getEquips(CommandReader cr, User user)
        {
            Dictionary <int, Equip> res = new Dictionary <int, Equip>();
            int equipCount = cr.getInt();

            for (int i = 0; i < equipCount; i++)
            {
                Equip eq = new Equip();
                eq.id = cr.getInt();
                int           item_id = cr.getInt();
                Item.ItemType iType   = (Item.ItemType)cr.getInt();
                int           dType   = cr.getInt();
                eq.in_use = cr.getInt() == 0 ? false: true;
                eq.wear   = cr.getInt();
                int location = cr.getInt();
                eq.location = location == 0 ? null : user.planets[location];
                eq.num      = cr.getInt();
                eq.last_use = cr.getDbl();
                switch (iType)
                {
                case Item.ItemType.consumable:
                {
                    Consumable item = MainData.itemCollect.get <Consumable>(item_id);
                    eq.item = item;
                    break;
                }

                case Item.ItemType.device:
                {
                    Device.DeviceType devT = (Device.DeviceType)dType;
                    switch (devT)
                    {
                    case Device.DeviceType.Body:
                    {
                        Body item = MainData.itemCollect.get <Body>(item_id);
                        eq.item = item;
                        break;
                    }

                    case Device.DeviceType.Droid:
                    {
                        Droid item = MainData.itemCollect.get <Droid>(item_id);
                        eq.item = item;
                        break;
                    }

                    case Device.DeviceType.Engine:
                    {
                        Engine item = MainData.itemCollect.get <Engine>(item_id);
                        eq.item = item;
                        break;
                    }

                    case Device.DeviceType.Fuelbag:
                    {
                        Fuelbag item = MainData.itemCollect.get <Fuelbag>(item_id);
                        eq.item = item;
                        break;
                    }

                    case Device.DeviceType.Hyper:
                    {
                        Hyper item = MainData.itemCollect.get <Hyper>(item_id);
                        eq.item = item;
                        break;
                    }

                    case Device.DeviceType.Radar:
                    {
                        Radar item = MainData.itemCollect.get <Radar>(item_id);
                        eq.item = item;
                        break;
                    }

                    case Device.DeviceType.Shield:
                    {
                        Shield item = MainData.itemCollect.get <Shield>(item_id);
                        eq.item = item;
                        break;
                    }

                    case Device.DeviceType.Weapon:
                    {
                        Weapon item = MainData.itemCollect.get <Weapon>(item_id);
                        eq.item = item;
                        break;
                    }
                    }
                    break;
                }
                }
                res.Add(eq.id, eq);
            }
            return(res);
        }
Ejemplo n.º 2
0
        public static ItemCollection getItems(CommandReader cr, User user)
        {
            ItemCollection res           = new ItemCollection();
            int            itemTypeCount = cr.getInt();

            for (int i = 0; i < itemTypeCount; i++)
            {
                int itemCount = cr.getInt();
                for (int j = 0; j < itemCount; j++)
                {
                    int           item_id          = cr.getInt();
                    Item.ItemType item_itemType    = (Item.ItemType)cr.getInt();
                    String        item_description = cr.getStr();
                    int           item_volume      = cr.getInt();
                    int           item_region_id   = cr.getInt();
                    int           item_use_only    = cr.getInt();
                    int           item_price       = cr.getInt();
                    switch (item_itemType)
                    {
                    case Item.ItemType.consumable:
                    {
                        Consumable item = new Consumable();
                        item.id          = item_id;
                        item.itemType    = item_itemType;
                        item.description = item_description;
                        item.volume      = item_volume;
                        item.region      = item_region_id;
                        res.consumables.Add(item.id, item);
                        break;
                    }

                    case Item.ItemType.device:
                    {
                        String            device_vendorStr  = cr.getStr();
                        Device.DeviceType device_deviceType = (Device.DeviceType)cr.getInt();
                        int device_durability = cr.getInt();
                        switch (device_deviceType)
                        {
                        case Device.DeviceType.Body:
                        {
                            Body dev = new Body();
                            int  body_slot_weapons = cr.getInt();
                            int  body_slot_droids  = cr.getInt();
                            int  body_slot_shield  = cr.getInt();
                            int  body_slot_hyper   = cr.getInt();
                            dev.id           = item_id;
                            dev.itemType     = item_itemType;
                            dev.description  = item_description;
                            dev.volume       = item_volume;
                            dev.region       = item_region_id;
                            dev.vendorStr    = device_vendorStr;
                            dev.deviceType   = device_deviceType;
                            dev.durability   = device_durability;
                            dev.use_only     = item_use_only;
                            dev.price        = item_price;
                            dev.slot_weapons = body_slot_weapons;
                            dev.slot_droids  = body_slot_droids;
                            dev.slot_shield  = body_slot_shield;
                            dev.slot_hyper   = body_slot_hyper;
                            res.bodyes.Add(dev.id, dev);
                            break;
                        }

                        case Device.DeviceType.Droid:
                        {
                            Droid dev               = new Droid();
                            int   droid_power       = cr.getInt();
                            int   droid_time_reload = cr.getInt();
                            int   radius            = cr.getInt();
                            dev.id          = item_id;
                            dev.itemType    = item_itemType;
                            dev.description = item_description;
                            dev.volume      = item_volume;
                            dev.region      = item_region_id;
                            dev.vendorStr   = device_vendorStr;
                            dev.deviceType  = device_deviceType;
                            dev.durability  = device_durability;
                            dev.use_only    = item_use_only;
                            dev.price       = item_price;
                            dev.power       = droid_power;
                            dev.time_reload = droid_time_reload;
                            res.droids.Add(dev.id, dev);
                            break;
                        }

                        case Device.DeviceType.Engine:
                        {
                            Engine dev             = new Engine();
                            int    engine_power    = cr.getInt();
                            int    engine_economic = cr.getInt();
                            dev.id          = item_id;
                            dev.itemType    = item_itemType;
                            dev.description = item_description;
                            dev.volume      = item_volume;
                            dev.region      = item_region_id;
                            dev.vendorStr   = device_vendorStr;
                            dev.deviceType  = device_deviceType;
                            dev.durability  = device_durability;
                            dev.use_only    = item_use_only;
                            dev.price       = item_price;
                            dev.power       = engine_power;
                            dev.economic    = engine_economic;
                            res.engines.Add(dev.id, dev);
                            break;
                        }

                        case Device.DeviceType.Fuelbag:
                        {
                            Fuelbag dev = new Fuelbag();
                            int     fuelbag_compress = cr.getInt();
                            dev.id          = item_id;
                            dev.itemType    = item_itemType;
                            dev.description = item_description;
                            dev.volume      = item_volume;
                            dev.region      = item_region_id;
                            dev.vendorStr   = device_vendorStr;
                            dev.deviceType  = device_deviceType;
                            dev.durability  = device_durability;
                            dev.use_only    = item_use_only;
                            dev.price       = item_price;
                            dev.compress    = fuelbag_compress;
                            res.fuelbags.Add(dev.id, dev);
                            break;
                        }

                        case Device.DeviceType.Hyper:
                        {
                            Hyper dev               = new Hyper();
                            int   hyper_radius      = cr.getInt();
                            int   hyper_time_start  = cr.getInt();
                            int   hyper_time_reload = cr.getInt();
                            dev.id          = item_id;
                            dev.itemType    = item_itemType;
                            dev.description = item_description;
                            dev.volume      = item_volume;
                            dev.region      = item_region_id;
                            dev.vendorStr   = device_vendorStr;
                            dev.deviceType  = device_deviceType;
                            dev.durability  = device_durability;
                            dev.use_only    = item_use_only;
                            dev.price       = item_price;
                            dev.radius      = hyper_radius;
                            dev.time_start  = hyper_time_start;
                            dev.time_reload = hyper_time_reload;
                            res.hypers.Add(dev.id, dev);
                            break;
                        }

                        case Device.DeviceType.Radar:
                        {
                            Radar dev           = new Radar();
                            int   radar_radius  = cr.getInt();
                            int   radar_defense = cr.getInt();
                            int   big_radius    = cr.getInt();
                            dev.id          = item_id;
                            dev.itemType    = item_itemType;
                            dev.description = item_description;
                            dev.volume      = item_volume;
                            dev.region      = item_region_id;
                            dev.vendorStr   = device_vendorStr;
                            dev.deviceType  = device_deviceType;
                            dev.durability  = device_durability;
                            dev.use_only    = item_use_only;
                            dev.price       = item_price;
                            dev.radius      = radar_radius;
                            dev.defense     = radar_defense;
                            dev.hyper       = big_radius;
                            res.radars.Add(dev.id, dev);
                            break;
                        }

                        case Device.DeviceType.Shield:
                        {
                            Shield dev          = new Shield();
                            int    shield_power = cr.getInt();
                            dev.id          = item_id;
                            dev.itemType    = item_itemType;
                            dev.description = item_description;
                            dev.volume      = item_volume;
                            dev.region      = item_region_id;
                            dev.vendorStr   = device_vendorStr;
                            dev.deviceType  = device_deviceType;
                            dev.durability  = device_durability;
                            dev.use_only    = item_use_only;
                            dev.price       = item_price;
                            dev.power       = shield_power;
                            res.shields.Add(dev.id, dev);
                            break;
                        }

                        case Device.DeviceType.Weapon:
                        {
                            Weapon dev = new Weapon();
                            int    weapon_weaponType  = cr.getInt();
                            int    weapon_radius      = cr.getInt();
                            int    weapon_power       = cr.getInt();
                            int    weapon_time_start  = cr.getInt();
                            int    weapon_time_reload = cr.getInt();
                            dev.id          = item_id;
                            dev.itemType    = item_itemType;
                            dev.description = item_description;
                            dev.volume      = item_volume;
                            dev.region      = item_region_id;
                            dev.vendorStr   = device_vendorStr;
                            dev.deviceType  = device_deviceType;
                            dev.durability  = device_durability;
                            dev.use_only    = item_use_only;
                            dev.price       = item_price;
                            dev.weaponType  = (Weapon.WeaponType)weapon_weaponType;
                            dev.radius      = weapon_radius;
                            dev.power       = weapon_power;
                            dev.time_start  = weapon_time_start;
                            dev.time_reload = weapon_time_reload;
                            res.weapons.Add(dev.id, dev);
                            break;
                        }
                        }
                        break;
                    }
                    }
                }
            }
            return(res);
        }