private void ArrowShoot() { LaneSelector laneSelector = FindObjectOfType <LaneSelector>(); if (Input.GetKeyDown(KeyCode.LeftArrow)) { GameObject laser = Instantiate(blueLaserPrefab, laneSelector.GetBottomPosition(), Quaternion.identity) as GameObject; } if (Input.GetKeyDown(KeyCode.RightArrow)) { GameObject laser = Instantiate(redLaserPrefab, laneSelector.GetBottomPosition(), Quaternion.identity) as GameObject; } }
// Start method is here to assign the target desintation of the gem and have it change for the // lifetime if the instance of this laser void Start() { LaneSelector laneSelector = FindObjectOfType <LaneSelector>(); if (laneSelector.GetBottomPosition() == centreBottomCoords) { this.targetPosition = centreTopCoords; } else if (laneSelector.GetBottomPosition() == leftBottomCoords) { this.targetPosition = leftTopCoords; } else if (laneSelector.GetBottomPosition() == rightBottomCoords) { this.targetPosition = rightTopCoords; } }
// when creating this function need to pass in the class and assign it to the instance at the start of the function, this is where unity asks for the script // to be passed in at the inspector public void RedShot(LaneSelector laneSelector) { GameObject laser = Instantiate(laserPrefab, laneSelector.GetBottomPosition(), Quaternion.identity) as GameObject; }
public static decimal PassedLength(this IEnumerable <IReadOnlyRacePassing> passings, PresentationSource presentationSource, DateTime when, IDistanceLaneLocations laneLocations, IReadOnlyCollection <IVenueSegment> segments, LaneSelector laneSelector = null) { laneSelector = laneSelector ?? ((s, l) => 0); var lap = 0; int lane; IVenueSegment segment; var from = laneLocations.Start; var length = laneLocations.StartOffset; var passedLapSegments = new List <IVenueSegment>(); foreach (var passing in (from p in passings where !p.Flags.HasFlag(RaceEventFlags.Deleted) && p.PresentationSource == presentationSource && p.When <= when orderby p.When select p).SkipWhile(p => p.Where == laneLocations.Start)) { if (!segments.Any(s => s.To == passing.Where)) { continue; } do { lane = laneSelector(passedLapSegments, lap); segment = segments.FirstOrDefault(s => s.Lane == lane && s.From == from); if (segment == null) { return(0); } if (laneLocations.Finishes.Contains(segment.To)) { passedLapSegments.Clear(); lap++; } passedLapSegments.Add(segment); length += segment.Length; from = segment.To; } while (segment.To != passing.Where); } return(length); }