コード例 #1
0
    private static GameObject DeterminePiece(Node node, ref WoodMaterialObject boardToSplit)
    {
        GameObject objToReturn = null;

        if (node.ConnectedPieces.Count <= 0)
        {
            GameObject obj = node.gameObject;
            obj.transform.parent = null;
            if (obj.tag == "Piece")
            {
                PieceController controller = obj.GetComponent <PieceController>();
                if (controller == null)
                {
                    controller = obj.AddComponent <PieceController>();
                }
            }
            else if (obj.tag == "Leftover")
            {
                WoodLeftover leftoverScript = obj.GetComponent <WoodLeftover>();
                leftoverScript.BeginDisappearing();
            }
            else
            {
                Debug.LogError(obj.name + " is not tag as Piece or Leftover");
            }
            objToReturn = obj;
        }
        else
        {
            GameObject obj = WoodManagerHelper.CreateSeparateBoard(node, ref boardToSplit);
            objToReturn = obj;
        }
        return(objToReturn);
    }
コード例 #2
0
    /// <summary>
    /// Determines if the Node is a singular wood piece, a leftover wood piece, or a wood material gameobject that
    /// contains child pieces that still need to be cut out.
    /// </summary>
    /// <param name="node">A Node monobehavior object</param>
    /// <param name="boardToSplit">The wood material gameobject that contains the pieces that will be split</param>
    /// <returns>A gamobject that either a piece, a leftover piece, or a large wood board object</returns>
    private static GameObject DeterminePiece(Node node, ref WoodMaterialObject boardToSplit)
    {
        GameObject objToReturn = null;

        if (node.ConnectedPieces.Count <= 0)
        {
            GameObject obj = node.gameObject;
            obj.transform.parent = null;
            if (obj.tag == "Piece")
            {
                //The Node object is a wood piece
                PieceController controller = obj.GetComponent <PieceController>();
                if (controller == null)
                {
                    controller = obj.AddComponent <PieceController>();
                }
            }
            else if (obj.tag == "Leftover")
            {
                //The Node object is a leftover piece. Run the script that will delete it
                WoodLeftover leftoverScript = obj.GetComponent <WoodLeftover>();
                leftoverScript.BeginDisappearing();
            }
            else
            {
                Debug.LogError(obj.name + " is not tag as Piece or Leftover");
            }
            objToReturn = obj;
        }
        else
        {
            //The Node object is still a child of a wood material. Call the method that will split it from the wood material board.
            GameObject obj = WoodManagerHelper.CreateSeparateBoard(node, ref boardToSplit);
            objToReturn = obj;
        }
        return(objToReturn);
    }