Example #1
0
 public IParseble Parse(JSONNode rootNode)
 {
     IsInvoiceCreated 	= rootNode ["invoice_created"].AsBool;
     OperationId 		= rootNode ["operation_id"].AsInt;
     Error 				= rootNode ["errors"].AsArray [0] ["message"];
     return this;
 }
Example #2
0
    public NoteData[] GetNoteDataFromJson(TextAsset SongJson)
    {
        NoteData[] newNoteData;

        SimpleJSON.JSONNode data = SimpleJSON.JSON.Parse(SongJson.text);
        //Debug.Log("Tempo " + data["tempo"]);

        //SongTempo = data["tempo"];

        newNoteData = new NoteData[data["tracks"].Count];

        //Debug.Log("Tracks Count " + data["tracks"].Count);

        for (int i = 0; i < data["tracks"].Count; i++)
        {
            newNoteData[i] = new NoteData();

            newNoteData[i].pad = data["tracks"][i]["p"];

            newNoteData[i].time = data["tracks"][i]["t"];

            //Debug.Log("note pad " + i + ": " + newNoteData[i].pad);

            //Debug.Log("note time " + i + ": " + newNoteData[i].time);
        }

        return(newNoteData);
    }
Example #3
0
    static void Send_Notification_Response(object[] data, Action <object[]> concluding_method)
    {
        Response_Status status = Http_Client.Parse_Status(data[0]);

        if (status < Response_Status.Network_Error)
        {
            SimpleJSON.JSONNode raw = SimpleJSON.JSON.Parse((string)data[2]);

            if (status == Response_Status.Ok)
            {
                if (raw["failure"].Value == "0")
                {
                    Debug.Log("Success on sending notification.");
                    concluding_method?.Invoke(new object[] { status, raw["success"].Value, "0" });
                }
                else
                {
                    Debug.LogWarning("Correct HTTP response but sending failures exists! (" + raw["success"].Value + " success, " + raw["failure"].Value + " failures)");
                    concluding_method?.Invoke(new object[] { status, raw["success"].Value, raw["failure"].Value });
                }
            }
            else
            {
                concluding_method?.Invoke(new object[] { status, raw["error"].Value, "-1" });
            }
        }
    }
Example #4
0
 public override void ParseJson(JSONNode json)
 {
     Size = json["size"].AsFloat;
     Shift = json["shift"].AsFloat;
     Direction = (Direction)Enum.Parse(typeof(Direction), json["direction"].ToString().Replace("\"", ""));
     Pivot = (Pivot)Enum.Parse(typeof(Pivot), json["pivot"].ToString().Replace("\"", ""));
 }
    private Queue <KeyValuePair <bool, int> > CaptureVoiceStatus()
    {
#if !UNITY_EDITOR && UNITY_ANDROID
        string json = currentActivity.Call <string>("getRecord");
        SimpleJSON.JSONNode parseResult = SimpleJSON.JSON.Parse(json);
        Queue <KeyValuePair <bool, int> > statusQueue = new Queue <KeyValuePair <bool, int> >();

        for (int idx = 0; idx < parseResult["status"].Count; ++idx)
        {
            var status = parseResult["status"][idx]["status"].Value; //int 0: silence; 1: speaking
            var time   = parseResult["status"][idx]["time"].Value;   //int (ms)

            KeyValuePair <bool, int> pair = new KeyValuePair <bool, int>
                                                (Convert.ToInt32(status) != 0 ? true : false,
                                                Convert.ToInt32(time));

            statusQueue.Enqueue(pair);
        }

        return(statusQueue);
#else
        //mock-up
        var statusQueue = new Queue <KeyValuePair <bool, int> >(_mockList);
        _mockList.Clear();
        return(statusQueue);
#endif
    }
Example #6
0
 public Items(CastleDBParser.RootNode root, SimpleJSON.JSONNode node, Dictionary <string, Texture> DatabaseImages)
 {
     id     = node["id"];
     name   = node["name"];
     Weight = node["Weight"].AsInt;
     image  = DatabaseImages[node["image"]];
 }
Example #7
0
    public StatsContainer(SimpleJSON.JSONNode data)
    {
        name         = data["name"];
        picDirection = data ["picDirection"];
        picCount     = data ["picCount"];

        minBaseAttack        = data["minBaseAttack"];
        maxBaseAttack        = data["maxBaseAttack"];
        minAttackDrain       = data["minAttackDrain"];
        maxAttackDrain       = data["maxAttackDrain"];
        minAttackMultiplier  = data["minAttackMultiplier"];
        maxAttackMultiplier  = data["maxAttackMultiplier"];
        splitDrain           = data["splitDrain"];
        maxSlimes            = data["maxSlimes"];
        plainMassGain        = data["plainMassGain"];
        scalingMassGain      = data["scalingMassGain"];
        conquerMassDrain     = data["conquerMassDrain"];
        slimeCountActionGain = data["slimeCountActionGain"];
        minCalcMass          = data["minCalcMass"];
        maxCalcMass          = data["maxCalcMass"];
        minDamageReduction   = data["minDamageReduction"];
        maxDamageReduction   = data["maxDamageReduction"];
        maxMass     = data["maxMass"];
        movement    = data["movement"];
        range       = data["range"];
        baseActions = data["baseActions"];
        baseMass    = data["baseMass"];
    }
Example #8
0
    public void Start()
    {
        Debug.Log("before Start dateString is :" + dateString);
        Debug.Log("starting in APIRequests");

//		authButton = GameObject.Find ("AuthButton").GetComponent<Button>();
//		apiButton = GameObject.Find ("APIButton").GetComponent<Button>();
//		displayText = GameObject.Find("DisplayText").GetComponent<Text>();

        jsonDataObj = GameObject.Find("JSONDataObject").GetComponent <JSONDataObject> ();
        JSONData    = jsonDataObj.JSONData;

        if (PlayerPrefs.GetString("CLIENT_ID") == "")
        {
            PlayerPrefs.SetString("CLIENT_ID", CLIENT_ID);
        }

        if (PlayerPrefs.GetString("CLIENT_SECRET") == "")
        {
            PlayerPrefs.SetString("CLIENT_SECRET", CLIENT_SECRET);
        }

        dateString = getCurrentDate();

        Debug.Log("APIRequests Start Func dateString is:" + dateString);
        Debug.Log("end of start in APIRequests");
    }
 public void Error(string error)
 {
     SimpleJSON.JSONNode result = SimpleJSON.JSON.Parse(error);
     response.text = result["message"];
     validator.loading.gameObject.SetActive(false);
     validator.form.gameObject.SetActive(true);
 }
    private void ReadJsonValues()
    {
        showBatterIndicator = false;
        string json_values = WaveVR_Utils.OEMConfig.getBatteryConfig();

        if (!json_values.Equals(""))
        {
            try
            {
                SimpleJSON.JSONNode jsNodes = SimpleJSON.JSONNode.Parse(json_values);

                string node_value = "";
                node_value = jsNodes["show"].Value;
                if (!node_value.Equals(""))
                {
                    if (node_value.Equals("2")) // always
                    {
                        showBatterIndicator = true;
                    }
                }
            }
            catch (Exception e)
            {
                Log.e(LOG_TAG, "JsonParse failed: " + e.ToString());
            }
        }

        PrintDebugLog("showBatterIndicator: " + showBatterIndicator);
    }
 public void SimpleJSONParse(SimpleJSON.JSONNode node)
 {
     MyStringA = node["MyStringA"].ToString();
     MyStringB = node["MyStringB"].ToString();
     MyStringC = node["MyStringC"].ToString();
     MyStringD = node["MyStringD"].ToString();
 }
        public void LoadConfig()
        {
            //Debug.Log(":: Loading Config ::");
            string json = File.ReadAllText(modConfigFile);

            modConfig = JSON.Parse(json);
        }
Example #13
0
    private void ReadJsonValues()
    {
        EnableSingleBeam = true;
        string json_values = WaveVR_Utils.OEMConfig.getSingleBeamEnableConfig();

        if (!json_values.Equals(""))
        {
            try
            {
                SimpleJSON.JSONNode jsNodes = SimpleJSON.JSONNode.Parse(json_values);

                string node_value = "";
                node_value = jsNodes["enable"].Value;
                if (!node_value.Equals(""))
                {
                    if (!node_value.Equals("true", System.StringComparison.OrdinalIgnoreCase))                     // not true
                    {
                        EnableSingleBeam = false;
                    }
                }
            }
            catch (Exception e)
            {
                Log.e(LOG_TAG, "JsonParse failed: " + e.ToString());
            }
        }

        PrintDebugLog("enable Single Beam: " + EnableSingleBeam);
    }
Example #14
0
    IEnumerator getData()
    {
        Debug.Log("APIRequests getData called");
        string api = getAPIString();

        WWW request = new WWW(api);

        yield return(request);

        if (request.error == null || request.error == "")
        {
            Debug.Log(request.text);

            SimpleJSON.JSONNode N = JSON.Parse(request.text);
            var newJSONObj        = N[0];

            storeDataObj(newJSONObj);

            Debug.Log(newJSONObj);
            Debug.Log("^^^^This is the data ^^^^");
        }
        else
        {
            Debug.Log("WWW error: " + request.error);
        }
    }
Example #15
0
    public void InitializeGameData()
    {
        string tData = Datas.CreateInstance <Datas>().GetData()[GameData.instance.currentLevel];//Getting the TextAsset data A/C level

        levelData = SimpleJSON.JSONArray.Parse(tData);

        bsize = int.Parse(levelData["r"]);

        //The required color array
        colors = new Color[] { Color.clear, Color.red, Color.green, Color.blue, new Color(1f, 165f / 255f, 0), new Color(128 / 255f, 0, 128 / 255f) };

        ColorData    = new int[bsize * bsize];
        DotColorData = new int[bsize * bsize];

        dotPoses = levelData["l"];//this is the  pathe between 2 dots

        GameData.instance.paths = new List <List <int> >();
        List <int> tpath0 = new List <int>();//the clear color path

        GameData.instance.paths.Add(tpath0);

        for (int i = 0; i < dotPoses.Count; i++)
        {
            List <int> tpath = new List <int>();
            GameData.instance.paths.Add(tpath);
        }
        winLinkCount = dotPoses.Count;

        linkedLines = new int[GameData.instance.paths.Count + 1];
    }
Example #16
0
    private List <LocalizationLanguage> ParseData(SimpleJSON.JSONNode json)
    {
        var list = new List <LocalizationLanguage>();

        var jsonLangs = json["localizations"].AsArray;

        foreach (SimpleJSON.JSONClass jsonLang in jsonLangs)
        {
            var lang = new LocalizationLanguage();

            var code = jsonLang["code"] + "";

            lang.Language = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), code);

            lang.Id            = jsonLang["_id"] + "";
            lang.GeneralDictId = jsonLang["generalDict"] + "";

            var jsonLocalization = jsonLang["localization"].AsArray;

            foreach (SimpleJSON.JSONClass jsonPair in jsonLocalization)
            {
                lang.Keys.Add(jsonPair["key"], jsonPair["val"]);//.ToString().ToUpper());
            }

            list.Add(lang);
        }

        return(list);
    }
Example #17
0
 public override void FromJSON(Tile tile, JSONNode node)
 {
     tile.position.x = node ["x"].AsInt;
     tile.position.y = node ["y"].AsInt;
     tile.text = node ["text"];
     tile.color = Util.Color.HexToColor (node["color"]);
 }
 private void OnNewMessageComplete(string result)
 {
     // Broken JSON to test reconnection logic on bad packet
     //result = @"{""result"":{""success"":true,""value"":""8cb2237d0679ca88db6464eac60da96345513964}";
     if (result != null && result != "")
     {
         try
         {
             SimpleJSON.JSONNode json = JSON.Parse(result);
             if (json != null)
             {
                 // Valid Data, Add it to the data list
                 lock (m_LiveData)
                 {
                     m_LiveData.Add(json);
                 }
             }
             else
             {
                 PrintWarning("Error: Deserialization of \n" + result + "\nfailed! Malformed JSON...");
             }
         }
         catch (Exception e)
         {
             PrintWarning("Error: Deserialization of \n" + result + "\n" + e.Message + "\nTrace: " + e.StackTrace);
         }
     }
     GetNextMessage();
 }
Example #19
0
 public Modifiers(CastleDBParser.RootNode root, RowValues line)
 {
     SimpleJSON.JSONNode node = root.GetSheetWithName("Modifiers").Rows[(int)line];
     id     = node["id"];
     name   = node["name"];
     change = node["change"].AsInt;
 }
Example #20
0
    public void LoadAreaResource()
    {
        PomeloSocket.Inst.Request("area.resourceHandler.loadAreaResource", (data) => {
            Debug.Log("LoadAreaResource:" + data.ToString());
            SimpleJSON.JSONNode jsondata    = SimpleJSON.JSON.Parse(data.ToString());
            SimpleJSON.JSONArray players    = jsondata["players"].AsArray;
            SimpleJSON.JSONArray mobs       = jsondata["mobs"].AsArray;
            SimpleJSON.JSONArray npcs       = jsondata["npcs"].AsArray;
            SimpleJSON.JSONArray items      = jsondata["items"].AsArray;
            SimpleJSON.JSONArray equipments = jsondata["equipments"].AsArray;

            view.SetTotalCount(1 + 1 + (players.Count + mobs.Count) * 16 + npcs.Count + items.Count + equipments.Count);

            LoadJsonResource(() =>
            {
                //预加载所有资源到内存一遍
                view.SetLoadedCount(1);
                view.LoadMap(data["mapName"].ToString());
                view.LoadCharacter(players, "player");
                view.LoadCharacter(mobs, "mob");
                view.LoadNpc(npcs);
                view.LoadItem(items);
                view.LoadEquipment(equipments);
                view.InitObjectPools(mobs, "mob");
                view.InitObjectPools(players, "player");

                Resources.UnloadUnusedAssets();
                System.GC.Collect();

                EnterScene();
            });
        });
    }
Example #21
0
 public Weapons(CastleDBParser.RootNode root, RowValues line)
 {
     SimpleJSON.JSONNode node = root.GetSheetWithName("Weapons").Rows[(int)line];
     id         = node["id"];
     Name       = node["Name"];
     Isavariant = node["Isavariant"].AsBool;
     foreach (var item in node["WeaponVariantReference"])
     {
         WeaponVariantReferenceList.Add(new WeaponVariantReference(root, item));
     }
     foreach (var item in node["WeaponModelPath"])
     {
         WeaponModelPathList.Add(new WeaponModelPath(root, item));
     }
     foreach (var item in node["WeaponFX"])
     {
         WeaponFXList.Add(new WeaponFX(root, item));
     }
     Health = node["Health"].AsFloat;
     Armor  = node["Armor"].AsFloat;
     foreach (var item in node["WeaponRoles"])
     {
         WeaponRolesList.Add(new WeaponRoles(root, item));
     }
     Ammo                  = new CompiledTypes.Ammos(root, CompiledTypes.Ammos.GetRowValue(node["Ammo"]));
     Max_range             = node["Max_range"].AsFloat;
     Min_range             = node["Min_range"].AsFloat;
     Muzzle_velocity       = node["Muzzle_velocity"].AsFloat;
     Reload_time           = node["Reload_time"].AsFloat;
     Precision             = node["Precision"].AsInt;
     Rotation_speed        = node["Rotation_speed"].AsFloat;
     Elevation_speed       = node["Elevation_speed"].AsFloat;
     Max_vertical_traverse = node["Max_vertical_traverse"].AsFloat;
     Min_vertical_traverse = node["Min_vertical_traverse"].AsFloat;
 }
Example #22
0
 public Enemies(CastleDBParser.RootNode root, RowValues line)
 {
     SimpleJSON.JSONNode node = root.GetSheetWithName("Enemies").Rows[(int)line];
     id        = node["id"];
     EnemyName = node["EnemyName"];
     Health    = node["Health"].AsInt;
 }
 public void createAssetFromJSON(SimpleJSON.JSONNode doc)
 {
     Debug.Log("Create From JSON: " + doc.ToString());
     try {
         string     type     = doc[S.SA_TYPE].Value;
         Vector3    position = new Vector3(float.Parse(doc[S.SA_POSITION]["x"].Value), float.Parse(doc[S.SA_POSITION]["y"].Value), float.Parse(doc[S.SA_POSITION]["z"].Value));
         GameObject go       = (GameObject)Instantiate(Resources.Load <GameObject>("AssetsLibrary/" + type), position, transform.rotation);
         if (go.GetComponent <SyncedAsset>() == null)
         {
             Debug.LogError("Prefab missing Synched Asset");
         }
         else
         {
             go.GetComponent <SyncedAsset>().UpdateWithJSON(doc.ToString());
         }
         if (!Enum.IsDefined(typeof(AssetType), type))
         {
             Debug.Log("Type from JSON is not an AssetType");
             AddToTree(go, (AssetType)Enum.Parse(typeof(AssetType), "Other"));
         }
         else
         {
             AddToTree(go, (AssetType)Enum.Parse(typeof(AssetType), type));
         }
     }
     catch (Exception e)
     {
         Debug.Log(e.ToString());
     }
 }
Example #24
0
        public static RfidBinding checkBindings(JSONNode JSONatt, touchType smartTouchType)
        {
            //Debug.LogError ("Checking rfid bindings that contains attributes...");
            RfidBinding rfidObject = null;
            for (int i = 0; i < bindedObjects.Count; i++) {
                RfidBinding temp = bindedObjects [i];
                for (int k = 0; k<JSONatt.Count; k++) {
                    string tempAttribute = JSONatt [k].Value;
                    if (temp.attribute.Contains (tempAttribute)) {
                        i = bindedObjects.Count;
                        k = JSONatt.Count;
                        //Debug.LogError ("Attributes found!...'" + tempAttribute + "', checking if binding is enabled and functions exists!");
                        if(temp.enableBinding &&
                            ((smartTouchType == touchType.smartTouchStart && temp.smartTouchStart != null) ||
                         (smartTouchType == touchType.smartTouchEnd && temp.smartTouchEnd != null))){
                            rfidObject = temp;
                        }

                    } else {
                        //Debug.LogError ("No bindings exists with attributes, " + tempAttribute);
                        rfidObject = null; //object exits, but not enabled or does not contain executable function
                    }
                }
            }
            return rfidObject;
        }
Example #25
0
        public IEnumerator GetCategories(int id)
        {
            WWWForm form = new WWWForm();

            form.AddField("user_id", id);

            using (UnityWebRequest www = UnityWebRequest.Post(BaseURL + "?action=get_categories", form))
            {
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    categories = new List <SimpleData> ();
                    SimpleJSON.JSONNode data = SimpleJSON.JSON.Parse(www.downloadHandler.text);
                    foreach (SimpleJSON.JSONNode message in data["categories"])
                    {
                        SimpleData f = new SimpleData(message ["category_id"].AsInt, message ["label"].Value, message ["description"].Value);
                        categories.Add(f);
                    }
                }
            }
        }
Example #26
0
    public string Deserialize(Stopwatch timer)
    {
        string notes;

        using (System.IO.FileStream inStream = new System.IO.FileStream(jsonPath, System.IO.FileMode.Open))
        {
            using (System.IO.BinaryReader reader = new System.IO.BinaryReader(inStream))
            {
                timer.Start();
                SimpleJSON.JSONNode  node = SimpleJSON.JSONNode.DeserializeBinary(reader);
                SimpleJSON.JSONArray arr  = node["junkList"].AsArray;
                Holder list = new Holder();
                list.junkList = new Junk[arr.Count];

                int i = 0;
                foreach (var n in arr)
                {
                    list.junkList[i] = new Junk();
                    list.junkList[i].SimpleJSONParse(n);
                    i++;
                }

                notes = "Parsed list is " + list.junkList.Length + " entries long, and we parsed " + i + " entries";
            }
        }
        return(notes);
    }
    public void StartGame()
    {
        if (GameStarted)
        {
            return;
        }

        GameStarted = true;

        VibrationManager = GetComponent <ControllerVibrationManager>();

        RobotArms = new GameObject[6];


        //NoteEndStartingPosition = new Vector3[6];

        for (int i = 0; i < RobotArms.Length; i++)
        {
            RobotArms[i] = GameObject.Instantiate(RobotArmPrefab, transform.position, transform.rotation * Quaternion.Euler(i * 60, 0, 0));

            //RobotArms[i].GetComponent<PunchPadHitDetection>().noteMgr = this;

            RobotArms[i].GetComponent <TestArmScr>().ArmIndex = i;

            //NoteEndTarget[i] = RobotArms[i].GetComponentInChildren<NoteMeshScr>().gameObject.transform;
        }

        SimpleJSON.JSONNode data = SimpleJSON.JSON.Parse(SongKeyframes.text);
        Debug.Log("Tempo " + data["tempo"]);

        SongTempo = data["tempo"];

        Notes = new Note[data["tracks"].Count];

        Debug.Log("Tracks Count " + data["tracks"].Count);

        for (int i = 0; i < data["tracks"].Count; i++)
        {
            Notes[i] = new Note();

            //Notes[i].NoteObj = GameObject.Instantiate(NotePrefab, Vector3.zero, Quaternion.identity);

            Notes[i].NoteObj.SetActive(false);

            Notes[i].pad = data["tracks"][i]["p"];

            Notes[i].time = data["tracks"][i]["t"];

            //Notes[i].EndTarget = NoteEndTarget[Notes[i].pad];

            Debug.Log("note pad " + i + ": " + Notes[i].pad);

            Debug.Log("note time " + i + ": " + Notes[i].time);
        }

        GetComponent <AudioSource>().clip = SongClip;
        GetComponent <AudioSource>().Play(); //just didn't want to hear this every time I hit play

        ScoreText.text = "Score: " + Score.ToString();
    }
Example #28
0
 public Items(CastleDBParser.RootNode root, RowValues line)
 {
     SimpleJSON.JSONNode node = root.GetSheetWithName("Items").Rows[(int)line];
     id     = node["id"];
     name   = node["name"];
     Weight = node["Weight"].AsInt;
 }
        //  create all layers
        private List<Layer> createLayers(JSONNode json)
        {
            List<Layer> layers = new List<Layer>();

            foreach (JSONNode layerNode in json.AsArray) {
                Layer layer = new Layer();
                layer.Name = layerNode["name"];
                layer.Height = layerNode["properties"]["Height"].AsInt;

                Vector3 rotation = Vector3.zero;

                if (layerNode["properties"]["Rotation-x"].Value != null) {
                    rotation.x = layerNode["properties"]["Rotation-x"].AsFloat;
                }

                if (layerNode["properties"]["Rotation-y"].Value != null) {
                    rotation.y = layerNode["properties"]["Rotation-y"].AsFloat;
                }

                if (layerNode["properties"]["Rotation-z"].Value != null) {
                    rotation.z = layerNode["properties"]["Rotation-z"].AsFloat;
                }

                layer.Rotation = Quaternion.Euler(rotation);

                foreach (JSONNode dataNode in layerNode["data"].AsArray) {
                    layer.Data.Add(dataNode.AsInt);
                }

                layers.Add(layer);
            }

            return layers;
        }
Example #30
0
 public IParseble Parse(JSONNode buyDataNode)
 {
     if (buyDataNode ["currency"] != null)
         currency = buyDataNode ["currency"];
     if (buyDataNode ["sum"] != null)
         sum = buyDataNode ["sum"];
     if (buyDataNode ["enabled"] != null)
         enabled = buyDataNode ["enabled"].AsBool;
     if (buyDataNode ["example"] != null)
         example = buyDataNode ["example"];
     if (buyDataNode ["isMandatory"] != null)
         isMandatory = buyDataNode ["isMandatory"];
     if (buyDataNode ["isPakets"] != null)
         isPakets = buyDataNode ["isPakets"];
     if (buyDataNode ["isReadonly"] != null)
         isReadonly = buyDataNode ["isReadonly"];
     if (buyDataNode ["isVisible"] != null)
         isVisible = buyDataNode ["isVisible"];
     if (buyDataNode ["name"] != null)
         name = buyDataNode ["name"];
     if (buyDataNode ["options"] != null)
         options = buyDataNode ["options"];
     if (buyDataNode ["title"] != null)
         title = buyDataNode ["title"];
     if (buyDataNode ["tooltip"] != null)
         tooltip = buyDataNode ["tooltip"];
     if (buyDataNode ["type"] != null)
         type = buyDataNode ["type"];
     if (buyDataNode ["value"] != null)
         value = buyDataNode ["value"];
     return this;
 }
    private bool _initRegressorMatrix(ref Matrix[] jointTemplate, ref Matrix[] regressor, ref TextAsset ta)
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-us");

        string jsonText = ta.text;

        SimpleJSON.JSONNode node = SimpleJSON.JSON.Parse(jsonText);

        // Get gender of the joint-regressor being used
        _gender = node ["gender"];

        // Init matrices
        for (int i = 0; i < _numberOfJoints; i++)
        {
            // Init joint template matrix
            double x = node["template_J"][i][0].AsDouble;
            double y = node["template_J"][i][1].AsDouble;
            double z = node["template_J"][i][2].AsDouble;

            (jointTemplate[0])[i, 0] = x;
            (jointTemplate[1])[i, 0] = y;
            (jointTemplate[2])[i, 0] = z;

            // Init beta regressor matrix
            for (int j = 0; j < _numberOfBetas; j++)
            {
                (regressor[0])[i, j] = node["betasJ_regr"][i][0][j].AsDouble;
                (regressor[1])[i, j] = node["betasJ_regr"][i][1][j].AsDouble;
                (regressor[2])[i, j] = node["betasJ_regr"][i][2][j].AsDouble;
            }
        }
        return(true);
    }
Example #32
0
 public FX_Storage(CastleDBParser.RootNode root, RowValues line)
 {
     SimpleJSON.JSONNode node = root.GetSheetWithName("FX_Storage").Rows[(int)line];
     id       = node["id"];
     FXPath   = node["FXPath"];
     FXPrefab = node["FXPrefab"];
 }
Example #33
0
    static void Get_Notification_Key_Response(object[] data, Action <object[]> concluding_method)
    {
        Response_Status status = Http_Client.Parse_Status(data[0]);

        if (status < Response_Status.Network_Error)
        {
            SimpleJSON.JSONNode raw = SimpleJSON.JSON.Parse((string)data[2]);

            if (status == Response_Status.Ok)
            {
                if (raw["notification_key"] != null)
                {
                    Debug.Log("Notification key is " + raw["notification_key"].Value);
                    concluding_method?.Invoke(new object[] { status, raw["notification_key"].Value });
                }
                else
                {
                    Debug.LogError("Correct HTTP response but notification key is null!");
                }
            }
            else
            {
                concluding_method?.Invoke(new object[] { status, raw["error"].Value });
            }
        }
    }
        public static BaseRule<PlayerState> make(JSONNode ruleNode)
        {
            string ruletype = ruleNode["type"];
            //Debug.Log("ruletype:"+ruletype);
            BaseRule<PlayerState> rule = null;

            ReallySimpleLogger.ReallySimpleLogger.WriteLog(
                typeof(JsonGameRuleFactory),string.Format("building rule of type:{0}",ruletype));

            if(ruletype.Equals("PlayerCrumbAllStateRule")){
                JSONArray crumbJson = ruleNode["state_crumb"].AsArray;
                string[] iA = new string[crumbJson.Count];

                int index = 0;
                foreach(JSONNode item in crumbJson){
                    iA[index] = (string)item;
                    index+=1;
                }

                string baseState = ruleNode["baseState"];
                string resultState = ruleNode["resultState"];

                //iAPlayer.state_crumbs = CollectionUtils.AsSet(iA);
                Player iAPlayer = new Player(){ State_crumbs = CollectionUtils.AsList(iA) };
                rule = new PlayerCrumbAllStateRule(new PlayerState(iAPlayer, baseState), resultState);

            } else if(ruletype.Equals("PlayerCrumbAnyStateRule")){
                JSONArray inventoryJson = ruleNode["state_crumb"].AsArray;
                string[] iA = new string[inventoryJson.Count];

                int index = 0;
                foreach(JSONNode item in inventoryJson){
                    iA[index] = (string)item;
                    index+=1;
                }

                string baseState = ruleNode["baseState"];
                string resultState = ruleNode["resultState"];

                Player iAPlayer = new Player(){ State_crumbs = CollectionUtils.AsList(iA) };
                //iAPlayer.state_crumbs = CollectionUtils.AsSet(iA);
                rule = new PlayerCrumbAnyStateRule(new PlayerState(iAPlayer, baseState), resultState);

            }
            //			else if(ruletype.Equals("PlayerStateFactorsRule")){
            //				//JSONNode playerNode = ruleNode["player"];
            //				Player p = new Player(ruleNode["player"]);
            //
            //				string baseState = ruleNode["baseState"];
            //				string resultState = ruleNode["resultState"];
            //				rule = new PlayerCrumbAnyStateRule(new PlayerState(p);
            //			}
            // Guard against a NULL rule
            if (rule == null)
            {
                throw new ArgumentNullException("rule is empty");
            }
            return rule;
        }
    private void ReadJsonValues()
    {
        string json_values = WaveVR_Utils.OEMConfig.getControllerConfig();

        if (!json_values.Equals(""))
        {
            SimpleJSON.JSONNode jsNodes = SimpleJSON.JSONNode.Parse(json_values);
            string node_value           = "";

            char[] split_symbols = { '[', ',', ']' };

            node_value = jsNodes ["arm"] ["head_to_elbow_offset"].Value;
            if (!node_value.Equals(""))
            {
                string[] split_value = node_value.Split(split_symbols);
                HEADTOELBOW_OFFSET = new Vector3(float.Parse(split_value [1]), float.Parse(split_value [2]), float.Parse(split_value [3]));
            }

            node_value = jsNodes ["arm"] ["elbow_to_wrist_offset"].Value;
            if (!node_value.Equals(""))
            {
                string[] split_value = node_value.Split(split_symbols);
                ELBOWTOWRIST_OFFSET = new Vector3(float.Parse(split_value [1]), float.Parse(split_value [2]), float.Parse(split_value [3]));
            }

            node_value = jsNodes ["arm"] ["wrist_to_controller_offset"].Value;
            if (!node_value.Equals(""))
            {
                string[] split_value = node_value.Split(split_symbols);
                WRISTTOCONTROLLER_OFFSET = new Vector3(float.Parse(split_value [1]), float.Parse(split_value [2]), float.Parse(split_value [3]));
            }

            node_value = jsNodes ["arm"] ["elbow_pitch_angle_offset"].Value;
            if (!node_value.Equals(""))
            {
                string[] split_value = node_value.Split(split_symbols);
                ELBOW_PITCH_OFFSET = new Vector3(float.Parse(split_value [1]), float.Parse(split_value [2]), float.Parse(split_value [3]));
            }

            node_value = jsNodes ["arm"] ["elbow_pitch_angle_min"].Value;
            if (!node_value.Equals(""))
            {
                ELBOW_PITCH_ANGLE_MIN = float.Parse(node_value);
            }

            node_value = jsNodes ["arm"] ["elbow_pitch_angle_max"].Value;
            if (!node_value.Equals(""))
            {
                ELBOW_PITCH_ANGLE_MAX = float.Parse(node_value);
            }

            PrintDebugLog(
                "HEADTOELBOW_OFFSET: {" + HEADTOELBOW_OFFSET.x + ", " + HEADTOELBOW_OFFSET.y + ", " + HEADTOELBOW_OFFSET.z +
                "\nELBOWTOWRIST_OFFSET: " + ELBOWTOWRIST_OFFSET.x + ", " + ELBOWTOWRIST_OFFSET.y + ", " + ELBOWTOWRIST_OFFSET.z +
                "\nWRISTTOCONTROLLER_OFFSET: " + WRISTTOCONTROLLER_OFFSET.x + ", " + WRISTTOCONTROLLER_OFFSET.y + ", " + WRISTTOCONTROLLER_OFFSET.z +
                "\nELBOW_PITCH_OFFSET: " + ELBOW_PITCH_OFFSET.x + ", " + ELBOW_PITCH_OFFSET.y + ", " + ELBOW_PITCH_OFFSET.z +
                "\nELBOW_PITCH_ANGLE_MIN: " + ELBOW_PITCH_ANGLE_MIN + "\nELBOW_PITCH_ANGLE_MAX: " + ELBOW_PITCH_ANGLE_MAX);
        }
    }
 public static Player Deserialize(JSONNode json)
 {
     return new Player {
         Name = json["name"].Value,
         PlanningCards = ParsePlanningCards(json["planning-cards"]),
         UseOneMorePlanningSprint = json["use-one-more-planning-sprint"].AsBool
     };
 }
Example #37
0
 public List<string> GetList(JSONNode N)
 {
     List<string> l = new List<string>();
     foreach(string value in N.Childs){
         l.Add(value);
     }
     return l;
 }
 private static int[] ParsePlanningCards(JSONNode json)
 {
     var len = json.Count;
     var result = new int[len];
     for (var i = 0; i < len; i++)
         result[i] = json[i].AsInt;
     return result;
 }
Example #39
0
 public Component(GameObject obj, JSONNode node) 
     : base(node)
 {
     GameObject = obj;
     this.Transform = GameObject.Transform;
     this.Scene = GameObject.Scene;
     this.Enabled = true;
 }
Example #40
0
 public void Init(JSONNode enemyData)
 {
     var data = enemyData[Name];
     if (data["hp"] != null) Health = data["hp"].AsInt;
     if (data["sp"] != null) Shield = data["sp"].AsInt;
     if (data["delay"] != null) ShootDelay = data["delay"].AsFloat;
     Weapons = (from JSONNode weapon in data["weapons"].AsArray select new Weapon(weapon[1], weapon[0])).ToList();
 }
        private static GazeFocusSettings GetSettingsFromObject(SimpleJSON.JSONNode json)
        {
            var gfs = new GazeFocusSettings();

            gfs.LayerMask       = json["LayerMask"].AsInt;
            gfs.MaximumDistance = json["MaximumDistance"].AsFloat;
            return(gfs);
        }
Example #42
0
 public Countries(CastleDBParser.RootNode root, RowValues line)
 {
     SimpleJSON.JSONNode node = root.GetSheetWithName("Countries").Rows[(int)line];
     id   = node["id"];
     Name = node["Name"];
     Team = new CompiledTypes.Teams(root, CompiledTypes.Teams.GetRowValue(node["Team"]));
     Flag = node["Flag"];
 }
Example #43
0
 public override void FromJSON(Tile tile, JSONNode node)
 {
     tile.position.x = node ["x"].AsInt;
     tile.position.y = node ["y"].AsInt;
     tile.text = "E";
     tile.color = Color.green;
     name = node ["name"];
     description = node ["description"];
 }
Example #44
0
 public static Ticket FromJson(JSONNode json)
 {
     Ticket ticket = new Ticket();
     ticket.Uri = json["uri"].Value;
     ticket.CompleteUri = json["complete_uri"].Value;
     ticket.TicketId = json["ticket_id"].Value;
     ticket.UploadLinkSecure = json["upload_link_secure"].Value;
     return ticket;
 }
 private void LoadJSON(string s)
 {
     try {
     JSONNode n = SimpleJSON.JSON.Parse(s);
     this.jsonConfig = n;
     } catch (JSONException e) {
     Debug.Log("No config loaded..." + e.ToString());
     }
 }
 public IParseble Parse(JSONNode rootNode)
 {
     _couponCode = rootNode["coupon_code"];
     _operationId = rootNode["operation_id"].AsInt;
     JSONNode node = rootNode["errors"].AsArray[0];
     _error = node["message"];
     _api = new XsollaApi().Parse(rootNode[XsollaApiConst.R_API]) as XsollaApi;
     return this;
 }
Example #47
0
 public override void Add(string aKey, JSONNode aItem)
 {
     if (!string.IsNullOrEmpty(aKey)) {
         if (_dict.ContainsKey(aKey))
             _dict[aKey] = aItem;
         else
             _dict.Add(aKey, aItem);
     } else
         _dict.Add(Guid.NewGuid().ToString(), aItem);
 }
Example #48
0
 public IParseble Parse(JSONNode xsollaInfoNode)
 {
     name = xsollaInfoNode ["name"].Value;
     value = xsollaInfoNode ["value"].Value;
     string key = xsollaInfoNode["attributes"]["key"];
     string pref = xsollaInfoNode["attributes"]["pref"];
     string parameter = xsollaInfoNode["attributes"]["parameter"];
     attributes = new Attributes (key, pref, parameter);
     return this;
 }
        private String getJsonString(JSONNode node, string key)
        {
            var jsonValue = getJsonValue (node, key);

            if (jsonValue == null) {
                return null;
            }

            return jsonValue.Value;
        }
 public void Load(JSONNode json)
 {
     _list = new Dictionary<string, ElementTransform>();
     var elements = json["game_elemets"];
     for (int i = 0; i < elements.AsArray.Count; i++)
     {
         var et = new ElementTransform(elements[i]);
         _list.Add(et.Name + et.Index, et);
     }
 }
 public static List<XsollaBonusItem> ParseMany(JSONNode bonusItemsNode)
 {
     var bonusItems = new List<XsollaBonusItem>(bonusItemsNode.Count);
     var bonusItemsEnumerator = bonusItemsNode.Childs.GetEnumerator ();
     while(bonusItemsEnumerator.MoveNext())
     {
         bonusItems.Add(new XsollaBonusItem().Parse(bonusItemsEnumerator.Current) as XsollaBonusItem);
     }
     return bonusItems;
 }
Example #52
0
        public JSONNode GetLevelData(int level)
        {
            // On level start, load enemies and paths
            _pathFile = JSON.Parse(Resources.Load<TextAsset>("Data/Paths").text);
            _enemiesFile = JSON.Parse(Resources.Load<TextAsset>("Data/Enemies").text);

            // Load level data
            var json = JSON.Parse(Resources.Load<TextAsset>("Data/" + level).text);
            if (json == null) Debug.LogError("Could not load '" + level + ".json'");
            return json;
        }
Example #53
0
        public void LoadLevel(int level)
        {
            // Load level data
            if (_level.GetComponent<LoadJsonData>()) Destroy(_level.GetComponent<LoadJsonData>());
            LevelData = _level.AddComponent<LoadJsonData>().GetLevelData(level);

            // Generate stuff
            StartCoroutine(GenerateEnemies());
            StartCoroutine(GenerateLevel(level));
            StartCoroutine(GenerateMessages());
        }
Example #54
0
        public IParseble Parse(JSONNode utilsNode)
        {
            accessToken 	= utilsNode [XsollaApiConst.ACCESS_TOKEN].Value;
            user 			= new XsollaUser ().Parse (utilsNode [XsollaApiConst.R_USER]) as XsollaUser;
            project 		= new XsollaProject ().Parse (utilsNode [XsollaApiConst.R_PROJECT]) as XsollaProject;
            purchase 		= new XsollaPurchase ().Parse (utilsNode [XsollaApiConst.R_PURCHASE]) as XsollaPurchase;
            settings 		= new XsollaSettings ().Parse (utilsNode [XsollaApiConst.R_SETTINGS]) as XsollaSettings;
            translations 	= new XsollaTranslations ().Parse (utilsNode [XsollaApiConst.R_TRANSLATIONS]) as XsollaTranslations;
            api 			= new XsollaApi ().Parse (utilsNode [XsollaApiConst.R_API]) as XsollaApi;

            return this;
        }
        private JSONNode getJsonValue(JSONNode node, string key)
        {
            if (node == null) {
                return null;
            }

            var nodeValue = node[key];

            if (nodeValue.GetType () == typeof(JSONLazyCreator)) {
                return null;
            }

            return nodeValue;
        }
Example #56
0
 public IParseble Parse(JSONNode checkoutNode)
 {
     if (checkoutNode ["action"] != null && !"null".Equals (checkoutNode ["action"])) {
         action = checkoutNode ["action"];
         data = new Dictionary<string, string> ();
         var dataNode = checkoutNode ["data"] as JSONClass;
         IEnumerator<KeyValuePair<string, JSONNode>> enumerator = dataNode.GetKeyValueDict ().GetEnumerator ();
         while (enumerator.MoveNext()) {
             data.Add (enumerator.Current.Key, enumerator.Current.Value);
         }
         method = checkoutNode ["method"];
         return this;
     } else {
         return null;
     }
 }
Example #57
0
 public IParseble Parse(JSONNode financyNode)
 {
     if(financyNode["sub_total"] != null)
         subTotal = new FinanceItem().Parse(financyNode["sub_total"]) as FinanceItem;
     if(financyNode["discount"] != null)
         discount = new FinanceItemBase().Parse(financyNode["discount"]) as FinanceItemBase;
     if(financyNode["fee"] != null)
         fee = new FinanceItemBase().Parse(financyNode["fee"]) as FinanceItemBase;
     if(financyNode["xsolla_credits"] != null)
         xsollaCredits = new FinanceItem().Parse(financyNode["xsolla_credits"]) as FinanceItem;
     if(financyNode["total"] != null)
         total = new FinanceItemBase().Parse(financyNode["total"]) as FinanceItemBase;
     if(financyNode["vat"] != null)
         vat = new FinanceItemBase().Parse(financyNode["vat"]) as FinanceItemBase;
     return this;
 }
Example #58
0
 public IParseble Parse(JSONNode purchaseNode)
 {
     if (purchaseNode.Count == 0)
         return null;
     if(purchaseNode ["virtual_currency"] != null)
         virtualCurrency = new VirtualCurrency ().Parse (purchaseNode ["virtual_currency"]) as VirtualCurrency;
     if(purchaseNode ["virtual_items"] != null)
         virtualItems = new VirtualItems().Parse(purchaseNode ["virtual_items"]) as VirtualItems;
     if(purchaseNode ["subscription"] != null)
         subscription = new Subscription ().Parse (purchaseNode ["subscription"]) as Subscription;
     if(purchaseNode ["payment_system"] != null)
         paymentSystem = new PaymentSystem().Parse(purchaseNode ["payment_system"]) as PaymentSystem;
     if (purchaseNode ["checkout"] != null)
         checkout = new Checkout ().Parse(purchaseNode ["checkout"]) as Checkout;;
     return this;
 }
 public IParseble Parse(JSONNode rootNode)
 {
     TotalWithoutDiscount 	= rootNode["finance"]["total_without_discount"]["vc_amount"].AsInt;
     Total 					= rootNode["finance"]["total"]["vc_amount"].AsInt;
     IsSkipConfirmation 		= rootNode["skip_confirmation"].AsBool;
     JSONArray jarrItems 	= rootNode["purchase"]["virtual_items"].AsArray;
     IEnumerator<JSONNode> iEnumerator = jarrItems.Childs.GetEnumerator();
     while (iEnumerator.MoveNext()) {
         JSONNode itemNode = iEnumerator.Current;
         SimpleVItem newItem = new SimpleVItem(itemNode["name"].Value,
                                            itemNode["image_url"].Value,
                                            itemNode["quantity"].AsInt);
         Items.Add(newItem);
     }
     return this;
 }
Example #60
0
        public static void GetConfig(string url = "http://localhost:8888/config") {
			// load the url
			string strContent;
			var webRequest = WebRequest.Create(@url);
			using (var response = webRequest.GetResponse())
			using(var content = response.GetResponseStream())
			using(var reader = new StreamReader(content)){
				strContent = reader.ReadToEnd();
			}

			// parse it as json
			_Config = JSON.Parse(strContent);

			// fire OnConfigLoaded
			if(OnConfigLoaded!=null)
				OnConfigLoaded();
		}