Exemplo n.º 1
0
    public static void ParseJSONString(string json)
    {
        JSONTake j = JsonReader.Deserialize <JSONTake>(json);

        if (!parseJSONTake(j))
        {
            Debug.LogWarning("Animator: Error parsing JSON");
        }
    }
Exemplo n.º 2
0
        // returns false if there were problems parsing the take
        private static bool  parseJSONTake(JSONTake j)
        {
            dictGameObjects   = new Dictionary <string, GameObject>();
            dictComponents    = new Dictionary <string, Component>();
            dictMethodInfos   = new Dictionary <string, MethodInfo>();
            dictFieldInfos    = new Dictionary <string, FieldInfo>();
            dictPropertyInfos = new Dictionary <string, PropertyInfo>();
            bool errorOccured = false;

            // set initial values
            if (j.inits != null)
            {
                foreach (JSONInit i in j.inits)
                {
                    if (!setInitialValue(i))
                    {
                        errorOccured = true;
                    }
                }
            }
            // execute actions
            if (j.actions != null)
            {
                foreach (JSONAction a in j.actions)
                {
                    switch (a.method)
                    {
                    // translation
                    case "moveto":
                        if (!parseMoveTo(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    case "rotateto":
                        if (!parseRotateTo(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    case "lookfollow":
                        if (!parseLookFollow(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    case "looktofollow":
                        if (!parseLookToFollow(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    case "playanimation":
                        if (!parsePlayAnimation(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    case "playaudio":
                        if (!parsePlayAudio(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    case "propertyto":
                        if (!parsePropertyTo(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    case "sendmessage":
                        if (!parseSendMessage(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    case "invokemethod":
                        if (!parseInvokeMethod(a))
                        {
                            errorOccured = true;
                        }
                        break;

                    default:
                        Debug.LogWarning("Animator: Error parsing method '" + a.method + "'");
                        errorOccured = true;
                        break;
                    }
                }
            }
            //AMTween.StartDisabled();	// enable all tweens at once
            return(!errorOccured);
        }
Exemplo n.º 3
0
 // returns false if there were problems parsing the take
 private static bool parseJSONTake(JSONTake j)
 {
     dictGameObjects = new Dictionary<string, GameObject>();
     dictComponents = new Dictionary<string, Component>();
     dictMethodInfos = new Dictionary<string, MethodInfo>();
     dictFieldInfos = new Dictionary<string, FieldInfo>();
     dictPropertyInfos = new Dictionary<string, PropertyInfo>();
     bool errorOccured = false;
     // set initial values
     if(j.inits != null) {
         foreach(JSONInit i in j.inits) {
             if(!setInitialValue(i)) errorOccured = true;
         }
     }
     // execute actions
     if(j.actions != null) {
         foreach(JSONAction a in j.actions) {
             switch(a.method) {
             // translation
             case "moveto":
                 if(!parseMoveTo(a)) errorOccured = true;
                 break;
             case "rotateto":
                 if(!parseRotateTo(a)) errorOccured = true;
                 break;
             case "lookfollow":
                 if(!parseLookFollow(a)) errorOccured = true;
                 break;
             case "looktofollow":
                 if(!parseLookToFollow(a)) errorOccured = true;
                 break;
             case "playanimation":
                 if(!parsePlayAnimation(a)) errorOccured = true;
                 break;
             case "playaudio":
                 if(!parsePlayAudio(a)) errorOccured = true;
                 break;
             case "propertyto":
                 if(!parsePropertyTo(a)) errorOccured = true;
                 break;
             case "sendmessage":
                 if(!parseSendMessage(a)) errorOccured = true;
                 break;
             case "invokemethod":
                 if(!parseInvokeMethod(a)) errorOccured = true;
                 break;
             default:
                 Debug.LogWarning("Animator: Error parsing method '"+a.method+"'");
                 errorOccured = true;
                 break;
             }
         }
     }
     //AMTween.StartDisabled();	// enable all tweens at once
     return !errorOccured;
 }