Making the Battle Logic and the UI Play Nice
Context
Considering how I'd like to make a career as a gameplay programmer, I decided it'd be fine to handle most of the UI logic in Unity Visual Scripting (UVS). It saved a lot of time, especially thanks to the help of the Community Extensions. This approach makes things easier on UI artists too, since they can implement most of the logic there without me needing to step in too often. Still, there were issues to address. The big one being...
The Language Event Barrier
The UI and the battle logic couldn't listen for each others' events directly. Thus, I needed to use C# as glue to compensate through the Adapter Pattern. I set up a static class (called UIGlobalEventTrigger) to let UVS announce its own events. Here's a small snippet:
Now, you may be asking... "Tespy, what's with that static method? Doesn't UVS have a node that lets you just trigger a UnityAction without that?" The answer, unfortunately, is no. Otherwise, I wouldn't have added in such middlemen-within-middlemen. As for the other way around, having the UI respond to the rest of the battle system... Adapter Pattern to the rescue (again)! I created a class called BattleEventRelayer that did what it sounds like: listen to the non-UI battle events and relay it to UVS. It would do that by executing UnityEvents, letting the Script Graph (in response) trigger the corresponding UVS Global Events. Here's a little peek:
It felt a bit awkward to implement, but it got the job done. Maybe the next time I work on a turn-based project, I can find a more graceful way to go about this stuff...
Get Trigram Islands
Trigram Islands
Golden-Sun-Esque JRPG
Status | Released |
Author | CG-Tespy |
Genre | Role Playing |
Tags | 3D, Anime, JRPG, Short, Turn-based, Unity |
More posts
- Initial Release (10-2024 W3)54 days ago
- Downscoping And The Initial Release (10-2024 W2)61 days ago
- Story Time: Damage Calcs (09-2024 W2)88 days ago
- More BatSys and Overworld Integration (09-2024 W1)94 days ago
- Setbacks And Redos And Title Sequences, Oh My! (09-2024 W0)Sep 02, 2024
- Audio Sys Ready (08-2024 W4)Aug 25, 2024
- Audio Sys Looping (08-2024 W3)Aug 16, 2024
- Audio-Management & Title Screen Progress (08-2024 W2)Aug 11, 2024
- UI Progress (08-2024 W1)Aug 04, 2024
- Coming off Hiatus (07-2024 W4)Jul 28, 2024
Leave a comment
Log in with itch.io to leave a comment.