Ejemplo n.º 1
0
 public static void Serialize(BinaryWriter s, GameState state)
 {
     s.Write(state.CurrentFrame);
     s.Write(state.TotalGameTime);
     s.Write(UUIDGenerator.GetUUID());
     s.Write(state.activeTeams.Length);
     foreach (var at in state.activeTeams)
     {
         s.Write(at.Index);
         RTSTeam.Serialize(s, at.Team);
     }
     s.Write(state.tbMemBuildings.TotalTasks);
     foreach (var task in state.tbMemBuildings.Tasks)
     {
         var ebu = task as EnemyBuildingUpdater;
         EnemyBuildingUpdater.Serialize(s, ebu);
     }
     LevelGrid.Serialize(s, state);
 }
Ejemplo n.º 2
0
        public static void Deserialize(BinaryReader s, Dictionary <string, ReflectedScript> res, GameState state)
        {
            state.curFrame   = s.ReadInt32();
            state.timePlayed = s.ReadSingle();
            UUIDGenerator.SetUUID(s.ReadInt32());
            state.Scripts = new Dictionary <string, ReflectedScript>(res);
            int c = s.ReadInt32();

            for (int i = 0; i < c; i++)
            {
                int ti = s.ReadInt32();
                state.teams[ti] = RTSTeam.Deserialize(s, ti, state);
            }
            state.UpdateActiveTeams();
            c = s.ReadInt32();
            for (int i = 0; i < c; i++)
            {
                var ebu = EnemyBuildingUpdater.Deserialize(s, state);
                state.tbMemBuildings.AddTask(ebu);
            }
            LevelGrid.Deserialize(s, state);
        }
Ejemplo n.º 3
0
        public static void Deserialize(BinaryReader s, GameState state)
        {
            LevelGrid g = state.LevelGrid;

            for (int y = 0; y < g.L1.numCells.Y; y++)
            {
                for (int x = 0; x < g.L1.numCells.X; x++)
                {
                    g.L1.Fog[x, y] = s.ReadUInt32();
                }
            }
            for (int y = 0; y < g.L2.numCells.Y; y++)
            {
                for (int x = 0; x < g.L2.numCells.X; x++)
                {
                    int c = s.ReadInt32();
                    for (int i = 0; i < c; i++)
                    {
                        // TODO: Custom Deserialization
                    }
                    g.L2.CellImpact[x, y] = s.ReadInt32();
                }
            }
        }
Ejemplo n.º 4
0
        public static void Serialize(BinaryWriter s, GameState state)
        {
            LevelGrid g = state.LevelGrid;

            for (int y = 0; y < g.L1.numCells.Y; y++)
            {
                for (int x = 0; x < g.L1.numCells.X; x++)
                {
                    s.Write(g.L1.Fog[x, y]);
                }
            }
            for (int y = 0; y < g.L2.numCells.Y; y++)
            {
                for (int x = 0; x < g.L2.numCells.X; x++)
                {
                    s.Write(g.L2.ImpactGenerators[x, y].Count);
                    for (int i = 0; i < g.L2.ImpactGenerators[x, y].Count; i++)
                    {
                        // TODO: Custom Serialization
                    }
                    s.Write(g.L2.CellImpact[x, y]);
                }
            }
        }