Exemplo n.º 1
0
        private static IMapObject GetObjectByChar(char c, int y, int x)
        {
            var position = new Vector2(x + 0.5f, y + 0.5f);

            return(c switch
            {
                'R' => (IMapObject)Rat.Create(ResourceCachedLoader.Instance, position, 0),
                'S' => Skeleton.Create(ResourceCachedLoader.Instance, position, 0),
                'L' => Lich.Create(ResourceCachedLoader.Instance, position, 0),
                'H' => HealingPotion.Create(position),
                'M' => ManaPotion.Create(position),
                'A' => ArrowPack.Create(position),
                'D' => Ded.Create(position),
                _ => null
            });
Exemplo n.º 2
0
        private static unsafe void Main(string[] args)
        {
            var options = new EngineOptions(
                "simple 3d game",
                720, 1280,
                true,
                UiResourcesHelper.PressStart2PFontPath,
                UiResourcesHelper.CrossSpritePath,
                UiResourcesHelper.ScrollSpritePath);

            using var engine = EngineBuilder.BuildEngine25D(options);
            var resourceLoader = ResourceCachedLoader.Instance;
            var player         = new MyPlayer(new Vector2(2.0f, 2.0f), new Vector2(0.3f, 0.3f), MathF.PI / 2, 10);
            var wallTexture    = Sprite.Load("./sprites/greystone.png");
            var floorTexture   = Sprite.Load("./sprites/colorstone.png");
            var windowTexture  = Sprite.Load("./sprites/window.png");
            var ceilingTexture = Sprite.Load("./sprites/wood.png");
            var bedTexture     = Sprite.Load("./sprites/bed.png");
            var sword          = Sword.Create(resourceLoader);
            var bow            = Bow.Create(resourceLoader);
            var doorAnimation  = resourceLoader.GetAnimation("./animations/door");

            player.Weapons = new Weapon[] { sword, bow };
            var backGroundMusic = resourceLoader.GetMusic(MusicResourceHelper.EnvironmentDungeonMusic);
            var objects         = new IMapObject[]
            {
                Lich.Create(resourceLoader, new Vector2(6f, 6f), 0.0f),
                Skeleton.Create(resourceLoader, new Vector2(6f, 6f), 0.0f),
                GreenLight.Create(resourceLoader, new Vector2(8.0f, 8.0f), new Vector2(0, 0), 0),
                HealingPotion.Create(new Vector2(6f, 6f)),
                ArrowPack.Create(new Vector2(7f, 7f)),
                Note.Create(new Vector2(5f, 5f), "о, привет!\nследующая строка\nотвратительно длинная строка с кучей слов капец\nа вот это уже максимум по длине лучше бы его не переступать ага га гус")
            };

            backGroundMusic.Play(-1);
            var storage = new MapTextureStorage(ceilingTexture, wallTexture, floorTexture, windowTexture, bedTexture, doorAnimation);
            var map     = Map.FromStrings(new[]
            {
                "###############################",
                "#.............................#",
                "#.............................#",
                "#.............................#",
                "##...................#........#",
                "#b...................###......#",
                "#b...................#........#",
                "####......##########.#........#",
                "##...................#......###",
                "#........####........#........#",
                "#........#..#........#........#",
                "#........#..#........###......#",
                "#####.####..####.....#........#",
                "#####.####..####.....#........#",
                "#....................#......###",
                "#....................#........#",
                "#####.####..####.....###......#",
                "#####.####..####.....#........#",
                "#....................#........#",
                "###############################"
            }, storage.GetCellByChar);
            var level = new Scene(player, map, objects);

            while (engine.Update(level))
            {
            }
        }