One of the initial design decisions that we had to make with the Tactical Pack was to define what it means to attack and take damage. Attacking and taking damage means different things to different games. For example, attack could mean to shoot a gun or throw a melee punch. Our goal with the Tactical Pack is to make the code as generic as possible. To solve this we added two interfaces, IAttackAgent and IDamagable. This allows you to define exactly what it means to attack or take damage for your game while still being able to use the Tactical Pack.
Included with the demo scene is one implementation of IAttackAgent and IDamagable. When the agent attacks they will instantiate a bullet prefab and that bullet will travel in the direction of the target. When the bullet hits the target it will call the IDamagable implementation to do the actual damage. It is expected that you will implement your own IAttackAgent and IDamagable components that fit your game. By structuring the Tactical Pack this way it succeeds in having a generic pack that works with any type of game.
The following methods need to be implemented with IAttackAgent:
// Returns the furthest distance that the agent is able to attack from. float AttackDistance(); // Can the agent attack? bool CanAttack(); // Returns the maximum angle that the agent can attack from. float AttackAngle(); // Does the actual attack. void Attack(Vector3 targetPosition);
The following methods need to be implemented with IDamagable:
// Take damage by the specified amount. void Damage(float amout); // Is the object currently alive? bool IsAlive();