예제 #1
0
        public void LoadConfig()
        {
            if (File.Exists(Application.StartupPath + '/' + ConfigName))
            {
                var s = new XmlSerializer(config.GetType());
                var r = File.OpenText(Application.StartupPath + '/' + ConfigName);
                config = (AutoHostConfig)s.Deserialize(r);
                r.Close();
                config.AddMissingCommands();
            }
            else
            {
                config.Defaults();
            }

            if (File.Exists(Application.StartupPath + '/' + PresetsName))
            {
                var s = new XmlSerializer(presets.GetType());
                using (var r = File.OpenText(Application.StartupPath + '/' + PresetsName)) {
                    presets = (List <Preset>)s.Deserialize(r);
                    r.Close();
                }
            }

            if (File.Exists(Application.StartupPath + '/' + BoxesName))
            {
                var frm = new BinaryFormatter();
                using (var r = new FileStream(Application.StartupPath + '/' + BoxesName, FileMode.Open)) {
                    MapBoxes = (Dictionary <string, Dictionary <int, BattleRect> >)frm.Deserialize(r);
                    r.Close();
                }
            }

            banList.Load();
        }
예제 #2
0
        public AutoHost(TasClient tas, Spring spring, AutoHostConfig conf)
        {
            banList = new BanList(this, tas);

            if (conf == null)
            {
                LoadConfig();
            }
            else
            {
                config = conf;
            }
            SaveConfig();

            this.tas    = tas;
            this.spring = spring;

            tas.Said += tas_Said;

            pollTimer           = new Timer(PollTimeout * 1000);
            pollTimer.Enabled   = false;
            pollTimer.AutoReset = false;
            pollTimer.Elapsed  += pollTimer_Elapsed;

            spring.SpringExited += spring_SpringExited;
            spring.GameOver     += spring_GameOver;

            tas.BattleUserLeft          += tas_BattleUserLeft;
            tas.UserStatusChanged       += tas_UserStatusChanged;
            tas.BattleUserJoined        += tas_BattleUserJoined;
            tas.BattleMapChanged        += tas_BattleMapChanged;
            tas.BattleUserStatusChanged += tas_BattleUserStatusChanged;
            tas.BattleLockChanged       += tas_BattleLockChanged;
            tas.BattleOpened            += tas_BattleOpened;

            linker         = new UnknownFilesLinker(spring);
            fileDownloader = new FileDownloader(spring);
            fileDownloader.DownloadCompleted += fileDownloader_DownloadCompleted;
            //fileDownloader.DownloadProgressChanged += new EventHandler<TasEventArgs>(fileDownloader_DownloadProgressChanged);

            tas.BattleFound += tas_BattleFound;
        }
예제 #3
0
        public AutoHost(TasClient tas, Spring spring, AutoHostConfig conf)
        {
            banList = new BanList(this, tas);

            if (conf == null)
            {
                LoadConfig();
            }
            else
            {
                config = conf;
            }
            SaveConfig();

            this.tas    = tas;
            this.spring = spring;

            tas.Said += tas_Said;

            pollTimer           = new Timer(PollTimeout * 1000);
            pollTimer.Enabled   = false;
            pollTimer.AutoReset = false;
            pollTimer.Elapsed  += pollTimer_Elapsed;

            spring.SpringExited      += spring_SpringExited;
            spring.GameOver          += spring_GameOver;
            spring.NotifyModsChanged += spring_NotifyModsChanged;

            tas.BattleUserLeft          += tas_BattleUserLeft;
            tas.UserStatusChanged       += tas_UserStatusChanged;
            tas.BattleUserJoined        += tas_BattleUserJoined;
            tas.BattleMapChanged        += tas_BattleMapChanged;
            tas.BattleUserStatusChanged += tas_BattleUserStatusChanged;
            tas.BattleLockChanged       += tas_BattleLockChanged;
            tas.BattleOpened            += tas_BattleOpened;

            linkProvider = new ResourceLinkProvider();
            spring.UnitSyncWrapper.Downloader.LinksRecieved += linkProvider.Downloader_LinksRecieved;
        }