Example #1
0
        /// <summary>
        /// Render
        /// </summary>
        public void Render()
        {
            var demo = (DemoReel)RB.Game;

            Vector2i labelSize = RB.PrintMeasure(mLabel);

            int yPos;

            if (mLabelBottomAligned)
            {
                yPos = mRect.y + mRect.height - labelSize.y - 4;
            }
            else
            {
                yPos = mRect.y + (mRect.height / 2) - (labelSize.y / 2);
            }

            if (mPressed)
            {
                RB.DrawRectFill(new Rect2i(mRect.x + 2, mRect.y + 2, mRect.width - 2, mRect.height - 2), DemoUtil.IndexToRGB(5));
                RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2) + 1, yPos + 1), DemoUtil.IndexToRGB(mLabelColor), mLabel);
            }
            else
            {
                RB.DrawRectFill(mRect, DemoUtil.IndexToRGB(mFaceColor));
                RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2), yPos), DemoUtil.IndexToRGB(mLabelColor), mLabel);
                RB.DrawRect(mRect, DemoUtil.IndexToRGB(5));
            }

            mHitRect = new Rect2i(-RB.CameraGet().x + mHotZone.x, -RB.CameraGet().y + mHotZone.y, mHotZone.width, mHotZone.height);
        }
Example #2
0
        /// <summary>
        /// Render
        /// </summary>
        public void Render()
        {
            Vector2i labelSize = RB.PrintMeasure(mLabel);

            int yPos;

            if (mLabelBottomAligned)
            {
                yPos = mRect.y + mRect.height - labelSize.y - 4;
            }
            else
            {
                yPos = mRect.y + (mRect.height / 2) - (labelSize.y / 2);
            }

            if (mPressed)
            {
                RB.DrawRectFill(new Rect2i(mRect.x + 2, mRect.y + 2, mRect.width - 2, mRect.height - 2), Color.gray);
                RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2) + 1, yPos + 1), Color.black, mLabel);
            }
            else
            {
                RB.DrawRectFill(mRect, Color.gray);
                RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2), yPos), Color.black, mLabel);
                RB.DrawRect(mRect, Color.white);
            }

            mHitRect = new Rect2i(-RB.CameraGet().x + mHotZone.x, -RB.CameraGet().y + mHotZone.y, mHotZone.width, mHotZone.height);
        }
Example #3
0
        private static void RenderMouseHover()
        {
            var tilePos = SceneGame.GetMouseTilePos();

            if (tilePos.x == -1)
            {
                return;
            }

            EntityFunctions.GetEntitiesStringAtTile(tilePos, C.FSTR);

            if (C.FSTR.Length > 0)
            {
                // Preserve camera location
                var cameraPos = RB.CameraGet();
                RB.CameraReset();

                var mousePos = RB.PointerPos();

                var anchorPos = new Vector2i(mousePos.x + 4, mousePos.y + 12);

                var textSize      = RB.PrintMeasure(C.FONT_SMALL, C.FSTR);
                var textRect      = new Rect2i(anchorPos.x, anchorPos.y, textSize.width, textSize.height);
                var textFrameRect = new Rect2i(textRect.x - 4, textRect.y - 4, textRect.width + 8, textRect.height + 8);

                RB.DrawRectFill(textFrameRect, C.COLOR_MENU_BACKGROUND);
                RB.DrawRect(textFrameRect, Color.white);
                RB.Print(C.FONT_SMALL, textRect, Color.white, 0, C.FSTR);

                RB.CameraSet(cameraPos);
            }
        }
Example #4
0
        /// <summary>
        /// Render the console
        /// </summary>
        public void Render()
        {
            var game = (RetroDungeoneerGame)RB.Game;

            var cameraPos = RB.CameraGet();

            RB.CameraReset();

            int yOffset = 0;
            var curLine = mLogLines.First;

            byte alpha = 255;

            // Keep looping and printing log lines until we the console max height
            while (yOffset < size.height && curLine != null && curLine.Value.Length > 0)
            {
                var lineSize = RB.PrintMeasure(game.assets.fontSmall, new Rect2i(0, 0, size.width, 9999), RB.TEXT_OVERFLOW_WRAP, curLine.Value);

                // Draw text
                RB.AlphaSet(alpha);
                RB.Print(game.assets.fontSmall, new Rect2i(4, RB.DisplaySize.height - yOffset - 4 - lineSize.height, size.width, 9999), Color.white, RB.TEXT_OVERFLOW_WRAP, curLine.Value);
                RB.AlphaSet(255);
                alpha -= 15;
                if (alpha < 15)
                {
                    alpha = 15;
                }

                yOffset += lineSize.height + 2;

                curLine = curLine.Next;
            }

            RB.CameraSet(cameraPos);
        }
Example #5
0
        private static void RenderUI(Player player, Menu menu)
        {
            var cameraPos = RB.CameraGet();

            RB.CameraReset();

            var barSize = new Vector2i(96, 12);
            var barPos  = new Vector2i(4, 4);

            RenderBar(barPos, barSize, player.Stats[StatTypes.HEALTH], player.Stats[StatTypes.MAX_HEALTH], C.HealthBarFG, C.HealthBarBG);
            RB.Print(new Rect2i(barPos.x, barPos.y, barSize.width, barSize.height), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, $"HP: {player.Stats[StatTypes.HEALTH]}/{player.Stats[StatTypes.MAX_HEALTH]}");

            RenderMessageLog();

            menu?.Render();

            RB.CameraSet(cameraPos);
        }
        /// <summary>
        /// Render the effect
        /// </summary>
        public override void Render()
        {
            var game = (RetroDungeoneerGame)RB.Game;

            var cameraPos = RB.CameraGet();

            var portalClipRect = new Rect2i(mPortal.e.pos.x * game.assets.spriteSheet.grid.cellSize.width, mPortal.e.pos.y * game.assets.spriteSheet.grid.cellSize.height, game.assets.spriteSheet.grid.cellSize.width, game.assets.spriteSheet.grid.cellSize.height);

            portalClipRect.x -= cameraPos.x;
            portalClipRect.y -= cameraPos.y;

            float rise = Ease.Interpolate(Ease.Func.QuadOut, 0.0f, 1.0f, mRiseTime);

            var portalPos    = new Vector2i(mPortal.e.pos.x * game.assets.spriteSheet.grid.cellSize.width, (mPortal.e.pos.y + (1.0f - rise)) * game.assets.spriteSheet.grid.cellSize.height);
            var portalCenter = new Vector2i(portalPos.x + (game.assets.spriteSheet.grid.cellSize.width / 2), (mPortal.e.pos.y * game.assets.spriteSheet.grid.cellSize.height) + game.assets.spriteSheet.grid.cellSize.height - 2);

            if (Random.Range(0, 10) == 0)
            {
                mShrinkLight = mShrinkLight == 0 ? 1 : 0;
            }

            var outerLightSize = new Vector2i((game.assets.spriteSheet.grid.cellSize.width * 2 * 0.8f) - mShrinkLight, (game.assets.spriteSheet.grid.cellSize.height * 0.8f) - mShrinkLight);
            var innerLightSize = new Vector2i((game.assets.spriteSheet.grid.cellSize.width * 2 * 0.5f) - mShrinkLight, (game.assets.spriteSheet.grid.cellSize.height * 0.5f) - mShrinkLight);

            outerLightSize *= rise;
            innerLightSize *= rise;

            RB.DrawEllipseFill(portalCenter, outerLightSize, new Color32(255, 255, 255, 32));
            RB.DrawEllipseFill(portalCenter, innerLightSize, new Color32(255, 255, 255, 32));

            if (mRiseTime != 1.0f)
            {
                Color32 color = new Color32(0x3c, 0xac, 0xd7, 255);

                RB.TintColorSet(color);

                RB.ClipSet(portalClipRect);
                RB.DrawSprite(S.PORTAL, portalPos);
                RB.ClipReset();
            }
        }
Example #7
0
        /// <summary>
        /// Render the game state
        /// </summary>
        /// <param name="gameState">Game state</param>
        /// <param name="player">Player</param>
        /// <param name="menu">Current menu</param>
        /// <param name="console">Console</param>
        public static void RenderAll(GameState gameState, EntityID player, Menu menu, Console console)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            RB.ShaderSet(C.SHADER_VIGNETTE);

            // Use a rect fill instead of RB.Clear() so that the shader will apply
            var cameraPos = RB.CameraGet();

            RB.CameraReset();
            RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height), game.map.backgroundColor);
            RB.CameraSet(cameraPos);

            RB.DrawMapLayer(C.LAYER_GRID);
            RB.DrawMapLayer(C.LAYER_TERRAIN);

            var previousTintColor = RB.TintColorGet();

            EffectManager.Instance.Render(RenderOrder.ACTOR_UNDERLAY_EFFECTS);

            foreach (var renderOrder in renderOrderList)
            {
                if (renderOrder == RenderOrder.HIDDEN)
                {
                    continue;
                }

                foreach (var entity in EntityStore.entities)
                {
                    if (renderOrder == RenderOrder.ACTOR_UNDERLAY_EFFECTS)
                    {
                        if (entity.e.moveTrail != null)
                        {
                            RenderTrail(entity);
                        }
                    }

                    if (entity.e.renderOrder == renderOrder)
                    {
                        RenderEntity(entity);
                    }
                }
            }

            EffectManager.Instance.Render(RenderOrder.ACTOR_OVERLAY_EFFECTS);

            RB.TintColorSet(previousTintColor);

            // Draw visibility layer on top, covering tiles as needed
            RB.DrawMapLayer(C.LAYER_VISIBILITY);

            RenderMapBorder();

            EffectManager.Instance.Render(RenderOrder.TOP_MOST);

            RB.ShaderReset();

            console.Render();

            RenderUI(gameState, menu, player);

            if (menu == null)
            {
                RenderMouseHover();
            }

            if (gameState == GameState.TARGETING)
            {
                RenderTargeting();
            }
        }
Example #8
0
        private static void RenderUI(GameState gameState, Menu menu, EntityID player)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            // Preserve camera location
            var cameraPos = RB.CameraGet();

            RB.CameraReset();

            var pe = player.e;

            var barSize = new Vector2i(96, 12);
            var barPos  = new Vector2i(RB.DisplaySize.width - barSize.width - 4, RB.DisplaySize.height - barSize.height - 4 - 10);

            RenderBar(
                barPos,
                barSize,
                "HP",
                pe.fighter.hp,
                pe.fighter.maxHp,
                new Color32(0xFF, 0x50, 0x50, 255),
                new Color32(0x50, 0x20, 0x20, 255),
                Color.white);

            if (game.map.dungeonLevel == 0 || game.map.dungeonLevel == 6)
            {
                RB.Print(C.FONT_SMALL, new Vector2i(barPos.x, barPos.y + barSize.height + 4), Color.white, C.FSTR.Set("Forest Clearing"));
            }
            else
            {
                RB.Print(C.FONT_SMALL, new Vector2i(barPos.x, barPos.y + barSize.height + 4), Color.white, C.FSTR.Set("Dungeon level: ").Append(game.map.dungeonLevel));
            }

            if (gameState == GameState.SHOW_INVENTORY || gameState == GameState.DROP_INVENTORY)
            {
                int itemsInInventory = 0;

                if (gameState == GameState.SHOW_INVENTORY)
                {
                    menu.SetSummary(C.FSTR.Set("Choose an item to use, or ESC to cancel."));
                }
                else
                {
                    menu.SetSummary(C.FSTR.Set("Choose an item to drop, or ESC to cancel."));
                }

                if (pe.inventory != null)
                {
                    menu.ClearOptions();

                    for (int i = 0; i < pe.inventory.items.Length; i++)
                    {
                        var item = pe.inventory.items[i].e;
                        if (item != null)
                        {
                            bool equipped = false;

                            if (pe.equipment != null)
                            {
                                equipped = pe.equipment.ContainsItem(item.id);
                            }

                            C.FSTR.Set(item.name);

                            if (item.equippable != null && (item.equippable.powerBonus != 0 || item.equippable.defenseBonus != 0))
                            {
                                C.FSTR.Append(" @707070(");

                                if (item.equippable.powerBonus != 0)
                                {
                                    if (item.equippable.powerBonus > 0)
                                    {
                                        C.FSTR.Append("+");
                                    }

                                    C.FSTR.Append(item.equippable.powerBonus).Append(" pwr");

                                    if (item.equippable.defenseBonus != 0)
                                    {
                                        C.FSTR.Append(" ");
                                    }
                                }

                                if (item.equippable.defenseBonus != 0)
                                {
                                    if (item.equippable.defenseBonus > 0)
                                    {
                                        C.FSTR.Append("+");
                                    }

                                    C.FSTR.Append(item.equippable.defenseBonus).Append(" def");
                                }

                                C.FSTR.Append(")");
                            }

                            if (equipped)
                            {
                                C.FSTR.Append(" @7070B0[equipped]@-");
                            }

                            menu.AddOption(C.FSTR);

                            itemsInInventory++;
                        }
                    }
                }

                if (itemsInInventory == 0)
                {
                    menu.SetSummary(C.FSTR.Set("Your inventory is empty. Press ESC to exit."));
                }

                menu.Render();
            }
            else if (menu != null)
            {
                menu.Render();
            }

            RB.CameraSet(cameraPos);
        }
Example #9
0
        private void DrawMouse(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y));

            int color1       = 4;
            int color2       = 3;
            int colorOutline = 0;

            RB.DrawEllipseFill(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(color1));
            RB.DrawEllipseFill(new Vector2i(26, 54), new Vector2i(26, 20), DemoUtil.IndexToRGB(color1));
            RB.DrawEllipse(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawEllipse(new Vector2i(26, 54), new Vector2i(26, 20), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(0, 15, 53, 54 - 15), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRectFill(new Rect2i(1, 15, 53 - 2, 54 - 15), DemoUtil.IndexToRGB(color1));

            RB.DrawLine(new Vector2i(52 / 3, 2), new Vector2i(52 / 3, 30), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawLine(new Vector2i(52 / 3 * 2, 2), new Vector2i(52 / 3 * 2, 30), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawLine(new Vector2i(0, 30), new Vector2i(52, 30), DemoUtil.IndexToRGB(colorOutline));

            if (RB.ButtonDown(RB.BTN_POINTER_A))
            {
                RB.ClipSet(new Rect2i(-RB.CameraGet().x + 1, -RB.CameraGet().y, (52 / 3) - 1, 30));
                RB.DrawEllipseFill(new Vector2i(26, 16), new Vector2i(26, 15), DemoUtil.IndexToRGB(5));
                RB.DrawEllipse(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(colorOutline));
                RB.DrawRectFill(new Rect2i(1, 15, 53 - 2, 54 - 15), DemoUtil.IndexToRGB(5));
                RB.ClipReset();
            }

            if (RB.ButtonDown(RB.BTN_POINTER_B))
            {
                RB.ClipSet(new Rect2i(-RB.CameraGet().x + 35, -RB.CameraGet().y, 52 / 3, 30));
                RB.DrawEllipseFill(new Vector2i(26, 16), new Vector2i(26, 15), DemoUtil.IndexToRGB(5));
                RB.DrawEllipse(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(colorOutline));
                RB.DrawRectFill(new Rect2i(1, 15, 53 - 2, 54 - 15), DemoUtil.IndexToRGB(5));
                RB.ClipReset();
            }

            if (RB.ButtonDown(RB.BTN_POINTER_C))
            {
                RB.ClipSet(new Rect2i(-RB.CameraGet().x + 18, -RB.CameraGet().y, (52 / 3) - 1, 30));
                RB.DrawEllipseFill(new Vector2i(26, 16), new Vector2i(26, 15), DemoUtil.IndexToRGB(5));
                RB.DrawEllipse(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(colorOutline));
                RB.DrawRectFill(new Rect2i(1, 15, 53 - 2, 54 - 15), DemoUtil.IndexToRGB(5));
                RB.ClipReset();
            }

            if (RB.ButtonDown(RB.BTN_POINTER_A))
            {
                RB.Print(new Vector2i(9, 16), DemoUtil.IndexToRGB(colorOutline), "A");
            }
            else
            {
                RB.Print(new Vector2i(8, 15), DemoUtil.IndexToRGB(colorOutline), "A");
            }

            if (RB.ButtonDown(RB.BTN_POINTER_C))
            {
                RB.Print(new Vector2i(25, 16), DemoUtil.IndexToRGB(colorOutline), "C");
            }
            else
            {
                RB.Print(new Vector2i(24, 15), DemoUtil.IndexToRGB(colorOutline), "C");
            }

            if (RB.ButtonDown(RB.BTN_POINTER_B))
            {
                RB.Print(new Vector2i(41, 16), DemoUtil.IndexToRGB(colorOutline), "B");
            }
            else
            {
                RB.Print(new Vector2i(40, 15), DemoUtil.IndexToRGB(colorOutline), "B");
            }

            RB.DrawRectFill(new Rect2i(23, 36, 8, 24), DemoUtil.IndexToRGB(color2));
            int barSize = (int)(6 * mScrollDeltaAnim / 2.0f);

            barSize = Mathf.Clamp(barSize, -12, 12);

            if (barSize > 0)
            {
                RB.DrawRectFill(new Rect2i(23, 48 - barSize, 8, barSize), DemoUtil.IndexToRGB(5));
            }
            else if (barSize < 0)
            {
                RB.DrawRectFill(new Rect2i(23, 48, 8, -barSize), DemoUtil.IndexToRGB(5));
            }

            RB.DrawRect(new Rect2i(23, 36, 8, 24), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawLine(new Vector2i(24, 48), new Vector2i(29, 48), DemoUtil.IndexToRGB(colorOutline));

            RB.CameraReset();
        }