Exemplo n.º 1
0
        public static AnimationEvent ReadAnimationEvent(JSON.ANode node)
        {
            AnimationEvent e = new AnimationEvent
            {
                time         = node["time"].AsFloat,
                functionName = node.GetOneOf("functionName").Value
            };

            ANode sPar = node.GetOneOf("stringParameter", "stringParam");

            if (sPar != null)
            {
                e.stringParameter = sPar.Value;
            }

            ANode fPar = node.GetOneOf("floatParameter", "floatParam");

            if (fPar != null)
            {
                e.floatParameter = fPar.AsFloat;
            }

            ANode iPar = node.GetOneOf("intParameter", "intParam");

            if (iPar != null)
            {
                e.intParameter = iPar.AsInt;
            }

            return(e);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Получение Vector3 из json
        /// </summary>
        /// <param name="node">Узел JSON</param>
        /// <returns> Vector3 </returns>
        public static Vector3 ReadVector3(JSON.ANode node)
        {
            float x = -1, y = -1, z = -1;

            if (TryReadFloat(node, ref x, "x") && TryReadFloat(node, ref y, "y") && TryReadFloat(node, ref z, "z"))
            {
                return(new Vector3(x, y, z));
            }
            Debug.LogError("Dev.JSON.ReadVector3: Bad Vector3: " + node.ToJSON());
            return(Vector3.zero);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Получение Quaternion из json
        /// </summary>
        /// <param name="node">Узел JSON</param>
        /// <returns> Quaternion </returns>
        public static Quaternion ReadQuaternion(JSON.ANode node)
        {
            float x = -1, y = -1, z = -1, w = -1;

            if (TryReadFloat(node, ref x, "x") && TryReadFloat(node, ref y, "y") && TryReadFloat(node, ref z, "z"))
            {
                return(TryReadFloat(node, ref w, "w") ? new Quaternion(x, y, z, w) : Quaternion.Euler(x, y, z));
            }
            Debug.LogError("Dev.JSON.ReadQuaternion: Bad Quaternion: " + node.ToJSON());
            return(Quaternion.identity);
        }
Exemplo n.º 4
0
 public static bool TryRead(ANode node, out JSON.ANode variable, params string[] names)
 {
     variable = null;
     foreach (string s in names)
     {
         ANode n = node[s];
         if (n == null)
         {
             continue;
         }
         variable = n;
         return(true);
     }
     return(false);
 }
Exemplo n.º 5
0
        public void JsonReadFrom(JSON.ANode node, string outerName = "")
        {
            JSON.Class userParArr  = node[STR_User_params].AsClass;
            var        paramsNodes = userParArr.GetNamesOfAllChildren();

            foreach (string item in paramsNodes)
            {
                Localization.Add(item, userParArr[item]);
            }
            JSON.Array picArr  = node[STR_Pictures].AsArray;
            int        counter = 0;

            foreach (JSON.ANode item in picArr)
            {
                Picture newPic = new Picture(item, counter++);
                AllProducts.Add(newPic.Id, newPic);
            }
        }
Exemplo n.º 6
0
        public void JsonReadFrom(JSON.ANode node, string outerName = "")
        {
            Id    = node[STR_Id].AsInt;
            SizeX = node[STR_Size_x].AsFloat;
            SizeY = node[STR_Size_y].AsFloat;
            JSON.TryReadString(node, ref Description, STR_Description);
            JSON.TryReadString(node, ref MainPictureStr, STR_Main_Name);
            JSON.TryReadString(node, ref PreviewPictureStr, STR_Preview_Name);
            JSON.TryReadBool(node, ref IsNew, STR_Is_new);
            JSON.Class userParNode = node[STR_User_params].AsClass;
            var        properties  = userParNode.GetNamesOfAllChildren();

            foreach (string item in properties)
            {
                UserParams.Add(Config.Localization[item], userParNode[item]);
            }

            MainPicture = Resources.Load <Sprite>(MainPictureStr);
            if (MainPicture == null)
            {
                Debug.Log("No main image " + MainPictureStr);
            }
            PreviewPicture = Resources.Load <Sprite>(PreviewPictureStr);
        }
Exemplo n.º 7
0
 public void JsonWriteTo(JSON.ANode parent, string forceName = "")
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
 public Config(JSON.ANode node)
 {
     JsonReadFrom(node);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Получение Vector2 из json
 /// </summary>
 /// <param name="node">Узел JSON</param>
 /// <returns> Vector2 </returns>
 public static Vector2 ReadVector2(JSON.ANode node)
 {
     return(new Vector2(node["x"].AsFloat, node["y"].AsFloat));
 }
Exemplo n.º 10
0
 public Picture(JSON.ANode node, int index)
 {
     Index = index;
     JsonReadFrom(node);
 }