Example #1
0
    private void ConfirmOrCancelPreviewSolid(bool isConfirmed)
    {
        if (isConfirmed)
        {
            previewSolid.SetMode(Solid3D.MODE.DEFAULT);
            if (!selectedFace.ParentPrimitive.ParentSolid.isStatic)
            {
                previewSolid.ParentSolid = selectedFace.ParentPrimitive.ParentSolid;
            }
            if (selectedFace.ParentPrimitive.ParentSolid.IsPowered)
            {
                previewSolid.IsPowered = true;
            }

            selectedFace.ParentPrimitive.ParentSolid.Children.Add(previewSolid);
            placedSolids.Add(previewSolid);



            previewSolid.ParentButton.Count -= 1;
            if (previewSolid.ParentButton.Count == 0)
            {
                previewSolid = null; // break reference to newly placed solid so that setting ReadySolid to null doesn't destroy it
                ReadySolid   = null;
            }

            previewSolid = null;
            selectedFace = null;


            Destroy(activeFaceSelector.gameObject);
            CheckWinConditions();
        }
        else
        {
            Destroy(previewSolid.gameObject);
        }
        previewSolid = null;
    }
Example #2
0
    private void CreatePreviewSolidAtSelectedFace()
    {
        if (previewSolid != null)
        {
            Destroy(previewSolid.gameObject);
        }

        previewSolid = Instantiate(ReadySolid.gameObject).GetComponent <Solid3D>();
        previewSolid.SetMode(Solid3D.MODE.PREVIEW);
        previewSolid.SelectFaceByNumberOfSides(selectedFace.sides);

        if (previewSolid.ActivePrimitive == null)
        {
            Destroy(previewSolid.gameObject);
            // TODO: no valid face
        }
        else
        {
            previewSolid.AlignToSelectedFace(selectedFace);
            previewSolid.ParentButton = ReadySolid.ParentButton;
        }
    }