Esempio n. 1
0
        static SimpleLevel()
        {
            Player = Actor.Create(
                1, ActorTypes.Player, "Player", HitPoints.Create(10, 10));
            Monster = Actor.Create(
                2, ActorTypes.Monster, "Monster", HitPoints.Create(10, 10));

            Floor      = Tile.Create(TileTypes.Floor, "Floor");
            Wall       = Tile.Create(TileTypes.Wall, "Wall");
            OpenDoor   = Tile.Create(TileTypes.OpenDoor, "OpenDoor");
            ClosedDoor = Tile.Create(TileTypes.ClosedDoor, "ClosedDoor");

            // . = Floor
            // # = Wall
            // C = ClosedDoor
            // O = OpenDoor
            // M = Monster
            // P = Player
            //
            // 3|.#P.
            // 2|##O#
            // 1|.C..
            // 0|.#.M
            //  +----
            //   0123

            var tiles = ImmutableGrid <Tile>
                        .CreateBuilder(Size.Create(4, 4))
                        .Set(0, 0, Floor)
                        .Set(0, 1, Wall)
                        .Set(0, 2, Floor)
                        .Set(0, 3, Floor)
                        .Set(1, 0, Wall)
                        .Set(1, 1, ClosedDoor)
                        .Set(1, 2, Wall)
                        .Set(1, 3, Wall)
                        .Set(2, 0, Wall)
                        .Set(2, 1, Wall)
                        .Set(2, 2, OpenDoor)
                        .Set(2, 3, Wall)
                        .Set(3, 0, Floor)
                        .Set(3, 1, Wall)
                        .Set(3, 2, Floor)
                        .Set(3, 3, Floor)
                        .Build();

            Level = Level
                    .Create(tiles, ImmutableDictionary <long, ActorState> .Empty)
                    .SpawnActor(Monster, Vector.Create(0, 3))
                    .SpawnActor(Player, Vector.Create(3, 2));
        }
Esempio n. 2
0
        public void WithHp()
        {
            var newHp = HitPoints.Create(2, 2);

            Validate(Actor.With(hitPoints: newHp), hp: newHp);
        }