Пример #1
0
        // permament features
        public override void InitializeConsole()
        {
            base.InitializeConsole();

            if (targetSkill == null)
            {
                return;
            }

            SkillComponent skillComp = targetSkill.Get <SkillComponent>();

            // draw skill name
            EGetScreenName getName    = (EGetScreenName)targetSkill.FireEvent(new EGetScreenName());
            string         screenName = getName.text;

            // draw the description of the skill
            DrawText(2, 1, screenName, Constants.COL_FRIENDLY);

            // common properties of skills: energy
            DrawText(2, 2, "E: " + skillComp.energy, Constants.COL_BLUE);
            PrintMessage(8, 2, "ATTR: %1" + skillComp.attribute, Constants.DEFAULT_COL_SET);

            // print the description as a dynamic text box
            var getSkillDescr = (EGetSkillDescription)targetSkill.FireEvent(new EGetSkillDescription());

            DrawTextBox(2, 4, console.getWidth() - 4, getSkillDescr.description);
        }
Пример #2
0
        // permament features
        public override void InitializeConsole()
        {
            base.InitializeConsole();


            if (inspectTile.entities == null)
            {
                return;
            }

            // setup the info based on the entities on the current tile
            int line = 0;

            foreach (Entity entity in inspectTile.entities)
            {
                EGetScreenName getName = (EGetScreenName)entity.FireEvent(new EGetScreenName());

                DrawText(left, top + line, getName.text, Constants.COL_NORMAL);

                // draw some other info about the entity
                var getEntityHp = (EGetHealth)entity.FireEvent(new EGetHealth());
                if (getEntityHp.maxHealth > 0)
                {
                    float hpPct = (float)getEntityHp.currentHealth / (float)getEntityHp.maxHealth;
                    DrawProgressBar(console.getWidth() - 10, top + line, 8, hpPct, Constants.COL_ANGRY, Constants.COL_BLUE);
                }

                line += 1;
            }
        }
Пример #3
0
        // permament features
        public override void InitializeConsole()
        {
            base.InitializeConsole();

            if (targetItem == null)
            {
                return;
            }

            EGetScreenName getName    = (EGetScreenName)targetItem.FireEvent(new EGetScreenName());
            string         screenName = getName.text;

            DrawText(2, 1, screenName, Constants.COL_FRIENDLY);

            var getStatList = (EGetStatList)targetItem.FireEvent(new EGetStatList());

            int line = 0;

            foreach (string stat in getStatList.stats)
            {
                DrawText(2, 2 + line, stat, Constants.COL_NORMAL);

                line++;
            }
        }
Пример #4
0
        // dynamic features
        public override TCODConsole GetUpdatedConsole()
        {
            base.GetUpdatedConsole();
            const int left         = 2;
            int       hoveredItemY = -1;
            Entity    hoveredItem  = null;
            int       width        = console.getWidth() - (left + 3);
            Vector2   mLoc         = ScreenToConsoleCoord(engine.mouseData.CellX, engine.mouseData.CellY);

            InitializeConsole();

            // devider line is a horizontal line that can be drawn across the console
            string deviderLine = CharConstants.E_TJOINT + "";

            for (int i = 1; i < console.getWidth() - 1; i++)
            {
                deviderLine += CharConstants.HORZ_LINE;
            }
            deviderLine += CharConstants.W_TJOINT;

            // inventory weight: TODO
            DrawText(left, 2, " weight: X/X", Constants.COL_FRIENDLY);

            // equipped area -------------------------------------------------------------
            int equiptopY = equipSection.starty;

            DrawText(0, equiptopY, deviderLine, TCODColor.white);
            DrawText(left, equiptopY, " equipped ", Constants.COL_NORMAL);

            if (equipment.weapon != null)
            {
                EGetScreenName getName    = (EGetScreenName)equipment.weapon.FireEvent(new EGetScreenName());
                string         weaponName = getName.text;

                // the weapon is being hovered over
                if (mLoc.y == equiptopY + 3 &&
                    mLoc.x >= left && mLoc.x < weaponName.Length + 1 + left)
                {
                    DrawRect(left, equiptopY + 3, width, Constants.COL_FRIENDLY);
                    hoveredItem  = equipment.weapon;
                    hoveredItemY = equiptopY + 3;

                    // was clicked, start dragging it
                    if (engine.mouseData.LeftButtonPressed)
                    {
                        parent.SetDragDrop(weaponName, equipment.weapon, OnDragDroppedEquippedItem);

                        parent.rangeIndicator.range = CombatEngine.GetThrowRange(player, equipment.weapon);
                        draggingItem = true;
                    }
                }

                DrawText(left, equiptopY + 2, "weapon: ", Constants.COL_NORMAL);
                DrawText(left, equiptopY + 3, " " + weaponName, TCODColor.white);
            }

            // pack adrea (general unequipped items) -------------------------------------
            int packtopY = invSection.starty;

            DrawText(0, packtopY, deviderLine, TCODColor.white);
            DrawText(left, packtopY, " pack ", Constants.COL_NORMAL);

            int line = 1;

            foreach (Entity item in inventory.items)
            {
                // get the screen name dynamically: TODO: maybe cache this?
                EGetScreenName getName    = (EGetScreenName)item.FireEvent(new EGetScreenName());
                string         screenName = getName.text;

                // check if the mouse is hovering on this item row
                if (mLoc.y == packtopY + line &&
                    mLoc.x >= left && mLoc.x < screenName.Length + 1 + left)
                {
                    hoveredItem  = item;
                    hoveredItemY = packtopY + line;

                    // highlight the item that is hovered on
                    DrawRect(left, packtopY + line, width, Constants.COL_FRIENDLY);

                    // check for clicks on this item, and start dragging it
                    if (engine.mouseData.LeftButtonPressed)
                    {
                        parent.SetDragDrop(screenName, item, OnDragDroppedInvItem);

                        // set the range indicator based on how far the dragged item can be thrown, in case the player dicides to throw its
                        parent.rangeIndicator.range = CombatEngine.GetThrowRange(player, item);
                        draggingItem = true;
                    }
                }

                DrawText(left, packtopY + line, screenName, TCODColor.white);
                DrawText(left - 1, packtopY + line, ">", Constants.COL_ATTENTION);

                line += 1;
            }

            // if there is a hovered item, open the item details window
            if (hoveredItem != null &&
                (!itemInfoWindow.isVisible || hoveredItem != itemInfoWindow.targetItem))
            {
                // move the window to the correct position, and open it for the new item
                itemInfoWindow.origin.y = hoveredItemY;
                itemInfoWindow.origin.x = origin.x - itemInfoWindow.console.getWidth();
                itemInfoWindow.OpenForItem(hoveredItem);
            }
            else if (hoveredItem == null && itemInfoWindow.isVisible)
            {
                itemInfoWindow.Close();
            }

            // tell the parent to draw the range indicator if the user is looking like they will drop the dragged item
            if (draggingItem)
            {
                if (!ScreenCoordInConsole(new Vector2(engine.mouseData.CellX, engine.mouseData.CellY)))
                {
                    parent.rangeIndicator.active = true;
                }
                else
                {
                    parent.rangeIndicator.active = false;
                }
            }

            return(console);
        }