コード例 #1
0
    bool CheckMatch(ShapesManager.CheckResult leftResult, ShapesManager.CheckResult rightResult)
    {
        bool isMatchL = leftResult.IsMatch();
        bool isMatchR = rightResult.IsMatch();

        return(isMatchL || isMatchR);
    }
コード例 #2
0
    void CheckWholeBoard()
    {
        Transform pieces     = GameObject.Find("Pieces").transform;
        int       childCount = pieces.childCount;

        for (int i = 0; i < childCount; i++)
        {
            Transform child = pieces.GetChild(i);
            Vector2   vec   = shapesManager.GetRowColFromGameObject(child.gameObject);
            if (vec.x == 10f)
            {
                Debug.LogError("F**K");
            }
        }
        var shapes = shapesManager.shapes;

        for (int row = 0; row < shapes.GetLength(0); row++)
        {
            for (int col = 0; col < shapes.GetLength(1); col++)
            {
                Shape   shape    = shapesManager.GetShape(row, col);
                Vector3 position = shapesManager.GetPositionOfBackgroundPiece(row, col);
                //shape.transform.position = position;
            }
        }
        List <Vector2> shapePositions = new List <Vector2>();

        for (int row = 0; row < shapes.GetLength(0); row++)
        {
            for (int col = 0; col < shapes.GetLength(1); col++)
            {
                Debug.Log("Check whole board: " + row + "  col: " + col);
                ShapesManager.CheckResult result = shapesManager.CheckMatch(row, col);
                if (result.IsMatch())
                {
                    Debug.Log("successfulSwap && isMatch");
                    SoundManager.PlaySound("match");
                    List <Vector2> tmpShapePositions = new List <Vector2>();
                    if (result.IsHorizontalMatch())
                    {
                        tmpShapePositions = result.horizontalList;
                    }
                    if (result.IsVerticalMatch())
                    {
                        tmpShapePositions = result.verticalList;
                    }
                    if (result.IsVerticalMatch() && result.IsHorizontalMatch())
                    {
                        tmpShapePositions = result.GetMatchSet();
                    }
                    foreach (var shape in tmpShapePositions)
                    {
                        if (!shapePositions.Contains(shape))
                        {
                            shapePositions.Add(shape);
                        }
                    }
                }
            }
        }
        Disappear_Driver(shapePositions);
        if (shapePositions.Count == 0)
        {
            if (currentMoves == 0)
            {
                Debug.LogError("End the Match");
                UIManager.Toggle();
            }
        }
        else
        {
            //update score
            score += shapePositions.Count * Constants.NORMAL_SHAPE_VALUE; // TODO get shape value here
            UIManager.UpdateScoreValue(score);                            // multiple by amount per piece
        }
        return;
    }