private void LoadWorld()
        {
            RpgLibrary.WorldClasses.LevelData levelData =
                Game.Content.Load <RpgLibrary.WorldClasses.LevelData>(@"Game\Levels\Starting Level");

            RpgLibrary.WorldClasses.MapData mapData =
                Game.Content.Load <RpgLibrary.WorldClasses.MapData>(@"Game\Levels\Maps\" + levelData.MapName);

            TileMap map = TileMap.FromMapData(mapData, Game.Content);

            Level level = new Level(map);

            ChestData chestData = Game.Content.Load <ChestData>(@"Game\Chests\Plain Chest");

            Chest chest = new Chest(chestData);

            BaseSprite chestSprite = new BaseSprite(
                containers,
                new Rectangle(0, 0, 32, 32),
                new Point(10, 10));

            ItemSprite itemSprite = new ItemSprite(
                chest,
                chestSprite);

            level.Chests.Add(itemSprite);

            World world = new World(GameRef, GameRef.ScreenRectangle);

            world.Levels.Add(level);
            world.CurrentLevel = 0;

            AnimatedSprite s = new AnimatedSprite(
                GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"),
                AnimationManager.Instance.Animations);

            s.Position = new Vector2(0 * Engine.TileWidth, 5 * Engine.TileHeight);

            EntityData ed = new EntityData("Eliza", 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16",
                                           "0|0|0");

            Entity e = new Entity("Eliza", ed, EntityGender.Female, EntityType.NPC);

            NonPlayerCharacter npc = new NonPlayerCharacter(e, s);

            npc.SetConversation("eliza1");
            world.Levels[world.CurrentLevel].Characters.Add(npc);

            GamePlayScreen.World = world;

            CreateConversation();

            ((NonPlayerCharacter)world.Levels[world.CurrentLevel].Characters[0]).SetConversation("eliza1");
        }
Exemple #2
0
        private void LoadWorld()
        {
            RpgLibrary.WorldClasses.LevelData levelData =
                Game.Content.Load <RpgLibrary.WorldClasses.LevelData>(@"Game\Levels\Starting Level");

            RpgLibrary.WorldClasses.MapData mapData =
                Game.Content.Load <RpgLibrary.WorldClasses.MapData>(@"Game\Levels\Maps\" + levelData.MapName);

            CharacterLayerData charData =
                Game.Content.Load <CharacterLayerData>(@"Game\Levels\Chars\Starting Level");
            CharacterLayer characterLayer = new CharacterLayer();
            MobLayer       mobLayer       = new MobLayer();

            TileMap map = TileMap.FromMapData(mapData, Game.Content);

            foreach (var c in charData.Characters)
            {
                Character character;

                if (c.Value is NonPlayerCharacterData data)
                {
                    Entity entity = new Entity(c.Value.Name, c.Value.EntityData, c.Value.Gender, EntityType.NPC);

                    using (Stream stream = new FileStream(c.Value.TextureName, FileMode.Open, FileAccess.Read))
                    {
                        Texture2D      texture = Texture2D.FromStream(GraphicsDevice, stream);
                        AnimatedSprite sprite  = new AnimatedSprite(texture, AnimationManager.Instance.Animations)
                        {
                            Position = new Vector2(c.Key.X * Engine.TileWidth, c.Key.Y * Engine.TileHeight)
                        };

                        character = new NonPlayerCharacter(entity, sprite);

                        ((NonPlayerCharacter)character).SetConversation(
                            data.CurrentConversation);
                    }

                    characterLayer.Characters.Add(c.Key, character);
                }
            }

            map.AddLayer(characterLayer);
            map.AddLayer(mobLayer);

            Level level = new Level(map);

            ChestData chestData = Game.Content.Load <ChestData>(@"Game\Chests\Plain Chest");

            Chest chest = new Chest(chestData);

            BaseSprite chestSprite = new BaseSprite(
                containers,
                new Rectangle(0, 0, 32, 32),
                new Point(10, 10));

            ItemSprite itemSprite = new ItemSprite(
                chest,
                chestSprite);

            level.Chests.Add(itemSprite);

            World world = new World(GameRef, GameRef.ScreenRectangle);

            world.Levels.Add(level);
            world.CurrentLevel = 0;

            AnimatedSprite s = new AnimatedSprite(
                GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"),
                AnimationManager.Instance.Animations)
            {
                Position = new Vector2(0 * Engine.TileWidth, 5 * Engine.TileHeight)
            };

            EntityData ed = new EntityData("Eliza", 1, 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16",
                                           "0|0|0");

            Entity e = new Entity("Eliza", ed, EntityGender.Female, EntityType.NPC);

            NonPlayerCharacter npc = new NonPlayerCharacter(e, s);

            npc.SetConversation("eliza1");
            //world.Levels[world.CurrentLevel].Characters.Add(npc);

            s = new AnimatedSprite(
                GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"),
                AnimationManager.Instance.Animations)
            {
                Position = new Vector2(10 * Engine.TileWidth, 0)
            };

            ed = new EntityData("Barbra", 2, 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16", "0|0|0");

            e = new Entity("Barbra", ed, EntityGender.Female, EntityType.Merchant);

            Merchant  m     = new Merchant(e, s);
            Texture2D items = Game.Content.Load <Texture2D>("ObjectSprites/roguelikeitems");

            m.Backpack.AddItem(GameItemManager.GetItem("Long Sword"));
            m.Backpack.AddItem(GameItemManager.GetItem("Short Sword"));
            m.Backpack.AddItem(GameItemManager.GetItem("Apprentice Staff"));
            m.Backpack.AddItem(GameItemManager.GetItem("Acolyte Staff"));
            m.Backpack.AddItem(GameItemManager.GetItem("Leather Armor"));
            m.Backpack.AddItem(GameItemManager.GetItem("Chain Mail"));
            m.Backpack.AddItem(GameItemManager.GetItem("Studded Leather Armor"));
            m.Backpack.AddItem(GameItemManager.GetItem("Light Robes"));
            m.Backpack.AddItem(GameItemManager.GetItem("Medium Robes"));
            world.Levels[world.CurrentLevel].Characters.Add(m);
            ((CharacterLayer)world.Levels[world.CurrentLevel].Map.Layers.Find(x => x is CharacterLayer)).Characters.Add(new Point(10, 0), m);
            GamePlayScreen.World = world;

            for (int i = 0; i < 25; i++)
            {
                ed = new EntityData("Bandit", 1, 10, 12, 12, 10, 10, 10, "20|CON|10", "12|WIL|12", "0|0|0");

                e = new Entity("Bandit", ed, EntityGender.Male, EntityType.Monster);

                s = new AnimatedSprite(
                    GameRef.Content.Load <Texture2D>(@"PlayerSprites/malerogue"),
                    AnimationManager.Instance.Animations);

                Mob mob = new Bandit(e, s);

                Rectangle r = new Rectangle(Mechanics.Random.Next(10, 20) * 32, Mechanics.Random.Next(10, 20) * 32, 32, 32);

                if (!mobLayer.Mobs.ContainsKey(r))
                {
                    mobLayer.Mobs.Add(r, mob);
                }

                mob.Entity.Equip(GameItemManager.GetItem("Short Sword"));
                mob.Drops.Add(GameItemManager.GetItem("Short Sword"));
                mob.Drops.Add(GameItemManager.GetItem("Minor Healing Potion"));
            }
        }
        private void LoadWorld()
        {
            RpgLibrary.WorldClasses.LevelData levelData =
                Game.Content.Load <RpgLibrary.WorldClasses.LevelData>(@"Game\Levels\Starting Level");

            RpgLibrary.WorldClasses.MapData mapData =
                Game.Content.Load <RpgLibrary.WorldClasses.MapData>(@"Game\Levels\Maps\" + levelData.MapName);


            string[] fileNames = Directory.GetFiles(
                Path.Combine("Content/Game/Items", "Armor"),
                "*.xnb");

            foreach (string a in fileNames)
            {
                string path = "Game/Items/Armor/" + Path.GetFileNameWithoutExtension(a);

                ArmorData armorData = Game.Content.Load <ArmorData>(path);
                ItemManager.AddArmor(new Armor(armorData));
            }

            fileNames = Directory.GetFiles(
                Path.Combine("Content/Game/Items", "Shield"),
                "*.xnb");

            foreach (string a in fileNames)
            {
                string path = "Game/Items/Shield/" + Path.GetFileNameWithoutExtension(a);

                ShieldData shieldData = Game.Content.Load <ShieldData>(path);
                ItemManager.AddShield(new Shield(shieldData));
            }

            fileNames = Directory.GetFiles(
                Path.Combine("Content/Game/Items", "Weapon"),
                "*.xnb");

            foreach (string a in fileNames)
            {
                string path = "Game/Items/Weapon/" + Path.GetFileNameWithoutExtension(a);

                WeaponData weaponData = Game.Content.Load <WeaponData>(path);
                ItemManager.AddWeapon(new Weapon(weaponData));
            }

            CharacterLayerData charData =
                Game.Content.Load <CharacterLayerData>(@"Game\Levels\Chars\Starting Level");
            CharacterLayer characterLayer = new CharacterLayer();

            TileMap map = TileMap.FromMapData(mapData, Game.Content);

            foreach (var c in charData.Characters)
            {
                Character character;

                if (c.Value is NonPlayerCharacterData)
                {
                    Entity entity = new Entity(c.Value.Name, c.Value.EntityData, c.Value.Gender, EntityType.NPC);

                    using (Stream stream = new FileStream(c.Value.TextureName, FileMode.Open, FileAccess.Read))
                    {
                        Texture2D      texture = Texture2D.FromStream(GraphicsDevice, stream);
                        AnimatedSprite sprite  = new AnimatedSprite(texture, AnimationManager.Instance.Animations)
                        {
                            Position = new Vector2(c.Key.X * Engine.TileWidth, c.Key.Y * Engine.TileHeight)
                        };

                        character = new NonPlayerCharacter(entity, sprite);

                        ((NonPlayerCharacter)character).SetConversation(
                            ((NonPlayerCharacterData)c.Value).CurrentConversation);
                    }

                    characterLayer.Characters.Add(c.Key, character);
                }
            }

            map.AddLayer(characterLayer);

            Level level = new Level(map);

            ChestData chestData = Game.Content.Load <ChestData>(@"Game\Chests\Plain Chest");

            Chest chest = new Chest(chestData);

            BaseSprite chestSprite = new BaseSprite(
                containers,
                new Rectangle(0, 0, 32, 32),
                new Point(10, 10));

            ItemSprite itemSprite = new ItemSprite(
                chest,
                chestSprite);

            level.Chests.Add(itemSprite);

            World world = new World(GameRef, GameRef.ScreenRectangle);

            world.Levels.Add(level);
            world.CurrentLevel = 0;

            AnimatedSprite s = new AnimatedSprite(
                GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"),
                AnimationManager.Instance.Animations);

            s.Position = new Vector2(0 * Engine.TileWidth, 5 * Engine.TileHeight);

            EntityData ed = new EntityData("Eliza", 1, 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16",
                                           "0|0|0");

            Entity e = new Entity("Eliza", ed, EntityGender.Female, EntityType.NPC);

            NonPlayerCharacter npc = new NonPlayerCharacter(e, s);

            npc.SetConversation("eliza1");
            //world.Levels[world.CurrentLevel].Characters.Add(npc);

            s = new AnimatedSprite(
                GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"),
                AnimationManager.Instance.Animations);
            s.Position = new Vector2(10 * Engine.TileWidth, 0);

            ed = new EntityData("Barbra", 2, 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16", "0|0|0");

            e = new Entity("Barbra", ed, EntityGender.Female, EntityType.Merchant);

            Merchant  m     = new Merchant(e, s);
            Texture2D items = Game.Content.Load <Texture2D>("ObjectSprites/roguelikeitems");

            m.Backpack.AddItem(new GameItem(ItemManager.GetWeapon("Long Sword"), items, new Rectangle(0, 0, 16, 16)));
            m.Backpack.AddItem(new GameItem(ItemManager.GetWeapon("Short Sword"), items, new Rectangle(16, 0, 16, 16)));

            world.Levels[world.CurrentLevel].Characters.Add(m);
            ((CharacterLayer)world.Levels[world.CurrentLevel].Map.Layers.Find(x => x is CharacterLayer)).Characters.Add(new Point(10, 0), m);
            GamePlayScreen.World = world;

            CreateConversation();

            // ((NonPlayerCharacter)world.Levels[world.CurrentLevel].Characters[0]).SetConversation("eliza1");
        }
        private void LoadWorld()
        {
            RpgLibrary.WorldClasses.LevelData levelData =
                Game.Content.Load <RpgLibrary.WorldClasses.LevelData>(@"Game\Levels\Starting Level");

            RpgLibrary.WorldClasses.MapData mapData =
                Game.Content.Load <RpgLibrary.WorldClasses.MapData>(@"Game\Levels\Maps\" + levelData.MapName);

            CharacterLayerData charData =
                Game.Content.Load <CharacterLayerData>(@"Game\Levels\Chars\Starting Level");
            CharacterLayer characterLayer = new CharacterLayer();

            TileMap map = TileMap.FromMapData(mapData, Game.Content);

            foreach (var c in charData.Characters)
            {
                Character character;

                if (c.Value is NonPlayerCharacterData)
                {
                    Entity entity = new Entity(c.Value.Name, c.Value.EntityData, c.Value.Gender, EntityType.NPC);

                    using (Stream stream = new FileStream(c.Value.TextureName, FileMode.Open, FileAccess.Read))
                    {
                        Texture2D      texture = Texture2D.FromStream(GraphicsDevice, stream);
                        AnimatedSprite sprite  = new AnimatedSprite(texture, AnimationManager.Instance.Animations)
                        {
                            Position = new Vector2(c.Key.X * Engine.TileWidth, c.Key.Y * Engine.TileHeight)
                        };

                        character = new NonPlayerCharacter(entity, sprite);

                        ((NonPlayerCharacter)character).SetConversation(
                            ((NonPlayerCharacterData)c.Value).CurrentConversation);
                    }

                    characterLayer.Characters.Add(c.Key, character);
                }
            }

            map.AddLayer(characterLayer);

            Level level = new Level(map);

            ChestData chestData = Game.Content.Load <ChestData>(@"Game\Chests\Plain Chest");

            Chest chest = new Chest(chestData);

            BaseSprite chestSprite = new BaseSprite(
                containers,
                new Rectangle(0, 0, 32, 32),
                new Point(10, 10));

            ItemSprite itemSprite = new ItemSprite(
                chest,
                chestSprite);

            level.Chests.Add(itemSprite);

            World world = new World(GameRef, GameRef.ScreenRectangle);

            world.Levels.Add(level);
            world.CurrentLevel = 0;

            AnimatedSprite s = new AnimatedSprite(
                GameRef.Content.Load <Texture2D>(@"SpriteSheets\Eliza"),
                AnimationManager.Instance.Animations);

            s.Position = new Vector2(0 * Engine.TileWidth, 5 * Engine.TileHeight);

            EntityData ed = new EntityData("Eliza", 1, 10, 10, 10, 10, 10, 10, "20|CON|12", "16|WIL|16",
                                           "0|0|0");

            Entity e = new Entity("Eliza", ed, EntityGender.Female, EntityType.NPC);

            NonPlayerCharacter npc = new NonPlayerCharacter(e, s);

            npc.SetConversation("eliza1");
            world.Levels[world.CurrentLevel].Characters.Add(npc);

            GamePlayScreen.World = world;

            CreateConversation();

            ((NonPlayerCharacter)world.Levels[world.CurrentLevel].Characters[0]).SetConversation("eliza1");
        }