예제 #1
0
    void OnMouseDrag()
    {
        //only if movement is allowed
        if (_allowMovement)
        {
            if (!_dragging)
            {
                OnStartDrag();
                _dragging = true;
            }

            //if hovered a tile that is reachable then move have the player move there
            Collider   tileParent;
            TileHolder tileHolder = null;
            if (BoardUI.GetTileHovered_Position(out tileParent))
            {
                tileHolder = tileParent.GetComponentInChildren <TileHolder> ();
            }

            if (tileHolder != null)
            {
                //try get the commander position marker
                GameObject posMarker = getCommanderMarker(tileHolder);
                if (posMarker != null)
                {
                    _toGoTo              = posMarker.transform.position;
                    _destination         = _toGoTo;
                    _destinationRotation = posMarker.transform.rotation;
                }
                else
                {
                    _toGoTo      = tileHolder.transform.position;
                    _destination = _toGoTo;
                }

                _toGoTo.y = _LiftedHeight;

                _targetY = tileHolder._Tile.Height;

                _destinationTile = tileHolder;

                //dragging
                OnDraggingCommander();
            }
            else
            {
                _destinationTile = null;
            }

            if (!_hasBeenLifted && !_liftingPiece)              // && _destinationTile == null )//|| _prevHovered != hoveredCollider))
            {
                LiftPiece();
            }
            //block raycast
            this.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
        }
    }