public static GenericOpenHeroesRunner CreateInstance(IMapLoader mapLoader = null, EntityWorld entityWorld = null)
 {
     if (mapLoader == null)
     {
         mapLoader = new ByteArrayMapLoader(ByteArrayHelper.CreateBase());
     }
     return(new GenericOpenHeroesRunner(mapLoader, entityWorld));
 }
示例#2
0
        public override void LoadContent()
        {
            base.LoadContent();
            _eventBus = BlackBoard.GetEntry <JEventBus>("EventBus") ?? JEventBus.GetDefault();
            _eventBus.Register(this);

            var _grid = BlackBoard.GetEntry <Grid>("Grid");

            _dijkstraPathFinder = new DijkstraPathFinder(ByteArrayHelper.CreateBase(_grid.Width));
        }
        public void TestPathfinderSystem()
        {
            GenericOpenHeroesRunner.CreateInstance(new ByteArrayMapLoader(ByteArrayHelper.CreateBase(128)));
            FindPathEvent findPathEvent = new FindPathEvent(new Point(0, 0), new Point(100, 100));

            JEventBus.GetDefault().Post(findPathEvent);

            Assert.IsNotNull(findPathEvent.CalculatedPath);
            Assert.IsNotEmpty(findPathEvent.CalculatedPath);
            Assert.AreEqual(101, findPathEvent.CalculatedPath.Count);
        }
        public void TestCreateRunnerAndInvokeGameLoop()
        {
            var runner = GenericOpenHeroesRunner.CreateInstance(new ByteArrayMapLoader(ByteArrayHelper.CreateBase(128)));

            MapObjectFactory.AddArmy("Red", new Point(1, 1));
            MapObjectFactory.AddArmy("Blue", new Point(128, 128));
            AddBuildings();
            AddResources();
            AddObstacles();
            for (int i = 0; i < 1000; i++)
            {
                runner.Draw();
                runner.Update();
            }
        }