public override void CreateDrawBehavior(string unitName, IGame game) { // Base stelt de standaard behavior in: running base.CreateDrawBehavior(unitName, game); _runningDrawBehavior = DrawBehavior; _jumpingDrawBehavior = UnitFactories.DrawBehaviors.Create(unitName, "jumping"); }
public Player(Image image, GameWorld gameWorld) { double speed = 0.000001; this.MotionBehavior = new NormalMotionBehavior(this, gameWorld); MotionBehavior.CanMoveThroughWall = false; Location = new DecimalPoint(300, 150); Image = image; Angle = 0; ActualSpeed = 0; Acceleration = 0.3; TargetSpeed = 0; Inertia = new DecimalPoint(0.5, 0.5); DrawBehavior = new TopDownRotationDrawBehavior(this); //((GrowingImageDrawBehavior)DrawBehavior).SpeedX = 10; //((GrowingImageDrawBehavior)DrawBehavior).SpeedY = 10; //((GrowingImageDrawBehavior) DrawBehavior).SizeChanged += (Size) => //{ // if (Size.Width > 400) // { // ((GrowingImageDrawBehavior)DrawBehavior).SpeedX = -2; // ((GrowingImageDrawBehavior)DrawBehavior).SpeedY = -2; // } // if (((GrowingImageDrawBehavior) DrawBehavior).SpeedY < 0) // { // ((GrowingImageDrawBehavior)DrawBehavior).SpeedX = 0 - (int)speed; // ((GrowingImageDrawBehavior)DrawBehavior).SpeedY = 0 - (int)speed; // speed += speed; // } //}; Paralax = Paralax.Middleground; IsPhysicalObject = true; }
protected virtual void setDrawBehavior(IDrawBehavior behavior, IGame game) { if (behavior != null) { if (_drawBehavior != null) _drawBehavior.RemoveGfx(game); _drawBehavior = behavior; _drawBehavior.AddGfx(game); } }