Exemplo n.º 1
0
        public void CreateUrbanListener(CreateUrbanEvent createUrbanEvent)
        {
            Entity resource = entityWorld.CreateEntityFromTemplate("Urban",
                                                                   createUrbanEvent.Position, createUrbanEvent.Population, createUrbanEvent.BirdsRate);

            _urbans[createUrbanEvent.Position] = resource;

            Structure structure = new Structure(new StructureDefinition("City", new Point(1, 1)));
            AddStructureOnWorldMapEvent addStructureOnWorldMap = new AddStructureOnWorldMapEvent(structure, createUrbanEvent.Position);

            _eventBus.Post(addStructureOnWorldMap);
        }
Exemplo n.º 2
0
        public void TestBaseFunctionality()
        {
            Fraction testFraction = new Fraction("test");
            Point testPosition = new Point(4, 4);

            CreateUrbanEvent createUrbanEvent = new CreateUrbanEvent(testPosition, 1000, 0.1f);
            JEventBus.GetDefault().Post(createUrbanEvent);

            _runner.Update();
            FindUrbanInformationEvent findUrbanInformationEvent = new FindUrbanInformationEvent(testPosition);
            JEventBus.GetDefault().Post(findUrbanInformationEvent);
            Assert.IsTrue(findUrbanInformationEvent.Success);
            Assert.AreEqual(1101, findUrbanInformationEvent.Urban.Population);

            _runner.Update();
            findUrbanInformationEvent = new FindUrbanInformationEvent(testPosition);
            JEventBus.GetDefault().Post(findUrbanInformationEvent);
            Assert.IsTrue(findUrbanInformationEvent.Success);
            Assert.AreEqual(1212, findUrbanInformationEvent.Urban.Population);
        }