Monday, April 30, 2012

I Love Databases

I got the database to work.  I basically lifted the scripts I wrote for Unity3D and compiled them in Microsoft C#.  I dumped the Battlestar.dll file in the Unity3D asset folder, and Battlestar (the game) now accesses a database.  Bullets and missiles now load their information from the databse.  Here's the coding for the bullets.
First the class declaration (bullet.cs):

Now here's the BulletManager.cs that handles the loading and saving of data to and from the database:


Basically, the load and save routines are executed here along with the creation of the Bullet class structure.  The missile data routines are similar to the bullet routines.  The major difference being the number of fields.  It takes more data to define a missile (not only does it explode; it has AI parameters and the flight control script to guide it). 

I did complete a basic AI routine for missiles, and they do travel to target now.  However, there is an issue of collision detection.  Sometimes the missile appears to travel through a target; I am working on resolving this issue. 

In addition, I made the explosive force associated with bullets and missile do damage.  The old system was purely kinetic damage.  Now, the explosion checks for all craft in range and applies damage.  There is a linear falloff on damage based on range (craft further away will take less damage). 

Inspired by the bullet and missile spawn points, I added damage spawn points.  After a craft takes so much damage, a "I'm damaged" visual effect is activated randomly.  It's just a simple particle effect to simulate sparks flying from certain points of the craft.  Each effect is preloaded onto the plane and activated after taking damage. 

Current plans include finishing up the counter measure routines and then revisiting the user control setup.

No comments:

Post a Comment