Example #1
0
            public StatsTab()
            {
                var heroClass = Dungeon.Hero.ClassName();

                var title = new IconTitle();

                title.Icon(HeroSprite.Avatar(Dungeon.Hero.heroClass, Dungeon.Hero.Tier()));
                title.Label(Utils.Format(TxtTitle, Dungeon.Hero.Lvl, heroClass).ToUpper(CultureInfo.CurrentCulture));
                title.SetRect(0, 0, WIDTH, 0);
                Add(title);

                float pos = title.Bottom();

                if (Dungeon.Challenges > 0)
                {
                    var btnCatalogus = new RedButton(TxtChallenges);
                    btnCatalogus.ClickAction = button => Game.Scene.Add(new WndChallenges(Dungeon.Challenges, false));
                    btnCatalogus.SetRect(0, pos + Gap, btnCatalogus.ReqWidth() + 2, btnCatalogus.ReqHeight() + 2);
                    Add(btnCatalogus);

                    pos = btnCatalogus.Bottom();
                }

                pos += Gap + Gap;

                pos = StatSlot(this, TxtStr, Dungeon.Hero.STR.ToString(), pos);
                pos = StatSlot(this, TxtHealth, Dungeon.Hero.HT.ToString(), pos);

                pos += Gap;

                pos = StatSlot(this, TxtDuration, ((int)Statistics.Duration).ToString(), pos);

                pos += Gap;

                pos = StatSlot(this, TxtDepth, Statistics.DeepestFloor.ToString(), pos);
                pos = StatSlot(this, TxtEnemies, Statistics.EnemiesSlain.ToString(), pos);
                pos = StatSlot(this, TxtGold, Statistics.GoldCollected.ToString(), pos);

                pos += Gap;

                pos = StatSlot(this, TxtFood, Statistics.FoodEaten.ToString(), pos);
                pos = StatSlot(this, TxtAlchemy, Statistics.PotionsCooked.ToString(), pos);
                pos = StatSlot(this, TxtAnkhs, Statistics.AnkhsUsed.ToString(), pos);
            }
Example #2
0
        protected override void CreateChildren()
        {
            _shield = new NinePatch(Assets.STATUS, 80, 0, 30 + 18, 0);
            Add(_shield);

            var touchArea = new TouchArea(0, 1, 30, 30);

            touchArea.ClickAction = touch =>
            {
                var sprite = Dungeon.Hero.Sprite;
                if (!sprite.Visible)
                {
                    Camera.Main.FocusOn(sprite);
                }
                GameScene.Show(new WndHero());
            };
            Add(touchArea);

            _btnMenu = new MenuButton();
            Add(_btnMenu);

            _avatar = HeroSprite.Avatar(Dungeon.Hero.heroClass, _lastTier);
            Add(_avatar);

            _blood = new Emitter();
            _blood.Pos(_avatar);
            _blood.Pour(BloodParticle.Factory, 0.3f);
            _blood.AutoKill = false;
            _blood.On       = false;
            Add(_blood);

            _compass = new Compass(Dungeon.Level.exit);
            Add(_compass);

            _hp = new Image(Assets.HP_BAR);
            Add(_hp);

            _exp = new Image(Assets.XP_BAR);
            Add(_exp);

            _level = new BitmapText(PixelScene.font1x);
            _level.Hardlight(0xFFEBA4);
            Add(_level);

            _depth = new BitmapText(Dungeon.Depth.ToString(CultureInfo.InvariantCulture), PixelScene.font1x);
            _depth.Hardlight(0xCACFC2);
            _depth.Measure();
            Add(_depth);

            Dungeon.Hero.Belongings.CountIronKeys();
            _keys = new BitmapText(PixelScene.font1x);
            _keys.Hardlight(0xCACFC2);
            Add(_keys);

            _danger = new DangerIndicator();
            Add(_danger);

            _loot = new LootIndicator();
            Add(_loot);

            _buffs = new BuffIndicator(Dungeon.Hero);
            Add(_buffs);
        }
Example #3
0
        public override void Update()
        {
            base.Update();

            var health = (float)Dungeon.Hero.HP / Dungeon.Hero.HT;

            if (Math.Abs(health) < 0.0001)
            {
                _avatar.Tint(0x000000, 0.6f);
                _blood.On = false;
            }
            else
            if (health < 0.25f)
            {
                _avatar.Tint(0xcc0000, 0.4f);
                _blood.On = true;
            }
            else
            {
                _avatar.ResetColor();
                _blood.On = false;
            }

            _hp.Scale.X  = health;
            _exp.Scale.X = (Width / _exp.Width) * Dungeon.Hero.Exp / Dungeon.Hero.MaxExp();

            if (Dungeon.Hero.Lvl != _lastLvl)
            {
                if (_lastLvl != -1)
                {
                    var emitter = Recycle <Emitter>();
                    emitter.Revive();
                    emitter.Pos(27, 27);
                    emitter.Burst(Speck.Factory(Speck.STAR), 12);
                }

                _lastLvl = Dungeon.Hero.Lvl;
                _level.Text(_lastLvl.ToString());
                _level.Measure();
                _level.X = PixelScene.Align(27.0f - _level.Width / 2);
                _level.Y = PixelScene.Align(27.5f - _level.BaseLine() / 2);
            }

            var k = IronKey.CurDepthQuantity;

            if (k != _lastKeys)
            {
                _lastKeys = k;
                _keys.Text(_lastKeys.ToString());
                _keys.Measure();
                _keys.X = Width - 8 - _keys.Width - 18;
            }

            var tier = Dungeon.Hero.Tier();

            if (tier == _lastTier)
            {
                return;
            }

            _lastTier = tier;
            _avatar.Copy(HeroSprite.Avatar(Dungeon.Hero.heroClass, tier));
        }