Beispiel #1
0
        public bool LoadItemsMonsters(int beginX, int beginY)
        {
            try
            {
                _items = itemService.ReturnItems(_worldName, beginX, beginY).ToList();
                foreach (var item in _items)
                {
                    if (item.x != null)
                    {
                        MapTile mapTile = Map[item.x.GetValueOrDefault() % 8, item.y.GetValueOrDefault() % 8];
                        mapTile.ObjectTile = _tiles[item.Description];
                        mapTile.SetObjectSprite(item.x.GetValueOrDefault() % 8, item.y.GetValueOrDefault() % 8);

                        if (mapTile.ObjectTile.IsTransparent)
                        {
                            mapTile.ObjectSprite.ColorKey = Color.FromArgb(75, 75, 75);
                        }
                    }
                }

                _monsters = monstreService.ReturnMonsters(_worldName, beginX, beginY).ToList();
                foreach (var monstre in _monsters)
                {
                    MapTile mapTile = Map[monstre.x % 8, monstre.y % 8];
                    mapTile.ObjectTile = _tiles[monstre.Nom];
                    mapTile.SetObjectSprite(monstre.x % 8, monstre.y % 8);

                    if (mapTile.ObjectTile.IsTransparent)
                    {
                        mapTile.ObjectSprite.ColorKey = Color.FromArgb(75, 75, 75);
                    }
                }
                return(true);
            }
            catch
            {
                DialogResult dr = MessageBox.Show("An error occured while loading the map!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }