Ejemplo n.º 1
0
 private void Start()
 {
     trackSection = sectionBuilder.BuildSection();
     GetComponent <LeanGameObjectPool>().Prefab = trackSection.gameObject;
     lastSection = AddSection(transform);
     for (var i = 1; i < lookAhead; i++)
     {
         lastSection = AddSection(lastSection.EndPoint);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     Places obstacles on the specified track section based on the registered obstaclePlacer service.
 /// </summary>
 /// <param name="section">The TrackSection to place obstacles on</param>
 public void PlaceObstacles(TrackSection section)
 {
     if (emptyInitialSections > 0)
     {
         emptyInitialSections--;
     }
     else
     {
         obstaclePlacer.PlaceObstacles(section);
     }
 }
Ejemplo n.º 3
0
        public override void PlaceObstacles(TrackSection target)
        {
            var lanes    = target.GetLanes();
            var position = new Vector3(0, .5f, 0);

            for (var i = 0; i < lanes.Count; i++)
            {
                var lane = lanes[i];
                if (i % 2 == (adjusted ? 1 : 0))
                {
                    LeanPool.Spawn(obstacle, position, Quaternion.identity, lane, false);
                }
            }

            adjusted = !adjusted;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Loads layer 0 of obstacle data for the target section. The passed layer will be cached so that the next layer can
        ///     be loaded on subsequent calls after loading layer 0 for the subsequent parameter.
        /// </summary>
        /// <param name="target"></param>
        public override void PlaceObstacles(TrackSection target)
        {
            var lanes = target.GetLanes();


            AddLayer0Data(lanes);
            AddLayer1Data(lanes);
            AddLayer2Data(lanes);

            var lastLayerCount = layer2.Count;

            for (var lane = 0; lane < lanes.Count; lane++)
            {
                var existenceLayer = layer0[lastLayerCount - 1][lane];
                var neighborLayer  = layer1[lastLayerCount - 1][lane];
                var nudgeLayer     = layer2[lastLayerCount - 1][lane];
                if (existenceLayer.Exists && neighborLayer.Exists && nudgeLayer.Nudge < maximumNudgeDistance)
                {
                    var position = new Vector3(0, .5f, -(laneLength / 2 - obstacleLength / 2) + nudgeLayer.Nudge);
                    LeanPool.Spawn(obstacle, position, Quaternion.identity, existenceLayer.Track, false);
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     Connects a new section of track to the end of the last added section.
 /// </summary>
 public void AddSection()
 {
     lastSection = AddSection(lastSection.EndPoint);
 }
Ejemplo n.º 6
0
 public abstract void PlaceObstacles(TrackSection target);