Example #1
0
        private bool hasReserveTicks(PCar iterCar, Vector needDirAngle)
        {
            MoveToPoint mover = null;

            if (null != needPos)
            {
                mover = new MoveToPoint(needPos, needDirAngle.Angle);
            }
            else
            {
                mover = new MoveToPoint(defaultPos);
            }

            PCar car = new PCar(iterCar);

            for (int tick = 0; tick < 5; tick++)
            {
                HashSet <IPhysicEvent> events = calculateTurnEvents(car, needDirAngle);

                if (events.ComeContaints(PhysicEventType.OutLine))
                {
                    return(false);
                }

                mover.Iteration(car, 1);
            }

            return(true);
        }
Example #2
0
        private int moveOnDistance(PCar car, Vector needDirAngle, double distance)
        {
            MoveToPoint mover = null;

            if (null != needPos)
            {
                mover = new MoveToPoint(needPos, needDirAngle.Angle);
            }
            else
            {
                mover = new MoveToPoint(defaultPos);
            }

            double speedL = car.Speed.Length;

            int addTick = 1;

            if (speedL > 1.0e-3)
            {
                addTick = (int)Math.Max(1, Math.Min(0.5 * distance / speedL, 1024));
            }
            else
            {
                addTick = 2;
            }

            mover.Iteration(car, addTick);
            return(addTick);
        }
Example #3
0
        private bool isMovedOutFromLine(PCar iterCar, Vector needDirAngle)
        {
            if (outLineEvent.OutLine(iterCar))
            {
                return(false);
            }

            MoveToPoint mover = null;

            if (null != needPos)
            {
                mover = new MoveToPoint(needPos, needDirAngle.Angle);
            }
            else
            {
                mover = new MoveToPoint(defaultPos);
            }

            PCar carToAngle = new PCar(iterCar);
            MoveToAngleFunction moveToAngle = new MoveToAngleFunction(needDirAngle.Angle);
            int ticksToAngle = 0;

            for (; ticksToAngle < 100; ticksToAngle++)
            {
                moveToAngle.Iteration(carToAngle, 1);
                if (angleReachEvent.Check(carToAngle))
                {
                    break;
                }
            }

            PCar car = new PCar(iterCar);

            mover.Iteration(car, ticksToAngle);

            return(outLineEvent.OutLine(car));
        }