public override void Update(GameTime gameTime) { if (CurrentTime > 0) { CurrentTime -= gameTime.ElapsedGameTime.Milliseconds; } if (CurrentTime <= 0 && FadedOut) { TextureToDraw = null; if (TexturesToDisplay.Count == 0) { var loading = new ConcurrentQueue <Action>(); loading.Enqueue(delegate { AssetLibrary.Init(); }); loading.Enqueue(delegate { XmlLibrary.Init(); }); loading.Enqueue(delegate { AudioManager.Init(); }); ScreenManager.DispatchScreen(new LoadingScreen(loading, GameApplication.CharacterScreen = new CharacterScreen())); return; } CurrentTime = DELAY_BETWEEN_SPLASH; } if (TextureToDraw == null) { TextureToDrawAlpha = 0; FadedOut = false; FadeIn = true; TextureToDraw = TexturesToDisplay.Dequeue(); } }
private void LoadXmls() { App.Info($"Loading remote xmls..."); var xmls = Directory.EnumerateFiles(XmlDir, "*.xml").Where(name => !name.Contains("[DELETED]")).Select(file => { var fileinfo = new FileInfo(file); using (var stream = File.OpenRead(file)) return new XmlFile() { File = Path.GetFileNameWithoutExtension(fileinfo.Name), Size = GetFileSize(fileinfo.Length), Path = fileinfo.FullName, XElement = XElement.Load(stream) }; }).ToList(); XmlLibrary.Init(xmls); XmlCountLabel.Text = xmls.Count.ToString(); App.Info($"Loading remote xmls... OK!"); }
protected override void Initialize() { MapState = MapState.Active; ClientBounds = new Vector2(608, 600); XmlLibrary.Init(); Mapper = new LoEMapper <Map>("BRMEMaps", (message) => App.Warn(message)); Mapper.CreateMainDirectory(); InteractiveObjects = new Dictionary <string, List <InteractiveObject> >(); Textures = new Dictionary <string, Texture2D>(); Images = new Dictionary <string, Image>(); foreach (var interactiveobject in XmlLibrary.AllXmls.Values.Where(content => content.LayerData != null)) { var group = interactiveobject.LayerData.Group; if (!InteractiveObjects.ContainsKey(group)) { App.Info($"- Added group: '{group}'."); InteractiveObjects.Add(group, new List <InteractiveObject>() { interactiveobject }); } else { InteractiveObjects[group].Add(interactiveobject); } } InteractiveObjects.Values.Select(interactiveobjects => interactiveobjects.OrderBy(interactiveobject => interactiveobject.Name)).ToList(); var spritesheets = new Dictionary <string, string>(); foreach (var interactiveobjects in InteractiveObjects.Values) { foreach (var interactiveobject in interactiveobjects) { var group = interactiveobject.LayerData.Group; if (!spritesheets.ContainsKey(interactiveobject.LayerData.Group)) { spritesheets.Add(interactiveobject.LayerData.Group, interactiveobject.TextureData.File); } } } foreach (var spritesheet in spritesheets) { Texture2D texture = null; Image image = null; try { texture = Utils.LoadEmbeddedSpritesheetToTexture2D(GraphicsDevice, spritesheet.Value); image = Utils.LoadEmbeddedSpritesheetToImage(spritesheet.Value); } catch { App.Warn($"Missing texture: {spritesheet.Value}.png"); } if (texture != null && image != null) { App.Info($"- Added spritsheet '{spritesheet.Value}' to group '{spritesheet.Key}'."); Textures.Add(spritesheet.Key, texture); Images.Add(spritesheet.Key, image); } } App.Info("Creating a sample map..."); Map = new Map(MapSize.SIZE_128); ShowUndergroundLayer = true; ShowGroundLayer = true; ShowObjectLayer = true; ShowSkyLayer = true; GridTexture = Utils.LoadEmbeddedTexture(GraphicsDevice, "sample-grid.png"); InteractiveObject = null; HUD.UpdatePalleteComboBox(InteractiveObjects.Keys.OrderBy(group => group).ToArray()); ActualMapName = "sample"; ActualMapSize = MapSize.SIZE_128; App.Info($"- Name: {ActualMapName}"); App.Info($"- Size: {(int)ActualMapSize} x {(int)ActualMapSize}"); App.Info("Creating a sample map... OK!"); App.Info("Game Map Editor is loading... OK!\n"); base.Initialize(); Editor.Content.RootDirectory = "Content"; Editor.ShowFPS = true; Camera = new LoECamera(609, 600); }
public static void Main(string[] args) { Console.Title = $"{Name} - Build: {Version}"; var config = new LoggingConfiguration(); var developerLog = new ColoredConsoleTarget() { Name = "developer", Layout = @"[${date:format=HH\:mm\:ss}] [${level}] ${message} ${exception}" }; var developerFile = new FileTarget() { Name = "developer-file", FileName = "../../../logs/server/Build ${assembly-version}/${level}/${date:format=dd-MM-yyyy}.txt", Layout = @"[${date:format=HH\:mm\:ss}] [${level}] ${message} ${exception}" }; config.AddTarget(developerLog); config.AddTarget(developerFile); config.AddRule(LogLevel.Info, LogLevel.Fatal, developerFile); config.AddRuleForAllLevels(developerLog); LogManager.Configuration = config; RollbarLocator.RollbarInstance.Configure(new RollbarConfig(RollbarId)); Info("Game Server is loading..."); XmlLibrary.Init(); Database = new Database(); LoEUtils = new Util((message) => Warn(message)); try { Map.BinaryMapsCache = new Dictionary <string, KeyValuePair <bool, byte[]> >(); Map.LoadEmbeddedMaps(); var manager = new WorldManager(); var connection = new NetworkListener(manager); NetworkProccessor.Start(); connection.Listen(); manager.BeginUpdate(); Info("Game Server is loading... OK!"); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Database.Dispose(); Info("Game Server has been stopped."); Environment.Exit(0); } catch (Exception e) { Database.Dispose(); Warn($"An error occurred! {e.ToString()}"); Error(e); Thread.Sleep(100); Warn("Press 'ESC' to close..."); while (Console.ReadKey(true).Key != ConsoleKey.Escape) { ; } Environment.Exit(-1); } }