예제 #1
0
    void SpawnPlatformStart()
    {
        float yPos = startYPos + distBetween;
        float xPos = 0f;

        topPlatformYPos = 0;

        for (int i = 0; i < totalSpawnStart; i++)
        {
            xPos = Random.Range(-cameraHalfWidth, cameraHalfWidth);
            if (platformBins[0].childCount <= 0)
            {
                platformGO = Instantiate(platformPrefabs[0], new Vector3(xPos, yPos, 0f), Quaternion.identity) as GameObject;
                platformGO.transform.SetParent(platformSpawned);
                Platforme platformScript = platformGO.GetComponent <Platforme> ();
                GetComponentForPlatformScript(platformScript);
            }
            else
            {
                platformGO = platformBins[0].GetChild(0).gameObject;
                platformGO.transform.SetParent(platformSpawned);
                platformGO.transform.position = new Vector3(xPos, yPos, 0f);
            }

            topPlatformYPos = yPos;
            yPos           += distBetween;
        }
    }
예제 #2
0
    void SpawnBreakPlatform()
    {
        totalBreakPlatformSpawn++;
        float xPos = Random.Range(-cameraHalfWidth, cameraHalfWidth);

        if (platformBins[1].childCount <= 0)
        {
            platformGO = Instantiate(platformPrefabs[1], new Vector3(xPos - 0.3f, topPlatformYPos, 0f), Quaternion.identity) as GameObject;
            platformGO.transform.SetParent(platformSpawned);
            Platforme platformScript = platformGO.GetComponent <Platforme> ();
            GetComponentForPlatformScript(platformScript);
        }
        else
        {
            platformGO = platformBins[1].GetChild(0).gameObject;
            platformGO.transform.position = new Vector3(xPos - 0.3f, topPlatformYPos, 0f);
            platformGO.transform.SetParent(platformSpawned);
        }

        if (platformBins[2].childCount <= 0)
        {
            platformGO = Instantiate(platformPrefabs[2], new Vector3(xPos + 0.3f, topPlatformYPos, 0f), Quaternion.identity) as GameObject;
            platformGO.transform.SetParent(platformSpawned);
            Platforme platformScript = platformGO.GetComponent <Platforme> ();
            GetComponentForPlatformScript(platformScript);
        }
        else
        {
            platformGO = platformBins[2].GetChild(0).gameObject;
            platformGO.transform.position = new Vector3(xPos + 0.3f, topPlatformYPos, 0f);
            platformGO.transform.SetParent(platformSpawned);
        }
    }
예제 #3
0
 void GetComponentForPlatformScript(Platforme _platformScript)
 {
     _platformScript.playerBoxCollider2d   = playerBoxCol2d;
     _platformScript.platformSpawnerScript = this;
     _platformScript.cameraTrans           = cameraScript.gameObject.transform;
     _platformScript.gameManagerScript     = this.gameManagerScript;
 }
예제 #4
0
 void SpawnNormalPlatform()
 {
     if (platformBins[0].childCount <= 0)
     {
         platformGO = Instantiate(platformPrefabs[0], new Vector3(Random.Range(-cameraHalfWidth, cameraHalfWidth), topPlatformYPos, 0f), Quaternion.identity) as GameObject;
         platformGO.transform.SetParent(platformSpawned);
         Platforme platformScript = platformGO.GetComponent <Platforme> ();
         GetComponentForPlatformScript(platformScript);
     }
     else
     {
         platformGO = platformBins[0].GetChild(0).gameObject;
         platformGO.transform.position = new Vector3(Random.Range(-cameraHalfWidth, cameraHalfWidth), topPlatformYPos, 0f);
         platformGO.transform.SetParent(platformSpawned);
     }
 }