コード例 #1
0
        public void FixedFiftyFiftyTest()
        {
            Vector3D detectorAngle = VectorFactory.Create(0);
            Vector3D particleAngle = VectorFactory.Create(90);
            var      detector      = new Detector(detectorAngle);

            int count = 0;

            for (int i = 0; i < iterationCount; ++i)
            {
                var particle = new Particle(VectorFactory.Create());

                // Force the particle direction.
                particle.ExposeToField(particleAngle);

                if (detector.InDirectionOfDetector(particle))
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.50);

            Assert.AreEqual(expected, count, margin);
        }
コード例 #2
0
        public void ReturnTheShearByAdjustingTheOtherValuesInColors()
        {
            var sut           = new LinearTranformationFactory();
            var vectorFactory = new VectorFactory();

            sut.Shear(2, 1, 2).Should().BeEquivalentTo(new Matrix(vectorFactory.CreateVector(1, 0), vectorFactory.CreateVector(2, 1)));
        }
コード例 #3
0
        // @see EPR paradox.
        public void JohnBellTest()
        {
            int count  = 0;
            var random = new Random(Guid.NewGuid().GetHashCode());

            for (int i = 0; i < iterationCount; ++i)
            {
                var particle1 = new Particle(VectorFactory.Create());
                var particle2 = new Particle(particle1);

                var detector1 = new Detector(VectorFactory.Create(random.Next(3) * 120));
                var detector2 = new Detector(VectorFactory.Create(random.Next(3) * 120));

                bool up1 = detector1.InDirectionOfDetector(particle1);
                bool up2 = detector2.InDirectionOfDetector(particle2);

                if (up1 != up2)
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.50);

            Assert.AreEqual(expected, count, margin);
        }
コード例 #4
0
        public void FortyFiveDegreesTest()
        {
            var detector1 = new Detector(VectorFactory.Create(0));
            var detector2 = new Detector(VectorFactory.Create(45));

            int count = 0;

            for (int i = 0; i < iterationCount; ++i)
            {
                var particle1 = new Particle(VectorFactory.Create());
                var particle2 = new Particle(particle1);

                bool up1 = detector1.InDirectionOfDetector(particle1);
                bool up2 = detector2.InDirectionOfDetector(particle2);

                if (up1 != up2)
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.85);

            Assert.AreEqual(expected, count, margin);
        }
コード例 #5
0
ファイル: LDA.cs プロジェクト: oswaldor/Plume
        /// <summary>
        /// Initializes a new instance of the <see cref="LDA"/> class.
        /// </summary>
        /// <param name="numTopic"></param>
        /// <param name="modelFileName"></param>
        /// <param name="corpusVocabularyFileName"></param>
        /// <param name="language"></param>
        private LDA(int numTopic, string modelFileName, string corpusVocabularyFileName, int[] badTopicIds, Language language)
        {
            this.numTopics = numTopic;
            this.dvFactory = DocumentVocabularyFactory.NewInstance(language);
            this.topicAllocationsFactory  = VectorFactory.NewInstance(VectorType.DenseVector, numTopic);
            this.corpusVocabularyFileName = corpusVocabularyFileName;

            StatusMessage.Write(string.Format("LDA: Initializing Vowpal Wabbit Interface with model file {0}", modelFileName));
            this.vwLDAModel = VowpalWabbitInterface.Initialize(string.Format("-i {0} -t --quiet", modelFileName));
            //this.vwLDAModel = new VowpalWabbit(string.Format(CultureInfo.InvariantCulture, "-i {0} -t --quiet", modelFileName));

            this.badTopics = new bool[this.numTopics];
            Array.Clear(this.badTopics, 0, this.numTopics);

            this.RecommendedCompressionType = VectorType.DenseVector; // Default
            int badTopicCount;

            if ((badTopicIds != null) && ((badTopicCount = badTopicIds.Length) > 0))
            {
                foreach (var topicId in badTopicIds)
                {
                    if (topicId < this.numTopics)
                    {
                        this.badTopics[topicId] = true;
                    }
                }

                var sizeOfSparseVector = VectorBase.SizeOfSparseVectors(numTopic, badTopicCount);
                var sizeOfDenseVector  = VectorBase.BytesPerDimension * numTopic;

                this.RecommendedCompressionType = (sizeOfSparseVector < sizeOfDenseVector) ? VectorType.SparseVector : VectorType.DenseVector;
            }
        }
コード例 #6
0
ファイル: Service1.cs プロジェクト: OlegLysovych/WCF_TRSPO
        public ObjectObgortka GetVectorData(int n, VectorEnum Letter)
        {
            VectorFactory  vectorFactory = new VectorFactory();
            ObjectObgortka obgortka      = new ObjectObgortka();

            obgortka.Vector = vectorFactory.GetVector(Letter, n);
            return(obgortka);
        }
コード例 #7
0
        static void Main(string[] args)
        {
            /*
             * Note: If both detectors have the same angle
             * the spin of the entangled particles
             * will be opposite 100% of the time.
             *
             * If the detectors are opposite the spin
             * will be equal 100% of the time.
             *
             * But, and this the point;
             * if the difference between the detectors
             * is 45 degrees (PI/4), the spin
             * will be opposite 85% of the time.
             * (not 75 as classical physics predicts)
             */

            var d1 = new Detector(new Vector3D(1, 0, 0));
            var d2 = new Detector(new Vector3D(0, 1, 0));

            int diffs = 0;

            for (int i = 0; i < 10000; ++i)
            {
                var p1 = new Particle(VectorFactory.Create());
                var p2 = new Particle(p1);

                bool up1 = false, up2 = false;

                bool async = true;
                if (async)
                {
                    Parallel.Invoke(
                        () => Detect(d1, p1, out up1),
                        () => Detect(d2, p2, out up2)
                        );
                }
                else
                {
                    Detect(d1, p1, out up1);
                    Detect(d2, p2, out up2);
                }

                Console.WriteLine(up1);
                Console.WriteLine(up2);

                if (up1 != up2)
                {
                    ++diffs;
                }

                Console.WriteLine();
            }

            Console.WriteLine(diffs);

            Console.ReadKey();
        }
コード例 #8
0
        public void OppositeDirectionTest()
        {
            Vector3D angle    = VectorFactory.Create(0);
            var      detector = new Detector(angle);

            for (int i = 0; i < 1000; ++i)
            {
                var particle1 = new Particle(VectorFactory.Create());
                var particle2 = new Particle(particle1);

                bool up1 = detector.InDirectionOfDetector(particle1);
                bool up2 = detector.InDirectionOfDetector(particle2);

                Assert.AreNotEqual(up1, up2);
            }
        }
コード例 #9
0
        public void RandomFiftyFiftyTest()
        {
            Vector3D angle    = VectorFactory.Create(0);
            var      detector = new Detector(angle);

            int count = 0;

            for (int i = 0; i < iterationCount; ++i)
            {
                var particle = new Particle(VectorFactory.Create());

                if (detector.InDirectionOfDetector(particle))
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.50);

            Assert.AreEqual(count, expected, margin);
        }
コード例 #10
0
    public void UpdateLeg()
    {
        stepSpeed = parent.GetSpeed();

        double angle = parent.GetDirection()
                       + legOffset * (orientation ? 1 : -1);

        Vector3 targetPos = new Vector3(parent.GetX() + (float)Lib.CosX(length, angle),
                                        parent.GetY() + (float)Lib.SinY(length, angle),
                                        parent.GetZ());

        if (stepping)
        {
            position.x += (float)((position.x > targetPos.x) ? -stepSpeed : stepSpeed);
            position.y += (float)((position.y > targetPos.y) ? -stepSpeed : stepSpeed);

            if (Lib.GetDist(position.x, position.y, targetPos.x, targetPos.y) < stepSpeed)
            {
                ToggleStepping();
            }
        }
        else
        {
            if (Lib.GetDist(position.x, position.y, targetPos.x, targetPos.y) > length)
            {
                ToggleStepping();
            }
            else if (Lib.GetDist(parent.GetX(), parent.GetY(), position.x, position.y) < lastDist)
            {
                parent.Push(length / 5 * (orientation ? 1:-1));
            }
        }

        lastDist = Lib.GetDist(parent.GetX(), parent.GetY(), position.x, position.y);

        if (parent.GetState() == 1)
        {
            VectorFactory.DrawCircle(position, thickness, Color.yellow);
        }
    }
コード例 #11
0
    public ArrayList GetLegByShoulder(ArrayList coords, Vector3[] shoulder, bool orientation)
    {
        Vector3 point1 = new Vector3(parent.GetX(), parent.GetY(), 0);
        Vector3 point2 = new Vector3(position.x, position.y, 0);

        double offset = Lib.ToDeg(Math.Acos((Lib.GetDist(point1.x, point1.y, point2.x, point2.y) / 2) / (length / 2)));

        offset *= outwardJoint ? -1 : 1;

        double rawAngle = Lib.GetDir(point1.x, point1.y, point2.x, point2.y);

        double angle;

        if (Double.IsNaN(offset))
        {
            angle = rawAngle;
        }
        else
        {
            angle = rawAngle + offset;
        }

        Vector3 elbow = new Vector3(point1.x + Lib.CosX(length / 2, angle),
                                    point1.y + Lib.SinY(length / 2, angle),
                                    point1.z);

        double footAngle  = Lib.GetDir(elbow.x, elbow.y, point2.x, point2.y);
        double elbowAngle = (angle + footAngle) / 2;

        coords.Add(shoulder[orientation ? 0:1]);
        coords.Add(shoulder[orientation ? 1:0]);
        coords.Add(VectorFactory.IKPoint(elbow, thickness / 2, angle + 90));
        coords.Add(VectorFactory.IKPoint(elbow, thickness / 2, angle - 90));
        coords.Add(VectorFactory.IKPoint(elbow, thickness / 2, footAngle + 90));
        coords.Add(VectorFactory.IKPoint(elbow, thickness / 2, footAngle - 90));
        coords.Add(VectorFactory.IKPoint(point2, thickness / 2, footAngle + 90));
        coords.Add(VectorFactory.IKPoint(point2, thickness / 2, footAngle - 90));

        return(coords);
    }
コード例 #12
0
        public static IFitnessCounter GetFitnessCounterForTraining(OptimizationParameters optimizationParameters)
        {
            var countFitnessParameters = new CountFitnessParameters()
            {
                FitnessType         = optimizationParameters.FitnessType,
                PositionsOfSheepSet = optimizationParameters.RandomPositions ?
                                      VectorFactory.GenerateRandomPositions(optimizationParameters.NumberOfRandomSets, optimizationParameters.NumberOfSheep, 0, 400) :
                                      new List <List <Vector2D> >()
                {
                    optimizationParameters.PositionsOfSheep
                },
                PositionsOfShepherdsSet = optimizationParameters.RandomPositions ?
                                          VectorFactory.GenerateRandomPositions(optimizationParameters.NumberOfRandomSets, optimizationParameters.NumberOfShepherds, 0, 400) :
                                          new List <List <Vector2D> >()
                {
                    optimizationParameters.PositionsOfShepherds
                },
                SheepType      = optimizationParameters.SheepType,
                TurnsOfHerding = optimizationParameters.TurnsOfHerding
            };

            return(GetFitnessCounter(countFitnessParameters));
        }
コード例 #13
0
        static void Main(string[] args)
        {
            TrajectorySet newSet = new TrajectorySet("gnss_point.csv", new NewTrajectorySetCreator(), CoordinateGenerator.CRSParseFromEPSG(4326));

            IShapefile roadShapefile = VectorFactory.OpenShapefile("road.shp", VectorOpenMode.Common);

            IMapMatch mapMatchFunction = new HMMMapMatch(roadShapefile, 0.000173);

            IMapMatch mapMatchFunction2 = new HMMMapMatch(roadShapefile, 0.000173, roadShapefile.GetBoundaryBox(), "Direction");

            TrajectorySet matchedSet = new TrajectorySet();

            foreach (Trajectory trajectory in newSet.TrajectoryList)
            {
                Trajectory mapMatchedTrajectory = mapMatchFunction.MatchRoute(trajectory, 0.000173 * 2, 10);

                matchedSet.AddTrajectory(mapMatchedTrajectory);
            }

            IShapefile matchedShapefile = matchedSet.ExportToShapefile(CoordinateGenerator.CRSParseFromEPSG(4326));

            matchedShapefile.ExportShapefile("matchedTrajectory2.shp");
        }
コード例 #14
0
        public void SixtyDegreesTest()
        {
            Vector3D detectorAngle = VectorFactory.Create(60);
            var      detector      = new Detector(detectorAngle);

            int count = 0;

            for (int i = 0; i < iterationCount; ++i)
            {
                Vector3D particleAngle = VectorFactory.Create(180);
                var      particle      = new Particle(particleAngle);

                bool up = detector.InDirectionOfDetector(particle);

                if (up)
                {
                    ++count;
                }
            }

            int expected = (int)(iterationCount * 0.75);

            Assert.AreEqual(expected, count, margin);
        }
コード例 #15
0
ファイル: Body.cs プロジェクト: zaineashe/salamander
    public void UpdateBody()
    {
        size = baseSize + breathing;

        if ((inOut == true && breathing > 0.2) || (inOut == false && breathing <= 0.1))
        {
            inOut = !inOut;
        }

        if (master.GetSpeed() < 0.1)
        {
            breathing += ((inOut ? 0.3 : 0) - breathing) / 20;
        }
        else
        {
            inOut = false;
        }


        float targetX = position.x;
        float targetY = position.y;

        if (parent == null)
        {
            if (Lib.GetDist(position.x, position.y, master.transform.position.x, master.transform.position.y) > size * 2)
            {
                targetX = master.transform.position.x + (float)Lib.CosX(0.1, master.GetDirection() + 180);
                targetY = master.transform.position.y + (float)Lib.SinY(0.1, master.GetDirection() + 180);
            }

            direction = master.GetDirection();
        }
        else
        {
            PointTo(parent.GetX(), parent.GetY());

            if (Lib.GetDist(position.x, position.y, parent.GetX(), parent.GetY()) > size * 2)
            {
                targetX = parent.GetX() + (float)Lib.CosX(size * 2, parent.GetDirection() + 180);
                targetY = parent.GetY() + (float)Lib.SinY(size * 2, parent.GetDirection() + 180);
            }
        }


        position.x += (float)((targetX - position.x) / 3.0);
        position.y += (float)((targetY - position.y) / 3.0);

        speedFactor = Math.Abs((((targetX - position.x) / 3.0) + (((targetY - position.y) / 3.0))) / 2) * 10;
        if (speedFactor < 0.8)
        {
            speedFactor = 0.8;
        }

        if (legs != null)
        {
            for (int i = 0; i < legs.Count; i++)
            {
                Leg leg = (Leg)legs[i];
                leg.UpdateLeg();
            }
        }

        if (master.GetState() == 0)
        {
            VectorFactory.DrawCircle(position, size, Color.white);
        }
    }
コード例 #16
0
        private static object CreateClassFromDic(Dictionary <string, object> dic, Type type, object parent)
        {
            var typename = type.FullName;
            var result   = parent ?? Reflection.Instance.FastCreateInstance(type);

            var props = Reflection.Instance.Getproperties(type, typename);

            foreach (var kv in dic)
            {
                var key     = kv.Key;
                var value   = kv.Value;
                var keyName = key.ToLower();

                var containsNameInProps = props.ContainsKey(keyName);
                if (!containsNameInProps)
                {
                    continue;
                }
                var    propInfo = props[keyName];
                object oset     = null;

                switch (propInfo.Type)
                {
                case MyPropInfoType.Int: oset = (int)(long)value; break;

                case MyPropInfoType.Float: oset = (float)Deserializer.TryGetDoubleValue(value); break;

                case MyPropInfoType.String: oset = (string)value; break;

                case MyPropInfoType.Bool: oset = (bool)value; break;

                case MyPropInfoType.Char: oset = ((string)value)[0]; break;

                case MyPropInfoType.Byte: oset = (byte)(long)value; break;

                case MyPropInfoType.Decimal: oset = (decimal)Deserializer.TryGetDoubleValue(value); break;

                case MyPropInfoType.Double: oset = Deserializer.TryGetDoubleValue(value); break;

                case MyPropInfoType.Short: oset = (short)(long)value; break;

                case MyPropInfoType.Long: oset = (long)value; break;

                case MyPropInfoType.DateTime: oset = Deserializer.CreateDateTime((string)value); break;

                case MyPropInfoType.Enum: oset = Deserializer.CreateEnum(propInfo.Pt, value); break;

                case MyPropInfoType.Guid: oset = Deserializer.CreateGuid((string)value); break;

                case MyPropInfoType.List: oset = CreateList((List <object>)value, propInfo.Pt); break;

                case MyPropInfoType.Array: oset = Deserializer.CreateArray((List <object>)value, propInfo.Bt, null); break;

                case MyPropInfoType.ByteArray: oset = Convert.FromBase64String((string)value); break;

                case MyPropInfoType.Hashtable:                         // same case as Dictionary
                case MyPropInfoType.Dictionary: oset = Deserializer.CreateDictionary((List <object>)value, propInfo.Pt, propInfo.GenericTypes, null); break;

                case MyPropInfoType.StringKeyDictionary: oset = Deserializer.CreateStringKeyDictionary((Dictionary <string, object>)value, propInfo.Pt, propInfo.GenericTypes, null); break;

                case MyPropInfoType.NameValue: oset = Deserializer.CreateNv((Dictionary <string, object>)value); break;

                case MyPropInfoType.StringDictionary: oset = Deserializer.CreateSd((Dictionary <string, object>)value); break;

                    #region Unity_Build-in_Classes
                case MyPropInfoType.Vector2:
                    oset = VectorFactory.CreateVector2((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Vector2Int:
                    oset = VectorFactory.CreateVector2Int((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Vector3:
                    oset = VectorFactory.CreateVector3((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Vector3Int:
                    oset = VectorFactory.CreateVector3Int((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Vector4:
                    oset = VectorFactory.CreateVector4((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Color:
                    oset = UnityClassesFactoryMain.CreateColor((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Color32:
                    oset = UnityClassesFactoryMain.CreateColor32((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Rect:
                    oset = UnityClassesFactoryMain.CreateRect((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.RectInt:
                    oset = UnityClassesFactoryMain.CreateRectInt((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Bounds:
                    oset = UnityClassesFactoryMain.CreateBounds((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.BoundsInt:
                    oset = UnityClassesFactoryMain.CreateBoundsInt((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Ray:
                    oset = UnityClassesFactoryMain.CreateRay((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Ray2D:
                    oset = UnityClassesFactoryMain.CreateRay2D((Dictionary <string, object>)value);
                    break;

                case MyPropInfoType.Quaternion:
                    oset = UnityClassesFactoryMain.CreateQuaternion((Dictionary <string, object>)value);
                    break;

                    #endregion
                case MyPropInfoType.Custom: oset = Reflection.Instance.CreateCustom((string)value, propInfo.Pt); break;

                case MyPropInfoType.Unknown:
                    UnityEngine.Debug.LogError("Your class is unsupported: " + propInfo.Pt + ". Pls register with JSONObject.RegisterCustomType().");
                    break;

                default:
                {
                    if (propInfo.IsGenericType && propInfo.IsValueType == false && value is List <object> )
                    {
                        oset = CreateList((List <object>)value, propInfo.Pt);
                    }

                    else if ((propInfo.IsClass || propInfo.IsStruct || propInfo.IsInterface) && value is Dictionary <string, object> )
                    {
                        oset = CreateClassFromDic((Dictionary <string, object>)value, propInfo.Pt, propInfo.Getter(result));
                    }

                    else if (value is List <object> )
                    {
                        oset = Deserializer.CreateArray((List <object>)value, typeof(object), null);
                    }

                    else if (propInfo.IsValueType)
                    {
                        oset = Deserializer.ChangeType(value, propInfo.ChangeType);
                    }

                    else
                    {
                        oset = value;
                    }
                }
                break;
                }

                result = propInfo.Setter(result, oset);
            }

            return(result);
        }
コード例 #17
0
ファイル: Lizard.cs プロジェクト: zaineashe/salamander
    // Update is called once per frame
    void Update()
    {
        MoveHead(Input.GetKey(KeyCode.UpArrow),
                 Input.GetKey(KeyCode.LeftArrow),
                 Input.GetKey(KeyCode.RightArrow));

        ChangeState(Input.GetKeyDown(KeyCode.Space));

        ArrayList coords = FinalizeCoords();

        Vector3[] vertices = new Vector3[coords.Count];
        Vector3[] normals  = new Vector3[coords.Count];
        Vector2[] uvs      = new Vector2[coords.Count];

        //triangulation
        ArrayList tris = new ArrayList();

        int boundUp = bodyLength;

        for (int i = 0; i < coords.Count; i++)
        {
            Vector3 vect = (Vector3)coords[i];
            vertices[i] = new Vector3(vect.x - transform.position.x, vect.y - transform.position.y, 0);
            normals[i]  = Vector3.down;

            uvs[i] = new Vector2(vertices[i].x, vertices[i].y);

            if (i >= bodyLength)
            {
                if ((i - bodyLength) % 8 == 0)
                {
                    if (boundUp + 8 > coords.Count)
                    {
                        boundUp = coords.Count;
                    }
                    else
                    {
                        boundUp += 8;
                    }
                }
                tris = CreateQuad(tris, coords, i, boundUp);
            }
            else if (i < bodyLength && i % 2 == 0)
            {
                tris = CreateQuad(tris, coords, i, boundUp);
            }
        }

        int[] triangles = new int[tris.Count];

        for (int i = 0; i < tris.Count; i++)
        {
            triangles[i] = (int)tris[i];
        }

        mesh.vertices  = vertices;
        mesh.normals   = normals;
        mesh.triangles = triangles;
        mesh.uv        = uvs;

        mesh.RecalculateBounds();

        filter.mesh = mesh;

        renderer.enabled = state == 2;

        if (state == 1)
        {
            VectorFactory.DrawTriangles(transform.position, triangles, vertices);
        }
    }
コード例 #18
0
        public T TryGetValue <T>()
        {
            var type = typeof(T);

            if (_nodeObject.ElementType == JsonElementType.Long)
            {
                if (type == typeof(int))
                {
                    return((T)(object)(int)(long)_nodeObject.FinishObj);
                }

                if (type == typeof(long))
                {
                    return((T)_nodeObject.FinishObj);
                }

                Debug.Log(type.Name);
            }

            if (_nodeObject.ElementType == JsonElementType.Bool)
            {
                if (type == typeof(bool))
                {
                    return((T)_nodeObject.FinishObj);
                }

                Debug.Log(type.Name);
            }

            if (_nodeObject.ElementType == JsonElementType.Dictionary)
            {
                if (type == typeof(Dictionary <string, object>))
                {
                    return((T)_nodeObject.FinishObj);
                }

                if (type == typeof(StringDictionary))
                {
                    return((T)(object)ClassFactory.GetStringDictionaryValue(_nodeObject.FinishObj));
                }

                if (type == typeof(Dictionary <string, string>))
                {
                    return((T)(object)ClassFactory.GetDictionaryStringStringValue(_nodeObject.FinishObj));
                }

                if (type == typeof(NameValueCollection))
                {
                    return((T)(object)ClassFactory.GetNameValueCollectionValue(_nodeObject.FinishObj));
                }

                #region UNITY_TYPES
                if (type == typeof(Vector2))
                {
                    return((T)(object)VectorFactory.CreateVector2((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Vector2Int))
                {
                    return((T)(object)VectorFactory.CreateVector2Int((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Vector3))
                {
                    return((T)(object)VectorFactory.CreateVector3((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Vector3Int))
                {
                    return((T)(object)VectorFactory.CreateVector3Int((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Vector4))
                {
                    return((T)(object)VectorFactory.CreateVector4((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Color))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateColor((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Color32))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateColor32((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Rect))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateRect((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(RectInt))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateRectInt((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Bounds))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateBounds((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(BoundsInt))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateBoundsInt((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Ray))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateRay((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Ray2D))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateRay2D((Dictionary <string, object>)_nodeObject.FinishObj));
                }

                if (type == typeof(Quaternion))
                {
                    return((T)(object)UnityClassesFactoryMain.CreateQuaternion((Dictionary <string, object>)_nodeObject.FinishObj));
                }
                #endregion

                var result = (T)CustomClassFactory.ParseCustomClass(_nodeObject.FinishObj, type);
                return(result);
            }

            if (_nodeObject.ElementType == JsonElementType.List)
            {
                if (type == typeof(List <object>))
                {
                    return((T)_nodeObject.FinishObj);
                }

                if (type == typeof(Hashtable))
                {
                    return((T)(object)ClassFactory.GetHashtableValue(_nodeObject.FinishObj));
                }

                if (type == typeof(Array))
                {
                    return((T)(object)ClassFactory.GetArrayValue(_nodeObject.FinishObj));
                }

                var result = (T)CustomClassFactory.ParseCustomClass(_nodeObject.FinishObj, type);
                return(result);
            }

            if (_nodeObject.ElementType != JsonElementType.String)
            {
                //Debug.Log(_nodeObject.ElementType);
                return(default(T));
            }

            var str = (string)_nodeObject.FinishObj;


            if (type == typeof(string))
            {
                return((T)(object)str);
            }

            if (type == typeof(DateTime))
            {
                var result = ClassFactory.GetDateTime(str);
                return((T)(object)result);
            }

            if (type == typeof(Guid))
            {
                var result = ClassFactory.GetGuidValue(str);
                return((T)(object)result);
            }

            if (type.IsEnum)
            {
                if (type == typeof(Enum))
                {
                    Debug.LogError("Pls get concrete enum type, not abstract enum");
                    return(default(T));
                }

                var result = ClassFactory.GetEnumValue <T>(str);
                return(result);
            }

            if (type == typeof(byte[]))
            {
                var result = ClassFactory.GetByteArrayValue(str);
                return((T)(object)result);
            }

            var result1 = (T)CustomClassFactory.ParseCustomClass(_nodeObject.FinishObj, type);
            return(result1);
        }