summaryrefslogtreecommitdiffstats
path: root/source/Concept/Framework/modules/logic
diff options
context:
space:
mode:
Diffstat (limited to 'source/Concept/Framework/modules/logic')
-rwxr-xr-xsource/Concept/Framework/modules/logic/logic.c9
-rwxr-xr-xsource/Concept/Framework/modules/logic/logic.h20
2 files changed, 20 insertions, 9 deletions
diff --git a/source/Concept/Framework/modules/logic/logic.c b/source/Concept/Framework/modules/logic/logic.c
index 00599d8..f698495 100755
--- a/source/Concept/Framework/modules/logic/logic.c
+++ b/source/Concept/Framework/modules/logic/logic.c
@@ -3,10 +3,7 @@
//-----------------------------------------------------------------------------
void Logic::OnBallOwned()
{
- Wireless* ourWireless = parent->GetModule<Wireless>(IO_WIRELESS_MAIN);
-
- //ourWireless->Send(WIRELESS_CODE);
- //ourWireless->Send();
+ this->SetKeeper(false);
}
//-----------------------------------------------------------------------------
@@ -27,12 +24,12 @@ void Logic::Update()
// is Keeper?
if(isKeeper) {
// turn around al little bit...
- if((status == STATUS_KEEPER_TURN_LEFT && ourNavigator->AngleReached()) ||
+ if((status == STATUS_KEEPER_TURN_LEFT && !ourNavigator->IsMoving()) ||
(status != STATUS_KEEPER_TURN_LEFT && status != STATUS_KEEPER_TURN_RIGHT)) {
status = STATUS_KEEPER_TURN_RIGHT;
ourNavigator->RotateTo(315,200);
}
- else if(status == STATUS_KEEPER_TURN_RIGHT && ourNavigator->AngleReached()) {
+ else if(status == STATUS_KEEPER_TURN_RIGHT && !ourNavigator->IsMoving()) {
status = STATUS_KEEPER_TURN_LEFT;
ourNavigator->RotateTo(45, 200);
}
diff --git a/source/Concept/Framework/modules/logic/logic.h b/source/Concept/Framework/modules/logic/logic.h
index 296956b..ad8bad7 100755
--- a/source/Concept/Framework/modules/logic/logic.h
+++ b/source/Concept/Framework/modules/logic/logic.h
@@ -3,9 +3,6 @@
#include "../../stdafx.h"
-#define STATUS_KEEPER_TURN_RIGHT 1
-#define STATUS_KEEPER_TURN_LEFT 2
-
class Logic : public IO_Module
{
public:
@@ -29,9 +26,18 @@ protected:
bool isKeeper;
uint8 status;
+ enum LogicalStatus
+ {
+ STATUS_KEEPER_TURN_RIGHT,
+ STATUS_KEEPER_TURN_LEFT,
+ };
+
void OnBallOwned();
void OnBallLost();
+ void OnBecomeKeeper();
+ void OnBecomeAttacker();
+
public:
void Update();
@@ -46,6 +52,14 @@ public:
}
void SetKeeper(bool newStatus) {
+ if(!this->isKeeper && newStatus)
+ {
+ this->OnBecomeKeeper();
+ }
+ else if(this->isKeeper && !newStatus)
+ {
+ this->OnBecomeAttacker();
+ }
this->isKeeper = newStatus;
}