예제 #1
0
        public static User getAddUser(CommandReader cr, User user)
        {
            User res = new User();

            res.id              = cr.getInt();
            res.shipName        = cr.getStr();
            res.x               = cr.getInt();
            res.y               = cr.getInt();
            res.domain          = cr.getInt();
            res.userShip.energy = cr.getDbl();
            double angle = cr.getDbl();

            res.equips = getEquips(cr, user);
            res.updateUserShip();
            return(res);
        }
예제 #2
0
        public static User getUserData(CommandReader cr, User user)
        {
            User res = user;

            res.id     = cr.getInt();
            res.x      = cr.getInt();
            res.y      = cr.getInt();
            res.domain = cr.getInt();
            int inPlanet = cr.getInt();

            if (inPlanet == 0)
            {
                res.inPlanet = null;
            }
            else
            {
                res.inPlanet = user.planets[inPlanet];
            }
            res.pilotName       = cr.getStr();
            res.shipName        = cr.getStr();
            res.userShip.energy = cr.getDbl();
            res.equips          = getEquips(cr, user);
            return(res);
        }
예제 #3
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);
        }