예제 #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
        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);
            }
        }