示例#1
0
 public void Clear()
 {
     SpeedModifier   = 1.0f;
     Loft            = 0.0f;
     Strength        = 0.0f;
     CreatableId     = Guid.Empty;
     Pronoun         = PronounModifier.Pronouns.None;
     Reset           = ResetModifier.Resets.None;
     Color           = Classification.Colors.None;
     Pitch           = PitchModifier.PitchDirections.None;
     Turn            = TurnModifier.TurnDirections.None;
     Make            = MakeObjectModifier.MakeObjects.None;
     Item            = ObjectModifier.ModifierObjects.None;
     TaskId          = TaskModifier.TaskIds.SIZEOF;
     Direction       = Programming.Directions.None;
     Facial          = Face.FaceState.NotApplicable;
     ExpressEmitter  = ExpressModifier.Emitters.NotApplicable;
     Verb            = GameThing.Verbs.None;
     MissileBehavior = MissileChassis.BehaviorFlags.TerrainFollowing;
     Constraints     = ConstraintModifier.Constraints.None;
     SoundUpid       = String.Empty;
     Points          = 0;
     PlayerIndex     = GamePadSensor.PlayerId.Dynamic;
     ScoreBucket     = ScoreBucket.NotApplicable;
 }
示例#2
0
        }   // end of Setup()

        /// <summary>
        /// c'tor for use when targetting a point in space rather than an object.
        /// </summary>
        /// <param name="position"></param>
        /// <param name="targetPosition"></param>
        /// <param name="launcher"></param>
        /// <param name="verbPayload"></param>
        /// <param name="trackingMode"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        static public CruiseMissile Create(
            Vector3 position,                                       // Starting position.
            Vector3 targetPosition,                                 // Location we're trying to hit.
            GameActor launcher,                                     // Actor that launched this missile.
            float initialRotation,                                  //
            GameThing.Verbs verbPayload,
            int damage,
            MissileChassis.BehaviorFlags behavior,
            Classification.Colors color,
            float desiredSpeed,
            float missileLifetime,
            bool wantSmoke)
        {
            CruiseMissile cm = NextAvailable();

            cm.Setup(
                position,
                launcher,
                initialRotation,
                verbPayload,
                damage,
                behavior,
                color,
                desiredSpeed,
                wantSmoke);

            //Vector3 forward = Vector3.Normalize(targetPosition - position);
            //Vector3 side = Vector3.Cross(Vector3.UnitZ, forward);
            //if (side.LengthSquared() < 0.01f)
            //{
            //    side = Vector3.Cross(Vector3.UnitY, forward);
            //}
            //side.Normalize();
            //Vector3 up = Vector3.Normalize(Vector3.Cross(forward, side));
            //Matrix l2w = Matrix.Identity;
            //l2w.Right = forward;
            //l2w.Up = up;
            //l2w.Forward = side;
            //l2w.Translation = position;
            //cm.Movement.LocalMatrix = l2w;

            MissileChassis missileChassis = cm.Chassis as MissileChassis;

            Vector3 direction = targetPosition - launcher.WorldCollisionCenter;
            Vector3 delta     = Vector3.Normalize(direction);

            float desiredPitch = (float)(Math.Atan2(delta.Z, new Vector2(delta.X, delta.Y).Length()));

            missileChassis.PitchAngle = desiredPitch;

            missileChassis.DeathTime      = Time.GameTimeTotalSeconds + missileLifetime * 1.1f;
            missileChassis.TargetPosition = position + delta * desiredSpeed * missileLifetime * 10f;
            missileChassis.TargetObject   = null;

            return(cm);
        }   // end of CruiseMissile Create
示例#3
0
        }   // end of CruiseMissile Create

        /// <summary>
        /// c'tor to use when shooting at a particular object
        /// </summary>
        /// <param name="position"></param>
        /// <param name="targetPosition"></param>
        /// <param name="targetThing"></param>
        /// <param name="launcher"></param>
        /// <param name="verbPayload"></param>
        /// <param name="trackingMode"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        static public CruiseMissile Create(
            Vector3 position,                                       // Starting position.
            GameThing targetThing,                                  // Object we're trying to hit.
            GameActor launcher,                                     // Actor that launched this missile.
            float initialRotation,                                  //
            GameThing.Verbs verbPayload,
            int damage,
            MissileChassis.BehaviorFlags behavior,
            Classification.Colors color,
            float desiredSpeed,
            float missileLifetime,
            bool wantSmoke)
        {
            CruiseMissile cm = NextAvailable();

            cm.Setup(
                position,
                launcher,
                initialRotation,
                verbPayload,
                damage,
                behavior,
                color,
                desiredSpeed,
                wantSmoke);

            MissileChassis missileChassis = cm.Chassis as MissileChassis;

            // Set initial speed taking into account the velocity of the launcher.
            Vector3 missileVelocity = new Vector3((float)Math.Cos(initialRotation), (float)Math.Sin(initialRotation), 0);
            float   dot             = Vector3.Dot(missileVelocity, launcher.Movement.Velocity);

            missileChassis.Speed = Math.Max(desiredSpeed, dot);

            missileChassis.DeathTime      = Time.GameTimeTotalSeconds + missileLifetime;
            missileChassis.TargetPosition = targetThing.WorldCollisionCenter;
            missileChassis.TargetObject   = targetThing;

            return(cm);
        }   // end of CruiseMissile Create
示例#4
0
        private void Setup(Vector3 position,                      // Starting position.
                           GameActor launcher,                    // Actor that launched this missile.
                           float initialRotation,
                           GameThing.Verbs verbPayload,
                           int damage,
                           MissileChassis.BehaviorFlags behavior,
                           Classification.Colors color,
                           float desiredSpeed,
                           bool wantSmoke)
        {
            smokeEnabled = wantSmoke;

            // Or, we could change the sound to something other than the rumble.
            if (!smokeEnabled)
            {
                XmlActorParams.IdleSoundName = null;
            }

            MissileChassis missileChassis = Chassis as MissileChassis;

            missileChassis.Missile      = this;
            missileChassis.Launcher     = launcher;
            missileChassis.VerbPayload  = verbPayload;
            missileChassis.Damage       = damage;
            missileChassis.Behavior     = behavior;
            missileChassis.Rotation     = initialRotation;
            missileChassis.DesiredSpeed = desiredSpeed;

            Mass = 10.0f;

            Movement.Position = position;

            // Calculate initial missile speed.
            float   initialSpeed = desiredSpeed;
            Vector3 gunVel       = launcher.Movement.Velocity;
            Vector3 shotVel      = new Vector3((float)Math.Cos(initialRotation), (float)Math.Sin(initialRotation), 0f) * initialSpeed;

            if (gunVel.X != 0 || gunVel.Y != 0)
            {
                // Add in some of the launcher's velocity.  Missile will
                // gradually adjust its speed to its desired velocity.
                Vector3 gunVelNorm  = Vector3.Normalize(gunVel);
                Vector3 shotVelNorm = Vector3.Normalize(shotVel);
                float   dot         = Vector3.Dot(gunVelNorm, shotVelNorm);
                Vector3 proj        = gunVel * dot;
                initialSpeed = proj.Length() * MyMath.Direction(dot);
            }
            // Don't allow initial speed to be negative because it looks odd.
            missileChassis.Speed = Math.Max(desiredSpeed, initialSpeed);

            classification.Color = color;

            InitSmokeEmitter(Classification.ColorVector4(classification.Color));

            InitMuzzleFlash(Classification.ColorVector4(classification.Color), 2.0f, 8.0f);

            missileChassis.IgnoreGlassWalls = true;
            missileChassis.Feelers.Clear();     // Don't want missiles to hit glass walls.

            // Register for collisions.
            //InGame.inGame.RegisterCollide(this);
        }   // end of Setup()