public void HandlePickupSpawns() { if (landscapeGamePanel == null) { landscapeGamePanel = GameObject.FindGameObjectWithTag("landscapeGamePanel"); } if (portraitGamePanel == null) { portraitGamePanel = GameObject.FindGameObjectWithTag("portraitGamePanel"); } if (Timer > LastSpawnTime + SpawnTimeInterval) { float xPos = Random.Range(0, Screen.height / 2); float yPos = Random.Range(0, Screen.width / 2); LastSpawnTime = Timer; float pickupNumber = Random.Range(0f, 2f); if (pickupNumber <= 1f) { MoneyBonusPickup pickup = new MoneyBonusPickup(xPos, yPos, PickupTexture); if (Screen.width > Screen.height) { pickup.PickupObject.transform.parent = landscapeGamePanel.transform; } else { pickup.PickupObject.transform.parent = portraitGamePanel.transform; } ActivePickups.Add(pickup); } else if (pickupNumber <= 2f) { MultiplierPickup pickup = new MultiplierPickup(xPos, yPos, PickupTexture); ActivePickups.Add(pickup); if (Screen.width > Screen.height) { pickup.PickupObject.transform.parent = landscapeGamePanel.transform; } else { pickup.PickupObject.transform.parent = portraitGamePanel.transform; } } SpawnTimeInterval = Random.Range(45.0f, 60.0f); } }
public void HandlePickupSpawns() { if (landscapeGamePanel == null) { landscapeGamePanel = GameObject.FindGameObjectWithTag("landscapeGamePanel"); } if (portraitGamePanel == null) { portraitGamePanel = GameObject.FindGameObjectWithTag("portraitGamePanel"); } if (Timer > LastSpawnTime + SpawnTimeInterval) { float xPos = Random.Range(0, Screen.height / 2); float yPos = Random.Range(0, Screen.width / 2); LastSpawnTime = Timer; float pickupNumber = Random.Range(0f, 2f); if (pickupNumber <= 1f) { MoneyBonusPickup pickup = new MoneyBonusPickup(xPos, yPos, PickupTexture, PickupSound, CurrentMoneyBonusText); if (Screen.width > Screen.height) { pickup.PickupObject.transform.parent = landscapeGamePanel.transform; } else { pickup.PickupObject.transform.parent = portraitGamePanel.transform; } ActivePickups.Add(pickup); } else if (pickupNumber <= 2f) { MultiplierPickup pickup = new MultiplierPickup(xPos, yPos, PickupTexture, PickupSound); ActivePickups.Add(pickup); if (Screen.width > Screen.height) { pickup.PickupObject.transform.parent = landscapeGamePanel.transform; } else { pickup.PickupObject.transform.parent = portraitGamePanel.transform; } } SpawnTimeInterval = Random.Range(45.0f, 60.0f); } }