Esempio n. 1
0
        private static VehicleState GetRandomNextState(VehicleState fromState, VehiclePrototype prototype, Random randomizer, float deltaTime)
        {
            VehicleDriveControls randomControl    = GetRandomControl(fromState, prototype, randomizer, deltaTime);
            DynamicTransform2    resultingDynamic = prototype.VehicleDrive(fromState.DynamicTransform, randomControl, deltaTime);

            return(new VehicleState(resultingDynamic, randomControl));
        }
Esempio n. 2
0
        public void ResetAndSetup(SimulationState currentSimState)
        {
            mTargetRootState = currentSimState.GetVehicle(mTargetID);
            mEnemyProjectiles.Clear();

            VehiclePrototype controlledPrototype = mSimData.GetVehiclePrototype(mControlledID);
            VehicleState     controlledState     = currentSimState.GetVehicle(mControlledID);

            var projectiles = currentSimState.GetProjectiles(mTargetID);

            //Cache the projectile states for next frame, but onyl those with a chance of hiting
            foreach (var projectile in projectiles)
            {
                Vector2 relativePosition = controlledState.DynamicTransform.Position - projectile.Position;
                Vector2 relativeVelocity = controlledState.DynamicTransform.Velocity - projectile.Velocity;
                if (Vector2.Dot(relativePosition, relativeVelocity) < 0f)
                {
                    if (!SimulationProcessor.ProjectileHitsVehicle(controlledState.DynamicTransform, controlledPrototype, projectile, mDeltaTime))
                    {
                        DynamicPosition2 updatedProjectile = new DynamicPosition2(projectile.Position + mDeltaTime * projectile.Velocity, projectile.Velocity);
                        mEnemyProjectiles.Add(projectile);
                    }
                }
            }


            mOptions.Clear();
            controlledPrototype.ControlConfig.GetPossibleControlChanges(controlledState.ControlState, mDeltaTime, mControlOptionCache);
            foreach (var driveControlOption in mControlOptionCache)
            {
                VehicleControls   controlOption         = new VehicleControls(driveControlOption);
                DynamicTransform2 resultingDynamicState = controlledPrototype.VehicleDrive(controlledState.DynamicTransform, driveControlOption, mDeltaTime);
                VehicleState      resultingVehicleState = new VehicleState(resultingDynamicState, driveControlOption); //We should not care for the gun state... I thnk...

                Option option = new Option(controlOption, resultingVehicleState);
                mOptions.Add(option);
            }
            mControlOptionCache.Clear();
            mIterations = 0;
        }