Exemplo n.º 1
0
 private void addtoAnimationsbutt_Click(object sender, EventArgs e)
 {
     if (listOfAnimations.Count < 17)
                 {
                         indvAnimation tempAm = new indvAnimation(singleAnimation);
                         indvFrame tempFrame = new indvFrame(singleFrame);
                         if (currentAnimation == -1)
                         {
                                 listOfAnimations.Add(tempAm);
                         }
                         else
                         {
                                 if (currentFrame != -1)
                                 {
                                         tempAm.AnimationListofFrames[currentFrame] = tempFrame;
                                 }
                                 listOfAnimations[currentAnimation] = tempAm;
                         }
                 }
                 changedAnimation = -1;
                 currentAnimation = -1;
                 singleAnimation.AnimationListofFrames.Clear();
                 currentFrame = -1;
                 changedFrame = -1;
                 sourceRectbutt.BackColor = SystemColors.Control;
                 sourceRectbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                 sourceRectButtpressed = false;
                 anchorPointbutt.BackColor = SystemColors.Control;
                 anchorPointbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                 anchorPointButtpressed = false;
                 collisionRectbutt.BackColor = SystemColors.Control;
                 collisionRectbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                 collisionRectButtpressed = false;
                 mouseCollRectUp = false;
                 mouseCollDraw = false;
                 collRectDrawn = false;
                 mouseCollRectClick = false;
                 mouseSrcRectClick = false;
                 mouseSrcRectUp = false;
                 mouseSrcDraw = false;
                 srcRectDrawn = false;
                 renderMouseClick = false;
                 tempSrcRect = Rectangle.Empty;
                 tempCollRect = Rectangle.Empty;
                 singleFrame.AnchorPointX = 0;
                 singleFrame.AnchorPointY = 0;
                 singleFrame.FrameCollRect = Rectangle.Empty;
                 singleFrame.FrameDuration = 0.00;
                 singleFrame.FrameSrcRect = Rectangle.Empty;
                 singleFrame.Trigger = -1;
                 mouseAchorDraw = false;
                 frameTabControl.SelectedTab = sourceRectTab;
 }
Exemplo n.º 2
0
 public indvAnimation(indvAnimation iA)
 {
     this.AnimationListofFrames = new List<indvFrame>(iA.AnimationListofFrames);
                     this.animationType = new int();
                     this.AnimationType = iA.AnimationType;
                     this.EntityType = new int();
                     this.EntityType = iA.EntityType;
                     this.looping = iA.looping;
 }
Exemplo n.º 3
0
        public void Update(double _dt)
        {
            if ((listOfAnimations.Count != 0) && (changedAnimation != currentAnimation))
                        {
                                currentAnimation = changedAnimation;
                                singleAnimation = listOfAnimations[currentAnimation];
                        }
                        if ((singleAnimation.AnimationListofFrames.Count != 0)&&(changedFrame!=currentFrame))
                        {
                                currentFrame = changedFrame;
                                singleFrame = singleAnimation.AnimationListofFrames[currentFrame];
                                tempSrcRect = singleFrame.FrameSrcRect;
                                tempCollRect = singleFrame.FrameCollRect;
                                collRectDrawn = true;
                                srcRectDrawn = true;
                                mouseCollDraw = true;
                                mouseSrcDraw = true;
                                durationUpdown.Value = (decimal)singleFrame.FrameDuration;
                                mouseAchorDraw = true;
                        }
                        else if (changedFrame != currentFrame)
                        {
                                currentFrame = -1;
                                changedFrame = -1;
                                sourceRectbutt.BackColor = SystemColors.Control;
                                sourceRectbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                                sourceRectButtpressed = false;
                                anchorPointbutt.BackColor = SystemColors.Control;
                                anchorPointbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                                anchorPointButtpressed = false;
                                collisionRectbutt.BackColor = SystemColors.Control;
                                collisionRectbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                                collisionRectButtpressed = false;
                                mouseCollRectUp = false;
                                mouseCollDraw = false;
                                collRectDrawn = false;
                                mouseCollRectClick = false;
                                mouseSrcRectClick = false;
                                mouseSrcRectUp = false;
                                mouseSrcDraw = false;
                                srcRectDrawn = false;
                                renderMouseClick = false;
                                tempSrcRect = Rectangle.Empty;
                                tempCollRect = Rectangle.Empty;
                                singleFrame.AnchorPointX = 0;
                                singleFrame.AnchorPointY = 0;
                                singleFrame.FrameCollRect = Rectangle.Empty;
                                singleFrame.FrameDuration = 0.00;
                                singleFrame.FrameSrcRect = Rectangle.Empty;
                                singleFrame.Trigger = -1;
                                mouseAchorDraw = false;
                        }
                        if (playing&&singleAnimation.AnimationListofFrames.Count!=0)
                        {
                                timeStarted += _dt;
                                if (timeStarted > singleAnimation.AnimationListofFrames[currentFrame].FrameDuration)
                                {
                                        changedFrame++;
                                        timeStarted = 0.0;
                                }
                                if (changedFrame == singleAnimation.AnimationListofFrames.Count)
                                {
                                        if (looping)
                                        {
                                                changedFrame = 0;
                                        }
                                        else
                                        {
                                                changedFrame--;
                                                playing = false;
                                        }
                                }

                        }
                        if (sourceRectButtpressed)
                        {
                                sourceRectbutt.BackColor = Color.FromArgb(255, 0, 0, 255);
                                sourceRectbutt.ForeColor = Color.FromArgb(255, 255, 255, 255);
                                collisionRectbutt.BackColor = SystemColors.Control;
                                collisionRectbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                                anchorPointbutt.BackColor = SystemColors.Control;
                                anchorPointbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                                if (!srcRectDrawn&&mouseSrcRectClick)
                                {
                                        if (endMousePosX > mousePosX)
                                        {
                                                tempSrcRect.X = mousePosX;
                                                tempSrcRect.Width = endMousePosX - mousePosX;
                                        }
                                        else
                                        {
                                                tempSrcRect.X = endMousePosX;
                                                tempSrcRect.Width = mousePosX - endMousePosX;
                                        }
                                        if (endMousePosY > mousePosY)
                                        {
                                                tempSrcRect.Y = mousePosY;
                                                tempSrcRect.Height = endMousePosY - mousePosY;
                                        }
                                        else
                                        {
                                                tempSrcRect.Y = endMousePosY;
                                                tempSrcRect.Height = mousePosY - endMousePosY;
                                        }
                                }
                                singleFrame.FrameSrcRect = tempSrcRect;
                                sourceXupdown.Value = tempSrcRect.X;
                                sourceYupdown.Value = tempSrcRect.Y;
                                sourceWidthupdown.Value = tempSrcRect.Width;
                                sourceHeightupdown.Value = tempSrcRect.Height;
                                if (mouseSrcRectUp)
                                {
                                        mouseSrcRectClick = false;
                                        mouseSrcRectUp = false;
                                        srcRectDrawn = true;
                                }
                        }
                        if (collisionRectButtpressed)
                        {
                                collisionRectbutt.BackColor = Color.FromArgb(255, 255, 0, 0);
                                collisionRectbutt.ForeColor = Color.FromArgb(255, 255, 255, 255);
                                sourceRectbutt.BackColor = SystemColors.Control;
                                sourceRectbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                                anchorPointbutt.BackColor = SystemColors.Control;
                                anchorPointbutt.ForeColor = Color.FromArgb(255, 0, 0, 0);
                                if (!collRectDrawn&&mouseCollRectClick)
                                {
                                        if (endMousePosX > mousePosX)
                                        {
                                                tempCollRect.X = mousePosX;
                                                tempCollRect.Width = endMousePosX - mousePosX;
                                        }
                                        else
                                        {
                                                tempCollRect.X = endMousePosX;
                                                tempCollRect.Width = mousePosX - endMousePosX;
                                        }
                                        if (endMousePosY > mousePosY)
                                        {
                                                tempCollRect.Y = mousePosY;
                                                tempCollRect.Height = endMousePosY - mousePosY;
                                        }
                                        else
                                        {
                                                tempCollRect.Y = endMousePosY;
                                                tempCollRect.Height = mousePosY - endMousePosY;
                                        }
                                }
                                singleFrame.FrameCollRect = tempCollRect;
                                collisionXupdown.Value = tempCollRect.X;
                                collisionYupdown.Value = tempCollRect.Y;
                                collisionWidthupdown.Value = tempCollRect.Width;
                                collisionHeightupdown.Value = tempCollRect.Height;
                                if (mouseCollRectUp)
                                {
                                        mouseCollRectClick = false;
                                        mouseCollRectUp = false;
                                        collRectDrawn = true;
                                }
                        }
                        if (!anchorPointButtpressed)
                        {
                                if (frameTabControl.SelectedTab == sourceRectTab)
                                {
                                        sourceRectButtpressed = true;
                                        collisionRectButtpressed = false;
                                }
                                else
                                {
                                        sourceRectButtpressed = false;
                                        collisionRectButtpressed = true;
                                }
                                anchorXupdown.Value = singleFrame.AnchorPointX;
                                anchorYupdown.Value = singleFrame.AnchorPointY;
                        }
                        durationUpdown.Value = (decimal)singleFrame.FrameDuration;
                        if (currentFrame >= 0&&!playing&&listOfFrames.Count!=0)
                        {
                                singleAnimation.AnimationListofFrames[currentFrame] = singleFrame;
                        }
        }
Exemplo n.º 4
0
        private void xMLToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            newToolStripMenuItem_Click(sender, e);
                        MessageBox.Show("Please select Image to load!");
                        //Set the Filter String
                        mainDlg.Filter = "All Files|*.*|Png Files|*.png";

                        //Set the Filter Index
                        mainDlg.FilterIndex = 2;

                        //Set the default extension
                        mainDlg.DefaultExt = "png";

                        //Set the Filter String
                        dlgXml.Filter = "All Files|*.*|Xml Files|*.xml";

                        //Set the Filter Index
                        dlgXml.FilterIndex = 2;

                        //Set the default extension
                        dlgXml.DefaultExt = "xml";

                        if (DialogResult.OK == mainDlg.ShowDialog())
                        {
                                MessageBox.Show("Please select Xml file!");
                                if (DialogResult.OK == dlgXml.ShowDialog())
                                {
                                        XmlDocument doc = new XmlDocument();
                                        doc.Load(dlgXml.FileName);
                                        XmlElement rootNode = doc.DocumentElement;
                                        XmlNode parentNode = rootNode.FirstChild;
                                        XmlNode filename = parentNode.FirstChild;
                                        fileName = filename.Value;
                                        mainImageID = tM.LoadTexture(mainDlg.FileName, Color.FromArgb(255, 255, 255, 255).ToArgb());
                                        if (mainImageID == -1)
                                        {
                                                loadMainImage = false;
                                        }
                                        else
                                        {
                                                loadMainImage = true;
                                        }
                                        XmlNode animation_infoNode = parentNode.FirstChild.NextSibling;
                                        listOfFrames.Clear();
                                        while (animation_infoNode != null)
                                        {
                                                indvAnimation tempAnimation = new indvAnimation();
                                                tempAnimation.AnimationListofFrames = new List<indvFrame>();
                                                tempAnimation.EntityType = Int32.Parse(parentNode.Attributes["entityType"].Value);
                                                if (Int32.Parse(animation_infoNode.Attributes["looping"].Value) == 1)
                                                {
                                                        tempAnimation.looping = true;
                                                }
                                                else
                                                {
                                                        tempAnimation.looping = false;
                                                }
                                                tempAnimation.AnimationType = Int32.Parse(animation_infoNode.Attributes["animationType"].Value);
                                                XmlNode frame_infoNode = animation_infoNode.FirstChild;
                                                while (frame_infoNode != null)
                                                {
                                                        indvFrame tempFrame = new indvFrame();
                                                        tempFrame.Trigger = Int32.Parse(frame_infoNode.Attributes["trigger"].Value);
                                                        Rectangle tempSrc = Rectangle.Empty;
                                                        tempSrc.X = Int32.Parse(frame_infoNode.Attributes["sourceRectX"].Value);
                                                        tempSrc.Y = Int32.Parse(frame_infoNode.Attributes["sourceRectY"].Value);
                                                        tempSrc.Width = Int32.Parse(frame_infoNode.Attributes["sourceRectWidth"].Value);
                                                        tempSrc.Height = Int32.Parse(frame_infoNode.Attributes["sourceRectHeight"].Value);
                                                        tempFrame.FrameSrcRect = tempSrc;
                                                        Rectangle tempColl = Rectangle.Empty;
                                                        tempColl.X = Int32.Parse(frame_infoNode.Attributes["collisionRectX"].Value);
                                                        tempColl.Y = Int32.Parse(frame_infoNode.Attributes["collisionRectY"].Value);
                                                        tempColl.Width = Int32.Parse(frame_infoNode.Attributes["collisionRectWidth"].Value);
                                                        tempColl.Height = Int32.Parse(frame_infoNode.Attributes["collisionRectHeight"].Value);
                                                        tempFrame.FrameCollRect = tempColl;
                                                        tempFrame.AnchorPointX = Int32.Parse(frame_infoNode.Attributes["anchorPointX"].Value);
                                                        tempFrame.AnchorPointY = Int32.Parse(frame_infoNode.Attributes["anchorPointY"].Value);
                                                        tempFrame.FrameDuration = float.Parse(frame_infoNode.Attributes["duration"].Value);
                                                        frame_infoNode = frame_infoNode.NextSibling;
                                                        tempAnimation.AnimationListofFrames.Add(tempFrame);
                                                }
                                                animation_infoNode = animation_infoNode.NextSibling;
                                                listOfAnimations.Add(tempAnimation);
                                        }
                                }

                        }
        }