Beispiel #1
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));
        }
Beispiel #2
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));
        }