Example #1
0
        private void Retry()
        {
            m_kAirplane.Dispose();
            _soundBank.PlayCue("Ship_Death");
            m_kAirplane = new Airplane(ScreenManager.Game);

            ScreenManager.Game.Components.Add(m_kAirplane);
            //_soundBank.PlayCue("Ship_Spawn");

            m_kAirplane.WorldPosition = new Vector3(8, 1, -3);
            m_kAirplane.PitchAngle = launchPitch;
            m_kAirplane.YawAngle = launchYaw;
            m_kAirplane.WorldRotation = Quaternion.Concatenate(Quaternion.CreateFromAxisAngle(Vector3.UnitY, m_kAirplane.YawAngle), Quaternion.CreateFromAxisAngle(Vector3.Normalize(m_kAirplane.mWorldTransform.Right), m_kAirplane.PitchAngle));

            launchPitch = 0;
            launchYaw = 0;

            //ScreenManager.Game.Components.Remove(camera);
            //camera = new CameraComponent(ScreenManager.Game, m_kAirplane);
            m_kAirplane.Camera = camera;
            camera.Airplane = m_kAirplane;
            //ScreenManager.Game.Components.Add(camera);
            camera.Reset();

            goalSoundPlayed = false;
        }
Example #2
0
        public CameraComponent(Game game, Airplane plane)
            : base(game)
        {
            airplane = plane;
            viewport = Game.GraphicsDevice.Viewport;
            aspectRatio = (float)viewport.Width / (float)viewport.Height;
            //cameraPosition = new Vector3(8.0f, 1.0f, -1.5f);
            //cameraLookat = Vector3.Add(airplane.WorldPosition, CITY_ANGLE_OFFSET);
            AIRPLANE_START_POS = airplane.WorldPosition;
            cameraLookat = airplane.WorldPosition;
            cameraPosition = Vector3.Add(cameraLookat, FOLLOW_CAM_OFFSET);
            cameraRotation = Matrix.Identity;

            CalculateMatrices(cameraPosition, cameraLookat, Vector3.UnitY);

            cameraReference = -Vector3.UnitZ;
            transformedReference = -Vector3.UnitZ;
            transformedUpVector = Vector3.UnitY;
            transformedRotateAbout = Vector3.UnitX;

            //System.Diagnostics.Debug.WriteLine("With plane. cameraLookat: " + cameraLookat + ", cameraPosition: " + cameraPosition + ", planePos: " + airplane.WorldPosition);
        }
Example #3
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            gameFont = content.Load<SpriteFont>("gamefont");

            _audioEngine = new AudioEngine("Content/Sounds.xgs");
            _waveBank = new WaveBank(_audioEngine, "Content/XNAsteroids Waves.xwb");
            _soundBank = new SoundBank(_audioEngine, "Content/XNAsteroids Cues.xsb");

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            //Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            //level building
            effect = content.Load<Effect>("effects");
            sceneryTexture = content.Load<Texture2D>("texturemap");
            LoadFloorPlan();
            SetUpVertices();
            SetUpBoundingBoxes();

            m_kAirplane = new Airplane(ScreenManager.Game);

            camera = new CameraComponent(ScreenManager.Game, m_kAirplane);
            m_kAirplane.Camera = camera;

            ScreenManager.Game.Components.Add(camera);

            ScreenManager.Game.Components.Add(m_kAirplane);
            //_soundBank.PlayCue("Ship_Spawn");

            m_kAirplane.WorldPosition = new Vector3(8, 1, -3);

            m_kGoal = new Goal(ScreenManager.Game);
            m_kGoal.Camera = camera;
            ScreenManager.Game.Components.Add(m_kGoal);
            m_kGoal.WorldPosition = new Vector3(5.5f,2.0f,-10.5f);
            SetUpGoalBoundingBox();
            goalSoundPlayed = false;

            m_kBonus = new Bonus(ScreenManager.Game);
            m_kBonus.Camera = camera;
            ScreenManager.Game.Components.Add(m_kBonus);
            m_kBonus.WorldPosition = new Vector3(8.5f,2.5f,-6.5f);

            ScreenManager.Game.IsMouseVisible = true;

            basicEffect = new BasicEffect(ScreenManager.GraphicsDevice);

            //m_kAirplane.WorldPosition = new Vector3(8, 0, -7);
            //camera.View = Matrix.CreateLookAt(new Vector3(3, 5, 2), new Vector3(2, 0, -1), new Vector3(0, 1, 0));
        }
Example #4
0
        private void Retry()
        {
            Quaternion oldRot = Quaternion.Concatenate(Quaternion.CreateFromAxisAngle(Vector3.UnitX, launchPitch), Quaternion.CreateFromAxisAngle(Vector3.UnitY, launchYaw)); ;
            m_kAirplane.Dispose();
            _soundBank.PlayCue("Ship_Death");
            if (m_kAirplane.GetType().Equals(typeof(Airplane)))
            {
                m_kAirplane = new Airplane(ScreenManager.Game);
            }
            else if (m_kAirplane.GetType().Equals(typeof(Airplane2)))
            {
                m_kAirplane = new Airplane2(ScreenManager.Game);
            }

            m_kAirplane.Camera = camera;
            m_kAirplane.WorldRotation = oldRot;

            //Remove points from bonus items (cause you died)
            //check collisions with bonus items
            foreach (KeyValuePair<Bonus, bool> entry in bonusItems)
            {
                if (entry.Value)
                {
                    score -= 1000;
                    entry.Key.Visible = true;
                    bonusItems[entry.Key] = false;
                }
            }

            ScreenManager.Game.Components.Add(m_kAirplane);
            GameObjects.Add(m_kAirplane);
            //_soundBank.PlayCue("Ship_Spawn");

            m_kAirplane.WorldPosition = planePosition;
            m_kAirplane.PitchAngle = launchPitch;
            m_kAirplane.YawAngle = launchYaw;

            launchPitch = 0;
            launchYaw = 0;

            //ScreenManager.Game.Components.Remove(camera);
            //camera = new CameraComponent(ScreenManager.Game, m_kAirplane);
            m_kAirplane.Camera = camera;
            camera.Airplane = m_kAirplane;
            //ScreenManager.Game.Components.Add(camera);
            camera.Reset();

            goalSoundPlayed = false;
        }
Example #5
0
        public void swapAirplane()
        {
            Quaternion oldRot = m_kAirplane.WorldRotation;
            m_kAirplane.Dispose();

            if (m_kAirplane.GetType().Equals(typeof(Airplane)))
            {
                System.Diagnostics.Debug.WriteLine("Swapping to airplane2");
                m_kAirplane = new Airplane2(ScreenManager.Game);
            }
            else if (m_kAirplane.GetType().Equals(typeof(Airplane2)))
            {
                System.Diagnostics.Debug.WriteLine("Swapping to airplane");
                m_kAirplane = new Airplane(ScreenManager.Game);
            }

            m_kAirplane.Camera = camera;
            m_kAirplane.PitchAngle = launchPitch;
            m_kAirplane.YawAngle = launchYaw;
            m_kAirplane.WorldRotation = oldRot;
            launchPitch = 0;
            launchYaw = 0;

            ScreenManager.Game.Components.Add(m_kAirplane);
            GameObjects.Add(m_kAirplane);
        }
Example #6
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            gameFont = content.Load<SpriteFont>("gamefont");

            _audioEngine = new AudioEngine("Content/Sounds.xgs");
            _waveBank = new WaveBank(_audioEngine, "Content/XNAsteroids Waves.xwb");
            _soundBank = new SoundBank(_audioEngine, "Content/XNAsteroids Cues.xsb");

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            //Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            //level building
            effect = content.Load<Effect>("effects");
            sceneryTexture = content.Load<Texture2D>("texturemap");
            LoadFloorPlan();
            SetUpVertices();
            SetUpBoundingBoxes();

            m_kAirplane = new Airplane(ScreenManager.Game);
            m_kGoal = new Goal(ScreenManager.Game);

            //load object data into map
            using (StreamReader streamReader = new StreamReader(dataString))
            {
                string line = streamReader.ReadLine();
                string[] numbers = line.Split(',');
                m_kAirplane.WorldPosition = new Vector3(float.Parse(numbers[0]), float.Parse(numbers[1]), float.Parse(numbers[2]));
                planePosition = m_kAirplane.WorldPosition;
                line = streamReader.ReadLine();
                string[] numbers2 = line.Split(',');
                m_kGoal.WorldPosition = new Vector3(float.Parse(numbers2[0]), float.Parse(numbers2[1]), float.Parse(numbers2[2]));
                goalPosition = m_kGoal.WorldPosition;
                SetUpGoalBoundingBox();
                ScreenManager.Game.Components.Add(m_kGoal);
                GameObjects.Add(m_kGoal);
                camera = new CameraComponent(ScreenManager.Game, m_kAirplane);
                //load bonuses
                do
                {
                    line = streamReader.ReadLine();
                    string[] numbers3 = line.Split(',');
                    foreach (string s in numbers3)
                    {
                        System.Diagnostics.Debug.WriteLine(s);
                    }

                    Bonus temp = new Bonus(ScreenManager.Game);
                    temp.Camera = camera;
                    temp.WorldPosition = new Vector3(float.Parse(numbers3[0]), float.Parse(numbers3[1]), float.Parse(numbers3[2]));
                    //temp.WorldPosition = new Vector3(8.0f, 1.0f, -3.0f);
                    if (bonusItems.TryAdd(temp, false))
                    {
                        ScreenManager.Game.Components.Add(temp);
                        GameObjects.Add(temp);
                        System.Diagnostics.Debug.WriteLine("Added bonus item " + temp.WorldPosition);
                    }
                } while (!streamReader.EndOfStream);
            }

            m_kAirplane.Camera = camera;
            ScreenManager.Game.Components.Add(camera);
            GameObjects.Add(camera);
            ScreenManager.Game.Components.Add(m_kAirplane);
            GameObjects.Add(m_kAirplane);
            //_soundBank.PlayCue("Ship_Spawn");
            //m_kAirplane.WorldPosition = new Vector3(8, 1, -3);
            m_kGoal.Camera = camera;
            goalSoundPlayed = false;

            ScreenManager.Game.IsMouseVisible = true;

            basicEffect = new BasicEffect(ScreenManager.GraphicsDevice);

            //m_kAirplane.WorldPosition = new Vector3(8, 0, -7);
            //camera.View = Matrix.CreateLookAt(new Vector3(3, 5, 2), new Vector3(2, 0, -1), new Vector3(0, 1, 0));
        }
Example #7
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            //camera = new CameraComponent(ScreenManager.Game);

            gameFont = content.Load<SpriteFont>("gamefont");

            _audioEngine = new AudioEngine("Content/Sounds.xgs");
            _waveBank = new WaveBank(_audioEngine, "Content/XNAsteroids Waves.xwb");
            _soundBank = new SoundBank(_audioEngine, "Content/XNAsteroids Cues.xsb");

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            //Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            //level building
            effect = content.Load<Effect>("effects");
            sceneryTexture = content.Load<Texture2D>("texturemap");
            SetUpCamera();
            LoadFloorPlan();
            SetUpVertices();

            m_kAirplane = new Airplane(ScreenManager.Game);
            m_kAirplane.WorldRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.PiOver2);
            ScreenManager.Game.Components.Add(m_kAirplane);

            //_soundBank.PlayCue("Ship_Spawn");
        }