Exemplo n.º 1
0
 void OnDrawGizmos()
 {
     if (platform != null)
     {
         Vector3 start = gameObject.transform.parent.TransformPoint(platform.GetStartPoint());
         Vector3 end   = gameObject.transform.parent.TransformPoint(platform.GetEndPoint());
         Vector3 land  = gameObject.transform.parent.TransformPoint(platform.GetLandPoint());
         Vector3 jump  = gameObject.transform.parent.TransformPoint(platform.GetJumpPoint());
         Gizmos.DrawWireSphere(start, 0.1f);
         Gizmos.DrawWireSphere(end, 0.1f);
         Gizmos.DrawLine(land, land + Vector3.up * 2);
         Gizmos.DrawLine(jump, jump + Vector3.up * 2);
     }
 }
Exemplo n.º 2
0
    public IList <PlatformInfo> GeneratePlatforms(System.Random rand, PlatformInfo startPlatform, LevelGeneratorParams p)
    {
        Assert.IsTrue(p.maxEarlyLandMargin + p.maxLateJumpMargin <= 1, "Early landing and late jump margin overlapping");

        IList <PlatformInfo> platforms = new List <PlatformInfo>();

        ChooseActionPoints(rand, p, startPlatform);
        platforms.Add(startPlatform);

        float accumLevelTime = Vector2.Distance(startPlatform.GetStartPoint(), startPlatform.GetJumpPoint()) / p.runSpeed;

        while (accumLevelTime < p.levelDuration)
        {
            float progress = accumLevelTime / p.levelDuration;

            PlatformInfo plat = PlaceNextPlatform(rand, p, platforms[platforms.Count - 1], progress);
            ChooseActionPoints(rand, p, plat);
            platforms.Add(plat);

            MovementFunc jf = SetupJumpFunction(p, platforms, platforms[platforms.Count - 2], platforms[platforms.Count - 1]);

            accumLevelTime += Vector2.Distance(plat.GetLandPoint(), plat.GetJumpPoint()) / p.runSpeed + jf.duration;
        }

        platforms[platforms.Count - 1].jumpFunction = new MovementFunc(_ => Vector2.zero, 0);

        return(platforms);
    }