internal static Track ToTrack(JSONObject jsonObj)
        {
            Track track = new Track();

            List <HapticEffect> effectList = new List <HapticEffect>();
            var effects = jsonObj.GetValueOrDefault("effects", new JSONArray());

            foreach (var effect in effects)
            {
                effectList.Add(HapticEffect.ToEffect(effect.Value.AsObject));
            }
            track.Effects = effectList.ToArray();

            return(track);
        }
示例#2
0
        internal static Track ToTrack(JsonObject jsonObj)
        {
            Track track = new Track();

            List <HapticEffect> effectList = new List <HapticEffect>();
            var effects = jsonObj.GetNamedArray("effects", new JsonArray());

            foreach (var effect in effects)
            {
                effectList.Add(HapticEffect.ToEffect(effect.GetObject()));
            }
            track.Effects = effectList.ToArray();

            return(track);
        }
        internal static HapticEffect ToEffect(JSONObject jsonObj)
        {
            var effect = new HapticEffect();

            // TODO
            effect.StartTime  = jsonObj.GetValueOrDefault("startTime", -1);
            effect.OffsetTime = jsonObj.GetValueOrDefault("offsetTime", -1);
            effect.Modes      = new Dictionary <string, HapticEffectMode>();

            var modeJson = jsonObj.GetValueOrDefault("modes", new JSONObject());

            foreach (var mode in modeJson)
            {
                effect.Modes[mode.Key] = HapticEffectMode.ToMode(mode.Value.AsObject);
            }

            return(effect);
        }