Esempio n. 1
0
        public EntityLivingBase(Rectangle[] bounds) : base(bounds)
        {
            //TileMaps für die BegweungsAnimationen
            Bitmap[][] images = new Bitmap[][] { ResourceManager.GetImages(this, "Right"), ResourceManager.GetImages(this, "Left") };
            //Einfärben für die Hurttime
            Bitmap[][] hurtTimeImages = new Bitmap[images.Length][];
            for (int i = 0; i < images.Length; i++)
            {
                hurtTimeImages[i] = new Bitmap[images[i].Length];
                for (int j = 0; j < images[i].Length; j++)
                {
                    hurtTimeImages[i][j] = RenderUtils.PaintBitmap(images[i][j], Color.Red, true);
                }
            }
            //Erstellen der Bewegungs-Animation und
            this.animations        = new FrameAnimation[] { new FrameAnimation(FPS, false, images[0]), new FrameAnimation(FPS, false, images[1]) };
            this.hurtTimeAnimation = new FrameAnimation[] { new FrameAnimation(FPS, false, hurtTimeImages[0]), new FrameAnimation(FPS, false, hurtTimeImages[1]) };

            Facing    = EnumFacing.RIGHT;
            animation = animations[0];
            //Erstellen der BoundingBox für Kollisionen
            Box = new BoundingBox(this, animation.Image.Width, animation.Image.Height);
            //Erstellen der Schlag- und TodesAnimation
            swing = CustomAnimation <float> .CreateDefaultAnimation(1.0f);

            swing.Toleranz  = 1E-2f;
            swing.OnFinish += (object sender, EventArgs args) =>
            {
                if (swing.Increments)
                {
                    swing.Reverse();
                }
            };
            swing.Reverse();
            death = CustomAnimation <float> .CreateDefaultAnimation(1.0f);

            death.Toleranz = 1e-5f;
            Health         = 20;
        }