public void SetVisibility(World world)
 {
     World = world;
     for (int i = 0; i <= 8; i++)
     {
         ScanOctant(1, 1.0, 0.0, i);
     }
 }
 public void SetVisibility(World world)
 {
     for (int x = 0; x < world.Map.Tiles.GetLength(0); x++)
     {
         for (int y = 0; y < world.Map.Tiles.GetLength(1); y++)
         {
             world.Map.Tiles[x, y].Visible = true;
         }
     }
 }
Esempio n. 3
0
        public void SetVisibility(World world)
        {
            World = world;
            var area = new Rectangle(0, 0, world.Map.Tiles.GetLength(0), world.Map.Tiles.GetLength(1));

            for (int x = area.Left; x < area.Right; x++)
            {
                TraceLine(world.Player.X, world.Player.Y, x, area.Top);
                TraceLine(world.Player.X, world.Player.Y, x, area.Bottom);

            }

            for (int y = 0; y < area.Top + 1; y++)
            {
                TraceLine(world.Player.X, world.Player.Y, area.Left, y);
                TraceLine(world.Player.X, world.Player.Y, area.Right, y);
            }
        }
Esempio n. 4
0
        public Engine(IFovStrategy fovStrategy, ITileFactory tileFactory, World world, IInputHandler input, ILogController gameLog, ConsoleWindow console)
        {
            FovStrategy = fovStrategy;
            TileFactory = tileFactory;
            World = world;
            InputHandler = input;
            Console = console;

            if (ActorControllers == null)
            {
                ActorControllers = new List<IController>();
            }

            if (FurnitureControllers == null)
            {
                FurnitureControllers = new List<IController>();
            }

            GameLogController = gameLog;
        }
Esempio n. 5
0
 public EntityMoveHelper(World world, ILogController gameLog)
 {
     World = world;
     GameLog = gameLog;
 }
Esempio n. 6
0
        public static Engine Start()
        {
            Container
                .For<ConsoleWindow>()
                .Provide(c => new ConsoleWindow(80, 220, "Explorer"))
                .AsSingleton();

            Container
                .For<IGraphicsComponent>()
                .Provide<AsciiGraphicsComponent>();

            Container
                .For<Player>()
                .Provide(c =>
                {
                    return new Player() { X = 10, Y = 15, EnergyDelta = 500 };
                }).AsSingleton();

            Container.For<ITileFactory>().Provide<NaturalCaveCaTileFactory>();

            Container.For<World>()
                .Provide(c =>
                {
                    var world = new World();
                    world.Player = c.Resolve<Player>();
                    world.Map = MapLoader.LoadMap(c.Resolve<ITileFactory>());
                    return world;
                }).AsSingleton();

            Container
                .For<IInputHandler>()
                .Provide<InputHandler>();

            Container
                .For<IView<Creature>>()
                .Provide<MonsterView>();

            Container
                .For<IView<Player>>()
                .Provide<PlayerView>();

            Container
                .For<IView<Furniture>>()
                .Provide<MapView>();

            Container
                .For<IView<GameLog>>()
                .Provide<GameLogView>();

            Container
                .For<IFovStrategy>()
                .Provide<AlwaysVisibleFovStrategy>();

            Container
                .For<PlayerController>()
                .Provide<PlayerController>();

            Container
                .For<GameLog>()
                .Provide(c => new GameLog { X = 1, Y = 60 })
                .AsSingleton();

            Container
                .For<ILogController>()
                .Provide<GameLogController>();

            Container
                .For<IMoveHelper>()
                .Provide<EntityMoveHelper>();

            Container
                .For<Engine>()
                .Provide<Engine>()
                .AsSingleton();

            var monsters = new List<Creature>()
            {
                new Creature() { X = 15, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 23, Y = 20, EnergyDelta = 250 },
                new Creature() { X = 10, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 29, Y = 20, EnergyDelta = 10 },
                new Creature() { X = 18, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 31, Y = 20, EnergyDelta = 100 },
                new Creature() { X = 10, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 38, Y = 20, EnergyDelta = 250 },
                new Creature() { X = 10, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 15, Y = 20, EnergyDelta = 10 },
                new Creature() { X = 34, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 18, Y = 20, EnergyDelta = 300 },
                new Creature() { X = 12, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 12, Y = 20, EnergyDelta = 250 },
                new Creature() { X = 23, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 39, Y = 20, EnergyDelta = 10 },
                new Creature() { X = 26, Y = 10, EnergyDelta = 100 },
                new Creature() { X = 20, Y = 20, EnergyDelta = 500 },
            };

            var engine = Container.Resolve<Engine>();

            foreach (var monster in monsters)
            {
                var controller = new MonsterController(monster,
                    Container.Resolve<IView<Creature>>(),
                    Container.Resolve<World>(),
                    Container.Resolve<IMoveHelper>(), Container.Resolve<ILogController>());

                engine.AddActor(monster, controller);
            }

            engine.ActorControllers.Add(Container.Resolve<PlayerController>());

            foreach (var tile in engine.World.Map.Tiles)
            {
                engine.FurnitureControllers.Add(new MapController(tile.Furniture, Container.Resolve<IView<Furniture>>(), Container.Resolve<World>(), Container.Resolve<ILogController>()));
            }

            return engine;

        }