/// <summary> /// Default constructor /// </summary> public RayCaster2() { stage.keyDown += e => { var key = e.keyCode; fKeyUp.ProcessKeyDown(key); fKeyDown.ProcessKeyDown(key); fKeyLeft.ProcessKeyDown(key); fKeyRight.ProcessKeyDown(key); }; stage.keyUp += e => { var key = e.keyCode; fKeyUp.ProcessKeyUp(key); fKeyDown.ProcessKeyUp(key); fKeyLeft.ProcessKeyUp(key); fKeyRight.ProcessKeyUp(key); }; createTables(); var data = new BitmapData(DefaultWidth, DefaultHeight, false); var bitmap = new Bitmap(data); bitmap.scaleX = DefaultScale; bitmap.scaleY = DefaultScale; fOffscreenGraphics = data; bitmap.AttachTo(this); stage.enterFrame += e => run(); }
public Actor(Bitmap[] frames, Bitmap corpse, Bitmap blood, Sound death) { this._frames = frames; this._corpse = corpse; this._blood = blood; this.mouseEnabled = false; PlayDeathSound = death.ToAction(); Kill = delegate { IsAlive = false; PlayDeathSound(); foreach (var v in frames) v.Orphanize(); #region corpse if (corpse != null) { corpse.MoveToCenter().AttachTo(this); (10000 + 10000.FixedRandom()).AtDelay( delegate { if (IsAlive) return; corpse.Orphanize(); blood.x = -blood.width / 2; blood.y = -blood.height / 2; blood.AttachTo(this); ((20000 + 10000.FixedRandom())).AtDelay( delegate { if (IsAlive) return; blood.Orphanize(); IsCorpseAndBloodGone = true; if (CorpseAndBloodGone != null) CorpseAndBloodGone(); } ); IsCorpseGone = true; if (CorpseGone != null) CorpseGone(); } ); } #endregion if (Die != null) Die(); }; //this.Moved += // delegate // { RunAnimationTimer = (1000 / 15).AtInterval( t => { if (!IsAlive) { t.stop(); return; } if (!RunAnimation) return; ShowFrame(t.currentCount); } ); ShowFrame(0); }