Exemplo n.º 1
0
        public override void MouseMoveExtra(int KeyFrame, int RealX, int RealY, int MouseChangeX, int MouseChangeY)
        {
            PolygonCutterKeyFrame ActiveObjectKeyFrame = (PolygonCutterKeyFrame)CreateOrRetriveKeyFrame(ActiveLayer, KeyFrame);

            for (int P = 0; P < ActiveObjectKeyFrame.ListPolygon.Count; P++)
            {
                Polygon ActivePolygon         = ListPolygon[P];
                Polygon ActiveKeyFramePolygon = ActiveObjectKeyFrame.ListPolygon[P];

                for (int V = 0; V < ActiveKeyFramePolygon.ArrayVertex.Length; V++)
                {
                    int KeyFrameX = (int)ActiveKeyFramePolygon.ArrayVertex[V].X - 2;
                    int KeyFrameY = (int)ActiveKeyFramePolygon.ArrayVertex[V].Y - 2;

                    if (RealX >= KeyFrameX && RealX < KeyFrameX + 5 &&
                        RealY >= KeyFrameY && RealY < KeyFrameY + 5)
                    {
                        ActiveKeyFramePolygon.ArrayVertex[V] =
                            new Vector2(ActiveKeyFramePolygon.ArrayVertex[V].X + MouseChangeX,
                                        ActiveKeyFramePolygon.ArrayVertex[V].Y + MouseChangeY);

                        ActivePolygon.ArrayVertex[V] = ActiveKeyFramePolygon.ArrayVertex[V];
                        break;
                    }
                }
            }

            base.MouseMoveExtra(KeyFrame, RealX, RealY, MouseChangeX, MouseChangeY);
        }
Exemplo n.º 2
0
            protected override VisibleAnimationObjectKeyFrame CopyAsVisibleAnimationObjectKeyFrame(AnimationClass.AnimationLayer ActiveLayer)
            {
                PolygonCutterKeyFrame NewPolygonCutterKeyFrame = new PolygonCutterKeyFrame(ActiveLayer);

                NewPolygonCutterKeyFrame.UpdateFrom(this);

                NewPolygonCutterKeyFrame.ListPolygon = new List <Polygon>(ListPolygon.Count);
                foreach (Polygon ActivePolygon in ListPolygon)
                {
                    NewPolygonCutterKeyFrame.ListPolygon.Add(new Polygon(ActivePolygon));
                }

                return(NewPolygonCutterKeyFrame);
            }
Exemplo n.º 3
0
        public override List <VisibleTimeline> CreateNewEditorItem(AnimationClass ActiveAnimation, AnimationClass.AnimationLayer ActiveLayer, int KeyFrame, System.Drawing.Point MousePosition)
        {
            List <VisibleTimeline> ReturnValue = new List <VisibleTimeline>();

            Vector2[] LocalPoints = new Vector2[4]
            {
                new Vector2(MousePosition.X - 40, MousePosition.Y - 40),
                new Vector2(MousePosition.X - 40, MousePosition.Y + 40),
                new Vector2(MousePosition.X + 40, MousePosition.Y + 40),
                new Vector2(MousePosition.X + 40, MousePosition.Y - 40),
            };

            PolygonCutterTimeline NewCreatePolygonCutterEvent = new PolygonCutterTimeline("New Polygon Cutter", Vector2.Zero, ActiveLayer);
            PolygonCutterHelper   NewSpawner = new PolygonCutterHelper(ActiveLayer.renderTarget, NewCreatePolygonCutterEvent.ListPolygon, true);

            NewSpawner.PolygonCutterViewer.ListPolygon.Add(new Polygon(LocalPoints, GameScreen.GraphicsDevice.Viewport.Width, GameScreen.GraphicsDevice.Viewport.Height));

            if (NewSpawner.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                NewCreatePolygonCutterEvent.SpawnFrame = KeyFrame;
                NewCreatePolygonCutterEvent.DeathFrame = KeyFrame + 10;
                NewCreatePolygonCutterEvent.IsUsed     = true;//Disable the spawner as we spawn the timeline manually.

                PolygonCutterKeyFrame NewPolygonCutterKeyFrame = new PolygonCutterKeyFrame(ActiveLayer, NewCreatePolygonCutterEvent.Position,
                                                                                           true, -1);

                foreach (Polygon NewPolygon in NewSpawner.PolygonCutterViewer.ListPolygon)
                {
                    NewPolygonCutterKeyFrame.ListPolygon.Add(new Polygon(NewPolygon));
                }

                NewCreatePolygonCutterEvent.ListPolygon.AddRange(NewSpawner.PolygonCutterViewer.ListPolygon);

                NewCreatePolygonCutterEvent.Add(KeyFrame, NewPolygonCutterKeyFrame);

                ReturnValue.Add(NewCreatePolygonCutterEvent);
            }

            return(ReturnValue);
        }
Exemplo n.º 4
0
        public override void UpdateAnimationObject(int KeyFrame)
        {
            //An Event is being executed.
            if (NextEvent != null && ArrayMoveValue != null)
            {
                UpdateAnimationSprite(KeyFrame);

                for (int P = 0; P < ListPolygon.Count; P++)
                {
                    for (int V = 0; V < ListPolygon[P].ArrayVertex.Length; V++)
                    {
                        Vector2 Result = ArrayMoveValue[P][V] * (KeyFrame - EventKeyFrameOld);
                        ListPolygon[P].ArrayVertex[V] = new Vector2(EventOld.ListPolygon[P].ArrayVertex[V].X + (int)Result.X, EventOld.ListPolygon[P].ArrayVertex[V].Y + (int)Result.Y);
                    }

                    if (PolygonCutterType == PolygonCutterTypes.Crop)
                    {
                        ListPolygon[P].ComputeColorAndUVCoordinates(ActiveLayer.Owner.ScreenWidth, ActiveLayer.Owner.ScreenHeight);
                    }
                    ListPolygon[P].ComputePerpendicularAxis();
                    ListPolygon[P].UpdateWorldPosition(Position, Angle);
                }
            }

            VisibleAnimationObjectKeyFrame ActiveKeyFrame;

            if (DicAnimationKeyFrame.TryGetValue(KeyFrame, out ActiveKeyFrame))
            {
                //If that animation has already been used, skip it.
                if (ActiveKeyFrame.IsUsed)
                {
                    return;
                }

                int NextKeyFrame = ActiveKeyFrame.NextKeyFrame;

                OnNewKeyFrameAnimationSprite(ActiveKeyFrame);

                PolygonCutterKeyFrame ActivePolygonCutterKeyFrame = (PolygonCutterKeyFrame)ActiveKeyFrame;
                EventOld = ActivePolygonCutterKeyFrame;

                if (DicAnimationKeyFrame.TryGetValue(NextKeyFrame, out ActiveKeyFrame))
                {
                    PolygonCutterKeyFrame NextActivePolygonCutterKeyFrame = (PolygonCutterKeyFrame)ActiveKeyFrame;

                    //Get the next polygons.
                    if (NextActivePolygonCutterKeyFrame.ListPolygon.Count != ListPolygon.Count)
                    {
                        ListPolygon.Clear();
                        for (int P = 0; P < NextActivePolygonCutterKeyFrame.ListPolygon.Count; P++)
                        {
                            Polygon ActivePolygon = new Polygon(NextActivePolygonCutterKeyFrame.ListPolygon[P]);
                            ListPolygon.Add(ActivePolygon);
                        }
                    }
                    for (int P = 0; P < NextActivePolygonCutterKeyFrame.ListPolygon.Count; P++)
                    {
                        Polygon ActivePolygon = NextActivePolygonCutterKeyFrame.ListPolygon[P];

                        if (PolygonCutterType == PolygonCutterTypes.Crop)
                        {
                            ActivePolygon.ComputeColorAndUVCoordinates(AnimationClass.GraphicsDevice.PresentationParameters.BackBufferWidth, AnimationClass.GraphicsDevice.PresentationParameters.BackBufferHeight);
                        }
                    }

                    if (ActiveKeyFrame.IsProgressive)
                    {
                        OnProgressiveNextKeyFrameAnimationSprite(ActiveKeyFrame, KeyFrame, NextKeyFrame);

                        float KeyFrameChange = KeyFrame - NextKeyFrame;
                        ArrayMoveValue = null;

                        if (ActivePolygonCutterKeyFrame.ListPolygon.Count == NextActivePolygonCutterKeyFrame.ListPolygon.Count)
                        {
                            ArrayMoveValue = new Vector2[NextActivePolygonCutterKeyFrame.ListPolygon.Count][];

                            for (int P = 0; P < NextActivePolygonCutterKeyFrame.ListPolygon.Count; P++)
                            {
                                if (ActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex.Length != NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex.Length)
                                {
                                    ArrayMoveValue = null;
                                    break;
                                }
                                else
                                {
                                    ArrayMoveValue[P] = new Vector2[NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex.Length];
                                    for (int V = 0; V < NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex.Length; V++)
                                    {
                                        ArrayMoveValue[P][V] = new Vector2(
                                            (ActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex[V].X - NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex[V].X) / KeyFrameChange,
                                            (ActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex[V].Y - NextActivePolygonCutterKeyFrame.ListPolygon[P].ArrayVertex[V].Y) / KeyFrameChange);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        NextEvent = null;
                    }
                }
            }
        }
Exemplo n.º 5
0
        public PolygonCutterTimeline(BinaryReader BR, AnimationClass.AnimationLayer ActiveLayer)
            : base(BR, TimelineType)
        {
            this.ActiveLayer            = ActiveLayer;
            _PolygonCutterType          = (PolygonCutterTypes)BR.ReadByte();
            _PolygonCutterSpecialEffect = (PolygonCutterSpecialEffects)BR.ReadByte();

            ListPolygon = new List <Polygon>();

            float MinX = float.MaxValue;
            float MaxX = float.MinValue;
            float MinY = float.MaxValue;
            float MaxY = float.MinValue;

            foreach (Polygon ActivePolygon in ListPolygon)
            {
                for (int V = 0; V < ActivePolygon.VertexCount; V++)
                {
                    int VertexX = (int)ActivePolygon.ArrayVertex[V].X;
                    int VertexY = (int)ActivePolygon.ArrayVertex[V].Y;

                    if (VertexX < MinX)
                    {
                        MinX = VertexX;
                    }
                    if (VertexX > MaxX)
                    {
                        MaxX = VertexX;
                    }

                    if (VertexY < MinY)
                    {
                        MinY = VertexY;
                    }
                    if (VertexY > MaxY)
                    {
                        MaxY = VertexY;
                    }
                }
            }

            SourceRectangle = new Rectangle((int)MinX, (int)MinY, (int)(MaxX - MinX), (int)(MaxY - MinY));
            Origin          = new Point(Width / 2, Height / 2);

            int DicAnimationSpriteKeyFrameCount = BR.ReadInt32();

            for (int E = 0; E < DicAnimationSpriteKeyFrameCount; E++)
            {
                int Key = BR.ReadInt32();

                PolygonCutterKeyFrame NewPolygonCutterKeyFrame = new PolygonCutterKeyFrame(BR, ActiveLayer);

                DicAnimationKeyFrame.Add(Key, NewPolygonCutterKeyFrame);
            }

            int FirstKey = int.MaxValue;

            foreach (int ActiveKey in DicAnimationKeyFrame.Keys)
            {
                if (FirstKey > ActiveKey)
                {
                    FirstKey = ActiveKey;
                }
            }
            PolygonCutterKeyFrame FirstKeyFrame = (PolygonCutterKeyFrame)DicAnimationKeyFrame[FirstKey];

            for (int P = 0; P < FirstKeyFrame.ListPolygon.Count; P++)
            {
                Polygon ActivePolygon = new Polygon(FirstKeyFrame.ListPolygon[P]);
                ListPolygon.Add(ActivePolygon);
            }
        }