Beispiel #1
0
        public void GetNewCameraMissile(Missile Missile)
        {
            NewPosition = Missile.position;
            NewPosition.Y += 10;

            //NewLeftRightRot = (Player.turretRotationValue - MathHelper.ToRadians(90));

            //NewUpDownRot -= (0.2f) * (0.0166f);
            NewUpDownRot -= (0.00167f / Player.Power);
            NewUpDownRot = MathHelper.Clamp(NewUpDownRot, -0.9f, 0.9f);
            Vector3 forwardVec = Matrix.CreateFromYawPitchRoll(NewLeftRightRot, 0f, 0f).Backward;
            forwardVec.Normalize();
            NewPosition += forwardVec * 20;
        }
Beispiel #2
0
        Vector3 GetMissileMuzzleVelocity(Missile missile)
        {
            Matrix rotationMatrix =
                Matrix.CreateFromYawPitchRoll(
                missile.rotation.Y,
                missile.rotation.X,
                missile.rotation.Z);

            return Vector3.Normalize(
                Vector3.Transform(Vector3.Backward,
                rotationMatrix)) * missilePower;
        }
Beispiel #3
0
 Vector3 GetMissileMuzzlePosition(Missile missile)
 {
     return position +
         new Vector3(0.05f, 4 + cannonRotationValue, 0) +  // variable offset.  should change based on scale
         (Vector3.Normalize(
         GetMissileMuzzleVelocity(missile)) *
         launcherHeadMuzzleOffset);
 }
        void FireBullet()
        {
            float timeNow = (float)gameTime.TotalGameTime.TotalMilliseconds / 1000.0f;
            float timeDiff = timeNow - shotTime;

            if ((MissileRemain > 0) && (timeDiff > ReloadTimeSec))
            {
                shotTime = timeNow;
                //MissileRemain--;

                Missile missile = new Missile(parentGame, rocketModel, rocketTextures, NormalDrawing, this);
                missile.position = new Vector3(
                    Player.position.X,
                    Player.position.Y,
                    Player.position.Z);
                Vector3 forwardVec = Matrix.CreateFromYawPitchRoll(
                    Player.turretRotationValue - MathHelper.ToRadians(90f),
                    0f,
                    0f).Forward;
                forwardVec.Normalize();

                missile.position += forwardVec * 11;

                missile.scale = 1;

                float DECLINATION = -Player.cannonRotationValue; // stays in radians

                // sin in radians                       // width                    // height
                missile.position.Y = (float)(Math.Sin(DECLINATION) * 13.3) + Player.position.Y + 4;

                float ROTATION = Player.turretRotationValue - MathHelper.ToRadians(90f);
                Matrix Orientation = Matrix.CreateFromYawPitchRoll(ROTATION, DECLINATION, 0f);
                //LevelVars.Player.FacingDirection
                //DECLINATION
                missile.SetBody(Orientation);

                Vector3 force = Orientation.Forward;
                force.Normalize();
                Vector3 angle = Orientation.Left;
                angle.Normalize();

                float power = 120f * Player.Power;
                missile.Body.ApplyWorldImpulse(force * power);
                missile.Body.AngularVelocity = (angle * MathHelper.Clamp((0.8f - Player.Power), 0.20f, 0.6f));

                missile.rgob.limbs[0].PhysicsBody.ApplyWorldImpulse(force * power * 5);
                missile.rgob.limbs[0].PhysicsBody.AngularVelocity = (angle * MathHelper.Clamp((0.8f - Player.Power), 0.20f, 0.6f) * 1);

                //missile.Body.AngularVelocity += (force * 1.5f);

                missile.Skin.callbackFn += new CollisionCallbackFn(MissileColllisionFunction);

                BulletList.Add(missile);

                FollowCam.Following = true;
                FollowCam.myMissile = missile;
                FollowCam.NewUpDownRot = missile.rotation.Y;
                FollowCam.NewLeftRightRot = (Player.turretRotationValue - MathHelper.ToRadians(90));

                cue = parentGame.soundBank.GetCue("fire");
                AudioEmitter emmit = new AudioEmitter();
                emmit.Position = Player.position;
                cue.Apply3D(listener, emmit);
                cue.Play();

                Vector3 effectPos = (missile.position - forwardVec * 2);
                for (int i = 0; i < 25; ++i)
                    NormalDrawing.shotSmokeParticles.AddParticle(effectPos, new Vector3(0, 0, 0));

                for (int i = 0; i < 25; ++i)
                    NormalDrawing.shotExplosionParticles.AddParticle(effectPos, new Vector3(0, 0, 0));
            }
        }
        void CreateDepotPieces(Building BUILD, Missile MISS, float Force, float Radius)
        {
            // x y z
            CreatePiece(BUILD, -5, 3, 7, DepotPiece1, DepotPiece1Textures,
                MISS.position, Force, Radius,
                4, 4, 1);

            CreatePiece(BUILD, 2, 2, -3, DepotPiece2, DepotPiece2Textures,
                MISS.position, Force, Radius,
                3, 3, 1);

            CreatePiece(BUILD, -3, 5, -7, DepotPiece3, DepotPiece3Textures,
                MISS.position, Force, Radius,
                1, 1, 1);

            CreatePiece(BUILD, -2, 5, -5, DepotPiece4, DepotPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, 3, 5, -7, DepotPiece3, DepotPiece3Textures,
                MISS.position, Force, Radius,
                1, 1, 1);

            CreatePiece(BUILD, 2, 5, -5, DepotPiece4, DepotPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, -10, 5, 2, DepotPiece3, DepotPiece3Textures,
                MISS.position, Force, Radius,
                1, 1, 1);

            CreatePiece(BUILD, 10, 5, 3, DepotPiece4, DepotPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);
        }
        void CreateBunkerPieces(Building BUILD, Missile MISS, float Force, float Radius)
        {
            // x y z
            CreatePiece(BUILD, 3, 13, -3, BunkerPiece1, BunkerPiece1Textures,
                MISS.position, Force, Radius,
                4, 4, 4);

            CreatePiece(BUILD, -3, 3, -3, BunkerPiece2, BunkerPiece2Textures,
                MISS.position, Force, Radius,
                4, 4, 4);

            CreatePiece(BUILD, -3, 9, 3, BunkerPiece3, BunkerPiece3Textures,
                MISS.position, Force, Radius,
                4, 4, 7);

            CreatePiece(BUILD, -2, 7, 1, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, 2, 14, 1, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, 2, 5, 2, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);

            CreatePiece(BUILD, -5, 15, -2, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
               2, 2, 2);

            CreatePiece(BUILD, -3, 9, 2, BunkerPiece4, BunkerPiece4Textures,
                MISS.position, Force, Radius,
                2, 2, 2);
        }