Exemplo n.º 1
0
        public void FinishExporter()
        {
            //save pat
            if (System.IO.File.Exists(_OutputFile))
            {
                System.IO.File.Delete(_OutputFile);
            }
            using (var stream = System.IO.File.Open(_OutputFile, System.IO.FileMode.CreateNew))
            {
                using (var writer = new System.IO.BinaryWriter(stream))
                {
                    GSPat.GSPatWriter.Write(_OutputData, writer);
                }
            }

            //save codes
            foreach (var code in _Codes)
            {
                code.Finish();
            }

            //reset referenced objects
            _Codes.Clear();
            _Project    = null;
            _ImageList  = null;
            _OutputData = null;
        }
Exemplo n.º 2
0
        public static void ExportAnimation(GSPat.GSPatFile file, ImageListExporter images,
                                           Pat.Action action, int id)
        {
            {
                var eAnimation = new GSPat.Animation()
                {
                    AnimationID = id,
                    AttackLevel = 0,
                    CancelLevel = ExportCancelLevel(action.Segments[0].CancelLevel),
                    IsLoop      = action.Segments[0].IsLoop,
                    Type        = GSPat.AnimationType.Normal,
                };
                ExportFrames(eAnimation, action.Segments[0], images);
                file.Animations.Add(eAnimation);
            }

            for (int i = 1; i < action.Segments.Count; ++i)
            {
                var eAnimation = new GSPat.Animation()
                {
                    AnimationID = -2,
                    AttackLevel = 0,
                    CancelLevel = ExportCancelLevel(action.Segments[i].CancelLevel),
                    IsLoop      = action.Segments[i].IsLoop,
                    Type        = GSPat.AnimationType.Normal,
                };
                ExportFrames(eAnimation, action.Segments[i], images);
                file.Animations.Add(eAnimation);
            }
        }
Exemplo n.º 3
0
        public static void ExportFrames(GSPat.Animation toList, Pat.AnimationSegment fromList,
                                        ImageListExporter images)
        {
            toList.Frames = new List <GSPat.Frame>();
            var attackType  = fromList.Damage == null ? Pat.AttackType.None : fromList.Damage.AttackType;
            var damage      = fromList.Damage == null ? 0 : fromList.Damage.BaseDamage;
            var hitG        = fromList.Damage == null ? 0 : fromList.Damage.Knockback.Gravity;
            var se          = fromList.Damage == null ? 0 : fromList.Damage.SoundEffect;
            var hso         = fromList.Damage == null ? 0 : fromList.Damage.HitStop.Opponent;
            var hss         = fromList.Damage == null ? 0 : fromList.Damage.HitStop.Self;
            var hitX        = fromList.Damage == null ? 0 : fromList.Damage.Knockback.SpeedX;
            var hitY        = fromList.Damage == null ? 0 : fromList.Damage.Knockback.SpeedY;
            var cancelJump  = fromList.JumpCancellable == null ? Int32.MaxValue : fromList.JumpCancellable.StartFrom;
            var cancelSkill = fromList.SkillCancellable == null ? Int32.MaxValue : fromList.SkillCancellable.StartFrom;

            var frameTime = 0;

            foreach (var frame in fromList.Frames)
            {
                var img = images.GetImage(frame.ImageID);

                var eFrame = new GSPat.Frame()
                {
                    AttackBoxes     = ExportBoxs(frame.AttackBoxes),
                    AttackFlag      = 0,
                    AttackType      = (short)attackType,
                    Bind            = 0,
                    Damage          = (short)damage,
                    DisplayTime     = (short)frame.Duration,
                    HitBoxes        = ExportBoxs(frame.HitBoxes),
                    HitG            = (short)hitG,
                    HitSoundEffect  = (short)se,
                    HitstopOpponent = (short)hso,
                    HitstopSelf     = (short)hss,
                    HitVX           = (short)hitX,
                    HitVY           = (short)hitY,

                    //TODO
                    ImageManipulation = ExportIM(frame, img),

                    OriginX     = (short)frame.OriginX,
                    OriginY     = (short)frame.OriginY,
                    PhysicsBox  = ExportPhysical(frame.PhysicalBox),
                    Point0      = ExportPoint(frame.Points, 0),
                    Point1      = ExportPoint(frame.Points, 1),
                    Point2      = ExportPoint(frame.Points, 2),
                    SpriteID    = images.GetImageIntID(frame.ImageID),
                    StateFlag   = (frameTime >= cancelSkill ? 0x20 : 0) + (frameTime >= cancelJump ? 0x200000 : 0),
                    ViewHeight  = (short)img.H,
                    ViewOffsetX = (short)img.X,
                    ViewOffsetY = (short)img.Y,
                    ViewWidth   = (short)img.W,
                };
                toList.Frames.Add(eFrame);

                frameTime += frame.Duration;
            }
        }
Exemplo n.º 4
0
        public void InitExporter(Pat.Project proj, string outputFile)
        {
            _Project    = proj;
            _OutputFile = outputFile;
            _OutputDir  = Path.GetDirectoryName(outputFile);

            _ImageList  = new ImageListExporter();
            _OutputData = new GSPat.GSPatFile()
            {
                Animations = new List <GSPat.Animation>(),
                Images     = new List <string>(),
            };
            _Codes.Clear();

            //first export images
            foreach (var img in proj.Images)
            {
                _ImageList.AddImage(_OutputData, img);
            }
        }