// 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); } }