NerfUS game coordinator for the Nerf gun firing range
Dependencies: HardwareInterface mbed-rtos mbed
Fork of NerfUS by
source/GameModes/PrecisionMode.cpp@17:48474266a361, 2017-03-17 (annotated)
- Committer:
- Ismael Balafrej
- Date:
- Fri Mar 17 17:19:42 2017 -0400
- Branch:
- PlayableGame
- Revision:
- 17:48474266a361
- Child:
- 18:469c8b2a9af9
First Commit of PlayableGame
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ismael Balafrej |
17:48474266a361 | 1 | #include "PrecisionMode.hpp" |
Ismael Balafrej |
17:48474266a361 | 2 | |
Ismael Balafrej |
17:48474266a361 | 3 | TargetInfo PrecisionMode::GetNextTarget() |
Ismael Balafrej |
17:48474266a361 | 4 | { |
Ismael Balafrej |
17:48474266a361 | 5 | if (numberOfRounds-- == 0) { |
Ismael Balafrej |
17:48474266a361 | 6 | return NULL; |
Ismael Balafrej |
17:48474266a361 | 7 | } |
Ismael Balafrej |
17:48474266a361 | 8 | TargetInfo new_target; |
Ismael Balafrej |
17:48474266a361 | 9 | |
Ismael Balafrej |
17:48474266a361 | 10 | currentTarget = (currentTarget + 1) % NUMBER_OF_TARGETS; |
Ismael Balafrej |
17:48474266a361 | 11 | new_target.id = currentTarget; |
Ismael Balafrej |
17:48474266a361 | 12 | new_target.type = TARGET_TYPE_ENEMY; |
Ismael Balafrej |
17:48474266a361 | 13 | new_target.timeout_ms = 30000; //30 seconds |
Ismael Balafrej |
17:48474266a361 | 14 | |
Ismael Balafrej |
17:48474266a361 | 15 | return new_target; |
Ismael Balafrej |
17:48474266a361 | 16 | } |
Ismael Balafrej |
17:48474266a361 | 17 | |
Ismael Balafrej |
17:48474266a361 | 18 | void PrecisionMode::OnTargetHit(int timeTaken) |
Ismael Balafrej |
17:48474266a361 | 19 | { |
Ismael Balafrej |
17:48474266a361 | 20 | stats.numberOfHits++; |
Ismael Balafrej |
17:48474266a361 | 21 | points += 2; |
Ismael Balafrej |
17:48474266a361 | 22 | } |
Ismael Balafrej |
17:48474266a361 | 23 | void PrecisionMode::OnTargetMiss() |
Ismael Balafrej |
17:48474266a361 | 24 | { |
Ismael Balafrej |
17:48474266a361 | 25 | stats.numberOfMiss++; |
Ismael Balafrej |
17:48474266a361 | 26 | points -= 5; |
Ismael Balafrej |
17:48474266a361 | 27 | } |
Ismael Balafrej |
17:48474266a361 | 28 | |
Ismael Balafrej |
17:48474266a361 | 29 | GameStats PrecisionMode::GetStats() |
Ismael Balafrej |
17:48474266a361 | 30 | { |
Ismael Balafrej |
17:48474266a361 | 31 | //Seems pretty basic... move to PlayableGame class ? |
Ismael Balafrej |
17:48474266a361 | 32 | |
Ismael Balafrej |
17:48474266a361 | 33 | //TODO: Complete the stats |
Ismael Balafrej |
17:48474266a361 | 34 | //stats.timeTaken |
Ismael Balafrej |
17:48474266a361 | 35 | //stats.averageTimePerTarget |
Ismael Balafrej |
17:48474266a361 | 36 | return stats; |
Ismael Balafrej |
17:48474266a361 | 37 | } |