Friday 27 March 2015

Spring Project - Boss Code

The boss code was a rather hard endeavor in hindsight. There were many aspects needed to make it work correctly and to actually have a flow to it.

Codes Needed:

  • Health
  • State Control
  • Attack Control
  • Types of Attacks
The health code was just an adaptation of the players health script. Calling the boss mesh instead. This was the easiest part of the boss scripts and only required a few adjustments to make it work as planned.

Boss Health Script











The creation of a basic state machine for controlling the state the boss was to be in was also not too hard. I just created 3 parameters Idle, Attack and Die. The die one hasn't been used at the moment due to the boss death being called in the health script but the code has been left for future optimization. The use of a basic trigger function to check for player entry allows me to prevent the boss from attacking before the player reaches him.

Boss States Scripts












The attack control script takes the current health value from the boss health script and changes the routines it uses based on the different health thresholds the boss reaches. The script containing all the attack creations are referenced here. It also taps into to change the amount of attacks based on health as well.

Attack Scripts












The final sets of scripts are the different types of projectiles. These being the normal missles, homing missiles and mines. Each act differently.

Burst Fire











The burst fire  creates a certain amount of missiles then waits for a time and then repeats this act. The missiles created are rather simple. Traveling forwards and exploding after a lifetime and on collision with anything.

Homing Missiles











The homing missile is just an edited normal one with parts of the shark movement attached to it to make it follow the player and blow up after its lifetime runs out.

Mines











The mines scripts have two ways of exploding. On trigger and on collision. Trigger makes it flash red and then explode whilst collision makes it explode instantly.

No comments:

Post a Comment