예제 #1
0
        protected override TeamInfo DeserializeJson(DeserializationHelper helper)
        {
            var uid             = helper.GetValue <string>("uid");
            var id              = helper.GetValue <int>("tid");
            var name            = helper.GetValue("name", "");
            var lastMaintenance = helper.GetValue("last_maintenance", "");
            var rank            = helper.GetValue("rank", 0f);
            var tier            = helper.GetValue("tier", 0);

            BotInfo[] bots;

            if (uid == DataManager.Instance.CurrentUser.ID)
            {
                var botIds  = helper.GetValue("bots", new int[0]);
                var botList = new List <BotInfo>(botIds.Select(DataManager.Instance.GetBot));
                botList.RemoveAll(bot => bot == null);
                bots = botList.ToArray();
            }
            else
            {
                bots = helper.GetArrayValue("bots", new BotInfo[0]);
            }

            return(new TeamInfo(id, name, DateTime.Parse(lastMaintenance), bots, rank, tier, uid));
        }
예제 #2
0
        protected override BlockInfo DeserializeJson(DeserializationHelper helper)
        {
            var id         = helper.GetValue <int>("id");
            var type       = helper.GetValue <string>("type");
            var typeAttrs  = helper.GetValue("typeAttrs", new Dictionary <string, string>());
            var inputIds   = helper.GetArrayValue <int>("inputIds");
            var chunkSizes = helper.GetArrayValue <int>("chunkSizes");

            return(new BlockInfo(id, type, typeAttrs, inputIds, chunkSizes));
        }
예제 #3
0
        protected override UserInfo DeserializeJson(DeserializationHelper helper)
        {
            var id         = helper.GetValue <string>("uid");
            var email      = helper.GetValue <string>("email");
            var username   = helper.GetValue <string>("username");
            var currency   = helper.GetValue("currency", 0);
            var xp         = helper.GetValue("xp", 0);
            var canCompete = helper.GetValue("canCompete", false);
            var settings   = helper.GetValue("settings", new Dictionary <string, string>());

            return(new UserInfo(id, email, username, currency, xp, canCompete, settings));
        }
예제 #4
0
        protected override PartInfo DeserializeJson(DeserializationHelper helper)
        {
            var id          = helper.GetValue <int>("pid");
            var name        = helper.GetValue("name", "");
            var desc        = helper.GetValue("desc", "");
            var partString  = helper.GetValue("type", "");
            var price       = helper.GetValue("price", 100000);
            var unlockLevel = helper.GetValue("unlockLvl", 1000);
            var stats       = helper.GetValue("stats", new Dictionary <string, float>());

            var partType = (PartType)Enum.Parse(typeof(PartType), partString, true);

            return(new PartInfo(id, name, desc, partType, price, unlockLevel, stats));
        }
예제 #5
0
        protected override BotInfo DeserializeJson(DeserializationHelper helper)
        {
            var id         = helper.GetValue <int>("bid");
            var name       = helper.GetValue("name", "");
            var partIds    = helper.GetValue("parts", new int[0]);
            var bodyTypeId = helper.GetValue("bodyType", 100);
            var tier       = helper.GetValue("tier", 0);
            var behaviors  = helper.GetArrayValue <BehaviorInfo>("ai");

            var equipment = new List <PartInfo>(partIds.Select(DataManager.Instance.GetPart));

            equipment.RemoveAll(p => p == null);
            var bodyType = DataManager.Instance.GetPart(bodyTypeId);

            return(new BotInfo(id, name, tier, equipment, bodyType, behaviors));
        }
예제 #6
0
 // Abstract convenience method for deserialization, to be implemented by subclasses
 protected abstract T DeserializeJson(DeserializationHelper helper);