コード例 #1
0
    public void CheckBlock(Block blockToCheck)
    {
        if (selectedPlayer != null)
        {
            if (selectedPlayer.CanRemoveFire(blockToCheck))
            {
                blockToCheck.RemoveFire();

                //set a corner to be disabled
                //Pick a random corner

                List <Corner> corners = blockToCheck.connectedCorners;

                bool lookingForPlace = true;
                while (lookingForPlace)
                {
                    int    randnum = Random.Range(0, corners.Count);
                    Corner corner  = corners[randnum].GetComponent <Corner>();

                    if (corner.blocked == false)
                    {
                        corner.BlockCorner();
                        corner.GetComponent <MeshRenderer>().material = unSelectedMat;
                        lookingForPlace = false;
                    }
                    corners.Remove(corner);

                    //check if all are full
                    if (corners.Count == 0)
                    {
                        lookingForPlace = false;
                    }
                }
            }
            else if (selectedPlayer.movementType == MovementType.Block)
            {
                selectedPlayer.MovePlayer(blockToCheck);
            }
        }
    }