コード例 #1
0
        public TextManager(Map map)
        {
            _log = Logging.LogManager.GetLogger(this);
            _log.Info("TextManager is loading map text entries...");
            _texts = new List<Text>();
            _activeText = null;

            if (!map.HasLayer("text"))
            {
                _log.Info("No text layer detected on map, aborting...");
                return;
            }

            foreach (var obj in map.FindObjects((l, o) => l.Name == "text"))
            {
                string title = obj.Properties.ContainsKey("title") ? obj.Properties["title"] : "<No Title>";

                string subtitle = obj.Properties.ContainsKey("subtitle") ? obj.Properties["subtitle"] : null;

                _log.DebugFormat("Adding new text {0} of type {1}", obj.Name, obj.Type);
                _texts.Add(new Text(obj.Bounds, obj.Name, obj.Type, title, subtitle));
            }

            _log.Debug("TextManager initialized!");
        }
コード例 #2
0
ファイル: Level.cs プロジェクト: Sharparam/DiseasedToast
 internal Level(string name, Map map)
 {
     _name = name;
     _map = map;
     _characters = new List<Character>();
     _containers = new List<ItemSprite>();
 }
コード例 #3
0
ファイル: World.cs プロジェクト: Sharparam/DiseasedToast
 public Level CreateLevel(string name, Map map)
 {
     Level level = _levels.FirstOrDefault(l => l.Name == name);
     if (level != null)
         return level;
     level = new Level(name, map);
     _levels.Add(level);
     return level;
 }
コード例 #4
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);
        }