コード例 #1
0
        public static void Save(string fileName, WorldMetadata table)
        {
            var s = new XmlSerializer(typeof(WorldMetadata));

            using (var f = File.OpenWrite(fileName))
            {
                s.Serialize(f, table);
            }
        }
コード例 #2
0
ファイル: World.cs プロジェクト: SerjinRwD/langtons-ant-1
        public World(WorldMetadata world)
        {
            W = world.W;
            H = world.H;

            Cells = new int[W, H];

            for (var x = 0; x < W; x++)
            {
                for (var y = 0; y < H; y++)
                {
                    Cells[x, y] = 0;
                }
            }

            Colors = new SDL.SDL_Color[world.Colors.Length];

            foreach (var cm in world.Colors)
            {
                Colors[cm.Id] = Resources.ParseColorCode(cm.RGBACode);
            }

            Turmites = new List <Turmite>();

            foreach (var tm in world.Turmites)
            {
                var tst = TransitionStateTable.Load(Resources.GetFilePath($@"turmites/{tm.Name}.xml"));
                var t   = new Turmite(tst);

                t.Direction = tm.Direction;
                t.StateId   = tm.StateId;
                t.X         = tm.X;
                t.Y         = tm.Y;

                Turmites.Add(t);
            }
        }