Beispiel #1
0
    private static void InitializeGameObject(GameObject go, FPVector position, FPQuaternion rotation)
    {
        ICollider[] tsColliders = go.GetComponentsInChildren <ICollider>();
        if (tsColliders != null)
        {
            for (int index = 0, length = tsColliders.Length; index < length; index++)
            {
                PhysicsManager.instance.AddBody(tsColliders[index]);
            }
        }

        FPTransform rootFPTransform = go.GetComponent <FPTransform>();

        if (rootFPTransform != null)
        {
            rootFPTransform.Initialize();

            rootFPTransform.position = position;
            rootFPTransform.rotation = rotation;
        }

        FPTransform[] FPTransforms = go.GetComponentsInChildren <FPTransform>();
        if (FPTransforms != null)
        {
            for (int index = 0, length = FPTransforms.Length; index < length; index++)
            {
                FPTransform FPTransform = FPTransforms[index];

                if (FPTransform != rootFPTransform)
                {
                    FPTransform.Initialize();
                }
            }
        }

        FPTransform2D rootFPTransform2D = go.GetComponent <FPTransform2D>();

        if (rootFPTransform2D != null)
        {
            rootFPTransform2D.Initialize();

            rootFPTransform2D.position = new FPVector2(position.x, position.y);
            rootFPTransform2D.rotation = rotation.ToQuaternion().eulerAngles.z;
        }

        FPTransform2D[] FPTransforms2D = go.GetComponentsInChildren <FPTransform2D>();
        if (FPTransforms2D != null)
        {
            for (int index = 0, length = FPTransforms2D.Length; index < length; index++)
            {
                FPTransform2D FPTransform2D = FPTransforms2D[index];

                if (FPTransform2D != rootFPTransform2D)
                {
                    FPTransform2D.Initialize();
                }
            }
        }
    }
        private static void InitializeGameObject(GameObject go, TSVector position, TSQuaternion rotation)
        {
            MonoBehaviour[] monoBehaviours = go.GetComponentsInChildren <MonoBehaviour>();
            for (int index = 0, length = monoBehaviours.Length; index < length; index++)
            {
                MonoBehaviour bh = monoBehaviours[index];

                if (bh is IFrameSyncBehaviour)
                {
                    instance.queuedBehaviours.Add(instance.NewManagedBehavior((IFrameSyncBehaviour)bh));
                }
            }


            ICollider[] tsColliders = go.GetComponentsInChildren <ICollider>();
            if (tsColliders != null)
            {
                for (int index = 0, length = tsColliders.Length; index < length; index++)
                {
                    PhysicsManager.instance.AddBody(tsColliders[index]);
                }
            }

            FPTransform rootFPTransform = go.GetComponent <FPTransform>();

            if (rootFPTransform != null)
            {
                rootFPTransform.Initialize();

                rootFPTransform.position = position;
                rootFPTransform.rotation = rotation;
            }

            FPTransform[] FPTransforms = go.GetComponentsInChildren <FPTransform>();
            if (FPTransforms != null)
            {
                for (int index = 0, length = FPTransforms.Length; index < length; index++)
                {
                    FPTransform FPTransform = FPTransforms[index];

                    if (FPTransform != rootFPTransform)
                    {
                        FPTransform.Initialize();
                    }
                }
            }

            FPTransform2D rootFPTransform2D = go.GetComponent <FPTransform2D>();

            if (rootFPTransform2D != null)
            {
                rootFPTransform2D.Initialize();

                rootFPTransform2D.position = new TSVector2(position.x, position.y);
                rootFPTransform2D.rotation = rotation.ToQuaternion().eulerAngles.z;
            }

            FPTransform2D[] FPTransforms2D = go.GetComponentsInChildren <FPTransform2D>();
            if (FPTransforms2D != null)
            {
                for (int index = 0, length = FPTransforms2D.Length; index < length; index++)
                {
                    FPTransform2D FPTransform2D = FPTransforms2D[index];

                    if (FPTransform2D != rootFPTransform2D)
                    {
                        FPTransform2D.Initialize();
                    }
                }
            }
        }