Esempio n. 1
0
        public static RTSTeam Deserialize(BinaryReader s, int index, GameState state)
        {
            int t = s.ReadInt32();
            RTSTeam team = new RTSTeam(index, t);
            team.Race = RTSRace.Deserialize(s, state);
            if(s.ReadBoolean()) {
                string it = s.ReadString();
                team.Input = state.Scripts[it].CreateInstance<ACInputController>();
                team.Input.Deserialize(s);
                team.Input.Init(state, index, null);
            }

            RTSColorScheme scheme = new RTSColorScheme();
            scheme.Name = s.ReadString();
            scheme.Primary = s.ReadVector3();
            scheme.Secondary = s.ReadVector3();
            scheme.Tertiary = s.ReadVector3();
            team.ColorScheme = scheme;

            int? target;
            var du = new Dictionary<int, RTSUnit>();
            List<int> su;

            int c = s.ReadInt32();
            RTSBuilding building;
            for(int i = 0; i < c; i++) {
                building = RTSBuilding.Deserialize(s, team, out target);
                team.buildings.Add(building);
                if(target.HasValue) {
                    // TODO: Add A Target Binding
                }
                state.CGrid.Add(building);
            }

            c = s.ReadInt32();
            RTSUnit unit;
            for(int i = 0; i < c; i++) {
                unit = RTSUnit.Deserialize(s, team, out target);
                du.Add(unit.UUID, unit);
                team.units.Add(unit);
                if(target.HasValue) {
                    // TODO: Add A Target Binding
                }
            }

            c = s.ReadInt32();
            RTSSquad squad;
            for(int i = 0; i < c; i++) {
                squad = RTSSquad.Deserialize(s, team, out su);
                team.squads.Add(squad);
                foreach(int uuid in su) {
                    if(du.TryGetValue(uuid, out unit)) {
                        squad.Add(unit);
                    }
                    else {
                        throw new Exception("Could Not Find A Unit With The Specified UUID");
                    }
                }
            }
            return team;
        }
Esempio n. 2
0
        public static RTSTeam Deserialize(BinaryReader s, int index, GameState state)
        {
            int     t    = s.ReadInt32();
            RTSTeam team = new RTSTeam(index, t);

            team.Race = RTSRace.Deserialize(s, state);
            if (s.ReadBoolean())
            {
                string it = s.ReadString();
                team.Input = state.Scripts[it].CreateInstance <ACInputController>();
                team.Input.Deserialize(s);
                team.Input.Init(state, index, null);
            }

            RTSColorScheme scheme = new RTSColorScheme();

            scheme.Name      = s.ReadString();
            scheme.Primary   = s.ReadVector3();
            scheme.Secondary = s.ReadVector3();
            scheme.Tertiary  = s.ReadVector3();
            team.ColorScheme = scheme;

            int?       target;
            var        du = new Dictionary <int, RTSUnit>();
            List <int> su;

            int         c = s.ReadInt32();
            RTSBuilding building;

            for (int i = 0; i < c; i++)
            {
                building = RTSBuilding.Deserialize(s, team, out target);
                team.buildings.Add(building);
                if (target.HasValue)
                {
                    // TODO: Add A Target Binding
                }
                state.CGrid.Add(building);
            }

            c = s.ReadInt32();
            RTSUnit unit;

            for (int i = 0; i < c; i++)
            {
                unit = RTSUnit.Deserialize(s, team, out target);
                du.Add(unit.UUID, unit);
                team.units.Add(unit);
                if (target.HasValue)
                {
                    // TODO: Add A Target Binding
                }
            }

            c = s.ReadInt32();
            RTSSquad squad;

            for (int i = 0; i < c; i++)
            {
                squad = RTSSquad.Deserialize(s, team, out su);
                team.squads.Add(squad);
                foreach (int uuid in su)
                {
                    if (du.TryGetValue(uuid, out unit))
                    {
                        squad.Add(unit);
                    }
                    else
                    {
                        throw new Exception("Could Not Find A Unit With The Specified UUID");
                    }
                }
            }
            return(team);
        }