private static void RenderMap(GameMap map) { RB.SpriteSheetSet(Engine.A.TerrainSprites); RB.DrawMapLayer((int)MapLayers.TERRAIN); foreach (var pos in map.Positions()) { if (!map.Explored[pos]) { continue; } var terrain = map.GetTerrain <MapTerrain>(pos); var alpha = map.FOV.BooleanFOV[pos] ? (byte)255 : (byte)127; RB.AlphaSet(alpha); RB.DrawSprite(terrain.SpriteID, new Vector2i(pos.X * C.TILE_SIZE, pos.Y * C.TILE_SIZE)); RB.AlphaSet(255); } RB.SpriteSheetSet(Engine.A.CharacterSprites); foreach (var actor in map.Actors) { if (!map.Explored[actor.Position]) { continue; } var layerID = (actor is Enemy) ? (int)MapLayers.ENEMIES : (int)MapLayers.PLAYER; RB.DrawMapLayer(layerID); RB.DrawSprite(actor.SpriteID, new Vector2i(actor.Position.X * C.TILE_SIZE, actor.Position.Y * C.TILE_SIZE)); } }
/// <summary> /// Render, your drawing code should go here. /// </summary> public void Render() { RB.Clear(new Color32(127, 213, 221, 255)); // Print "Hi there" centered in a rectangular area near the top of the screen RB.Print(new Rect2i(0, (RB.DisplaySize.height / 2) - 48, RB.DisplaySize.width, 32), Color.black, RB.ALIGN_H_CENTER, "Hi there!"); // Draw some ground RB.DrawEllipseFill(new Vector2i(RB.DisplaySize.width / 2, RB.DisplaySize.height - 24), new Vector2i(RB.DisplaySize.width / 5 * 4, RB.DisplaySize.height / 2), new Color32(74, 198, 138, 255)); // Draw character var position = new Vector2i((RB.DisplaySize.width / 2) - (RB.SpriteSize().width / 2), (RB.DisplaySize.height / 2) - 36); int spriteIndex = ((int)RB.Ticks / 20) % 2; // Draw character shadow RB.DrawEllipseFill(position + new Vector2i(RB.SpriteSize().width / 2, RB.SpriteSize().height - 1), new Vector2i(6 + spriteIndex, 2), new Color32(54, 150, 104, 255)); // Draw a sprite just below RB.DrawSprite(spriteIndex, position); // Print some more text RB.Print( new Rect2i(0, (RB.DisplaySize.height / 2) + 12, RB.DisplaySize.width, 64), new Color32(35, 101, 71, 255), RB.ALIGN_H_CENTER | RB.TEXT_OVERFLOW_WRAP, "Now it's @ffffff@w165your@w000@- time to shine!\n\nPlease enjoy@- @ffffffRetroBlit@-! I sincerely hope it inspires, and enables you\nto create the next great retro game!\n" + "\nIf you enjoyed @ffffffRetroBlit@-, and would like to continue supporting its development then please share your review on the @ffffffUnity Asset Store@-!" + "\n\nThank you!"); }
/// <summary> /// Render /// </summary> public override void Render() { int flip = mDirX == 1 ? 0 : RB.FLIP_H; int frame = 0; if (mPhysics.IsOnGround) { frame = mRunFrames[(int)mFrameIndex]; } else { frame = 3; } if (mPlayerNum == RB.PLAYER_ONE) { RB.DrawSprite(RB.SpriteIndex(frame, 2), new Vector2i((int)Pos.x, (int)Pos.y), flip); RB.DrawSprite(RB.SpriteIndex(frame, 3), new Vector2i((int)Pos.x, (int)Pos.y + 16), flip); } else { RB.DrawSprite(RB.SpriteIndex(frame + 5, 2), new Vector2i((int)Pos.x, (int)Pos.y), flip); RB.DrawSprite(RB.SpriteIndex(frame + 5, 3), new Vector2i((int)Pos.x, (int)Pos.y + 16), flip); } base.Render(); }
/// <summary> /// Render the effect /// </summary> public override void Render() { var e = mTarget.e; if (e == null) { return; } RB.TintColorSet(Color.white); float alpha = 1; if (mFramesRemaining < FADE_FRAMES) { alpha = mFramesRemaining / (float)FADE_FRAMES; } if (mFramesRemaining > mFramesTotal - FADE_FRAMES) { alpha = (mFramesTotal - mFramesRemaining) / (float)FADE_FRAMES; } RB.AlphaSet((byte)(alpha * 255)); RB.TintColorSet(new Color32(0xe6, 0x48, 0x2e, 255)); RB.DrawSprite(S.AGGRO, new Vector2i(e.pos.x * RB.SpriteSize(0).width, (e.pos.y * RB.SpriteSize(0).height) + mFloatPos)); RB.AlphaSet(255); }
private void DrawTint(int x, int y, int spriteIndex) { var demo = (DemoReel)RB.Game; RB.CameraSet(new Vector2i(-x, -y - 50)); DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 64, 16), -1, mOutputFrame, mOutputBackground); RB.TintColorSet(Color.white); RB.DrawSprite(spriteIndex, new Vector2i(0, 0)); RB.TintColorSet(DemoUtil.IndexToRGB(12)); RB.DrawSprite(spriteIndex, new Vector2i(24, 0)); RB.TintColorSet(DemoUtil.IndexToRGB((int)(RB.Ticks / 10) % 32)); RB.DrawSprite(spriteIndex, new Vector2i(48, 0)); RB.TintColorSet(Color.white); RB.CameraReset(); mFormatStr.Set("@C// Set tint color for drawing (RGB Mode only)\n"); mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i@N(@L0@N, @L0@N));\n"); mFormatStr.Append("@[email protected](@I12);\n").Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i@N(@L24@N, @L0@N));\n"); mFormatStr.Append("@[email protected](@I").Append((RB.Ticks / 10) % 32, 2).Append(");\n"); mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i(@L48@N, @L0@N));"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
private void DrawSprite(int x, int y, int spriteIndex) { var demo = (DemoReel)RB.Game; RB.CameraSet(new Vector2i(-x, -y - 17)); DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 16, 16), -1, mOutputFrame, mOutputBackground); mFormatStr.Clear(); if (RB.Ticks % 200 < 100) { mFormatStr.Append("@C// Draw sprite from sprite sheet by its index\n"); mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i@N(@L0@N, @L0@N));"); RB.DrawSprite(spriteIndex, new Vector2i(0, 0)); } else { mFormatStr.Append("@C// Draw sprite from sprite sheet by its index\n"); mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i@N(@L0@N, @L0@N), @[email protected]_H );"); RB.DrawSprite(spriteIndex, new Vector2i(0, 0), RB.FLIP_H); } RB.CameraReset(); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
/// <summary> /// Render the effect /// </summary> public override void Render() { var game = (RetroDungeoneerGame)RB.Game; var e = mTarget.e; if (e == null) { return; } RB.TintColorSet(Color.white); float alpha = 1; if (mFramesRemaining < FADE_FRAMES) { alpha = mFramesRemaining / (float)FADE_FRAMES; } if (mFramesRemaining > mFramesTotal - FADE_FRAMES) { alpha = (mFramesTotal - mFramesRemaining) / (float)FADE_FRAMES; } RB.AlphaSet((byte)(alpha * 255)); RB.TintColorSet(new Color32(0xe6, 0x48, 0x2e, 255)); RB.DrawSprite(S.AGGRO, new Vector2i(e.pos.x * game.assets.spriteSheet.grid.cellSize.width, (e.pos.y * game.assets.spriteSheet.grid.cellSize.height) + mFloatPos)); RB.AlphaSet(255); }
private static void RenderEntity(EntityID entity) { var game = (RetroDungeoneerGame)RB.Game; var e = entity.e; if (game.map.IsInFOV(e.pos) || (e.stairs != null && game.map.IsInExplored(e.pos))) { RB.TintColorSet(e.color); RB.AlphaSet(e.color.a); RB.DrawSprite(e.sprite, new Vector2i(e.pos.x * RB.SpriteSize(0).width, e.pos.y * RB.SpriteSize(0).height)); // Render paper doll items if (e.equipment != null) { for (int i = 0; i < e.equipment.equipment.Length; i++) { if (!e.equipment.equipment[i].isEmpty && e.equipment.equipment[i].e.item != null) { var itemEntity = e.equipment.equipment[i].e; RB.TintColorSet(itemEntity.color); RB.DrawSprite(itemEntity.item.paperDoll, new Vector2i(e.pos.x * RB.SpriteSize(0).width, e.pos.y * RB.SpriteSize(0).height)); } } } RB.AlphaSet(255); } }
public void draw() { int spriteIndex = ((int)RB.Ticks / 20) % numFrames + spriteStartIndex; // Draw a sprite just below RB.DrawSprite(spriteIndex, position); }
public override void Render() { if (!isVisible) { return; } int off = 0; if (currentState != State.Pressed) { RB.TintColorSet(Color.black); RB.DrawSprite(sprite, pos + new Vector2i(1, 1)); } else { off = 1; } bool highlight = currentState == State.Hovered || currentState == State.Pressed; if (highlight) { RB.TintColorSet(Color.yellow); } else if (currentState == State.Disabled) { RB.TintColorSet(Color.gray); } else { RB.TintColorSet(Color.white); } RB.DrawSprite(sprite, pos + new Vector2i(off, off)); RB.TintColorSet(Color.white); }
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)); }
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); }
/// <summary> /// Render /// </summary> public void Render() { byte prevAlpha = RB.AlphaGet(); // Be sure to account for shadow render pass here RB.AlphaSet((byte)((mAlpha / 255.0f) * prevAlpha)); RB.DrawSprite(RB.SpriteIndex(FlashFrame, 2), new Vector2i(Rect.x, Rect.y)); RB.AlphaSet(prevAlpha); }
/// <summary> /// Run the stress test /// </summary> protected override void StressTest() { Random.InitState(0); for (int i = 0; i < mStressLevel; i++) { var randPos = mRandomPos[i]; randPos += GetWiggle(); RB.DrawSprite(mRandomSprite[i], randPos); } }
/// <summary> /// Render /// </summary> public override void Render() { if (mPlayerNum == RB.PLAYER_ONE) { RB.DrawSprite(RB.SpriteIndex(4, 1), new Vector2i((int)Pos.x + 4, (int)Pos.y + (int)(Mathf.Sin(Time.time * 8) * 3) - 1), 0); } else { RB.DrawSprite(RB.SpriteIndex(9, 1), new Vector2i((int)Pos.x + 4, (int)Pos.y + (int)(Mathf.Sin(Time.time * 8) * 3) - 1), 0); } }
/// <summary> /// Render the scene /// </summary> public override void Render() { RB.DrawSprite(S.TITLE_BACKGROUND, Vector2i.zero); int yOffset = Mathf.RoundToInt(Mathf.Sin(RB.Ticks / 16.0f) * 2); RB.TintColorSet(Color.black); RB.DrawSprite(S.TITLE_TEXT, new Vector2i(170, 15 + yOffset)); RB.TintColorSet(Color.white); RB.DrawSprite(S.TITLE_TEXT, new Vector2i(170, 12 + yOffset)); mMenuMain.Render(); }
public override void Render() { if (!isVisible) { return; } RB.AlphaSet(alpha); RB.TintColorSet(tintColor); RB.DrawSprite(sprite, pos); RB.TintColorSet(Color.white); RB.AlphaSet(255); }
/// <summary> /// Render the effect /// </summary> public override void Render() { if (mTargetEntity.isEmpty) { return; } var entityPos = mTargetEntity.e.pos; var renderPos = new Vector2i(entityPos.x * RB.SpriteSize(0).width, entityPos.y * RB.SpriteSize(0).height); RB.TintColorSet(Color.white); int frame = ((mFramesTotal - mFramesRemaining) / 1) - 1; RB.DrawSprite(S.ANIM_SWOOSH[frame], renderPos, mDrawFlags); }
private void DrawOutputScreen(int x, int y) { var demo = (DemoReel)RB.Game; RB.CameraSet(new Vector2i(-x, -y)); DemoUtil.DrawOutputFrame(new Rect2i(0, 0, EXAMPLE_WIDTH, EXAMPLE_HEIGHT), 4, 2, 22); int spriteIndex = ((int)RB.Ticks / 20) % 2; RB.DrawSprite(spriteIndex, new Vector2i(120, 64)); RB.Print(new Vector2i(110, 52), DemoUtil.IndexToRGB(0), "Hi there!"); RB.CameraReset(); }
private void DrawRotate(int x, int y, int spriteIndex) { var demo = (DemoReel)RB.Game; RB.CameraSet(new Vector2i(-x, -y - 17)); DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 18, 18), -1, mOutputFrame, mOutputBackground); RB.DrawSprite(spriteIndex, new Vector2i(1, 1), new Vector2i(8, 8), (RB.Ticks * 4) % 360); RB.CameraReset(); mFormatStr.Set("@C// Rotate sprites around pivot point\n"); mFormatStr.Append("@[email protected](@Knew @MVector2i(@1@N, @L1@N), @Knew @MVector2i@N(@L8@N, @L8@N), @L").Append((RB.Ticks * 4) % 360).Append("@N);"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
/// <summary> /// Render /// </summary> public override void Render() { int flip = 0; int frame = (int)mFlagFrames[(int)mFrameIndex]; if (mPlayerNum == RB.PLAYER_ONE) { RB.DrawSprite(RB.SpriteIndex(frame, 1), new Vector2i((int)Pos.x, (int)Pos.y), flip); } else { RB.DrawSprite(RB.SpriteIndex(frame + 5, 1), new Vector2i((int)Pos.x, (int)Pos.y), flip); } base.Render(); }
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); } }
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); } }
/// <summary> /// Render the effect /// </summary> public override void Render() { var game = (RetroDungeoneerGame)RB.Game; var target = mTarget.e; if (target == null) { return; } var map = ((RetroDungeoneerGame)RB.Game).map; if (!map.IsInFOV(target.pos)) { return; } Color32 color = new Color32(0x38, 0xd9, 0x73, 255); var targetPos = new Vector2i(target.pos.x * game.assets.spriteSheet.grid.cellSize.width, target.pos.y * game.assets.spriteSheet.grid.cellSize.height); var globalAlpha = mFramesRemaining <= FADE_FRAMES ? (mFramesRemaining / (float)FADE_FRAMES) : 1.0f; RB.TintColorSet(color); for (int i = 0; i < mMarks.Count; i++) { float alpha = 1; int y = (int)mMarks[i].y; if (-y < FADE_FRAMES) { alpha = (-y) / (float)FADE_FRAMES; } if (-y > FLOAT_HEIGHT - FADE_FRAMES) { alpha = (FLOAT_HEIGHT + y) / (float)FADE_FRAMES; } RB.AlphaSet((byte)(alpha * 255 * globalAlpha)); RB.DrawSprite(S.CONFUSION, targetPos + mMarks[i]); RB.AlphaSet(255); } }
/// <summary> /// Render the effect /// </summary> public override void Render() { var game = (RetroDungeoneerGame)RB.Game; if (mTargetEntity.isEmpty) { return; } var entityPos = mTargetEntity.e.pos; var renderPos = new Vector2i(entityPos.x * game.assets.spriteSheet.grid.cellSize.width, entityPos.y * game.assets.spriteSheet.grid.cellSize.height); RB.TintColorSet(Color.white); int frame = ((mFramesTotal - mFramesRemaining) / 1) - 1; RB.DrawSprite(S.ANIM_SWOOSH[frame], renderPos, mDrawFlags); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); DrawNoisePad(4, 4); DrawPiano(4, 200); DrawMusicPlayer(350, 4); mNextButton.Render(); mPrevButton.Render(); if (RB.PointerPosValid()) { RB.DrawSprite(4, RB.PointerPos()); } }
/// <summary> /// Run the stress test /// </summary> protected override void StressTest() { Random.InitState(0); mString.Set("@7fd5ddT").Append("@a47746e").Append("@a44653s").Append("@369668t"); // Divide by 2 because there are two tests in one here for (int i = 0; i < mStressLevel / 2; i++) { var randPos = mRandomPos[i]; randPos += GetWiggle(); RB.DrawSprite(mRandomSprite[i], randPos); randPos = mRandomPos[(i + 20000) % mRandomPos.Length]; randPos += GetWiggle(); RB.Print(randPos, Color.white, mString); } }
/// <summary> /// Render the effect /// </summary> public override void Render() { RB.TintColorSet(Color.white); float alpha = 1; if (mFramesRemaining < FADE_FRAMES) { alpha = mFramesRemaining / (float)FADE_FRAMES; } if (mFramesRemaining > mFramesTotal - FADE_FRAMES) { alpha = (mFramesTotal - mFramesRemaining) / (float)FADE_FRAMES; } RB.AlphaSet((byte)(alpha * 210)); RB.DrawSprite(S.PLAYER_GHOST, new Vector2i(mGhostPos.x + (Mathf.Sin((mFramesTotal - mFramesRemaining) / 50.0f) * 5.0f), mGhostPos.y)); RB.AlphaSet(255); }
/// <summary> /// Render the effect /// </summary> public override void Render() { if (mFrameDelay > 0) { return; } int drawFlags = 0; drawFlags |= Random.Range(0, 2) == 0 ? 0 : RB.FLIP_H; float alpha = mAlphaFade / (float)FADE_FRAMES; var renderPos = new Vector2i(mPos.x * RB.SpriteSize(0).width, mPos.y * RB.SpriteSize(0).height); RB.TintColorSet(new Color32(0xf7, 0x9d, 0x48, 255)); RB.AlphaSet((byte)(alpha * 255)); RB.DrawSprite(S.FIRE, renderPos, drawFlags); RB.AlphaSet(255); }