void GetComponentForPlatformScript(Patah _platformScript) { //Mengambil semua komponen yang dibutuhkan oleh PlatformScript _platformScript.playerBoxCollider2d = playerBoxCol2d; _platformScript.patahSpawnerScript = this; _platformScript.cameraTrans = cameraScript.gameObject.transform; _platformScript.gameManagerScript = this.gameManagerScript; }
void SpawnPlatformStart() { float yPos = -3f; float xPos = 0f; topPlatformYPos = 0; if (platformSecond.childCount <= 0) { playerGO = Instantiate(playerPrefabs, Vector3.zero, Quaternion.identity) as GameObject; playerBoxCol2d = playerGO.GetComponent <BoxCollider2D>(); GetComponentForPlayerScript(playerGO.GetComponent <PlayerController>()); cameraScript.player = playerGO.transform; GetComponentForGameManager(); } else { playerGO.SetActive(true); } for (int i = 0; i < 12; i++) { xPos = Random.Range(-1.5f, 1.5f); if (platformSecond.childCount <= i) { platformGO = Instantiate(platformPrefabs, new Vector3(xPos, yPos, 0f), Quaternion.identity) as GameObject; platformGO.transform.SetParent(platformSecond); Patah patahScript = platformGO.GetComponent <Patah>(); GetComponentForPlatformScript(patahScript); } else { platformGO = platformSecond.GetChild(i).gameObject; platformGO.transform.position = new Vector3(xPos, yPos, 0f); } if (i <= 0) { playerGO.transform.position = new Vector3(xPos, yPos + 1f, 0f); } topPlatformYPos = yPos; yPos += 4f; } }