예제 #1
0
        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 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);
        }