This time, the video showcases more than just what I worked towards this week. The past two weeks, I've also been spending time creating a full level: first in graybox, then creating a tileset to give it visuals. Obviously, the level's still incomplete, so this blogpost will just be about the action commands. Click 'Read more' to go a little more in-depth with the action commands. The Action Faction The action commands were, in theory, very simple. There's no timing behind the scenes for when you need to press buttons, no scripts running in the background to keep track of button presses. Instead, I simply move the buttons across the screen using a coroutine. The buttons, as well as the UI element containing them, have 2D colliders that function as triggers. Once they overlap, the player can press that button to register either a "regular" or a "perfect" hit to add to their damage. If they press the wrong button, or no button at all, it'll register a "failed" hit and reduce damage. This is probably the most important part of the code. Woah, nestled ifs! I don't like using them because they make code more confusing, but a few else parts were necessary. The code has three booleans it uses to keep track of what kind of hit is done by the player. If any hit has been done, it should stop changing those booleans, hence the first if. Within that, it needs to check whether the buttons are going (a boolean turned on when the first coroutine starts), and whether a button is pressed. This is where we need to nestle again: if the player presses the incorrect button, they will get a failed hit. If they press the correct button when certain bools are on, the player gets a perfect hit or a regular hit. These booleans are turned on when the button colliders overlap the colliders on the action bar. Once a button stops moving it triggers this method. It adds up the amount of hits, then checks whether it's spawned enough buttons. If so, it triggers attack calculation and resets the number of hits afterwards, ready for the next turn. Calculating attack damage now takes into account the amount of hits, and increases or reduces damage based on that. Once I've got animations, I want to separate the amount of damage for each hit so every button press corresponds with a character's attack.
Next week, I'll be working on making the monsters available in the level, and letting the player win or lose.
1 Comment
|
AboutThis is a development blog for my own game project, "Viola". Archives
February 2019
Categories |