Exemplo n.º 1
0
        public GameState()
        {
            UUIDGenerator.SetUUID(0);
            EntityHashSet = new Dictionary <int, IEntity>();

            teams       = new RTSTeam[MAX_PLAYERS];
            activeTeams = new IndexedTeam[0];
            Regions     = new List <ImpactRegion>();

            // No Data Yet Available
            VoxState = new VoxState();
            VoxState.World.worldMin = Point.Zero;
            Scripts = new Dictionary <string, ReflectedScript>();
            grid    = new LevelGrid();
            //grid.L0 = null;
            grid.L1 = null;
            grid.L2 = null;

            curFrame   = 0;
            timePlayed = 0f;

            tbMemBuildings = new TimeBudget(BUILDING_MEMORIZATION_LATENCY);

            lckParticles = new object();
            particles    = new List <Particle>();
            tmpParticles = new List <Particle>();
        }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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);
        }