Merge
This commit is contained in:
commit
1064957555
@ -66,12 +66,16 @@ public class PlayerController : MonoBehaviour
|
|||||||
currentSpeed += 0.0005f;
|
currentSpeed += 0.0005f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetAxis("Vertical") > 0 && currentSpeed < maxSpeed) {
|
if (Input.GetAxis("Vertical") > 0 && currentSpeed < maxSpeed)
|
||||||
if (!canMove) {
|
{
|
||||||
|
if (!canMove)
|
||||||
|
{
|
||||||
canMove = true;
|
canMove = true;
|
||||||
}
|
}
|
||||||
currentSpeed += 0.01f;
|
currentSpeed += 0.01f;
|
||||||
} else if (Input.GetAxis("Vertical") < 0 && currentSpeed > minSpeed) {
|
}
|
||||||
|
else if (Input.GetAxis("Vertical") < 0 && currentSpeed > minSpeed)
|
||||||
|
{
|
||||||
currentSpeed -= 0.01f;
|
currentSpeed -= 0.01f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,9 +226,12 @@ public class PlayerController : MonoBehaviour
|
|||||||
modifier += platform.speed;
|
modifier += platform.speed;
|
||||||
break;
|
break;
|
||||||
case PlatformManager.PlatformType.SpeedDown:
|
case PlatformManager.PlatformType.SpeedDown:
|
||||||
if (modifier - platform.speed >= 0) {
|
if (modifier - platform.speed >= 0)
|
||||||
|
{
|
||||||
modifier -= platform.speed;
|
modifier -= platform.speed;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
modifier = 0.0f;
|
modifier = 0.0f;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -232,8 +239,10 @@ public class PlayerController : MonoBehaviour
|
|||||||
gDirection = -other.GetContact(0).normal;
|
gDirection = -other.GetContact(0).normal;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
gDirection = -other.GetContact(0).normal;
|
else
|
||||||
|
{
|
||||||
|
gDirection = -transform.up;
|
||||||
}
|
}
|
||||||
platformForward = other.transform.forward;
|
platformForward = other.transform.forward;
|
||||||
this.downDirection = gDirection;
|
this.downDirection = gDirection;
|
||||||
|
@ -10,13 +10,22 @@ public class ProceduralGeneration : MonoBehaviour
|
|||||||
public GameObject lastBlock;
|
public GameObject lastBlock;
|
||||||
private GameObject lastBlockPrefab;
|
private GameObject lastBlockPrefab;
|
||||||
private int spavnetobjectIndex = 0;
|
private int spavnetobjectIndex = 0;
|
||||||
|
private int maximumNumberOfPlatformsAtScene = 100;
|
||||||
|
private float maximumDistanceOfPlatformFromPlayer = 20.0f;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
|
GameObject drawPlatform(GameObject lastObject, GameObject objToSpawn)
|
||||||
{
|
{
|
||||||
lastBlockPrefab = this.gameObject.transform.GetChild(0).gameObject;
|
MeshFilter meshfilter = lastObject.GetComponent<MeshFilter>();
|
||||||
lastBlock = this.gameObject.transform.GetChild(0).gameObject;
|
Bounds bounds = meshfilter.mesh.bounds;
|
||||||
this.spawnedLevelBlocks.Add(lastBlock);
|
|
||||||
|
float scale = meshfilter.transform.localScale.x;
|
||||||
|
Bounds b = new Bounds(bounds.center * scale, bounds.size * scale);
|
||||||
|
|
||||||
|
Vector3 nextBlockLocation = new Vector3(lastObject.transform.position.x, lastObject.transform.position.y, lastObject.transform.position.z + b.size.z + 1.0f);
|
||||||
|
|
||||||
|
return Instantiate(objToSpawn, nextBlockLocation, (Quaternion.identity));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<GameObject> spawnSpiralOfPlatforms(GameObject lastObject, GameObject objToSpawn)
|
List<GameObject> spawnSpiralOfPlatforms(GameObject lastObject, GameObject objToSpawn)
|
||||||
@ -53,19 +62,23 @@ public class ProceduralGeneration : MonoBehaviour
|
|||||||
return levelBlocksSpawnTemp;
|
return levelBlocksSpawnTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
lastBlockPrefab = this.gameObject.transform.GetChild(0).gameObject;
|
||||||
|
lastBlock = this.gameObject.transform.GetChild(0).gameObject;
|
||||||
|
this.spawnedLevelBlocks.Add(lastBlock);
|
||||||
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
int maxNumberOfBlock = 200;
|
|
||||||
|
|
||||||
Vector3 playerPosition = this.player.transform.position;
|
Vector3 playerPosition = this.player.transform.position;
|
||||||
|
|
||||||
Debug.Log("Index" + 0);
|
|
||||||
|
|
||||||
for (var i = 0; i < this.spawnedLevelBlocks.Count; i++)
|
for (var i = 0; i < this.spawnedLevelBlocks.Count; i++)
|
||||||
{
|
{
|
||||||
float distance = Vector3.Distance(this.spawnedLevelBlocks[i].transform.position, playerPosition);
|
float distance = Vector3.Distance(this.spawnedLevelBlocks[i].transform.position, playerPosition);
|
||||||
if (distance > 10.0f && this.spawnedLevelBlocks.Count >= maxNumberOfBlock)
|
if (distance > this.maximumDistanceOfPlatformFromPlayer && this.spawnedLevelBlocks.Count >= this.maximumNumberOfPlatformsAtScene)
|
||||||
{
|
{
|
||||||
Destroy(this.spawnedLevelBlocks[i]);
|
Destroy(this.spawnedLevelBlocks[i]);
|
||||||
this.spawnedLevelBlocks.Remove(this.spawnedLevelBlocks[i]);
|
this.spawnedLevelBlocks.Remove(this.spawnedLevelBlocks[i]);
|
||||||
@ -78,7 +91,7 @@ public class ProceduralGeneration : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.spawnedLevelBlocks.Count <= maxNumberOfBlock)
|
if (this.spawnedLevelBlocks.Count <= this.maximumNumberOfPlatformsAtScene)
|
||||||
{
|
{
|
||||||
int blockToSpawn = Random.Range(0, levelBlocks.Count);
|
int blockToSpawn = Random.Range(0, levelBlocks.Count);
|
||||||
|
|
||||||
@ -97,15 +110,7 @@ public class ProceduralGeneration : MonoBehaviour
|
|||||||
|
|
||||||
if ((blockToSpawn > -1 && (blockToSpawn < (levelBlocks.Count - 1))))
|
if ((blockToSpawn > -1 && (blockToSpawn < (levelBlocks.Count - 1))))
|
||||||
{
|
{
|
||||||
MeshFilter meshfilter = this.lastBlock.GetComponent<MeshFilter>();
|
instantiatedGameObject = this.drawPlatform(this.lastBlock, this.levelBlocks[blockToSpawn]);
|
||||||
Bounds bounds = meshfilter.mesh.bounds;
|
|
||||||
|
|
||||||
float scale = meshfilter.transform.localScale.x;
|
|
||||||
Bounds b = new Bounds(bounds.center * scale, bounds.size * scale);
|
|
||||||
|
|
||||||
blockObjToSpawn = levelBlocks[blockToSpawn];
|
|
||||||
Vector3 nextBlockLocation = new Vector3(this.lastBlock.transform.position.x, this.lastBlock.transform.position.y, this.lastBlock.transform.position.z + b.size.z + 1.0f);
|
|
||||||
instantiatedGameObject = Instantiate(blockObjToSpawn, nextBlockLocation, (Quaternion.identity));
|
|
||||||
this.spawnedLevelBlocks.Add(instantiatedGameObject);
|
this.spawnedLevelBlocks.Add(instantiatedGameObject);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -120,7 +125,6 @@ public class ProceduralGeneration : MonoBehaviour
|
|||||||
blockObjToSpawn = levelBlocks[0];
|
blockObjToSpawn = levelBlocks[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log("Spawn" + blockToSpawn);
|
|
||||||
this.lastBlock = instantiatedGameObject;
|
this.lastBlock = instantiatedGameObject;
|
||||||
this.lastBlockPrefab = blockObjToSpawn;
|
this.lastBlockPrefab = blockObjToSpawn;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user