I made more progress! I ran into a couple of issues of object accessibility in the code as I tried to modularize my code as per my design. With this in mind, I decided to make the prototype trigger a battle as opposed to just starting in one. To do this, I struggled with design decisions on using “Resources” folder approach, or having the game objects to be used within the same scene.
If I used the “Resources” folder approach, I would have to use specific paths for each resource to load in a scene and I read that this approach does not let Unity “optimize” resource use, since it does not know what is in a scene. I was thinking this approach would be best for an RPG with a million resources that can randomly appear where ever in the game as long as I used the resources folder path to load it. I decided to stay with the game object in the scene approach instead.
What I did was create a few empty game objects with a script called “entitiesLoad” and it would have a single parameter in the inspector for a Gameobject array. I would be able to limit enemies to be spawned in a given area by dragging their corresponding prefabs to the array and then randomly generate from the available list. It is totally possible that this will in the long run cause some performance issues, but if that happens, it will be the perfect opportunity to learn why.
I then drew the forest elements and made the level. I still need to work on proportions on making the level seem the right size. It is ghetto for now, since my priority is learning how to get things to be playable! I also animated the river and waterfall by drawing different frames for it. I had to write code to translate it, and use an animator to fade it in and out. I could not get the animator to dynamically start at the objects originally location when translating, since the animation would override the position values. I wanted to have the same animation for multiple game objects, but this was not possible if I translated the object using the animator.
Next I worked on the Controller logic, which was what took me the most time since my last post. OH MY GAWD! I overestimated this part of the code. I already had the basic “move the cursor” and attack stuff, but I wanted the battle logic to be modularized as well (I had everything in one place like a BOSS). I managed to create separate classes, one for controller and another for BattleActions. Once an enemy was touched, it would activate the battle, changing a value in the controller class to “Battle Mode”. The battle entities are then instantiated. One new feature I added, was the “move” action. I want my game to allow moving the characters to be within range for an attack. I already have the stats logic coded, I just need to “Link” the stats so I can limit the allowed movement, which will be for a subsequent update. I plan to use the forest level as my main prototype development area.
Below is a video of what I have so far. I am using CamStudio to record the screen, so there is no audio. I need to investigate how I can get this recorded with audio. I hope by my next post, I can add skill attacks and “end of battle”.