During this sprint, I spent a lot of time working on the spell effects in the game.
I also had to handle a few GitHub hiccups that arose this sprint - many merge conflicts. As previously mentioned, each member of the team has their own branch. When they want to add their changes they’ll push it into the main branch. Since all of us (including me) are relatively new to GitHub, there are bound to be issues. Alex Lopez, Josh, and Polawat all lost some of their changes on separate occasions this sprint. Both Alex Lopez and Josh were able to fix their problems, but I had to help Polawat out.
Polawat lost an entire level. He said he was willing to redo it, which is good. Afterward, I showed him how to pull from the main, push to his branch, create a pull request, etc. I am not sure if he knows how to handle merge conflicts yet, but he seems to have a much better grasp of how GitHub works. Hopefully, from now on there will be fewer issues, so I can put more time into my assigned cards.
The first thing I did this sprint is created Enemy spawners. This came with a couple of issues, specifically with unlocking rooms. This is because if there are no enemies in the room activated, then the door will unlock! This is a problem if their enemies to be spawned, but not exactly active in the room yet. So, I had to modify the EnemyRoomManager script. I created a DefeatedAllEnemies property that returns true if there are no enemies currently active in the room AND there are no enemies TO BE SPAWNED. See the implementation below.
EnemyRoomManager.cs DefeatedAllEnemies
I check if DefeatedAllEnemies is true every three seconds. When it is true, I call every Door’s Unlock() function and activate a Reward object.
The spawner in action.
Afterward, I made it so you can FINALLY use cards to create spells! Alex Lopez finished the fundamental components of the UI and helped me setting the Deck up with the current Input system.
The UI, Deck, Cards, and Spells all work in unison.
Combining the deck, cards, and spells with the UI felt great since we can finally see the game come together.
Then, I began to work on all of the status effects. Given most of the spells are not completed yet, I had to make basic spell objects for each type: Fire, Ice, Shadow, Lightning, and Nature. The behaviors of each effect are described in the enumerator’s definition (see below).
The Shock effect seemed to be the easiest to implement, so I started with that. The enemies are dealt damage by calling their TakeDamage() function, so, inside that function, I check if they have the Shock status effect. If they do, then I double the damage value. Nothing fancy. The only real problem is that if the enemy has two shocks stacked, then it will still deal times-two damage - when it should be times-four. (I only realized the issue as of writing this; I swear it’s so much easier to spot bugs when I have to write these blogs).
It’s a simple fix, though. I’ll just change the HasSpellEffect(...) function to return the number of effects of that type, rather than whether the enemy has at least one. If an enemy is shocked, the equation for damage should be like this:
amount = amount * 2 * NumSpellEffectOf(StatusEffect.Shock));
So if NumSpellEffectOf(...) returns a two (meaning there are two Shock effects stacked on an enemy), the damage amount will be increased four-fold.
Then I did the Ignite and Bramble Effect since they both deal damage over time. See the implementation below.
DamageOverTime.cs Update() - As the name implies, it deals damage over time to an enemy. Generalized for both Ignite and Bramble spell effects. The effect deals more damage if they are Rotted.
A prefab with this script attached becomes a child of an enemy, grabbing a reference to its EnemyBase (called myEnemy). It then calls myEnemy’s TakeDamage(...) function.
I later made it so that enemies can freeze over a duration of time since that’s needed for the Bramble and Freeze effect. This was kind of difficult since both enemy types move in different ways. One enemy uses an AI system, and the other uses an EnemyFollow script Josh made. This means I had to handle them differently.
Both rely on the property IsFrozen of EnemyBase, which just returns if the freeze timer is greater than zero. If that is true, I check if the enemy has the Pathfinding.AI component and if so freeze the enemy that way. If there is no Pathfinding.AI component, the enemy will have an EnemyFollow script. The EnemyFollow script will have access to IsFrozen, and will not call its Move function while IsFrozen is true.
Here’s what the Bramble effect looks like with the freezing effect and the damage over time:
Notice how the enemy does not die immediately after hitting it. That is because it dies from DamageOverTime.
Finally, I’d like to show what the spell script looks like with all the spell effects completed. It’s kind of a mess.
Spells.cs OnCollisionEnter(...)
The spell type is determined by a bunch of mutually exclusive boolean variables (lightning, fire, frost, etc.), and extra things are going on for some of these effects excluding simply “applying the status effect”. In short, it’s admittedly bad code, but functionally it works as intended.
In the following weeks, I will be working on new Spells the player can use, and also enjoying Spring Break. See you at the end of Sprint 4.
In Progress:
As a designer, I would like Ice counters to be implemented as a spell block and on enemy stats. (1)
As a designer, I would like 3 Frost Spells to be added (3).
As a designer, I would like 3 Frost Spells to be added (3).
Complete:
As a designer, I would like a freeze status effect to be added. (1)
As a designer, I would like a rot status effect to be added. (1)
As a designer, I would like a bramble status effect to be added. (1)
As a designer, I would like an ignite status effect to be added. (1)
As a designer, I would like a shock status effect to be added (1).
As a designer, I would like the player's cards to interact with the UI. (3)
As a designer, I would like a spawner that spawns enemies on spawning locations shortly after a player enters a level. (1)
No comments:
Post a Comment