public void Start() { _Instance = this; transform.localScale = new Vector3(1, 1, 0.01f); Background = GameObject.CreatePrimitive(PrimitiveType.Quad); MeshRenderer mr = Background.GetComponent <MeshRenderer>(); mr.material = new Material(MainCamera.MainShader); mr.material.SetColor("_Color", new Color(0, 0, 0, 1)); Background.transform.parent = transform; Background.transform.localPosition = new Vector3(Screen.width / 2, Screen.height / 2, 0.1f); Background.transform.localScale = new Vector3(Screen.width, Screen.height, 1); Background.name = "Background"; RendererMapName = new AllodsTextRenderer(Fonts.Font1, Font.Align.Center, Screen.width, Fonts.Font1.LineHeight, false); RendererMapName.Text = "downloading map " + FileName + "..."; ObjectMapName = RendererMapName.GetNewGameObject(0.01f, transform, 100); ObjectMapName.transform.localPosition = new Vector3(0, Screen.height / 2 - 16, -1); RendererMapPercent = new AllodsTextRenderer(Fonts.Font1, Font.Align.Center, Screen.width, Fonts.Font1.LineHeight, false); RendererMapPercent.Text = "0% complete"; RendererMapPercent.Material.color = new Color(0.6f, 0.6f, 0.6f); ObjectMapPercent = RendererMapPercent.GetNewGameObject(0.01f, transform, 100); ObjectMapPercent.transform.localPosition = new Vector3(0, Screen.height / 2, -1); }
public AutoHost(TasClient tas, Spring spring, AutoHostConfig conf) { if (conf == null) LoadConfig(); else config = conf; SaveConfig(); this.tas = tas; this.spring = spring; tas.Said += new EventHandler<TasSayEventArgs>(tas_Said); pollTimer = new Timer(PollTimeout * 1000); pollTimer.Enabled = false; pollTimer.AutoReset = false; pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed); spring.SpringExited += new EventHandler(spring_SpringExited); spring.GameOver += new EventHandler<SpringLogEventArgs>(spring_GameOver); tas.BattleUserLeft += new EventHandler<TasEventArgs>(tas_BattleUserLeft); tas.UserRemoved += new EventHandler<TasEventArgs>(tas_UserRemoved); tas.UserStatusChanged += new EventHandler<TasEventArgs>(tas_UserStatusChanged); tas.BattleUserJoined += new EventHandler<TasEventArgs>(tas_BattleUserJoined); tas.BattleMapChanged += new EventHandler<TasEventArgs>(tas_BattleMapChanged); tas.BattleUserStatusChanged += new EventHandler<TasEventArgs>(tas_BattleUserStatusChanged); tas.BattleLockChanged += new EventHandler<TasEventArgs>(tas_BattleLockChanged); mapLinker = new MapLinker(spring); mapDownloader = new MapDownloader(spring); mapDownloader.DownloadCompleted += new EventHandler<TasEventArgs>(mapDownloader_DownloadCompleted); mapDownloader.DownloadProgressChanged += new EventHandler<TasEventArgs>(mapDownloader_DownloadProgressChanged); tas.BattleFound += new EventHandler<TasEventArgs>(tas_BattleFound); }
public bool Process() { // similar logic to "map" console command, except no .alm autocompletion because server should send it string baseFilename = Path.GetFileName(FileName); string actualFilename = null; if (ResourceManager.FileExists(FileName)) { actualFilename = FileName; } else if (ResourceManager.FileExists(baseFilename)) { actualFilename = baseFilename; } else if (ResourceManager.FileExists("maps/" + baseFilename)) { actualFilename = "maps/" + baseFilename; } string actualMD5 = (actualFilename != null) ? ResourceManager.CalcMD5(actualFilename) : null; if (actualMD5 != null) { GameConsole.Instance.WriteLine("Server is using map \"{0}\" (hash {1}).\nLocal file found: {2} (hash {3}).", FileName, MD5, actualFilename, actualMD5); } else { GameConsole.Instance.WriteLine("Server is using map \"{0}\" (hash {1}).\nLocal file NOT found.", FileName, MD5, actualFilename, actualMD5); } if (actualMD5 != MD5) // including null case I guess { // enter map download state locally. // Client.State = ClientState.DownloadingMap; MapDownloader dlHandler = Utils.CreateObjectWithScript <MapDownloader>(); dlHandler.Setup(FileName); dlHandler.transform.parent = UiManager.Instance.transform; ServerCommands.RequestDownloadStart reqDlCmd; ClientManager.SendCommand(reqDlCmd); } else { // possibly execute additional init sequences here Client.State = ClientState.Playing; ServerCommands.RequestGamestate reqCmd; reqCmd.Nickname = Config.cl_nickname; ClientManager.SendCommand(reqCmd); MapView.Instance.InitFromFile(actualFilename); // wait MapLogic.Instance.WaitLoaded(30000); } return(true); }
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 += new EventHandler <TasSayEventArgs>(tas_Said); pollTimer = new Timer(PollTimeout * 1000); pollTimer.Enabled = false; pollTimer.AutoReset = false; pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed); spring.SpringExited += new EventHandler(spring_SpringExited); spring.GameOver += new EventHandler <SpringLogEventArgs>(spring_GameOver); tas.BattleUserLeft += new EventHandler <TasEventArgs>(tas_BattleUserLeft); tas.UserStatusChanged += new EventHandler <TasEventArgs>(tas_UserStatusChanged); tas.BattleUserJoined += new EventHandler <TasEventArgs>(tas_BattleUserJoined); tas.BattleMapChanged += new EventHandler <TasEventArgs>(tas_BattleMapChanged); tas.BattleUserStatusChanged += new EventHandler <TasEventArgs>(tas_BattleUserStatusChanged); tas.BattleLockChanged += new EventHandler <TasEventArgs>(tas_BattleLockChanged); tas.BattleOpened += new EventHandler <TasEventArgs>(tas_BattleOpened); linker = new UnknownFilesLinker(spring); mapDownloader = new MapDownloader(spring); mapDownloader.DownloadCompleted += new EventHandler <TasEventArgs>(mapDownloader_DownloadCompleted); mapDownloader.DownloadProgressChanged += new EventHandler <TasEventArgs>(mapDownloader_DownloadProgressChanged); modDownloader = new ModDownloader(spring); modDownloader.DownloadCompleted += new EventHandler <TasEventArgs>(modDownloader_DownloadCompleted); modDownloader.DownloadProgressChanged += new EventHandler <TasEventArgs>(mapDownloader_DownloadProgressChanged); tas.BattleFound += new EventHandler <TasEventArgs>(tas_BattleFound); }
/// <summary> /// Downloads the current map if necessary. /// </summary> public void DownloadAndLoadMap() { const string MapFolder = "maps"; DirectoryInfo dir = new DirectoryInfo(MapFolder); if (!dir.Exists) { dir.Create(); } currentMapName = GameServer.GetCurrentMapName(); GameMode = GameServer.GetCurrentGameMode(); string fileName = String.Format("{0}{1}{2}", MapFolder, System.IO.Path.DirectorySeparatorChar, currentMapName); Map playableMap = MapDownloader.GetMap(currentMapName, fileName, MainServer); Game.CurrentMap = playableMap; }
private static void Main(string[] args) { var regionList = File.ReadAllText("city.txt").Split( new[] { "$$" }, StringSplitOptions.RemoveEmptyEntries); var task = new RegionTask(1, 14); foreach (var region in regionList) { var points = region.Split(';'); IList <MercatorPoint> ml = new List <MercatorPoint>(); foreach (var p in points) { var location = p.Split(','); var lng = Convert.ToDouble(location[0]); var lat = Convert.ToDouble(location[1]); var m = BaiduProjection.Instance.CoordinateToMercator(lat, lng); ml.Add(m); } task.AddRegion(ml); } task.CalculateQuest(); foreach (var zoom in task) { File.WriteAllText($"Zoom{zoom.Zoom}.txt", zoom.ToString()); } var downloader = new MapDownloader(task); while (!downloader.IsComplete) { Console.WriteLine(downloader.GetDescription()); Thread.Sleep(5000); } Console.ReadLine(); }
public void Kill() { _Instance = null; Destroy(gameObject); Destroy(this); }