NerfUS game coordinator for the Nerf gun firing range
Dependencies: HardwareInterface mbed-rtos mbed
Fork of NerfUS by
source/GameModes/PrecisionMode.cpp@18:469c8b2a9af9, 2017-03-27 (annotated)
- Committer:
- Ismael Balafrej
- Date:
- Mon Mar 27 11:15:50 2017 -0400
- Branch:
- PlayableGame
- Revision:
- 18:469c8b2a9af9
- Parent:
- 17:48474266a361
Fixed compiling error
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 |
18:469c8b2a9af9 | 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 |
18:469c8b2a9af9 | 8 | TargetInfo * new_target = &((*this->targets)[currentTarget]); |
Ismael Balafrej |
17:48474266a361 | 9 | |
Ismael Balafrej |
18:469c8b2a9af9 | 10 | currentTarget = (currentTarget + 1) % this->targets->size(); |
Ismael Balafrej |
18:469c8b2a9af9 | 11 | new_target->type = TARGET_TYPE_ENEMY; |
Ismael Balafrej |
18:469c8b2a9af9 | 12 | new_target->timeout_ms = 30000; //30 seconds |
Ismael Balafrej |
17:48474266a361 | 13 | |
Ismael Balafrej |
17:48474266a361 | 14 | return new_target; |
Ismael Balafrej |
17:48474266a361 | 15 | } |
Ismael Balafrej |
17:48474266a361 | 16 | |
Ismael Balafrej |
17:48474266a361 | 17 | void PrecisionMode::OnTargetHit(int timeTaken) |
Ismael Balafrej |
17:48474266a361 | 18 | { |
Ismael Balafrej |
17:48474266a361 | 19 | stats.numberOfHits++; |
Ismael Balafrej |
17:48474266a361 | 20 | points += 2; |
Ismael Balafrej |
17:48474266a361 | 21 | } |
Ismael Balafrej |
17:48474266a361 | 22 | void PrecisionMode::OnTargetMiss() |
Ismael Balafrej |
17:48474266a361 | 23 | { |
Ismael Balafrej |
17:48474266a361 | 24 | stats.numberOfMiss++; |
Ismael Balafrej |
17:48474266a361 | 25 | points -= 5; |
Ismael Balafrej |
17:48474266a361 | 26 | } |
Ismael Balafrej |
17:48474266a361 | 27 | |
Ismael Balafrej |
17:48474266a361 | 28 | GameStats PrecisionMode::GetStats() |
Ismael Balafrej |
17:48474266a361 | 29 | { |
Ismael Balafrej |
17:48474266a361 | 30 | //Seems pretty basic... move to PlayableGame class ? |
Ismael Balafrej |
17:48474266a361 | 31 | |
Ismael Balafrej |
17:48474266a361 | 32 | //TODO: Complete the stats |
Ismael Balafrej |
17:48474266a361 | 33 | //stats.timeTaken |
Ismael Balafrej |
17:48474266a361 | 34 | //stats.averageTimePerTarget |
Ismael Balafrej |
17:48474266a361 | 35 | return stats; |
Ismael Balafrej |
17:48474266a361 | 36 | } |