コード例 #1
0
    void GetTileSize()
    {
        // Create a provisional planet to get proper collision bound measurements
        GameObject tempPlanet = planetsPool.GetPlanet();

        tileSize = tempPlanet.GetComponent <SphereCollider>().bounds.extents.x * 2.1f;

        // We don't need this anymore
        tempPlanet.SetActive(false);
    }
コード例 #2
0
    void SpawnPlanet(float y, bool isFirstSpawn = false)
    {
        // Get new planet from pool
        Planet planet = prefabPool.GetPlanet().GetComponent <Planet>();

        // Initialize planet with material/type
        planet.Init(materials[Random.Range(0, materials.Length)], this);

        // Assign position
        planet.gameObject.transform.position = new Vector3(xPosition, y, 0);

        // Add it to list
        planets.Add(planet);

        // Play sound
        if (!isFirstSpawn)
        {
            audioManager.PlaySFX(AudioClips.SFX_PLANET_SPAWN);
        }
    }