diff --git a/Platformer_001/Assets/Scripts/Endlosmodus/Endlosmodus.cs b/Platformer_001/Assets/Scripts/Endlosmodus/Endlosmodus.cs index 4a4328c..cd9ea22 100644 --- a/Platformer_001/Assets/Scripts/Endlosmodus/Endlosmodus.cs +++ b/Platformer_001/Assets/Scripts/Endlosmodus/Endlosmodus.cs @@ -18,6 +18,7 @@ public class Endlosmodus : MonoBehaviour { int maxDown=-4; [Range(0,1)] float hazardChance=.5f; + float crocSpawnChance = .5f; int lastX; List spawnedTiles; List spawnedTilesGround; @@ -27,6 +28,8 @@ public class Endlosmodus : MonoBehaviour { int height; int blockArt = 1; int counter = 25; + bool crocSpawned; + int lastHeight; void Start () { spawnedTiles = new List(); @@ -64,22 +67,22 @@ void Update () { void Spawn() { counter--; if (hazardChance > Random.value && !isHazard) { - int size = Random.Range(2, maxHazardSize); + int size = Random.Range (2, maxHazardSize); for (int i = 1; i <= size; i++) { lastX += 2; isHazard = true; } } else { int size = Random.Range (minPlatSize, maxPlatSize); - height = Mathf.RoundToInt(Random.Range (maxUp, maxDown)/2)*2; + height = Mathf.RoundToInt (Random.Range (maxUp, maxDown) / 2) * 2; if (Mathf.Abs (heightAlt - height) >= 6) { Spawn (); } else { heightAlt = height; isHazard = false; - for (int i = 2; i <= size * 2; i = i + 2) { - switch(blockArt) - { + int sizedummy = size; + for (int i = 2; i <= sizedummy * 2; i = i + 2) { + switch (blockArt) { case 0: SpawnLine (redBrick, false, redBrick); break; @@ -94,13 +97,17 @@ void Spawn() { break; } } - } - if (size >= 7 && Random.value > .5f) { - Vector3 crocvec = new Vector3 (lastX - 3, height + 3, 0); + + if (size >= 7 && Random.value > crocSpawnChance && crocSpawned == false) { + Vector3 crocvec = new Vector3 (lastX, height + 3, 0); Instantiate (crocodile, crocvec, new Quaternion ()); - print (crocvec); + crocSpawned = true; + } else if (height != lastHeight) { + crocSpawned = false; } - } + lastHeight = height; + } + } } void Delete() { diff --git a/Platformer_001/Assets/Scripts/Health System/LebenController.cs b/Platformer_001/Assets/Scripts/Health System/LebenController.cs index 4d5d289..ad6402a 100644 --- a/Platformer_001/Assets/Scripts/Health System/LebenController.cs +++ b/Platformer_001/Assets/Scripts/Health System/LebenController.cs @@ -7,11 +7,8 @@ public class LebenController : MonoBehaviour { public int leben; public string gameOverName = "Game_Over_Screen"; - public GameObject player; - private Highscore hs; // Use this for initialization void Start () { - hs = GetComponent (); } // Update is called once per frame @@ -23,8 +20,6 @@ public void GameOver() { print ("Du bist Tod!"); SceneManager.LoadScene(gameOverName); - - hs.saveLength (Mathf.RoundToInt(player.transform.position.x)); } public void Sterben()