Beispiel #1
0
        private void _endTouch()
        {
            if (!СGameController.IsInputState())
            {
                return;
            }
            _isDragged = false;

            if (_state == GameInputState.MOVING)
            {
                if (_currentCell && _currentCell.Piece)
                {
                    _currentCell.Piece.zIndex = _beforeDragZIndex;
                    if (GameEngine.GameController != null)
                    {
                        Debug.Log("End drag piece");
                        GameEngine.GameController.OnPlayerEndDragBoard(_currentCell);
                        _currentCell = null;
                    }
                }

                _state = GameInputState.WAIT_MOVE;
            }
            else if (_state == GameInputState.FIGHT_CELL)
            {
                if (_currentCell && _currentCell.HasFight)
                {
                    _gameEngine.FightUi.DisplayFightInput(_currentCell);
                    SetUiInput(true);
                }
            }
        }
Beispiel #2
0
        private void _updateTouch(Vector2 touchPosition)
        {
            if (!СGameController.IsInputState())
            {
                return;
            }
            if (_state != GameInputState.MOVING)
            {
                return;
            }
            Vector3 pos3 = Camera.main.ScreenToWorldPoint(touchPosition);

            pos3 = new Vector3(pos3.x * GameEngine.TO_PIXELS, pos3.y * GameEngine.TO_PIXELS, 0);
            _gameEngine.Board.updateDraggingAction(pos3);
        }
Beispiel #3
0
        private void _beginTouch(Vector2 touchPosition)
        {
            if (!СGameController.IsInputState())
            {
                return;
            }
            if (_state != GameInputState.WAIT_MOVE)
            {
                return;
            }

            _mouseBeginDragPos = Camera.main.ScreenToWorldPoint(touchPosition);
            _mouseBeginDragPos = new Vector3(_mouseBeginDragPos.x * GameEngine.TO_PIXELS, _mouseBeginDragPos.y * GameEngine.TO_PIXELS, 0);

            int posX = (int)Mathf.Round(_mouseBeginDragPos.x / GameEngine.CELL_SIZE);
            int posY = (int)Mathf.Round(_mouseBeginDragPos.y / GameEngine.CELL_SIZE);

            if (posX > -1 && posY > -1 && posY < _gameEngine.Board.Cells.Length && posX < ChessBoard.W)
            {
                Cell cell = _gameEngine.Board.Cells[posY, posX];

                if (cell && !cell.HasFight && cell.Piece && cell.Piece.Relation == PieceRelation.SELF)
                {
                    _state       = GameInputState.MOVING;
                    _isDragged   = true;
                    _currentCell = cell;
                    BasePiece piece = cell.Piece;
                    _beforeDragZIndex = piece.zIndex;
                    piece.zIndex      = ZIndex.DRAGGING_PIECE;
                    Debug.Log("begin drag at " + posX + " " + posY);

                    if (GameEngine.GameController != null)
                    {
                        GameEngine.GameController.OnPlayerBeginDragBoard(cell);
                    }
                }
                else if (cell && cell.HasFight)
                {
                    _state       = GameInputState.FIGHT_CELL;
                    _currentCell = cell;
                }
            }
        }