示例#1
0
        public override void LoadContent()
        {
            LeftFoot  = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\leftfoot");
            RightFoot = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\rightfoot");
            Hurdle    = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\hurdle");

            this._track     = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\track");
            this._font      = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\FixedWidthFont");
            this._fixedFont = this._font;

            _leftFootDrum  = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\FootDrum");
            _rightFootDrum = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\FootDrum");

            this.Logo       = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\runner");
            this._raceFlags = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\racerflags");

            this.Assets.Add(LeftFoot);
            this.Assets.Add(RightFoot);
            this.Assets.Add(Hurdle);
            this.Assets.Add(_track);
            this.Assets.Add(_leftFootDrum);
            this.Assets.Add(_rightFootDrum);
            this.Assets.Add(Logo);
            this.Assets.Add(_raceFlags);

            this._timePanel.Bounds    = new Rectangle(0, 10, 800, 470);
            this._timePanel.FixedSize = true;

            XnaImage flagsImage     = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height));
            XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90));

            completedLabel.BackColor = new Color(0, 0, 0, 150);
            completedLabel.FontZoom  = 1.5f;
            completedLabel.Text      = "Race Completed!";

            this._timePanel.AddChild(flagsImage);
            this._timePanel.AddChild(completedLabel);
            this._timePanel.AddChild(_timeLabel);
            this._timePanel.AddChild(_timeLabel2);

            SpriteFont bigFont = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\GameFont");

            _configurePanel.Bounds = new Rectangle(20, 0, 780, 480);
            _configurePanel.HorizontalAlignment = HorizontalAlignment.Left;

            XnaLabel label = new XnaLabel(new Rectangle(0, 0, 800, 100));

            label.HorizontalAlignment = HorizontalAlignment.Left;
            label.Font     = bigFont;
            label.FontZoom = 1.0f;
            label.Text     = "Select Race Length..";

            _configurePanel.AddChild(label);

            int index = 0;

            foreach (RaceLengths diff in new RaceLengths[] { RaceLengths.Sprint, RaceLengths.Medium, RaceLengths.Marathon })
            {
                XnaButton raceLengthButton = new XnaButton(new Rectangle(0, 0, 800, 80));
                raceLengthButton.Tag = diff;
                raceLengthButton.HorizontalAlignment = HorizontalAlignment.Left;
                raceLengthButton.Font     = bigFont;
                raceLengthButton.FontZoom = 0.8f;
                raceLengthButton.Text     = diff.ToString();
                raceLengthButton.Click   += new EventHandler(raceLengthButton_Click);

                if (FingerGames.IsTrial && index > 0)
                {
                    raceLengthButton.Color = new Color(110, 110, 110);
                }

                _configurePanel.AddChild(raceLengthButton);
                index++;
            }

            base.LoadContent();
        }
        public override void LoadContent()
        {
            this._font = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\GameFont");

            this._engineIdle = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\Engine").CreateInstance();
            this._carScreech = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\pop").CreateInstance();
            this._carHorn    = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\Horn").CreateInstance();

            this.Logo       = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\racer");
            this._car       = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\car");
            this._raceFlags = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\racerflags");

            _textureMap.Add(TilePiece.Grass, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\grass"));
            _textureMap.Add(TilePiece.TopLeft, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\tl"));
            _textureMap.Add(TilePiece.TopRight, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\tr"));
            _textureMap.Add(TilePiece.BottomLeft, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\bl"));
            _textureMap.Add(TilePiece.BottomRight, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\br"));
            _textureMap.Add(TilePiece.Horizontal, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\h"));
            _textureMap.Add(TilePiece.Vertical, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\v"));
            _textureMap.Add(TilePiece.Start, this.GameManager.Game.Content.Load <Texture2D>(@"Textures\tl"));


            this.Assets.Add(_engineIdle);
            this.Assets.Add(_carScreech);
            this.Assets.Add(_carHorn);
            this.Assets.Add(Logo);
            this.Assets.Add(_car);
            this.Assets.Add(_raceFlags);

            foreach (IDisposable asset in _textureMap.Values)
            {
                this.Assets.Add(asset);
            }

            this._engineIdle.Volume   = this._carScreech.Volume = this._carHorn.Volume = 0.5f;
            this._engineIdle.IsLooped = true;


            _mapPanel.Bounds = new Rectangle(0, 0, 800, 480);

            int mapCount = 0;
            HorizontalStackPanel panel = null;

            foreach (string mapName in MapNames)
            {
                string mapData = this.GameManager.Game.Content.Load <string>(@"RacerMaps\" + mapName).Trim();
                LoadedMaps.Add(mapName, mapData);

                if (null == panel)
                {
                    panel = new HorizontalStackPanel();
                    panel.VerticalAlignment = VerticalAlignment.Middle;
                    panel.FixedSize         = false;
                    panel.Bounds            = new Rectangle(0, 0, 800, 180);

                    _mapPanel.AddChild(panel);
                }

                VerticalStackPanel vertPanel = new VerticalStackPanel();
                vertPanel.Bounds = new Rectangle(0, 0, 200, 150);

                XnaRaceTrackTile tile = new XnaRaceTrackTile(_textureMap, mapName, mapData);
                tile.Tag    = tile;
                tile.Bounds = new Rectangle(0, 0, 200, 120);
                tile.Click += new EventHandler(mapTile_Click);

                XnaButton button = new XnaButton(new Rectangle(0, 0, 250, 30));
                button.Tag      = tile;
                button.Text     = mapName;
                button.FontZoom = 0.5f;
                button.Click   += new EventHandler(mapTile_Click);

                if (FingerGames.IsTrial && mapCount > 2)
                {
                    button.Color = new Color(110, 110, 110);
                }

                vertPanel.AddChild(tile);
                vertPanel.AddChild(button);

                panel.AddChild(vertPanel);

                mapCount++;

                if ((mapCount % 3) == 0)
                {
                    panel = null;
                }
            }
            _mapPanel.ForceLayout();

            float maxX = 0;

            for (int i = 0; i < 10; ++i)
            {
                maxX = Math.Max(maxX, _font.MeasureString(i.ToString()).X);
            }

            _decimalWidth = maxX * 1.05f / 2;

            this._timePanel.Bounds    = new Rectangle(0, 10, 800, 470);
            this._timePanel.FixedSize = true;

            XnaImage flagsImage     = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height));
            XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90));

            completedLabel.BackColor = new Color(0, 0, 0, 150);
            completedLabel.FontZoom  = 1.5f;
            completedLabel.Text      = "Race Completed!";

            this._timePanel.AddChild(flagsImage);
            this._timePanel.AddChild(completedLabel);
            this._timePanel.AddChild(_timeLabel);

            base.LoadContent();
        }
        public override void LoadContent()
        {
            this._track = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\track");
            this._font = this.GameManager.Game.Content.Load<SpriteFont>(@"Fonts\FixedWidthFont");
            this._fixedFont = this._font;

            this.Logo = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\runner");
            this._raceFlags = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racerflags");

            this.Assets.Add(_track);
            this.Assets.Add(Logo);
            this.Assets.Add(_raceFlags);

            this._timePanel.Bounds = new Rectangle(0, 10, 800, 470);
            this._timePanel.FixedSize = true;

            XnaImage flagsImage = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height));
            XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90));
            completedLabel.BackColor = new Color(0, 0, 0, 150);
            completedLabel.FontZoom = 1.5f;
            completedLabel.Text = "Race Completed!";

            this._timePanel.AddChild(flagsImage);
            this._timePanel.AddChild(completedLabel);
            this._timePanel.AddChild(_timeLabel);
            this._timePanel.AddChild(_timeLabel2);

            SpriteFont bigFont = this.GameManager.Game.Content.Load<SpriteFont>(@"Fonts\GameFont");

            _configurePanel.Bounds = new Rectangle(20, 0, 780, 480);
            _configurePanel.HorizontalAlignment = HorizontalAlignment.Left;

            XnaLabel label = new XnaLabel(new Rectangle(0, 0, 800, 100));
            label.HorizontalAlignment = HorizontalAlignment.Left;
            label.Font = bigFont;
            label.FontZoom = 1.0f;
            label.Text = "Select Race Length..";

            _configurePanel.AddChild(label);

            int index = 0;
            foreach (RaceLengths diff in new RaceLengths[] { RaceLengths.Sprint, RaceLengths.Medium, RaceLengths.Marathon })
            {
                XnaButton raceLengthButton = new XnaButton(new Rectangle(0, 0, 800, 80));
                raceLengthButton.Tag = diff;
                raceLengthButton.HorizontalAlignment = HorizontalAlignment.Left;
                raceLengthButton.Font = bigFont;
                raceLengthButton.FontZoom = 0.8f;
                raceLengthButton.Text = diff.ToString();
                raceLengthButton.Click += new EventHandler(raceLengthButton_Click);

                if (FingerGames.IsTrial && index > 0)
                {
                    raceLengthButton.Color = new Color(110, 110, 110);
                }

                _configurePanel.AddChild(raceLengthButton);
                index++;
            }

            base.LoadContent();
        }
        public override void LoadContent()
        {
            this._font = this.GameManager.Game.Content.Load<SpriteFont>(@"Fonts\GameFont");

            this._engineIdle = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\Engine").CreateInstance();
            this._carScreech = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\pop").CreateInstance();
            this._carHorn = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\Horn").CreateInstance();

            this.Logo = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racer");
            this._car = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\car");
            this._raceFlags = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\racerflags");

            _textureMap.Add(TilePiece.Grass, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\grass"));
            _textureMap.Add(TilePiece.TopLeft, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tl"));
            _textureMap.Add(TilePiece.TopRight, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tr"));
            _textureMap.Add(TilePiece.BottomLeft, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\bl"));
            _textureMap.Add(TilePiece.BottomRight, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\br"));
            _textureMap.Add(TilePiece.Horizontal, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\h"));
            _textureMap.Add(TilePiece.Vertical, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\v"));
            _textureMap.Add(TilePiece.Start, this.GameManager.Game.Content.Load<Texture2D>(@"Textures\tl"));

            this.Assets.Add(_engineIdle);
            this.Assets.Add(_carScreech);
            this.Assets.Add(_carHorn);
            this.Assets.Add(Logo);
            this.Assets.Add(_car);
            this.Assets.Add(_raceFlags);

            foreach (IDisposable asset in _textureMap.Values)
            {
                this.Assets.Add(asset);
            }

            this._engineIdle.Volume = this._carScreech.Volume = this._carHorn.Volume = 0.5f;
            this._engineIdle.IsLooped = true;

            _mapPanel.Bounds = new Rectangle(0, 0, 800, 480);

            int mapCount = 0;
            HorizontalStackPanel panel = null;

            foreach (string mapName in MapNames)
            {
                string mapData = this.GameManager.Game.Content.Load<string>(@"RacerMaps\" + mapName).Trim();
                LoadedMaps.Add(mapName, mapData);

                if (null == panel)
                {
                    panel = new HorizontalStackPanel();
                    panel.VerticalAlignment = VerticalAlignment.Middle;
                    panel.FixedSize = false;
                    panel.Bounds = new Rectangle(0, 0, 800, 180);

                    _mapPanel.AddChild(panel);
                }

                VerticalStackPanel vertPanel = new VerticalStackPanel();
                vertPanel.Bounds = new Rectangle(0, 0, 200, 150);

                XnaRaceTrackTile tile = new XnaRaceTrackTile(_textureMap, mapName, mapData);
                tile.Tag = tile;
                tile.Bounds = new Rectangle(0, 0, 200, 120);
                tile.Click += new EventHandler(mapTile_Click);

                XnaButton button = new XnaButton(new Rectangle(0, 0, 250, 30));
                button.Tag = tile;
                button.Text = mapName;
                button.FontZoom = 0.5f;
                button.Click += new EventHandler(mapTile_Click);

                if (FingerGames.IsTrial && mapCount > 2)
                {
                    button.Color = new Color(110, 110, 110);
                }

                vertPanel.AddChild(tile);
                vertPanel.AddChild(button);

                panel.AddChild(vertPanel);

                mapCount++;

                if ((mapCount % 3) == 0)
                {
                    panel = null;
                }
            }
            _mapPanel.ForceLayout();

            float maxX = 0;
            for (int i = 0; i < 10; ++i)
            {
                maxX = Math.Max(maxX, _font.MeasureString(i.ToString()).X);
            }

            _decimalWidth = maxX * 1.05f / 2;

            this._timePanel.Bounds = new Rectangle(0, 10, 800, 470);
            this._timePanel.FixedSize = true;

            XnaImage flagsImage = new XnaImage(this._raceFlags, new Rectangle(0, 0, this._raceFlags.Width, this._raceFlags.Height));
            XnaLabel completedLabel = new XnaLabel(new Rectangle(0, 0, 800, 90));
            completedLabel.BackColor = new Color(0, 0, 0, 150);
            completedLabel.FontZoom = 1.5f;
            completedLabel.Text = "Race Completed!";

            this._timePanel.AddChild(flagsImage);
            this._timePanel.AddChild(completedLabel);
            this._timePanel.AddChild(_timeLabel);

            base.LoadContent();
        }