예제 #1
0
        void Spawn()
        {
            bool success = false;

            while (success != true)
            {
                int tempIndex = Random.Range(0, platforms.Length);
                if (!currentlyPlacedPlatformIndices.Exists(ele => ele == tempIndex))
                {
                    PlatformBehaviour temp        = platforms[currentlyPlacedPlatformIndices[currentlyPlacedPlatformIndices.Count - 1]];
                    float             prevObjMaxZ = temp.transform.position.z + (temp.transform.localScale.z / 2.0f);
                    float             zOffset     = prevObjMaxZ;
                    zOffset += Random.Range(minDistanceForGap, maxDistanceForGap);
                    currentlyPlacedPlatformIndices.Add(tempIndex);
                    Vector3 newPlacementPos = new Vector3(0, -1, zOffset + (platforms[tempIndex].transform.localScale.z / 2.0f));
                    platforms[tempIndex].transform.position = newPlacementPos;
                    success = true;
                    float nextObjMaxZ = platforms[tempIndex].transform.position.z + (platforms[tempIndex].transform.localScale.z / 2.0f);
                }
            }
        }
예제 #2
0
 public void RemoveExistingPlatform(PlatformBehaviour platform)
 {
     platform.transform.position = Vector3.one * 200;
     currentlyPlacedPlatformIndices.Remove(platform.indexInList);
     Spawn();
 }