Ejemplo n.º 1
0
    public void OnTurnWasMade(bool wasMatch, bool justAddPipe)
    {
        if (GameBoard.GameType == EGameType.Leveled)
        {
            //if (!justAddPipe)
            //{
            ++_allTurns;
            --MovesLeft;
            CheckLeveledWinCondition();
            //}
        }
        else
        {
            if (!justAddPipe && GameBoard.AddingType == EAddingType.EachXMoves)
            {
                --_movesToNextPipe;
                ++_allTurns;
            }
            else
            {
                ++_allTurns;
            }
            bool pipeneeded = false;
            if (justAddPipe)
            {
                pipeneeded = true;
            }
            else
            if (GameBoard.AddingType == EAddingType.EachXMoves)
            {
                if (_movesToNextPipe == 0)
                {
                    pipeneeded = true;
                }
            }
            else
            if (GameBoard.AddingType == EAddingType.OnNoMatch)
            {
                if (!wasMatch)
                {
                    pipeneeded = true;
                }
            }

            if (pipeneeded)
            {
                if (GameBoard.AddingType == EAddingType.EachXMoves && _movesToNextPipe == 0)
                {
                    _movesToNextPipe = Consts.TURNS_TO_NEXT_PIPE;
                }
                bool needBlocker = false;
                if (GameBoard.AddingType != EAddingType.OnNoMatch || Consts.USE_BLOCKERS_ON_NO_MATCH_ADDING)
                {
                    needBlocker = _pipesToNextBlocker == 0;
                    if (needBlocker)
                    {
                        _pipesToNextBlocker = Consts.PIPES_TO_NEXT_BLOCKER;
                    }
                    else
                    {
                        --_pipesToNextBlocker;
                    }
                }
                // add new pipe to queue and create new
                EPipeType pipeType = EPipeType.Colored;
                if (needBlocker)
                {
                    pipeType = EPipeType.Blocker;
                }
                if (pipeneeded)
                {
                    if (pipeneeded && AGameBoard.AddRandomPipe(pipeType))
                    {
                        ++_pipesAdded;
                    }
                    else
                    {
                        if (pipeType == EPipeType.Blocker)
                        {
                            // add blocker on next turn
                            _pipesToNextBlocker = 0;
                        }
                    }
                }
            }
        }
        EventData eventData = new EventData("OnTurnWasMadeEvent");

        eventData.Data["tonextpipe"] = _movesToNextPipe;
        eventData.Data["turnsmade"]  = _allTurns;
        eventData.Data["pipesadded"] = _pipesAdded;
        GameManager.Instance.EventManager.CallOnTurnWasMadeEvent(eventData);
    }