Beispiel #1
0
 public static bool Deserialize(string orig, Deep deep, out MineGunV1_0 deserialized)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(orig, NAME, deep, out rest))
     {
         if (rest.Length == 4)
         {
             int[]    paramsInt;
             string[] zonesString;
             if (Parser.TryParse(new int[] { 0, 1, 2 }, rest, out paramsInt) &&
                 ProtocolV1_0Utils.Deserialize(rest[3], out zonesString, deep.NEXT))
             {
                 ZoneV1_0[] zones = new ZoneV1_0[zonesString.Length];
                 for (int i = 0; i < zones.Length; i++)
                 {
                     if (!ZoneV1_0.Deserialize(zonesString[i], deep.NEXT.NEXT, out zones[i]))
                     {
                         deserialized = null;
                         return(false);
                     }
                 }
                 deserialized = new MineGunV1_0(paramsInt[0], paramsInt[1], paramsInt[2], zones);
                 return(true);
             }
         }
     }
     deserialized = null;
     return(false);
 }
Beispiel #2
0
 /// <summary>
 /// Convert MineGun to MineGunV1_0
 /// </summary>
 /// <param name="mineGun"></param>
 /// <returns></returns>
 public static MineGunV1_0[] Convert(MineGun[] mineGun)
 {
     MineGunV1_0[] output = new MineGunV1_0[mineGun.Length];
     for (int i = 0; i < mineGun.Length; i++)
     {
         output[i] = new MineGunV1_0(mineGun[i]);
     }
     return(output);
 }
Beispiel #3
0
            public override bool IsTransferable(ACommand c)
            {
                var c2 = c as GetMineGunsAnswerCommand;

                if (c2 != null)
                {
                    cache.Cached(c, new GetMineGunsAnswerCommandV10(MineGunV1_0.Convert(c2.MINE_GUNS)));
                    return(true);
                }
                return(false);
            }
Beispiel #4
0
 public override bool IsDeserializeable(string s)
 {
     s = s.Trim();
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, ProtocolV1_0Utils.DEFAULT, out rest))
     {
         if (rest.Length == 1 && ProtocolV1_0Utils.Deserialize(rest[0], out rest, ProtocolV1_0Utils.DEFAULT.NEXT))
         {
             MineGunV1_0[] mineGuns = new MineGunV1_0[rest.Length];
             for (int i = 0; i < mineGuns.Length; i++)
             {
                 if (!MineGunV1_0.Deserialize(rest[i], ProtocolV1_0Utils.DEFAULT.NEXT.NEXT, out mineGuns[i]))
                 {
                     return(false);
                 }
             }
             cache.Cached(s, new GetMineGunsAnswerCommandV10(mineGuns));
             return(true);
         }
     }
     return(false);
 }