예제 #1
0
    private string GetRandomKitchen(KITCHEN_TYPES kitchen_type)
    {
        string kitchen = "";
        int    kit     = 0;

        switch (kitchen_type)
        {
        case KITCHEN_TYPES.LEFT:
            kit     = Random.Range(0, LEFT_KITCHENS.Length);
            kitchen = LEFT_KITCHENS[kit];
            break;

        case KITCHEN_TYPES.RIGHT:
            kit     = Random.Range(0, RIGHT_KITCHENS.Length);
            kitchen = RIGHT_KITCHENS[kit];
            break;

        case KITCHEN_TYPES.OBSTACLE_LEFT:
            kit     = Random.Range(0, OBSTACLE_LEFT_KITCHENS.Length);
            kitchen = OBSTACLE_LEFT_KITCHENS[kit];
            break;

        case KITCHEN_TYPES.OBSTACLE_RIGHT:
            kit     = Random.Range(0, OBSTACLE_RIGHT_KITCHENS.Length);
            kitchen = OBSTACLE_RIGHT_KITCHENS[kit];
            break;

        default:
            break;
        }

        return(kitchen);
    }
예제 #2
0
    private void AddKitchen(int posIndex)
    {
        float spawnRange = pos[posIndex].z - spawnDistance;

        if (player.transform.position.z > spawnRange && kitchenCount < maximumKitchenCount)
        {
            KITCHEN_TYPES currentKitchenType = KITCHEN_TYPES.LEFT;

            // Determine if kitchen is lane obstacle
            if (!isTutorial && OBSTACLE_LEFT_KITCHENS.Length > 0 && OBSTACLE_RIGHT_KITCHENS.Length > 0 && Random.Range(0, 100) < 10)
            {
                currentKitchenType = posIndex == 0 ? KITCHEN_TYPES.OBSTACLE_LEFT : KITCHEN_TYPES.OBSTACLE_RIGHT;
            }
            else
            {
                currentKitchenType = posIndex == 0 ? KITCHEN_TYPES.LEFT : KITCHEN_TYPES.RIGHT;
            }

            // Set position of platform
            kitchen = ObjectPooler.Instance.SpawnFromPool(GetRandomKitchen(currentKitchenType), pos[posIndex], Quaternion.identity);
            // Check if platform spawned
            if (kitchen == null)
            {
                return;                    // Should never occur if pool size is larger than max
            }
            pos[posIndex].z += kitchen.transform.localScale.z * kitchenLength;

            kitchenComponent = kitchen.GetComponent <PlatformController>();
            kitchenComponent.OnObjectSpawn();
            kitchenComponent.onRemoveItem += RemoveOne;

            kitchenCount++;
        }
    }