public ItemDescriptor(SimpleJSON.JSONNode data) { _attributes = new Dictionary<string, SimpleJSON.JSONNode>(); _name = data["name"]; _description = data["description"]; _weight = data["weight"].AsFloat; _volume = data["volume"].AsFloat; _size = (ItemSize)data["size"].AsInt; string type = data["type"]; switch (type) { case "consumable": _itemType = ItemType.Consumable; _class = typeof(Consumable); break; case "storage": _itemType = ItemType.Storage; _class = typeof(Storage); break; default: _itemType = ItemType.Item; _class = typeof(Item); break; } // Read the attributes List<string> keys = data["attributes"].GetKeys(); foreach(string key in keys) { _attributes.Add(key, data["attributes"][key]); } }
public void TestJSONParser() { var jsonText = "{ a : 10, b: 'text', c : [ 1, 'a'], d: { a: 10, b: 'text', c: true }}"; var json = new SimpleJSON().Parse(jsonText) as IDictionary; Assert.AreEqual(json ["a"], 10.0d); }
public static void Init(SimpleJSON.JSONNode node) { for (int i = 0; i < node.Count; i++) { int item_id = int.Parse(node.AsObject.keyAt(i)); Items.Add(item_id, new Item(item_id, node[i])); } }
public Generals (SimpleJSON.JSONClass j, int cnt=1){ id = cnt; Name = j ["Name"]; Rank = j["Rank"].AsInt; Era = j["Era"]; Type = j["Type"].AsInt; InitialIQ = j["InitialIQ"].AsInt; GainIQ = j["GainIQ"].AsDouble; HighestIQ = j["HighestIQ"].AsInt; InitialLeadership = j["InitialLeadership"].AsInt; GainLv30Leadership = j["GainLv30Leadership"].AsInt; GainLv60Leadership = j["GainLv60Leadership"].AsInt; GainLv99Leadership = j["GainLv99Leadership"].AsInt; HighestLeadership = j["HighestLeadership"].AsInt; InitialPrestige = j["InitialPrestige"].AsInt; InitialCourage = j["InitialCourage"].AsInt; GainCourage = j["GainCourage"].AsInt; HighestCourage = j["HighestCourage"].AsInt; InitialForce = j["InitalForce"].AsInt; GainForce = j["GainForce"].AsInt; HighestForce = j["HighestForce"].AsInt; InitialPhysical = j["InitialPhysical"].AsInt; GainPhysical = j["GainPhysical"].AsInt; HighestPhysical = j["HighestPhysical"].AsInt; Obedience = j["Obedience"].AsInt; }
public void SetData(SimpleJSON.JSONNode data) { title = data["title"]; color = data["color"]; objectType = data["type"]; obeyGravity = data["obeyGravity"].AsBool; SyncTitle(); }
public static void Update() { var manifestPath = Path.Combine(Application.dataPath, "..", "Packages", "manifest.json"); var filePath = Path.GetFullPath(manifestPath); var json = File.ReadAllText(filePath); var manifest = new Manifest().Deserialize(SimpleJSON.Parse(json)); Ensure(manifest); File.WriteAllText($"{filePath}", manifest.Serialize().ToString(2)); AssetDatabase.Refresh(); }
public SkillData(string strKey,SimpleJSON.JSONNode nodeData) { m_strKey = strKey; m_Range = nodeData["RANGE"].AsFloat; SimpleJSON.JSONArray arrSkill = nodeData["SKILL"].AsArray; if(arrSkill != null) { for(int i = 0; i < arrSkill.Count; i++) { m_SkillList.Add(arrSkill[i]); } } }
public IParseble Parse(SimpleJSON.JSONNode userNode) { if(userNode ["requisites"].Count > 1) requisites = new Requisites (userNode ["requisites"] ["value"], userNode ["requisites"] ["isVisible"].AsBool); country = new Country (userNode ["country"] ["value"], userNode ["country"] ["allow_modify"].AsBool); local = userNode ["local"]; savedPaymentMethodCount = userNode ["savedPaymentMethodCount"].AsInt; acceptLanguage = userNode ["acceptLanguage"]; acceptEncoding = userNode ["acceptEncoding"]; if (userNode["virtual_currency_balance"]["amount"] != null) virtualCurrencyBalance = new VirtualCurrencyBalance(userNode["virtual_currency_balance"]["amount"].AsDouble); return this; }
public SkillTemplate(string strKey,SimpleJSON.JSONNode nodeData) { m_strKey = strKey; m_SkillType = (eSkillTemplateType)nodeData["SKILL_TYPE"].AsInt; m_RangeType = (eSkillAttackRangeType)nodeData["RANGE_TYPE"].AsInt; m_RangeData_1 = nodeData["RANGE_DATA_1"].AsFloat; m_RangeData_2 = nodeData["RANGE_DATA_2"].AsFloat; for(int i = 0; i < (int)eFactorData.FACTOR_COUNT; ++i) { eFactorData factorData = (eFactorData)i; double valueData = nodeData[factorData.ToString()].AsDouble; if (valueData > 0) m_FactorData.IncreaseData(factorData, valueData); } }
public Counselors (SimpleJSON.JSONClass j, int cnt =0){ id = cnt; Name = j ["Name"]; Rank = j["Rank"].AsInt; Era = j["Era"]; Type = j["Type"].AsInt; InitialIQ = j["InitialIQ"].AsInt; GainIQ = j["GainIQ"].AsDouble; HighestIQ = j["HighestIQ"].AsInt; InitialLeadership = j["InitialLeadership"].AsInt; GainLv30Leadership = j["GainLv30Leadership"].AsInt; GainLv60Leadership = j["GainLv60Leadership"].AsInt; GainLv99Leadership = j["GainLv99Leadership"].AsInt; HighestLeadership = j["HighestLeadership"].AsInt; InitialPrestige = j["InitialPrestige"].AsInt; KnownFormation = j["KnownFormation"]; KnownKnowledge = j["KnownKnowledge"]; }
// supposed to be called before any other mod's code public static void init() { if (inited || !(inited = true)) { return; } UnityHelper.createPersistentGameObject <ShutdownListener>($"{id}.ShutdownListener"); // may be overkill to make it for all mods and from the start Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; try { File.Delete(Paths.modRootPath + tmpFileName); } catch (UnauthorizedAccessException) {} var manifest = SimpleJSON.Parse(File.ReadAllText(Paths.modRootPath + "mod.json")); _name = manifest["DisplayName"]; bool needCheckVer = manifest["UpdateCheck"].AsBool; #if DISABLE_VERSION_CHECK_IN_DEVBUILD if (needCheckVer && Consts.isDevBuild) { "Version check is disabled for dev build!".logDbg(); needCheckVer = false; } #endif if (needCheckVer) { Version currentVersion = new (manifest["Version"]); var latestVersion = VersionChecker.getLatestVersion(manifest["VersionURL"]); $"Latest version is {latestVersion}".logDbg(); if (latestVersion > currentVersion) { addCriticalMessage(updateMessage.format(currentVersion, latestVersion), color: "yellow"); } } "Mod inited".logDbg(); }
public IParseble Parse(SimpleJSON.JSONNode rootNode) { if (rootNode != null && !"null".Equals(rootNode.ToString())) { this._status = rootNode["status"]; this._final = rootNode["final"].AsBool; this._elapsedTime = rootNode["elapsedTime"].AsInt; switch(rootNode["group"]) { case "invoice": { this._group = XsollaStatus.Group.INVOICE; break; } case "done": { this._group = XsollaStatus.Group.DONE; break; } case "delivering": { this._group = XsollaStatus.Group.DELIVERING; break; } case "troubled": { this._group = XsollaStatus.Group.TROUBLED; break; } default: { this._group = XsollaStatus.Group.UNKNOWN; break; } } } return this; }
public CharacterTemplateData(string strKey, SimpleJSON.JSONNode nodeData) { m_strKey = strKey; for(int i =0; i < (int)eFactorData.FACTOR_COUNT;i++) { eFactorData factorData = (eFactorData)i; double valueData = nodeData[factorData.ToString()].AsDouble; if (valueData > 0) m_FactorData.IncreaseData(factorData, valueData); } SimpleJSON.JSONArray arrSkill = nodeData["SKILL"].AsArray; if(arrSkill != null) { for(int i = 0; i < arrSkill.Count; i++) { m_listSkill.Add(arrSkill[i]); } } }
public void Send(SimpleJSON.JSONClass jc) { Send(jc.ToJSON(0)); }
public override void loadData(SimpleJSON.JSONNode savedNode) { base.loadData (savedNode); position = new TilePosition (savedNode ["PositionX"].AsInt, savedNode ["PositionY"].AsInt, savedNode ["PositionZ"].AsInt); }
public override void loadData(SimpleJSON.JSONNode savedNode) { base.loadData (savedNode); }
public Transform(GameObject o, SimpleJSON.JSONNode n) : base(o, n) { Position = Vector2.Zero; Rotation = 0; Scale = Vector2.One; }
internal static User Create(SimpleJSON.JObject Json) { var Temp = new User(); Temp.ID = Json["id"].StringValue; Temp.Kind = Kind.Account; Temp.HasMail = Json["has_mail"].BooleanValue; Temp.Name = Json["name"].StringValue; Temp.IsFriend = Json["is_friend"].BooleanValue; Temp.Created = Json["created"].DoubleValue.ToDateTime(); Temp.CreatedUTC = Json["created_utc"].DoubleValue.ToDateTime(); Temp.LinkKarma = Json["link_karma"].IntValue; Temp.CommentKarma = Json["comment_karma"].IntValue; Temp.IsGold = Json["is_gold"].BooleanValue; Temp.IsMod = Json["is_mod"].BooleanValue; Temp.HasModMail = Json["has_mod_mail"].BooleanValue; return Temp; }
public Storage (SimpleJSON.JSONClass j){ id = j["id"].AsInt; productId = j ["prod_id"].AsInt; type = j["prod_type"].AsInt; quantity = j["quantity"].AsInt; }
//{"player_id":"3","device_id":"","sns_type":1,"sns_url":"10153232082329123","country":"HK","register_time":1437706124,"last_login_time":1437713377,"last_login_ip":3232235781,"total_login_time":622037,"status":1,"exp":1043,"war_credits":1124,"battle_started_time":"2016-02-02T02:53:00.000Z"} public Login (SimpleJSON.JSONClass j){ id = j ["user_id"].AsInt; name = j ["name"]; snsType = j ["sns_type"].AsInt; snsURL = j ["sns_url"]; exp = j ["exp"].AsInt; warCredit = j ["war_credit"].AsInt; country = j ["country"]; deviceID = j ["device_id"]; }
/// <summary> /// Constructor to load a level from json. Or binary maybe. we'll see /// </summary> /// <param name="n">JSON Node that contains the scene data1591</param> /// <param name="c">The content manager for the game</param> /// <param name="d">The current graphics device</param> public Scene(SimpleJSON.JSONNode n, ContentManager c, GraphicsDevice d) { Content = c; Device = d; Name = n["name"]; JSONArray objects = n["objects"] as JSONArray; foreach (JSONNode node in objects) { AddGameObject(new GameObject(node)); } }
public Model2D(GameObject obj, SimpleJSON.JSONNode n) : base(obj, n) { TintColor = Color.White; }
public Item(int id, SimpleJSON.JSONNode node) { itemID = id; name = node["name"]; }
public Model(GameObject g, SimpleJSON.JSONNode n) : base (g, n) { }
public Xsolla.IParseble Parse(SimpleJSON.JSONNode rootNode) { JSONArray array = rootNode["head"].AsArray; foreach (JSONNode item in array) { _head.Add(item.AsArray[0]); } array = rootNode["body"].AsArray; foreach (JSONNode item in array) { _body.Add(item.AsArray[0]); } return this; }
public RigidBody(GameObject o, SimpleJSON.JSONNode n) : base(o, n) { Model2D model = GameObject.GetComponent<Model2D>(); if(model != null) { _model = model; Box = model.BoundingBox(); } UseGravity = true; UseCollision = true; }
internal static Comment Create(SimpleJSON.JObject Json) { var Temp = new Comment(); Temp.LinkID = Json["link_id"].StringValue.Remove(0, 3); Temp.ID = Json["id"].StringValue; Temp.Kind = Kind.Comment; //Temp.BannedBy = Json["banned_by"]; Temp.Likes = Json["likes"].IntValue; Temp.Comments = new List<Comment>(); if (Json["replies"].ObjectValue != null && Json["replies"]["data"].ObjectValue != null) { foreach (var Reply in Json["replies"]["data"]["children"].ArrayValue) { var ReplyObj = Comment.Create(Reply["data"]); ReplyObj._Parent = Temp; Temp.Comments.Add(ReplyObj); } } Temp.Gilded = Json["gilded"].IntValue; Temp.AuthorName = Json["author"].StringValue; Temp.ParentThing = Thing.Get(Json["parent_id"].StringValue); //Temp.ApprovedBy = Json["approved_by"]; Temp._Content = Json["body"].StringValue; Temp.Edited = Json["edited"].BooleanValue; Temp.AuthorFlairText = Json["author_flair_text"].StringValue; Temp.AuthorFlairCSSClass = Json["author_flair_css_class"].StringValue; Temp.Downvotes = Json["downs"].IntValue; Temp.ContentHtml = Json["body_html"].StringValue; Temp.SubredditName = Json["subreddit"].StringValue; Temp.Created = Json["created"].DoubleValue.ToDateTime(); Temp.CreatedUTC = Json["created_utc"].DoubleValue.ToDateTime(); //Temp.NumReports = Json["num_reports"]; Temp.Upvotes = Json["ups"].IntValue; return Temp; }
public Wealth(SimpleJSON.JSONClass j){ id = j["pk"].AsInt; type = j["currency_id"].AsInt; value = j["currency_value"].AsInt; }
internal static Subreddit Create(string Name, SimpleJSON.JObject Json) { var Temp = new Subreddit(); Temp.Name = Name; var Children = Json["children"]; Temp.Kind = Kind.Subreddit; if (Children.ArrayValue.Count > 0) { Temp.ID = Children.ArrayValue[0]["data"]["subreddit_id"].StringValue.Split('_')[1]; } Temp.ModHash = Json["modhash"].StringValue; Temp.Before = Thing.Get(Json["before"].StringValue); Temp.After = Thing.Get(Json["after"].StringValue); foreach (var Link in Children.ArrayValue) { Temp.Links.Add(API.Link.Create(Link["data"])); } return Temp; }
internal static SubredditMetaData Create(SimpleJSON.JObject Json) { var Temp = new SubredditMetaData(); Temp.AccountsActive = Json["accounts_active"].IntValue; Temp.Created = Json["created"].DoubleValue.ToDateTime(); Temp.CreatedUTC = Json["created_utc"].DoubleValue.ToDateTime(); Temp.Description = Json["description"].StringValue; Temp.DescriptionHtml = Json["description_html"].StringValue; Temp.DisplayName = Json["display_name"].StringValue; if (Json["header_size"].Count > 0) { Temp.Header = new SubredditHeader(); Temp.Header.ImageUrl = Json["header_img"].StringValue; Temp.Header.ImageWidth = Json["header_size"][0].IntValue; Temp.Header.ImageHeight = Json["header_size"][1].IntValue; Temp.Header.Title = Json["header_title"].StringValue; } Temp.ID = Json["id"].StringValue; Temp.Thing = Thing.Get(Json["name"].StringValue); Temp.Over18 = Json["over18"].BooleanValue; Temp.PublicDescription = Json["public_description"].StringValue; Temp.Subscribers = Json["subscribers"].LongValue; Temp.Title = Json["title"].StringValue; Temp.Url = Json["url"].StringValue; return Temp; }
internal static Message Create(SimpleJSON.JObject Json) { Json = Json["data"]; var Temp = new Message(); Temp.AuthorName = Json["author"].StringValue; Temp.Body = Json["body"].StringValue; Temp.BodyHtml = Json["body_html"].StringValue; Temp.ContextUrl = "" + Json["context"].StringValue; Temp.Created = Json["created"].DoubleValue.ToDateTime(); Temp.CreatedUTC = Json["created_utc"].DoubleValue.ToDateTime(); Temp.RecipientName = Json["dest"].StringValue; Temp.FirstMessageId = Json["first_message"].StringValue.Remove(0, 3); Temp.ID = Json["id"].StringValue; Temp.Kind = Kind.Message; Temp.New = Json["new"].BooleanValue; Temp.ParentId = Json["parent_id"].StringValue.Remove(0, 3); Temp.Subject = Json["subject"].StringValue; Temp.SubredditName = Json["subreddit"].StringValue; Temp.WasComment = Json["was_comment"].BooleanValue; return Temp; }