Example #1
0
        // spawn a scene object at the specified location
        private SceneObject SpawnSceneObject(int localIndex, ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately)
        {
            SceneObject scene        = (SceneObject)infiniteObjectManager.ObjectFromPool(localIndex, ObjectType.Scene);
            Quaternion  lookRotation = Quaternion.LookRotation(direction);

            scene.Orient(position + direction * sceneSizes[localIndex].z / 2, lookRotation);
            if (activateImmediately)
            {
                scene.Activate();
            }

            int            objectIndex  = infiniteObjectManager.LocalIndexToObjectIndex(localIndex, ObjectType.Scene);
            InfiniteObject prevTopScene = infiniteObjectHistory.ObjectSpawned(objectIndex, 0, location, lookRotation.eulerAngles.y, ObjectType.Scene, scene);

            // the current scene now becames the parent of the previous top scene
            if (prevTopScene != null)
            {
                prevTopScene.SetInfiniteObjectParent(scene);
            }
            else
            {
                infiniteObjectHistory.SetBottomInfiniteObject(location, true, scene);
            }

            infiniteObjectHistory.AddTotalDistance(sceneSizes[localIndex].z, location, true, spawnData.section);
            if (scene.sectionTransition)
            {
                infiniteObjectHistory.DidSpawnSectionTranition(location, true);
            }

            return(scene);
        }
Example #2
0
    // spawn a scene object at the specified location
    private SceneObject SpawnScene(int localIndex, Direction locationDirection, Vector3 position,
                                   Vector3 direction, bool activateImmediately)
    {
        SceneObject scene        = (SceneObject)ObjectPool.instance.GetObjectFromPool(localIndex, ObjectType.Scene);
        Quaternion  lookRotation = Quaternion.LookRotation(direction);

        scene.Orient(position + direction * sceneSizes[localIndex].z / 2, lookRotation);
        if (activateImmediately)
        {
            scene.Activate();
        }

        int         objectIndex  = ObjectPool.instance.GetObjectIndexFromLocalIndex(localIndex, ObjectType.Scene);
        BasicObject prevTopScene = ObjectHistory.instance.ObjectSpawned(objectIndex, 0, locationDirection,
                                                                        lookRotation.eulerAngles.y, ObjectType.Scene, scene);

        // the current scene now becames the parent of the previous top scene
        if (prevTopScene != null)
        {
            prevTopScene.SetObjectParent(scene);
        }
        else
        {
            ObjectHistory.instance.SetBottomObject(locationDirection, IS_SCENE, scene);
        }

        ObjectHistory.instance.AddTotalDistance(sceneSizes[localIndex].z, locationDirection, IS_SCENE, spawnData.section);
        if (scene.isForSectionTransition)
        {
            ObjectHistory.instance.DidSpawnSectionTransition(locationDirection, IS_SCENE);
        }

        return(scene);
    }