예제 #1
0
 /// <summary>
 /// Raises the TouchDownDetected event.
 /// </summary>
 /// <param name='e'>
 /// <see cref="Crystallography.InputManager.SustainedTouchEventArgs"/>
 /// </param>
 protected void OnTouchDown( SustainedTouchEventArgs e )
 {
     pressDuration += e.elapsed;
     if (pressDuration > MAX_PRESS_DURATION && dragging == false) {
         OnDrag ( e );
     }
     EventHandler<SustainedTouchEventArgs> handler = TouchDownDetected;
     if (handler != null ) {
         handler( this, e );
     }
 }
        /// <summary>
        /// Handles <c>InputManager.TouchDownDetected</c>.
        /// </summary>
        /// <param name='sender'>
        /// InputManager instance
        /// </param>
        /// <param name='e'>
        /// <see cref="Crystallography.InputManager.BaseTouchEventArgs"/>
        /// </param>
        void HandleInputManagerInstanceTouchDownDetected(object sender, SustainedTouchEventArgs e)
        {
            // NO TOUCHING PIECES WHEN GAME IS PAUSED
            if ( GameScene.paused ) return;
            // NO TOUCHING PIECES WHEN LEVEL IS OVER
            if ( GameScene.Hud.MetGoalTime != 0.0f) return;

            setPosition( e.touchPosition );

            if (velocity < MAXIMUM_PICKUP_VELOCITY) {
                if ( InputManager.dragging ) { // ----------------------------------- LOOK FOR ENTITIES THE PLAYER MIGHT BE TRYING TO TOUCH
                    // TEST FINGER POSITION
                    var entity = GetEntityAtPosition( e.touchPosition );
                    if (justDownPositionEntity != null) { // ------------------------ EDGE CASE: PLAYER TOUCHED DOWN ON A PIECE, BUT DRAGGED OFF OF IT
                        if (justDownPositionEntity != entity ) { // ----------------- BEFORE WE ADDED IT TO THE SELECTION GROUP.
                            if (entity == null) {
                                entity = justDownPositionEntity; // ----------------- COMMON: PLAYER IS TOUCHING EMPTY SPACE; RESOLVE IT BELOW
                            }
                        }
                        justDownPositionEntity = null;
                    }

                    if ( entity == null
                         && velocity < 100.0f
                         && population != 0) {
                        // TRY THE PICK UP POSITIONS FOR THE PIECE THE PLAYER ALREADY HAS

                        if (_pucks[(int)POSITIONS.TOP].Children.Count != 0) {
                            entity = GetEntityAtPosition( getNode().LocalToWorld(UP_LEFT_SELECTION_POINT), POSITIONS.LEFT);
                            if (entity == null) {
                                entity = GetEntityAtPosition( getNode().LocalToWorld(UP_RIGHT_SELECTION_POINT), POSITIONS.RIGHT);
                            }
                        }
                        if ( entity == null && _pucks[(int)POSITIONS.LEFT].Children.Count != 0) {
                            entity = GetEntityAtPosition( getNode().LocalToWorld(LEFT_UP_SELECTION_POINT), POSITIONS.TOP);
                        }
                        if ( entity == null && _pucks[(int)POSITIONS.RIGHT].Children.Count != 0){
                            entity = GetEntityAtPosition( getNode().LocalToWorld(RIGHT_UP_SELECTION_POINT), POSITIONS.TOP);
                        }
                    }
                    if (entity != null) {
                        if ( selectionDelay == 0.0f) {
                            Add (entity);
                        }
                    }
                    lastEntityTouched = entity;
                }
            }
        }
예제 #3
0
 protected void OnDrag( SustainedTouchEventArgs e )
 {
     dragging = true;
     EventHandler<SustainedTouchEventArgs> handler = DragDetected;
     if (handler != null) {
         handler( this, e );
     }
 }
 void HandleInputManagerInstanceDragDetected(object sender, SustainedTouchEventArgs e)
 {
     if( GameScene.paused ) return;
     if ( GameScene.Hud.MetGoalTime != 0.0f) return;
 }