Checkpoint commit wiring up a CrowdStageScenePanel that handles Occupant locations and making a sprite for them on the screen. Lots of TODOs still in this stuff, esp. related to Pathing.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@965 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -87,6 +87,9 @@ public class MisoScenePanel extends Sprite
|
||||
|
||||
_isoView.addEventListener(MouseEvent.CLICK, onClick);
|
||||
|
||||
_objScene = new IsoScene();
|
||||
_objScene.layoutRenderer = new ClassFactory(PrioritizedSceneLayoutRenderer);
|
||||
|
||||
addChild(_loading = createLoadingPanel());
|
||||
}
|
||||
|
||||
@@ -118,13 +121,27 @@ public class MisoScenePanel extends Sprite
|
||||
}
|
||||
|
||||
public function onClick (event :MouseEvent) :void
|
||||
{
|
||||
// TODO - handle _hobject
|
||||
handleMousePressed(null, event);
|
||||
}
|
||||
|
||||
public function handleMousePressed (hobject :Object, event :MouseEvent) :Boolean
|
||||
{
|
||||
var viewPt :Point = _isoView.globalToLocal(new Point(event.stageX, event.stageY));
|
||||
moveBy(new Point(viewPt.x - _isoView.width / 2, viewPt.y - _isoView.height / 2));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function moveBy (pt :Point) :void
|
||||
{
|
||||
// No scene model yet, just do it...
|
||||
if (_model == null) {
|
||||
_isoView.centerOnPt(new Pt(pt.x + _isoView.currentX,
|
||||
pt.y + _isoView.currentY), false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pendingMoveBy != null) {
|
||||
log.info("Already performing a move...");
|
||||
return;
|
||||
@@ -330,9 +347,6 @@ public class MisoScenePanel extends Sprite
|
||||
// Clear it out...
|
||||
_isoView.removeAllScenes();
|
||||
|
||||
_objScene = new IsoScene();
|
||||
_objScene.layoutRenderer = new ClassFactory(PrioritizedSceneLayoutRenderer);
|
||||
|
||||
refreshBaseBlockScenes();
|
||||
}
|
||||
|
||||
@@ -345,6 +359,37 @@ public class MisoScenePanel extends Sprite
|
||||
return null;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public function canTraverse (traverser :Object, tx :int, ty :int) :Boolean
|
||||
{
|
||||
var block :SceneBlock = _blocks.get(SceneBlock.getBlockKey(tx, ty));
|
||||
return (block == null) ? canTraverseUnresolved(traverser, tx, ty) :
|
||||
block.canTraverse(traverser, tx, ty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Derived classes can control whether or not we consider unresolved tiles to be traversable
|
||||
* or not.
|
||||
*/
|
||||
protected function canTraverseUnresolved (traverser :Object, tx :int, ty :int) :Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a path for the specified sprite to the specified tile coordinates.
|
||||
*
|
||||
* @param loose if true, an approximate path will be returned if a complete path cannot be
|
||||
* located. This path will navigate the sprite "legally" as far as possible and then walk the
|
||||
* sprite in a straight line to its final destination. This is generally only useful if the
|
||||
* the path goes "off screen".
|
||||
*/
|
||||
public function getPath (sprite :Sprite, x :int, y :int, loose :Boolean) :Object // TODO Path
|
||||
{
|
||||
// TODO Path
|
||||
return null;
|
||||
}
|
||||
|
||||
protected var _model :MisoSceneModel;
|
||||
|
||||
protected var _isoView :IsoView;
|
||||
|
||||
@@ -209,6 +209,12 @@ public class SceneBlock
|
||||
}
|
||||
}
|
||||
|
||||
public function canTraverse (traverser :Object, tx :int, ty :int) :Boolean
|
||||
{
|
||||
// TODO Path
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function noteTileToLoad () :void
|
||||
{
|
||||
_pendingCt++;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.threerings.miso.util {
|
||||
|
||||
import com.threerings.util.MathUtil;
|
||||
|
||||
public class MisoUtil
|
||||
{
|
||||
public static function fullToTile (fullCoord :int) :int
|
||||
{
|
||||
return MathUtil.floorDiv(fullCoord, FULL_TILE_FACTOR);
|
||||
}
|
||||
|
||||
public static function tileToFull (tileCoord :int, fine :int = 0) :int
|
||||
{
|
||||
return tileCoord * FULL_TILE_FACTOR + fine;
|
||||
}
|
||||
|
||||
public static function fullToFine (fullCoord :int) :int
|
||||
{
|
||||
return (fullCoord - (fullToTile(fullCoord) * FULL_TILE_FACTOR));
|
||||
}
|
||||
|
||||
protected static const FULL_TILE_FACTOR :int = 100;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user