// Update is called once per frame void Update() { /*if (transform.position.x < posEndBG.position.x) { * posEndBG3 = posEndBG.position.x * a; * selectedBackground = PlayerPrefs.GetInt ("selectedBG"); * transformMinusPos = posEndBG.position.x - posEndBG2.position.x; * switch (selectedBackground) { * case 0: * * if (posEndBG3 <= ten) { * * theCoinGenerator.Background01 (new Vector3 (posEndBG.position.x + (72 * a), theCatcher.position.y + 5f, transform.position.z)); * //if(a == ten){ * * a++; * } * if (posCamera.position.x > posEndBG3 -100 ) { * ten += 72 ; * } * * break; * } * }*/ if (transform.position.x < platformPoint.position.x) { distance = Random.Range(minDistance, maxDistance); switch (selectedTile) { case 0: platformSelector = Random.Range(0, theObjectPools.Length); break; case 1: platformSelector = Random.Range(0, theObjectPoolsYellow.Length); break; case 2: platformSelector = Random.Range(0, theObjectPoolsGreen.Length); break; case 3: platformSelector = Random.Range(0, theObjectPoolsCake.Length); break; case 4: platformSelector = Random.Range(0, theObjectPoolsCastle.Length); break; case 5: platformSelector = Random.Range(0, theObjectPoolsChoco.Length); break; case 6: platformSelector = Random.Range(0, theObjectPoolsDirt.Length); break; case 7: platformSelector = Random.Range(0, theObjectPoolsGrass.Length); break; case 8: platformSelector = Random.Range(0, theObjectPoolsMetal.Length); break; case 9: platformSelector = Random.Range(0, theObjectPoolsSand.Length); break; case 10: platformSelector = Random.Range(0, theObjectPoolsSnow.Length); break; case 11: platformSelector = Random.Range(0, theObjectPoolsTundra.Length); break; case 12: platformSelector = Random.Range(0, theObjectPoolsPurple.Length); break; } /*if (/*selectCharacter == 5 ||selectCharacter == 6 || selectCharacter == 7 || selectCharacter == 8 || selectCharacter == 9) { * * maxHeightChangeRandom = Random.Range (maxHeightChange, 3.5f); * minHeightChangeRandom = Random.Range (-maxHeightChange, -3.5f); * * } else{ * maxHeightChangeRandom = Random.Range (maxHeightChange, 0.5f); * minHeightChangeRandom = Random.Range (-maxHeightChange, -0.5f); * }*/ heightChange = transform.position.y + Random.Range(maxHeightChange, -maxHeightChange); if (heightChange > maxHeight) { heightChange = maxHeight; } else if (minHeight > heightChange) { heightChange = minHeight; } transform.position = new Vector3(transform.position.x + (platformWidths [platformSelector] / 2) + distance, heightChange, transform.position.z); //break; /*switch (selectedTile) { * case 0: * transform.position = new Vector3 (transform.position.x + (platformWidths [platformSelector] / 2) + distance, heightChange, transform.position.z); * break; * case 1: * transform.position = new Vector3 (transform.position.x + (platformWidths02 [platformSelector] / 2) + distance, heightChange, transform.position.z); * break; * case 2: * transform.position = new Vector3 (transform.position.x + (platformWidths03 [platformSelector] / 2) + distance, heightChange, transform.position.z); * break; * }*/ if (!addObject) { switch (platformSelector) { case 0: medPlatform = 0.4f; break; case 1: medPlatform = -0.73f; break; case 2: medPlatform = -1.73f; break; case 3: medPlatform = -2.73f; break; default: break; } } else if (addObject) { switch (platformSelector) { case 0: medPlatform = 0.10f; break; case 1: medPlatform = 0.21f; break; case 2: medPlatform = 1.21f; break; case 3: medPlatform = 2.21f; break; default: break; } } if (heightChange == maxHeight || heightChange == -maxHeight) { if (!addObject) { randomHeight = (Random.Range(2f, 3f)); } else if (addObject) { randomHeight = (Random.Range(2.4f, 3.4f)); } } else if (heightChange < -maxHeight) { if (!addObject) { randomHeight = (Random.Range(1f, 1.5f)); } else if (addObject) { randomHeight = (Random.Range(1.4f, 1.9f)); } } //Instantiate (/*thePlatform*/ thePlatforms[platformSelector], transform.position, transform.rotation); switch (selectedTile) { case 0: newP = theObjectPools [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 1: newP = theObjectPoolsYellow [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 2: newP = theObjectPoolsGreen [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 3: newP = theObjectPoolsCake [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 4: newP = theObjectPoolsCastle [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 5: newP = theObjectPoolsChoco [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 6: newP = theObjectPoolsDirt [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 7: newP = theObjectPoolsGrass [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 8: newP = theObjectPoolsMetal [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 9: newP = theObjectPoolsSand [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 10: newP = theObjectPoolsSnow [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 11: newP = theObjectPoolsTundra [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; case 12: newP = theObjectPoolsPurple [platformSelector].GetPooledObject(); newP.transform.position = transform.position; break; } newP.transform.rotation = transform.rotation; newP.SetActive(true); float randomPosCoin = 1.4f; float randomPosCoin2 = 1.4f; int randomSwitch = (int)Mathf.Round(Random.Range(0f, 1.5f)); if (Random.Range(0f, 100f) < 7) { if (!addObject) { theCoinGenerator.Arrow(new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z)); } else if (addObject) { theCoinGenerator.Arrow(new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z)); } } if (Random.Range(0f, 100f) < randomCoinGold) { if (!addObject) { switch (randomSwitch) { case 0: theCoinGenerator.SpawnCoinsGold(new Vector3(transform.position.x - medPlatform, transform.position.y + randomPosCoin, transform.position.z)); break; case 1: theCoinGenerator.SpawnCoinsUpAndUpGold(new Vector3(transform.position.x - medPlatform, transform.position.y + randomPosCoin, transform.position.z)); break; } } else if (addObject) { switch (randomSwitch) { case 0: theCoinGenerator.SpawnCoinsGold(new Vector3(transform.position.x - medPlatform, transform.position.y + randomPosCoin2, transform.position.z)); break; case 1: theCoinGenerator.SpawnCoinsUpAndUpGold(new Vector3(transform.position.x - medPlatform, transform.position.y + randomPosCoin2, transform.position.z)); break; } } } else if (Random.Range(0f, 100f) < randomCoinBronze) { if (!addObject) { switch (randomSwitch) { case 0: theCoinGenerator.SpawnCoinsBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + randomPosCoin, transform.position.z)); break; case 1: theCoinGenerator.SpawnCoinsUpAndUpBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + randomPosCoin, transform.position.z)); break; } } else if (addObject) { switch (randomSwitch) { case 0: theCoinGenerator.SpawnCoinsBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + randomPosCoin2, transform.position.z)); break; case 1: theCoinGenerator.SpawnCoinsUpAndUpBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + randomPosCoin2, transform.position.z)); break; } } } transform.position = new Vector3(transform.position.x + (platformWidths [platformSelector] / 2) + distance, transform.position.y, transform.position.z); if (Random.Range(0f, 100f) < randomCoinGold) { if (distance < distanceNormal && distance > distanceNormal02) { //switch (Random.Range (0, 3)) { //case 1: theCoinGenerator.SpawnCoinsOneGold(new Vector3(transform.position.x - medPlatform, transform.position.y + randomHeight, transform.position.z)); /*break; * case 2: * theCoinGenerator.SpawnCoinsTwoGold (new Vector3 (transform.position.x - medPlatform, transform.position.y + 1.5f, transform.position.z)); * break; * default: * theCoinGenerator.SpawnCoinsOneGold (new Vector3 (transform.position.x - medPlatform, transform.position.y + randomHeight, transform.position.z)); * break;*/ //} } else if (distance > distanceThree) { if (!addObject) { if (heightChange == maxHeight) { theCoinGenerator.SpawnCoinsThreeGold(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.5f, transform.position.z)); } else if (heightChange == -maxHeight) { theCoinGenerator.SpawnCoinsThreeGold(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.5f, transform.position.z)); } else { theCoinGenerator.SpawnCoinsTwoGold(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.6f, transform.position.z)); } } else if (addObject) { if (heightChange == maxHeight) { theCoinGenerator.SpawnCoinsThreeGold(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.9f, transform.position.z)); } else if (heightChange == -maxHeight) { theCoinGenerator.SpawnCoinsThreeGold(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.9f, transform.position.z)); } else { theCoinGenerator.SpawnCoinsTwoGold(new Vector3(transform.position.x - medPlatform, transform.position.y + 2f, transform.position.z)); } } } } else if (Random.Range(0f, 100f) < randomCoinBronze) { if (distance < distanceNormal && distance > distanceNormal02) { /*switch (Random.Range (0, 3)) { * //case 1: * theCoinGenerator.SpawnCoinsOneBronze (new Vector3 (transform.position.x - medPlatform, transform.position.y + randomHeight, transform.position.z)); * /*break; * case 2: * theCoinGenerator.SpawnCoinsTwoBronze (new Vector3 (transform.position.x - medPlatform, transform.position.y + 1.5f, transform.position.z)); * break; * default: * theCoinGenerator.SpawnCoinsOneBronze (new Vector3 (transform.position.x - medPlatform, transform.position.y + randomHeight, transform.position.z)); * break;*/ //} } else if (distance > distanceThree) { if (!addObject) { if (heightChange == maxHeight) { theCoinGenerator.SpawnCoinsThreeBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.5f, transform.position.z)); } else if (heightChange == -maxHeight) { theCoinGenerator.SpawnCoinsThreeBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.5f, transform.position.z)); } else { theCoinGenerator.SpawnCoinsTwoBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.6f, transform.position.z)); } } else if (addObject) { if (heightChange == maxHeight) { theCoinGenerator.SpawnCoinsThreeBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.9f, transform.position.z)); } else if (heightChange == -maxHeight) { theCoinGenerator.SpawnCoinsThreeBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + 1.9f, transform.position.z)); } else { theCoinGenerator.SpawnCoinsTwoBronze(new Vector3(transform.position.x - medPlatform, transform.position.y + 2f, transform.position.z)); } } } } } }