public Boomlagoon.JSON.JSONValue ExportDataAsPresetSection(bool saveSampleTextData = true)
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            if (m_loop_cycles.Count > 0)
            {
                Boomlagoon.JSON.JSONArray loops_data = new Boomlagoon.JSON.JSONArray();

                foreach (ActionLoopCycle action_loop in m_loop_cycles)
                {
                    loops_data.Add(action_loop.ExportData());
                }

                json_data["LOOPS_DATA"] = loops_data;
            }

            Boomlagoon.JSON.JSONArray actions_data = new Boomlagoon.JSON.JSONArray();
            foreach (LetterAction action in m_letter_actions)
            {
                actions_data.Add(action.ExportData());
            }
            json_data["ACTIONS_DATA"] = actions_data;

            if (saveSampleTextData)
            {
                json_data["SAMPLE_NUM_LETTERS_ANIMATED"] = m_letters_to_animate.Count;
            }

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
        public void ImportPresetSectionData(Boomlagoon.JSON.JSONObject json_data, LetterSetup[] letters, string assetNameSuffix = "")
        {
            m_letter_actions = new List <LetterAction>();
            m_loop_cycles    = new List <ActionLoopCycle>();

            ImportPresetSectionData(json_data, letters, 0, 0, assetNameSuffix);
        }
        public void ImportData(Boomlagoon.JSON.JSONObject json_data, string assetNameSuffix = "")
        {
            m_letters_to_animate            = json_data["m_letters_to_animate"].Array.JSONtoListInt();
            m_letters_to_animate_custom_idx = (int)json_data["m_letters_to_animate_custom_idx"].Number;
            m_letters_to_animate_option     = (LETTERS_TO_ANIMATE)(int)json_data["m_letters_to_animate_option"].Number;

            m_letter_actions = new List <LetterAction>();
            LetterAction letter_action;

            foreach (Boomlagoon.JSON.JSONValue action_data in json_data["ACTIONS_DATA"].Array)
            {
                letter_action = new LetterAction();
                letter_action.ImportData(action_data.Obj, assetNameSuffix);
                m_letter_actions.Add(letter_action);
            }

            m_loop_cycles = new List <ActionLoopCycle>();
            if (json_data.ContainsKey("LOOPS_DATA"))
            {
                ActionLoopCycle loop_cycle;

                foreach (Boomlagoon.JSON.JSONValue loop_data in json_data["LOOPS_DATA"].Array)
                {
                    loop_cycle = new ActionLoopCycle();
                    loop_cycle.ImportData(loop_data.Obj);

                    // Check for invalid loops
                    if (loop_cycle.m_start_action_idx < m_letter_actions.Count && loop_cycle.m_end_action_idx < m_letter_actions.Count)
                    {
                        m_loop_cycles.Add(loop_cycle);
                    }
                }
            }
        }
예제 #4
0
 public static Vector2 JSONtoVector2(this Boomlagoon.JSON.JSONObject json_data)
 {
     return(new Vector2()
     {
         x = (float)json_data["x"].Number, y = (float)json_data["y"].Number
     });
 }
예제 #5
0
 public void ImportData(Boomlagoon.JSON.JSONObject json_data)
 {
     m_override_default = json_data["m_override_default"].Boolean;
     m_x_ease           = (EasingEquation)(int)json_data["m_x_ease"].Number;
     m_y_ease           = (EasingEquation)(int)json_data["m_y_ease"].Number;
     m_z_ease           = (EasingEquation)(int)json_data["m_z_ease"].Number;
 }
        public Boomlagoon.JSON.JSONValue ExportData()
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            json_data["m_letters_to_animate"]            = m_letters_to_animate.ExportData();
            json_data["m_letters_to_animate_custom_idx"] = m_letters_to_animate_custom_idx;
            json_data["m_letters_to_animate_option"]     = (int)m_letters_to_animate_option;

            if (m_loop_cycles.Count > 0)
            {
                Boomlagoon.JSON.JSONArray loops_data = new Boomlagoon.JSON.JSONArray();

                foreach (ActionLoopCycle action_loop in m_loop_cycles)
                {
                    loops_data.Add(action_loop.ExportData());
                }

                json_data["LOOPS_DATA"] = loops_data;
            }

            Boomlagoon.JSON.JSONArray actions_data = new Boomlagoon.JSON.JSONArray();
            foreach (LetterAction action in m_letter_actions)
            {
                actions_data.Add(action.ExportData());
            }
            json_data["ACTIONS_DATA"] = actions_data;

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
예제 #7
0
        public static Boomlagoon.JSON.JSONValue Vector2ToJSON(this Vector2 vec)
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
            json_data["x"] = vec.x;
            json_data["y"] = vec.y;

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
예제 #8
0
 public static Boomlagoon.JSON.JSONValue ExportData(this Vector3 vec)
 {
     Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
     json_data["x"] = vec.x;
     json_data["y"] = vec.y;
     json_data["z"] = vec.z;
     return(new Boomlagoon.JSON.JSONValue(json_data));
 }
예제 #9
0
 public static Boomlagoon.JSON.JSONValue ExportData(this UnityEngine.Keyframe frame)
 {
     Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
     json_data["inTangent"]   = frame.inTangent;
     json_data["outTangent"]  = frame.outTangent;
     json_data["tangentMode"] = frame.tangentMode;
     json_data["time"]        = frame.time;
     json_data["value"]       = frame.value;
     return(new Boomlagoon.JSON.JSONValue(json_data));
 }
예제 #10
0
 public static Color JSONtoColor(this Boomlagoon.JSON.JSONObject json_data)
 {
     return(new Color()
     {
         r = (float)json_data["r"].Number,
         g = (float)json_data["g"].Number,
         b = (float)json_data["b"].Number,
         a = (float)json_data["a"].Number
     });
 }
예제 #11
0
 public static UnityEngine.Keyframe JSONtoKeyframe(this Boomlagoon.JSON.JSONObject json_data)
 {
     return(new UnityEngine.Keyframe()
     {
         inTangent = (float)json_data["inTangent"].Number,
         outTangent = (float)json_data["outTangent"].Number,
         tangentMode = (int)json_data["tangentMode"].Number,
         time = (float)json_data["time"].Number,
         value = (float)json_data["value"].Number
     });
 }
예제 #12
0
        public static Boomlagoon.JSON.JSONValue ExportData(this VertexColour vert_color)
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            json_data["bottom_left"]  = vert_color.bottom_left.ExportData();
            json_data["bottom_right"] = vert_color.bottom_right.ExportData();
            json_data["top_left"]     = vert_color.top_left.ExportData();
            json_data["top_right"]    = vert_color.top_right.ExportData();

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
예제 #13
0
        public static Boomlagoon.JSON.JSONValue ExportData(this Color color)
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            json_data["r"] = color.r;
            json_data["g"] = color.g;
            json_data["b"] = color.b;
            json_data["a"] = color.a;

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
예제 #14
0
        public Boomlagoon.JSON.JSONValue ExportData()
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            json_data["m_override_default"] = m_override_default;
            json_data["m_x_ease"]           = (int)m_x_ease;
            json_data["m_y_ease"]           = (int)m_y_ease;
            json_data["m_z_ease"]           = (int)m_z_ease;

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
예제 #15
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			json_data["m_finish_at_end"] = m_finish_at_end;
			json_data["m_delay_first_only"] = m_delay_first_only;
			json_data["m_end_action_idx"] = m_end_action_idx;
			json_data["m_loop_type"] = (int) m_loop_type;
			json_data["m_number_of_loops"] = m_number_of_loops;
			json_data["m_start_action_idx"] = m_start_action_idx;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
        public Boomlagoon.JSON.JSONValue ExportData()
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            json_data["m_finish_at_end"]    = m_finish_at_end;
            json_data["m_delay_first_only"] = m_delay_first_only;
            json_data["m_end_action_idx"]   = m_end_action_idx;
            json_data["m_loop_type"]        = (int)m_loop_type;
            json_data["m_number_of_loops"]  = m_number_of_loops;
            json_data["m_start_action_idx"] = m_start_action_idx;

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
예제 #17
0
        public static VertexColour JSONtoVertexColour(this Boomlagoon.JSON.JSONObject json_data)
        {
            if (json_data.ContainsKey("r"))
            {
                // Legacy export data
                return(new VertexColour(json_data.JSONtoColor()));
            }

            return(new VertexColour()
            {
                bottom_left = json_data["bottom_left"].Obj.JSONtoColor(),
                bottom_right = json_data["bottom_right"].Obj.JSONtoColor(),
                top_left = json_data["top_left"].Obj.JSONtoColor(),
                top_right = json_data["top_right"].Obj.JSONtoColor()
            });
        }
 public void ImportData(Boomlagoon.JSON.JSONObject json_data)
 {
     if (json_data.ContainsKey("m_finish_at_end"))
     {
         m_finish_at_end = json_data["m_finish_at_end"].Boolean;
     }
     else
     {
         m_finish_at_end = false;
     }
     m_delay_first_only = json_data["m_delay_first_only"].Boolean;
     m_end_action_idx   = (int)json_data["m_end_action_idx"].Number;
     m_loop_type        = (LOOP_TYPE)(int)json_data["m_loop_type"].Number;
     m_number_of_loops  = (int)json_data["m_number_of_loops"].Number;
     m_start_action_idx = (int)json_data["m_start_action_idx"].Number;
 }
예제 #19
0
        public void ImportData(Boomlagoon.JSON.JSONObject json_data)
        {
            m_anchor_points = new List <BezierCurvePoint>();

            BezierCurvePoint curve_point;

            Boomlagoon.JSON.JSONObject anchor_json;

            foreach (Boomlagoon.JSON.JSONValue anchor_data in json_data["ANCHORS_DATA"].Array)
            {
                anchor_json = anchor_data.Obj;
                curve_point = new BezierCurvePoint();
                curve_point.m_anchor_point = anchor_json["m_anchor_point"].Obj.JSONtoVector3();
                curve_point.m_handle_point = anchor_json["m_handle_point"].Obj.JSONtoVector3();
                m_anchor_points.Add(curve_point);
            }
        }
예제 #20
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			ExportBaseData(ref json_data);
			
			json_data["m_effect_type"] = (int) m_effect_type;
			if(m_effect_type == PARTICLE_EFFECT_TYPE.LEGACY)
				json_data["m_legacy_particle_effect"] = m_legacy_particle_effect.ToPath();
			else
				json_data["m_shuriken_particle_effect"] = m_shuriken_particle_effect.ToPath();
			json_data["m_duration"] = m_duration.ExportData();
			json_data["m_follow_mesh"] = m_follow_mesh;
			json_data["m_position_offset"] = m_position_offset.ExportData();
			json_data["m_rotation_offset"] = m_rotation_offset.ExportData();
			json_data["m_rotate_relative_to_letter"] = m_rotate_relative_to_letter;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
예제 #21
0
        public Boomlagoon.JSON.JSONValue ExportData()
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            Boomlagoon.JSON.JSONArray  anchors_data = new Boomlagoon.JSON.JSONArray();
            Boomlagoon.JSON.JSONObject anchor_point_data;

            foreach (BezierCurvePoint anchor_point in m_anchor_points)
            {
                anchor_point_data = new Boomlagoon.JSON.JSONObject();
                anchor_point_data["m_anchor_point"] = anchor_point.m_anchor_point.ExportData();
                anchor_point_data["m_handle_point"] = anchor_point.m_handle_point.ExportData();

                anchors_data.Add(anchor_point_data);
            }

            json_data["ANCHORS_DATA"] = anchors_data;

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
예제 #22
0
    public void checkForUnlockJetpack()
    {
        dato = BGWebSocket.instance.Datito;
        if (dato != 0)
        {
            isJetpackUnlocked = true;
            dato = 0;
            BGWebSocket.instance.Datito = 0;
            var json = new Boomlagoon.JSON.JSONObject();
            json.Add("room", "FPS_Simulator");
            json.Add("name", "FPS_Simulator");
            json.Add("message", 1);
            string data = json.ToString();
            BGWebSocket.instance.socket.Emit("Dimessage", new JSONObject(data));
        }

        if (Input.GetKeyDown("j") && !boolActivateMechanic)
        {
            boolActivateMechanic = true;
            unlockJetpack();

            print("J key was pressed");
        }
    }
예제 #23
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			Boomlagoon.JSON.JSONArray anchors_data = new Boomlagoon.JSON.JSONArray();
			Boomlagoon.JSON.JSONObject anchor_point_data;
			
			foreach(BezierCurvePoint anchor_point in m_anchor_points)
			{
				anchor_point_data = new Boomlagoon.JSON.JSONObject();
				anchor_point_data["m_anchor_point"] = anchor_point.m_anchor_point.ExportData();
				anchor_point_data["m_handle_point"] = anchor_point.m_handle_point.ExportData();
				
				anchors_data.Add(anchor_point_data);
			}
			
			json_data["ANCHORS_DATA"] = anchors_data;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
        public void ImportPresetSectionData(Boomlagoon.JSON.JSONObject json_data, LetterSetup[] letters, int action_insert_index, int loop_insert_index, ref int num_actions_added, ref int num_loops_added, string assetNameSuffix = "")
        {
            if (m_letter_actions == null)
            {
                m_letter_actions = new List <LetterAction>();
            }

            float timing_scale = -1;

            if (m_letters_to_animate == null || m_letters_to_animate.Count == 0)
            {
                CalculateLettersToAnimate(letters);
            }

            if (json_data.ContainsKey("SAMPLE_NUM_LETTERS_ANIMATED") && m_letters_to_animate != null && m_letters_to_animate.Count > 0)
            {
                timing_scale = m_letters_to_animate.Count / ((float)json_data["SAMPLE_NUM_LETTERS_ANIMATED"].Number);
            }


            LetterAction letter_action;

            num_actions_added = 0;
            foreach (Boomlagoon.JSON.JSONValue action_data in json_data["ACTIONS_DATA"].Array)
            {
                letter_action = new LetterAction();
                letter_action.ImportData(action_data.Obj, assetNameSuffix, timing_scale: timing_scale);

                if (num_actions_added == 0 && action_insert_index > 0)
                {
                    // Inserting new actions into the middle of the animation. Set first action to continue from last
                    letter_action.m_offset_from_last = true;
                }

                InsertAction(action_insert_index + num_actions_added, letter_action);

                num_actions_added++;
            }


            if (m_loop_cycles == null)
            {
                m_loop_cycles = new List <ActionLoopCycle>();
            }


            num_loops_added = 0;

            if (json_data.ContainsKey("LOOPS_DATA"))
            {
                ActionLoopCycle loop_cycle;

                foreach (Boomlagoon.JSON.JSONValue loop_data in json_data["LOOPS_DATA"].Array)
                {
                    loop_cycle = new ActionLoopCycle();
                    loop_cycle.ImportData(loop_data.Obj);
                    loop_cycle.m_start_action_idx += action_insert_index;
                    loop_cycle.m_end_action_idx   += action_insert_index;

                    // Check for invalid loops
                    if (loop_cycle.m_start_action_idx < m_letter_actions.Count && loop_cycle.m_end_action_idx < m_letter_actions.Count)
                    {
                        m_loop_cycles.Insert(loop_insert_index + num_loops_added, loop_cycle);

                        num_loops_added++;
                    }
                }
            }
        }
        public void ImportPresetSectionData(Boomlagoon.JSON.JSONObject json_data, LetterSetup[] letters, int action_insert_index, int loop_insert_index, string assetNameSuffix = "")
        {
            int num_actions = 0, num_loops = 0;

            ImportPresetSectionData(json_data, letters, action_insert_index, loop_insert_index, ref num_actions, ref num_loops, assetNameSuffix);
        }
예제 #26
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			ExportBaseData(ref json_data);
			
			json_data["m_audio_clip"] = m_audio_clip.ToPath();
			json_data["m_offset_time"] = m_offset_time.ExportData();
			json_data["m_volume"] = m_volume.ExportData();
			json_data["m_pitch"] = m_pitch.ExportData();
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
예제 #27
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			json_data["m_action_type"] = (int) m_action_type;
			json_data["m_ease_type"] = (int) m_ease_type;
			json_data["m_force_same_start_time"] = m_force_same_start_time;
			json_data["m_letter_anchor_start"] = m_letter_anchor_start;
			json_data["m_letter_anchor_end"] = m_letter_anchor_end;
			json_data["m_letter_anchor_2_way"] = m_letter_anchor_2_way;
			json_data["m_offset_from_last"] = m_offset_from_last;
			json_data["m_position_axis_ease_data"] = m_position_axis_ease_data.ExportData();
			json_data["m_rotation_axis_ease_data"] = m_rotation_axis_ease_data.ExportData();
			json_data["m_scale_axis_ease_data"] = m_scale_axis_ease_data.ExportData();
			
			json_data ["m_colour_transition_active"] = m_colour_transition_active;
			json_data["m_start_colour"] = m_start_colour.ExportData();
			json_data ["m_position_transition_active"] = m_position_transition_active;
			json_data["m_start_pos"] = m_start_pos.ExportData();
			json_data ["m_local_rotation_transition_active"] = m_local_rotation_transition_active;
			json_data["m_start_euler_rotation"] = m_start_euler_rotation.ExportData();
			json_data ["m_local_scale_transition_active"] = m_local_scale_transition_active;
			json_data["m_start_scale"] = m_start_scale.ExportData();
			json_data ["m_global_rotation_transition_active"] = m_global_rotation_transition_active;
			json_data["m_global_start_euler_rotation"] = m_global_start_euler_rotation.ExportData();
			json_data ["m_global_scale_transition_active"] = m_global_scale_transition_active;
			json_data["m_global_start_scale"] = m_global_start_scale.ExportData();
			
			json_data["m_end_colour"] = m_end_colour.ExportData();
			json_data["m_end_pos"] = m_end_pos.ExportData();
			json_data["m_end_euler_rotation"] = m_end_euler_rotation.ExportData();
			json_data["m_end_scale"] = m_end_scale.ExportData();
			json_data["m_global_end_euler_rotation"] = m_global_end_euler_rotation.ExportData();
			json_data["m_global_end_scale"] = m_global_end_scale.ExportData();
			
			json_data["m_delay_progression"] = m_delay_progression.ExportData();
			json_data["m_duration_progression"] = m_duration_progression.ExportData();
			
			
			Boomlagoon.JSON.JSONArray audio_effects_data = new Boomlagoon.JSON.JSONArray();
			foreach(AudioEffectSetup effect_setup in m_audio_effects)
			{
				if(effect_setup.m_audio_clip == null)
					continue;
				
				audio_effects_data.Add(effect_setup.ExportData());
			}
			json_data["AUDIO_EFFECTS_DATA"] = audio_effects_data;
			
			Boomlagoon.JSON.JSONArray particle_effects_data = new Boomlagoon.JSON.JSONArray();
			foreach(ParticleEffectSetup effect_setup in m_particle_effects)
			{
				if(effect_setup.m_legacy_particle_effect == null && effect_setup.m_shuriken_particle_effect == null)
					continue;
				
				particle_effects_data.Add(effect_setup.ExportData());
			}
			json_data["PARTICLE_EFFECTS_DATA"] = particle_effects_data;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
		public override Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			ExportBaseData(ref json_data);
			
			json_data["m_from"] = m_from.ExportData();
			json_data["m_to"] = m_to.ExportData();
			json_data["m_to_to"] = m_to_to.ExportData();
			json_data["m_use_colour_gradients"] = m_use_colour_gradients;
			json_data ["m_override_alpha"] = m_override_alpha;

			return new Boomlagoon.JSON.JSONValue(json_data);
		}
		public override Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			ExportBaseData(ref json_data);
			
			json_data["m_from"] = m_from;
			json_data["m_to"] = m_to;
			json_data["m_to_to"] = m_to_to;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
		public override Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			ExportBaseData(ref json_data);
			
			json_data["m_from"] = m_from.ExportData();
			json_data["m_to"] = m_to.ExportData();
			json_data["m_to_to"] = m_to_to.ExportData();
			json_data["m_ease_curve_per_axis"] = m_ease_curve_per_axis;
			
			if(Progression == (int) ValueProgression.EasedCustom && m_ease_curve_per_axis)
			{
				json_data["m_custom_ease_curve_y"] = m_custom_ease_curve_y.ExportData();
				json_data["m_custom_ease_curve_z"] = m_custom_ease_curve_z.ExportData();
			}
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
예제 #31
0
        /// <summary>
        /// Attempt to parse a string into a JSONObject.
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns>A new JSONObject or null if parsing fails.</returns>
        public static JSONObject Parse(string jsonString)
        {
            if (string.IsNullOrEmpty(jsonString))
            {
                return(null);
            }

            JSONValue currentValue = null;

            var keyList = new List <string>();

            var state = JSONParsingState.Object;

            for (var startPosition = 0; startPosition < jsonString.Length; ++startPosition)
            {
                startPosition = SkipWhitespace(jsonString, startPosition);

                switch (state)
                {
                case JSONParsingState.Object:
                    if (jsonString[startPosition] != '{')
                    {
                        return(Fail('{', startPosition));
                    }

                    JSONValue newObj = new JSONObject();
                    if (currentValue != null)
                    {
                        newObj.Parent = currentValue;
                    }
                    currentValue = newObj;

                    state = JSONParsingState.Key;
                    break;

                case JSONParsingState.EndObject:
                    if (jsonString[startPosition] != '}')
                    {
                        return(Fail('}', startPosition));
                    }

                    if (currentValue.Parent == null)
                    {
                        return(currentValue.Obj);
                    }

                    switch (currentValue.Parent.Type)
                    {
                    case JSONValueType.Object:
                        currentValue.Parent.Obj.values[keyList.Pop()] = new JSONValue(currentValue.Obj);
                        break;

                    case JSONValueType.Array:
                        currentValue.Parent.Array.Add(new JSONValue(currentValue.Obj));
                        break;

                    default:
                        return(Fail("valid object", startPosition));
                    }
                    currentValue = currentValue.Parent;

                    state = JSONParsingState.ValueSeparator;
                    break;

                case JSONParsingState.Key:
                    if (jsonString[startPosition] == '}')
                    {
                        --startPosition;
                        state = JSONParsingState.EndObject;
                        break;
                    }

                    var key = ParseString(jsonString, ref startPosition);
                    if (key == null)
                    {
                        return(Fail("key string", startPosition));
                    }
                    keyList.Add(key);
                    state = JSONParsingState.KeyValueSeparator;
                    break;

                case JSONParsingState.KeyValueSeparator:
                    if (jsonString[startPosition] != ':')
                    {
                        return(Fail(':', startPosition));
                    }
                    state = JSONParsingState.Value;
                    break;

                case JSONParsingState.ValueSeparator:
                    switch (jsonString[startPosition])
                    {
                    case ',':
                        state = currentValue.Type == JSONValueType.Object ? JSONParsingState.Key : JSONParsingState.Value;
                        break;

                    case '}':
                        state = JSONParsingState.EndObject;
                        --startPosition;
                        break;

                    case ']':
                        state = JSONParsingState.EndArray;
                        --startPosition;
                        break;

                    default:
                        return(Fail(", } ]", startPosition));
                    }
                    break;

                case JSONParsingState.Value: {
                    var c = jsonString[startPosition];
                    if (c == '"')
                    {
                        state = JSONParsingState.String;
                    }
                    else if (char.IsDigit(c) || c == '-')
                    {
                        state = JSONParsingState.Number;
                    }
                    else
                    {
                        switch (c)
                        {
                        case '{':
                            state = JSONParsingState.Object;
                            break;

                        case '[':
                            state = JSONParsingState.Array;
                            break;

                        case ']':
                            if (currentValue.Type == JSONValueType.Array)
                            {
                                state = JSONParsingState.EndArray;
                            }
                            else
                            {
                                return(Fail("valid array", startPosition));
                            }
                            break;

                        case 'f':
                        case 't':
                            state = JSONParsingState.Boolean;
                            break;


                        case 'n':
                            state = JSONParsingState.Null;
                            break;

                        default:
                            return(Fail("beginning of value", startPosition));
                        }
                    }

                    --startPosition;                             //To re-evaluate this char in the newly selected state
                    break;
                }

                case JSONParsingState.String:
                    var str = ParseString(jsonString, ref startPosition);
                    if (str == null)
                    {
                        return(Fail("string value", startPosition));
                    }

                    switch (currentValue.Type)
                    {
                    case JSONValueType.Object:
                        currentValue.Obj.values[keyList.Pop()] = new JSONValue(str);
                        break;

                    case JSONValueType.Array:
                        currentValue.Array.Add(str);
                        break;

                    default:
                        Debug.LogError("Fatal error, current JSON value not valid");
                        return(null);
                    }

                    state = JSONParsingState.ValueSeparator;
                    break;

                case JSONParsingState.Number:
                    var number = ParseNumber(jsonString, ref startPosition);
                    if (double.IsNaN(number))
                    {
                        return(Fail("valid number", startPosition));
                    }

                    switch (currentValue.Type)
                    {
                    case JSONValueType.Object:
                        currentValue.Obj.values[keyList.Pop()] = new JSONValue(number);
                        break;

                    case JSONValueType.Array:
                        currentValue.Array.Add(number);
                        break;

                    default:
                        Debug.LogError("Fatal error, current JSON value not valid");
                        return(null);
                    }

                    state = JSONParsingState.ValueSeparator;

                    break;

                case JSONParsingState.Boolean:
                    if (jsonString[startPosition] == 't')
                    {
                        if (jsonString.Length < startPosition + 4 ||
                            jsonString[startPosition + 1] != 'r' ||
                            jsonString[startPosition + 2] != 'u' ||
                            jsonString[startPosition + 3] != 'e')
                        {
                            return(Fail("true", startPosition));
                        }

                        switch (currentValue.Type)
                        {
                        case JSONValueType.Object:
                            currentValue.Obj.values[keyList.Pop()] = new JSONValue(true);
                            break;

                        case JSONValueType.Array:
                            currentValue.Array.Add(new JSONValue(true));
                            break;

                        default:
                            Debug.LogError("Fatal error, current JSON value not valid");
                            return(null);
                        }

                        startPosition += 3;
                    }
                    else
                    {
                        if (jsonString.Length < startPosition + 5 ||
                            jsonString[startPosition + 1] != 'a' ||
                            jsonString[startPosition + 2] != 'l' ||
                            jsonString[startPosition + 3] != 's' ||
                            jsonString[startPosition + 4] != 'e')
                        {
                            return(Fail("false", startPosition));
                        }

                        switch (currentValue.Type)
                        {
                        case JSONValueType.Object:
                            currentValue.Obj.values[keyList.Pop()] = new JSONValue(false);
                            break;

                        case JSONValueType.Array:
                            currentValue.Array.Add(new JSONValue(false));
                            break;

                        default:
                            Debug.LogError("Fatal error, current JSON value not valid");
                            return(null);
                        }

                        startPosition += 4;
                    }

                    state = JSONParsingState.ValueSeparator;
                    break;

                case JSONParsingState.Array:
                    if (jsonString[startPosition] != '[')
                    {
                        return(Fail('[', startPosition));
                    }

                    JSONValue newArray = new JSONArray();
                    if (currentValue != null)
                    {
                        newArray.Parent = currentValue;
                    }
                    currentValue = newArray;

                    state = JSONParsingState.Value;
                    break;

                case JSONParsingState.EndArray:
                    if (jsonString[startPosition] != ']')
                    {
                        return(Fail(']', startPosition));
                    }

                    if (currentValue.Parent == null)
                    {
                        return(currentValue.Obj);
                    }

                    switch (currentValue.Parent.Type)
                    {
                    case JSONValueType.Object:
                        currentValue.Parent.Obj.values[keyList.Pop()] = new JSONValue(currentValue.Array);
                        break;

                    case JSONValueType.Array:
                        currentValue.Parent.Array.Add(new JSONValue(currentValue.Array));
                        break;

                    default:
                        return(Fail("valid object", startPosition));
                    }
                    currentValue = currentValue.Parent;

                    state = JSONParsingState.ValueSeparator;
                    break;

                case JSONParsingState.Null:
                    if (jsonString[startPosition] == 'n')
                    {
                        if (jsonString.Length < startPosition + 4 ||
                            jsonString[startPosition + 1] != 'u' ||
                            jsonString[startPosition + 2] != 'l' ||
                            jsonString[startPosition + 3] != 'l')
                        {
                            return(Fail("null", startPosition));
                        }

                        switch (currentValue.Type)
                        {
                        case JSONValueType.Object:
                            currentValue.Obj.values[keyList.Pop()] = new JSONValue(JSONValueType.Null);
                            break;

                        case JSONValueType.Array:
                            currentValue.Array.Add(new JSONValue(JSONValueType.Null));
                            break;

                        default:
                            Debug.LogError("Fatal error, current JSON value not valid");
                            return(null);
                        }

                        startPosition += 3;
                    }
                    state = JSONParsingState.ValueSeparator;
                    break;
                }
            }
            Debug.LogError("Unexpected end of string");
            return(null);
        }
예제 #32
0
        /// <summary>
        /// Attempt to parse a string as a JSON array.
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns>A new JSONArray object if successful, null otherwise.</returns>
        public static JSONArray Parse(string jsonString)
        {
            var tempObject = JSONObject.Parse("{ \"array\" :" + jsonString + '}');

            return(tempObject == null ? null : tempObject.GetValue("array").Array);
        }
		public string ExportData(bool hard_copy = false)
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

			json_data["TEXTFX_EXPORTER_VERSION"] = JSON_EXPORTER_VERSION;
			json_data["m_animate_per"] = (int) m_animate_per;
			
			if (hard_copy)
			{
				json_data["m_begin_delay"] = m_begin_delay;
				json_data["m_begin_on_start"] = m_begin_on_start;
				json_data["m_on_finish_action"] = (int) m_on_finish_action;
				json_data["m_time_type"] = (int) m_time_type;
			}
			
			Boomlagoon.JSON.JSONArray letter_animations_data = new Boomlagoon.JSON.JSONArray();
			if(m_master_animations != null)
			{
				foreach(LetterAnimation anim in m_master_animations)
				{
					letter_animations_data.Add(anim.ExportData());
				}
			}
			json_data["LETTER_ANIMATIONS_DATA"] = letter_animations_data;


			// Handle exporting quick setup configuration fields
			Boomlagoon.JSON.JSONArray effect_settings_options = new Boomlagoon.JSON.JSONArray();
			if(m_preset_effect_settings != null)
			{
				foreach(PresetEffectSetting effect_setting in m_preset_effect_settings)
				{
					effect_settings_options.Add(effect_setting.ExportData());
				}
			}
			json_data["PRESET_EFFECT_SETTINGS"] = effect_settings_options;

			
			return json_data.ToString();
		}
예제 #34
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			json_data["m_letters_to_animate"] = m_letters_to_animate.ExportData();
			json_data["m_letters_to_animate_custom_idx"] = m_letters_to_animate_custom_idx;
			json_data["m_letters_to_animate_option"] = (int) m_letters_to_animate_option;
			
			if(m_loop_cycles.Count > 0)
			{
				Boomlagoon.JSON.JSONArray loops_data = new Boomlagoon.JSON.JSONArray();
				
				foreach(ActionLoopCycle action_loop in m_loop_cycles)
				{
					loops_data.Add(action_loop.ExportData());
				}
				
				json_data["LOOPS_DATA"] = loops_data;
			}
			
			Boomlagoon.JSON.JSONArray actions_data = new Boomlagoon.JSON.JSONArray();
			foreach(LetterAction action in m_letter_actions)
			{
				actions_data.Add(action.ExportData());
			}
			json_data["ACTIONS_DATA"] = actions_data;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
	//	public void ExportData(Boomlagoon.JSON.JSONObject json_data, bool hard_copy = false)
	//	{
	//		json_data["TEXTFX_EXPORTER_VERSION"] = JSON_EXPORTER_VERSION;
	//		json_data["m_animate_per"] = (int) m_animate_per;
	//
	//		if (hard_copy)
	//		{
	//			json_data["m_begin_delay"] = m_begin_delay;
	//			json_data["m_begin_on_start"] = m_begin_on_start;
	//			json_data["m_on_finish_action"] = (int) m_on_finish_action;
	//			json_data["m_time_type"] = (int) m_time_type;
	//		}
	//
	//		Boomlagoon.JSON.JSONArray letter_animations_data = new Boomlagoon.JSON.JSONArray();
	//		if(m_master_animations != null)
	//			foreach(LetterAnimation anim in m_master_animations)
	//		{
	//			letter_animations_data.Add(anim.ExportData());
	//		}
	//		json_data["LETTER_ANIMATIONS_DATA"] = letter_animations_data;
	//	}



#if UNITY_EDITOR
		public string ExportDataAsPresetSection(bool saveSampleTextInfo = true)
		{
			if(m_master_animations == null || m_master_animations.Count == 0)
			{
				Debug.LogError("There's no animation to export");
				return "";
			}

			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			json_data["TEXTFX_EXPORTER_VERSION"] = JSON_EXPORTER_VERSION;
			json_data["LETTER_ANIMATIONS_DATA"] = m_master_animations[0].ExportDataAsPresetSection(saveSampleTextInfo);
			
			
			// Handle exporting quick setup configuration fields
			Boomlagoon.JSON.JSONArray effect_settings_options = new Boomlagoon.JSON.JSONArray();
			if(m_preset_effect_settings != null)
			{
				foreach(PresetEffectSetting effect_setting in m_preset_effect_settings)
				{
					effect_settings_options.Add(effect_setting.ExportData());
				}
			}
			json_data["PRESET_EFFECT_SETTINGS"] = effect_settings_options;
			
			return json_data.ToString();
		}
예제 #36
0
		public Boomlagoon.JSON.JSONValue ExportDataAsPresetSection(bool saveSampleTextData = true)
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			if(m_loop_cycles.Count > 0)
			{
				Boomlagoon.JSON.JSONArray loops_data = new Boomlagoon.JSON.JSONArray();
				
				foreach(ActionLoopCycle action_loop in m_loop_cycles)
				{
					loops_data.Add(action_loop.ExportData());
				}
				
				json_data["LOOPS_DATA"] = loops_data;
			}
			
			Boomlagoon.JSON.JSONArray actions_data = new Boomlagoon.JSON.JSONArray();
			foreach(LetterAction action in m_letter_actions)
			{
				actions_data.Add(action.ExportData());
			}
			json_data["ACTIONS_DATA"] = actions_data;

			if(saveSampleTextData)
				json_data["SAMPLE_NUM_LETTERS_ANIMATED"] = m_letters_to_animate.Count;

			return new Boomlagoon.JSON.JSONValue(json_data);
		}