示例#1
0
文件: OsbReader.cs 项目: Deliay/MGLib
 public TestOsbReader()
 {
     elementList = new OsbElementList(@"z:\test.osb");
     foreach (var element in elementList)
     {
         //item 的 commands;
         foreach (var command in element.Commands)
         {
             if (command.CommandType == CommandType.Loop)
             {
                 foreach (var subCommand in command.SubCommands)
                 {
                 }
             }
         }
     }
 }
示例#2
0
        static void Main(string[] args)
        {
            OsbElementList elements     = new OsbElementList(@"Z:\Dollscythe - Flashes (Extended) (Skystar).osb");
            Stopwatch      sw           = new Stopwatch();
            int            count        = 0;
            int            commandCount = 0;

            sw.Start();
            foreach (var item in elements)
            {
                sw.Stop();
                ++count;
                commandCount += item.Commands.Count();
                sw.Start();
            }
            sw.Stop();
            Console.WriteLine($"总用时:{sw.ElapsedMilliseconds}ms,平均单个物件用时: {sw.ElapsedMilliseconds / count}ms,命令总数:{commandCount}个,平均1000个命令用时:{(float)sw.ElapsedMilliseconds / (float)(commandCount / 1000)}ms");
        }
示例#3
0
        public static ElementGroup ParseFromFile(string path)
        {
            ElementGroup eg = new ElementGroup(0);

            using (OsbElementList elements = new OsbElementList(path))
            {
                foreach (var mgElement in elements)
                {
                    Element osElement;
                    switch (mgElement.ElementType)
                    {
                    case 0:     // sprite
                        osElement = eg.CreateSprite(
                            mgElement.Layer.ToOSharp(),
                            mgElement.Origin.ToOSharp(),
                            mgElement.TexturePath, mgElement.Position.Item1,
                            mgElement.Position.Item2
                            );
                        break;

                    case 1:     // animation
                        osElement = eg.CreateAnimation(
                            mgElement.Layer.ToOSharp(),
                            mgElement.Origin.ToOSharp(),
                            mgElement.TexturePath, mgElement.Position.Item1,
                            mgElement.Position.Item2,
                            mgElement.FrameCount,
                            mgElement.FrameDelay,
                            mgElement.LoopType.ToOSharp()
                            );
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    AddEvent(mgElement.Commands, osElement);
                }
            }

            return(eg);
        }