Esempio n. 1
0
 // it is a lot of work to adjust for the previous platform start position
 private Vector3 getPrevPlatformStartPosition(InfiniteObject platform, int platformIndex, Vector3 direction)
 {
     return platformStartPosition[platformIndex].x * platform.getTransform().right + platformStartPosition[platformIndex].y * Vector3.up + 
                 platformStartPosition[platformIndex].z * direction;
 }
    // move all of the active objects
    public void moveObjects(float moveDistance)
    {
        if (moveDistance == 0)
        {
            return;
        }

        // the distance to move the objects
        Vector3 delta = moveDirection * moveDistance;

        // only move the top most platform/scene of each ObjectLocation because all of the other objects are children of these two
        // objects. Only have to check the bottom-most platform/scene as well to determine if it should be removed
        InfiniteObject infiniteObject  = null;
        Transform      objectTransform = null;
        PlatformObject platformObject  = null;

        for (int i = 0; i < 2; ++i)   // loop through the platform and scenes
        {
            for (int j = 0; j < (int)ObjectLocation.Last; ++j)
            {
                // move
                infiniteObject = infiniteObjectHistory.getTopInfiniteObject((ObjectLocation)j, i == 0);
                if (infiniteObject != null)
                {
                    objectTransform = infiniteObject.getTransform();
                    Vector3 pos = objectTransform.position;
                    pos -= delta;
                    objectTransform.position = pos;

                    // check for removal.. there will always be a bottom object if there is a top object
                    infiniteObject = infiniteObjectHistory.getBottomInfiniteObject((ObjectLocation)j, i == 0);
                    if (cameraTransform.InverseTransformPoint(infiniteObject.getTransform().position).z < removeHorizon)
                    {
                        // if the infinite object is a platform and it has changes height, move everything down by that height
                        if (i == 1)   // 1 are platforms
                        {
                            platformObject = infiniteObject as PlatformObject;
                            if (platformObject.slope != PlatformSlope.None)
                            {
                                transitionHeight(platformSizes[platformObject.getLocalIndex()].y);
                            }
                        }

                        infiniteObjectHistory.objectRemoved((ObjectLocation)j, i == 0);
                        infiniteObject.deactivate();
                    }
                }
            }

            // loop through all of the turn objects
            infiniteObject = infiniteObjectHistory.getTopTurnInfiniteObject(i == 0);
            if (infiniteObject != null)
            {
                objectTransform = infiniteObject.getTransform();
                Vector3 pos = objectTransform.position;
                pos -= delta;
                objectTransform.position = pos;

                infiniteObject = infiniteObjectHistory.getBottomTurnInfiniteObject(i == 0);
                if (cameraTransform.InverseTransformPoint(infiniteObject.getTransform().position).z < removeHorizon)
                {
                    infiniteObjectHistory.turnObjectRemoved(i == 0);
                    infiniteObject.deactivate();
                }
            }
        }

        localDistance[(int)ObjectLocation.Center]      -= moveDistance;
        localSceneDistance[(int)ObjectLocation.Center] -= moveDistance;

        if (!stopObjectSpawns)
        {
            spawnObjectRun(true);
        }
    }
Esempio n. 3
0
 public void setInfiniteObjectParent(InfiniteObject parentObject)
 {
     infiniteObjectParent = parentObject;
     thisTransform.parent = parentObject.getTransform();
 }
Esempio n. 4
0
 public void setInfiniteObjectParent(InfiniteObject parentObject)
 {
     infiniteObjectParent = parentObject;
     thisTransform.parent = parentObject.getTransform();
 }