Now, it is time to design the enemy, behavior. Before writing a single line of code, we need to design the enemy behavior:
This is our draft. The tree describes the following behavior:
- If it is night, the enemy is deactivated.
- If the target is very close, then the enemy shoots at the target.
- If the target is a bit further away, the enemy chases the target.
- Otherwise, the enemy just wanders around.
There are two important things to note:
- First, the two IsTargetClose nodes differ in the value we consider close. In particular, we want to shoot the target only if we are really close to the target; otherwise, we just ...