Example #1
0
 private void UpdateFinishAlign(int i, FieldScan fieldScan, FieldInput fieldInput, Vector2Int gamePosition)
 {
     fieldInput.phase        = EnumFieldInputPhase.None;
     fieldInput.swipeVec     = EnumSwipeVec.None;
     fieldInput.distPosition = Vector2Int.zero;
     fieldInputs[i]          = fieldInput;
 }
Example #2
0
 private void UpdateEnded(int i, FieldScan fieldScan, FieldInput fieldInput, Vector2Int gamePosition)
 {
     fieldInput.phase      = EnumFieldInputPhase.Align;
     fieldInput.alignVec   = GetAlignVec(fieldInput, fieldScan);
     fieldInput.alignDelta = GetAlignDelta(fieldInput.alignVec);
     fieldInput.isOnGrid   = CheckOnGrid(fieldInput.distPosition, fieldInput.swipeVec);
     // DebugPanel.Log($"fieldInput.alignVec", fieldInput.alignVec.ToString());
     // DebugPanel.Log($"fieldInput.alignDelta", fieldInput.alignDelta.ToString());
     fieldInputs[i] = fieldInput;
 }
Example #3
0
 private EnumPieceAlignVec GetAlignVec(FieldInput fieldInput, FieldScan fieldScan)
 {
     if ((Mathf.Abs(fieldScan.delta.x) > BorderSpeed && fieldInput.swipeVec == EnumSwipeVec.Horizontal) ||
         (Mathf.Abs(fieldScan.delta.y) > BorderSpeed && fieldInput.swipeVec == EnumSwipeVec.Vertical))
     {
         return(GetSlipAlignVec(fieldScan.delta, fieldInput.swipeVec));
     }
     else
     {
         return(GetBackAlignVec(fieldInput.distPosition, fieldInput.swipeVec));
     }
 }
Example #4
0
            private bool CheckFinishAlign(FieldInput fieldInput, Vector2Int newDistPosition)
            {
                EnumPieceAlignVec lastAlignVec = GetBackAlignVec(fieldInput.distPosition, fieldInput.swipeVec);
                EnumPieceAlignVec nowAlignVec  = GetBackAlignVec(newDistPosition, fieldInput.swipeVec);

                // DebugPanel.Log($"fieldInput.distPosition", fieldInput.distPosition.ToString());
                // DebugPanel.Log($"newDistPosition", newDistPosition.ToString());
                // DebugPanel.Log($"lastAlignVec", lastAlignVec.ToString());
                // DebugPanel.Log($"fieldInput.alignVec", fieldInput.alignVec.ToString());
                return(((lastAlignVec != nowAlignVec) && lastAlignVec == fieldInput.alignVec) ||
                       lastAlignVec == EnumPieceAlignVec.None);
            }
Example #5
0
            private void UpdateAlign(int i, FieldScan fieldScan, FieldInput fieldInput, Vector2Int gamePosition)
            {
                Vector2Int newDistPosition = fieldInput.distPosition + fieldInput.alignDelta;

                if (CheckFinishAlign(fieldInput, newDistPosition))
                {
                    fieldInput.phase = EnumFieldInputPhase.FinishAlign;
                }

                fieldInput.distPosition = newDistPosition;
                fieldInput.isOnGrid     = CheckOnGrid(fieldInput.distPosition, fieldInput.swipeVec);
                fieldInputs[i]          = fieldInput;
            }
Example #6
0
            private void UpdateBegan(int i, FieldScan fieldScan, FieldInput fieldInput, Vector2Int gamePosition)
            {
                if (!CheckInfield(gamePosition))
                {
                    return;
                }

                fieldInput.phase         = EnumFieldInputPhase.Hold;
                fieldInput.gridPosition  = ConvertGridPosition(gamePosition);
                fieldInput.startPosition = gamePosition;
                fieldInput.swipeVec      = EnumSwipeVec.None;
                fieldInput.distPosition  = Vector2Int.zero;
                fieldInputs[i]           = fieldInput;
            }
Example #7
0
 private void UpdateAlignFinish(FieldInput fieldInput)
 {
     for (int i = 0; i < piecePositions.Length; i++)
     {
         var piecePosition = piecePositions[i];
         piecePosition.position = FromGridPosition(piecePosition.gridPosition);
         piecePositions[i]      = piecePosition;
         if (piecePosition.gridPosition.x == 2)
         {
             // DebugPanel.Log($"piecePositions{i}.position grid", piecePositions[i].position.ToString() + " _ " + piecePositions[i].gridPosition.ToString());
             // DebugPanel.Log($"piecePositions{i}.gridPosition", piecePositions[i].gridPosition.ToString());
         }
     }
 }
Example #8
0
 private void UpdateInputMove(FieldInput fieldInput)
 {
     // DebugPanel.Log($"fieldInput.distPosition", fieldInput.distPosition.ToString());
     if (fieldInput.swipeVec == EnumSwipeVec.Horizontal)
     {
         for (int i = 0; i < piecePositions.Length; i++)
         {
             var piecePosition = piecePositions[i];
             if (piecePosition.gridPosition.y == fieldInput.gridPosition.y)
             {
                 int        posX   = RoundPos(piecePosition.startPosition.x + fieldInput.distPosition.x, FieldWidth);
                 Vector2Int newPos = new Vector2Int(posX, piecePosition.position.y);
                 piecePositions[i] = MovePosition(piecePosition, newPos); //, delta);
             }
         }
     }
     else if (fieldInput.swipeVec == EnumSwipeVec.Vertical)
     {
         for (int i = 0; i < piecePositions.Length; i++)
         {
             var piecePosition = piecePositions[i];
             if (piecePosition.gridPosition.x == fieldInput.gridPosition.x)
             {
                 int        posY   = RoundPos(piecePosition.startPosition.y + fieldInput.distPosition.y, FieldHeight);
                 Vector2Int newPos = new Vector2Int(piecePosition.position.x, posY);
                 piecePositions[i] = MovePosition(piecePosition, newPos);
                 if (piecePosition.gridPosition.x == 2)
                 {
                     // DebugPanel.Log($"piecePositions{i}.position grid", piecePositions[i].position.ToString() + " _ " + piecePositions[i].gridPosition.ToString());
                 }
             }
         }
     }
     else
     {
         for (int i = 0; i < piecePositions.Length; i++)
         {
             var piecePosition = piecePositions[i];
             piecePosition.startPosition = FromGridPosition(piecePosition.gridPosition);
             piecePositions[i]           = piecePosition;
             if (piecePosition.gridPosition.x == 2)
             {
                 // DebugPanel.Log($"piecePositions{i}.position grid", piecePositions[i].position.ToString() + " _ " + piecePositions[i].gridPosition.ToString());
             }
         }
     }
 }
Example #9
0
            private void DecideSwipeVec(ref FieldInput fieldInput, Vector2 distPosition)
            {
                if (fieldInput.swipeVec == EnumSwipeVec.None)
                {
                    float distX = Mathf.Abs(distPosition.x);
                    float distY = Mathf.Abs(distPosition.y);

                    if (distX > distY && distX > SwipeThreshold)
                    {
                        fieldInput.swipeVec = EnumSwipeVec.Horizontal;
                    }
                    else if (distX < distY && distY > SwipeThreshold)
                    {
                        fieldInput.swipeVec = EnumSwipeVec.Vertical;
                    }
                }
            }
Example #10
0
            private void UpdateMoved(int i, FieldScan fieldScan, FieldInput fieldInput, Vector2Int gamePosition)
            {
                if (fieldInput.phase != EnumFieldInputPhase.Hold)
                {
                    return;
                }

                Vector2 distPosition = (fieldScan.nowPosition - fieldScan.startPosition);

                DecideSwipeVec(ref fieldInput, distPosition);

                fieldInput.distPosition = new Vector2Int(
                    (int)(distPosition.x / PixelSize),
                    (int)(distPosition.y / PixelSize));
                fieldInput.isOnGrid = CheckOnGrid(fieldInput.distPosition, fieldInput.swipeVec);
                // DebugPanel.Log($"fieldInput.isOnGrid", fieldInput.isOnGrid.ToString());
                fieldInputs[i] = fieldInput;
            }