21 Nov

Localization in Unity with No Such Localization

Localization in Unity with No Such Localization is easy and truly convenient. We used that package to localize our game 10th Corpse into several languages, and it was a straightforward process. When the time came to localize our game, we evaluated the localization options available for Unity. The canon choice, so to speak, is Unity’s own Localization package which, however, required us to update our project and also, at that time, did not have an expedited installation (it had to be installed manually.) In the long run, Unity’s Localization package is likely to become the standard and the first choice of Unity developers, but for now it’s still at the preview stage.

For 10th Corpse, however, No Such Localization was a wise choice. In fact, No Such Localization offers much more than what we really needed to localize our game, which only required localization of strings. No images and no audio had to be localized in 10th Corpse, but if your project needs that, No Such Localization easily allows for it.

What is No Such Localization?

It’s a localization package for Unity, and it comes in 2 versions: Lite and Pro. Both versions are available in the Unity Asset Store. The Pro version (paid) offers even more features, such as support for Right-To-Left (RTL) languages (Hebrew, etc.), automatic variable replacement, and translation source classes for JSON and CSV files (more about this in a while.) Even the Lite version is awesome and, as told above, it offers much more than what our game’s localization required. No Such Localization integrates naturally with the Unity editor, and requires no coding unless you want to extend its functionality. And that’s the beauty of the package: its architecture, which makes it a breeze understanding and extending its functionality.

How to work with No Such Localization?

Let’s first understand the architecture of No Such Localization. The official documentantion is here and is very good. You’ll work with 3 classes of components. The most important of these components is the LocalizationService. It’s the core of your localization, and you should have a single instance in your scenes (ideally, use DontDestroyOnLoad to have single, persistent LocalizationService object if your project comprises multiple scenes.) Just create an empty object and append a LocalizationService component. Now, in the Locales list, add the languages you want to support, e.g., English and German. There are a few attributes, but you’ll be mostly changing Current Locale. Once you complete the localization process, modifying this Current Locale will immediately switch your project’s content to the localized strings and assets corresponding to such language.

So, main component: LocalizationService. We have yet to work with other two components: ComponentLocalizer and BaseTranslationSource. LocalizationService is our core, our hub, the ruler of all the localization of your game. However, it needs to know what scene’s objects (strictly speaking, components) it has to localize, and it also needs to know where it’s going to find the content with which it will localize those objects. For instance, let’s suppose you have a Text object (again, strictly speaking, an object with a Text component) displaying a “Welcome” string. The LocalizationService can automatically localize that object, but it needs to know that such object has to be localized (that’s the responsibility of ComponentLocalizer), and it needs to know what content it will use to localize the object (that’s the responsibility of BaseTranslationSource.) You can subclass both ComponentLocalizer and BaseTranslationSource to adapt them to the requirements of your project, but No Such Localization comes with classes that will suffice for basic requirements. For instance, the package includes a TextLocalizer component.

In continuation of our example, let’s add a TextLocalizer to our Text object having the “Welcome” string. You’ll notice that the TextLocalizer component has a Phrase attribute. When localizing, you’ll have to remove string literals (e.g., “Welcome”) from your components and replace them with unique IDs. The localization components will used those unique IDs to identify the content. Place unique IDs in that Phrase attribute, e.g., welcome_text. Now we need a Translation Source with an entry for that unique ID, welcome_text. The package comes with a very basic translation source, StandaloneTranslationSource which we can recur to for a simple use case like this. Create another object, add a StandaloneTranslationSource component, and edit its Translation List attribute to add welcome_text as an entry of such list, with translations for Locale English and Locale German.

Localization in Unity with No Such Localization
Translation List of a Standalone Translation Source

That’s all. All the components of No Such Localization will connect among them automatically, and if you go back to your LocalizationService component and change the Current Locale you’ll see your text component modifying its content accordingly. It’s like magic!

Of course, if your project is medium or large sized, working with the StandaloneTranslationSource can be tiresome and error-prone. You might want to read your content from a file (the Pro version of this component comes with translation sources for JSON and CSV files.) The wonderful thing about architecture of No Such Localization is that you can extend it as you wish (we created our own Translation Source class for 10th Corpse.) And you can also create your own ComponentLocalizer for your specialized widgets, for example. You can localize text, images, sound, etc. Further information in the official documentation. An excellent tool for localizing your Unity project!

08 Nov

10th Corpse: Tips and Solutions

10th Corpse Tips

10th Corpse is, at its core, a Match 3 game with an eccentric set of characters and an eclectic array of gameplays. Here we present a few 10th Corpse tips and comments. The game comprises several minigames and challenges, specifically:

  • Match 3: 100 levels. There are many challenges. Collecting icons, destroying crates, boss battles, gravity-immune icons, free-swap icons, killing gargoyles, rechargeable icons, breakable tiles, buttons that show hidden cells, keys that must be led to doors, magnifying glasses that must be led to fingerprints, and much more. The player will also have 5 rechargeable power-ups. Here are some videos showing solutions for a few Match 3 levels of 10th Corpse.
Match 3: Level 1 of 10th Corpse
Match 3: Level 8 of 10th Corpse
Match 3: Level 18 of 10th Corpse
Match 3: Level 21 of 10th Corpse
Match 3: Level 86 of 10th Corpse
  • Arkadiusz Boxtrap: The goal is removing all the skulls which are placed on a board. In order to remove those skulls you’ll have to place pieces on the board, trying to form 3 x 3 areas of squares covered by your pieces (or 4 x 4, etc.) Skulls trapped in those 3 x 3 areas will be immediately destroyed. Each turn you’ll get 2 pieces to place on the board. By the way, pieces can be rotated with a right-click before placing them on the board.
10th Corpse: Level 5 of Arkadiusz Boxtrap minigame
  • Arkadiusz KOMBI!: Groups of pieces will fall down, following gravity, and you’ll have to move and rotate them in order to form rows or columns with 4 or more pieces to remove them. The levels’ goals require combining a few pieces of some color, or destroying all the monsters in the level. Include monsters in your combinations of pieces in order to destroy them. Pieces can be rotated, and you can switch between mouse or keyboard controls.
10th Corpse: Level 3 of Arkadiusz KOMBI! minigame
  • Trivia questions asked by Jake (a.k.a., The Lover of Wisdom) and questions by other characters: from time to time, the characters in Mansion Vinterfragen (especially Jake) will ask you questions. Jake’s questions are trivia questions, like how old was Napoleon Bonaparte when he was crowned Emperor (the answer is 35.) The questions asked by other characters are not usually of this type, and are more related to the personality of each of them. The player will have to try to guess which is the answer that each character would like. For example, Arkadiusz is a bit masochistic, and therefore it is necessary to answer him in the most cruel way possible (for example, there is a case where Arkadiusz asks what he should expect from the critics about his game, and the correct answer is “Expect pain!”.) In any case, if the player gets these answers right, some of her statuses for the Match 3 levels will go up (e.g., the power bar will fill up faster, or her attacks in the battles will be stronger, and so on). The player does not receive any penalty for incorrect answers. However, as mentioned, getting the answers right improves the player’s attributes in Match 3 levels.
  • Hidden Objects: There are 13 HO scenes. Most of them correspond to 9th Corpse, a game inside the game. One of the central characters of the game is Professor Arkadiusz, a game designer whose games pervade Mansion Vinterfragen. The player will be able to play a few of his games: the above referred Boxtrap and KOMBI!, and parts of a fictitious HOPA entitled 9th Corpse. All the hidden object scenes have hints that can be used without any precondition. Simply, after using a hint, you’ll have to wait a while for the hint button to become available again.
Level 2 of “9th Corpse” Hidden Objects minigame

Further 10th Corpse tips can be found in this fantastic and complete walkthrough.

The official page of the game contains additional details and screenshots. You can purchase the game here.

12 Mar

DOTween: How to append a tween to a sequence already playing?

I’m using the fantastic DOTween engine for creating and managing tweens on Unity, but the latest version cannot handle a specific case: how to append a tween to a sequence which is already playing? First a bit of background. After completing DragonScales 6, we’re focusing on a new game, a casual Match 3 with a traditional tile swapping gameplay. Our DragonScales games are created with Java and LibGDX. However, this new project will be built on Unity with C#, and we make intensive use of tweens.

In particular, we want the players to be able to keep playing and swapping tiles even if the game is simultaneously processing matches in other areas of the board. When a match is detected, tiles above those matched tiles will fall. We’re implementing this falling path with position tweens, via DOTween. However, new matches in other areas might alter the path of tiles which are already falling. In order to handle such cases we’ll be appending new tweens to the tweens which are already executing. The problem is that sequences in the current version of DOTween must be entirelly defined beforehand, which clearly does not suit our requirements.

Luckily, there’s a sound workaround published by user EvgenL in this pertinent and open DOTween issue. In short: use a queue of sequences. Here’s the class we’re using, completely based on the referred code:

public class TweenChain
{
    public Queue<Sequence> SequenceQueue = new Queue<Sequence>();

    public TweenChain()
    {
        // empty
    }

    public void AddAndPlay(Tween tween)
    {
        // Create a paused DOTween sequence to "wrap" our tween
        var sequence = DG.Tweening.DOTween.Sequence();
        sequence.Pause();
        // "Wrap" the tween
        sequence.Append(tween);
        // Add tween to queue
        SequenceQueue.Enqueue(sequence);
        // If this is the only tween in queue, play it immediately
        if (SequenceQueue.Count == 1)
        {
            SequenceQueue.Peek().Play();
        }
        // When the tween finishes, we'll evaluate the queue
        sequence.OnComplete(OnComplete);
    }

    private void OnComplete()
    {
        // Tween completed. Remove it.
        SequenceQueue.Dequeue();

        // Other tweens awaiting?
        if (SequenceQueue.Count > 0)
        {
            // Play next tween in queue
            SequenceQueue.Peek().Play();
        }
    }

    public bool IsRunning()
    {
        // Are tweens being processed?
        return (SequenceQueue.Count() > 0);
    }

    public void Destroy()
    {
        // Goodbye. Thanks for your hard work.
        foreach (var sequence in SequenceQueue)
        {
            sequence.Kill();
        }
        SequenceQueue.Clear();
    }
}

Hopefully future versions of DOTween will handle this use case in a straightforward fashion. We needed to append a tween to a sequence in execution and, for the time being, this class solves our requirement.

20 Feb

NagiQ on Steam

We’ll be releasing our game NagiQ on Steam πŸ™‚ The release date is set for March 5:

NagiQ is a family-friendly, word game. It’s a great game to practice English vocabulary, and you’ll have to think a lot to complete all the 100+ boards of the game. Here’s a trailer with the basic gameplay:

Basic gameplay: Type words and connect the mystic letters.

We’ve added 10 Steam achievements to the game, corresponding to the trophies you get for completing the following actions:

  • Capture 2 mystic letters in a single play.
  • Capture more than 2 mystic letters in a single play.
  • Length of a word greater or equal to 15.
  • Complete a board with an amount of words lower or equal to the number of mystic letters on the board.
  • Complete a board in less than 10 seconds.
  • 20 consecutive boards completed, without exit / reset.
  • 15 consecutive boards completed, without using hints.
  • Score >= 20,000
  • Score >= 100,000
  • Score >= 200,000

Updating NagiQ on Steam

NagiQ is the first game we released, back in 2011. The game was created with Ren’Py, and in hindsight those were really fun development times. In order to integrate Steam achievements I updated the game to use the latest Ren’Py version. In short, these are the changes I had to make:

Read More
16 Jan

16 bits COM Oddity

I can’t even pinpoint what a 16 bits COM Oddity really means, but I think the idea is therein, somehow. Previously, I explained how to code a simple a “hello, world” program using the DEBUG tool that was shipped with DOS. Revisiting this obsolete knowledge was unexpectedly fun. We’ll retrieve the hexadecimal version of “hello, world” (well, “hello, world!!”) from that post:

EB 13 0D 0A 68 65 6C 6C 6F 2C 20 77 6F 72 6C 64
21 21 0D 0A 24 B4 09 BA 02 01 CD 21 B4 00 CD 21

That’s all we need for our “hello, world!!” binary. 32 bytes exactly. We can create that file bit by bit but that’d be too excessive, I think. Let’s use the echo command instead. This is the full command I entered in my Windows 10 cmd.exe prompt:

echo|set /p="Γ™β€Όβ™ͺβ—™hello, world!!β™ͺβ—™$β”€β—‹β•‘β˜»β˜Ίβ•!1└═!">hello.com

After that you’ll get a 16-bit COM, hello.com, that will display the “hello, world!!” message. Funny πŸ™‚

What are those weird characters?

First a little explanation. We want our hello.com file to be, byte after byte, an exact representation of the hexadecimal sequence above presented. We’ll use cmd.exe commands to dump characters into the file and, if we choose our characters carefully in order to match the target hexadecimal values, we’ll end up with the exact representation we’re looking for. For instance, the first 2 bytes block, EB 13, is the “jmp 115” instruction. Then comes the newline (0D 0A), and so on. If we convert our hexadecimal to decimal, we get:

235 19 13 10 104 101 108 108 111 44 32 119 111 114 108 100 
 33 33 13 10  36 180   9 186   2  1 205 33 180   0 205  33

The first byte in hello.com must be EB, or 235 in decimal. In order to dump our characters from the command line, we’ll convert that decimal value to a character. I’m trying this on a Windows 10 (64-bits) machine, with cmd.exe using Code page 850 Multilingual Latin 1. In such code page, character 235 is Γ™. And 19 is β€Ό. And, luckily, 13 is β™ͺ and 10 is β—™. Those two characters are especially important because they represent the carriage return and the line feed, respectively, and some shells won’t convert them to characters. However, happily, cmd.exe with my default code page will handle them as we need. To input those characters you can type the usual ALT + decimal value.

There are a few important things to notice:

Read More
15 Jan

“Hello world” with DEBUG

Coding “Hello world” with DEBUG will be a blunt exercise on programming futility. Or an exercise on retro, old-school coding. More than two decades ago I used to code in x86 (Intel) assembly, almost daily. I remember the masochist approach to learning the opcodes and the hardware architecture. The famous RBIL (Ralf Brown’s Interrupt List) was, back then, my favorite “reference”. First painful steps were taken and first crashes happily followed. I remember trying to code, as expected, the traditional “hello, world!”, using a strange tool included in DOS, DEBUG.COM. I wrote a post about this “hello, world” with DEBUG.COM elsewhere, and yesterday I found the time to reread it: I verified, first with awe, then with horror, and finally, with relief, that I had almost completely forgotten how to code in assembly. So I’ll revisit this here, mostly as a self-imposed disciplinary measure, an exercise on programming, specifically, an exercise on programming futility. Heck, DEBUG isn’t even available on the Windows 10 machine I’m typing this on. However, DEBUG looked pretty cool back then: it could assemble, disassemble and dump hexadecimal output. You could create little programs, or inspect programs and peek memory areas.

Specifically what I want is to build a minimal “hello, world!” program using DEBUG.COM. I don’t have any use for this, but it comes as a “relaxing” post after several weeks focused on the release of “DragonScales 3: Eternal Prophecy of Darkness” on Steam and the localization of “DragonScales 5: The Frozen Tomb”. After we execute DEBUG.COM we’ll meet a prompt with a “-” symbol. Now we can input our commands. I want to assemble, i.e., I want to type assembly language instructions. The command for that is “a”, which might be optionally followed by a memory address. By default, instructions will be placed starting from CS:0100, so I’ll use that address. Equivalently, I could type “a 0100” or “a 100” to achieve the same result.

-a

Now we have to place the data in memory. For this little program I only need the characters for “hello, world!!”. Notice I want two “!!” at the end. That’s because I want the final program to occupy exactly 32 bytes; we’ll see the reason for this later on. I’ll use the pseudo-instruction “DB” to define our string. With DB I can neatly provide the string using ASCII values, like this:

 db "hello, world!!"

Those are 14 bytes. However, I want a prettier output, with a newline character before and after our string. A newline is in fact two characters: a carriage return (CR is ASCII 13) and a line feed (LF is ASCII 10). In hexadecimal, CR is 0Dh, and LF is 0Ah. OK. Now our DB would be modified to look like this:

 db 0d,0a,"hello, world",0d,0a

Those are 18 bytes. We are not done yet with our data. In order to effectively print the message to the standard output I’ll recur to the function 09h of INT 21h. Check RBIL D-2109. In short, I have to place the value 09h in register AH, and DS:DX should point to the beginning of our string. The function will print every character until finding a “$” character (i.e., β€œ$” acts as the “zero” in null-terminated C strings). ASCII value of “$” is 36, or 24 in hexadecimal. Therefore, we modify our DB instruction again:

 db 0d,0a,"hello, world",0d,0a,"$"
Read More
06 Jan

DragonScales 3 on Steam

We’ll begin 2020 by releasing our game DragonScales 3: Eternal Prophecy of Darkness on Steam. Here’s the game’s Steam widget:

Key features for the Steam version:

  • 150 levels.
  • Only for Windows platform.
  • 10 Steam achievements.
  • Languages supported: English, German, French, Dutch, Italian, Portuguese and Spanish.
  • Updated libraries.
DragonScales 3 on Steam
DragonScales 3 on Steam

DragonScales 3 was the first DragonScales game with Gravity Mode and falling skulls. Furthermore, the game showcases 5 boss battles combining a new gravity approach with the classic DragonScales tile-matching gameplay. DragonScales 3’s story is based on a sinister prophecy, the Eternal Prophecy of Darkness. There is a group of dark cultists who want this prophecy to come true. Their plan is to bring back Specktr to life. Specktr! The ultimate embodiment of malice! Rumor has it that Specktr, once resurrected, will grant immortality to his followers. One of such followers, incidentally, is the powerful Archmage Cedric. DragonScales 3 is also the first DragonScales 3 with references to a fantasy kingdom, the Gravity Kingdom.

Read More
17 Dec

DragonScales: The Story of Archmage Cedric

This is the background story for the Archmage Cedric of the DragonScales games. If you have not played DragonScales 3 or DragonScales 5 yet, the following text contains several spoilers. All the art of DragonScales was created by our artist XKlibur: check her portfolio here.

Archmage Cedric
Archmage Cedric

The Archmage Cedric was one of the most powerful mages of the Gravity Kingdom. His command of the DragonScales magic was sublime, and that raised him to great glory and fame. Other mages of the kingdom respected and even feared him. In a sense, the Archmage Cedric was the epitome of success in sorcery and he achieved all he ever dreamt of. Once these men achieve all the things they want, their ambition grows even bigger, and they start bordering madness. This occured to Archmage Cedric. Suddenly, he started regretting his human condition, pitying himself for the weaknesses of his mortal vessel, the ugliness of pain, and then yearned for the absolute immutability of his body: he wanted to become an immortal.

Read More
11 Dec

DragonScales 6 game: Solution for Level 5-8

Some players of the latest DragonScales game, DragonScales 6: Love and Redemption, have reached out to us asking about a solution for Level 5-8. That level might seem a bit intimidating at first look, but once you figure out the little tricks for several parts of the board you’ll agree it’s kind of easy. Let’s take a look at the initial configuration of the board.

DragonScales 6 game initial configuration of Level 5-8
Initial configuration

A typical DragonScales board. We have two goals only: capture the red and the green cross-scales. There are some novelties, though, specific to DragonScales 6: keys and doors. Cells with a door icon won’t accept scales on them, so you’ll first have to remove the doors. That means you won’t be able to clear the top-left red cross-scale, or the green cross-scale or activate the arrow until you manage to remove the respective doors. To remove a door just click on it, but you’ll obviously need to capture at least one key beforehand. To capture a key, just form a combination containing the cell with the key.

Read More
08 Dec

Inversion of Control in Software Engineering

What is Inversion of Control in Software Engineering?

Inversion of Control in Software Engineering (IoC) is essentially a strategy for decoupling software components. Basically, the purpose of IoC is to remove unnecessary dependencies (couplings) which might reduce flexibility and elegance of a system’s design. The term Inversion of Control in Software Engineering might sometimes appear applied to different design contexts. It is a term that comes from the 70s, when bottom-up parsing was considered an inversion of top-down parsing. It has roughly continued to be applied in multiple contexts. Some people think Inversion of Control in Software Engineering is a design strategy. For others, it’s a design pattern. After some articles dealing with OpenGL, in this post we will briefly discuss this topic of Software Engineering.

Read More