Пример #1
0
        private void DrawHook(object sender, WorldState.DrawEventArgs args)
        {
            WorldState  world      = sender as WorldState;
            SpriteBatch batch      = args.Batch;
            Vector2     screenSize = args.ScreenSize;

            Matrix oldTransform = batch.Transform;

            batch.Rectangle(new Rectangle(0, 0, args.Batch.Device.Viewport.Width, args.Batch.Device.Viewport.Height), Color.Black * (1.0f - _offsetY) * 0.3f);
            batch.Transform = oldTransform;

            Texture2D bg = _world.Assets.Get <Texture2D>("ui/textbox.png");

            batch.Texture(new Vector2(4, 270 - bg.Height - 4 + (bg.Height + 20) * (float)_offsetY.Value), bg, Color.White);

            Font font = _world.Assets.Get <Font>("fonts/bitcell.ttf");

            batch.Text(font, 16, _content.Speaker, new Vector2(16, 270 - bg.Height + (bg.Height + 20) * (float)_offsetY.Value), Color.White, 0.8f);
            batch.Text(font, 16, _textWrittenYet, new Vector2(16, 270 - bg.Height + 12 + (bg.Height + 20) * (float)_offsetY.Value), Color.White * 0.8f, 0.8f);

            if (_textWrittenYet.Length == _content.Text.Length &&
                ((world.Game.TotalFixedUpdates - _completionTime) % 40) > 20)
            {
                batch.Texture(new Vector2(480 - 20, 270 - 24 + (bg.Height + 20) * (float)_offsetY.Value), _world.Assets.Get <Texture2D>("ui/arrow.png"), Color.White * 0.8f);
            }
        }
Пример #2
0
        private void DrawHook(object sender, WorldState.DrawEventArgs e)
        {
            e.Batch.Rectangle(new Rectangle(0, 0, (int)e.ScreenSize.X, (int)e.ScreenSize.Y), Color.Black * _alpha * 0.3f);

            Vector2 uiPos = e.ScreenSize / 2 - _menu.Area.Value / 2;

            _menu.Draw(uiPos, e.Batch, e.ScreenSize);
        }
Пример #3
0
        private void DrawHook(object sender, WorldState.DrawEventArgs args)
        {
            WorldState  world      = sender as WorldState;
            SpriteBatch batch      = args.Batch;
            Vector2     screenSize = args.ScreenSize;

            Texture2D bg = world.Assets.Get <Texture2D>("ui/player.png");

            batch.Texture(new Vector2(0, 270 - bg.Height + (bg.Height + 20) * (float)_offsetY.Value), bg, Color.White);

            Font font = world.Assets.Get <Font>("fonts/bitcell.ttf");

            int x = 16;

            batch.Text(font,
                       16,
                       "[" + InputMap.FindMapping(InputAction.Inventory).Key + "] Inventory",
                       new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                       Color.White * 0.6f);

            x += (int)font.Measure(16, "[" + InputMap.FindMapping(InputAction.Inventory).Key + "] Inventory").X + 6;

            batch.Text(font,
                       16,
                       "[" + InputMap.FindMapping(InputAction.Spells).Key + "] Spells",
                       new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                       Color.White);

            x += (int)font.Measure(16, "[" + InputMap.FindMapping(InputAction.Spells).Key + "] Spells").X + 6;

            batch.Text(font,
                       16,
                       "[" + InputMap.FindMapping(InputAction.Player).Key + "] " + _entity.Name,
                       new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                       Color.White * 0.6f);
        }
Пример #4
0
        private void DrawHook(object sender, WorldState.DrawEventArgs args)
        {
            WorldState  world      = sender as WorldState;
            SpriteBatch batch      = args.Batch;
            Vector2     screenSize = args.ScreenSize;

            Texture2D bg = _state.Assets.Get <Texture2D>("ui/inventory.png");

            batch.Texture(new Vector2(0, 270 - bg.Height + (bg.Height + 20) * (float)_offsetY.Value), bg, Color.White);

            Font font = _state.Assets.Get <Font>("fonts/bitcell.ttf");

            if (_state is CombatState)
            {
                batch.Text(font,
                           16,
                           "Inventory",
                           new Vector2(16, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                           Color.White);
            }
            else
            {
                int x = 16;

                batch.Text(font,
                           16,
                           "[" + InputMap.FindMapping(InputAction.Inventory).Key + "] Inventory",
                           new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                           Color.White);

                x += (int)font.Measure(16, "[" + InputMap.FindMapping(InputAction.Inventory).Key + "] Inventory").X + 6;

                // only the player uses the inventory for now
                batch.Text(font,
                           16,
                           "[" + InputMap.FindMapping(InputAction.Spells).Key + "] Spells",
                           new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                           Color.White * 0.6f);

                x += (int)font.Measure(16, "[" + InputMap.FindMapping(InputAction.Spells).Key + "] Spells").X + 6;

                batch.Text(font,
                           16,
                           "[" + InputMap.FindMapping(InputAction.Player).Key + "] " + _entity.Name,
                           new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                           Color.White * 0.6f);
            }

            Rectangle itemsListRectangle = new Rectangle(16, 31, 171, 222);
            Vector2   transformLT        = Vector2.Transform(itemsListRectangle.Location.ToVector2(), batch.Transform);
            Vector2   transformRB        = Vector2.Transform(new Vector2(itemsListRectangle.Right, itemsListRectangle.Bottom), batch.Transform);

            Vector3    scale, translation;
            Quaternion rot;

            batch.Transform.Decompose(out scale, out rot, out translation);
            batch.Transform = batch.Transform * Matrix.CreateTranslation(0, (int)-_scroll * scale.X, 0);

            batch.Scissor = new Rectangle(
                (int)transformLT.X,
                (int)(transformLT.Y + (bg.Height + 20) * (float)_offsetY.Value * scale.X),
                (int)(transformRB.X - transformLT.X),
                (int)(transformRB.Y - transformLT.Y));

            itemsListRectangle.Y      += 6;
            itemsListRectangle.Height -= 12;

            if (_entity.Inventory.OccupiedSlots == 0)
            {
                Vector2 measure = font.Measure(16, "No items in inventory");
                batch.Text(font, 16, "No items in inventory", itemsListRectangle.Center.ToVector2() - measure / 2 + new Vector2(0, (bg.Height + 20) * (float)_offsetY.Value), Color.White * 0.4f);
            }
            else
            {
                for (int i = 0; i < _entity.Inventory.OccupiedSlots; i++)
                {
                    Inventory.ItemSlotReference reference = _sortedList[i];
                    int   y        = itemsListRectangle.Y + i * 15 + (int)((bg.Height + 20) * _offsetY.Value);
                    bool  selected = _selectedSlot == i;
                    float alpha    = selected ? 0.7f + (float)Math.Sin(_state.Game.Time * 10) * 0.1f : 0.4f;

                    batch.Texture(
                        new Vector2(itemsListRectangle.X + 6, y),
                        _state.Assets.Get <Texture2D>(reference.Item.SmallIcon),
                        Color.White * alpha);

                    batch.Text(font,
                               16,
                               reference.Item.Name,
                               new Vector2(itemsListRectangle.X + 18, y - 8),
                               Color.White * alpha);

                    int statusX = itemsListRectangle.X + itemsListRectangle.Width - 6 - 8;

                    if (reference.Item.EquippableIn != InventoryEquipSlot.None)
                    {
                        bool drawn = false;

                        foreach (InventoryEquipSlot slot in Enum.GetValues(typeof(InventoryEquipSlot)))
                        {
                            if (slot != InventoryEquipSlot.None && _entity.Inventory[slot].Slot == reference.Slot)
                            {
                                batch.Texture(new Vector2(statusX, y), _state.Assets.Get <Texture2D>("icons/equipped.png"), Color.White * 0.5f);
                                drawn = true;
                                break;
                            }
                        }

                        if (!drawn)
                        {
                            batch.Texture(new Vector2(statusX, y), _state.Assets.Get <Texture2D>("icons/not_equipped.png"), Color.White * 0.5f);
                        }

                        statusX -= 10;
                    }

                    // unusable
                    if (_state is CombatState && !(reference.Item is CombatItem))
                    {
                        batch.Texture(new Vector2(statusX, y), _state.Assets.Get <Texture2D>("icons/unusable.png"), Color.White * 0.5f);
                        statusX -= 10;
                    }
                }
            }

            batch.Transform = batch.Transform * Matrix.CreateTranslation(0, (int)_scroll * scale.X, 0);
            batch.Scissor   = null;

            Rectangle infoRectangle = new Rectangle(itemsListRectangle.Right + 12, itemsListRectangle.Top - 6 + (int)((bg.Height + 20) * (float)_offsetY.Value), 261, 223);

            infoRectangle.Y += 40;

            if (_entity.Inventory.OccupiedSlots > 0 && _selectedSlot != -1)
            {
                Inventory.ItemSlotReference reference = _sortedList[_selectedSlot];

                batch.Texture(
                    new Vector2(infoRectangle.X + infoRectangle.Width / 2 - 16, infoRectangle.Y),
                    _state.Assets.Get <Texture2D>(reference.Item.Icon),
                    Color.White);

                Vector2 measure = font.Measure(16, reference.Item.Name);
                batch.Text(font, 16, reference.Item.Name, new Vector2(infoRectangle.X + infoRectangle.Width / 2 - measure.X / 2, infoRectangle.Y + 30), Color.White);

                int y = 44;
                foreach (string s in reference.Item.Description.Split('\n'))
                {
                    measure = font.Measure(16, s);
                    batch.Text(font, 16, s, new Vector2(infoRectangle.X + infoRectangle.Width / 2 - measure.X / 2, infoRectangle.Y + y), Color.White * 0.7f);

                    y += 12;
                }

                if (reference.Item is ArmorItem)
                {
                    Rectangle blockRectangle = new Rectangle(infoRectangle.X + infoRectangle.Width / 2 - 140 / 2, infoRectangle.Y + 90, 140, 16);

                    batch.Rectangle(blockRectangle, Color.White * 0.1f);
                    blockRectangle.Width = (int)(140 * ((float)(reference.Item as ArmorItem).ArmorValue / 100));
                    batch.Rectangle(blockRectangle, Color.White * 0.3f);
                    blockRectangle.Width = 140;

                    batch.Text(font, 16,
                               ((reference.Item as ArmorItem).Protection == ArmorItem.ProtectionType.Magical ? "Magical" : "Physical") +
                               " Armor: +" +
                               (reference.Item as ArmorItem).ArmorValue,
                               new Vector2(blockRectangle.X + 4, blockRectangle.Y - 4), Color.White);
                }

                if (reference.Item is WeaponItem)
                {
                    string text = "Damage: " +
                                  (reference.Item as WeaponItem).DamageRange.Item1 + "-" + (reference.Item as WeaponItem).DamageRange.Item2 +
                                  " (scales with " + ((reference.Item as WeaponItem).UsesAgility ? "agility" : "strength") + ")";
                    measure = font.Measure(16, text);

                    batch.Text(font, 16, text, new Vector2(infoRectangle.X + infoRectangle.Width / 2 - measure.X / 2, infoRectangle.Y + 90 - 8), Color.White);
                }

                int x = 0;
                batch.Text(font, 16, "Actions", new Vector2(infoRectangle.X + x + 10, infoRectangle.Y + infoRectangle.Height - 72 - 8), Color.White);

                if (_state is CombatState && !(_sortedList[_selectedSlot].Item is CombatItem))
                {
                    batch.Text(font, 16, "This item is not usable in combat", new Vector2(infoRectangle.X + x + 10, infoRectangle.Y + infoRectangle.Height - 60 - 8), Color.White * 0.6f);
                }
                else
                {
                    foreach (PaneAction action in _actions)
                    {
                        bool selected = _rightPaneSelected && _selectedAction == _actions.IndexOf(action);
                        //float alpha = selected ? 0.8f + (float)Math.Sin(_state.Game.Time * 10) * 0.2f : 0.6f;
                        float alpha = selected ? 0.8f : 0.6f;

                        batch.Text(font, 16, action.Name, new Vector2(infoRectangle.X + x + 10, infoRectangle.Y + infoRectangle.Height - 60 - 8), Color.White * alpha);
                        if (selected)
                        {
                            batch.Texture(new Vector2(infoRectangle.X + x, infoRectangle.Y + infoRectangle.Height - 60), _state.Assets.Get <Texture2D>("ui/arrow.png"), Color.White);
                        }

                        x += (int)font.Measure(16, action.Name).X + 16;
                    }
                }
            }
        }
Пример #5
0
        private void DrawHook(object sender, WorldState.DrawEventArgs args)
        {
            WorldState  world      = sender as WorldState;
            SpriteBatch batch      = args.Batch;
            Vector2     screenSize = args.ScreenSize;

            Texture2D bg = world.Assets.Get <Texture2D>("ui/player.png");

            batch.Texture(new Vector2(0, 270 - bg.Height + (bg.Height + 20) * (float)_offsetY.Value), bg, Color.White);

            Font font = world.Assets.Get <Font>("fonts/bitcell.ttf");

            int x = 16;

            batch.Text(font,
                       16,
                       "[" + InputMap.FindMapping(InputAction.Inventory).Key + "] Inventory",
                       new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                       Color.White * 0.6f);

            x += (int)font.Measure(16, "[" + InputMap.FindMapping(InputAction.Inventory).Key + "] Inventory").X + 6;

            batch.Text(font,
                       16,
                       "[" + InputMap.FindMapping(InputAction.Spells).Key + "] Spells",
                       new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                       Color.White * 0.6f);

            x += (int)font.Measure(16, "[" + InputMap.FindMapping(InputAction.Spells).Key + "] Spells").X + 6;

            batch.Text(font,
                       16,
                       "[" + InputMap.FindMapping(InputAction.Player).Key + "] " + _entity.Name,
                       new Vector2(x, 8 + (bg.Height + 20) * (float)_offsetY.Value),
                       Color.White);

            Player    player      = world.Player;
            Point     oldPosition = player.Position;
            Direction oldHeading  = player.Heading;

            player.MoveInstantly(new Point(0, 0));

            switch (((int)(_world.Game.Time * 3) % 4))
            {
            case 0:
                player.Heading = Direction.Left;
                break;

            case 1:
                player.Heading = Direction.Up;
                break;

            case 2:
                player.Heading = Direction.Right;
                break;

            case 3:
                player.Heading = Direction.Down;
                break;
            }

            Matrix     oldTransform = batch.Transform;
            Vector3    scale, translation;
            Quaternion rot;

            batch.Transform.Decompose(out scale, out rot, out translation);
            batch.Transform = oldTransform * Matrix.CreateTranslation((screenSize.X / 2 - 8) * scale.X, (70 + 16 + (bg.Height + 20) * (float)_offsetY.Value) * scale.Y, 0);

            player.Draw(batch, false);
            player.Draw(batch, true);

            batch.Transform = oldTransform;
            player.MoveInstantly(oldPosition);
            player.Heading = oldHeading;

            Vector2 measure = font.Measure(16, "Level " + player.Level);

            batch.Text(font, 16, "Level " + player.Level, new Vector2(screenSize.X / 2 - measure.X / 2, 100 + (bg.Height + 20) * (float)_offsetY.Value), Color.White * 0.8f);

            Rectangle xpBarRectangle = new Rectangle((int)screenSize.X / 2 - 80, (int)(120 + (bg.Height + 20) * (float)_offsetY.Value), 160, 2);

            batch.Rectangle(xpBarRectangle, Color.White * 0.4f);

            xpBarRectangle.Width = (int)(xpBarRectangle.Width * ((float)player.XP / player.NeededXP));
            batch.Rectangle(xpBarRectangle, Color.White * 0.4f);
        }