Exemplo n.º 1
0
        public void Load()
        {
            string                      GameName = "SavedGames" + "/SavedGame.dat";
            FileStream                  file     = new FileStream(GameName, FileMode.Open);
            BinaryFormatter             bf       = new BinaryFormatter();
            Game                        g        = GetComponent <Game>();
            Dictionary <string, object> o        = (Dictionary <string, object>)bf.Deserialize(file);

            //GAMEDATA
            g.Data = (GameData)o["gamedata"];

            //TEAMS
            List <TeamData> teams = (List <TeamData>)o["teams"];

            Transform map = transform.Find("Map");

            Team[] ta = map.GetComponentsInChildren <Team>();
            //save each team data
            // TODO: Create Teams from scratch, setup prefabs depending on team ID
            for (int i = 0; i < g.Data.NumTeams; i++)
            {
                ta[i].Data = teams[i];
                ta[i].Clear();
            }

            // SELECTABLES
            List <object> sels = (List <object>)o["selectables"];
            BuildMan      bm   = GetComponent <BuildMan>();

            foreach (List <object> d in sels)
            {
                bm.BuildFromData(d);
            }
        }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     Limits  = GetComponent <LimitsMan>();
     Builder = GetComponent <BuildMan>();
     MyTeam  = GetComponent <Team>();
     //StartCoroutine("BuildArmy");
     InvokeRepeating("CheckBuild", 1, DelayBetweenBuilds);
 }