Ejemplo n.º 1
0
 public Keyframe()
 {
     keyframenumber = 0;
     rectangles = new Dictionary<string, FrameRectangle>();
     killingRect = new SpecialRect(new Rectangle());
     dieRect = new SpecialRect(new Rectangle());
 }
Ejemplo n.º 2
0
        public void LoadFrame(string[] names,string pdata,int number)
        {
            FrameRectangle newrect= new FrameRectangle();
            string[] data = pdata.Split('_');
            string[] rects = data[0].Split(':');
            keyframenumber = number;
            if (rects.Length >= names.Length)
            {
                for (int i = 0; i < names.Length; i++)
                {
                    try
                    {
                        newrect.LoadFromData(rects[i]);

                        rectangles.Add(names[i], newrect);
                    }
                    catch
                    {

                    }
                }
                if (data.Length > 1)
                {
                    int x, y, width, height;
                    string[] killdata = data[1].Split(',');
                    if (killdata.Length >= 8)
                    {
                        Rectangle killRect;
                        x = int.Parse(killdata[0]);
                        y = int.Parse(killdata[1]);
                        width = int.Parse(killdata[2]);
                        height = int.Parse(killdata[3]);
                        killRect = new Rectangle(x, y, width, height);
                        KillingRect = new SpecialRect(killRect);

                        x = int.Parse(killdata[4]);
                        y = int.Parse(killdata[5]);
                        width = int.Parse(killdata[6]);
                        height = int.Parse(killdata[7]);
                        killRect = new Rectangle(x, y, width, height);
                        DieRect = new SpecialRect(killRect);
                    }
                    else
                    {
                        KillingRect = new SpecialRect(new Rectangle(0,0,10,10));
                        DieRect = new SpecialRect(new Rectangle(0,0,10,10));
                    }
                }
                else
                {
                    KillingRect = new SpecialRect(new Rectangle(0, 0, 10, 10));
                    DieRect = new SpecialRect(new Rectangle(0, 0, 10, 10));
                }
            }
            else
            {
                FileManager.WriteInErrorLog(this, "Es sind zu wenig FrameRectangle Daten vorhanden um alle Rectangles zu füllen");
                throw new ArgumentException("Es sind zu wenig FrameRectangle Daten vorhanden um alle Rectangles zu füllen");
            }
        }
Ejemplo n.º 3
0
        protected override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            SpecialRect killRect;
            if (enemy.Animations.CurrentAnimationKeyframe.KillingRect != null)
                killRect = new SpecialRect(enemy.Animations.CurrentAnimationKeyframe.KillingRect.Rectangle);
            else
                killRect = new SpecialRect(new Rectangle());
            Rectangle temp = new Rectangle(
                killRect.OriginalRectangle.X + (int)enemy.Pos.X,
                killRect.OriginalRectangle.Y + (int)enemy.Pos.Y,
                killRect.OriginalRectangle.Width,
                killRect.OriginalRectangle.Height);
            killRect.Rectangle = temp;
            SpecialRect dieRect;
            if (enemy.Animations.CurrentAnimationKeyframe.DieRect != null)

                dieRect = new SpecialRect(enemy.Animations.CurrentAnimationKeyframe.DieRect.Rectangle);
            else
                dieRect = new SpecialRect(new Rectangle());
            temp = new Rectangle(
                dieRect.OriginalRectangle.X + (int)enemy.Pos.X,
                dieRect.OriginalRectangle.Y + (int)enemy.Pos.Y,
                dieRect.OriginalRectangle.Width,
                dieRect.OriginalRectangle.Height);
            dieRect.Rectangle = temp;
            Rectangle collision = new Rectangle(enemy.Collisionrect.X,
                enemy.Collisionrect.Y,
                enemy.Collisionrect.Width,
                enemy.Collisionrect.Height);
            collision.Location = new Point((int)enemy.Pos.X + collision.X, (int)enemy.Pos.Y + collision.Y);
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            for (int i = 0; i*20 < Size.Height; i++)
            {
                spriteBatch.Draw(tex, new Rectangle(Size.Width / 2, i*20, 2, 10), new Color(255,255,255, (byte)127));
            }
            spriteBatch.End();
            enemy.Draw(gameTime, spriteBatch, Matrix.CreateTranslation(Vector3.Zero),textures,null,null);
            if (editMode == EditMode.Data)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(tex, collision, new Color(0, 0, 255, 127));
                spriteBatch.Draw(tex, killRect.Rectangle, new Color(255,0,0, 127));
                spriteBatch.Draw(tex, dieRect.Rectangle, new Color(0,255,0, 127));
                //spriteBatch.DrawString(font,DetermineMousePos().ToString(), Vector2.Zero, Color.Red);
                spriteBatch.End();
            }
            playcontrol.Draw(spriteBatch);
        }