void flipLilypads() { foreach (GameObject lilypadObject in lilypads) { Lilypad lilypad = null; if (lilypadObject.CompareTag("Lilypad")) { lilypad = lilypadObject.GetComponent <Lilypad>(); } else if (lilypadObject.CompareTag("EggLilypad")) { lilypad = lilypadObject.GetComponent <EggLilypad>(); } else if (lilypadObject.CompareTag("AlligatorLilypad")) { lilypad = lilypadObject.GetComponent <AlligatorLilypad>(); } lilypad.flipLilypad(); } }
void GenerateNewLilypad() { Lilypad lastLilyPad = (Lilypad)lilyPads[lilyPads.Count - 1]; Vector2 newPosition; if (Score.score < 20) { newPosition = lastLilyPad.position + new Vector2(Random.Range(-2f, 2f), Random.Range(1f, 2f)); } else if (Score.score < 50) { newPosition = lastLilyPad.position + new Vector2(Random.Range(-2f, 2f), Random.Range(1f, 3f)); } else if (Score.score < 100) { newPosition = lastLilyPad.position + new Vector2(Random.Range(-2.5f, 2.5f), Random.Range(1f, 4f)); } else if (Score.score < 200) { newPosition = lastLilyPad.position + new Vector2(Random.Range(-3f, 3f), Random.Range(1f, 3f)); } else if (Score.score < 300) { newPosition = lastLilyPad.position + new Vector2(Random.Range(-2.5f, 2.5f), Random.Range(1f, 3f)); } else if (Score.score < 500) { newPosition = lastLilyPad.position + new Vector2(Random.Range(-2f, 2f), Random.Range(1f, 2.5f)); } else { newPosition = lastLilyPad.position + new Vector2(Random.Range(-3f, 3f), Random.Range(1f, 3f)); } float newScale; if (Score.score < 10) { newScale = Random.Range(0.6f, 1.2f); } else if (Score.score < 50) { newScale = Random.Range(0.6f, 1f); } else if (Score.score < 100) { newScale = Random.Range(0.5f, 0.8f); } else if (Score.score < 200) { newScale = Random.Range(0.5f, 1f); } else { newScale = Random.Range(0.5f, 1.5f); } float newRotation = Random.Range(0f, 360f); lilyPads.Add(new Lilypad(newPosition, newScale, newRotation)); lastLilyPad.Instantiate(this.transform); }