示例#1
0
    public override void _Ready()
    {
        player = GetNode(Game.PLAYER_PATH) as Player;

        worldGenerator = new WorldGenerator();
        worldGenerator.terrainModifiers.Add(new HillLandscapeTM(AVERAGE_HEIGHT, HEIGHT_SPREAD));
        worldGenerator.generators.Add(new IceGenerator(SEA_LEVEL));
        worldGenerator.generators.Add(new RockGenerator(RED_ROCK_LAYER_NUM));

        foreach (UniformRandomBlockGenerator g in fossilGenerators)
        {
            worldGenerator.generators.Add(g);
        }

        Base    b = GetNode(Game.PLANET_BASE_PATH) as Base;
        Vector2 horizontalBasePos = new Vector2(b.position.x, b.position.z);

        b.position = new IntVector3(b.position.x, worldGenerator.GetHeightAt(horizontalBasePos) - 1, b.position.z);
        b.InitGeneration();
        worldGenerator.terrainModifiers.Add(b.Smoothing);
        worldGenerator.generators.Add(b.Generator);

        Vector2 playerPos = new Vector2(player.Translation.x, player.Translation.z) / Block.SIZE;
        float   terrainGraphicalHeight = worldGenerator.GetHeightAt(playerPos) * Block.SIZE;

        player.Translation = new Vector3(playerPos.x, terrainGraphicalHeight + Player.INIT_REL_POS.y, playerPos.y);

        Plants p = GetNode(Game.PLANTS_PATH) as Plants;

        blockChageCallback = (oldBlock, newBlock, blockPos) => p.HandleBlockChange(oldBlock, newBlock, blockPos);
    }