void mapTile_Click(object sender, EventArgs e)
        {
            XnaButton        button = (XnaButton)sender;
            XnaRaceTrackTile tile   = button.Tag as XnaRaceTrackTile;

            if (Array.IndexOf(MapNames, tile.Name) > 2 && FingerGames.IsTrial)
            {
                FingerGames.Instance.SetStage(Stage.Trial);
            }
            else
            {
                _boardTiles = tile.BoardTiles;
                GameManager.GameVariation = tile.Name;
                _loadedMap = true;
            }
        }
Beispiel #2
0
        void raceLengthButton_Click(object sender, EventArgs e)
        {
            XnaButton   button = (XnaButton)sender;
            RaceLengths length = (RaceLengths)button.Tag;

            _needsConfigure = false;

            if (FingerGames.IsTrial && (length == RaceLengths.Medium || length == RaceLengths.Marathon))
            {
                FingerGames.Instance.SetStage(Stage.Trial);
            }
            else
            {
                RaceLength = (int)length;

                HurdleDistance            = (int)FingerGames.Randomizer.Next(RaceLength / 10, RaceLength / 2);
                GameManager.GameVariation = length.ToString();
            }
        }
        public override void LoadContent()
        {
            this.Logo  = this.GameManager.Game.Content.Load <Texture2D>(@"Textures\twister");
            this._font = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\MenuFont");
            SpriteFont bigFont = this.GameManager.Game.Content.Load <SpriteFont>(@"Fonts\GameFont");

            PopSound = this.GameManager.Game.Content.Load <SoundEffect>(@"Sounds\POP2");

            this.Assets.Add(Logo);
            this.Assets.Add(PopSound);

            _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 Difficulty..";

            _configurePanel.AddChild(label);

            foreach (TwisterDifficulty diff in new TwisterDifficulty[] { TwisterDifficulty.Beginner, TwisterDifficulty.Intermediate, TwisterDifficulty.Master })
            {
                XnaButton difficultyButton = new XnaButton(new Rectangle(0, 0, 800, 80));
                difficultyButton.Tag = diff;
                difficultyButton.HorizontalAlignment = HorizontalAlignment.Left;
                difficultyButton.Font     = bigFont;
                difficultyButton.FontZoom = 0.8f;
                difficultyButton.Text     = diff.ToString();
                difficultyButton.Click   += new EventHandler(difficultyButton_Click);

                if (FingerGames.IsTrial && diff != TwisterDifficulty.Intermediate)
                {
                    difficultyButton.Color = new Color(110, 110, 110);
                }

                _configurePanel.AddChild(difficultyButton);
            }

            base.LoadContent();
        }
Beispiel #4
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.Logo = this.GameManager.Game.Content.Load<Texture2D>(@"Textures\twister");
            this._font = this.GameManager.Game.Content.Load<SpriteFont>(@"Fonts\MenuFont");
            SpriteFont bigFont = this.GameManager.Game.Content.Load<SpriteFont>(@"Fonts\GameFont");
            PopSound = this.GameManager.Game.Content.Load<SoundEffect>(@"Sounds\POP2");

            this.Assets.Add(Logo);
            this.Assets.Add(PopSound);

            _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 Difficulty..";

            _configurePanel.AddChild(label);

            foreach (TwisterDifficulty diff in new TwisterDifficulty[] { TwisterDifficulty.Beginner, TwisterDifficulty.Intermediate, TwisterDifficulty.Master })
            {
                XnaButton difficultyButton = new XnaButton(new Rectangle(0, 0, 800, 80));
                difficultyButton.Tag = diff;
                difficultyButton.HorizontalAlignment = HorizontalAlignment.Left;
                difficultyButton.Font = bigFont;
                difficultyButton.FontZoom = 0.8f;
                difficultyButton.Text = diff.ToString();
                difficultyButton.Click += new EventHandler(difficultyButton_Click);

                if (FingerGames.IsTrial && diff != TwisterDifficulty.Intermediate)
                {
                    difficultyButton.Color = new Color(110, 110, 110);
                }

                _configurePanel.AddChild(difficultyButton);
            }

            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();
        }
        void difficultyButton_Click(object sender, EventArgs e)
        {
            XnaButton         button = (XnaButton)sender;
            TwisterDifficulty diff   = (TwisterDifficulty)button.Tag;

            _needsConfigure = false;

            if (FingerGames.IsTrial && (diff == TwisterDifficulty.Beginner || diff == TwisterDifficulty.Master))
            {
                FingerGames.Instance.SetStage(Stage.Trial);
            }
            else
            {
                int colCount = 5;
                int rowCount = 3;
                int yOffset = 24;
                int width, height;

                switch (diff)
                {
                case TwisterDifficulty.Beginner:
                {
                    colCount = 3;
                    rowCount = 2;
                }
                break;

                case TwisterDifficulty.Intermediate:
                {
                    colCount = 5;
                    rowCount = 3;
                }
                break;

                case TwisterDifficulty.Master:
                {
                    colCount = 6;
                    rowCount = 4;
                }
                break;
                }

                GameManager.GameVariation = diff.ToString();

                width   = (800 - 80) / colCount;
                height  = width;
                yOffset = (480 - width * rowCount) / 2;

                double halfCol     = (colCount - 1) / 2;
                double widthOffset = (width / 10);

                _circles = new TwisterCircle[colCount * rowCount];
                int index = 0;
                for (int x = 0; x < colCount; ++x)
                {
                    for (int y = 0; y < rowCount; ++y)
                    {
                        Rectangle bounds = new Rectangle((int)(80 + x * width + (y - halfCol) * widthOffset), yOffset + y * height, width, height);
                        _circles[index] = new TwisterCircle(this.GameManager.Game, bounds, _colors[index % _colors.Length]);

                        index++;
                    }
                }
                foreach (TwisterCircle circle in _circles)
                {
                    circle.Digit = null;
                    circle.SetIntroAnim(TimeSpan.FromMilliseconds(FingerGames.Randomizer.Next(0, 2000)), FingerGames.Randomizer.Next(100, 1600));
                }
            }
        }
        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._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();
        }