Game Development Reference
In-Depth Information
Creating the Tank Class
The Tank class represents our tank enemy.
The
m_VehicleID
can hold a unique id that identifies this specific vehicle or class of vehicles, such as
“lasertank03.”
private String m_VehicleID = "None";
The
m_Driver
variable holds the Driver class object of the tank and contains the finite state machine
that implements the tank's artificial intelligence.
private Driver m_Driver;
The
m_MainBody
variable holds the lower 3D mesh portion of the tank that turns toward the waypoint
and controls the movement of the upper turret portion of the tank.
private Object3d m_MainBody;
The
m_Turret
variable holds the upper 3D mesh portion of the tank that turns toward the target and
fires projectiles at it.
private Object3d m_Turret;
The
m_Heading
holds the direction that the tank is moving.
private Vector3 m_Heading = new Vector3(0,0,0);
The
MAX_WEAPONS
variable holds the maximum number of weapons that this tank can have.
private int MAX_WEAPONS = 5;
The
m_NumberWeapons
variable holds the number of weapons that this tank currently has.
private int m_NumberWeapons = 0;
The
m_Weapons
array holds the tank's weapons.
private Weapon[] m_Weapons = new Weapon[MAX_WEAPONS];
The
m_TurretOffset
holds the tank turret's offset position from the center of the tank's main body.
private Vector3 m_TurretOffset = new Vector3(0,0,0);
The
m_HitGroundSFXIndex
holds the index to the sound effect to be played when the tank hits the
ground.
private int m_HitGroundSFXIndex = -1;