public void AssignParent(InfiniteObject infiniteObject, ObjectType objectType) { switch (objectType) { case ObjectType.Platform: infiniteObject.SetParent(platformParent); break; case ObjectType.Scene: infiniteObject.SetParent(sceneParent); break; case ObjectType.Obstacle: infiniteObject.SetParent(obstacleParent); break; case ObjectType.Coin: infiniteObject.SetParent(coinParent); break; case ObjectType.PowerUp: infiniteObject.SetParent(powerUpParent); break; } }
// 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); }
public virtual void deactivate() { if (destroyOnDeactivation) { // don't destroy the collision particle effect ParticleSystem[] particleSystems = GetComponentsInChildren <ParticleSystem>(); if (PlayerController.instance) { ParticleSystem collisionParticleSystem = PlayerController.instance.collisionParticleSystem; for (int i = 0; i < particleSystems.Length; ++i) { if (particleSystems[i] == collisionParticleSystem) { particleSystems[i].transform.parent = null; } } } Destroy(gameObject); return; } thisTransform.parent = startParent; infiniteObjectParent = null; #if UNITY_3_5 thisGameObject.SetActiveRecursively(false); #else thisGameObject.SetActive(false); #endif }
// 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); }
// the player hit a turn, start generating new objects public bool UpdateSpawnDirection(Vector3 newDirection, bool setMoveDirection, bool rightTurn, bool playerAboveTurn, out Vector3 turnOffset) { turnOffset = Vector3.zero; // Don't set the move direction above a curve because the cuve will set the direction if (setMoveDirection) { moveDirection = newDirection; } // don't change spawn directions if the player isn't above a turn. The game is about to be over anyway so there isn't a reason to keep generating objects if (!playerAboveTurn) { stopObjectSpawns = true; return(false); } float yAngle = Quaternion.LookRotation(newDirection).eulerAngles.y; if ((rightTurn && Mathf.Abs(yAngle - infiniteObjectHistory.GetObjectLocationAngle(ObjectLocation.Right)) < 0.01f) || (!rightTurn && Mathf.Abs(yAngle - infiniteObjectHistory.GetObjectLocationAngle(ObjectLocation.Left)) < 0.01f)) { spawnDirection = newDirection; wrongMoveDistance = 0; ObjectLocation turnLocation = (rightTurn ? ObjectLocation.Right : ObjectLocation.Left); turnPlatform[(int)ObjectLocation.Center] = turnPlatform[(int)turnLocation]; turnPlatform[(int)ObjectLocation.Right] = turnPlatform[(int)ObjectLocation.Left] = null; turnIndex[(int)ObjectLocation.Center] = turnIndex[(int)turnLocation]; turnScene[(int)ObjectLocation.Center] = turnScene[(int)turnLocation]; turnScene[(int)ObjectLocation.Right] = turnScene[(int)ObjectLocation.Left] = null; sceneTurnIndex[(int)ObjectLocation.Center] = sceneTurnIndex[(int)turnLocation]; // The center objects and the objects in the location opposite of turn are grouped together with the center object being the top most object for (int i = 0; i < 2; ++i) { InfiniteObject infiniteObject = infiniteObjectHistory.GetTopInfiniteObject((turnLocation == ObjectLocation.Right ? ObjectLocation.Left : ObjectLocation.Right), i == 0); // may be null if the turn only turns one direction if (infiniteObject != null) { InfiniteObject centerObject = infiniteObjectHistory.GetBottomInfiniteObject(ObjectLocation.Center, i == 0); infiniteObject.SetInfiniteObjectParent(centerObject); } } infiniteObjectHistory.Turn(turnLocation); if (turnPlatform[(int)ObjectLocation.Center] != null) { infiniteObjectHistory.ResetTurnCount(); } turnOffset = GetTurnOffset(); return(true); } // Set the move direction even if the turn is a curve so the infinite objects will move in the opposite direciton of the player moveDirection = newDirection; return(false); }
public override void assignIndexToObject(InfiniteObject infiniteObject, int index) { base.assignIndexToObject(infiniteObject, index); for (int i = 0; i < avoidPlatforms.Count; ++i) { if (avoidPlatforms[i].assignIndexToObject(infiniteObject, index)) break; } }
public bool AssignIndexToObject(InfiniteObject infiniteObject, int index) { if (infiniteObject == platform) { platformIndex = index; return(true); } return(false); }
// the player has turned left or right. Replace the center values with the corresponding turn values if they aren't -1 public void turn(ObjectLocation location) { for (int i = 0; i < objectSpawnIndex[(int)ObjectLocation.Center].Count; ++i) { lastObjectSpawnDistance[(int)ObjectLocation.Center][i] = lastObjectSpawnDistance[(int)location][i]; if (objectSpawnIndex[(int)location][i] != -1) { objectSpawnIndex[(int)ObjectLocation.Center][i] = objectSpawnIndex[(int)location][i]; } } for (int i = 0; i < (int)ObjectLocation.Last; ++i) { if (objectTypeSpawnIndex[(int)location][i] != -1) { objectTypeSpawnIndex[(int)ObjectLocation.Center][i] = objectTypeSpawnIndex[(int)location][i]; } lastLocalIndex[(int)ObjectLocation.Center][i] = lastLocalIndex[(int)location][i]; latestObjectTypeSpawnDistance[(int)ObjectLocation.Center][i] = latestObjectTypeSpawnDistance[(int)location][i]; } totalDistance[(int)ObjectLocation.Center] = totalDistance[(int)location]; totalSceneDistance[(int)ObjectLocation.Center] = totalSceneDistance[(int)location]; platformDistanceIndexMap[(int)ObjectLocation.Center] = platformDistanceIndexMap[(int)location]; spawnedPlatformSectionTransition[(int)ObjectLocation.Center] = spawnedPlatformSectionTransition[(int)location]; spawnedSceneSectionTransition[(int)ObjectLocation.Center] = spawnedSceneSectionTransition[(int)location]; // use the center location if there aren't any objects in the location across from the turn location ObjectLocation acrossLocation = (location == ObjectLocation.Right ? ObjectLocation.Left : ObjectLocation.Right); if (bottomPlatformObjectSpawned[(int)acrossLocation] == null) { acrossLocation = ObjectLocation.Center; } bottomTurnPlatformObjectSpawned = bottomPlatformObjectSpawned[(int)acrossLocation]; bottomTurnSceneObjectSpawned = bottomSceneObjectSpawned[(int)acrossLocation]; topTurnPlatformObjectSpawned = topPlatformObjectSpawned[(int)ObjectLocation.Center]; topTurnSceneObjectSpawned = topSceneObjectSpawned[(int)ObjectLocation.Center]; topPlatformObjectSpawned[(int)ObjectLocation.Center] = topPlatformObjectSpawned[(int)location]; bottomPlatformObjectSpawned[(int)ObjectLocation.Center] = bottomPlatformObjectSpawned[(int)location]; topSceneObjectSpawned[(int)ObjectLocation.Center] = topSceneObjectSpawned[(int)location]; bottomSceneObjectSpawned[(int)ObjectLocation.Center] = bottomSceneObjectSpawned[(int)location]; for (int i = (int)ObjectLocation.Left; i < (int)ObjectLocation.Last; ++i) { topPlatformObjectSpawned[i] = null; bottomPlatformObjectSpawned[i] = null; topSceneObjectSpawned[i] = null; bottomSceneObjectSpawned[i] = null; } }
public void setTopInfiniteObject(ObjectLocation location, bool isSceneObject, InfiniteObject infiniteObject) { if (isSceneObject) { topSceneObjectSpawned[(int)location] = infiniteObject; } else { topPlatformObjectSpawned[(int)location] = infiniteObject; } }
public static int addPlatform(List<PlatformPlacementRule> platformPlacementRules, InfiniteObject platform, bool linkedPlatform) { // Make sure there aren't any duplicates for (int i = 0; i < platformPlacementRules.Count; ++i) { if (platformPlacementRules[i].platform == platform) return 2; } platformPlacementRules.Add(new PlatformPlacementRule(platform, linkedPlatform)); return 0; }
// the bottom infinite object only needs to be set for the very first object at the object location.. objectRemoved will otherwise take care of making sure the // bottom object is correct public void SetBottomInfiniteObject(ObjectLocation location, bool isSceneObject, InfiniteObject infiniteObject) { if (isSceneObject) { bottomSceneObjectSpawned[(int)location] = infiniteObject; } else { bottomPlatformObjectSpawned[(int)location] = infiniteObject; } }
public virtual void AssignIndexToObject(InfiniteObject infiniteObject, int index) { for (int i = 0; i < avoidObjectRuleMaps.Count; ++i) { avoidObjectRuleMaps[i].AssignIndexToObject(infiniteObject, index); } for (int i = 0; i < probabilityAdjustmentMaps.Count; ++i) { probabilityAdjustmentMaps[i].AssignIndexToObject(infiniteObject, index); } }
public override void assignIndexToObject(InfiniteObject infiniteObject, int index) { base.assignIndexToObject(infiniteObject, index); for (int i = 0; i < avoidPlatforms.Count; ++i) { if (avoidPlatforms[i].assignIndexToObject(infiniteObject, index)) { break; } } }
public override void assignIndexToObject(InfiniteObject infiniteObject, int index) { base.assignIndexToObject(infiniteObject, index); for (int i = 0; i < linkedPlatforms.Count; ++i) { if (linkedPlatforms[i].assignIndexToObject(infiniteObject, index)) { (infiniteObject as PlatformObject).enableLinkedSceneObjectRequired(); break; } } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUILayout.Label("Sections:"); InfiniteObject infiniteObject = (InfiniteObject)target; List <int> sections = infiniteObject.sections; if (SectionSelectionInspector.showSections(ref sections, false)) { infiniteObject.sections = sections; EditorUtility.SetDirty(target); } }
// Returns the specified object from the pool public InfiniteObject ObjectFromPool(int localIndex, ObjectType objectType) { InfiniteObject obj = null; int objectIndex = LocalIndexToObjectIndex(localIndex, objectType); List <InfiniteObject> objectPool = objectsPool[objectIndex]; int poolIndex = objectPoolIndex[objectIndex]; // keep a start index to prevent the constant pushing and popping from the list if (objectPool.Count > 0 && objectPool[poolIndex].IsActive() == false) { obj = objectPool[poolIndex]; objectPoolIndex[objectIndex] = (poolIndex + 1) % objectPool.Count; return(obj); } // No inactive objects, need to instantiate a new one InfiniteObject[] objects = null; switch (objectType) { case ObjectType.Platform: objects = platforms; break; case ObjectType.Scene: objects = scenes; break; case ObjectType.Obstacle: objects = obstacles; break; case ObjectType.Coin: objects = coins; break; case ObjectType.PowerUp: objects = powerUps; break; } obj = (GameObject.Instantiate(objects[localIndex].gameObject) as GameObject).GetComponent <InfiniteObject>(); AssignParent(obj, objectType); obj.SetLocalIndex(localIndex); objectPool.Insert(poolIndex, obj); objectPoolIndex[objectIndex] = (poolIndex + 1) % objectPool.Count; return(obj); }
public override void AssignIndexToObject(InfiniteObject infiniteObject, int index) { base.AssignIndexToObject(infiniteObject, index); for (int i = 0; i < linkedPlatforms.Count; ++i) { if (linkedPlatforms[i].AssignIndexToObject(infiniteObject, index)) { PlatformObject platform = infiniteObject as PlatformObject; platform.EnableLinkedSceneObjectRequired(); (thisInfiniteObject as SceneObject).sectionTransition = platform.sectionTransition; break; } } }
// remove the saved infinite objects and activate the set of objects for the next game public void ReadyFromReset() { // deactivate the saved infinite objects from the previous game InfiniteObject infiniteObject = infiniteObjectHistory.GetSavedInfiniteObjects(); InfiniteObject[] childObjects = null; for (int i = 0; i < 2; ++i) // loop through the platform and scenes { if (i == 0) // scene { childObjects = infiniteObject.GetComponentsInChildren <SceneObject>(true); } else { childObjects = infiniteObject.GetComponentsInChildren <PlatformObject>(true); } for (int j = 0; j < childObjects.Length; ++j) { childObjects[j].Deactivate(); } } // activate the objects for the current game for (int i = 0; i < 2; ++i) // loop through the platform and scenes { for (int j = 0; j < (int)ObjectLocation.Last; ++j) { infiniteObject = infiniteObjectHistory.GetTopInfiniteObject((ObjectLocation)j, i == 0); if (infiniteObject != null) { if (i == 0) // scene { childObjects = infiniteObject.GetComponentsInChildren <SceneObject>(true); } else { childObjects = infiniteObject.GetComponentsInChildren <PlatformObject>(true); } for (int k = 0; k < childObjects.Length; ++k) { childObjects[k].Activate(); } } } } }
public bool AssignIndexToObject(InfiniteObject obj, int index) { if (targetObject == null) { return(false); } if (obj == targetObject) { targetObjectIndex = index; targetObjectIsScene = targetObject.GetObjectType() == ObjectType.Scene; return(true); } return(false); }
// turn the player to the specified location public Vector3 changeMoveDirection(Vector3 newDirection, bool rotateRight) { if (turnPlatform[(int)ObjectLocation.Center] != null) { turnOffset += moveDirection * (turnPlatform[(int)ObjectLocation.Center].turnLengthOffset + localDistance[(int)ObjectLocation.Center]); } moveDirection = newDirection; // don't change move directions if there are still turn objects. It is about to be game over anyway since multiple turns aren't supported this closely if (infiniteObjectHistory.getBottomTurnInfiniteObject(true)) { stopObjectSpawns = true; return(turnOffset); } ObjectLocation turnLocation = (rotateRight ? ObjectLocation.Right : ObjectLocation.Left); localDistance[(int)ObjectLocation.Center] = localDistance[(int)turnLocation]; localSceneDistance[(int)ObjectLocation.Center] = localSceneDistance[(int)turnLocation]; localPlatformHeight[(int)ObjectLocation.Center] = localPlatformHeight[(int)turnLocation]; localSceneHeight[(int)ObjectLocation.Center] = localSceneHeight[(int)turnLocation]; turnPlatform[(int)ObjectLocation.Center] = turnPlatform[(int)turnLocation]; turnPlatform[(int)ObjectLocation.Right] = turnPlatform[(int)ObjectLocation.Left] = null; // The center objects and the objects in the location opposite of turn are grouped togeter with the center object being the top most object for (int i = 0; i < 2; ++i) { InfiniteObject infiniteObject = infiniteObjectHistory.getTopInfiniteObject((turnLocation == ObjectLocation.Right ? ObjectLocation.Left : ObjectLocation.Right), i == 0); // may be null if the turn only turns one direction if (infiniteObject != null) { InfiniteObject centerObject = infiniteObjectHistory.getBottomInfiniteObject(ObjectLocation.Center, i == 0); infiniteObject.setInfiniteObjectParent(centerObject); } } infiniteObjectHistory.turn(turnLocation); if (turnPlatform[(int)ObjectLocation.Center] != null) { setupPlatformTurn(); } return(turnOffset); }
public virtual void Init() { infiniteObjectHistory = InfiniteObjectHistory.instance; thisInfiniteObject = GetComponent <InfiniteObject>(); ObjectType objectType = thisInfiniteObject.GetObjectType(); for (int i = 0; i < avoidObjectRuleMaps.Count; ++i) { avoidObjectRuleMaps[i].Init(infiniteObjectHistory, objectType); } for (int i = 0; i < probabilityAdjustmentMaps.Count; ++i) { probabilityAdjustmentMaps[i].Init(infiniteObjectHistory, objectType); } }
public void TurnObjectRemoved(bool isSceneObject) { if (isSceneObject) { bottomTurnSceneObjectSpawned = bottomTurnSceneObjectSpawned.GetInfiniteObjectParent(); if (bottomTurnSceneObjectSpawned == null) { topTurnSceneObjectSpawned = null; } } else { bottomTurnPlatformObjectSpawned = bottomTurnPlatformObjectSpawned.GetInfiniteObjectParent(); if (bottomTurnPlatformObjectSpawned == null) { topTurnPlatformObjectSpawned = null; } } }
// returns true if there is still space on the platform for a collidable object to spawn private void spawnCollidable(ObjectType objectType, Vector3 position, Vector3 direction, ObjectLocation location, PlatformObject platform, int platformLocalIndex, bool activateImmediately) { int collidablePositions = platform.collidablePositions; // can't do anything if the platform doesn't accept any collidable object spawns if (collidablePositions == 0) { return; } Vector3 offset = platformSizes[platformLocalIndex] * 0.1f; float zDelta = platformSizes[platformLocalIndex].z * .8f / (1 + collidablePositions); for (int i = 0; i < collidablePositions; ++i) { if (platform.canSpawnCollidable(i)) { int localIndex = infiniteObjectManager.getNextObjectIndex(objectType, spawnData); if (localIndex != -1) { InfiniteObject collidable = infiniteObjectManager.objectFromPool(localIndex, objectType); collidable.orient(platform, position + (offset.z + ((i + 1) * zDelta)) * direction + platform.getRandomSlot() * slotDistance, Quaternion.LookRotation(direction)); int objectIndex = infiniteObjectManager.localIndexToObjectIndex(localIndex, objectType); infiniteObjectHistory.objectSpawned(objectIndex, (offset.z + ((i + 1) * zDelta)), location, objectType); platform.collidableSpawned(i); if (activateImmediately) { collidable.activate(); } // don't allow any more of the same collidable type if we are forcing a different collidable if (platform.forceDifferentCollidableTypes) { break; } } } } }
// spawn a scene object at the specified location private void spawnSceneObject(int localIndex, ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately) { SceneObject scene = (SceneObject)infiniteObjectManager.objectFromPool(localIndex, ObjectType.Scene); scene.orient(position + direction * sceneSizes[localIndex].z / 2, Quaternion.LookRotation(direction)); localSceneDistance[(int)location] += sceneSizes[localIndex].z; int assocaitedPlatformLocalIndex = infiniteObjectHistory.getFirstPlatformIndex(); PlatformObject associatedPlatform = infiniteObjectManager.localIndexToInfiniteObject(assocaitedPlatformLocalIndex, ObjectType.Platform) as PlatformObject; if (associatedPlatform.slope != PlatformSlope.None) { localSceneHeight[(int)location] += platformSizes[assocaitedPlatformLocalIndex].y; } int objectIndex = infiniteObjectManager.localIndexToObjectIndex(localIndex, ObjectType.Scene); InfiniteObject prevTopScene = infiniteObjectHistory.objectSpawned(objectIndex, 0, location, 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); if (scene.sectionTransition) { infiniteObjectHistory.didSpawnSectionTranition(location, true); } if (activateImmediately) { scene.activate(); } }
// Keep track of the object spawned. Returns the previous object at the top position public InfiniteObject objectSpawned(int index, float locationOffset, ObjectLocation location, ObjectType objectType, InfiniteObject infiniteObject = null) { lastObjectSpawnDistance[(int)location][index] = (objectType == ObjectType.Scene ? totalSceneDistance[(int)location] : totalDistance[(int)location]) + locationOffset; objectTypeSpawnIndex[(int)location][(int)objectType] += 1; objectSpawnIndex[(int)location][index] = objectTypeSpawnIndex[(int)location][(int)objectType]; latestObjectTypeSpawnDistance[(int)location][(int)objectType] = lastObjectSpawnDistance[(int)location][index]; lastLocalIndex[(int)location][(int)objectType] = infiniteObjectManager.objectIndexToLocalIndex(index, objectType); InfiniteObject prevTopObject = null; if (objectType == ObjectType.Platform) { prevTopObject = topPlatformObjectSpawned[(int)location]; topPlatformObjectSpawned[(int)location] = infiniteObject; } else if (objectType == ObjectType.Scene) { prevTopObject = topSceneObjectSpawned[(int)location]; topSceneObjectSpawned[(int)location] = infiniteObject; } return(prevTopObject); }
public override void OnInspectorGUI() { List<ObjectRuleMap> appearanceRules = ((AppearanceRules)target).avoidObjectRuleMaps; if (appearanceRules != null && appearanceRules.Count > 0) { GUILayout.Label("Avoid Object Rules", "BoldLabel"); showAppearanceRules(appearanceRules, true); } appearanceRules = ((AppearanceRules)target).probabilityAdjustmentMaps; if (appearanceRules != null && appearanceRules.Count > 0) { GUILayout.Label("Probability Adjustment Rules", "BoldLabel"); showAppearanceRules(appearanceRules, false); } if (addNewRule) { avoidObjectRule = GUILayout.SelectionGrid((avoidObjectRule ? 0 : 1), ruleTypeStrings, 2) == 0; minDistanceSameObjectType = GUILayout.Toggle(minDistanceSameObjectType, "Use Min Distance with same Object Type"); GUILayout.BeginHorizontal(); GUILayout.Label("Min Distance", GUILayout.Width(150)); string stringValue = GUILayout.TextField(minDistance.ToString()); try { minDistance = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Min Object Separation", GUILayout.Width(150)); stringValue = GUILayout.TextField(minObjectSeperation.ToString()); try { minObjectSeperation = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Target Object"); targetObject = EditorGUILayout.ObjectField(targetObject, typeof(InfiniteObject), false) as InfiniteObject; GUILayout.EndHorizontal(); useEndDistance = GUILayout.Toggle(useEndDistance, "Use End Distance"); GUILayout.BeginHorizontal(); GUILayout.Label("Start Distance", GUILayout.Width(120)); stringValue = GUILayout.TextField(startDistance.ToString()); try { startDistance = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); if (avoidObjectRule && useEndDistance) { GUILayout.BeginHorizontal(); GUILayout.Label("End Distance", GUILayout.Width(120)); stringValue = GUILayout.TextField(endDistance.ToString()); try { endDistance = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); } else if (!avoidObjectRule) { GUILayout.BeginHorizontal(); GUILayout.Label("Start Probability Adj", GUILayout.Width(120)); stringValue = GUILayout.TextField(startProbability.ToString()); try { startProbability = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); if (useEndDistance) { GUILayout.BeginHorizontal(); GUILayout.Label("End Distance", GUILayout.Width(120)); stringValue = GUILayout.TextField(endDistance.ToString()); try { endDistance = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("End Probability Adj", GUILayout.Width(120)); stringValue = GUILayout.TextField(endProbability.ToString()); try { endProbability = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); } } if (addError.Length > 0) { GUI.contentColor = Color.red; GUILayout.Label(addError); GUI.contentColor = Color.white; } GUILayout.BeginHorizontal(); if (GUILayout.Button("Add")) { int error; if ((error = addRule()) == 0) { addNewRule = false; } else { switch (error) { case 1: addError = "Error: start distance must be\ngreater than end distance"; break; case 2: addError = "Error: Target Object is not set"; break; case 3: addError = "Error: Both Min Distance and\nMin Object Seperation are 0"; break; case 4: addError = "Error: the rule distances overlap\na different set of rule distances"; break; case 5: addError = "Error: another rule already exists\nwhich does not have the end distance set"; break; default: addError = "Unknown Error"; break; } } } if (GUILayout.Button("Cancel")) { addNewRule = false; } GUILayout.EndHorizontal(); } if (!addNewRule && GUILayout.Button("New Rule")) { addError = ""; addNewRule = true; } }
public virtual void deactivate() { if (destroyOnDeactivation) { // don't destroy the collision particle effect ParticleSystem[] particleSystems = GetComponentsInChildren<ParticleSystem>(); if (PlayerController.instance) { ParticleSystem collisionParticleSystem = PlayerController.instance.collisionParticleSystem; for (int i = 0; i < particleSystems.Length; ++i) { if (particleSystems[i] == collisionParticleSystem) particleSystems[i].transform.parent = null; } } Destroy(gameObject); return; } thisTransform.parent = startParent; infiniteObjectParent = null; if (optimizeDeactivation) { foreach (Renderer child in childRenderers) child.enabled = false; foreach (Collider child in childColliders) child.enabled = false; enabled = false; } else { #if UNITY_3_5 thisGameObject.SetActiveRecursively(false); #else InfiniteRunnerStarterPackUtility.ActiveRecursively(thisTransform, false); #endif } }
// 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; if (moveDirection != spawnDirection) { wrongMoveDistance += 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 (playerTransform.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 (heightReposition && i == 1) // 1 are platforms { platformObject = infiniteObject as PlatformObject; if (platformObject.slope != PlatformSlope.None) { TransitionHeight(platformSizes[platformObject.GetLocalIndex()].y); } } if (turnPlatform[j] == infiniteObject) { turnPlatform[j] = null; } 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 (playerTransform.InverseTransformPoint(infiniteObject.GetTransform().position).z < removeHorizon) { infiniteObjectHistory.TurnObjectRemoved(i == 0); infiniteObject.Deactivate(); } } } if (!stopObjectSpawns) { dataManager.AddToScore(moveDistance); SpawnObjectRun(true); } }
// the bottom infinite object only needs to be set for the very first object at the object location.. objectRemoved will otherwise take care of making sure the // bottom object is correct public void setBottomInfiniteObject(ObjectLocation location, bool isSceneObject, InfiniteObject infiniteObject) { if (isSceneObject) { bottomSceneObjectSpawned[(int)location] = infiniteObject; } else { bottomPlatformObjectSpawned[(int)location] = infiniteObject; } }
// An object run contains many platforms strung together with collidables: obstacles, power ups, and coins. If spawnObjectRun encounters a turn, // it will spawn the objects in the correct direction public void SpawnObjectRun(bool activateImmediately) { // spawn the center objects InfiniteObject prevPlatform = infiniteObjectHistory.GetTopInfiniteObject(ObjectLocation.Center, false); while ((prevPlatform == null || (Vector3.Scale(prevPlatform.GetTransform().position, spawnDirection)).sqrMagnitude < sqrHorizon) && (turnPlatform[(int)ObjectLocation.Center] == null || turnPlatform[(int)ObjectLocation.Center].straight)) { Vector3 position = Vector3.zero; if (prevPlatform != null) { int prevPlatformIndex = infiniteObjectHistory.GetLastLocalIndex(ObjectLocation.Center, ObjectType.Platform); position = prevPlatform.GetTransform().position - GetPrevPlatformStartPosition(prevPlatform, prevPlatformIndex, spawnDirection) + platformSizes[prevPlatformIndex].z / 2 * spawnDirection + platformSizes[prevPlatformIndex].y * Vector3.up; } PlatformObject platform = SpawnObjects(ObjectLocation.Center, position, spawnDirection, activateImmediately); if (platform == null) { return; } PlatformSpawned(platform, ObjectLocation.Center, spawnDirection, activateImmediately); prevPlatform = infiniteObjectHistory.GetTopInfiniteObject(ObjectLocation.Center, false); if (spawnFullLength) { SpawnObjectRun(activateImmediately); } } // spawn the left and right objects if (turnPlatform[(int)ObjectLocation.Center] != null) { Vector3 turnDirection = turnPlatform[(int)ObjectLocation.Center].GetTransform().right; // spawn the platform and scene objects for the left and right turns for (int i = 0; i < 2; ++i) { ObjectLocation location = (i == 0 ? ObjectLocation.Right : ObjectLocation.Left); bool canSpawn = (location == ObjectLocation.Right && turnPlatform[(int)ObjectLocation.Center].rightTurn) || (location == ObjectLocation.Left && turnPlatform[(int)ObjectLocation.Center].leftTurn); if (canSpawn && turnPlatform[(int)location] == null) { prevPlatform = infiniteObjectHistory.GetTopInfiniteObject(location, false); if (prevPlatform == null || (Vector3.Scale(prevPlatform.GetTransform().position, turnDirection)).sqrMagnitude < sqrHorizon) { infiniteObjectHistory.SetActiveLocation(location); Vector3 position = Vector3.zero; if (prevPlatform != null) { int prevPlatformIndex = infiniteObjectHistory.GetLastLocalIndex(location, ObjectType.Platform); position = prevPlatform.GetTransform().position - GetPrevPlatformStartPosition(prevPlatform, prevPlatformIndex, turnDirection) + platformSizes[prevPlatformIndex].z / 2 * turnDirection + platformSizes[prevPlatformIndex].y * Vector3.up; } else { PlatformObject centerTurn = turnPlatform[(int)ObjectLocation.Center]; int centerTurnIndex = turnIndex[(int)ObjectLocation.Center]; position = centerTurn.GetTransform().position - platformStartPosition[centerTurnIndex].x * turnDirection - Vector3.up * platformStartPosition[centerTurnIndex].y - platformStartPosition[centerTurnIndex].z * spawnDirection + centerTurn.centerOffset.x * turnDirection + centerTurn.centerOffset.z * spawnDirection + platformSizes[centerTurnIndex].y * Vector3.up; } PlatformObject platform = SpawnObjects(location, position, turnDirection, activateImmediately); if (platform == null) { return; } PlatformSpawned(platform, location, turnDirection, activateImmediately); } } turnDirection *= -1; } // reset infiniteObjectHistory.SetActiveLocation(ObjectLocation.Center); } }
public override void OnInspectorGUI() { List <ObjectRuleMap> appearanceRules = ((AppearanceRules)target).avoidObjectRuleMaps; GUILayout.Label("Avoid Object Rules", "BoldLabel"); if (appearanceRules != null && appearanceRules.Count > 0) { ShowAppearanceRules(appearanceRules, true); } else { GUILayout.Label("No rules"); } appearanceRules = ((AppearanceRules)target).probabilityAdjustmentMaps; GUILayout.Label("Probability Adjustment Rules", "BoldLabel"); if (appearanceRules != null && appearanceRules.Count > 0) { ShowAppearanceRules(appearanceRules, false); } else { GUILayout.Label("No rules"); } if (addNewRule) { avoidObjectRule = GUILayout.SelectionGrid((avoidObjectRule ? 0 : 1), ruleTypeStrings, 2) == 0; minDistanceSameObjectType = GUILayout.Toggle(minDistanceSameObjectType, "Use Min Distance with same Object Type"); GUILayout.BeginHorizontal(); GUILayout.Label("Min Distance", GUILayout.Width(150)); string stringValue = GUILayout.TextField(minDistance.ToString()); try { minDistance = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Min Object Separation", GUILayout.Width(150)); stringValue = GUILayout.TextField(minObjectSeperation.ToString()); try { minObjectSeperation = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Target Object"); targetObject = EditorGUILayout.ObjectField(targetObject, typeof(InfiniteObject), false) as InfiniteObject; GUILayout.EndHorizontal(); useEndDistance = GUILayout.Toggle(useEndDistance, "Use End Distance"); GUILayout.BeginHorizontal(); GUILayout.Label("Start Distance", GUILayout.Width(120)); stringValue = GUILayout.TextField(startDistance.ToString()); try { startDistance = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); if (avoidObjectRule && useEndDistance) { GUILayout.BeginHorizontal(); GUILayout.Label("End Distance", GUILayout.Width(120)); stringValue = GUILayout.TextField(endDistance.ToString()); try { endDistance = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); } else if (!avoidObjectRule) { if (!forceOccurance) { GUILayout.BeginHorizontal(); GUILayout.Label("Start Probability Adj", GUILayout.Width(120)); stringValue = GUILayout.TextField(startProbability.ToString()); try { startProbability = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); } if (useEndDistance) { GUILayout.BeginHorizontal(); GUILayout.Label("End Distance", GUILayout.Width(120)); stringValue = GUILayout.TextField(endDistance.ToString()); try { endDistance = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); if (!forceOccurance) { GUILayout.BeginHorizontal(); GUILayout.Label("End Probability Adj", GUILayout.Width(120)); stringValue = GUILayout.TextField(endProbability.ToString()); try { endProbability = int.Parse(stringValue); } catch (Exception) { } GUILayout.EndHorizontal(); } } forceOccurance = GUILayout.Toggle(forceOccurance, "Force Appearance"); } if (addError.Length > 0) { GUI.contentColor = Color.red; GUILayout.Label(addError); GUI.contentColor = Color.white; } GUILayout.BeginHorizontal(); if (GUILayout.Button("Add")) { int error; if ((error = AddRule()) == 0) { addNewRule = false; } else { switch (error) { case 1: addError = "Error: start distance must be\ngreater than end distance"; break; case 2: addError = "Error: Target Object is not set"; break; case 3: addError = "Error: Both Min Distance and\nMin Object Seperation are 0"; break; case 4: addError = "Error: the rule distances overlap\na different set of rule distances"; break; case 5: addError = "Error: another rule already exists\nwhich does not have the end distance set"; break; default: addError = "Unknown Error"; break; } } } if (GUILayout.Button("Cancel")) { addNewRule = false; } GUILayout.EndHorizontal(); } if (!addNewRule && GUILayout.Button("New Rule")) { addError = ""; addNewRule = true; } }
public PlatformPlacementRule(InfiniteObject p, bool c) { platform = p; canSpawn = c; }
// set everything back to 0 for a new game public void saveObjectsReset() { // save off the current objects. They will be deactivated after new objects have been sapwned if (topPlatformObjectSpawned[(int)ObjectLocation.Center] != null) { savedInfiniteObjects = topPlatformObjectSpawned[(int)ObjectLocation.Center]; for (int i = 0; i < (int)ObjectLocation.Last; ++i) { if (i != (int)ObjectLocation.Center && topPlatformObjectSpawned[i]) topPlatformObjectSpawned[i].setInfiniteObjectParent(savedInfiniteObjects); if (bottomPlatformObjectSpawned[i] != null) bottomPlatformObjectSpawned[i].setInfiniteObjectParent(savedInfiniteObjects); if (topSceneObjectSpawned[i] != null) topSceneObjectSpawned[i].setInfiniteObjectParent(savedInfiniteObjects); if (bottomSceneObjectSpawned[i] != null) bottomSceneObjectSpawned[i].setInfiniteObjectParent(savedInfiniteObjects); if (topTurnPlatformObjectSpawned != null) topTurnPlatformObjectSpawned.setInfiniteObjectParent(savedInfiniteObjects); } } else { // topPlatformObjectSpawned is null when the player turns the wrong way off of a turn savedInfiniteObjects = topTurnPlatformObjectSpawned; } if (bottomTurnPlatformObjectSpawned != null) bottomTurnPlatformObjectSpawned.setInfiniteObjectParent(savedInfiniteObjects); if (topTurnSceneObjectSpawned != null) topTurnSceneObjectSpawned.setInfiniteObjectParent(savedInfiniteObjects); if (bottomTurnSceneObjectSpawned != null) bottomTurnSceneObjectSpawned.setInfiniteObjectParent(savedInfiniteObjects); activeObjectLocation = ObjectLocation.Center; for (int i = 0; i < (int)ObjectLocation.Last; ++i) { totalDistance[i] = 0; totalSceneDistance[i] = 0; platformDistanceDataMap[i].reset(); objectLocationAngle[i] = 0; topPlatformObjectSpawned[i] = bottomPlatformObjectSpawned[i] = null; topSceneObjectSpawned[i] = bottomSceneObjectSpawned[i] = null; previousPlatformSection[i] = 0; previousSceneSection[i] = 0; spawnedSceneSectionTransition[i] = false; spawnedPlatformSectionTransition[i] = false; for (int j = 0; j < objectSpawnIndex[i].Count; ++j) { objectSpawnIndex[i][j] = -1; lastObjectSpawnDistance[i][j] = 0; } for (int j = 0; j < (int)ObjectType.Last; ++j) { objectTypeSpawnIndex[i][j] = -1; lastLocalIndex[i][j] = -1; latestObjectTypeSpawnDistance[i][j] = -1; } } topTurnPlatformObjectSpawned = bottomTurnPlatformObjectSpawned = null; topTurnSceneObjectSpawned = bottomTurnSceneObjectSpawned = null; }
public ObjectRuleMap(InfiniteObject io, ScoreObjectCountRule r) { targetObject = io; rules = new List <ScoreObjectCountRule>(); rules.Add(r); }
public bool assignIndexToObject(InfiniteObject infiniteObject, int index) { if (infiniteObject == platform) { platformIndex = index; return true; } return false; }
public void assignParent(InfiniteObject infiniteObject, ObjectType objectType) { switch (objectType) { case ObjectType.Platform: infiniteObject.setParent(platformParent); break; case ObjectType.Scene: infiniteObject.setParent(sceneParent); break; case ObjectType.Obstacle: infiniteObject.setParent(obstacleParent); break; case ObjectType.Coin: infiniteObject.setParent(coinParent); break; case ObjectType.PowerUp: infiniteObject.setParent(powerUpParent); break; } }
public void turnObjectRemoved(bool isSceneObject) { if (isSceneObject) { bottomTurnSceneObjectSpawned = bottomTurnSceneObjectSpawned.getInfiniteObjectParent(); if (bottomTurnSceneObjectSpawned == null) { topTurnSceneObjectSpawned = null; } } else { bottomTurnPlatformObjectSpawned = bottomTurnPlatformObjectSpawned.getInfiniteObjectParent(); if (bottomTurnPlatformObjectSpawned == null) { topTurnPlatformObjectSpawned = null; } } }
public static int addPlatform(List <PlatformPlacementRule> platformPlacementRules, InfiniteObject platform, bool linkedPlatform) { // Make sure there aren't any duplicates for (int i = 0; i < platformPlacementRules.Count; ++i) { if (platformPlacementRules[i].platform == platform) { return(2); } } platformPlacementRules.Add(new PlatformPlacementRule(platform, linkedPlatform)); return(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); }
public ObjectRuleMap(InfiniteObject io, ScoreObjectCountRule r) { targetObject = io; rules = new List<ScoreObjectCountRule>(); rules.Add(r); }
// Keep track of the object spawned. Returns the previous object at the top position public InfiniteObject objectSpawned(int index, float locationOffset, ObjectLocation location, float angle, ObjectType objectType, InfiniteObject infiniteObject = null) { lastObjectSpawnDistance[(int)location][index] = (objectType == ObjectType.Scene ? totalSceneDistance[(int)location] : totalDistance[(int)location]) + locationOffset; objectTypeSpawnIndex[(int)location][(int)objectType] += 1; objectSpawnIndex[(int)location][index] = objectTypeSpawnIndex[(int)location][(int)objectType]; latestObjectTypeSpawnDistance[(int)location][(int)objectType] = lastObjectSpawnDistance[(int)location][index]; lastLocalIndex[(int)location][(int)objectType] = infiniteObjectManager.objectIndexToLocalIndex(index, objectType); InfiniteObject prevTopObject = null; if (objectType == ObjectType.Platform) { prevTopObject = topPlatformObjectSpawned[(int)location]; topPlatformObjectSpawned[(int)location] = infiniteObject; objectLocationAngle[(int)location] = angle; } else if (objectType == ObjectType.Scene) { prevTopObject = topSceneObjectSpawned[(int)location]; topSceneObjectSpawned[(int)location] = infiniteObject; } return prevTopObject; }
public bool assignIndexToObject(InfiniteObject obj, int index) { if (targetObject == null) { return false; } if (obj == targetObject) { targetObjectIndex = index; targetObjectIsScene = targetObject.getObjectType() == ObjectType.Scene; return true; } return false; }
// the player has turned. Replace the center values with the corresponding turn values if they aren't -1 public void turn(ObjectLocation location) { for (int i = 0; i < objectSpawnIndex[(int)ObjectLocation.Center].Count; ++i) { lastObjectSpawnDistance[(int)ObjectLocation.Center][i] = lastObjectSpawnDistance[(int)location][i]; if (objectSpawnIndex[(int)location][i] != -1) { objectSpawnIndex[(int)ObjectLocation.Center][i] = objectSpawnIndex[(int)location][i]; } } for (int i = 0; i < (int)ObjectLocation.Last; ++i) { if (objectTypeSpawnIndex[(int)location][i] != -1) { objectTypeSpawnIndex[(int)ObjectLocation.Center][i] = objectTypeSpawnIndex[(int)location][i]; } lastLocalIndex[(int)ObjectLocation.Center][i] = lastLocalIndex[(int)location][i]; latestObjectTypeSpawnDistance[(int)ObjectLocation.Center][i] = latestObjectTypeSpawnDistance[(int)location][i]; } totalDistance[(int)ObjectLocation.Center] = totalDistance[(int)location]; totalSceneDistance[(int)ObjectLocation.Center] = totalSceneDistance[(int)location]; objectLocationAngle[(int)ObjectLocation.Center] = objectLocationAngle[(int)location]; platformDistanceDataMap[(int)ObjectLocation.Center] = platformDistanceDataMap[(int)location]; previousPlatformSection[(int)ObjectLocation.Center] = previousPlatformSection[(int)location]; previousSceneSection[(int)ObjectLocation.Center] = previousSceneSection[(int)location]; spawnedPlatformSectionTransition[(int)ObjectLocation.Center] = spawnedPlatformSectionTransition[(int)location]; spawnedSceneSectionTransition[(int)ObjectLocation.Center] = spawnedSceneSectionTransition[(int)location]; // use the center location if there aren't any objects in the location across from the turn location ObjectLocation acrossLocation = (location == ObjectLocation.Right ? ObjectLocation.Left : ObjectLocation.Right); if (bottomPlatformObjectSpawned[(int)acrossLocation] == null) { acrossLocation = ObjectLocation.Center; } if (topTurnPlatformObjectSpawned != null) { topTurnPlatformObjectSpawned.setInfiniteObjectParent(topPlatformObjectSpawned[(int)ObjectLocation.Center]); } else { bottomTurnPlatformObjectSpawned = bottomPlatformObjectSpawned[(int)acrossLocation]; } topTurnPlatformObjectSpawned = topPlatformObjectSpawned[(int)ObjectLocation.Center]; if (topTurnSceneObjectSpawned != null) { topTurnSceneObjectSpawned.setInfiniteObjectParent(topSceneObjectSpawned[(int)ObjectLocation.Center]); } else { bottomTurnSceneObjectSpawned = bottomSceneObjectSpawned[(int)acrossLocation]; } topTurnSceneObjectSpawned = topSceneObjectSpawned[(int)ObjectLocation.Center]; topPlatformObjectSpawned[(int)ObjectLocation.Center] = topPlatformObjectSpawned[(int)location]; bottomPlatformObjectSpawned[(int)ObjectLocation.Center] = bottomPlatformObjectSpawned[(int)location]; topSceneObjectSpawned[(int)ObjectLocation.Center] = topSceneObjectSpawned[(int)location]; bottomSceneObjectSpawned[(int)ObjectLocation.Center] = bottomSceneObjectSpawned[(int)location]; for (int i = (int)ObjectLocation.Left; i < (int)ObjectLocation.Last; ++i) { topPlatformObjectSpawned[i] = null; bottomPlatformObjectSpawned[i] = null; topSceneObjectSpawned[i] = null; bottomSceneObjectSpawned[i] = null; } }
public virtual void init() { infiniteObjectHistory = InfiniteObjectHistory.instance; thisInfiniteObject = GetComponent<InfiniteObject>(); ObjectType objectType = thisInfiniteObject.getObjectType(); for (int i = 0; i < avoidObjectRuleMaps.Count; ++i) { avoidObjectRuleMaps[i].init(infiniteObjectHistory, objectType); } for (int i = 0; i < probabilityAdjustmentMaps.Count; ++i) { probabilityAdjustmentMaps[i].init(infiniteObjectHistory, objectType); } }
public void setInfiniteObjectParent(InfiniteObject parentObject) { infiniteObjectParent = parentObject; thisTransform.parent = parentObject.getTransform(); }
public virtual void assignIndexToObject(InfiniteObject infiniteObject, int index) { for (int i = 0; i < avoidObjectRuleMaps.Count; ++i) { avoidObjectRuleMaps[i].assignIndexToObject(infiniteObject, index); } for (int i = 0; i < probabilityAdjustmentMaps.Count; ++i) { probabilityAdjustmentMaps[i].assignIndexToObject(infiniteObject, index); } }
// 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; }