Esempio n. 1
0
 void CancleDragSwap()
 {
     if (endDragCell && endDragFindCell)
     {
         endDragFindCell.SwapCellElement(endDragCell);
         endDragCell     = null;
         endDragFindCell = null;
     }
 }
Esempio n. 2
0
        void OnCellDragCallback(CellPrefabs _cell, Vector2 _dirty)
        {
            if (state != GameState.Ready)
            {
                return;
            }
            float       xCos      = Vector2.Dot(_dirty.normalized, Vector2.right);
            float       yCos      = Vector2.Dot(_dirty.normalized, Vector2.up);
            CellPrefabs _findCell = null;

            if (Mathf.Abs(xCos) > Mathf.Abs(yCos))
            {
                if (xCos > 0)
                {
                    _findCell = GetCellByDir(_cell, Dir.RIGHT);
                }
                else
                {
                    _findCell = GetCellByDir(_cell, Dir.LEFT);
                }
            }
            else
            {
                if (yCos > 0)
                {
                    _findCell = GetCellByDir(_cell, Dir.UP);
                }
                else
                {
                    _findCell = GetCellByDir(_cell, Dir.DOWN);
                }
            }
            if (_findCell)
            {
                state = GameState.Swap;
                _cell.SwapCellElement(_findCell);
                endDragCell     = _cell;
                endDragFindCell = _findCell;

                SetToDirty(endDragCell);
                SetToDirty(endDragFindCell);

                StartCoroutine(MatchStep());
            }
        }