示例#1
0
        public void FindUrbanInformationListener(FindUrbanInformationEvent findUrbanInformationEvent)
        {
            findUrbanInformationEvent.Success = true;
            if (!_urbans.ContainsKey(findUrbanInformationEvent.Position))
            {
                return;
            }

            Entity urban = _urbans[findUrbanInformationEvent.Position];

            findUrbanInformationEvent.Urban = urban.GetComponent <Urban>();
        }
        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);
        }