Beispiel #1
0
    static void Main(string[] args)
    {
        // 注册序列化类型
        PKG.AllTypes.Register();

        // 填充 ways
        Ways.Fill();

        // 填充 frames, fishFrames
        SpriteFrames.Fill();

        // 创建配置实例
        var cfg = new PKG.CatchFish.Configs.Config();

        cfg.cannons     = new xx.List <PKG.CatchFish.Configs.Cannon>();
        cfg.fishs       = new xx.List <PKG.CatchFish.Configs.Fish>();
        cfg.sitPositons = new xx.List <xx.Pos>();
        cfg.stages      = new xx.List <PKG.CatchFish.Stages.Stage>();
        cfg.fixedWays   = new xx.List <PKG.CatchFish.Way>();
        cfg.weapons     = new xx.List <PKG.CatchFish.Configs.Weapon>();

        // 基于 1280 x 720 的设计尺寸
        cfg.sitPositons.Add(new xx.Pos {
            x = -250, y = -335
        });
        cfg.sitPositons.Add(new xx.Pos {
            x = 250, y = -335
        });
        cfg.sitPositons.Add(new xx.Pos {
            x = 250, y = 335
        });
        cfg.sitPositons.Add(new xx.Pos {
            x = -250, y = 335
        });
        cfg.aimTouchRadius          = 20;
        cfg.normalFishMaxRadius     = 150;
        cfg.enableBulletFastForward = false;

        // 有前后依赖
        Cannons.Fill(cfg);
        Weapons.Fill(cfg);
        Fishs.Fill(cfg);
        Stages.Fill(cfg);

        // cfg 序列化存盘
        var bb = new xx.BBuffer();

        bb.WriteRoot(cfg);
        File.WriteAllBytes(Path.Combine(outputPath, "cfg.bin"), bb.DumpData());
        bb.ReadRoot(ref cfg);   // test read
    }