Пример #1
0
        private static Pat.Frame ImportFrame(Pat.Project proj, GSPat.GSPatFile pat, GSPat.Frame frame)
        {
            var hasIM = frame.ImageManipulation != null;

            return(new Pat.Frame
            {
                ImageID = AddImageToProject(proj, pat.Images[frame.SpriteID], frame).ImageID,
                OriginX = frame.OriginX,
                OriginY = frame.OriginY,
                ScaleX = hasIM ? frame.ImageManipulation.ScaleX : 100,
                ScaleY = hasIM ? frame.ImageManipulation.ScaleY : 100,
                Alpha = hasIM ? frame.ImageManipulation.Alpha / 255.0f : 1.0f,
                Red = hasIM ? frame.ImageManipulation.Red / 255.0f : 1.0f,
                Green = hasIM ? frame.ImageManipulation.Green / 255.0f : 1.0f,
                Blue = hasIM ? frame.ImageManipulation.Blue / 255.0f : 1.0f,
                Duration = frame.DisplayTime,
                //TODO check if rotation should be inversed
                Rotation = hasIM ? frame.ImageManipulation.Rotation : 0,
                PhysicalBox = ImportPhysicalBox(frame.PhysicsBox),
                HitBoxes = frame.HitBoxes.Select(ImportBox).ToList(),
                AttackBoxes = frame.AttackBoxes.Select(ImportBox).ToList(),
                Points = new List <FramePoint>()
                {
                    ImportPoint(frame.Point0),
                    ImportPoint(frame.Point1),
                    ImportPoint(frame.Point2),
                },
            });
        }
Пример #2
0
        //TODO move to image list
        public static Pat.FrameImage AddImageToProject(Project proj, string filename, GSPat.Frame frame)
        {
            if (Path.GetExtension(filename) == ".bmp" || Path.GetExtension(filename) == ".png")
            {
                filename = Path.ChangeExtension(filename, ".cv2");
            }

            var find = proj.Images.FirstOrDefault(
                img =>
                img.Resource.ResourceID == filename &&
                img.X == frame.ViewOffsetX && img.Y == frame.ViewOffsetY &&
                img.W == frame.ViewWidth && img.H == frame.ViewHeight
                );

            if (find != null)
            {
                return(find);
            }
            var id  = MakeImageID(proj, filename);
            var ret = new Pat.FrameImage()
            {
                ImageID = id,
                //TODO AlphaBlend might be 0,1,2. catch 2
                AlphaBlendMode = frame.ImageManipulation == null ? false : frame.ImageManipulation.AlphaBlend == 1,
                Resource       = new ResourceReference {
                    ResourceID = filename
                },
                X = frame.ViewOffsetX,
                Y = frame.ViewOffsetY,
                W = frame.ViewWidth,
                H = frame.ViewHeight,
            };

            proj.Images.Add(ret);
            return(ret);
        }