Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //var origin = new GoogleMapPoint
            //{
            //    Lat = 10.8160092,
            //    Lng = 106.7068522
            //};

            //var destination = new GoogleMapPoint
            //{
            //    Lat = 10.802195,
            //    Lng = 106.650778
            //};

            //var origin1 = new GeoCoordinate(Convert.ToDouble(origin.Lat), Convert.ToDouble(origin.Lng));
            //var destination1 = new GeoCoordinate(Convert.ToDouble(destination.Lat), Convert.ToDouble(destination.Lng));

            //var metter = origin1.GetDistanceTo(destination1);
            //var miles = metter * 0.000621371;
            //var data = MetersToMiles(origin1.GetDistanceTo(destination1),2);

            //Console.WriteLine(metter);
            //Console.WriteLine(miles);
            //Console.WriteLine(data);

            XmlLibrary.ReadXmlToList();
            Console.WriteLine("Finished");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
 public override void Init()
 {
     if (Content != null)
     {
         Animation.UpdateOrAdd(Content);
         Texture = XmlLibrary.GetSpriteFromContent(Content, 0, 1);
     }
 }
Ejemplo n.º 3
0
 public Tile(int x, int y, int id)
 {
     X              = x;
     Y              = y;
     TileId         = id;
     TileProperties = XmlLibrary.TilesXml[TileId];
     Texture        = XmlLibrary.GetSpriteFromContent(TileProperties);
 }
Ejemplo n.º 4
0
        private void AddCharacterView()
        {
            RemoveChild(CharacterView);

            CharacterView = new Sprite(50, 15, 150, 150, XmlLibrary.GetSpriteFromContent(Content, 0, 1));
            CharacterView.IsEventApplicable = false;

            AddChild(CharacterView);
        }
Ejemplo n.º 5
0
        public void UpdateOrAdd(ObjectsContent content)
        {
            var animation = XmlLibrary.GetAnimation(content);

            AddAnimation(AnimationType.Forward, animation[0]);
            AddAnimation(AnimationType.Backward, animation[1]);
            AddAnimation(AnimationType.Left, animation[3]);
            AddAnimation(AnimationType.Right, animation[2]);
        }
Ejemplo n.º 6
0
            public CharacterView(int x, int y, int id)
                : base(x, y, 150, 200, AssetLibrary.Images["characterDisplayRect"])
            {
                var content = XmlLibrary.ObjectsXml[id];

                CharacterSprite = new Sprite(0, 25, 150, 150, XmlLibrary.GetSpriteFromContent(content, 0, 1));

                AddChild(CharacterSprite);
            }
Ejemplo n.º 7
0
        private static MethodsAggregator CreateLibrary()
        {
            var methodsManager    = new MethodsManager();
            var propertiesManager = new PropertiesManager();

            var library = new XmlLibrary();

            methodsManager.RegisterLibraries(library);
            propertiesManager.RegisterProperties(library);

            return(new MethodsAggregator(methodsManager, propertiesManager));
        }
Ejemplo n.º 8
0
        public void LoadPlayerSprite(GamePlayer player)
        {
            if (!Contains(PlayerSprite))
            {
                PlayerSprite = new CharacterView(130, -215, player.Player.Id);

                AddChild(PlayerSprite);
                return;
            }

            PlayerSprite.CharacterSprite.SpriteTexture = XmlLibrary.GetSpriteFromContent(player.Player.Content, 0, 1);
        }
Ejemplo n.º 9
0
        public ItemCell(int id, int itemidx, int x, int y)
            : base(x, y, 50, 50, AssetLibrary.Images["itemDisplayRect"])
        {
            Id        = id;
            ItemIndex = itemidx;
            if (Id != -1)
            {
                XmlContent = XmlLibrary.ItemsXml[Id];
            }

            ItemSprite = new Sprite(10, 10, 30, 30, (XmlContent == null) ? null : XmlLibrary.GetSpriteFromContent(XmlContent));

            //DescriptionBox = new DescriptionPanel(DrawHelper.CenteredToScreenWidth(300), DrawHelper.CenteredToScreenHeight(400), XmlContent.Name);
            //DescriptionBox.IsZeroApplicaple = true;

            ActiveDescription = new ActiveDescriptionBox(0, 0);
            ActiveDescription.Reload((XmlContent == null) ? null : XmlContent);
            ActiveDescription.Visible           = false;
            ActiveDescription.IsZeroApplicaple  = true;
            ActiveDescription.IsEventApplicable = false;

            AddChild(ItemSprite);

            AddEventListener(Event.MOUSEOVER, delegate
            {
                SpriteColor = Color.Yellow;
                Selected    = true;

                if (!Dragging && Id != -1)
                {
                    if (!ParentSprite.Contains(ActiveDescription))
                    {
                        ParentSprite.AddChild(ActiveDescription);
                    }

                    ActiveDescription.Visible = true;
                    ActiveDescription.X       = EventsHandler.MouseRectangle.X;
                    ActiveDescription.Y       = EventsHandler.MouseRectangle.Y;
                }
            });

            AddEventListener(Event.MOUSEOUT, delegate
            {
                SpriteColor = Color.Gray;

                Selected = false;
                ActiveDescription.Visible = false;
            });
        }
Ejemplo n.º 10
0
        public void Reload(int id)
        {
            Id         = id;
            XmlContent = XmlLibrary.ItemsXml[Id];

            if (Contains(ItemSprite))
            {
                RemoveChild(ItemSprite);
                ItemSprite.SpriteTexture = XmlLibrary.GetSpriteFromContent(XmlContent);
                AddChild(ItemSprite);
            }
            else
            {
                ItemSprite = new Sprite(5, 5, 30, 30, XmlLibrary.GetSpriteFromContent(XmlContent));
                AddChild(ItemSprite);
            }

            ActiveDescription.Reload(XmlContent);
        }
Ejemplo n.º 11
0
        public void Init(CharacterRect parent)
        {
            _parent = parent;

            int spriteX = 10;

            _meleeClass   = new Sprite(spriteX, 10, 120, 120, XmlLibrary.GetSpriteFromContent(XmlLibrary.ObjectsXml[5], 0, 1));
            spriteX      += 130;
            _rangeClass   = new Sprite(spriteX, 10, 120, 120, XmlLibrary.GetSpriteFromContent(XmlLibrary.ObjectsXml[6], 0, 1));
            spriteX      += 130;
            _defenseClass = new Sprite(spriteX, 10, 120, 120, XmlLibrary.GetSpriteFromContent(XmlLibrary.ObjectsXml[7], 0, 1));

            _meleeClass.AddEventListener(Event.CLICKLEFT, delegate
            {
                CreateCharacter(5);
                ParentSprite.RemoveChild(this);
            });
            _meleeClass.AddEventListener(Event.MOUSEOUT, delegate { _meleeClass.SpriteColor = Color.White; });
            _meleeClass.AddEventListener(Event.MOUSEOVER, delegate { _meleeClass.SpriteColor = Color.DarkSlateGray; });

            _rangeClass.AddEventListener(Event.CLICKLEFT, delegate
            {
                CreateCharacter(6);
                ParentSprite.RemoveChild(this);
            });
            _rangeClass.AddEventListener(Event.MOUSEOUT, delegate { _rangeClass.SpriteColor = Color.White; });
            _rangeClass.AddEventListener(Event.MOUSEOVER, delegate { _rangeClass.SpriteColor = Color.DarkSlateGray; });

            _defenseClass.AddEventListener(Event.CLICKLEFT, delegate
            {
                CreateCharacter(7);
                ParentSprite.RemoveChild(this);
            });
            _defenseClass.AddEventListener(Event.MOUSEOUT, delegate { _defenseClass.SpriteColor = Color.White; });
            _defenseClass.AddEventListener(Event.MOUSEOVER, delegate { _defenseClass.SpriteColor = Color.DarkSlateGray; });

            AddChild(_mask);
            AddChild(_meleeClass);
            AddChild(_rangeClass);
            AddChild(_defenseClass);
        }
Ejemplo n.º 12
0
        private void RunTasks()
        {
            Program.TreadUI = SynchronizationContext.Current;

            UserConfig userConfig = SaveUserConfig();

            if (UserConfig.IsConfigured(userConfig))
            {
                XmlLibrary selectedLibrary = new XmlLibrary(Program.Config);

                if (lbDiscs.SelectedItem != null)
                {
                    if (lbDiscs.SelectedItem is XmlDisc)
                    {
                        XmlDisc disc = lbDiscs.SelectedItem as XmlDisc;
                        selectedLibrary.AddTracks(disc.Tracks);
                    }
                }
                else if (tvLibrary.SelectedNode != null)
                {
                    if (tvLibrary.SelectedNode.Tag is XmlAlbumArtist)
                    {
                        XmlAlbumArtist band = tvLibrary.SelectedNode.Tag as XmlAlbumArtist;
                        selectedLibrary.AddTracks(band.GetTracks());
                    }
                    else if (tvLibrary.SelectedNode.Tag is XmlAlbum)
                    {
                        XmlAlbum album = tvLibrary.SelectedNode.Tag as XmlAlbum;
                        selectedLibrary.AddTracks(album.GetTracks());
                    }
                }
                else
                {
                    selectedLibrary = Program.Library; // if nothing is selected then validate entire library
                }

                Program.LogViewer.BindWorker(selectedLibrary.Worker);
                selectedLibrary.RunTasks();
            }
        }
Ejemplo n.º 13
0
        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!");
        }
Ejemplo n.º 14
0
        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();
            }
        }
Ejemplo n.º 15
0
        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);
            }
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
 public virtual void Init()
 {
     Texture = XmlLibrary.GetSpriteFromContent(Content);
 }