Skip to content
This repository has been archived by the owner on Dec 28, 2019. It is now read-only.

Commit

Permalink
Merge pull request #82 from pklaschka/Endlosmodus_fixes
Browse files Browse the repository at this point in the history
Bugs fixed
  • Loading branch information
pklaschka authored May 27, 2017
2 parents 02b98bb + b72567d commit ad36689
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
27 changes: 17 additions & 10 deletions Platformer_001/Assets/Scripts/Endlosmodus/Endlosmodus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Endlosmodus : MonoBehaviour {
int maxDown=-4;
[Range(0,1)]
float hazardChance=.5f;
float crocSpawnChance = .5f;
int lastX;
List<GameObject> spawnedTiles;
List<GameObject> spawnedTilesGround;
Expand All @@ -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<GameObject>();
Expand Down Expand Up @@ -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;
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Highscore> ();
}

// Update is called once per frame
Expand All @@ -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()
Expand Down

0 comments on commit ad36689

Please sign in to comment.