private void CreateBattleButtons() { // set up die buttons UpdateDieButtons(); pawnCards = new Dictionary <Pawn, UIObj>(); EnemyPawnCard epc = new EnemyPawnCard(new Vector2i(size.x / 2, 72), new Vector2i(128, 128), battle.enemy, battle, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER); AddUIObj(epc); pawnCards.Add(battle.enemy, epc); viewPawnImages = new Image[battle.allies.Length + 1]; string[] tabNames = new string[battle.allies.Length]; int spellCount = 0; PlayerPawnCard ppc; PackedSprite viewSprite = RB.PackedSpriteGet("Eye", Game.SPRITEPACK_BATTLE); for (int i = 0; i < battle.allies.Length; i++) { AddUIObj(ppc = new PlayerPawnCard(new Vector2i(8, 8 + 36 * i), new Vector2i(96, 32), battle.allies[i], battle)); pawnCards.Add(battle.allies[i], ppc); AddUIObj(viewPawnImages[i] = new Image(new Vector2i(108, 24 + 36 * i), viewSprite)); if (i > 0) { viewPawnImages[i].isVisible = false; } int x = i; ppc.SetOnClick(() => { ViewSpellTab(x); }); tabNames[i] = battle.allies[i].GetName(); spellCount += battle.allies[i].GetSpells().Length; } spellPane = new TabbedPane(new Vector2i(size.width - 102, 0), new Vector2i(102, size.height), true); spellPane.SetTabs(tabNames); AddUIObj(spellPane); spellButtons = new SpellButton[spellCount]; spellButtonOwnership = new int[spellCount]; int currentSpellIndex = 0; for (int i = 0; i < battle.allies.Length; i++) { currentSpellIndex = FillSpellPane(spellPane, i, currentSpellIndex); } /* * Spell[] knownSpells = battle.GetClientPawn().GetSpells(); * spellButtons = new SpellButton[knownSpells.Length]; * for(int i = 0; i < knownSpells.Length; i++) { * AddUIObj(spellButtons[i] = new SpellButton(battle, knownSpells[i], new Vector2i(size.width - 100, 8 + i * 36))); * }*/ ViewSpellTab(0); }
/// <summary> /// Setup a custom font from the sprite sheet. /// </summary> /// <remarks>The glyphs in your sprite sheet should be organized into a grid, with each cell size being the same. If <paramref name="monospaced"/> is false then RetroBlit will automatically trim any /// horizontal empty space on either side of the glyph. If <paramref name="monospaced"/> is true then the empty space is retained.</remarks> /// <param name="unicodeStart">First unicode character in the font</param> /// <param name="unicodeEnd">Last unicode character in the font</param> /// <param name="glyphSprites">List of packed sprite names to use for the glyphs</param> /// <param name="spriteSheet">The sprite sheet containing the font</param> /// <param name="characterSpacing">Spacing between characters</param> /// <param name="lineSpacing">Line spacing between lines of text</param> /// <param name="monospaced">True if font is monospaced</param> /// <returns>Setup status</returns> public RB.AssetStatus Setup(char unicodeStart, char unicodeEnd, List <string> glyphSprites, SpriteSheetAsset spriteSheet, int characterSpacing, int lineSpacing, bool monospaced) { InternalSetErrorStatus(RB.AssetStatus.Failed, RB.Result.BadParam); progress = 0; if (unicodeStart < 0 || unicodeEnd < unicodeStart) { Debug.LogError("Invalid unicode range"); return(status); } if (spriteSheet == null) { Debug.LogError("Invalid sprite sheet"); return(status); } if (spriteSheet.status != RB.AssetStatus.Ready) { Debug.LogError("Sprite sheet is not ready or not loaded"); return(status); } if (glyphSprites == null) { Debug.LogError("Glyph sprites list is null!"); return(status); } if ((unicodeEnd - unicodeStart + 1) != glyphSprites.Count) { Debug.LogError("Expected " + (unicodeEnd - unicodeStart + 1) + " glyph sprites to cover the given unicode range, was given " + glyphSprites.Count + " glyph sprites"); return(status); } var glyphSprites2 = new List <PackedSprite>(glyphSprites.Count); for (int i = 0; i < glyphSprites.Count; i++) { glyphSprites2.Add(RB.PackedSpriteGet(glyphSprites[i], spriteSheet)); } RetroBlitInternal.RBAPI.instance.Font.FontSetup(this, unicodeStart, unicodeEnd, null, glyphSprites2, spriteSheet, characterSpacing, lineSpacing, monospaced, true); InternalSetErrorStatus(RB.AssetStatus.Ready, RB.Result.Success); progress = 1; return(status); }
/// <summary> /// Load all assets /// </summary> public void LoadAll() { spriteSheet.Load("Demos/RetroDungeoneer/SpritePack", SpriteSheetAsset.SheetType.SpritePack); spriteSheet.grid = new SpriteGrid(new Vector2i(16, 16)); soundMonsterDeath.Load("Demos/RetroDungeoneer/Sounds/MonsterDeath"); soundPlayerDeath.Load("Demos/RetroDungeoneer/Sounds/PlayerDeath"); soundFootStep.Load("Demos/RetroDungeoneer/Sounds/FootStep"); soundMonsterAttack.Load("Demos/RetroDungeoneer/Sounds/MonsterAttack"); soundPlayerAttack.Load("Demos/RetroDungeoneer/Sounds/PlayerAttack"); soundInventory.Load("Demos/RetroDungeoneer/Sounds/Inventory"); soundDrink.Load("Demos/RetroDungeoneer/Sounds/Drink"); soundMenuOpen.Load("Demos/RetroDungeoneer/Sounds/MenuOpen"); soundMenuClose.Load("Demos/RetroDungeoneer/Sounds/MenuClose"); soundStairs.Load("Demos/RetroDungeoneer/Sounds/Stairs"); soundPointerSelect.Load("Demos/RetroDungeoneer/Sounds/PointerSelect"); soundSelectOption.Load("Demos/RetroDungeoneer/Sounds/SelectOption"); soundLevelUp.Load("Demos/RetroDungeoneer/Sounds/LevelUp"); soundFireBall.Load("Demos/RetroDungeoneer/Sounds/Fireball"); soundLightning.Load("Demos/RetroDungeoneer/Sounds/Lightning"); soundConfuse.Load("Demos/RetroDungeoneer/Sounds/Confuse"); soundCheat.Load("Demos/RetroDungeoneer/Sounds/CheatMode"); soundAggro1.Load("Demos/RetroDungeoneer/Sounds/Aggro1"); soundAggro2.Load("Demos/RetroDungeoneer/Sounds/Aggro2"); soundPlayerFallYell.Load("Demos/RetroDungeoneer/Sounds/PlayerFallYell"); soundPortal.Load("Demos/RetroDungeoneer/Sounds/Portal"); soundJump.Load("Demos/RetroDungeoneer/Sounds/Jump"); soundBowShoot.Load("Demos/RetroDungeoneer/Sounds/BowShoot"); soundBowHit.Load("Demos/RetroDungeoneer/Sounds/BowHit"); soundWeb.Load("Demos/RetroDungeoneer/Sounds/Web"); soundTeleport.Load("Demos/RetroDungeoneer/Sounds/Teleport"); soundSlime.Load("Demos/RetroDungeoneer/Sounds/Slime"); musicMainMenu.Load("Demos/RetroDungeoneer/Music/ReturnToNowhere"); musicGame.Load("Demos/RetroDungeoneer/Music/DungeonAmbience"); musicDeath.Load("Demos/RetroDungeoneer/Music/DeathPiano"); musicForest.Load("Demos/RetroDungeoneer/Music/ForestAmbience"); RB.SpriteSheetSet(spriteSheet); var fontSprite = RB.PackedSpriteGet(S.FONT_RETROBLIT_DROPSHADOW); var fontPos = new Vector2i(fontSprite.SourceRect.x + 1, fontSprite.SourceRect.y + 1); fontRetroBlitDropShadow.Setup('!', (char)((int)'~' + 8), fontPos, spriteSheet, new Vector2i(6, 7), ((int)'~' + 8) - (int)'!' + 1, 1, 1, false); fontSmall = fontRetroBlitDropShadow; shaderVignette.Load("Demos/RetroDungeoneer/DrawVignette"); }
public void UpdateSell(List <string> sellableSpells) { foreach (VendorButton ib in sellButtons) { RemoveUIObj(ib); } foreach (ImageButton ib in swapButtons) { RemoveUIObj(ib); } sellButtons = new VendorButton[sellableSpells.Count]; bool buyPossible = pawn.GetSpells().Length < pawn.SpellSlotCount.GetValue(); for (int i = 0; i < buyButtons.Length; i++) { buyButtons[i].blocked = !buyPossible || pawn.DoesKnowSpell(buyButtons[i].spell); } int height = 28 * sellableSpells.Count + (4 * (sellableSpells.Count - 1)); int yStart = size.height / 2 - height / 2; for (int i = 0; i < sellButtons.Length; i++) { sellButtons[i] = new VendorButton(Spells.Get(sellableSpells[i]), new Vector2i(3 * (size.width / 4), yStart + i * 32)); AddUIObj(sellButtons[i]); int x = i; if (i > 0) { ImageButton up = new ImageButton(new Vector2i(3 * (size.width / 4) + 50, yStart + 7 + i * 32), RB.PackedSpriteGet("ButtonUp", Game.SPRITEPACK_BATTLE)); swapButtons.Add(up); AddUIObj(up); up.SetOnClick(() => { Game.client.Send(GameMsg.SwapSpells, new GameMsg.MsgIntegerArray(x - 1, x)); Spell temp = sellButtons[x - 1].spell; sellButtons[x - 1].spell = sellButtons[x].spell; sellButtons[x].spell = temp; }); } if (i < sellButtons.Length - 1) { ImageButton down = new ImageButton(new Vector2i(3 * (size.width / 4) + 50, yStart + 19 + i * 32), RB.PackedSpriteGet("ButtonDown", Game.SPRITEPACK_BATTLE)); swapButtons.Add(down); AddUIObj(down); down.SetOnClick(() => { Game.client.Send(GameMsg.SwapSpells, new GameMsg.MsgIntegerArray(x, x + 1)); Spell temp = sellButtons[x].spell; sellButtons[x].spell = sellButtons[x + 1].spell; sellButtons[x + 1].spell = temp; }); } } sellHeader.SetPosition(new Vector2i(3 * size.width / 4, yStart - 10)); }
/// <summary> /// Handle scene entry /// </summary> public override void Enter() { base.Enter(); RB.SpriteSheetSetup(0, "Demos/DemoReel/DemoSpritePack", new Vector2i(16, 16)); RB.SpriteSheetSetup(1, "Demos/DemoReel/Sprites", new Vector2i(16, 16)); RB.SpriteSheetSetup(2, "Demos/DemoReel/DemoSpritePack", new Vector2i(8, 8)); RB.SpriteSheetSet(0); mSpriteHero1 = RB.PackedSpriteGet("Characters/Hero1"); mSpriteHero2 = RB.PackedSpriteGet("Characters/Hero2"); mSpriteDirtCenter = RB.PackedSpriteGet("Terrain/DirtCenter"); mSpriteDirtSide = RB.PackedSpriteGet("Terrain/DirtSide"); mSpriteGrassTop = RB.PackedSpriteGet("Terrain/GrassTop"); mSpriteGrassTopRight = RB.PackedSpriteGet("Terrain/GrassTopRight"); mSpriteWater = RB.PackedSpriteGet("Terrain/Water"); if (mSpriteHero1.Size.x == 0) { mBadSpritepack = true; return; } RB.MapSpriteSet(0, new Vector2i(0, 0), mSpriteGrassTopRight, RB.FLIP_H); RB.MapSpriteSet(0, new Vector2i(1, 0), mSpriteGrassTop); RB.MapSpriteSet(0, new Vector2i(2, 0), mSpriteGrassTop); RB.MapSpriteSet(0, new Vector2i(3, 0), mSpriteGrassTopRight); RB.MapSpriteSet(0, new Vector2i(0, 1), mSpriteDirtSide, RB.FLIP_H); RB.MapSpriteSet(0, new Vector2i(1, 1), mSpriteDirtCenter); RB.MapSpriteSet(0, new Vector2i(2, 1), mSpriteDirtCenter); RB.MapSpriteSet(0, new Vector2i(3, 1), mSpriteDirtSide); mNineSlice = new NineSlice("Other/NinesliceTopLeft", "Other/NinesliceTop", "Other/NinesliceMiddle"); var glyphs = new List <string>(); for (int i = 0; i <= 9; i++) { glyphs.Add("Font/" + i); } glyphs.Add("Font/colon"); List <char> chars = new List <char>(); for (char c = '0'; c <= '9'; c++) { chars.Add(c); } chars.Add(':'); RB.FontSetup(0, chars, glyphs, 0, 1, 1, true); var mapping = new string[16]; for (int i = 0; i < 16; i++) { mapping[i] = "Terrain/Tiny" + i; } var tinyMap = RB.MapLoadTMX("Demos/DemoReel/TinyMap"); RB.MapLoadTMXLayer(tinyMap, "Terrain", 1, mapping); RB.MapLayerSpriteSheetSet(1, 2); }
private void DrawTMX(int x, int y) { var demo = (DemoReel)RB.Game; RB.SpriteSheetSet(0); mFormatStr.Set("@C// Load sprite packs at runtime just like any other spritesheet!\n"); mFormatStr.Append("@[email protected](@L0@N, @S\"DemoReel/DemoSpritePack\"@N, @Knew@N @MVector2i@N(@L16@N, @L16@N));\n"); mFormatStr.Append("\n"); mFormatStr.Append("@C// Now you can draw sprites using their sprite path and name, there is\n"); mFormatStr.Append("@C// no need to specify source rectangle, RetroBlit sprite packing\n"); mFormatStr.Append("@C// creates an internal lookup table that takes care of that for you!\n"); var outputFrameRect = new Rect2i(x + 130, y + 60, 20, 20); DemoUtil.DrawOutputFrame(outputFrameRect, -1, 21, 22); if (RB.Ticks % 40 < 20) { mFormatStr.Append("@[email protected](@S\"Characters/Hero1\"@N, @Knew@N @MVector2i@N(@L32@N, @L48@N));\n"); RB.DrawSprite("Characters/Hero1", new Vector2i(outputFrameRect.x + 2, outputFrameRect.y + 2)); } else { mFormatStr.Append("@[email protected](@S\"Characters/Hero2\"@N, @Knew@N @MVector2i@N(@L32@N, @L48@N));\n"); RB.DrawSprite("Characters/Hero2", new Vector2i(outputFrameRect.x + 2, outputFrameRect.y + 2)); } RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); y += 90; mFormatStr.Set("@C// You can also use sprite packs with tile maps\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L0@N, @L0@N), @S\"Terrain/GrassTopRight\"@N, @[email protected]_H);\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L1@N, @L0@N), @S\"Terrain/GrassTop\"@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L2@N, @L0@N), @S\"Terrain/GrassTop\"@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L3@N, @L0@N), @S\"Terrain/GrassTopRight\"@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L0@N, @L1@N), @S\"Terrain/DirtSide\"@N, @[email protected]_H);\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L1@N, @L1@N), @S\"Terrain/DirtCenter\"@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L2@N, @L1@N), @S\"Terrain/DirtCenter\"@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L3@N, @L1@N), @S\"Terrain/DirtSide\"@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](0);"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); RB.MapSpriteSet(0, new Vector2i(0, 0), mSpriteGrassTopRight, RB.FLIP_H); RB.MapSpriteSet(0, new Vector2i(1, 0), mSpriteGrassTop); RB.MapSpriteSet(0, new Vector2i(2, 0), mSpriteGrassTop); RB.MapSpriteSet(0, new Vector2i(3, 0), mSpriteGrassTopRight); RB.MapSpriteSet(0, new Vector2i(0, 1), mSpriteDirtSide, RB.FLIP_H); RB.MapSpriteSet(0, new Vector2i(1, 1), mSpriteDirtCenter); RB.MapSpriteSet(0, new Vector2i(2, 1), mSpriteDirtCenter); RB.MapSpriteSet(0, new Vector2i(3, 1), mSpriteDirtSide); outputFrameRect = new Rect2i(x + 105, y + 95, (16 * 4) + 4, (16 * 2) + 4); DemoUtil.DrawOutputFrame(outputFrameRect, -1, 21, 22); RB.DrawMapLayer(0, new Vector2i(outputFrameRect.x + 2, outputFrameRect.y + 4)); y += 140; mFormatStr.Set("@C// Sometimes it can be useful to get the sprite source rectangle\n"); mFormatStr.Append("@Kvar@N sprite = @[email protected](@S\"Terrain/Water\"@N);\n"); mFormatStr.Append("@Kvar@N sourceRect = sprite.SourceRect;\n"); mFormatStr.Append("sourceRect.x += @L").Append((int)((RB.Ticks / 2) % 16)).Append("@N;\n"); mFormatStr.Append("@[email protected](sourceRect, @Knew@N @MVector2i@N(@L32@N, @L48@N));\n"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); outputFrameRect = new Rect2i(x + 130, y + 44, 16 + 4, 16 + 4); DemoUtil.DrawOutputFrame(outputFrameRect, -1, 21, 22); var sprite = RB.PackedSpriteGet("Terrain/Water"); var sourceRect = sprite.SourceRect; sourceRect.x += (int)((RB.Ticks / 2) % 16); sourceRect.width = 16; RB.DrawCopy(sourceRect, new Vector2i(outputFrameRect.x + 2, outputFrameRect.y + 2)); y += 72; mFormatStr.Set("@C// You can also use sprite packs for custom fonts, nine-slice images,\n"); mFormatStr.Append("@C// and when loading map layers from TMX files!\n"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); y += 20; mFormatStr.Set("@w444"); int count = mCounter; int ms = count % 60; count /= 60; int s = count % 60; count /= 60; int m = count; mFormatStr.Append(m, 2).Append(':').Append(s, 2).Append(':').Append(ms, 2); mCounter++; if (mCounter >= 60 * 60 * 60) { mCounter = 0; } RB.Print(0, new Vector2i(x + 15, y + 8), Color.white, mFormatStr); int xGrow = (int)(Mathf.Sin(RB.Ticks / 40.0f) * 20.0f) + 20 + 20; int yGrow = (int)(Mathf.Sin(RB.Ticks / 20.0f) * 18.0f) + 18 + 16; RB.DrawNineSlice(new Rect2i(x + 130 - (xGrow / 2), y + 18 - (yGrow / 2), xGrow, yGrow), mNineSlice); RB.DrawMapLayer(1, new Vector2i(x + 190, y - 1)); }
/// <summary> /// Update /// </summary> public override void Update() { base.Update(); if (spriteSheet1.status == RB.AssetStatus.Ready && spriteSheet2.status == RB.AssetStatus.Ready && spriteSheet3.status == RB.AssetStatus.Ready && !mSpritePackPostLoadDone) { RB.SpriteSheetSet(spriteSheet1); mSpriteHero1 = RB.PackedSpriteGet("Characters/Hero1"); mSpriteHero2 = RB.PackedSpriteGet("Characters/Hero2"); mSpriteDirtCenter = RB.PackedSpriteGet("Terrain/DirtCenter"); mSpriteDirtSide = RB.PackedSpriteGet("Terrain/DirtSide"); mSpriteGrassTop = RB.PackedSpriteGet("Terrain/GrassTop"); mSpriteGrassTopRight = RB.PackedSpriteGet("Terrain/GrassTopRight"); mSpriteWater = RB.PackedSpriteGet("Terrain/Water"); RB.MapSpriteSet(0, new Vector2i(0, 0), mSpriteGrassTopRight, RB.FLIP_H); RB.MapSpriteSet(0, new Vector2i(1, 0), mSpriteGrassTop); RB.MapSpriteSet(0, new Vector2i(2, 0), mSpriteGrassTop); RB.MapSpriteSet(0, new Vector2i(3, 0), mSpriteGrassTopRight); RB.MapSpriteSet(0, new Vector2i(0, 1), mSpriteDirtSide, RB.FLIP_H); RB.MapSpriteSet(0, new Vector2i(1, 1), mSpriteDirtCenter); RB.MapSpriteSet(0, new Vector2i(2, 1), mSpriteDirtCenter); RB.MapSpriteSet(0, new Vector2i(3, 1), mSpriteDirtSide); RB.MapLayerSpriteSheetSet(0, spriteSheet1); mNineSlice = new NineSlice("Other/NinesliceTopLeft", "Other/NinesliceTop", "Other/NinesliceMiddle"); var glyphs = new List <string>(); for (int i = 0; i <= 9; i++) { glyphs.Add("Font/" + i); } glyphs.Add("Font/colon"); List <char> chars = new List <char>(); for (char c = '0'; c <= '9'; c++) { chars.Add(c); } chars.Add(':'); font.Setup(chars, glyphs, spriteSheet1, 1, 1, true); var mapping = new string[16]; for (int i = 0; i < 16; i++) { mapping[i] = "Terrain/Tiny" + i; } mMap.Load("Demos/DemoReel/TinyMap"); mMap.LoadLayer("Terrain", 1, mapping); RB.MapLayerSpriteSheetSet(1, spriteSheet3); mSpritePackPostLoadDone = true; } }
/// <summary> /// Initialize your game here. /// </summary> /// <returns>Return true if successful</returns> public bool Initialize() { // You can load a spritesheet here RB.SpriteSheetSetup(0, "Demos/RetroDungeoneer/SpritePack", new Vector2i(16, 16)); RB.SpriteSheetSet(0); var fontSprite = RB.PackedSpriteGet(S.FONT_RETROBLIT_DROPSHADOW); var fontPos = new Vector2i(fontSprite.SourceRect.x + 1, fontSprite.SourceRect.y + 1); RB.FontSetup(C.FONT_RETROBLIT_DROPSHADOW, '!', (char)((int)'~' + 8), fontPos, 0, new Vector2i(6, 7), ((int)'~' + 8) - (int)'!' + 1, 1, 1, false); RB.MusicSetup(C.MUSIC_MAIN_MENU, "Demos/RetroDungeoneer/Music/ReturnToNowhere"); RB.MusicSetup(C.MUSIC_GAME, "Demos/RetroDungeoneer/Music/DungeonAmbience"); RB.MusicSetup(C.MUSIC_DEATH, "Demos/RetroDungeoneer/Music/DeathPiano"); RB.MusicSetup(C.MUSIC_FOREST, "Demos/RetroDungeoneer/Music/ForestAmbience"); RB.SoundSetup(C.SOUND_MONSTER_DEATH, "Demos/RetroDungeoneer/Sounds/MonsterDeath"); RB.SoundSetup(C.SOUND_PLAYER_DEATH, "Demos/RetroDungeoneer/Sounds/PlayerDeath"); RB.SoundSetup(C.SOUND_FOOT_STEP, "Demos/RetroDungeoneer/Sounds/FootStep"); RB.SoundSetup(C.SOUND_MONSTER_ATTACK, "Demos/RetroDungeoneer/Sounds/MonsterAttack"); RB.SoundSetup(C.SOUND_PLAYER_ATTACK, "Demos/RetroDungeoneer/Sounds/PlayerAttack"); RB.SoundSetup(C.SOUND_INVENTORY, "Demos/RetroDungeoneer/Sounds/Inventory"); RB.SoundSetup(C.SOUND_DRINK, "Demos/RetroDungeoneer/Sounds/Drink"); RB.SoundSetup(C.SOUND_MENU_OPEN, "Demos/RetroDungeoneer/Sounds/MenuOpen"); RB.SoundSetup(C.SOUND_MENU_CLOSE, "Demos/RetroDungeoneer/Sounds/MenuClose"); RB.SoundSetup(C.SOUND_STAIRS, "Demos/RetroDungeoneer/Sounds/Stairs"); RB.SoundSetup(C.SOUND_POINTER_SELECT, "Demos/RetroDungeoneer/Sounds/PointerSelect"); RB.SoundSetup(C.SOUND_SELECT_OPTION, "Demos/RetroDungeoneer/Sounds/SelectOption"); RB.SoundSetup(C.SOUND_LEVEL_UP, "Demos/RetroDungeoneer/Sounds/LevelUp"); RB.SoundSetup(C.SOUND_FIREBALL, "Demos/RetroDungeoneer/Sounds/Fireball"); RB.SoundSetup(C.SOUND_LIGHTNING, "Demos/RetroDungeoneer/Sounds/Lightning"); RB.SoundSetup(C.SOUND_CONFUSE, "Demos/RetroDungeoneer/Sounds/Confuse"); RB.SoundSetup(C.SOUND_CHEAT, "Demos/RetroDungeoneer/Sounds/CheatMode"); RB.SoundSetup(C.SOUND_AGGRO1, "Demos/RetroDungeoneer/Sounds/Aggro1"); RB.SoundSetup(C.SOUND_AGGRO2, "Demos/RetroDungeoneer/Sounds/Aggro2"); RB.SoundSetup(C.SOUND_PLAYER_FALL_YELL, "Demos/RetroDungeoneer/Sounds/PlayerFallYell"); RB.SoundSetup(C.SOUND_PORTAL, "Demos/RetroDungeoneer/Sounds/Portal"); RB.SoundSetup(C.SOUND_JUMP, "Demos/RetroDungeoneer/Sounds/Jump"); RB.SoundSetup(C.SOUND_BOW_SHOOT, "Demos/RetroDungeoneer/Sounds/BowShoot"); RB.SoundSetup(C.SOUND_BOW_HIT, "Demos/RetroDungeoneer/Sounds/BowHit"); RB.SoundSetup(C.SOUND_WEB, "Demos/RetroDungeoneer/Sounds/Web"); RB.SoundSetup(C.SOUND_TELEPORT, "Demos/RetroDungeoneer/Sounds/Teleport"); RB.SoundSetup(C.SOUND_SLIME, "Demos/RetroDungeoneer/Sounds/Slime"); RB.ShaderSetup(C.SHADER_VIGNETTE, "Demos/RetroDungeoneer/DrawVignette"); RB.EffectSet(RB.Effect.Scanlines, 0.5f); EntityFunctions.Initialize(); S.InitializeAnims(); InitializeNewGame.InitializeConstants(); RenderFunctions.Initialize(); mSceneGame = new SceneGame(); mSceneMainMenu = new SceneMainMenu(); mSceneMessage = new SceneMessage(); // Generate tile grid, this is a one time operation, we can keep reusing the grid var gridColor = Color.white; for (int x = 0; x < RB.MapSize.width; x++) { for (int y = 0; y < RB.MapSize.height; y++) { RB.MapSpriteSet(C.LAYER_GRID, new Vector2i(x, y), S.GRID, gridColor); } } ChangeScene(SceneEnum.MAIN_MENU); // Collect any garbage created during initilization to avoid a performance hiccup later. System.GC.Collect(); return(true); }
public override void OnConstruct() { AddUIObj(rollButton = new ImageButton(new Vector2i(size.x / 5, size.y / 2 + 32), RB.PackedSpriteGet("RollButton", Game.SPRITEPACK_BATTLE), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER)); rollButton.SetOnClick(() => { if (battle.rollsLeft > 0) { Game.client.Send(GameMsg.Roll, new EmptyMessage()); } }); rollButton.SetKeybind(KeyCode.Space); AddUIObj(passButton = new TextButton(new Vector2i(size.x / 5, size.y / 2 + 48), "Pass", RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER)); passButton.SetOnClick(() => { if (battle.rollsLeft == 0) { Game.client.Send(GameMsg.Pass, new EmptyMessage()); passButton.isVisible = false; } }); passButton.isVisible = false; passButton.SetKeybind(KeyCode.Return); AddUIObj(bottomPane = new TabbedPane(new Vector2i(0, size.height - 72), new Vector2i(size.width / 2 + 1, 72))); bottomPane.SetTabs(new string[] { "Battle Log", "Inventory", "Bestiary" }); AddUIObj(battleLog = new Text(new Vector2i(4, size.height - 64), new Vector2i(size.width / 3 * 2, 60), RB.ALIGN_H_LEFT | RB.ALIGN_V_BOTTOM | RB.TEXT_OVERFLOW_CLIP)); bottomPane.AddToTab(0, battleLog); // Infopane int infoPaneWidth = (size.width - 102) - (size.width / 2 + 1); AddUIObj(infoPane = new TabbedPane(new Vector2i(size.width / 2 + 1, size.height - 62), new Vector2i(infoPaneWidth, 62), true)); infoPane.SetTabs(new string[] { "Player", "Enemy", "Spell", "Item" }); // Infopane: Pawn info AddUIObj(playerName = new Text(new Vector2i(size.width / 2 + 5, size.height - 58), new Vector2i(infoPaneWidth / 2, 10), RB.ALIGN_H_LEFT | RB.ALIGN_V_TOP)); playerName.SetEffect(Text.Outline); playerName.SetColor(Color.white); infoPane.AddToTab(0, playerName); AddUIObj(affinities = new Text(new Vector2i(size.width / 2 + 5 + infoPaneWidth / 2, size.height - 58), new Vector2i(infoPaneWidth / 2 - 6, 40), RB.ALIGN_H_LEFT | RB.ALIGN_V_TOP)); affinities.SetText("Affinities:"); affinities.SetColor(Color.white); affinities.SetEffect(Text.Outline); infoPane.AddToTab(0, affinities); AddUIObj(affinities = new Text(new Vector2i(size.width / 2 + 5 + infoPaneWidth / 2, size.height - 58), new Vector2i(infoPaneWidth / 2 - 6, 40), RB.ALIGN_H_LEFT | RB.ALIGN_V_TOP)); affinities.SetColor(Color.white); string affText = ""; for (int i = 0; i < 6; i++) { affText += "\n " + Element.All[i].GetColorHex() + Element.All[i].GetName(); } affinities.SetText(affText); infoPane.AddToTab(0, affinities); AddUIObj(affinities = new Text(new Vector2i(size.width / 2 + 5 + infoPaneWidth / 2, size.height - 58), new Vector2i(infoPaneWidth / 2 - 6, 40), RB.ALIGN_H_RIGHT | RB.ALIGN_V_TOP)); affinities.SetColor(Color.black); infoPane.AddToTab(0, affinities); TooltipArea tta = new TooltipArea(new Vector2i(size.width / 2 + 5 + infoPaneWidth / 2, size.height - 58), new Vector2i(infoPaneWidth / 2 - 6, 54), "Affinities determine how likely\nyou are to roll a certain aspect."); AddUIObj(tta); infoPane.AddToTab(0, tta); // Infopane: Spell info AddUIObj(spellName = new Text(new Vector2i(size.width / 2 + 5, size.height - 58), new Vector2i(infoPaneWidth / 2, 10), RB.ALIGN_H_LEFT | RB.ALIGN_V_TOP)); spellName.SetEffect(Text.Outline); spellName.SetColor(Color.white); infoPane.AddToTab(1, spellName); AddUIObj(description = new Text(new Vector2i(size.width / 2 + 5, size.height - 32), new Vector2i(infoPaneWidth - 6, 30), RB.ALIGN_H_LEFT | RB.ALIGN_V_TOP | RB.TEXT_OVERFLOW_WRAP)); description.SetColor(Color.white); infoPane.AddToTab(1, description); }