Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        var mapToWorldMapper = new MapToWorldMapper(
            minWorldY: MapMinY,
            maxWorldY: MapMaxY,
            tileRadius: MapTileRadius
            );
        var heightMap = new HeightMap(
            colors: HeightMap.GetPixels(),
            width: (uint)HeightMap.width,
            height: (uint)HeightMap.height
            );
        var mapGenerator = new MapGenerator(heightMap);

        this.Game = new Game(
            mapGenerator: mapGenerator,
            spawnMapTile: SpawnMapTile,
            mapToWorldMapper: mapToWorldMapper,
            initialMoney: InitialMoney,
            incomePerEconomyTick: IncomePerEconomyTick,
            economyTickInterval: EconomyTickInterval
            );
        SetCameraLimits(this.Game.WorldSize);

        GameTimeTimer              = new Timer(tickInterval: 1.0f); // tick each second
        GameTimeTimer.TimerTicked += (sender, args) => Game.GameTimeTick();
    }
Exemplo n.º 2
0
        public void TestGetWorldSize(GetWorldSizeTestCase testCase)
        {
            var mapper = new MapToWorldMapper(
                minWorldY: testCase.MinWorldY,
                maxWorldY: testCase.MaxWorldY,
                tileRadius: testCase.TileRadius
                );

            var worldSize = mapper.GetWorldSize(
                mapWidth: testCase.MapWidth,
                mapHeight: testCase.MapHeight
                );

            Assert.That(
                worldSize,
                Is.EqualTo(testCase.ExpectedWorldSize)
                );
        }
Exemplo n.º 3
0
        public void TestGetWorldPosition(GetWorldPositionTestCase testCase)
        {
            var mapper = new MapToWorldMapper(
                minWorldY: testCase.MinWorldY,
                maxWorldY: testCase.MaxWorldY,
                tileRadius: testCase.TileRadius
                );

            var worldPosition = mapper.GetWorldPosition(
                mapX: testCase.MapX,
                mapY: testCase.MapY,
                tile: testCase.Tile
                );

            Assert.That(
                worldPosition,
                Is.EqualTo(testCase.ExpectedWorldPosition)
                );
        }