Exemplo n.º 1
0
    private void InitBrick(RecipeBrickVisualization vis, RecipeBrick recBrick)
    {
        vis.SetColor(colorPalette.Colors[recBrick.GetID()]);

        Vector3    pos = transform.position + recBrick.GetVoxels()[1].getCenter() * SCALE;
        Quaternion rot = Quaternion.LookRotation(GetMajorAxis(recBrick.GetVoxels()));

        vis.transform.SetPositionAndRotation(pos, rot);
    }
Exemplo n.º 2
0
    private static RecipeBrick[] GetCurrentBricks()
    {
        PhysicsBrick[] physicsBricks = Object.FindObjectsOfType <PhysicsBrick>();
        RecipeBrick[]  recipeBricks  = new RecipeBrick[physicsBricks.Length];

        for (int i = 0; i < physicsBricks.Length; i++)
        {
            PhysicsBrick pBrick = physicsBricks[i];
            BrickUtility.AlignBrick(pBrick);
            RecipeBrick brick = new RecipeBrick(pBrick.GetID(), pBrick.GetVoxels());

            recipeBricks[i] = brick;
        }
        Debug.Log(recipeBricks.Length + " bricks saved to new recipe.");
        return(recipeBricks);
    }
Exemplo n.º 3
0
    private bool MatchIngredient(RecipeBrick ingredient)
    {
        if (ingredient.GetVoxels().Length == 0)
        {
            Debug.LogError($"Recipe {currentRecipe} is corrupt.");
            // TODO handle this error in a nice way
            currentRecipe = FindObjectOfType <Cookbook>().GetNext();
            return(false);
        }

        // check if any of the brick matches the one in the recipe
        foreach (var brick in bricks)
        {
            if (brick.Match(ingredient) == true)
            {
                return(true);
            }
        }
        // return false if none of the placed bricks matches
        return(false);
    }