private void CreateControls()
        {
            Log.Debug("Loading controls...");
            var leftTexture = Game.Content.Load<Texture2D>(@"GUI\LeftArrowUp");
            var rightTexture = Game.Content.Load<Texture2D>(@"GUI\RightArrowUp");
            var stopTexture = Game.Content.Load<Texture2D>(@"GUI\StopBar");

            _background = new PictureBox(Game.Content.Load<Texture2D>(@"Backgrounds\Title"), GameRef.ScreenRectangle);
            ControlManager.Add(_background);

            var label1 = new Label {Text = "Who will search for the Eyes of the Dragon?"};
            label1.AutoSize();
            label1.Position = new Vector2((GameRef.Window.ClientBounds.Width - label1.Size.X) / 2, 150);
            ControlManager.Add(label1);

            _genderSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            _genderSelector.SetItems(Genders, 125);
            _genderSelector.Position = new Vector2(label1.Position.X, 200);
            _genderSelector.SelectionChanged += SelectionChanged;
            ControlManager.Add(_genderSelector);

            _classSelector = new LeftRightSelector(leftTexture, rightTexture, stopTexture);
            _classSelector.SetItems(_classes, 125);
            _classSelector.Position = new Vector2(label1.Position.X, 250);
            _classSelector.SelectionChanged += SelectionChanged;
            ControlManager.Add(_classSelector);

            var acceptLabel = new LinkLabel {Text = "Accept this character", Position = new Vector2(label1.Position.X, 300)};
            acceptLabel.Selected += AcceptLabelSelected;
            ControlManager.Add(acceptLabel);

            _characterImage = new PictureBox(_characterImages[0, 0], new Rectangle(500, 200, 96, 96), new Rectangle(0, 0, 32, 32));
            ControlManager.Add(_characterImage);

            ControlManager.NextControl();
            Log.Debug("Loaded controls!");
        }
Esempio n. 2
0
        protected override void LoadContent()
        {
            base.LoadContent();

            _map = GameRef.World.CurrentLevel.Map;

            _player.SetMapSize(_map.PixelsWide, _map.PixelsHigh);

            var spawn = _map.FindObject((l, o) => l.Name == "player" && o.Name == "spawn" && o.ObjectType == MapObjectType.Plain);
            //string pos = _map.GetProperty("spawn");
            if (spawn != null)
            {
                //string[] splitPos = pos.Split(';');
                float x = spawn.Bounds.X;
                float y = spawn.Bounds.Y;

                _player.Sprite.Position = new Vector2(x, y);
                _player.Camera.LockToSprite(_player.Sprite);
            }

            _pointer = Game.Content.Load<Texture2D>(@"GUI\pointer");

            var emptyBar = Game.Content.Load<Texture2D>(@"GUI\EmptyBar");
            int barYPos = Game.GraphicsDevice.Viewport.Height - (emptyBar.Height + BarVerticalOffset);
            _healthBar = new Bar(Game.Content.Load<Texture2D>(@"GUI\HealthBar"), emptyBar, new Vector2(BarLeftOffset, barYPos));
            _manaBar = new Bar(Game.Content.Load<Texture2D>(@"GUI\ManaBar"), emptyBar, new Vector2(_healthBar.Position.X + emptyBar.Width + BarHorizontalOffset, barYPos));
            _staminaBar = new Bar(Game.Content.Load<Texture2D>(@"GUI\StaminaBar"), emptyBar, new Vector2(_manaBar.Position.X + emptyBar.Width + BarHorizontalOffset, barYPos));

            _zoneLabel = new Label
            {
                Enabled = true,
                Visible = true,
                Font = Game.Content.Load<SpriteFont>(@"Fonts\ControlFont"),
                Name = "ZoneLabel",
                Position = new Vector2(20, 100),
                Text = "%ZONE_NAME%",
                TabStop = false
            };
            _zoneLabel.AutoSize();

            #if DEBUG
            _debugFont = Game.Content.Load<SpriteFont>(@"Fonts\DebugFont");

            _posLabel = new Label
            {
                Enabled = true,
                Visible = true,
                Font = _debugFont,
                Name = "PositionLabel",
                Position = new Vector2(10, 10),
                Text = PositionFormat,
                TabStop = false
            };
            _posLabel.AutoSize();

            _levelLabel = new Label
            {
                Enabled = true,
                Visible = true,
                Font = _debugFont,
                Name = "LevelLabel",
                Position = new Vector2(10, _posLabel.Position.Y + _posLabel.Size.Y + 5),
                Text = LevelFormat,
                TabStop = false
            };
            _levelLabel.AutoSize();

            _playerLabel = new Label
            {
                Enabled = true,
                Visible = true,
                Font = _debugFont,
                Name = "PlayerLabel",
                Position = new Vector2(10, _levelLabel.Position.Y + _levelLabel.Size.Y + 5),
                Text = PlayerFormat,
                TabStop = false
            };
            _playerLabel.AutoSize();

            _infoLabel = new Label
            {
                Enabled = true,
                Visible = true,
                Font = _debugFont,
                Name = "InfoLabel",
                Position = new Vector2(10, 500),
                Text = "KEYS: B = Battle Theme, M = Normal Theme",
                TabStop = false
            };
            _infoLabel.AutoSize();

            _helpLabel = new Label
            {
                Font = _debugFont,
                Name = "HelpLabel",
                Position = new Vector2(10, 700),
                Text = "H = Toggle Help"
            };
            _helpLabel.AutoSize();
            #endif

            var song = GameRef.AudioManager.Song.GetSong("Level0_bgm");
            song.SetStartFade(new FadeInfo(0.0f, 0.1f));
            song.SetEndFade(new FadeInfo(0.1f, 0.0f, -0.01f));
            //GameRef.AudioManager.AddSong(new Song("Level0_bgm", Game.Content.Load<Microsoft.Xna.Framework.Media.Song>(@"Music\Level0_bgm"), 0.1f));
            //GameRef.AudioManager.AddSong(new Song("BattleTest", Game.Content.Load<Microsoft.Xna.Framework.Media.Song>(@"Music\BattleTest")));
            var bSong = GameRef.AudioManager.Song.GetSong("BattleTest");
            bSong.SetStartFade(new FadeInfo(0.0f, 1.0f));
            bSong.SetEndFade(new FadeInfo(1.0f, 0.0f, -0.01f));
            song.SetNext(bSong);
            bSong.SetNext(song);

            song.BeginStartFade();
            GameRef.AudioManager.Song.Play(song);
        }