Esempio n. 1
0
    public override void Render()
    {
        Rect2i rect = new Rect2i(pos, size);

        RB.DrawRectFill(rect, boxBackgroundColor);
        RB.DrawRect(rect, boxOutlineColor);
        rect.Expand(-4);
        if ((effect & Shadow) == Shadow)
        {
            RB.Print(rect.Offset(new Vector2i(1, 1)), Color.black, RB.NO_INLINE_COLOR | flags, text);
        }
        else
        if ((effect & Outline) == Outline)
        {
            for (int dx = -1; dx <= 1; dx++)
            {
                for (int dy = -1; dy <= 1; dy++)
                {
                    RB.Print(rect.Offset(new Vector2i(dx, dy)), Color.black, RB.NO_INLINE_COLOR | flags, text);
                }
            }
        }
        RB.Print(rect, color, flags, text);
        foreach (TextButton button in buttons)
        {
            button.Render();
        }
    }
Esempio n. 2
0
    public override void Render()
    {
        if (!isVisible)
        {
            return;
        }
        bool highlight = currentState == State.Hovered || currentState == State.Pressed;
        bool disabled  = currentState == State.Disabled || blocked;

        RB.DrawRectFill(new Rect2i(pos, size), currentState == State.Pressed ? Color.yellow : disabled ? Color.gray : Color.white);

        RB.Print(pos + new Vector2i(2, 2), Color.black, spell.GetName());

        ElementDisplay[] displays = spell.GetElementDisplays(RollContext.Null);
        int px = pos.x + 2;
        int py = pos.y + size.height - 18;

        for (int i = 0; i < displays.Length; i++)
        {
            displays[i].Render(px + i * 18, py);
        }

        if (highlight)
        {
            RB.DrawRect(new Rect2i(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2), Color.yellow);
        }
        else
        {
            RB.DrawRect(new Rect2i(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2), Color.black);
        }
    }
Esempio n. 3
0
    private void RenderCard(int xPos, int w, LobbyPlayer player, bool self)
    {
        int topLeftX = xPos - w / 2 + 2;
        int topLeftY = 32;

        RB.DrawRectFill(new Rect2i(topLeftX - 1, topLeftY - 1, new Vector2i(w, size.height - 90)), Color.black);
        RB.DrawRectFill(new Rect2i(topLeftX - 2, topLeftY - 2, new Vector2i(w, size.height - 90)), Color.green);
        RB.DrawRect(new Rect2i(topLeftX, topLeftY, new Vector2i(w - 4, size.height - 94)), Color.gray);
        if (self)
        {
            if (!nameInput.isVisible)
            {
                nameInput.SetText(player.charName);
            }
            readyButton.isVisible     = true;
            nameInput.isVisible       = true;
            prevClassButton.isVisible = true;
            nextClassButton.isVisible = true;
        }
        else
        {
            RB.Print(new Rect2i(topLeftX + 1, topLeftY + 49, w - 4, 12), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_TOP, player.charName);
            RB.Print(new Rect2i(topLeftX, topLeftY + 48, w - 4, 12), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_TOP, player.charName);
            RB.Print(new Vector2i(xPos - 26, topLeftY + size.height - 115), Color.black, RB.NO_INLINE_COLOR, "Ready?");
            RB.Print(new Vector2i(xPos - 27, topLeftY + size.height - 116), Color.white, "Ready?");
        }

        RB.Print(new Rect2i(topLeftX + 11, topLeftY + 71, w - 24, 20), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, DB.Classes[player.charClass].GetName());
        RB.Print(new Rect2i(topLeftX + 10, topLeftY + 70, w - 24, 20), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, DB.Classes[player.charClass].GetName());
        RB.DrawEllipseFill(new Vector2i(xPos + 16, topLeftY - 2 + size.height - 110), new Vector2i(5, 5), Color.black);
        RB.DrawEllipseFill(new Vector2i(xPos + 15, topLeftY - 3 + size.height - 110), new Vector2i(5, 5), player.ready ? Color.green : Color.red);
        RB.DrawEllipse(new Vector2i(xPos + 15, topLeftY - 3 + size.height - 110), new Vector2i(5, 5), Color.white);
    }
Esempio n. 4
0
        private void DrawInputString(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            int width  = 612;
            int height = 32;

            RB.DrawRect(new Rect2i(0, 0, width, height), DemoUtil.IndexToRGB(25));
            RB.DrawRectFill(new Rect2i(1, 1, width - 2, height - 2), DemoUtil.IndexToRGB(27));

            RB.ClipSet(new Rect2i(x + 4, y + 4, width - 8, height - 2));

            if (RB.Ticks % 30 < 15)
            {
                RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(23), RB.NO_ESCAPE_CODES, mInputString);
            }
            else
            {
                mInputString.Append('|');
                RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(23), RB.NO_ESCAPE_CODES, mInputString);
                mInputString.Truncate(mInputString.Length - 1);
            }

            RB.CameraReset();

            RB.ClipReset();
        }
Esempio n. 5
0
        private void DrawGamepadDPad(int x, int y, int pressedMask, int color, int colorOutline)
        {
            var demo = (DemoReel)RB.Game;

            int pressedColor = 5;
            int size         = 10;

            RB.DrawRect(new Rect2i(x + size, y, size, size * 3), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(x, y + size, size * 3, size), DemoUtil.IndexToRGB(colorOutline));

            RB.DrawRectFill(new Rect2i(x + size + 1, y + 1, size - 2, (size * 3) - 2), DemoUtil.IndexToRGB(color));
            RB.DrawRectFill(new Rect2i(x + 1, y + size + 1, (size * 3) - 2, size - 2), DemoUtil.IndexToRGB(color));

            // Up
            mFormatStr.Set((char)127);
            RB.DrawRectFill(new Rect2i(x + size + 1, y + 1, size - 2, size), (pressedMask & RB.BTN_UP) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color));
            RB.Print(new Vector2i(x + size + (size / 2) - 3, y + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr);

            // Down
            mFormatStr.Set((char)128);
            RB.DrawRectFill(new Rect2i(x + size + 1, y + (size * 2) - 1, size - 2, size), (pressedMask & RB.BTN_DOWN) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color));
            RB.Print(new Vector2i(x + size + (size / 2) - 3, y + 2 + (size * 2)), DemoUtil.IndexToRGB(colorOutline), mFormatStr);

            // Left
            mFormatStr.Set((char)129);
            RB.DrawRectFill(new Rect2i(x + 1, y + size + 1, size, size - 2), (pressedMask & RB.BTN_LEFT) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color));
            RB.Print(new Vector2i(x + 2, y + size + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr);

            // Right
            mFormatStr.Set((char)130);
            RB.DrawRectFill(new Rect2i(x + (size * 2) - 1, y + size + 1, size, size - 2), (pressedMask & RB.BTN_RIGHT) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color));
            RB.Print(new Vector2i(x + (size * 2) + 3, y + size + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public virtual void Render()
        {
            var display = RB.DisplaySize;

            var menuRect    = new Rect2i(display.width / 2 - MENU_WIDTH / 2, display.height / 2, MENU_WIDTH, 24);
            var summarySize = RB.PrintMeasure(menuRect, RB.ALIGN_H_CENTER | RB.TEXT_OVERFLOW_WRAP, Summary);

            menuRect.height += summarySize.height;

            // header
            var headerSize = RB.PrintMeasure(Header);

            headerSize.width += 8;
            var headerRect = new Rect2i(menuRect.x + menuRect.width / 2 - headerSize.width / 2, menuRect.y - 6, headerSize.width,
                                        MIN_HEADER_HEIGHT);

            var summaryRect = new Rect2i(menuRect.x + BORDER_PADDING, menuRect.y + BORDER_PADDING + 8, menuRect.width - BORDER_PADDING, menuRect.height - BORDER_PADDING);

            RB.DrawRectFill(menuRect, C.MenuBG);
            RB.DrawRect(menuRect, Color.white);
            RB.DrawRectFill(headerRect, Color.black);
            RB.DrawRect(headerRect, Color.white);
            RB.Print(headerRect, Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, Header);
            RB.Print(summaryRect, Color.white, SummaryPrintFlags, Summary);
        }
Esempio n. 8
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);
            }
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
    public override void Render()
    {
        if (!isVisible)
        {
            return;
        }
        bool highlight = currentState == State.Hovered || currentState == State.Pressed;

        RB.DrawRectFill(new Rect2i(pos, size), currentState == State.Pressed ? Color.yellow : castable ? Color.white : Color.cyan);

        RB.Print(pos + new Vector2i(2, 2), Color.black, spell.GetName());

        ElementDisplay[] displays = spell.GetElementDisplays(battle.BuildContext(screen.GetCurrentTargetPawnId()));
        int px = pos.x + 2;
        int py = pos.y + size.height - 18;

        for (int i = 0; i < displays.Length; i++)
        {
            displays[i].Render(px + i * 18, py);
        }

        if (highlight)
        {
            RB.DrawRect(new Rect2i(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2), Color.yellow);
        }
        else
        {
            RB.DrawRect(new Rect2i(pos.x - 1, pos.y - 1, size.x + 2, size.y + 2), Color.black);
        }
    }
Esempio n. 11
0
        /// <summary>
        /// Render
        /// </summary>
        public void Render()
        {
            if (mAlpha <= 0)
            {
                return;
            }

            RB.TintColorSet(ColorTint);

            byte prevAlpha = RB.AlphaGet();

            RB.AlphaSet((byte)(mAlpha * prevAlpha));

            int LifeFrame = 5 - (int)(((float)Life / (float)MaxLife) * 5);

            if (Type != BrickType.Block)
            {
                LastSpriteRect = new Rect2i(Global.BRICK_WIDTH * LifeFrame, 0, Rect.width, Rect.height);
            }
            else
            {
                LastSpriteRect = new Rect2i(120, 0, 20, 10);
            }

            RB.DrawCopy(LastSpriteRect, Rect);

            for (int i = 0; i < FlashFrame; i++)
            {
                RB.DrawRect(new Rect2i(Rect.x + i, Rect.y + i, Rect.width - (i * 2), Rect.height - (i * 2)), Color.white);
            }

            RB.TintColorSet(Color.white);

            RB.AlphaSet(prevAlpha);
        }
Esempio n. 12
0
    public override void Render()
    {
        if (!isVisible)
        {
            return;
        }
        int off = 0;

        if (currentState != State.Pressed)
        {
            RB.DrawRectFill(new Rect2i(pos.x + 1, pos.y + 1, size.x - 1, size.y - 1), Color.black);
        }
        else
        {
            off = 1;
        }
        Color backgroundHighlight = Color.white;
        Color backgroundDefault   = Color.gray;
        Color foregroundHighlight = Color.yellow;
        Color foregroundDefault   = Color.white;
        bool  highlight           = currentState == State.Hovered || currentState == State.Pressed;

        RB.DrawRectFill(new Rect2i(pos.x + off, pos.y + off, size.x - 1, size.y - 1), highlight ? backgroundHighlight : backgroundDefault);
        RB.DrawRect(new Rect2i(pos.x + 1 + off, pos.y + 1 + off, size.width - 3, size.height - 3), highlight ? foregroundHighlight : foregroundDefault);
        RB.Print(new Vector2i(pos.x + 4 + off, pos.y + 4 + off), Color.black, RB.NO_INLINE_COLOR, text);
        if (currentState != State.Disabled)
        {
            RB.Print(new Vector2i(pos.x + 3 + off, pos.y + 3 + off), highlight ? foregroundHighlight : foregroundDefault, text);
        }
    }
Esempio n. 13
0
        private void DrawTMX()
        {
            var demo = (DemoReel)RB.Game;

            int    spriteFrame   = (RB.Ticks % 40) > 20 ? 1 : 0;
            Rect2i clipRect      = new Rect2i(0, 0, 0, 0);
            int    cameraYOffset = 0;
            int    cameraXOffset = 0;
            int    cameraYRange  = 16;

            if (mStyle == RB.PixelStyle.Wide)
            {
                clipRect = new Rect2i((RB.DisplaySize.width / 2) - 100, RB.DisplaySize.height - 220, 200, 200);
            }
            else if (mStyle == RB.PixelStyle.Tall)
            {
                clipRect      = new Rect2i((RB.DisplaySize.width / 2) - 200, RB.DisplaySize.height - 110, 400, 100);
                cameraYOffset = 150;
                cameraXOffset = -120;
                cameraYRange  = 8;
            }

            if (mMap != null)
            {
                int      scrollPos = -(int)RB.Ticks % (mMapSize.width * RB.SpriteSize().width);
                Vector2i cameraPos = new Vector2i((int)((Mathf.Sin(RB.Ticks / 100.0f) * 420) + 450 + cameraXOffset), (int)((Mathf.Sin(RB.Ticks / 10.0f) * cameraYRange) + cameraYOffset));

                RB.ClipSet(clipRect);
                RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22));

                RB.CameraSet(cameraPos);
                RB.DrawMapLayer(0, new Vector2i(scrollPos, 0));
                RB.DrawMapLayer(0, new Vector2i(scrollPos + (mMapSize.width * RB.SpriteSize().width), 0));
                RB.DrawMapLayer(1);
                RB.DrawMapLayer(2);
                RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16));
                RB.DrawSprite(RB.SpriteIndex(6, 10) + spriteFrame, new Vector2i(67 * 16, 14 * 16));
                RB.CameraReset();
            }
            else
            {
                RB.Print(new Vector2i(clipRect.x + 2, clipRect.y + 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map\nDemos/DemoReel/Tilemap.tmx in Unity");
            }

            RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21));

            RB.ClipReset();

            mFormatStr.Set("@C// Use ").Append(mStyle == RB.PixelStyle.Wide ? "wide" : "tall").Append(" pixel format\n");
            mFormatStr.Append("@Kpublic @MHardwareSettings @NQueryHardware() {\n");
            mFormatStr.Append("   @Kvar @Nhw = @Knew @MHardwareSettings@N();\n");
            mFormatStr.Append("   @Nhw.DisplaySize = @Knew @MVector2i@N(@L").Append(RB.DisplaySize.width).Append("@N, @L").Append(RB.DisplaySize.height).Append("@N);\n");
            mFormatStr.Append("   @Nhw.PixelStyle = @KRetroBlit@N.@EPixelStyle@N.").Append(mStyle == RB.PixelStyle.Wide ? "Wide" : "Tall").Append(";\n");
            mFormatStr.Append("   @Kreturn @Nhw;\n");
            mFormatStr.Append("}");

            RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
Esempio n. 14
0
        private void DrawTMX(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            Rect2i   clipRect    = new Rect2i(x + 16, y + 142, 310, 207);
            Vector2i cameraPos   = new Vector2i((int)(Mathf.Sin(RB.Ticks / 100.0f) * 450) + 200, (int)Mathf.Sin(RB.Ticks / 10.0f) * 16);
            int      spriteFrame = (RB.Ticks % 40) > 20 ? 1 : 0;

            if (mMap != null && mMap.status == RB.AssetStatus.Ready)
            {
                int scrollPos = -(int)RB.Ticks % (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width);

                RB.ClipSet(clipRect);
                RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22));

                RB.CameraSet(cameraPos);

                RB.DrawMapLayer(1, new Vector2i(scrollPos, 0));
                RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width), 0));
                RB.DrawMapLayer(2);
                RB.DrawMapLayer(3);
                RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16));
                RB.DrawSprite(RB.SpriteIndex(6, 10) + spriteFrame, new Vector2i(67 * 16, 14 * 16));
            }
            else
            {
                RB.CameraReset();
                RB.ClipReset();
                RB.Print(new Vector2i(x + 18, y + 144), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity");
            }

            RB.CameraReset();
            RB.ClipReset();
            RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21));

            mMap.Load("Demos/DemoReel/Tilemap");

            mFormatStr.Set("@C// Load a map from a TMX file\n");
            mFormatStr.Append("@NmyTMXMap.Load(@S\"Demos/Demo/Tilemap\"@N);\n");
            mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Clouds\"@N, @L1@N);\n");
            mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Decoration\"@N, @L2@N);\n");
            mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Terrain\"@N, @L3@N);\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N));\n");
            mFormatStr.Append("@[email protected](@Knew@N @MRect2i@N(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N), @I22);\n");
            mFormatStr.Append("@[email protected](@Knew @MVector2i@N(@L").Append(cameraPos.x).Append("@N, @L").Append(cameraPos.y).Append("@N));\n");
            mFormatStr.Append("@Kint@N pos = @L").Append(-(int)RB.Ticks).Append("@N % (myMap.size.width * @[email protected]);\n");
            mFormatStr.Append("@[email protected](@L1@N, @Knew @MVector2i@N(pos, @L0@N));\n");
            mFormatStr.Append("@[email protected](@L1@N, @Knew @MVector2i@N(pos + (myMap.size.width * @[email protected])), @L0@N));\n");
            mFormatStr.Append("@[email protected](@L2@N);\n");
            mFormatStr.Append("@[email protected](@L3@N);\n");
            mFormatStr.Append("@[email protected](@L").Append(0 + spriteFrame).Append("@N, @Knew@N @MVector2i@N(@L").Append(13 * 16).Append("@N, @L").Append(16 * 16).Append("@N));\n");
            mFormatStr.Append("@[email protected](@L").Append(RB.SpriteIndex(6, 10) + spriteFrame).Append("@N, @Knew @MVector2i@N(@L").Append(67 * 16).Append("@N, @L").Append(14 * 16).Append("@N));\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N), @I21);\n");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
        /// <summary>
        /// Render
        /// </summary>
        public override void Render()
        {
            var demo = (DemoReel)RB.Game;

            RB.Clear(DemoUtil.IndexToRGB(22));

            int spriteFrame = ((int)RB.Ticks % 40) > 20 ? 1 : 0;

            if (mMap != null)
            {
                RB.DrawMapLayer(0);
                RB.DrawMapLayer(1);
            }

            RB.EffectSet(RB.Effect.Noise, 0.15f);
            RB.EffectSet(RB.Effect.Scanlines, 1.0f);
            RB.EffectSet(RB.Effect.Desaturation, (Mathf.Sin(RB.Ticks / 50.0f) * 0.5f) + 0.5f);

            RB.EffectApplyNow();
            RB.EffectReset();

            if (mMap != null)
            {
                RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16));
            }
            else
            {
                RB.Print(new Vector2i(2, 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity");
            }

            mFormatStr.Set("@C// Specify when post-processing effects should be applied\n");
            mFormatStr.Append("@[email protected](@L0@N);\n");
            mFormatStr.Append("@[email protected](@L1@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L0.15f@N);\n");
            mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L1.0f@N);\n");
            mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L").Append((Mathf.Sin(RB.Ticks / 50.0f) * 0.5f) + 0.5f, 2).Append("f@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](@L").Append(0 + spriteFrame).Append("@N, @Knew@N Vector2i(@L").Append(13 * 16).Append("@N, @L").Append(16 * 16).Append("@N));");

            var size = RB.PrintMeasure(DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            size.x += 4;
            size.y += 4;

            var rect = new Rect2i((RB.DisplaySize.width / 2) - (size.x / 2), (RB.DisplaySize.height / 2) - (size.y / 2), size.x, size.y);

            rect.y -= 64;

            RB.DrawRectFill(rect, DemoUtil.IndexToRGB(1));
            RB.DrawRect(rect, DemoUtil.IndexToRGB(4));
            RB.Print(new Vector2i(rect.x + 2, rect.y + 2), DemoUtil.IndexToRGB(0), mFinalStr);
        }
        private void DrawTilemap(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.Offscreen(spriteSheet1);
            RB.SpriteSheetSet(spriteSheet2);
            mWaveOffset = (int)((RB.Ticks / 2) % 16);
            mFishFrame  = (int)((RB.Ticks / 6) % 32);
            RB.DrawCopy(new Rect2i(mWaveOffset, 0, RB.SpriteSheetGet().grid.cellSize), new Vector2i(48, 192));
            RB.Clear(new Color32(0, 0, 0, 0), new Rect2i(80, 192, RB.SpriteSheetGet().grid.cellSize));
            if (mFishFrame < 7)
            {
                RB.DrawCopy(new Rect2i(mFishFrame * RB.SpriteSheetGet().grid.cellSize.width, RB.SpriteSheetGet().grid.cellSize.height, RB.SpriteSheetGet().grid.cellSize), new Vector2i(80, 192));
            }

            RB.Onscreen();

            Rect2i clipRect = new Rect2i(x, y + (RB.DisplaySize.height / 2) - 8, 632, 180);

            if (mMap != null)
            {
                RB.ClipSet(clipRect);
                RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22));

                RB.CameraSet(new Vector2i(0, 0));
                RB.DrawMapLayer(2);
                RB.DrawMapLayer(3);

                RB.TintColorSet(Color.black);
                RB.AlphaSet(32);
                int scrollPos = -(int)RB.Ticks % (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width);
                RB.DrawMapLayer(1, new Vector2i(scrollPos + 8, 8));
                RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width) + 8, 8));
                RB.TintColorSet(Color.white);

                RB.AlphaSet(196);
                RB.DrawMapLayer(1, new Vector2i(scrollPos, 0));
                RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width), 0));
                RB.AlphaSet(255);

                RB.CameraReset();

                RB.ClipReset();
                RB.SpriteSheetSet(spriteSheet1);
            }
            else
            {
                RB.Print(new Vector2i(clipRect.x + 2, clipRect.y + 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/TilemapOcean.tmx in Unity");
            }

            RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21));
        }
Esempio n. 17
0
        private void DrawPiano(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            mFormatStr.Set("@C// Play sound at specific volume and pitch\n");
            mFormatStr.Append("@NsoundC5Note.Load(@S\"Demos/Demo/C5Note\"@N);\n");
            mFormatStr.Append("@[email protected](soundC5Note, @L0.@L5f@N, @L1.@L2f@N);\n");

            RB.Print(new Vector2i(0, 0), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

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

            Rect2i pianoRect = mPianoRect;
            Rect2i holeRect  = pianoRect;

            pianoRect = pianoRect.Expand(8);
            holeRect  = holeRect.Expand(2);

            int cornerSize = 8;

            RB.DrawEllipseFill(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawRect(new Rect2i(pianoRect.x + cornerSize, pianoRect.y, pianoRect.width - (cornerSize * 2), pianoRect.height), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(pianoRect.x + cornerSize, pianoRect.y + 1, pianoRect.width - (cornerSize * 2), pianoRect.height - 2), DemoUtil.IndexToRGB(3));

            RB.DrawRect(new Rect2i(pianoRect.x, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(pianoRect.x + 1, pianoRect.y + cornerSize, cornerSize - 1, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3));

            RB.DrawRect(new Rect2i(pianoRect.x + pianoRect.width - cornerSize, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3));

            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(2));

            for (int i = 0; i < mPianoButtons.Length; i++)
            {
                mPianoButtons[i].Render();
            }

            RB.CameraReset();
        }
Esempio n. 18
0
        private void DrawTextFrame(Rect2i rect, FastString subTitle)
        {
            var demo = (DemoReel)RB.Game;

            RB.DrawRectFill(rect, DemoUtil.IndexToRGB(1));
            RB.DrawRect(rect, DemoUtil.IndexToRGB(2));

            if (subTitle != null)
            {
                var subTitleRect = new Rect2i(rect.x, rect.y + rect.height + 5, rect.width, rect.height);
                RB.Print(subTitleRect, DemoUtil.IndexToRGB(3), RB.ALIGN_H_CENTER | RB.TEXT_OVERFLOW_WRAP, subTitle);
            }
        }
Esempio n. 19
0
        private void DrawGamepadShoulder(int x, int y, string label, bool pressed, int color, int colorOutline)
        {
            var demo = (DemoReel)RB.Game;

            int faceColor = pressed ? 5 : color;
            int offset    = pressed ? 3 : 0;

            RB.DrawRectFill(new Rect2i(x, y + offset + 1, 16, 12), DemoUtil.IndexToRGB(faceColor));
            RB.DrawRect(new Rect2i(x + 1, y + offset, 14, 1), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(x, y + offset + 1, 1, 12), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(x + 15, y + offset + 1, 1, 12), DemoUtil.IndexToRGB(colorOutline));

            RB.Print(new Vector2i(x + 4, y + 2 + offset), DemoUtil.IndexToRGB(colorOutline), label);
        }
Esempio n. 20
0
        /// <summary>
        /// Draw output frame
        /// </summary>
        /// <param name="rect">Rectangle</param>
        /// <param name="frameOuter">Outer frame color</param>
        /// <param name="frameInner">Inner frame color</param>
        /// <param name="fillColorIndex">Fill color</param>
        public static void DrawOutputFrame(Rect2i rect, int frameOuter, int frameInner, int fillColorIndex)
        {
            var demo = (DemoReel)RB.Game;

            if (frameOuter != -1)
            {
                RB.DrawRect(new Rect2i(rect.x - 2, rect.y - 2, rect.width + 4, rect.height + 4), IndexToRGB(frameOuter));
            }

            if (frameInner != -1)
            {
                RB.DrawRect(new Rect2i(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2), IndexToRGB(frameInner));
            }

            RB.DrawRectFill(rect, IndexToRGB(fillColorIndex));
        }
Esempio n. 21
0
        /// <summary>
        /// Run the stress test
        /// </summary>
        protected override void StressTest()
        {
            var game = (StressTest)RB.Game;

            Random.InitState(0);

            for (int i = 0; i < mStressLevel; i++)
            {
                var wiggle = GetWiggle();

                var randRect = new Rect2i(
                    (int)(Random.Range(-game.spriteSheet.grid.cellSize.width * 0.75f, RB.DisplaySize.width - (game.spriteSheet.grid.cellSize.width * 0.25f)) + wiggle.x),
                    (int)(Random.Range(-game.spriteSheet.grid.cellSize.height * 0.75f, RB.DisplaySize.height - (game.spriteSheet.grid.cellSize.height * 0.25f)) + wiggle.y),
                    Random.Range(8, 64),
                    Random.Range(8, 64));

                int type = Random.Range(0, 5);
                if (type == 0)
                {
                    RB.DrawLine(new Vector2i(randRect.x, randRect.y), new Vector2i(randRect.x + randRect.width, randRect.y + randRect.height), mRandomColor[i]);
                }
                else if (type == 1)
                {
                    RB.DrawRect(randRect, mRandomColor[i]);
                }
                else if (type == 2)
                {
                    RB.DrawRectFill(randRect, mRandomColor[i]);
                }
                else if (type == 3)
                {
                    RB.DrawTriangleFill(
                        new Vector2i(randRect.x, randRect.y),
                        new Vector2i(randRect.x + randRect.width, randRect.y),
                        new Vector2i(randRect.x + (randRect.width / 2), randRect.y + randRect.height),
                        mRandomColor[i]);
                }
                else if (type == 4)
                {
                    RB.DrawTriangle(
                        new Vector2i(randRect.x, randRect.y),
                        new Vector2i(randRect.x + randRect.width, randRect.y),
                        new Vector2i(randRect.x + (randRect.width / 2), randRect.y + randRect.height),
                        mRandomColor[i]);
                }
            }
        }
Esempio n. 22
0
    public static void Render(int x, int y, Element element, bool large = false, bool optional = false, int extension = -1)
    {
        if (element == null)
        {
            return;
        }
        string name = element.GetName();

        if (!large)
        {
            name = name.Substring(0, 1);
        }
        Rect2i rect      = new Rect2i(x, y, large ? 32 : 16, large ? 32 : 16);
        Rect2i innerRect = new Rect2i(x + (large ? 10 : 2), y + (large ? 4 : 2), 12, 12);

        if (optional || extension >= 0)
        {
            RB.AlphaSet(127);
        }
        RB.DrawRectFill(rect, Color.black);
        RB.DrawRectFill(rect.Expand(-1), Color.white);
        RB.AlphaSet(255);
        RB.DrawSprite(element.GetName(), innerRect);
        if (extension > 0)
        {
            Vector2i measure = RB.PrintMeasure(extension.ToString());
            Rect2i   extRect = new Rect2i(rect.x + rect.width, rect.y + rect.height / 2 - measure.height / 2, measure).Offset(new Vector2i(1, 0));
            extRect.Expand(2);
            RB.DrawRectFill(extRect, Color.white);
            RB.DrawRect(extRect, Color.black);
            RB.Print(extRect, Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, extension.ToString());
        }
        if (large)
        {
            rect = rect.Offset(new Vector2i(0, 8));
            rect.Expand(0, -4);
            for (int dx = -1; dx <= 1; dx++)
            {
                for (int dy = -1; dy <= 1; dy++)
                {
                    RB.Print(rect.Offset(new Vector2i(dx, dy)), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, name);
                }
            }
            RB.Print(rect, element.GetColor(), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, name);
        }
    }
Esempio n. 23
0
    public override void RenderForeground()
    {
        for (int i = 0; i < battle.rolls.Length; i++)
        {
            if (battle.locks[i])
            {
                RB.DrawSprite("Lock", lockPositions[i] - new Vector2i(6, 6));
                //RB.Print(new Rect2i(lockPositions[i] - new Vector2i(16, 8), new Vector2i(32, 16)), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, "Locked");
            }
        }

        for (int i = 0; i < battle.rollsLeft; i++)
        {
            RB.DrawEllipseFill(new Vector2i(size.x / 5 - 10 + i * 10, size.y / 2 + 44), new Vector2i(4, 4), Color.white);
            RB.DrawEllipse(new Vector2i(size.x / 5 - 10 + i * 10, size.y / 2 + 44), new Vector2i(4, 4), Color.black);
        }

        if (infoPane.GetOpenTabIndex() == 1)
        {
            ElementDisplay[] displays = viewedSpell.GetElementDisplays(battle.BuildContext());
            for (int i = 0; i < displays.Length; i++)
            {
                displays[i].Render(size.width / 2 + 5 + i * 18, size.height - 50);
            }
        }

        if (renderTargeting)
        {
            if (targetPawn != null)
            {
                RB.AlphaSet(96);
                RB.DrawRectFill(new Rect2i(0, 0, size), Color.black);
                RB.AlphaSet(255);
                pawnCards[targetPawn].Render();
                RB.DrawRect(targetRect, Color.yellow);
                RB.DrawPixel(targetPoint - new Vector2i(1, 0), Color.white);
                //RB.DrawRect(targetRect.Offset(new Vector2i(0, 0)).Expand(1), Color.black);
                originButton.Render();
            }
            RB.DrawPixel(originPoint + new Vector2i(1, 0), Color.white);
            //RB.DrawRect(new Rect2i(originButton.pos, originButton.size).Expand(2), Color.black);
            RB.DrawLine(originPoint + new Vector2i(0, 1), targetPoint + new Vector2i(0, 1), Color.yellow);
            RB.DrawLine(originPoint, targetPoint, Color.white);
            RB.DrawLine(originPoint - new Vector2i(0, 1), targetPoint - new Vector2i(0, 1), Color.yellow);
        }
    }
Esempio n. 24
0
        private void DrawGamepadSystem(int x, int y, bool pressed, int color, int colorOutline)
        {
            var demo = (DemoReel)RB.Game;

            int faceColor = pressed ? 5 : color;

            RB.DrawEllipseFill(new Vector2i(x, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(faceColor));
            RB.DrawEllipseFill(new Vector2i(x + 6, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(faceColor));

            RB.DrawEllipse(new Vector2i(x, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawEllipse(new Vector2i(x + 6, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(x - 1, y - 7, 10, 15), DemoUtil.IndexToRGB(colorOutline));

            RB.DrawRectFill(new Rect2i(x - 1, y - 6, 10, 13), DemoUtil.IndexToRGB(faceColor));

            RB.Print(new Vector2i(x - 4, y - 3), DemoUtil.IndexToRGB(colorOutline), "SYS");
        }
Esempio n. 25
0
        private static void RenderBar(Vector2i pos, Vector2i size, string name, int value, int maximum, Color32 barColor, Color32 backColor, Color32 frameColor)
        {
            int barWidth = (int)((float)value / maximum * (size.width - 2));

            RB.DrawRectFill(new Rect2i(pos.x, pos.y, size.width, size.height), backColor);

            if (barWidth > 0)
            {
                RB.DrawRectFill(new Rect2i(pos.x + 1, pos.y, barWidth, size.height), barColor);
            }

            RB.DrawRect(new Rect2i(pos.x, pos.y, size.width, size.height), frameColor);

            C.FSTR.Set(name).Append(": ").Append(value).Append(" / ").Append(maximum);

            RB.Print(C.FONT_SMALL, new Rect2i(pos.x, pos.y + 1, size.width, size.height), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, C.FSTR);
        }
Esempio n. 26
0
        private void DrawGamepad(int x, int y, int playerNum)
        {
            var demo = (DemoReel)RB.Game;

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

            int color1       = playerNum == RB.PLAYER_ONE ? 22 : 15;
            int color2       = playerNum == RB.PLAYER_ONE ? 21 : 14;
            int colorOutline = 0;

            DrawGamepadShoulder(25, -9, "LS", RB.ButtonDown(RB.BTN_LS, playerNum), color2, colorOutline);
            DrawGamepadShoulder(88, -9, "RS", RB.ButtonDown(RB.BTN_RS, playerNum), color2, colorOutline);

            RB.DrawEllipseFill(new Vector2i(26, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(color1));
            RB.DrawEllipseFill(new Vector2i(102, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(color1));

            RB.DrawEllipse(new Vector2i(26, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawEllipse(new Vector2i(102, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(26, 0, 76, 57), DemoUtil.IndexToRGB(colorOutline));

            RB.DrawRectFill(new Rect2i(26, 1, 76, 55), DemoUtil.IndexToRGB(color1));

#if ABXY_SWITCHED
            DrawGamepadABXY(87, 29, "Y", RB.ButtonDown(RB.BTN_Y, playerNum), color2, colorOutline);
            DrawGamepadABXY(113, 29, "A", RB.ButtonDown(RB.BTN_A, playerNum), color2, colorOutline);
            DrawGamepadABXY(100, 16, "X", RB.ButtonDown(RB.BTN_X, playerNum), color2, colorOutline);
            DrawGamepadABXY(100, 41, "B", RB.ButtonDown(RB.BTN_B, playerNum), color2, colorOutline);
#else
            DrawGamepadABXY(100, 16, "Y", RB.ButtonDown(RB.BTN_Y, playerNum), color2, colorOutline);
            DrawGamepadABXY(100, 41, "A", RB.ButtonDown(RB.BTN_A, playerNum), color2, colorOutline);
            DrawGamepadABXY(87, 29, "X", RB.ButtonDown(RB.BTN_X, playerNum), color2, colorOutline);
            DrawGamepadABXY(113, 29, "B", RB.ButtonDown(RB.BTN_B, playerNum), color2, colorOutline);
#endif

            DrawGamepadMenu(55, 20, RB.ButtonDown(RB.BTN_MENU, playerNum), color2, colorOutline);
            DrawGamepadSystem(57, 37, RB.ButtonDown(RB.BTN_SYSTEM, playerNum), color2, colorOutline);

            DrawGamepadDPad(
                10,
                14,
                (RB.ButtonDown(RB.BTN_UP, playerNum) ? RB.BTN_UP : 0) | (RB.ButtonDown(RB.BTN_DOWN, playerNum) ? RB.BTN_DOWN : 0) | (RB.ButtonDown(RB.BTN_LEFT, playerNum) ? RB.BTN_LEFT : 0) | (RB.ButtonDown(RB.BTN_RIGHT, playerNum) ? RB.BTN_RIGHT : 0),
                color2,
                colorOutline);

            RB.CameraReset();
        }
Esempio n. 27
0
        private void DrawSound(int x, int y)
        {
            int barHeight = 24;

            if (mAudioProgress >= 0.999f)
            {
                var rect = new Rect2i(x, y, mSpriteSheet.sheetSize.width, barHeight);
                RB.DrawRectFill(rect, DemoUtil.IndexToRGB(6));

                var prev   = new Vector2i(0, 0);
                var offset = new Vector2i(rect.x, rect.y + (rect.height / 2));
                var freq   = (Mathf.Sin(RB.Ticks / 20.0f) * 0.4f) + 0.25f;

                for (int i = 0; i <= rect.width; i += 4)
                {
                    float j     = (rect.width / 4) - (i / 2);
                    float freq2 = Mathf.Sin(j * freq);
                    float amp   = ((rect.height - 2) / 2) * Mathf.Cos(j / 10.0f) * Mathf.Sin(j / 20.0f);

                    if (i > rect.width / 2)
                    {
                        amp = -amp;
                    }

                    var point = new Vector2i(i, freq2 * amp);
                    RB.DrawLine(prev + offset, point + offset, DemoUtil.IndexToRGB(1));
                    prev = point;
                }

                rect = new Rect2i(x, y, mSpriteSheet.sheetSize.width, barHeight);
                RB.DrawRect(rect, DemoUtil.IndexToRGB(4));
            }
            else
            {
                var rect = new Rect2i(x, y, (int)(mSpriteSheet.sheetSize.width * mAudioProgress), barHeight);
                RB.DrawRectFill(rect, DemoUtil.IndexToRGB(4));

                rect = new Rect2i(x, y, mSpriteSheet.sheetSize.width, barHeight);
                RB.DrawRect(rect, DemoUtil.IndexToRGB(3));

                mFormatStr.Clear();
                mFormatStr.Append("Audio ").Append((int)(mAudioProgress * 100)).Append("%");
                RB.Print(new Vector2i(rect.x + 4, rect.y + 4), DemoUtil.IndexToRGB(5), mFormatStr);
            }
        }
Esempio n. 28
0
 public void Render()
 {
     RB.EffectApplyNow();
     RB.EffectSet(RB.Effect.Noise, .2F);
     RB.Clear(background);
     RB.EffectSet(RB.Effect.Noise, 0F);
     if (currentScreen != null)
     {
         currentScreen.Render();
     }
     if (message.Length > 0)
     {
         RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.x, RB.DisplaySize.y), Color.Lerp(Color.black, Color.clear, 0.5F));
         Vector2i msgSize = RB.PrintMeasure(message);
         Rect2i   msgRect = new Rect2i(RB.DisplaySize.x / 2 - msgSize.x / 2, RB.DisplaySize.y / 2 - msgSize.y / 2, msgSize.x, msgSize.y).Expand(2);
         RB.DrawRectFill(msgRect, Color.white);
         RB.DrawRect(msgRect, Color.black);
         RB.Print(msgRect, Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, message);
     }
 }
Esempio n. 29
0
    public override void Render()
    {
        if (titles != null && !hideTabs)
        {
            int x = pos.x + 1;
            for (int i = 0; i < titles.Length; i++)
            {
                tabTitleX[i] = x;
                Vector2i textSize = RB.PrintMeasure(titles[i]);
                if (currentlyOpenTab == i)
                {
                    RB.DrawRectFill(new Rect2i(x, pos.y, textSize.width + 5, textSize.height + 5), Color.gray);
                    RB.DrawRect(new Rect2i(x, pos.y, textSize.width + 5, textSize.height + 5), Color.white);
                    RB.Print(new Vector2i(x + 3, pos.y + 3), Color.black, titles[i]);
                    RB.Print(new Vector2i(x + 2, pos.y + 2), Color.white, titles[i]);
                    x += textSize.width + 5;
                }
                else
                {
                    RB.DrawRectFill(new Rect2i(x, pos.y + 1, textSize.width + 2, textSize.height + 4), Color.gray);
                    RB.Print(new Vector2i(x + 1, pos.y + 2), Color.black, titles[i]);
                    //RB.Print(new Vector2i(x + 2, tabY + 2), Color.white, titles[i]);
                    x += textSize.width + 2;
                }
            }
            tabTitleX[titles.Length] = x;
        }

        int y = tabY;
        int h = size.y - (tabY - pos.y);

        if (hideTabs)
        {
            y = pos.y;
            h = size.y;
        }
        Rect2i tabRect = new Rect2i(pos.x, y, size.x, h);

        RB.DrawRectFill(tabRect, Color.gray);
        RB.DrawRect(tabRect.Expand(-1), Color.white);
    }
Esempio n. 30
0
        private void DrawSetTile(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            int      flags     = Random.Range(0, 2) == 0 ? 0 : RB.FLIP_V;
            Rect2i   clipRect  = new Rect2i(x + 16, y + 82, 250, 268);
            Vector2i cameraPos = new Vector2i((int)(Mathf.Sin(RB.Ticks / 50.0f) * 128) + 128, (int)(Mathf.Sin(RB.Ticks / 10.0f) * 16) + 16);
            string   flagsStr  = string.Empty;

            if (flags != 0)
            {
                flagsStr = ", @[email protected]_V";
            }

            RB.MapSpriteSet(0, new Vector2i(Random.Range(0, 38), Random.Range(0, 26)), Random.Range(RB.SpriteIndex(0, 4), RB.SpriteIndex(4, 4)), Color.white, flags);

            RB.ClipSet(clipRect);

            RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22));

            RB.CameraSet(cameraPos);
            RB.DrawMapLayer(0);
            RB.CameraReset();
            RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21));

            RB.ClipReset();

            mFormatStr.Set("@C// Set specific tile at specific map layer, sprite flags\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew @MVector2i@N(@L").Append(Random.Range(0, 60)).Append("@N, @L").Append(Random.Range(0, 12)).Append("@N), @L").Append(Random.Range(RB.SpriteIndex(0, 4), RB.SpriteIndex(4, 4))).Append(", 0").Append(flagsStr).Append("@N);\n");
            mFormatStr.Append("@[email protected](@Knew@N @MRect2i@N(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N));\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N),\n   @I22);\n");
            mFormatStr.Append("@[email protected](@Knew@N @MVector2i@N(@L").Append(cameraPos.x).Append("@N, @L").Append(cameraPos.y).Append("@N));\n");
            mFormatStr.Append("@[email protected](@L0@N);\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N),\n");
            mFormatStr.Append("   @I21);");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }