public string Serialize()
        {
            EndLapCommandV1_0 endLapCommand = null;

            if (END_LAP_COMMAND != null)
            {
                endLapCommand = (EndLapCommandV1_0)EndLapCommandV1_0.FACTORY.Transfer(this.END_LAP_COMMAND);
            }
            return(ProtocolV1_0Utils.SerializeParams(COMMAND_NAME, (ProtocolDouble)X, (ProtocolDouble)Y, HIT_POINTS, (ProtocolDouble)POWER, TURN, MAX_TURN, COUNT_OF_LIFE_ROBOTS, ARRAY_IDS_OF_LIFE_ROBOTS, endLapCommand, SerializeMore(SUB_COMMAND_FACTORIES)));
        }
Ejemplo n.º 2
0
        public static bool Deserialize(string orig, Deep deep, out EndLapCommandV1_0 deserialized)
        {
            string[] rest;
            if (ProtocolV1_0Utils.GetParams(orig, COMMAND_NAME, deep, out rest))
            {
                if (rest.Length == 3)
                {
                    int      gold, score;
                    LapState lapState;

                    if (Enum.TryParse(rest[0], true, out lapState) && int.TryParse(rest[1], out gold) && int.TryParse(rest[2], out score))
                    {
                        deserialized = new EndLapCommandV1_0(lapState, gold, score);
                        return(true);
                    }
                }
            }
            deserialized = null;
            return(false);
        }
            public override bool IsDeserializeable(string s)
            {
                string[] rest;
                if (ProtocolV1_0Utils.GetParams(s, COMMAND_NAME, out rest))
                {
                    if (rest.Length == 10)
                    {
                        ProtocolDouble[] paramsPDoubles;
                        int[]            paramInts;
                        int[]            arrayIdsOfLifeRobots;

                        if (Parser.TryParse(new int[] { 0, 1, 3 }, rest, out paramsPDoubles) &&
                            Parser.TryParse(new int[] { 2, 4, 5, 6 }, rest, out paramInts) &&
                            ProtocolV1_0Utils.Deserialize(rest[7], out arrayIdsOfLifeRobots, ProtocolV1_0Utils.DEFAULT.NEXT)
                            )
                        {
                            EndLapCommandV1_0 endLapCommand;
                            EndLapCommandV1_0.Deserialize(rest[8], ProtocolV1_0Utils.DEFAULT.NEXT, out endLapCommand);

                            RobotStateCommandV1_0 robotStateCommand = new RobotStateCommandV1_0(paramsPDoubles[0], paramsPDoubles[1],
                                                                                                paramInts[0], paramsPDoubles[2],
                                                                                                paramInts[1], paramInts[2],
                                                                                                paramInts[3],
                                                                                                arrayIdsOfLifeRobots, endLapCommand);
                            string[] moreString;
                            if (ProtocolV1_0Utils.Deserialize(rest[9], out moreString, ProtocolV1_0Utils.DEFAULT.NEXT))
                            {
                                robotStateCommand.DeserializeMore(moreString, robotStateCommand.MORE, SUB_COMMAND_FACTORIES);
                            }
                            cache.Cached(s, robotStateCommand);
                            return(true);
                        }
                    }
                }
                return(false);
            }