// returns the length of the created platform private PlatformObject SpawnPlatform(int localIndex, ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately) { PlatformObject platform = (PlatformObject)infiniteObjectManager.ObjectFromPool(localIndex, ObjectType.Platform); Quaternion lookRotation = Quaternion.LookRotation(direction); platform.Orient(position + (direction * platformSizes[localIndex].z / 2), lookRotation); if (activateImmediately) { platform.Activate(); } int objectIndex = infiniteObjectManager.LocalIndexToObjectIndex(localIndex, ObjectType.Platform); InfiniteObject prevTopPlatform = infiniteObjectHistory.ObjectSpawned(objectIndex, 0, location, lookRotation.eulerAngles.y, ObjectType.Platform, platform); // the current platform now becames the parent of the previous top platform if (prevTopPlatform != null) { prevTopPlatform.SetInfiniteObjectParent(platform); } else { infiniteObjectHistory.SetBottomInfiniteObject(location, false, platform); } infiniteObjectHistory.AddTotalDistance(platformSizes[localIndex].z, location, false, spawnData.section); return(platform); }
// Spawn platform private PlatformObject SpawnPlatform(int localIndex, Direction locationDirection, Vector3 position, Vector3 direction, bool activateImmediately) { PlatformObject platform = (PlatformObject)ObjectPool.instance.GetObjectFromPool(localIndex, ObjectType.Platform); Quaternion lookRotation = Quaternion.LookRotation(direction); platform.Orient(position + (direction * platformSizes[localIndex].z / 2), lookRotation); if (activateImmediately) { platform.Activate(); } int objectIndex = ObjectPool.instance.GetObjectIndexFromLocalIndex(localIndex, ObjectType.Platform); BasicObject prevTopPlatform = ObjectHistory.instance.ObjectSpawned(objectIndex, 0, locationDirection, lookRotation.eulerAngles.y, ObjectType.Platform, platform); // the current platform now becames the parent of the previous top platform if (prevTopPlatform != null) { prevTopPlatform.SetObjectParent(platform); } else { ObjectHistory.instance.SetBottomObject(locationDirection, IS_PLATFORM, platform); } ObjectHistory.instance.AddTotalDistance(platformSizes[localIndex].z, locationDirection, IS_PLATFORM, spawnData.section); return(platform); }