Esempio n. 1
0
        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);

       
        }