コード例 #1
0
ファイル: SaveLoad.cs プロジェクト: zenithlee/worldatwar
        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);
            }
        }
コード例 #2
0
ファイル: AIArmy.cs プロジェクト: zenithlee/worldatwar
 // Use this for initialization
 void Start()
 {
     Limits  = GetComponent <LimitsMan>();
     Builder = GetComponent <BuildMan>();
     MyTeam  = GetComponent <Team>();
     //StartCoroutine("BuildArmy");
     InvokeRepeating("CheckBuild", 1, DelayBetweenBuilds);
 }