private void UpdateVelocities()
        {
            Rigidbody2D physicsBodyFront = front.GetComponent <Rigidbody2D>();

            Assert.IsTrue(physicsBodyFront != null, "Front part does not have a RigidBody2D.");
            Rigidbody2D physicsBodyBack = back.GetComponent <Rigidbody2D>();

            Assert.IsTrue(physicsBodyBack != null, "Back part does not have a RigidBody2D.");
            physicsBodyFront.velocity = speed * Vector2.left;
            physicsBodyBack.velocity  = speed * Vector2.left;
        }
        private TiledMap LoadNextMapPart(float baseX)
        {
            string partFile;

            if (partsLoaded < partsStart.Count)
            {
                partFile = partsStart[partsLoaded];
            }
            else if (partsLoaded < 6)
            {
                partFile = partsEasy[Random.Range(0, partsEasy.Count)];
            }
            else if (partsLoaded < 12)
            {
                // 50/50 chance of getting an easy or medium part
                if (Random.Range(0, 1) == 1)
                {
                    partFile = partsEasy[Random.Range(0, partsEasy.Count)];
                }
                else
                {
                    partFile = partsMed[Random.Range(0, partsMed.Count)];
                }
            }
            else
            {
                partFile = partsMed[Random.Range(0, partsMed.Count)];
            }

            string     partPath     = partsDirectory + "/" + partFile;
            GameObject partPrefabGO = Resources.Load(partPath) as GameObject;

            Assert.IsTrue(partPrefabGO != null, "The part prefab does not exist! Path:" + partPath);
            TiledMap partPrefab = partPrefabGO.GetComponent <TiledMap>();

            Assert.IsTrue(partPrefab != null, "The part prefab does not have a TiledMap component.");

            TiledMap part = Instantiate(partPrefab, new Vector3(baseX, partPrefab.GetMapHeightInPixelsScaled() / 2), Quaternion.identity, transform);

            Rigidbody2D physicsBody = part.GetComponent <Rigidbody2D>();

            Assert.IsTrue(physicsBody != null, "The map '" + partPath + "' needs to have a Rigidbody2D.");
            physicsBody.velocity = speed * Vector2.left;

            partsLoaded += 1;

            return(part);
        }