package world.items { import flash.display.Sprite; import flash.geom.Point; import creatures.*; import creatures.parts.*; import world.items.behaviors.*; public class SheepDweller extends Dweller { private static const WALK_CYCLE_FRAMES:int = 20; private static const WALK_CYCLE_LEGS:Array = [ [0,1.8,0], [0,1.3,2], [0,0.5,0], [0,1.2,0], ]; private static const STAND_CYCLE_FRAMES:int = 1; private static const STAND_CYCLE_LEGS:Array = [ [0,1.3,0], ]; private static const TREMBLE_CYCLE_FRAMES:int = 4; private static const TREMBLE_CYCLE_LEGS:Array = [ [0,1.3,0], [0,0.5,0], ]; public function SheepDweller(loc:Point = null) { _display = new Sheep(); var sheep:Sheep = _display as Sheep; size = 80; // create behavior setBehavior(new Grazer()); // create animations var anim:SkeletonAnimation; var segAnim:SegmentAnimation; // Stand cycle anim = new SkeletonAnimation(); segAnim = new SegmentAnimation(STAND_CYCLE_FRAMES, STAND_CYCLE_LEGS); anim.addSegmentAnimation(segAnim, "leftLeg"); anim.addSegmentAnimation(segAnim, "rightLeg"); anim.addSegmentAnimation(segAnim, "leftArm"); anim.addSegmentAnimation(segAnim, "rightArm"); addSkeletonAnimation(anim, Dweller.STAND_ANIM); // Walk cycle anim = new SkeletonAnimation(); segAnim = new SegmentAnimation(WALK_CYCLE_FRAMES, WALK_CYCLE_LEGS); anim.addSegmentAnimation(segAnim, "leftLeg"); anim.addSegmentAnimation(segAnim, "rightLeg", WALK_CYCLE_FRAMES/2); anim.addSegmentAnimation(segAnim, "leftArm", WALK_CYCLE_FRAMES/2); anim.addSegmentAnimation(segAnim, "rightArm"); addSkeletonAnimation(anim, Dweller.WALK_ANIM); // Tremble cycle anim = new SkeletonAnimation(); segAnim = new SegmentAnimation(TREMBLE_CYCLE_FRAMES, TREMBLE_CYCLE_LEGS); anim.addSegmentAnimation(segAnim, "leftLeg"); anim.addSegmentAnimation(segAnim, "rightLeg"); anim.addSegmentAnimation(segAnim, "leftArm", WALK_CYCLE_FRAMES/2); anim.addSegmentAnimation(segAnim, "rightArm", WALK_CYCLE_FRAMES/2); addSkeletonAnimation(anim, Dweller.TREMBLE_ANIM); // init loc if (loc) { location = loc; } } public override function clone():Dweller { var copy:SheepDweller = new SheepDweller(); return copy; } public override function toString():String { return "[Sheep Dweller]"; } } }