Esempio n. 1
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            int startX, startY;

            if (comboBox1.SelectedItem != null && comboBox2.SelectedItem != null)
                if (comboBox1.SelectedItem != comboBox2.SelectedItem)
                {
                    FrameRectangle[] parentRectangles = new FrameRectangle[currentAnimation.Frames.Length];
                    FrameRectangle[] childRectangles = new FrameRectangle[currentAnimation.Frames.Length];
                    Vector2 parentRotationVector;
                    float startRotationOffset;
                    Vector2 transformedVector;

                    for (int i = 0; i < currentAnimation.Frames.Length; i++)
                    {
                        parentRectangles[i] = currentAnimation.Frames[i].GetRectangles[comboBox1.SelectedItem.ToString()];
                        childRectangles[i] = currentAnimation.Frames[i].GetRectangles[comboBox2.SelectedItem.ToString()];
                    }

                    parentRotationVector = new Vector2(childRectangles[0].Rect.X, childRectangles[0].Rect.Y) - new Vector2(parentRectangles[0].Rect.X, parentRectangles[0].Rect.Y);

                    startRotationOffset = parentRectangles[0].Rotation;

                    startX = childRectangles[0].Rect.X;
                    startY = childRectangles[0].Rect.Y;

                    for (int i = 1; i < currentAnimation.Frames.Length; i++)
                    {

                        if (checkBoxRotation.Checked)
                        {
                            transformedVector = Vector2.Transform(parentRotationVector, Matrix.CreateRotationZ(parentRectangles[i].Rotation - startRotationOffset));
                            childRectangles[i].Rect.X = parentRectangles[i].Rect.X + (int)transformedVector.X;
                            childRectangles[i].Rect.Y = parentRectangles[i].Rect.Y + (int)transformedVector.Y;
                        }
                        else
                        {
                            int offsetX, offsetY;
                            offsetX = parentRectangles[i].Rect.X - parentRectangles[i - 1].Rect.X;
                            offsetY = parentRectangles[i].Rect.Y - parentRectangles[i - 1].Rect.Y;
                            childRectangles[i].Rect.X = startX + offsetX;
                            childRectangles[i].Rect.Y = startY + offsetY;
                            startX += offsetX;
                            startY += offsetY;
                        }
                    }

                    ChildTransformed(comboBox2.SelectedItem.ToString(), childRectangles);
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                    MessageBox.Show(this, "Parent und Child dürfen nicht gleich sein!", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
                MessageBox.Show(this, "Du musst Parent und Child angeben", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
 public LinearInterpolationForm(int frames,FrameRectangle standardRect,FrameRectangle[] origFrames)
 {
     InitializeComponent();
     endFrameUpDown.Maximum = frames;
     endFrameUpDown.Value = frames;
     startFrameUpDown.Maximum = endFrameUpDown.Value - 1M;
     LoadRectangleData(standardRect);
     orgFrames = (FrameRectangle[]) origFrames.Clone();
     InitializeCheckBox();
 }
Esempio n. 3
0
 public void AddRectangle(string rectangle, Texture2D tex,FrameRectangle newrect)
 {
     //textures.Add(rectangle, tex);
     foreach (Animation anim in animations)
     {
         foreach (Keyframe frame in anim.Frames)
         {
             frame.GetRectangles.Add(rectangle, newrect);
         }
     }
 }
Esempio n. 4
0
        private FrameRectangle GenerateFrameRectangle()
        {
            FrameRectangle rect = new FrameRectangle();

            Microsoft.Xna.Framework.Rectangle pos = new Microsoft.Xna.Framework.Rectangle((int)xPositionNumericUpDown.Value, (int)yPositionNumericUpDown.Value, (int)widthNumericUpDown.Value, (int)heightNumericUpDown.Value);
            float rotation = (float)rotationNumericUpDown.Value;
            float layer = (float)layerNumericUpDown.Value;
            Vector2 origin = new Vector2((float)xOriginNumericUpDown.Value,(float)yOriginNumericUpDown.Value);
            Color color = new Color((byte)rColorNumericUpDown.Value, (byte)gColorNumericUpDown.Value, (byte)bColorNumericUpDown.Value, (byte)aColorNumericUpDown.Value);
            rect.Load(pos, rotation, layer, color, origin);
            return rect;
        }
Esempio n. 5
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (comboBoxRectangle.SelectedItem != null && checkBoxFrameOffset.Checked)
            {
                int offset = (int)numericUpDownOffset.Value;
                FrameRectangle[] oldRectangles = new FrameRectangle[currentAnimation.Frames.Length];
                FrameRectangle[] newRectangles = new FrameRectangle[currentAnimation.Frames.Length];

                for (int i = 0; i < oldRectangles.Length; i++)
                {
                    oldRectangles[i] = currentAnimation.Frames[i].GetRectangles[comboBoxRectangle.SelectedItem.ToString()];
                }

                for (int i = 0; i < oldRectangles.Length; i++)
                {
                    newRectangles[i] = oldRectangles[i + offset < oldRectangles.Length ? i + offset : i + offset - oldRectangles.Length];
                }

                RectangleOffset(comboBoxRectangle.SelectedItem.ToString(), newRectangles);
            }
            else if (checkBox1.Checked)
            {
                List<string> rects = new List<string>();
                foreach (string key in currentAnimation.Frames[0].GetRectangles.Keys)
                    rects.Add(key);
                foreach (string rect in rects)
                {
                    FrameRectangle[] oldRectangles = new FrameRectangle[currentAnimation.Frames.Length];
                    FrameRectangle[] newRectangles = new FrameRectangle[currentAnimation.Frames.Length];

                    for (int i = 0; i < oldRectangles.Length; i++)
                    {
                        oldRectangles[i] = currentAnimation.Frames[i].GetRectangles[rect];
                    }

                    for (int i = 0; i < oldRectangles.Length; i++)
                    {
                        newRectangles[i] = oldRectangles[i];
                        newRectangles[i].Rect.X += (int)numericUpDown1.Value;
                        newRectangles[i].Rect.Y += (int)numericUpDown2.Value;

                    }

                    RectangleOffset(rect, newRectangles);
                }
                Close();
            }
            else
                MessageBox.Show(this, "A Rectangle must be Selected", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Esempio n. 6
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");
            }
        }
Esempio n. 7
0
 public void AddRectangle(string name,Texture2D tex, FrameRectangle newrect)
 {
     if (enemyvariables[EnemyVariables.AnimRectangles] == "")
         enemyvariables[EnemyVariables.AnimRectangles] = name;
     else
         enemyvariables[EnemyVariables.AnimRectangles] += "," + name;
     animations.AddRectangle(name, tex, newrect);
 }
Esempio n. 8
0
 private void SetRectangle()
 {
     FrameRectangle rect = new FrameRectangle();
     Vector2 origin;
     origin = new Vector2((float)xOriginNumericUpDown.Value, (float)yOriginNumericUpDown.Value);
     Microsoft.Xna.Framework.Rectangle pos;
     Microsoft.Xna.Framework.Color color = new Microsoft.Xna.Framework.Color(
         (byte)rColorNumericUpDown.Value,
         (byte)gColorNumericUpDown.Value,
         (byte)bColorNumericUpDown.Value,
         (byte)aColorNumericUpDown.Value);
     pos = new Microsoft.Xna.Framework.Rectangle(
         (int)xPositionNumericUpDown.Value,
         (int)yPositionNumericUpDown.Value,
         (int)widthNumericUpDown.Value,
         (int)heightNumericUpDown.Value);
     float rotation = (float)rotationNumericUpDown.Value;
     float layer = (float)layerNumericUpDown.Value;
     rect.Load(pos, rotation, layer, color, origin);
     enemyControl.Enemy.Animations.CurrentAnimationKeyframe.GetRectangles[(string)rectangleComboBox.SelectedItem] = rect;
 }
Esempio n. 9
0
        void rectForm_RectangleLoaded(string enemyName, string rectangleName, FrameRectangle rect)
        {
            enemyControl.AddAnimationRectangle(rectangleName, rect);
            //rectangleComboBox.Items.Add(rectangleName);

            SetKeyFrameList(enemyControl.Enemy.Animations.CurrentAnimationKeyframes);
            SetRectComboBox();
            rectangleComboBox.SelectedItem = rectangleName;
            enemyControl.CurrentRectangle = (string)rectangleComboBox.SelectedItem;
        }
        private void LoadRectangleData(FrameRectangle rect)
        {
            xPositionNumericUpDown.Value = rect.Rect.X;
            xPositionNumericUpDown.Value = rect.Rect.X;
            yPositionNumericUpDown.Value = rect.Rect.Y;
            widthNumericUpDown.Value = rect.Rect.Width;
            heightNumericUpDown.Value = rect.Rect.Height;
            rotationNumericUpDown.Value = (decimal)rect.Rotation;
            layerNumericUpDown.Value = (decimal)rect.DrawPosition;
            rColorNumericUpDown.Value = rect.Color.R;
            gColorNumericUpDown.Value = rect.Color.G;
            bColorNumericUpDown.Value = rect.Color.B;
            aColorNumericUpDown.Value = rect.Color.A;

            xStartPositionUpDown.Value = rect.Rect.X;
            yStartPositionUpDown.Value = rect.Rect.Y;
            widthStartPositionUpDown.Value = rect.Rect.Width;
            heightStartPositionUpDown.Value = rect.Rect.Height;
            rotationStartUpDown.Value = (decimal)rect.Rotation;
            layerStartUpDown.Value = (decimal)rect.DrawPosition;
            rColorStartUpDown.Value = rect.Color.R;
            gColorStartUpDown.Value = rect.Color.G;
            bColorStartUpDown.Value = rect.Color.B;
            aColorStartUpDown.Value = rect.Color.A;
        }
Esempio n. 11
0
 void offsetForm_RectangleOffset(string rectangle, FrameRectangle[] tranformedRectangles)
 {
     for (int i = 0; i < tranformedRectangles.Length; i++)
     {
         enemyControl.Enemy.Animations.Animations[(int)enemyControl.Enemy.Animations.CurrentAnimation].Frames[i].GetRectangles[rectangle] = tranformedRectangles[i];
     }
 }
Esempio n. 12
0
        private void linearToolButton_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty((string)rectangleComboBox.SelectedItem))
            {
                FrameRectangle[] orgFrames = new FrameRectangle[enemyControl.Enemy.Animations.CurrentAnimationKeyFrameCount];
                for (int i = 0; i < enemyControl.Enemy.Animations.CurrentAnimationKeyFrameCount; i++)
                    orgFrames[i] = enemyControl.Enemy.Animations.CurrentAnimationKeyframes[i].GetRectangles[(string)rectangleComboBox.SelectedItem];

                linearForm = new LinearInterpolationForm(
                    enemyControl.Enemy.Animations.CurrentAnimationKeyFrameCount,
                    enemyControl.Enemy.Animations.CurrentAnimationKeyframe.GetRectangles[(string)rectangleComboBox.SelectedItem],
                    orgFrames);
                linearForm.LinearInterpolated += new LinearInterpolationForm.LinearRectangleEventHandler(linearForm_LinearInterpolated);
                linearForm.ShowDialog(this);
            }
        }
Esempio n. 13
0
 void linearForm_LinearInterpolated(FrameRectangle[] frameRects, int startPos, int endPos)
 {
     for (int i = startPos; i < endPos; i++)
     {
         enemyControl.Enemy.Animations.CurrentAnimationKeyframes[i].GetRectangles[(string)rectangleComboBox.SelectedItem] = frameRects[i-startPos];
     }
     LoadRectangleData();
 }
Esempio n. 14
0
 void enemyControl_CurrentRectangleChanged(FrameRectangle newrect)
 {
     LoadRectangleData();
 }
Esempio n. 15
0
 public void AddAnimationRectangle(string rectName, FrameRectangle newrect)
 {
     Texture2D tex = content.Load<Texture2D>(GameConstants.EnemiesPath + Enemy.Type + "/" + rectName);
     Enemy.AddRectangle(rectName, tex, newrect);
     textures.Add(rectName, tex);
 }
Esempio n. 16
0
 void ParentForm_ChildTransformed(string child, FrameRectangle[] tranformedRectangles)
 {
     //throw new NotImplementedException();
 }
Esempio n. 17
0
 void parentForm_ChildTransformed(string child, FrameRectangle[] tranformedRectangles)
 {
     for (int i = 0; i < tranformedRectangles.Length; i++)
     {
         enemyControl.Enemy.Animations.Animations[(int)enemyControl.Enemy.Animations.CurrentAnimation].Frames[i].GetRectangles[child] = tranformedRectangles[i];
     }
     //throw new NotImplementedException();
 }
        private FrameRectangle[] Interpolate()
        {
            int length = (int)(endFrameUpDown.Value - startFrameUpDown.Value);
            int start = (int)startFrameUpDown.Value;
            Microsoft.Xna.Framework.Vector2 origin;
            Microsoft.Xna.Framework.Color color;
            FrameRectangle[] interpolatedRects= new FrameRectangle[length];
            RectangleDifference differences = GetDifference(length);

            for (int i = 0; i < length; i++)
            {
                Microsoft.Xna.Framework.Rectangle rect;
                float rotation;
                float layer;
                if (rectGB1.Enabled)
                     rect = new Microsoft.Xna.Framework.Rectangle(
                        (int)xStartPositionUpDown.Value + (int)(i * differences.xPositionDifference),
                        (int)yStartPositionUpDown.Value + (int)(i * differences.yPositionDifference),
                        (int)widthStartPositionUpDown.Value + (int)(i * differences.widthPositionDifference),
                        (int)heightStartPositionUpDown.Value + (int)(i * differences.heightPositionDifference));
                else
                    rect = orgFrames[start + i].Rect;

                if (rotationNumericUpDown.Enabled)
                    rotation = (float)rotationStartUpDown.Value + (differences.rotationDifference * i);
                else
                    rotation = orgFrames[start + i].Rotation;

                if (layerNumericUpDown.Enabled)
                    layer = (float)layerStartUpDown.Value + (differences.layerDifference * i);
                else
                    layer = orgFrames[start + i].DrawPosition;

                if (origGB2.Enabled)
                    origin = new Microsoft.Xna.Framework.Vector2(
                        (float)xOriginStartUpDown.Value + differences.xOriginDifference * i,
                        (float)yOriginStartUpDown.Value + differences.yOriginDifference * i);
                else
                    origin = orgFrames[start + i].Origin;

                if (colorGB2.Enabled)
                    color = new Microsoft.Xna.Framework.Color(
                        (((float)rColorStartUpDown.Value) + differences.rColorDifference * i) / 255f,
                        (((float)gColorStartUpDown.Value) + differences.gColorDifference * i) / 255f,
                        (((float)bColorStartUpDown.Value) + differences.bColorDifference * i) / 255f,
                        (((float)(aColorStartUpDown.Value) + (differences.aColorDifference * i))) / 255f);
                else
                    color = orgFrames[start + i].Color;

                interpolatedRects[i].Load(rect, rotation, layer, color, origin);
            }

            return interpolatedRects;
        }