Provide estimated travel time.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2473 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TilePath.java,v 1.14 2003/04/17 19:21:16 mdb Exp $
|
// $Id: TilePath.java,v 1.15 2003/04/27 03:53:41 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.client;
|
package com.threerings.miso.client;
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ import com.threerings.util.DirectionCodes;
|
|||||||
|
|
||||||
import com.threerings.media.sprite.Sprite;
|
import com.threerings.media.sprite.Sprite;
|
||||||
import com.threerings.media.util.LineSegmentPath;
|
import com.threerings.media.util.LineSegmentPath;
|
||||||
|
import com.threerings.media.util.MathUtil;
|
||||||
import com.threerings.media.util.PathNode;
|
import com.threerings.media.util.PathNode;
|
||||||
import com.threerings.media.util.Pathable;
|
import com.threerings.media.util.Pathable;
|
||||||
|
|
||||||
@@ -47,6 +48,15 @@ public class TilePath extends LineSegmentPath
|
|||||||
createPath(sprite, tiles, destx, desty);
|
createPath(sprite, tiles, destx, desty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the estimated number of millis that we'll be traveling
|
||||||
|
* along this path.
|
||||||
|
*/
|
||||||
|
public long getEstimTravelTime ()
|
||||||
|
{
|
||||||
|
return (long)(_estimPixels / _vel);
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public boolean tick (Pathable pable, long timestamp)
|
public boolean tick (Pathable pable, long timestamp)
|
||||||
{
|
{
|
||||||
@@ -169,6 +179,12 @@ public class TilePath extends LineSegmentPath
|
|||||||
*/
|
*/
|
||||||
protected void addNode (int tx, int ty, int x, int y, int dir)
|
protected void addNode (int tx, int ty, int x, int y, int dir)
|
||||||
{
|
{
|
||||||
|
if (_last == null) {
|
||||||
|
_last = new Point();
|
||||||
|
} else {
|
||||||
|
_estimPixels += MathUtil.distance(_last.x, _last.y, x, y);
|
||||||
|
}
|
||||||
|
_last.setLocation(x, y);
|
||||||
_nodes.add(new TilePathNode(tx, ty, x, y, dir));
|
_nodes.add(new TilePathNode(tx, ty, x, y, dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,6 +194,12 @@ public class TilePath extends LineSegmentPath
|
|||||||
/** The destination tile path node. */
|
/** The destination tile path node. */
|
||||||
protected TilePathNode _dest;
|
protected TilePathNode _dest;
|
||||||
|
|
||||||
|
/** Used to compute estimated travel time. */
|
||||||
|
protected Point _last;
|
||||||
|
|
||||||
|
/** Estimated pixels traveled. */
|
||||||
|
protected int _estimPixels;
|
||||||
|
|
||||||
/** The scene metrics. */
|
/** The scene metrics. */
|
||||||
protected MisoSceneMetrics _metrics;
|
protected MisoSceneMetrics _metrics;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user