Saturday, March 30, 2024

Seven Seas to Glory - Sprint Blog 4

Sprint 4

My goal for Sprint 4 was to enhance the ship and hand-to-hand combat to be more engaging, as well as add visual elements that can replace some of the tutorial text.

Before I began working on adding things to the project, I took time to reduce the project size. Some old assets and packages weren’t being used anymore, and I wanted to clean that up before adding more things that would have to be sorted through. Somehow, a build ended up in the project folder, so it was nice to be able to delete that. At the time of doing this, I reduced the project size by about 0.5 GB. While that isn’t much, the project file is large enough on its own, so it’s better to dedicate all the space to what’s required. 


The first feature I worked on was the gun. We already had the model and texture for it, but now it was a matter of adding the ability to use the gun. I started by making the gun shootable. I wanted the gun to work similarly to the cannon in terms of scripting. The difference is that the gun’s aim is based on the center of the camera, whereas the cannon can be aimed up and down. I also wanted the controls to shoot the gun to be the same as the controls to swing the sword, so the transition in combat is easier for the player to adjust to.



I then adjusted the character controller to allow the player to switch to the gun. I achieved this by creating a bool for whether the player was using the sword or the gun. The player can toggle this by pressing either 1 for the sword or 2 for the gun. When the player is using the gun, pressing the LMB instead activates the gun script to fire instead of making the sword swing. At the moment, there is no separate animation for the gun firing.


After the player was able to switch between the gun and the sword, I made it so the gun has a reload time similar to how the cannon has a reload time. I used the same reload UI as the cannon, but I adjusted its duration to be slightly less than the cannon. There was also the issue of the reload UI staying on the screen when the player switched to the sword, so I had to make sure that the UI was no longer active when in the sword.


I moved on to creating the enemy drops that the player gains after combat. I started with the money gain. I wanted the player to gain a random amount of money from $10 to $100 after every successful combat encounter, but if the player is in hand-to-hand combat mode and chooses to kill the whole crew they gain an extra $100. I achieved this by creating a script called KillGain, which accesses the player class, and two public functions are called in the ShipHealth and SpareOrKill scripts. One function just gives a random amount of money to the player class, the other adds $100 to the random number.

I also wanted the enemies to have a random chance to drop special cannonball types, the exploding and freezing cannonballs. I added the logic for this in the KillGain script. I wanted the chance to get a cannonball type to be 50%, 25% for each special cannonball. The script makes a random number from 0 to 3, with the higher bound being adjustable in the inspector for future balancing. If the number is 0, the player gains a random amount of explosive cannonballs from 1 to 3. If the number is 1, the player gains a random amount of freezing cannonballs from 1 to 3.


Now that there was a way to gain special cannonballs, I made the special cannonballs limited to the amount that’s stored in the player class, with an infinite amount of normal cannonballs. I also wanted the cannonball to automatically switch to the normal cannonball when the player runs out of the current cannonball type they are using. This was decently easy to achieve. I didn't worry about updating the indicator text when the automatic switch happened because I knew I was going to work on the inventory next which would tell you that information in a more visually appealing way.


Lastly, I created the inventory system for the game. While it was still time-consuming, we essentially had something like an inventory already. It was more a matter of making it visible to the player and using it to replace some of the tutorial text. I first made the art for the inventory, making all the elements separate such as the inventory background, the text areas, the item boxes, the active indicator, and the images of the items themselves. The inventory’s active indicator corresponds to what the player is currently using rather than the button that the player pressed. This way, it’s always accurate to what the player is seeing. It also automatically changes from the sword or gun to the normal cannonball when the player switches to the cannon mode and back to the sword when the player switches back to the character. I also had to change the numbers that are used for the cannonballs for this to work properly. The biggest challenge at first was making it so the inventory didn’t take up too much space on the screen and having it stretch properly with different camera views.

No comments:

Post a Comment

Seven Seas to Glory - Sprint Blog 6

 Sprint 6 My goal for Sprint 6 was to fix all issues and imperfections that were present in the game and make the ship combat a more fun exp...