Example #1
0
    public override bool OnElementDestruction(BoardManager board)
    {
        if (hasBeenDestroyed)
        {
            return(false);
        }
        KeyValuePair <int, int> pos = BoardFunctions.GetBoardPositionOfElement(this, board.elementsPositions);

        switch (thisBombStyle)
        {
        case BombExplosionStyle.CrossStyle:
            BoardFunctions.DestroyAllElementsCrossStyle(pos.Key, pos.Value, ref board.matchedElemPositions);
            break;

        case BombExplosionStyle.DoubleBombStyle:
            BoardFunctions.DestroyElementsDoubleBombStyle(pos.Key, pos.Value, ref board.matchedElemPositions);
            break;

        case BombExplosionStyle.NormalStyle:
            BoardFunctions.DestroyElementsBombStyle(pos.Key, pos.Value, ref board.matchedElemPositions);
            break;

        default:
            BoardFunctions.DestroyElementsBombStyle(pos.Key, pos.Value, ref board.matchedElemPositions);
            break;
        }
        board.matchedElemPositions[pos.Key, pos.Value] = true;
        hasBeenDestroyed = true;
        return(true);
    }
Example #2
0
    public override bool OnElementDestruction(BoardManager board)
    {
        if (hasBeenDestroyed)
        {
            return(false);
        }
        KeyValuePair <int, int> pos = BoardFunctions.GetBoardPositionOfElement(this, board.elementsPositions);

        BoardFunctions.DestroyAllElementsCrossStyle(pos.Key, pos.Value, ref board.matchedElemPositions);
        board.matchedElemPositions[pos.Key, pos.Value] = true;
        hasBeenDestroyed = true;
        return(true);
    }
Example #3
0
    public override bool OnElementDestruction(BoardManager board, BoardElement otherElement)
    {
        if (hasBeenDestroyed)
        {
            return(false);
        }
        // if (otherElement == null) {
        //     Debug.LogError(BoardFunctions.GetTransformByIndex(otherElement.GetTransformIndex()) + " Bell OnElementDestruction() triggered with null as gameobject");
        // }
        KeyValuePair <int, int> pos = BoardFunctions.GetBoardPositionOfElement(this, board.elementsPositions);

        BoardFunctions.ActivateBellFunction(board, otherElement);
        board.matchedElemPositions[pos.Key, pos.Value] = true;
        hasBeenDestroyed = true;
        return(true);
    }
Example #4
0
    /// <summary>Swaps to elements positions on the board </summary>
    public static void SwapBoardElementNeighbours(BoardElement oldElement, BoardElement newElement, ref BoardElement[, ] positions)
    {
        KeyValuePair <int, int> oldElementPosition = BoardFunctions.GetBoardPositionOfElement(oldElement, positions);
        KeyValuePair <int, int> newElementPosition = BoardFunctions.GetBoardPositionOfElement(newElement, positions);

        positions[oldElementPosition.Key, oldElementPosition.Value] = newElement;
        positions[newElementPosition.Key, newElementPosition.Value] = oldElement;

#if UNITY_EDITOR
        //Debug.Log(newElementPosition.Key + ", " + newElementPosition.Value + " set to position " + oldElementPosition.Key + ", " + oldElementPosition.Value);
        //Debug.Log(oldElementPosition.Key + ", " + oldElementPosition.Value + " set to position " + newElementPosition.Key + ", " + newElementPosition.Value);
        if (positions[oldElementPosition.Key, oldElementPosition.Value] == positions[newElementPosition.Key, newElementPosition.Value])
        {
            UnityEngine.Debug.LogError("Swap was not correct");
        }
#endif
    }
Example #5
0
    public bool HandleInputForElement(BoardElement element, BoardElement otherElement)
    {
        bool areThereMatches = false;

        if (element.GetElementClassType() == typeof(CashBoardElement) || otherElement.GetElementClassType() == typeof(CashBoardElement))
        {
            return(false);
        }
        else if (element.GetElementClassType() == typeof(BombBoardElement))
        {
            if (otherElement.GetElementClassType() == typeof(CrossBoardElement))
            {
                //AlexDebugger.GetInstance().AddMessage(BoardFunctions.GetTransformByIndex(element.GetTransformIndex()) + " bomb style set to cross", AlexDebugger.tags.Step1);
                ((BombBoardElement)element).SetExplosionStyleTo(BombBoardElement.BombExplosionStyle.CrossStyle);
            }
            else if (otherElement.GetElementClassType() == typeof(BombBoardElement))
            {
                //AlexDebugger.GetInstance().AddMessage(BoardFunctions.GetTransformByIndex(element.GetTransformIndex()) + " bomb style set to double bomb", AlexDebugger.tags.Step1);
                ((BombBoardElement)element).SetExplosionStyleTo(BombBoardElement.BombExplosionStyle.DoubleBombStyle);
            }
            element.OnElementDestruction(this);
            AlexDebugger.GetInstance().AddMessage("first element was a bomb, go to step2: -play effects for matched elements-", AlexDebugger.tags.Step1);
            areThereMatches = true;
        }
        else if (element.GetElementClassType() == typeof(BellBoardElement))
        {
            AlexDebugger.GetInstance().AddMessage("first element was a bell, go to step2: -play effects for matched elements-", AlexDebugger.tags.Step1);
            element.OnElementDestruction(this, otherElement);
            areThereMatches = true;
        }
        else
        {
            KeyValuePair <int, int> firstPosition = BoardFunctions.GetBoardPositionOfElement(element, elementsPositions);
            int numberOfMatchesForFirst           = BoardFunctions.CheckElementForMatches(firstPosition.Key, firstPosition.Value, elementsPositions, ref matchedElemPositions, ConstantValues.totalCollums, ConstantValues.totalRows, true);
            // if there are matches
            if (numberOfMatchesForFirst > 0)
            {
                AlexDebugger.GetInstance().AddMessage("Matches found for first element " + numberOfMatchesForFirst + ", go to step2: -play effects for matched elements-", AlexDebugger.tags.Step1);
                // allow Update() to play effects
                areThereMatches = true;
            }
        }
        return(areThereMatches);
    }
Example #6
0
    /// <summary> Returns if two elements are neighbours</summary>
    public static bool GetIfNeighbours(BoardElement elem1, BoardElement elem2, BoardElement[, ] positions)
    {
        KeyValuePair <int, int> elem1Pos = BoardFunctions.GetBoardPositionOfElement(elem1, positions);
        KeyValuePair <int, int> elem2Pos = BoardFunctions.GetBoardPositionOfElement(elem2, positions);

        // Case same collumn, one row         above                                 or below
        if (elem1Pos.Key == elem2Pos.Key && (elem2Pos.Value == elem1Pos.Value - 1 || elem2Pos.Value == elem1Pos.Value + 1))
        {
            return(true);
        }
        // Case same row, one collumn                left                                 or right
        else if (elem1Pos.Value == elem2Pos.Value && (elem2Pos.Key == elem1Pos.Key - 1 || elem2Pos.Key == elem1Pos.Key + 1))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }