Пример #1
0
        private void ConfigureTileColors(WorldRules worldConfig)
        {
            var terrains = worldConfig.Terrains;
            var zones    = worldConfig.Zones;

            TypedComponents <Color> terrainColor = new TypedComponents <Color>(TerrainLayer.Component, () => this.ErrorTile);

            terrainColor[terrains[Terrains.Land]]  = this.LandTile;
            terrainColor[terrains[Terrains.Water]] = this.WaterTile;
            terrains.Extend(terrainColor);

            TypedComponents <Color?> zoneColor = new TypedComponents <Color?>(ZoneLayer.Component, () => null);

            zoneColor[zones[Zones.Commercial]]  = this.CommercialTile;
            zoneColor[zones[Zones.Farmland]]    = this.FarmlandTile;
            zoneColor[zones[Zones.Residential]] = this.ResidentialTile;
            zoneColor[zones[Zones.Road]]        = this.RoadTile;
            zones.Extend(zoneColor);

            TypedComponents <BuildingColor> tileColor = new TypedComponents <BuildingColor>(BuildingLayer.Component, () => (v) => this.ErrorTile);

            tileColor[zones[Zones.Farmland]]    = new BuildingColor((v) => this.FieldTile);
            tileColor[zones[Zones.Commercial]]  = new BuildingColor((v) => this.Building1Tile);
            tileColor[zones[Zones.Residential]] = new BuildingColor((v) => this.Building2Tile);
            zones.Extend(tileColor);
        }
        public void OccupiedNode_NoStatus_Occupied()
        {
            NodeState state = NodeState.Occupied;

            NodeState testResult = WorldRules.GetNewState(state, "");

            Assert.AreEqual(NodeState.Occupied, testResult);
        }
        public void OccupiedNode_EntityMoved_Empty()
        {
            NodeState state = NodeState.Occupied;

            NodeState testResult = WorldRules.GetNewState(state, "empty");

            Assert.AreEqual(NodeState.Empty, testResult);
        }
        public void EmptyNode_NoArrival_Empty()
        {
            NodeState state = NodeState.Empty;

            NodeState testResult = WorldRules.GetNewState(state, "empty");

            Assert.AreEqual(NodeState.Empty, testResult);
        }
        public void EmptyNode_EntityArrived_Occupied()
        {
            NodeState state = NodeState.Empty;

            NodeState testResult = WorldRules.GetNewState(state, "occupied");

            Assert.AreEqual(NodeState.Occupied, testResult);
        }
Пример #6
0
        public void ShouldDecideToKillTwoCellsWhenWorldHasHorizontalPattern()
        {
            var life      = new World(5, 5);
            var cellOne   = new Cell(1, 1);
            var cellTwo   = new Cell(1, 2);
            var cellThree = new Cell(1, 3);

            life.InsertCell(cellOne);
            life.InsertCell(cellTwo);
            life.InsertCell(cellThree);

            var rules = new WorldRules();

            rules.DecideDead(life);

            Assert.Equal(2, rules._cellsToBeDestroyed.Count);
        }
Пример #7
0
        public void ShouldPopulateTwoCellsWhenWorldHasHorizontalPattern()
        {
            var life      = new World(5, 5);
            var cellOne   = new Cell(1, 1);
            var cellTwo   = new Cell(1, 2);
            var cellThree = new Cell(1, 3);

            life.InsertCell(cellOne);
            life.InsertCell(cellTwo);
            life.InsertCell(cellThree);

            var rules = new WorldRules();

            rules.DecideNewLife(life);
            rules.Populate(life);

            Assert.Equal(5, life.Cells.Count);
        }
Пример #8
0
        public void ShouldDeleteTwoCellsWhenWorldHasHorizontalPattern()
        {
            var life      = new World(5, 5);
            var cellOne   = new Cell(1, 1);
            var cellTwo   = new Cell(1, 2);
            var cellThree = new Cell(1, 3);

            life.InsertCell(cellOne);
            life.InsertCell(cellTwo);
            life.InsertCell(cellThree);

            var rules = new WorldRules();

            rules.DecideDead(life);
            rules.Eradicate(life);

            Assert.Single(life.Cells);
        }