Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        // 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));
        }
Esempio n. 4
0
        public void Remove()
        {
            gameObject.SetActive(false);

            if (lane == null)
            {
                return;
            }

            lane.RemoveAiController(this);

            if (laneSectionIndex < 0)
            {
                return;
            }

            LaneSection curSection = lane.LaneSections[laneSectionIndex];

            curSection.RemoveAi();
        }