Exemplo n.º 1
0
    private (IList <Platform> platforms, MovementFunc guidePath) ConstructLevel(LevelGeneratorParams levelGenParams)
    {
        LevelGenerator levelGen = new LevelGenerator();

        // Generate platforms
        IList <PlatformInfo> platformInfos = levelGen.GeneratePlatforms(new System.Random(), PlatformInfo.FromLength(Vector2.zero, startPlatformLength), levelGenParams);
        IList <Platform>     platforms     = new List <Platform>(platformInfos.Count);

        PlacePlatforms(platforms, platformInfos);

        // Generate guide path
        float        jumpDuration  = platformInfos.Sum(p => p.GetJumpFunction().duration);
        float        runDuration   = levelGenParams.levelDuration - jumpDuration;
        float        runDistance   = platformInfos.Sum(p => Vector3.Distance(p.GetLandPoint(), p.GetJumpPoint()));
        float        guideRunSpeed = runDistance / runDuration;
        MovementFunc guidePath     = levelGen.GenerateGuidePath(platformInfos, guideRunSpeed);

        return(platforms, guidePath);
    }