コード例 #1
0
 public virtual void InitPipe(EPipeType pipeType, int acolor, int param)
 {
     PipeType = pipeType;
     Param    = param;
     AColor   = acolor;
     UpdateSkin();
 }
コード例 #2
0
 public void LoadPanel(List <int> state)
 {
     for (int i = 0; i < _sequence.Count; ++i)
     {
         if (_sequence[i] != null)
         {
             _sequence[i].gameObject.SetActive(false);
             _sequence[i] = null;
         }
     }
     if (state.Count == 0)
     {
         for (int i = 0; i <= SIZE; ++i)
         {
             state.Add(GameManager.Instance.BoardData.GetRandomColor());
         }
     }
     //create full queue at start
     for (int i = 1; i <= SIZE; ++i)
     {
         EPipeType ptype  = EPipeType.Colored;
         int       param  = 0;
         int       acolor = state[i - 1];
         if (acolor == -1)
         {
             ptype  = EPipeType.Blocker;
             acolor = -1;
             param  = -1;
         }
         SequencePipe pipe = CreatePipe(ptype, acolor, param);
         pipe.ATransform.localPosition = _slotsPoses[i];
         _sequence[i] = pipe;
     }
 }
コード例 #3
0
    private void RecreateLevel()
    {
        _carrentBrushType  = EPipeType.None;
        _carrentBrushColor = -1;
        _carrentBrushParam = -1;
        _intBrush          = PIPE_TYPE_NONE_ID;
        _indexStart        = -1;
        _drawState         = EMoveType.None;

        _textures = new Texture[_w * _h];
        _neededStates.Clear();
        for (int i = 0; i < _w; ++i)
        {
            List <SSlotData> rowN = new List <SSlotData>();
            for (int j = 0; j < _h; ++j)
            {
                int id = GetSlotIndex(i, j);
                _textures[id] = _statesTexs[PIPE_TYPE_NONE_ID];

                SSlotData neededSlot = new SSlotData();
                neededSlot.x  = i;
                neededSlot.y  = j;
                neededSlot.c  = -1;
                neededSlot.p  = -1;
                neededSlot.pt = EPipeType.None;
                rowN.Add(neededSlot);
            }
            _neededStates.Add(rowN);
        }
    }
コード例 #4
0
 private void EditorsIntToPipeParams(int editorsInt)
 {
     if (editorsInt == PIPE_TYPE_BLOCKER_ID)
     {
         _carrentBrushType  = EPipeType.Blocker;
         _carrentBrushColor = -1;
         _carrentBrushParam = -1;
     }
     else
     if (editorsInt == PIPE_TYPE_NONE_ID)
     {
         _carrentBrushType  = EPipeType.None;
         _carrentBrushColor = -1;
         _carrentBrushParam = -1;
     }
     else
     if (editorsInt == PIPE_TYPE_HOLE_ID)
     {
         _carrentBrushType  = EPipeType.Hole;
         _carrentBrushColor = -1;
         _carrentBrushParam = -1;
     }
     else
     {
         _carrentBrushType  = EPipeType.Colored;
         _carrentBrushColor = editorsInt / (LAST_COLOR_PARAM + 1);
         _carrentBrushParam = editorsInt % (LAST_COLOR_PARAM + 1);
     }
 }
コード例 #5
0
 public SSlotData(int xx, int yy, EPipeType ppt, int pp, int cc)
 {
     x  = xx;
     y  = yy;
     pt = ppt;
     p  = pp;
     c  = cc;
 }
コード例 #6
0
    public int c;        // color

    public SSlotData()
    {
        x  = 0;
        y  = 0;
        pt = EPipeType.None;
        p  = -1;
        c  = 0;
    }
コード例 #7
0
    private SequencePipe CreatePipe(EPipeType pipeType, int acolor, int param)
    {
        SequencePipe pipe = GetPipeFromPool();

        pipe.InitPipe(pipeType, acolor, param);
        Transform pipeTransf = pipe.ATransform;

        pipeTransf.localScale = new Vector3(PIPES_SCALE, PIPES_SCALE, 1);
        return(pipe);
    }
コード例 #8
0
    public override bool IsCanApply(SSlot slot)
    {
        if (!slot || !slot.Pipe)
        {
            return(false);
        }
        EPipeType pipeType = slot.Pipe.PipeType;

        if (pipeType == EPipeType.Colored) // || pipeType == EPipeType.Blocker) //TODO upgrade to breake blockers
        {
            return(true);
        }
        return(false);
    }
コード例 #9
0
    public void MoveQueue(EPipeType pipeType, int acolor, int param)
    {
        // add new pipe to last slot
        SequencePipe pipe = CreatePipe(pipeType, acolor, param);

        pipe.ATransform.localPosition = _slotsPoses[_lastSlot];
        // move prev pipes to the left
        for (int i = 1; i <= SIZE; ++i)
        {
            if (_sequence[i] == null)
            {
                continue;
            }
            int          newi = i - 1;
            SequencePipe p    = _sequence[i];
            GameObject   pobj = p.AGameObject;
            LeanTween.cancel(p.gameObject);
            if (newi == 0)
            {
                // move to the left and remove
                LeanTween.moveLocalX(pobj, _slotsPoses[newi].x, MOVE_SPEED)
                .setOnComplete
                (
                    () =>
                {
                    pobj.SetActive(false);
                }
                );
            }
            else
            {
                // just move to the left
                _sequence[newi] = p;
                LeanTween.moveLocalX(pobj, _slotsPoses[newi].x, MOVE_SPEED);
            }
        }
        // move new pipe
        _sequence[SIZE] = pipe;
        LeanTween.moveLocalX(pipe.AGameObject, _slotsPoses[SIZE].x, MOVE_SPEED);
        //
    }
コード例 #10
0
 private int PipeParamsToEditorsInt(EPipeType brushType, int brushColor, int brushParam)
 {
     if (brushType == EPipeType.Blocker)
     {
         return(PIPE_TYPE_BLOCKER_ID);
     }
     else
     if (brushType == EPipeType.None)
     {
         return(PIPE_TYPE_NONE_ID);
     }
     else
     if (brushType == EPipeType.Hole)
     {
         return(PIPE_TYPE_HOLE_ID);
     }
     else
     {
         return(brushColor * (LAST_COLOR_PARAM + 1) + brushParam);
     }
 }
コード例 #11
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);
    }