Credits screen
Finally, the credits screen is done and working. But, let's start from the beginning.
As I've mentioned in the previous post, the work has already started for the credits screen. As the fonts were working I switched my attention for the faces with the blinking eyes and sliding credits.
At first, all the "eyes" were implemented as solo sprites. But then I thought why not use a sprite atlas after all? There was just one problem and it was, that sprites, that should be used in the atlas, should be a regular assets. But in my case, they were "embedded" in the .sti file. New asset type was added to StciImporter. Then the whole process of extraction and atlas generation is done in 2 passes. First, the texture sub-assets in the .sti file are remapped to the external assets. That is, the textures are extracted to solo asset files and in the .sti file only sprites are left. Then in the second pass, the textures are marked as dependencies for the sprite and sprite atlas is created. AssetManager was also updated, because atlas are loaded on demand using events. And finally, while generating the asset bundles, the atlas source textures are ignored, using special chars for directory (which is then ignored) as they aren't needed anymore.
The blinking eyes are implemented as simple alpha blending of the sprites. That is, when the time comes to blink the eyes, the "blinking eyes" sprite's colors alpha is set to opaque (gradually) and then back to transparent after some time. There is also some randomness added to it.
The next thing, which was already implemented, but I forgot to mention it in the previous post was, the sliding credits (text). This is implemented as a sliding game object with text component (and all the other supported components). The game object is instantiated "below" the screen, then move up and finally after isn't visible on the screen, the game object is destroyed. As in the original game, speed change (+/-) and pause are implemented too.
And finally, the detailed info about each face was implemented. This was done using events in CreditsFaceComponent class, to which ScreenMainMenuCreditsManager is subscribed (for each face) and handles the detailed text that is passed to it from the event. But because the cursor changes while the mouse cursor is hovering over the face, some type of cursor manager needed to be implemented. As in original JA2, each game cursor has an enum, it is the same here. But, because cursor could have some other attributes like if it is animated, hot spot, etc. the AssetCursorDatabase class was created which is used as cursor database (and StciImporter was also updated to support the cursor asset type). There, all the cursors should be defined (for now, only two are, the base arrow and "pointing finger" cursor). CursorManager class then handle all the operations with cursors.
Here is some simple "video" of the credits screen:
Another thing I was working on was "import settings" asset. It is an asset, where one can define for each file in the given .slf the attributes for the importer. Like what asset type it is, and some default values for it. This is to avoid setting it manually after extracting the .slf.
AssetRef had now a custom GUI (PropertyDrawer) and could be used for creating the AssetRef data from the asset object.
For the main menu, keyboard shortcuts were implemented.
I also removed some unused classes like MouseRegion as it isn't needed altogether in Unity (mouse enter/leave is handled directly in the UI components for now).
I've already started implementing the preferences screen. And this will be the next entry about.
Comments