public bool TryMoveForward() { LaneSection[] laneSections = lane.LaneSections; if (laneSectionIndex < laneSections.Length - 1) { if (laneSectionIndex >= 0) { LaneSection curSection = laneSections[laneSectionIndex]; if (!curSection.IsAllowedToPass()) { return(false); } curSection.RemoveAi(); } laneSectionIndex++; LaneSection newSection = laneSections[laneSectionIndex]; newSection.AddAi(); Vector3 destPos = newSection.GetAiPosition(); if (!SetDestination(destPos)) { Warp(destPos); } return(true); } return(false); }
internal static IEnumerable <Lane> GetLaneSectionSide(LaneSection laneSection, Side side) { var lanes = side == Side.Left ? laneSection.leftLanes : laneSection.rightLanes; if (lanes == null) { throw new InvalidOperationException("Attempted to fetch an un-initialized lanes list."); } return(lanes); }
// Selects all the lanes in a specified side up to the first stopAtLane encountered internal static IEnumerable <Lane> GetLaneSectionSideUpTo(LaneSection laneSection, Side side, LaneType stopAtLane) { var lanes = GetLaneSectionSide(laneSection, side); var numLanesToTake = 0; foreach (var lane in lanes) { if (lane.laneType == stopAtLane) { break; } numLanesToTake++; } return(lanes.Take(numLanesToTake)); }
public void Remove() { gameObject.SetActive(false); if (lane == null) { return; } lane.RemoveAiController(this); if (laneSectionIndex < 0) { return; } LaneSection curSection = lane.LaneSections[laneSectionIndex]; curSection.RemoveAi(); }