summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/gamestate/mapview/event/specialmove/StepMoveEvent.java
blob: af50087a04ccc652e38288ec622a592140739721 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fourisland.fourpuzzle.gamestate.mapview.event.specialmove;

import com.fourisland.fourpuzzle.Direction;
import com.fourisland.fourpuzzle.gamestate.mapview.event.Event;

/**
 * StepMoveEvent moves the event in the direction specified.
 *
 * @author hatkirby
 */
public class StepMoveEvent implements MoveEvent {

    Direction direction;
    public StepMoveEvent(Direction direction)
    {
        this.direction = direction;
    }
    
    public void doAction(Event ev)
    {
        if (ev.startMoving(direction))
        {
            while (ev.isMoving())
            {
                try {
                    Thread.sleep(2);
                } catch (InterruptedException ex) {
                    Thread.currentThread().interrupt();
                }
            }
        }
    }

}