w e e k 1 1
My two biggest tasks for this week were the core economy (basically the purchasing system for traps) and the energy system.
Previously we had a set amount of traps you could place, but we wanted to weight the traps so that players couldn’t spam the powerful ones.
The core economy was a fairly basic purchasing system. The player has 15 “cores” represented by an int. Each trap has a cost, and you can’t purchase a trap if you don’t have enough cores to cover the cost. That was fairly simple to implement.
The energy system was a bit more complex. Basically, I created an EnergyHandler class which I then attached to each trap. This keeps track of the current amount of energy the trap has, and it slowly decreases this supply it if the trap is not currently being charged. Now, instead of activating a trap being a binary on/off, a trap would only be activated if it had more than zero energy.
I also created a DroneEnergy class which handles the drone’s supply of energy. The drone replenishes its own supply by flying over to the goal area of its base. Basically the scripts which handle the drone’s activation radius colliding with the traps (if the drone has any energy left it will remove the energy) grab an amount of energy from the drone (if it has any left), store this in a local variable, and then give it to the trap.
Additionally, I added this collider which blocks traps from being placed if they are colliding with a wall (this is so players can’t place traps inside walls). It changes color based on whether you can currently place a trap or not.