Exemplo n.º 1
0
    public void SendCompletedMission()
    {
        JSONObject json = new JSONObject();

        json["type"] = "completed-mission";
        SendMessage(json);
    }
Exemplo n.º 2
0
    void BoradcastBoardEvent(GameCommand command)
    {
        if (command > GameCommand.BOARD_START && command < GameCommand.BOARD_END)
        {
            GameEvent evt = new GameEvent();
            evt.PCommand = command;
            if (command == GameCommand.BOARD_SCORE_POINT)
            {
                SimpleJSON.JSONObject obj = new SimpleJSON.JSONObject();
                obj[Constant.SAVE_SCORE] = m_ScorePoint;
                evt.PParams = obj;
            }
            EventBoard(evt);
        }

        // switch (command)
        // {
        //     case GameCommand.BOARD_CAN_RECEIVE_INPUT:
        //     {
        //         evt.PCommand = command;
        //         break;
        //     }

        //     case GameCommand.BOARD_STOP_RECEIVE_INPUT:
        //     {
        //         evt.PCommand = command;
        //         break;
        //     }
        // }

        // if (command != GameCommand.NONE)
        // {
        //     EventBoard(evt);
        // }
    }
Exemplo n.º 3
0
    public override void Load(SimpleJSON.JSONObject json_data)
    {
        friendState = json_data["friendState"].AsInt;


        string pickedUpObjs = json_data["pickedUpObjects"];

        Debug.Log("******loaded rock obj string:********" + pickedUpObjs);
        if (pickedUpObjs != null)
        {
            string[] pickedUpArray = pickedUpObjs.Split(',');
            for (int i = 0; i < pickedUpArray.Length; i++)
            {
                for (int j = 0; j < desiredObject.Count; j++)
                {
                    if (desiredObject[j].name == pickedUpArray[i])
                    {
                        pickedUpObjects.Add(desiredObject[j]);
                        desiredObject.RemoveAt(j);
                        break;
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
 static public string JsonToString(SimpleJSON.JSONObject jClass)
 {
     if (null == jClass)
     {
         return(string.Empty);
     }
     return(JsonToString(jClass.ToString()));
 }
Exemplo n.º 5
0
    public override SimpleJSON.JSONObject Save()
    {
        var json_data = new SimpleJSON.JSONObject();

        json_data["friendState"] = friendState;

        return(json_data);
    }
Exemplo n.º 6
0
        public static StringMessage BasicValueToStringMsg(string p_event_name, string p_value, string p_playerID)
        {
            SimpleJSON.JSONObject newJSON = new SimpleJSON.JSONObject();
            newJSON["_id"]       = p_event_name;
            newJSON["player_id"] = p_playerID;
            newJSON["message"]   = p_value;

            return(new StringMessage(newJSON.ToString()));
        }
Exemplo n.º 7
0
    private static Network ParseNetwork(JSONObject json)
    {
        Network network;

        network.bandwidth   = (int)json["bandwidth"].AsLong;
        network.latency     = (int)json["latency"].AsLong;
        network.reliability = (int)json["reliability"].AsLong;
        network.security    = (int)json["security"].AsLong;
        return(network);
    }
    public SimpleJSON.JSONNode SimpleJSONPopulateNode()
    {
        SimpleJSON.JSONNode n = new SimpleJSON.JSONObject();

        n["MyStringA"] = MyStringA;
        n["MyStringB"] = MyStringB;
        n["MyStringC"] = MyStringC;
        n["MyStringD"] = MyStringD;

        return(n);
    }
Exemplo n.º 9
0
    public void TryAnswer()
    {
        btnTryAnswer.gameObject.SetActive(false);

        var N = new SimpleJSON.JSONObject();

        N["teamID"]     = Info.TeamId;
        N["answers"][0] = GameObject.Find("c1").GetComponent <color>().SelecctedColorId;
        N["answers"][1] = GameObject.Find("c2").GetComponent <color>().SelecctedColorId;
        N["answers"][2] = GameObject.Find("c3").GetComponent <color>().SelecctedColorId;
        N["answers"][3] = GameObject.Find("c4").GetComponent <color>().SelecctedColorId;
        _api.ApiPost("MasterMind/try", N, showResult);
    }
Exemplo n.º 10
0
    public override void Load(SimpleJSON.JSONObject json_data)
    {
        friendState      = json_data["friendState"].AsInt;
        movieEnhancement = json_data["movieEnhancement"];
        wearHat          = json_data["wearHat"].AsBool;
        earnedProjector  = json_data["earnedProjector"].AsBool;
        day = json_data["day"].AsInt;

        films.Clear();
        for (int i = 0; i < json_data["films"].Count; i++)
        {
            films.Add(json_data["films"][i]);
        }
    }
Exemplo n.º 11
0
    public SimpleJSON.JSONNode SimpleJSONPopulateNode()
    {
        SimpleJSON.JSONNode n = new SimpleJSON.JSONObject();
        n["BitsName"] = BitsName;

        SimpleJSON.JSONArray arr = new SimpleJSON.JSONArray();
        for (int i = 0; i < SomeBits.Length; i++)
        {
            arr[i] = SomeBits[i];
        }
        n["SomeBits"] = arr;

        return(n);
    }
    public override SimpleJSON.JSONObject Save()
    {
        SimpleJSON.JSONNode.longAsString = true; // Needed to store pins properly.
        var json_data = new SimpleJSON.JSONObject();

        // Game Settings.
        json_data["MASTER_MUSIC_VOL"] = MASTER_MUSIC_VOL;
        json_data["MASTER_SFX_VOL"]   = MASTER_SFX_VOL;

        // Gameplay and collectables.
        json_data["DAY_NUMBER"] = DAY_NUMBER;

        json_data["ABILITY_PIN_1"] = (long)EquippedAbilityPins[0];
        json_data["ABILITY_PIN_2"] = (long)EquippedAbilityPins[1];

        json_data["pinsDiscoveredValue"] = pinsDiscoveredValue;
        json_data["pinsEquippedValue"]   = pinsEquippedValue;
        json_data["pinsViewedValue"]     = pinsViewedValue;

        json_data["WORLD_ROOMS_DISCOVERED"] = (uint)WORLD_ROOMS_DISCOVERED;

        json_data["STANDARD_GARBAGE_DISCOVERED"]   = (uint)STANDARD_GARBAGE_DISCOVERED;
        json_data["STANDARD_GARBAGE_VIEWED"]       = (uint)STANDARD_GARBAGE_VIEWED;
        json_data["COMPOST_GARBAGE_DISCOVERED"]    = (uint)COMPOST_GARBAGE_DISCOVERED;
        json_data["COMPOST_GARBAGE_VIEWED"]        = (uint)COMPOST_GARBAGE_VIEWED;
        json_data["RECYCLABLE_GARBAGE_DISCOVERED"] = (uint)RECYCLABLE_GARBAGE_DISCOVERED;
        json_data["RECYCLABLE_GARBAGE_VIEWED"]     = (uint)RECYCLABLE_GARBAGE_VIEWED;
        json_data["LARGE_GARBAGE_DISCOVERED"]      = (uint)LARGE_GARBAGE_DISCOVERED;
        json_data["LARGE_GARBAGE_VIEWED"]          = (uint)LARGE_GARBAGE_VIEWED;

        // Stats and things
        json_data["STAR_POINTS"]             = STAR_POINTS_STAT.GetMaxRaw();
        json_data["CURRENT_STAR_POINTS"]     = STAR_POINTS_STAT.GetCurrent();
        json_data["TOTAL_DAYTIME_INSECONDS"] = TOTAL_DAYTIME_INSECONDS;
        json_data["TIME_UPGRADE_LEVEL"]      = TIME_UPGRADE_LEVEL;
        json_data["Max_HP"]       = HP_STAT.GetMaxRaw();
        json_data["BAG_SIZE"]     = BAG_SIZE_STAT.GetMaxRaw();
        json_data["PPVALUE"]      = PP_STAT.GetMaxRaw();
        json_data["DEJAVUCOUNT"]  = DEJAVUCOUNT;
        json_data["CURSEVALUE"]   = CURSEVALUE;
        json_data["MOMONEYVALUE"] = MOMONEYVALUE;
        json_data["PROGRESS_LV"]  = PROGRESS_LV;
        json_data["UPGRADES"]     = (uint)UPGRADES_UNLOCKED;

        json_data["TUT_POPUPS_SHOWN"]   = (uint)TUT_POPUPS_SHOWN;
        json_data["BROKEN_TRASH_DOORS"] = (uint)BROKEN_TRASH_DOORS;         //steve did I do this right?

        return(json_data);
    }
Exemplo n.º 13
0
 public void PopulatePlayerList(SimpleJSON.JSONObject json)
 {
     Debug.Log(json);
     foreach (SimpleJSON.JSONNode p in json)
     {
         PlayerData player = new PlayerData();
         player.name   = p["name"].Value;
         player.attack = p["attack"].AsInt;
         player.level  = p["level"].AsInt;
         player.xp     = p["xp"].AsInt;
         players.Add(player);
         Debug.Log(p["name"].Value);
         SpawnPlayer(player);
     }
 }
Exemplo n.º 14
0
    /// <summary>
    /// Builds JSON object of the results and writes it to a file
    /// </summary>
    /// <param name="time"></param>
    /// <param name="usedCheats"></param>
    public static void WriteResultsToFile(float time, bool usedCheats)
    {
        var outputObject = new SimpleJSON.JSONObject();

        outputObject["completionTime"] = time;
        outputObject["usedCheats"]     = usedCheats;

        string   file = Path.Combine(Directory.GetCurrentDirectory(), GameConfiguration.Instance.OutputFile);
        FileInfo fi   = new FileInfo(file);

        if (!fi.Directory.Exists)
        {
            Directory.CreateDirectory(fi.DirectoryName);
        }
        File.WriteAllText(file, outputObject.ToString());
    }
    public override void Load(SimpleJSON.JSONObject json_data)
    {
        MASTER_MUSIC_VOL = json_data["MASTER_MUSIC_VOL"].AsFloat;
        MASTER_SFX_VOL   = json_data["MASTER_SFX_VOL"].AsFloat;

        DAY_NUMBER             = json_data["DAY_NUMBER"].AsInt;
        WORLD_ROOMS_DISCOVERED = (ROOM)json_data["WORLD_ROOMS_DISCOVERED"].AsInt;
        pinsDiscoveredValue    = json_data["pinsDiscoveredValue"].AsLong;
        pinsEquippedValue      = json_data["pinsEquippedValue"].AsLong;
        pinsViewedValue        = json_data["pinsViewedValue"].AsLong;


        EquippedAbilityPins[0] = (PIN)json_data["ABILITY_PIN_1"].AsLong;
        EquippedAbilityPins[1] = (PIN)json_data["ABILITY_PIN_2"].AsLong;

        STANDARD_GARBAGE_DISCOVERED   = (STANDARDGARBAGE)json_data["STANDARD_GARBAGE_DISCOVERED"].AsInt;
        STANDARD_GARBAGE_VIEWED       = (STANDARDGARBAGE)json_data["STANDARD_GARBAGE_VIEWED"].AsInt;
        COMPOST_GARBAGE_DISCOVERED    = (COMPOSTGARBAGE)json_data["COMPOST_GARBAGE_DISCOVERED"].AsInt;
        COMPOST_GARBAGE_VIEWED        = (COMPOSTGARBAGE)json_data["COMPOST_GARBAGE_VIEWED"].AsInt;
        RECYCLABLE_GARBAGE_DISCOVERED = (RECYCLABLEGARBAGE)json_data["RECYCLABLE_GARBAGE_DISCOVERED"].AsInt;
        RECYCLABLE_GARBAGE_VIEWED     = (RECYCLABLEGARBAGE)json_data["RECYCLABLE_GARBAGE_VIEWED"].AsInt;
        LARGE_GARBAGE_DISCOVERED      = (LARGEGARBAGE)json_data["LARGE_GARBAGE_DISCOVERED"].AsInt;
        LARGE_GARBAGE_VIEWED          = (LARGEGARBAGE)json_data["LARGE_GARBAGE_VIEWED"].AsInt;

        STAR_POINTS_STAT = new PlayerStat(PLAYERSTATTYPE.STAR_POINTS, json_data["STAR_POINTS"].AsInt);
        STAR_POINTS_STAT.SetCurrent(json_data["CURRENT_STAR_POINTS"].AsInt);

        HP_STAT = new PlayerStat(PLAYERSTATTYPE.HP, json_data["Max_HP"].AsInt);
        HP_STAT.ResetCurrent();

        BAG_SIZE_STAT = new PlayerStat(PLAYERSTATTYPE.BAG_SIZE, json_data["BAG_SIZE"].AsInt);
        HP_STAT.ResetCurrent();

        PP_STAT = new PlayerStat(PLAYERSTATTYPE.PP, json_data["PPVALUE"].AsInt);

        DEJAVUCOUNT             = json_data["DEJAVUCOUNT"].AsInt;
        CURSEVALUE              = json_data["CURSEVALUE"].AsInt;
        MOMONEYVALUE            = json_data["MOMONEYVALUE"].AsInt;
        PROGRESS_LV             = json_data["PROGRESS_LV"].AsInt;
        UPGRADES_UNLOCKED       = (UPGRADES)json_data["UPGRADES"].AsInt;
        TOTAL_DAYTIME_INSECONDS = json_data["TOTAL_DAYTIME_INSECONDS"].AsInt;
        TIME_UPGRADE_LEVEL      = json_data["TIME_UPGRADE_LEVEL"].AsInt;
        TUT_POPUPS_SHOWN        = (TUTORIALPOPUPS)json_data["TUT_POPUPS_SHOWN"].AsInt;
        BROKEN_TRASH_DOORS      = (TRASHDOORS)json_data["BROKEN_TRASH_DOORS"].AsInt;    //Steve did I do this right?
    }
Exemplo n.º 16
0
    public override SimpleJSON.JSONObject Save()
    {
        var json_data = new SimpleJSON.JSONObject();

        json_data["friendState"] = friendState;

        string savedObjString = "";

        for (int i = 0; i < pickedUpObjects.Count; i++)
        {
            savedObjString = savedObjString + pickedUpObjects[i].name + ",";
        }
        Debug.Log("***SavedObjString for Rock:" + savedObjString);

        json_data["pickedUpObjects"] = savedObjString;


        return(json_data);
    }
Exemplo n.º 17
0
    public SimpleJSON.JSONNode SimpleJSONPopulateNode()
    {
        SimpleJSON.JSONNode n = new SimpleJSON.JSONObject();
        n["JunkName"] = JunkName;
        n["JunkData"] = JunkData;

        n["FloatA"] = FloatA;
        n["FloatB"] = FloatB;
        n["FloatC"] = FloatC;
        n["FloatD"] = FloatD;

        n["IntA"] = IntA;
        n["IntB"] = IntB;

        n["MyStuff"] = MyStuff.SimpleJSONPopulateNode();
        n["MyThing"] = MyThing.SimpleJSONPopulateNode();

        return(n);
    }
Exemplo n.º 18
0
    public override SimpleJSON.JSONObject Save()
    {
        var json_data = new SimpleJSON.JSONObject();

        json_data["friendState"]      = friendState;
        json_data["movieEnhancement"] = movieEnhancement;
        json_data["wearHat"]          = wearHat;
        json_data["earnedProjector"]  = earnedProjector;
        json_data["day"] = day; // keeping hold of the day for the next film.

        // keep track of the films
        json_data.Remove("films");
        for (int i = 0; i < films.Count; i++)
        {
            json_data["films"][i] = films[i];
        }

        return(json_data);
    }
Exemplo n.º 19
0
    public SimpleJSON.JSONNode SimpleJSONPopulateNode()
    {
        SimpleJSON.JSONNode n = new SimpleJSON.JSONObject();
        n["StuffName"] = StuffName;

        n["DescA"] = DescA;
        n["DescB"] = DescB;
        n["DescC"] = DescC;
        n["DescD"] = DescD;
        n["DescE"] = DescE;

        n["AttrA"] = AttrA;
        n["AttrB"] = AttrB;
        n["AttrC"] = AttrC;

        n["MyBits"]   = MyBits.SimpleJSONPopulateNode();
        n["MyPieces"] = MyPieces.SimpleJSONPopulateNode();

        return(n);
    }
Exemplo n.º 20
0
    void backToNav(string json)
    {
        var   N           = new SimpleJSON.JSONObject();
        var   timeresult  = (DateTime.Now - starttijd).Minutes;
        float finalResult = 0;

        if (timeresult < 3)
        {
            finalResult = 100;
        }
        else if (timeresult < 10)
        {
            finalResult = 103 - timeresult;
        }
        else
        {
            finalResult = 85 - ((timeresult - 10) * 0.5f);
        }
        finalResult = (finalResult - (guesses * 0.25f)) / 10;
        Debug.Log("all found");
        levelLoader.ChangeGameModeEndOfGame(_api, "havenhuis", finalResult);
    }
Exemplo n.º 21
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        SerializedProperty list = serializedObject.FindProperty("affixes");

        EditorGUILayout.PropertyField(list);

        EditorGUI.indentLevel += 1;
        if (list.isExpanded)
        {
            for (int i = 0; i < list.arraySize; i++)
            {
                SerializedProperty affix        = list.GetArrayElementAtIndex(i);
                SerializedProperty Name         = affix.FindPropertyRelative("name");
                SerializedProperty ItemLevel    = affix.FindPropertyRelative("item_level");
                SerializedProperty MinAmount    = affix.FindPropertyRelative("min_amount");
                SerializedProperty MaxAmount    = affix.FindPropertyRelative("max_amount");
                SerializedProperty Type         = affix.FindPropertyRelative("type");
                SerializedProperty Modifier     = affix.FindPropertyRelative("modifier");
                SerializedProperty ModifierType = affix.FindPropertyRelative("modifier_type");
                SerializedProperty ItemType     = affix.FindPropertyRelative("item_type");

                float oldlabelwidth = EditorGUIUtility.labelWidth;
                float oldfieldwidth = EditorGUIUtility.fieldWidth;

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(affix);
                if (GUILayout.Button("\u2191", GUILayout.Width(50), GUILayout.Height(20)))
                {
                    list.MoveArrayElement(i, i - 1);
                }
                if (GUILayout.Button("\u2193", GUILayout.Width(50), GUILayout.Height(20)))
                {
                    list.MoveArrayElement(i, i + 1);
                }

                bool propertyDeleted = false;
                if (GUILayout.Button("-", GUILayout.Width(50), GUILayout.Height(20)))
                {
                    propertyDeleted = true;
                    list.DeleteArrayElementAtIndex(i);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel += 1;
                if (!propertyDeleted && affix.isExpanded)
                {
                    EditorGUILayout.LabelField("Basic Information", EditorStyles.boldLabel);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Name", GUILayout.Width(100));
                    EditorGUILayout.PropertyField(Name, new GUIContent(""));
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Item Level", GUILayout.Width(100));
                    EditorGUILayout.PropertyField(ItemLevel, new GUIContent(""));
                    EditorGUILayout.LabelField("Item Type", GUILayout.Width(100));
                    EditorGUILayout.PropertyField(ItemType, new GUIContent(""));
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Affix Information", EditorStyles.boldLabel);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PropertyField(Type, new GUIContent(""));
                    EditorGUILayout.PropertyField(Modifier, new GUIContent(""));
                    EditorGUILayout.PropertyField(ModifierType, new GUIContent(""));
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Amounts", EditorStyles.boldLabel);
                    EditorGUIUtility.labelWidth = 60;
                    EditorGUILayout.Space();
                    EditorGUILayout.PropertyField(MinAmount, new GUIContent("Min"));
                    EditorGUILayout.PropertyField(MaxAmount, new GUIContent("Max"));
                    float min = MinAmount.intValue;
                    float max = MaxAmount.intValue;
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();
                    EditorGUILayout.MinMaxSlider(ref min, ref max, 0, 130);
                    EditorGUILayout.EndHorizontal();
                    EditorGUIUtility.labelWidth = oldlabelwidth;
                    MinAmount.intValue          = (int)min;
                    MaxAmount.intValue          = (int)max;
                    if (MinAmount.intValue > MaxAmount.intValue)
                    {
                        MinAmount.intValue = MaxAmount.intValue;
                    }
                }
                EditorGUI.indentLevel -= 1;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            if (GUILayout.Button("+", GUILayout.Width(158)))
            {
                list.InsertArrayElementAtIndex(list.arraySize);
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUI.indentLevel -= 1;


        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Location: Resources/affixes.json", GUILayout.Width(250), GUILayout.Height(20));

        if (GUILayout.Button("Save"))
        {
            SimpleJSON.JSONObject root    = new SimpleJSON.JSONObject();
            SimpleJSON.JSONArray  objects = root["list"].AsArray;
            for (int i = 0; i < list.arraySize; i++)
            {
                SerializedProperty    affix = list.GetArrayElementAtIndex(i);
                SimpleJSON.JSONObject af    = objects[-1].AsObject;
                af["name"]          = affix.FindPropertyRelative("name").stringValue;
                af["item_level"]    = affix.FindPropertyRelative("item_level").intValue;
                af["min_range"]     = affix.FindPropertyRelative("min_amount").intValue;
                af["max_range"]     = affix.FindPropertyRelative("max_amount").intValue;
                af["type"]          = affix.FindPropertyRelative("type").enumNames[affix.FindPropertyRelative("type").enumValueIndex];
                af["modifier"]      = affix.FindPropertyRelative("modifier").enumNames[affix.FindPropertyRelative("modifier").enumValueIndex];
                af["modifier_type"] = affix.FindPropertyRelative("modifier_type").enumNames[affix.FindPropertyRelative("modifier_type").enumValueIndex];
                af["item_type"]     = affix.FindPropertyRelative("item_type").enumNames[affix.FindPropertyRelative("item_type").enumValueIndex];
            }

            File.WriteAllText("Assets/Resources/affixes.json", root.ToString(3));
            Debug.Log("Saved to Assets/Resources/affixes.json!");
        }

        if (GUILayout.Button("Load"))
        {
            SimpleJSON.JSONNode   json    = SimpleJSON.JSON.Parse(File.ReadAllText("Assets/Resources/affixes.json"));
            SimpleJSON.JSONObject root    = (SimpleJSON.JSONObject)json;
            SimpleJSON.JSONArray  objects = root["list"].AsArray;

            list.ClearArray();
            for (int i = 0; i < objects.Count; i++)
            {
                SimpleJSON.JSONObject af = objects[i].AsObject;
                list.InsertArrayElementAtIndex(list.arraySize);
                SerializedProperty affix = list.GetArrayElementAtIndex(list.arraySize - 1);
                affix.FindPropertyRelative("name").stringValue    = af["name"];
                affix.FindPropertyRelative("item_level").intValue = af["item_level"];
                affix.FindPropertyRelative("min_amount").intValue = af["min_range"];
                affix.FindPropertyRelative("max_amount").intValue = af["max_range"];
                for (int j = 0; j < affix.FindPropertyRelative("type").enumNames.Length; j++)
                {
                    if (affix.FindPropertyRelative("type").enumNames[j] == af["type"])
                    {
                        affix.FindPropertyRelative("type").enumValueIndex = j;
                        break;
                    }
                }
                for (int j = 0; j < affix.FindPropertyRelative("modifier").enumNames.Length; j++)
                {
                    if (affix.FindPropertyRelative("modifier").enumNames[j] == af["modifier"])
                    {
                        affix.FindPropertyRelative("modifier").enumValueIndex = j;
                        break;
                    }
                }
                for (int j = 0; j < affix.FindPropertyRelative("modifier_type").enumNames.Length; j++)
                {
                    if (affix.FindPropertyRelative("modifier_type").enumNames[j] == af["modifier_type"])
                    {
                        affix.FindPropertyRelative("modifier_type").enumValueIndex = j;
                        break;
                    }
                }
                for (int j = 0; j < affix.FindPropertyRelative("item_type").enumNames.Length; j++)
                {
                    if (affix.FindPropertyRelative("item_type").enumNames[j] == af["item_type"])
                    {
                        affix.FindPropertyRelative("item_type").enumValueIndex = j;
                        break;
                    }
                }
            }

            Debug.Log("Succesfully loaded affixes.json!");
        }
        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();
    }
Exemplo n.º 22
0
    public void saveVuforiaObjectsToFile()
    {
        //update position of this object's struct in the dictionary:
        updateStructsBasedOnGameObjects();

        JSONArray ja = new JSONArray();

        foreach (KeyValuePair <string, realityEditorObjectStruct> pair in realityEditorObjectDict)
        {
            //Debug.Log("save operating on: " + pair.Key + " " + pair.Value.ip);
            //Debug.Log("content of struct");
            Debug.Log(pair.Value.id + " " + pair.Value.ip + " " + pair.Value.temporaryChecksum + " " + pair.Value.versionNumber + " " + pair.Value.zone + " " + pair.Value.xmlAddress + " " + pair.Value.datAddress);

            //Debug.Log("temporary checksum value: " + pair.Value.temporaryChecksum + " nulloperator: " + (pair.Value.temporaryChecksum ?? "null") + " ==\"\"?" + (pair.Value.temporaryChecksum == ""));

            JSONNode jo = new SimpleJSON.JSONObject();
            jo.Add("id", pair.Value.id ?? "");
            jo.Add("ip", pair.Value.ip ?? "");
            jo.Add("temporaryChecksum", pair.Value.temporaryChecksum ?? "");
            jo.Add("versionNumber", pair.Value.versionNumber ?? "");
            jo.Add("zone", pair.Value.zone ?? "");
            jo.Add("xmlAddress", pair.Value.xmlAddress ?? "");
            jo.Add("dataAddress", pair.Value.datAddress ?? "");
            jo.Add("Tx", pair.Value.position.x);
            jo.Add("Ty", pair.Value.position.y);
            jo.Add("Tz", pair.Value.position.z);
            jo.Add("Qx", pair.Value.rotation.x);
            jo.Add("Qy", pair.Value.rotation.y);
            jo.Add("Qz", pair.Value.rotation.z);
            jo.Add("Qw", pair.Value.rotation.w);

            /*
             * jo.Add("id", pair.Value.id);
             * jo.Add("ip", pair.Value.ip);
             * jo.Add("temporaryChecksum", pair.Value.temporaryChecksum);
             * jo.Add("versionNumber", pair.Value.versionNumber);
             * jo.Add("zone", pair.Value.zone);
             * jo.Add("xmlAddress", pair.Value.xmlAddress);
             * jo.Add("dataAddress", pair.Value.datAddress);
             * jo.Add("Tx", pair.Value.position.x);
             * jo.Add("Ty", pair.Value.position.y);
             * jo.Add("Tz", pair.Value.position.z);
             * jo.Add("Qx", pair.Value.rotation.x);
             * jo.Add("Qy", pair.Value.rotation.y);
             * jo.Add("Qz", pair.Value.rotation.z);
             * jo.Add("Qw", pair.Value.rotation.w);
             */
            //JSONNode cameraCalibrationResult = new JSONObject();
            //cameraCalibrationResult.Add("camera_enumeration", 1);
            //cameraCalibrationResult.Add("serial_number", "cool");


            //jo["id"] = pair.Value.id;

            /*
             * jo["ip"] = pair.Value.ip;
             * jo["temporaryChecksum"] = pair.Value.temporaryChecksum;
             * jo["versionNumber"] = pair.Value.versionNumber;
             * jo["zone"] = pair.Value.zone;
             * jo["xmlAddress"] = pair.Value.xmlAddress;
             * jo["datAddress"] = pair.Value.datAddress;
             *
             *
             *
             *
             *
             *
             * jo["Tx"] = pair.Value.position.x;
             * jo["Ty"] = pair.Value.position.y;
             * jo["Tz"] = pair.Value.position.z;
             * jo["Qx"] = pair.Value.rotation.x;
             * jo["Qy"] = pair.Value.rotation.y;
             * jo["Qz"] = pair.Value.rotation.z;
             * jo["QW"] = pair.Value.rotation.w;
             */
            //Debug.Log("camera calibration result: " + cameraCalibrationResult.ToString());
            //Debug.Log("adding jo: " + jo.ToString());

            ja.Add(jo);
        }
        //Debug.Log("json array: " + ja.ToString());
        System.IO.File.WriteAllText("vuforiaSaved.txt", ja.ToString());
    }
Exemplo n.º 23
0
    void sendToVuforia()
    {
        //Debug.Log("capturing image for vuforia");
        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

        sw.Reset();
        sw.Start();
        Texture2D colorTexture = (Texture2D)imageCube.GetComponent <Renderer>().material.mainTexture;

        sw.Stop();
        //Debug.Log("time to acquire texture pointer: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));

        sw.Reset();
        sw.Start();
        RenderTexture colorRT = new RenderTexture(colorTexture.width, colorTexture.height, 24, RenderTextureFormat.ARGB32);

        sw.Stop();
        //Debug.Log("time to declare render texture: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));

        sw.Reset();
        sw.Start();
        Graphics.Blit(colorTexture, colorRT); //move it from colortexture gpu to rendertexture
        sw.Stop();
        //Debug.Log("time to blit texture to render texture: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));

        sw.Reset();
        sw.Start();
        RenderTexture.active = colorRT;
        sw.Stop();
        //Debug.Log("time to make render texture active: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));


        //debugFreezeRendertexture = colorRT;
        sw.Reset();
        sw.Start();
        Texture2D colorFreeze = new Texture2D(colorTexture.width, colorTexture.height, TextureFormat.ARGB32, false);

        sw.Stop();
        //Debug.Log("time to declare a freeze texture: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));

        sw.Reset();
        sw.Start();
        colorFreeze.ReadPixels(new UnityEngine.Rect(0, 0, colorTexture.width, colorTexture.height), 0, 0);
        sw.Stop();
        //Debug.Log("time to read pixels from rendertexture: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));

        byte[] c         = colorFreeze.GetRawTextureData();
        string outstring = "";

        for (int i = 0; i < 50; i++)
        {
            outstring += c[i] + "-";
        }
        //Debug.Log("first 50: " + outstring);

        sw.Reset();
        sw.Start();
        colorFreeze.Apply();
        sw.Stop();
        //Debug.Log("time to do apply: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));



        sw.Reset();
        sw.Start();
        byte[] b = colorFreeze.GetRawTextureData();
        sw.Stop();
        //Debug.Log("time to return raw texture data: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));
        //Array.Reverse(b);

        string outstring2 = "";

        for (int i = 0; i < 50; i++)
        {
            outstring2 += b[i] + "-";
        }
        //Debug.Log("first 50: " + outstring2);

        /*
         * //flip up down:
         * byte[] b_flip = new byte[b.Length];
         * for (int i = 0; i < colorFreeze.height; i++)
         * {
         *  for (int j = 0; j < 4 * colorFreeze.width; j++)
         *  {
         *      b_flip[i * (colorFreeze.width * 4) + j] = b[((colorFreeze.height - 1) - i) * (colorFreeze.width * 4) + j];
         *  }
         * }
         * //b = b_flip;
         */

        sw.Reset();
        sw.Start();
        string image_data = System.Convert.ToBase64String(b);

        sw.Stop();
        //Debug.Log("time to convert to base 64: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));


        sw.Reset();
        sw.Start();
        JSONNode vuforiaRequest = new SimpleJSON.JSONObject();

        vuforiaRequest.Add("imageData", image_data);
        vuforiaRequest.Add("imageWidth", colorFreeze.width);
        vuforiaRequest.Add("imageHeight", colorFreeze.height);

        vuforiaRequest.Add("A_offset", 0);
        vuforiaRequest.Add("R_offset", 1);
        vuforiaRequest.Add("G_offset", 2);
        vuforiaRequest.Add("B_offset", 3);
        string data = vuforiaRequest.ToString();

        sw.Stop();
        //Debug.Log("time to make vuforia string: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));

        sw.Reset();
        sw.Start();
        GameObject.Find("pusher").GetComponent <Pusher>().sendToVuforia(data);
        sw.Stop();
        //Debug.Log("time to send vuforia string: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));

        sw.Reset();
        sw.Start();
        DestroyImmediate(colorRT);
        DestroyImmediate(colorFreeze);
        sw.Stop();
        //Debug.Log("time to destroy resources: " + ((float)sw.ElapsedTicks / (float)System.TimeSpan.TicksPerMillisecond).ToString("F6"));
    }
Exemplo n.º 24
0
 public override void Load(SimpleJSON.JSONObject json_data)
 {
     friendState = json_data["friendState"].AsInt;
 }
Exemplo n.º 25
0
    void sendVuforiaUpdate()
    {
        //var visibleObjectsString = "{\"amazonBox0zbc6yetuoyj\":[-0.9964230765028328,0.009800613580158324,-0.08393736781840644,0,0.022929297584320937,0.987345281122669,-0.15691860457929643,0,-0.08133670600902992,0.15828222984430484,0.9840378965122027,0,329.2388939106902,77.77425852082308,-1489.0291313193022,1],\"kepwareBox4Qimhnuea3n6\":[-0.9913746548884379,0.034050970326370084,-0.12655601222953172,0,0.051082427979348755,0.9896809533465255,-0.13387410555924745,0,-0.12069159903807483,0.1391844414830788,0.9828837698713899,0,212.63741144996703,206.15960431449824,-1826.5693898311488,1],\"_WORLD_OBJECT_local\":[-0.9742120258704184,-0.00437900631612313,-0.22559212287700664,0,-0.035464931453757634,-0.9844127588621392,0.17226278091636868,0,-0.22282991544549868,0.17582138398908906,0.9588711290537871,0,161.99950094104497,-166.5114134489016,-519.0149842693205,1],\"_WORLD_OBJECT_PF5x8fv3zcgm\":[-0.9742120258704184,-0.00437900631612313,-0.22559212287700664,0,-0.035464931453757634,-0.9844127588621392,0.17226278091636868,0,-0.22282991544549868,0.17582138398908906,0.9588711290537871,0,161.99950094104497,-166.5114134489016,-519.0149842693205,1]}";
        //var visibleObjects = JSON.parse(visibleObjectsString);

        string visibleString = "\"{";

        SimpleJSON.JSONObject ja = new SimpleJSON.JSONObject();

        for (int i = 0; i < realityEditorObjectVisualizerList.Count; i++)
        {
            visibleString += "\\\"" + realityEditorObjectVisualizerList[i].name + "\\\":[";



            Matrix4x4 worldToOrigin = origin.transform.worldToLocalMatrix;
            Matrix4x4 worldToObject = realityEditorObjectVisualizerList[i].transform.worldToLocalMatrix;



            //M_world_object = M_origin_object * M_world_origin
            //M_origin_object = M_world_object * (M_world_origin)^-1

            Matrix4x4 originToObject = worldToObject * worldToOrigin.inverse;
            Matrix4x4 objectToOrigin = originToObject.inverse;

            Matrix4x4 m = objectToOrigin;
            //Matrix4x4 m = originToObject;

            //Debug.Log("World to Origin: " + worldToOrigin);
            //Debug.Log("world to object: " + worldToObject);
            //Debug.Log("origin to object: " + originToObject);
            //Debug.Log("object to origin: " + objectToOrigin);

            /*
             * GameObject dummy = new GameObject();
             * dummy.transform.position = realityEditorObjectVisualizerList[i].transform.position;
             * dummy.transform.rotation = realityEditorObjectVisualizerList[i].transform.rotation;
             * dummy.transform.parent = virtualCam.transform;
             *
             * Matrix4x4 m = Matrix4x4.TRS(dummy.transform.localPosition, dummy.transform.localRotation, dummy.transform.localScale);
             * m = m.inverse;
             *
             *
             * GameObject.Destroy(dummy);
             */
            /*
             * //fix righthand?
             * m[0, 2] = -m[0, 2];
             * m[1, 2] = -m[1, 2];
             * m[2, 2] = -m[2, 2];
             */


            //fix righthand?
            //m[0, 0] = -m[0, 0];
            //m[1, 0] = -m[1, 0];
            //m[2, 0] = -m[2, 0];


            /*
             * //fix rotation:
             * m[0, 0] = -m[0, 0];
             * m[0, 1] = -m[0, 1];
             * m[0, 2] = -m[0, 2];
             */


            //flip translation
            m[0, 3] = -m[0, 3];
            m[1, 3] = -m[1, 3];
            m[2, 3] = -m[2, 3];



            //fix rotation:
            m[0, 2] = -m[0, 2];
            m[1, 2] = -m[1, 2];
            m[2, 2] = -m[2, 2];



            /*
             * //flip all the x's
             * m[0, 0] = -m[0, 0];
             * m[0, 1] = -m[0, 1];
             * m[0, 2] = -m[0, 2];
             * //m[0, 3] = -m[0, 3];
             */



            /*
             * for (int mm = 0; mm<3; mm++)
             * {
             *  for(int nn = 0; nn<3; nn++)
             *  {
             *      m[mm, nn] = 0;
             *  }
             * }
             * m[0, 0] = -1;
             * m[1, 1] = 1;
             * m[2, 2] = 1;
             */

            //fix vuforia mm to m
            m[0, 3] = 1000.0f * m[0, 3];
            m[1, 3] = 1000.0f * m[1, 3];
            m[2, 3] = 1000.0f * m[2, 3];

            //Debug.Log(realityEditorObjectVisualizerList[i].name);
            //Debug.Log("full matrix: " + m);
            JSONArray ma = new JSONArray();
            for (int jj = 0; jj < 16; jj++)
            {
                //int sampleIdx = jj; //read through rows first
                int sampleIdx = (jj % 4) * 4 + (int)(jj / 4);
                int row       = jj % 4;
                int col       = (int)(jj / 4);

                //Debug.Log("idx: " + jj + " row: " + row + " col: " + col + " value: " + dummy.transform.localToWorldMatrix[row, col]);

                //visibleString += ((float)dummy.transform.localToWorldMatrix[sampleIdx]).ToString("0.00000000");
                visibleString += (m[row, col]).ToString("0.00000000"); //this should be backwards, but works?
                if (jj < 15)
                {
                    visibleString += ",";
                }
                ma.Add((float)m[sampleIdx]);
            }
            ja[realityEditorObjectVisualizerList[i].name] = ma;
            visibleString += "]";
            if (i < realityEditorObjectVisualizerList.Count - 1)
            {
                visibleString += ",";
            }



            //dump matrix to array:
            //dummy.transform.localToWorldMatrix;
        }
        visibleString += "}\"";

        //Debug.Log("visible object string: " + visibleObjectsString);
        //Debug.Log("this object string: " + ja.ToString());
        //Debug.Log("vis string: " + visibleString);
        GameObject.Find("pusher").GetComponent <Pusher>().Emit_VuforiaModuleUpdate_system_server(visibleString);
    }
Exemplo n.º 26
0
 public override void Load(SimpleJSON.JSONObject json_data)
 {
     Debug.Log("Harry load activate-*-*-*-*-*-*-*-*-*");
     friendState = json_data["friendState"].AsInt;
     day         = json_data["day"].AsInt;
 }
Exemplo n.º 27
0
 public override void Load(SimpleJSON.JSONObject json_data)
 {
 }
Exemplo n.º 28
0
 public override void Load(SimpleJSON.JSONObject json_data)
 {
     friendState     = json_data["friendState"].AsInt;
     trashInLoveFund = json_data["trashInLoveFund"].AsInt;
 }
Exemplo n.º 29
0
    public override SimpleJSON.JSONObject Save()
    {
        var json_data = new SimpleJSON.JSONObject();

        return(json_data);
    }