Ejemplo n.º 1
0
        public WndChallenges(int isChecked, bool editable)
        {
            _editable = editable;

            var title = PixelScene.CreateText(Title, 9);

            title.Hardlight(TitleColor);
            title.Measure();
            title.X = PixelScene.Align(Camera, (WIDTH - title.Width) / 2);
            Add(title);

            _boxes = new List <CheckBox>();

            var pos = title.Height + Gap;

            for (var i = 0; i < Challenges.NAMES.Length; i++)
            {
                var cb = new CheckBox(Challenges.NAMES[i]);
                cb.SetChecked((isChecked & Challenges.MASKS[i]) != 0);
                cb.Active = editable;

                if (i > 0)
                {
                    pos += Gap;
                }

                cb.SetRect(0, pos, WIDTH, BtnHeight);
                pos = cb.Bottom();

                Add(cb);
                _boxes.Add(cb);
            }

            Resize(WIDTH, (int)pos);
        }
Ejemplo n.º 2
0
        public WndBadge(Badge badge)
        {
            var icon = BadgeBanner.Image(badge.Image);

            icon.Scale.Set(2);
            Add(icon);

            var info = PixelScene.CreateMultiline(badge.Description, 8);

            info.MaxWidth = WIDTH - MARGIN * 2;
            info.Measure();

            var w = Math.Max(icon.Width, info.Width) + MARGIN * 2;

            icon.X = (w - icon.Width) / 2;
            icon.Y = MARGIN;

            var pos = icon.Y + icon.Height + MARGIN;

            foreach (var line in new LineSplitter(info.Font, info.Scale, info.Text()).Split())
            {
                line.Measure();
                line.X = PixelScene.Align((w - line.Width) / 2);
                line.Y = PixelScene.Align(pos);
                Add(line);

                pos += line.Height;
            }

            Resize((int)w, (int)(pos + MARGIN));

            BadgeBanner.Highlight(icon, badge.Image);
        }
Ejemplo n.º 3
0
        protected override void Layout()
        {
            _Height = 32;

            _shield.Size(Width, _shield.Height);

            _avatar.X = PixelScene.Align(Camera, _shield.X + 15 - _avatar.Width / 2);
            _avatar.Y = PixelScene.Align(Camera, _shield.Y + 16 - _avatar.Height / 2);

            _compass.X = _avatar.X + _avatar.Width / 2 - _compass.Origin.X;
            _compass.Y = _avatar.Y + _avatar.Height / 2 - _compass.Origin.Y;

            _hp.X = 30;
            _hp.Y = 3;

            _depth.X = Width - 24 - _depth.Width - 18;
            _depth.Y = 6;

            _keys.Y = 6;

            _danger.SetPos(Width - _danger.Width, 20);

            _loot.SetPos(Width - _loot.Width, _danger.Bottom() + 2);

            _buffs.SetPos(32, 11);

            _btnMenu.SetPos(Width - _btnMenu.Width, 1);
        }
Ejemplo n.º 4
0
        protected override void Layout()
        {
            _sprite.Y = PixelScene.Align(Y + (Height - _sprite.Height) / 2);

            _label.X = _sprite.X + _sprite.Width;
            _label.Y = PixelScene.Align(Y + (Height - _label.BaseLine()) / 2);
        }
Ejemplo n.º 5
0
        public WndJournal()
        {
            Resize(WIDTH, HEIGHT);

            txtTitle = PixelScene.CreateText(TxtTitle, 9);
            txtTitle.Hardlight(TitleColor);
            txtTitle.Measure();
            txtTitle.X = PixelScene.Align(PixelScene.uiCamera, (WIDTH - txtTitle.Width) / 2);
            Add(txtTitle);

            var content = new Component();

            Collections.Sort(Journal.Records);

            float pos = 0;

            foreach (var rec in Journal.Records)
            {
                var item = new ListItem(rec.feature, rec.depth);
                item.SetRect(0, pos, WIDTH, ItemHeight);
                content.Add(item);

                pos += item.Height;
            }

            content.SetSize(WIDTH, pos);

            list = new ScrollPane(content);
            Add(list);

            list.SetRect(0, txtTitle.Height, WIDTH, HEIGHT - txtTitle.Height);
        }
Ejemplo n.º 6
0
        private void UpdateList()
        {
            _txtTitle.Text(Utils.Format(TxtTitle, ShowPotions ? TxtPotions : TxtScrolls));
            _txtTitle.Measure();
            _txtTitle.X = PixelScene.Align(PixelScene.uiCamera, (WIDTH - _txtTitle.Width) / 2);

            _items.Clear();

            var content = _list.Content();

            content.Clear();
            _list.ScrollTo(0, 0);

            float pos = 0;

            HashSet <Type> known;

            if (ShowPotions)
            {
                known = Potion.GetKnown;
            }
            else
            {
                known = Scroll.GetKnown;
            }

            foreach (var itemClass in known)
            {
                var item = new ListItem(itemClass);
                item.SetRect(0, pos, WIDTH, ItemHeight);
                content.Add(item);
                _items.Add(item);

                pos += item.Height;
            }

            HashSet <Type> unknown;

            if (ShowPotions)
            {
                unknown = Potion.GetUnknown;
            }
            else
            {
                unknown = Scroll.GetUnknown;
            }

            foreach (var itemClass in unknown)
            {
                var item = new ListItem(itemClass);
                item.SetRect(0, pos, WIDTH, ItemHeight);
                content.Add(item);
                _items.Add(item);

                pos += item.Height;
            }

            content.SetSize(WIDTH, pos);
        }
Ejemplo n.º 7
0
            protected override void Layout()
            {
                _icon.X = X;
                _icon.Y = PixelScene.Align(Y + (Height - _icon.Height) / 2);

                _label.X = _icon.X + _icon.Width + 2;
                _label.Y = PixelScene.Align(Y + (Height - _label.BaseLine()) / 2);
            }
Ejemplo n.º 8
0
        protected override void Layout()
        {
            base.Layout();

            slot.Fill(this);

            _crossB.X = PixelScene.Align(X + (Width - _crossB.Width) / 2);
            _crossB.Y = PixelScene.Align(Y + (Height - _crossB.Height) / 2);
        }
Ejemplo n.º 9
0
        protected override void Layout()
        {
            base.Layout();

            float margin = (Height - InternalText.BaseLine()) / 2;

            InternalText.X = PixelScene.Align(PixelScene.uiCamera, X + margin);
            InternalText.Y = PixelScene.Align(PixelScene.uiCamera, Y + margin);

            InternalIcon.X = PixelScene.Align(PixelScene.uiCamera, X + Width - margin - InternalIcon.Width);
            InternalIcon.Y = PixelScene.Align(PixelScene.uiCamera, Y + (Height - InternalIcon.Height) / 2);
        }
Ejemplo n.º 10
0
            protected override void Layout()
            {
                base.Layout();

                _btLabel.X = PixelScene.Align(X + (Width - _btLabel.Width) / 2);
                _btLabel.X = PixelScene.Align(Y + (Height - _btLabel.BaseLine()) / 2) - 1;

                if (!Selected)
                {
                    _btLabel.Y -= 2;
                }
            }
Ejemplo n.º 11
0
        protected override void Layout()
        {
            ImIcon.X = 0;
            ImIcon.Y = 0;

            TfLabel.X        = PixelScene.Align(PixelScene.uiCamera, ImIcon.X + ImIcon.Width + Gap);
            TfLabel.MaxWidth = (int)(Width - TfLabel.X);
            TfLabel.Measure();
            TfLabel.Y = PixelScene.Align(PixelScene.uiCamera, ImIcon.Height > TfLabel.Height ? (ImIcon.Height - TfLabel.BaseLine()) / 2 : ImIcon.Y);

            _Height = Math.Max(ImIcon.Y + ImIcon.Height, TfLabel.Y + TfLabel.Height);
        }
Ejemplo n.º 12
0
            protected override void Layout()
            {
                _icon.X = Width - _icon.Width;

                _depth.X = _icon.Y - 1 - _depth.Width;

                _depth.Y = PixelScene.Align(Y + (Height - _depth.Height) / 2);

                _icon.Y = _depth.Y - 1;

                _feature.Y = PixelScene.Align(_depth.Y + _depth.BaseLine() - _feature.BaseLine());
            }
Ejemplo n.º 13
0
        public virtual void Reset(float x, float y, string text, int color)
        {
            Revive();

            Text(text);
            Hardlight(color);

            Measure();
            X = PixelScene.Align(x - Width / 2);
            Y = y - Height;

            _timeLeft = Lifespan;
        }
Ejemplo n.º 14
0
        protected override void Layout()
        {
            base.Layout();

            if (_sprite == null)
            {
                return;
            }

            _sprite.X = X + (Width - _sprite.Width) / 2;
            _sprite.Y = Y + (Height - _sprite.Height) / 2;
            PixelScene.Align(_sprite);
        }
Ejemplo n.º 15
0
        protected override void Layout()
        {
            base.Layout();

            Bg.X = X;
            Bg.Y = Y;
            Bg.Size(Width, Height);

            Close.SetPos(Bg.X + Bg.Width - Bg.MarginHor() / 2 - MarginHor - Close.Width, Y + (Height - Close.Height) / 2);

            BitmapText.X = Close.Left() - MarginHor - BitmapText.Width;
            BitmapText.Y = Y + (Height - BitmapText.Height) / 2;
            PixelScene.Align(BitmapText);
        }
Ejemplo n.º 16
0
            private float StatSlot(Group parent, string label, string value, float pos)
            {
                var txt = PixelScene.CreateText(label, 7);

                txt.Y = pos;
                parent.Add(txt);

                txt = PixelScene.CreateText(value, 7);
                txt.Measure();
                txt.X = PixelScene.Align(WIDTH * 0.65f);
                txt.Y = pos;
                parent.Add(txt);

                return(pos + Gap + txt.BaseLine());
            }
Ejemplo n.º 17
0
            private void StatSlot(string label, string value)
            {
                var txt = PixelScene.CreateText(label, 8);

                txt.Y = pos;
                Add(txt);

                txt = PixelScene.CreateText(value, 8);
                txt.Measure();
                txt.X = PixelScene.Align(WIDTH * 0.65f);
                txt.Y = pos;
                Add(txt);

                pos += GAP + txt.BaseLine();
            }
Ejemplo n.º 18
0
        private void UpdateImage()
        {
            if (_sprite != null)
            {
                _sprite.KillAndErase();
                _sprite = null;
            }

            try
            {
                _sprite = (CharSprite)Activator.CreateInstance(_lastTarget.SpriteClass);
                _sprite.Idle();
                _sprite.paused = true;
                Add(_sprite);

                _sprite.X = X + (Width - _sprite.Width) / 2 + 1;
                _sprite.Y = Y + (Height - _sprite.Height) / 2;
                PixelScene.Align(_sprite);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 19
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));
        }
Ejemplo n.º 20
0
 private void PlaceNumber()
 {
     number.X = Right() - 11 - number.Width;
     number.Y = PixelScene.Align(Y + (Height - number.BaseLine()) / 2);
 }