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 the effect /// </summary> public override void Render() { var game = (RetroDungeoneerGame)RB.Game; var source = mSourceEntity.e; var target = mTargetEntity.e; if (source == null || target == null) { return; } var sourcePos = new Vector2i(source.pos.x * game.assets.spriteSheet.grid.cellSize.width, source.pos.y * game.assets.spriteSheet.grid.cellSize.height); sourcePos += new Vector2i(game.assets.spriteSheet.grid.cellSize.width / 2, game.assets.spriteSheet.grid.cellSize.height / 2); var targetPos = new Vector2i(target.pos.x * game.assets.spriteSheet.grid.cellSize.width, target.pos.y * game.assets.spriteSheet.grid.cellSize.height); targetPos += new Vector2i(game.assets.spriteSheet.grid.cellSize.width / 2, game.assets.spriteSheet.grid.cellSize.height / 2); var delta = new Vector2(targetPos.x - sourcePos.x, targetPos.y - sourcePos.y); var dist = delta.magnitude; var dir = delta; dir.Normalize(); var perp = new Vector2(dir.y, -dir.x); var segmentLen = 4.0f; Color32[] colors = new Color32[] { new Color32(0x3c, 0xac, 0xd7, 255), new Color32(0x3c, 0xac, 0xd7, 255), Color.white, Color.white }; var alpha = mAlphaFade / (float)FADE_FRAMES; RB.AlphaSet((byte)(alpha * 255)); RB.TintColorSet(Color.white); for (int i = 0; i < 4; i++) { var segmentStart = sourcePos.ToVector2(); var distleft = dist; while (distleft > 12) { var len = segmentLen; var segmentEnd = segmentStart + (dir * len) + (perp * Random.Range(-1.5f, 1.5f)); distleft -= len; RB.DrawLine(segmentStart, segmentEnd, colors[i]); segmentStart = segmentEnd; } RB.DrawLine(segmentStart, targetPos, colors[i]); } RB.AlphaSet(255); }
/// <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.DrawCopy(new Rect2i(127, 10, 5, 8), new Rect2i((int)mPos.x, (int)mPos.y, 5, 8)); RB.AlphaSet(prevAlpha); }
/// <summary> /// Render /// </summary> public void Render() { var game = (BrickBustGame)RB.Game; RB.DrawMapLayer(0); // Render in 2 passes, first pass renders shadows for (int renderPass = 0; renderPass < 2; renderPass++) { if (renderPass == 0) { RB.ShaderSet(game.assets.shaderShadow); game.assets.shaderShadow.ColorSet("_ShadowColor", new Color32(0, 0, 0, 96)); RB.CameraSet(new Vector2i(-4, -4)); } else { RB.TintColorSet(Color.white); RB.ShaderReset(); } for (int i = 0; i < mBricks.Count; i++) { mBricks[i].Render(); } mPaddle.Render(); for (int i = 0; i < mBalls.Count; i++) { mBalls[i].Render(); } for (int i = 0; i < mPowerUps.Count; i++) { mPowerUps[i].Render(); } for (int i = 0; i < mLaserShots.Count; i++) { mLaserShots[i].Render(); } mParticles.Render(); if (renderPass == 0) { RB.AlphaSet(255); RB.CameraReset(); } } RB.DrawMapLayer(1, new Vector2i(-2, 0)); mHud.Render(); }
/// <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); }
public override void Render() { if (!isVisible) { return; } RB.AlphaSet(alpha); RB.TintColorSet(tintColor); RB.DrawSprite(sprite, pos); RB.TintColorSet(Color.white); RB.AlphaSet(255); }
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)); }
/// <summary> /// Render the effect /// </summary> public override void Render() { var globalAlpha = mFramesRemaining <= FADE_FRAMES ? (mFramesRemaining / (float)FADE_FRAMES) : 1.0f; RB.AlphaSet((byte)(globalAlpha * 255)); RB.TintColorSet(Color.white); for (int i = 0; i < mParticles.Count; i++) { RB.DrawPixel(mParticles[i].pos, mParticles[i].color); } RB.AlphaSet(255); }
private static void RenderTrail(EntityID entity) { var moveTrail = entity.e.moveTrail; RB.TintColorSet(Color.white); for (int i = 0; i < moveTrail.trail.Count; i++) { var t = moveTrail.trail[i]; RB.AlphaSet(t.fade); RB.DrawEllipseFill(t.pos + new Vector2i(RB.SpriteSize(0).width / 2, RB.SpriteSize(0).height / 2), new Vector2i(2, 2), Color.white); } RB.AlphaSet(255); }
private static void RenderTrail(EntityID entity) { var game = (RetroDungeoneerGame)RB.Game; var moveTrail = entity.e.moveTrail; RB.TintColorSet(Color.white); for (int i = 0; i < moveTrail.trail.Count; i++) { var t = moveTrail.trail[i]; RB.AlphaSet(t.fade); RB.DrawEllipseFill(t.pos + new Vector2i(game.assets.spriteSheet.grid.cellSize.width / 2, game.assets.spriteSheet.grid.cellSize.height / 2), new Vector2i(2, 2), Color.white); } RB.AlphaSet(255); }
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); } }
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); } }
/// <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); } }
public virtual void Render() { foreach (UIObj uiObj in uiObjs) { if (uiObj.isVisible) { uiObj.Render(); } } RenderForeground(); if (currentMsgBox != null) { RB.AlphaSet(120); RB.DrawRectFill(new Rect2i(0, 0, size.width, size.height), Color.black); RB.AlphaSet(255); currentMsgBox.Render(); } if (tooltip.Length > 0) { Vector2i tooltipSize = RB.PrintMeasure(tooltip) + new Vector2i(6, 6); Vector2i topRightPos = RB.PointerPos() - new Vector2i(0, tooltipSize.y); if (topRightPos.y >= 0) { if (topRightPos.x + tooltipSize.width < RB.DisplaySize.width) { RenderTooltip(new Rect2i(topRightPos, tooltipSize), tooltip); } else { RenderTooltip(new Rect2i(RB.PointerPos() - tooltipSize, tooltipSize), tooltip); } } else { if (topRightPos.x + tooltipSize.width < RB.DisplaySize.width) { RenderTooltip(new Rect2i(RB.PointerPos(), tooltipSize), tooltip); } else { RenderTooltip(new Rect2i(RB.PointerPos() - new Vector2i(tooltipSize.x, 0), tooltipSize), tooltip); } } } }
/// <summary> /// Render /// </summary> public void Render() { RB.DrawNineSlice(Rect, mNSFrame[FlashFrame]); if (mLaserOffset < 1.0f) { Vector2i offset = Vector2i.zero; offset.x = (int)(16 * mLaserOffset); offset.y = (int)(8 * mLaserOffset); byte prevAlpha = RB.AlphaGet(); RB.AlphaSet((byte)((1 - mLaserOffset) * prevAlpha)); RB.DrawCopy(new Rect2i(120, 10, 7, 10), new Rect2i(Rect.x - 3 - offset.x, Rect.y - 2 - offset.y, 7, 10)); RB.DrawCopy(new Rect2i(120, 10, 7, 10), new Rect2i(Rect.x + Rect.width - 4 + offset.x, Rect.y - 2 - offset.y, 7, 10)); RB.AlphaSet(prevAlpha); } }
/// <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); }
/// <summary> /// Render /// </summary> public void Render() { var game = (BrickBustGame)RB.Game; var level = game.Level; for (int i = 0; i < level.Lives; i++) { RB.DrawCopy(new Rect2i(0, 40, 15, 7), new Rect2i(10 + (i * 17), RB.DisplaySize.height - 10, 15, 7)); } Rect2i titleRect = new Rect2i(0, 50, 93, 17); RB.DrawCopy(titleRect, new Rect2i((RB.DisplaySize.width / 2) - (titleRect.width / 2), 2, titleRect.width, titleRect.height)); mString.Set("@64C132SCORE@-\n").Append(level.Score); RB.Print(new Rect2i(0, 0, RB.DisplaySize.width / 4, RB.SpriteSize(0).height * 2), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, mString); mString.Set("@64C132HISCORE@-\n").Append(level.HiScore); RB.Print(new Rect2i(RB.DisplaySize.width - (RB.DisplaySize.width / 4), 0, RB.DisplaySize.width / 4, RB.SpriteSize(0).height * 2), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, mString); mString.Set("DRAG TO MOVE PADDLE\n\nDOUBLE ").Append(C.ACTION_VERB).Append(" TO RELEASE THE BALL!"); if (mShowGameOver) { mString.Set("GAME OVER!\n\nDOUBLE ").Append(C.ACTION_VERB).Append(" TO EXIT!"); } else if (mShowWin) { mString.Set("LEVEL CLEARED!\n\nDOUBLE ").Append(C.ACTION_VERB).Append(" TO PROCEED!"); } if (mInfoFade > 0) { int bob = (int)(Math.Sin(RB.Ticks / 10.0f) * 5); RB.AlphaSet((byte)mInfoFade); RB.Print(new Rect2i(0 + 2, 260 + 2 + bob, RB.DisplaySize.width, 40), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, mString); RB.Print(new Rect2i(0, 260 + bob, RB.DisplaySize.width, 40), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, mString); RB.AlphaSet(255); } }
private void DrawPositional(int x, int y) { RB.CameraSet(new Vector2i(-x, -y)); mFormatStr.Set("@C// RetroBlit supports positional sounds. Simply\n"); mFormatStr.Append("@C// set the position of your sound, and the\n"); mFormatStr.Append("@C// position of the listener!\n"); mFormatStr.Append("@N\n"); mFormatStr.Append("@Kvoid@N Init() {\n"); mFormatStr.Append(" sndRef = @[email protected](waterfallSnd);\n"); mFormatStr.Append(" @[email protected](sndRef, @Ltrue@N);\n"); mFormatStr.Append("}\n"); mFormatStr.Append("\n"); mFormatStr.Append("@Kvoid@N Update() {\n"); mFormatStr.Append(" @[email protected](sndRef, @Knew@N @MVector2i@N(@L" + mSoundPos.x + "@N, @L" + mSoundPos.y + "@N));\n"); mFormatStr.Append(" @[email protected](@Knew@N @MVector2i@N(@L" + mListenerPos.x + "@N, @L" + mListenerPos.y + "@N));\n"); mFormatStr.Append("}\n"); RB.Print(new Vector2i(0, 0), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); mPositionalButton.Render(); for (int i = 0; i < (int)(10 * RB.SoundVolumeGet(mPosSoundRef)); i++) { int radius = 3; RB.DrawEllipse(new Vector2i((i * 23) + 4, mListenerPos.y - 3), new Vector2i(radius, radius), DemoUtil.IndexToRGB(2)); } // Use absolute coordinates for drawing ear/rain drop RB.CameraReset(); var volAlpha = (byte)(RB.SoundVolumeGet(mPosSoundRef) * 255); RB.AlphaSet(volAlpha); RB.DrawLine(mListenerPos, mSoundPos, DemoUtil.IndexToRGB(17)); RB.DrawCopy(new Rect2i(0, 224, 14, 24), mListenerPos - new Vector2i(14 / 2, 24 / 2)); RB.DrawCopy(new Rect2i(14, 224, 14, 24), mSoundPos - new Vector2i(14 / 2, 24 / 2)); RB.AlphaSet(255); }
/// <summary> /// Render /// </summary> public void Render() { for (int i = 0; i < mParticles.Count; i++) { RB.TintColorSet(mParticles[i].ColorTint); float alpha = 1.0f; if (mParticles[i].Life < 0.5f) { alpha = mParticles[i].Life / 0.5f; } byte prevAlpha = RB.AlphaGet(); RB.AlphaSet((byte)(prevAlpha * alpha)); RB.DrawCopy(mParticles[i].Rect, new Vector2i((int)mParticles[i].Pos.x, (int)mParticles[i].Pos.y)); RB.AlphaSet(prevAlpha); RB.TintColorSet(Color.white); } }
/// <summary> /// Render the effect /// </summary> public override void Render() { var game = (RetroDungeoneerGame)RB.Game; 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 * game.assets.spriteSheet.grid.cellSize.width, mPos.y * game.assets.spriteSheet.grid.cellSize.height); RB.TintColorSet(new Color32(0xf7, 0x9d, 0x48, 255)); RB.AlphaSet((byte)(alpha * 255)); RB.DrawSprite(S.FIRE, renderPos, drawFlags); RB.AlphaSet(255); }
private void DrawAlpha(int x, int y, int spriteIndex) { var demo = (DemoReel)RB.Game; RB.CameraSet(new Vector2i(-x, -y - 35)); DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 16, 16), -1, mOutputFrame, mOutputBackground); byte alpha = (byte)((Mathf.Sin(RB.Ticks / 20.0f) * 127) + 127); RB.DrawSprite(2, new Vector2i(0, 0)); RB.AlphaSet(alpha); RB.DrawSprite(spriteIndex, new Vector2i(0, 0)); RB.AlphaSet(255); RB.CameraReset(); mFormatStr.Set("@C// Alpha transparency\n").Append("@[email protected](@L2@N, @Knew @MVector2i@N(@L0@N, @L0@N));\n"); mFormatStr.Append("@[email protected](@L").Append(alpha).Append("@N);\n"); mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i(@L0@N, @L0@N));"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
private void DrawEase(Ease.Func func, string funcName, int x, int y, int width, int height) { byte spriteAlpha = 255; if (mT > 1.5f) { spriteAlpha = (byte)(((1.5f - mT) / 0.5f) * 255); } var graphColor = DemoUtil.IndexToRGB(2); var lineColor = DemoUtil.IndexToRGB(3); var scaleColor = DemoUtil.IndexToRGB(24); var interStartColor = DemoUtil.IndexToRGB(27); var interEndColor = DemoUtil.IndexToRGB(23); RB.CameraSet(new Vector2i(-x, -y)); width -= 28; height -= 16; // Draw graph int spaceBetweenLines = (height + 8) - 8; RB.DrawLine(new Vector2i(0, 8), new Vector2i(width, 8), graphColor); RB.DrawLine(new Vector2i(0, 8 + spaceBetweenLines), new Vector2i(width, 8 + spaceBetweenLines), graphColor); RB.Print(new Vector2i(0, 10), graphColor, funcName); // Draw line Vector2i p0 = new Vector2i(0, 8 + height); for (int i = 1; i <= width; i += 1) { int val = 0; val = Ease.Interpolate(func, 0, height, i / (float)width); Vector2i p1 = new Vector2i(i, 8 + height - val); RB.DrawLine(p0, p1, lineColor); p0 = p1; } // Draw movement sprite float t = mT; if (t > 1) { t = 1; } float ti = Ease.Interpolate(func, 0, 1.0f, t); Vector2i pos = new Vector2i(width + 8 - 4, 8 + height - Mathf.RoundToInt(ti * height) - 4); RB.DrawSprite(RB.SpriteIndex(7, 12), new Vector2i(width + 8 - 4, 8 - 4)); RB.DrawSprite(RB.SpriteIndex(7, 12), new Vector2i(width + 8 - 4, 8 + height - 4)); RB.AlphaSet(spriteAlpha); var highlightPos = new Vector2i((t * width) - 1, pos.y + 3); RB.DrawSprite(RB.SpriteIndex(7, 13), highlightPos); RB.DrawSprite(RB.SpriteIndex(7, 11), pos); RB.AlphaSet(255); int scale = 4 + Mathf.RoundToInt(ti * ((spaceBetweenLines / 2) - 4)); RB.DrawRectFill(new Rect2i(width + 16, (height / 2) - scale + 8, 3, (scale * 2) + 1), scaleColor); var interColor = Ease.Interpolate(func, interStartColor, interEndColor, t); RB.DrawRectFill(new Rect2i(width + 20, 8, 3, 3), interEndColor); RB.DrawRectFill(new Rect2i(width + 20, 8 + spaceBetweenLines - 4 + 2, 3, 3), interStartColor); RB.DrawRectFill(new Rect2i(width + 20, 9 + 3, 3, spaceBetweenLines - 7), interColor); RB.CameraReset(); }
/// <summary> /// Render the effect /// </summary> public override void Render() { var game = (RetroDungeoneerGame)RB.Game; var target = mTargetEntity.e; var targetPos = Vector2i.zero; // Set target to target entity if available, otherwise we'll use the passed target position if (target != null) { targetPos = new Vector2i(target.pos.x * game.assets.spriteSheet.grid.cellSize.width, target.pos.y * game.assets.spriteSheet.grid.cellSize.height); } else { targetPos = new Vector2i(mTargetPos.x * game.assets.spriteSheet.grid.cellSize.width, mTargetPos.y * game.assets.spriteSheet.grid.cellSize.height); } var delta = new Vector2(targetPos.x - mSourcePos.x, targetPos.y - mSourcePos.y); var shotPos = mSourcePos + (delta * ((mFramesTotal - mFramesRemaining) / (float)mFramesTotal)); var deltaShotPos = targetPos - shotPos; var alpha = mAlphaFade / (float)FADE_FRAMES; RB.AlphaSet((byte)(alpha * 255)); RB.TintColorSet(mProjecticleColor); var shotSprite = mProjecticleSprite; int shotSpriteFlags = 0; if (mRotate) { // Pick short sprite and sprite flags based on angle to target float angle = Mathf.Atan2(deltaShotPos.y, deltaShotPos.x) * 180.0f / Mathf.PI; if (angle > -22.5f && angle <= 22.5f) { shotSprite = mProjecticleSprite; shotSpriteFlags |= RB.ROT_90_CW; } else if (angle > 22.5f && angle <= 67.5f) { shotSprite = mProjecticleSprite45; shotSpriteFlags |= RB.FLIP_V; } else if (angle > 67.5f && angle <= 112.5f) { shotSprite = mProjecticleSprite; shotSpriteFlags |= RB.FLIP_V; } else if (angle > 112.5f && angle <= 157.5f) { shotSprite = mProjecticleSprite45; shotSpriteFlags |= RB.FLIP_V | RB.FLIP_H; } else if ((angle > 157.5f && angle <= 180.0f) || angle <= -157.5f) { shotSprite = mProjecticleSprite; shotSpriteFlags |= RB.ROT_270_CW; } else if (angle > -157.5f && angle <= -112.5f) { shotSprite = mProjecticleSprite45; shotSpriteFlags |= RB.FLIP_H; } else if (angle > -112.5f && angle <= -67.5f) { shotSprite = mProjecticleSprite; shotSpriteFlags = 0; } else if (angle > -67.5f && angle <= -22.5f) { shotSprite = mProjecticleSprite45; shotSpriteFlags = 0; } } RB.DrawSprite(shotSprite, shotPos, shotSpriteFlags); RB.AlphaSet(255); }
private void DrawAll(int x, int y) { var demo = (DemoReel)RB.Game; var gridColor = DemoUtil.IndexToRGB(14); RB.Offscreen(0); RB.SpriteSheetSet(1); mWaveOffset = (int)((RB.Ticks / 2) % 8); RB.DrawCopy(new Rect2i(mWaveOffset, 0, RB.SpriteSize()), new Vector2i(24, 8)); RB.Onscreen(); Rect2i clipRectOverlap = mClipRect; clipRectOverlap.width += 400; if (mMap != null) { RB.DrawRectFill(mClipRect, DemoUtil.IndexToRGB(22)); } RB.ClipSet(clipRectOverlap); DrawTilemap(mClipRect.x, mClipRect.y); RB.ClipReset(); RB.CameraReset(); // Blank out right side RB.AlphaSet(196); RB.DrawRectFill(new Rect2i(mClipRect.x + mClipRect.width, mClipRect.y, 300, mClipRect.height), DemoUtil.IndexToRGB(1)); RB.AlphaSet(255); // Blank out left side RB.DrawRectFill(new Rect2i(0, mClipRect.y, mClipRect.x - 1, mClipRect.height), DemoUtil.IndexToRGB(1)); RB.DrawRect(mClipRect, DemoUtil.IndexToRGB(7)); if (mMap == null) { return; } RB.AlphaSet(128); mFinalStr.Set("Chunk Tile Offset:"); RB.Print(new Vector2i(mClipRect.x, mClipRect.y - 16), gridColor, mFinalStr); RB.CameraSet(mChunkCameraPos - new Vector2i(mClipRect)); int gxStart = 0; int gxEnd = gxStart + (RB.DisplaySize.width * 2); for (int gx = gxStart; gx < gxEnd; gx += RB.MapChunkSize.width * RB.SpriteSize().x) { RB.DrawLine(new Vector2i(gx, -8), new Vector2i(gx, mClipRect.height + 4), gridColor); mFinalStr.Set(gx / RB.SpriteSize().x); RB.Print(new Vector2i(gx + 3, -8), gridColor, mFinalStr); } RB.AlphaSet(255); RB.CameraReset(); RB.SpriteSheetSet(0); }