コード例 #1
0
    private void criaInstancia(ISpawnable iPreFab, GameObject spawn)
    {
        float maxAltura = iPreFab.getMaxAltura();

        float max = spawn.transform.position.y + maxAltura;
        float min = spawn.transform.position.y - (1f * maxAltura);

        if (isPlayerBased)
        {
            max = objPlayer.transform.position.y + 0.4f;
            min = objPlayer.transform.position.y - 0.4f;
        }

        if (max > 1.8f)
        {
            max = 1.8f;
        }

        if (min < -2.4f)
        {
            min = -2.4f;
        }


        float distCheese = 0f;

        if (spwCheese)
        {
            spwCheese  = false;
            distCheese = 10f * (movBallon / 2);
            spawnCheeseGroup(spawn);
        }


        contaSpawn++;

        altura = Random.Range(max, min);

        iPreFab.setMovSpeed(movBallon);

        iPreFab.setMoving(isMoving);

        Instantiate(iPreFab.getPreFab(), new Vector3(spawn.transform.position.x + DisInstance + distCheese, altura, 0), Quaternion.identity);
    }