Beispiel #1
0
        /// avoid map crash
        private HashSet <IPhysicEvent> calculateAvoidMapCrashEvents(Move currentMove)
        {
            HashSet <IPhysicEvent> pEvents = new HashSet <IPhysicEvent> {
                new MapCrashEvent()
            };

            if (null != moverSelfMapCrashEvent)
            {
                pEvents.Add(moverSelfMapCrashEvent.Copy());
            }

            if (null != passageLineEvent)
            {
                pEvents.Add(passageLineEvent.Copy());
            }

            PCar physicCar = new PCar(car, game);

            physicCar.setEnginePower(currentMove.EnginePower);
            physicCar.setWheelTurn(0);//currentMove.WheelTurn
            physicCar.setBrake(currentMove.IsBrake);

            PhysicEventsCalculator.calculateEvents(physicCar, new MoveWithOutChange(), pEvents, calculateAvoidSideCrashEventCheckEnd);

            return(pEvents);
        }
Beispiel #2
0
        /// Move to Additional Point
        private void moveToAdditionalPoint(double needAngle)
        {
            if (null == additionalPoints)
            {
                return;
            }

            int minTicks = int.MaxValue;

            foreach (Tuple <Vector, double> data in additionalPoints)
            {
                Vector point = data.Item1;

                IPhysicEvent           passageLineEvent = new PassageLineEvent(Vector.sincos(needAngle), point, 0);
                HashSet <IPhysicEvent> pEvents          = new HashSet <IPhysicEvent> {
                    new MapCrashEvent(),
                    passageLineEvent
                };

                if (null != moverSelfMapCrashEvent)
                {
                    pEvents.Add(moverSelfMapCrashEvent.Copy());
                }

                PCar physicCar = new PCar(car, game);
                PhysicEventsCalculator.calculateEvents(physicCar, new MoveToPoint(point, needAngle), pEvents, moveToAddPointEventCheckEnd);

                if (pEvents.ComeContaints(PhysicEventType.MapCrash) || pEvents.ComeContaints(PhysicEventType.ObjectsCrash) ||
                    !pEvents.ComeContaints(PhysicEventType.PassageLine))
                {
                    continue;
                }

                if (passageLineEvent.CarCome.Pos.GetDistanceTo(point) > data.Item2)
                {
                    continue;
                }

                if (passageLineEvent.TickCome < minTicks)
                {
                    needPos = point;
                }
            }
        }
Beispiel #3
0
        /// Turn
        private HashSet <IPhysicEvent> calculateTurnEvents(PCar iterCar, Vector needDirAngle)
        {
            HashSet <IPhysicEvent> pEvents = new HashSet <IPhysicEvent> {
                passageLineEvent.Copy(),
                                   outLineEvent.Copy(),
                                   angleReachEvent.Copy()
            };

            PCar physicCar = new PCar(iterCar);

            PhysicEventsCalculator.calculateEvents(physicCar, new MoveToAngleFunction(needDirAngle.Angle), pEvents, calculateTurnEventCheckEnd);

            if (!pEvents.Containts(PhysicEventType.SpeedReach))
            {
                pEvents.Add(new SpeedReachEvent());
            }

            return(pEvents);
        }
Beispiel #4
0
        private HashSet <IPhysicEvent> calculateTurnMapCrashEvents(PCar iterCar, Vector needDirAngle, bool isBrake)
        {
            HashSet <IPhysicEvent> pEvents = new HashSet <IPhysicEvent> {
                passageLineEvent.Copy()
            };

            if (null != moverSelfMapCrashEvent)
            {
                pEvents.Add(moverSelfMapCrashEvent.Copy());
            }

            PCar physicCar = new PCar(iterCar);

            useBrakeForTurn = isBrake;
            physicCar.setBrake(isBrake);
            PhysicEventsCalculator.calculateEvents(physicCar, new MoveToAngleFunction(needDirAngle.Angle), pEvents, calculateTurnMapCrashEventCheckEnd);

            return(pEvents);
        }
Beispiel #5
0
        ///Move
        private HashSet <IPhysicEvent> calculateMoveEvents(PCar iterCar)
        {
            HashSet <IPhysicEvent> pEvents = new HashSet <IPhysicEvent> {
                new MapCrashEvent()
            };

            if (null != moverSelfMapCrashEvent)
            {
                pEvents.Add(moverSelfMapCrashEvent.Copy());
            }

            PCar physicCar = new PCar(iterCar);

            /*if (null != needPos) {
             * PhysicEventsCalculator.calculateEvents(physicCar, new MoveToAngleFunction(Math.Atan2(dirMove.Y, dirMove.X)), pEvents, calculateMoveEventCheckEnd);
             * } else {*/
            PhysicEventsCalculator.calculateEvents(physicCar, new MoveToAngleFunction(car.GetAbsoluteAngleTo(defaultPos.X, defaultPos.Y)), pEvents, calculateMoveEventCheckEnd);
            //}

            return(pEvents);
        }