void Update() { if (!Changing && WallPool.GetDivisor().transform.position.y - PlayerTransform.position.y <= 2) { Changing = true; switch (CurrentSection) { case WorldSection.EARTH: CurrentSection = WorldSection.SKY; ChangeSection(WorldSection.SKY); WallPool.ChangeSection(WorldSection.SKY); break; case WorldSection.SKY: CurrentSection = WorldSection.EARTH; ChangeSection(WorldSection.EARTH); WallPool.ChangeSection(WorldSection.EARTH); break; } } }
//The pool will give us a wall, and it will pay for it void BuildAWall() { if (!SectionBuilt) { GameObject WallToBuild = pool.GetWall(); if (WallToBuild == null) { SectionBuilt = true; Divisor = pool.GetDivisor(); Divisor.transform.position = transform.position; Divisor.SetActive(true); return; } WallToBuild.transform.position = transform.position; //WallToBuild.transform.rotation = transform.rotation; WallToBuild.SetActive(true); ActiveWalls.Add(WallToBuild); newPosition.z += WallToBuild.GetComponent <WallCoordinates> ().ZSpawnerCoordinate; newPosition.y = transform.position.y + WallToBuild.GetComponent <WallCoordinates> ().YSpawnerCoordinate; transform.position = newPosition; } }