From 0ba199a777520795c5f204d2d8bc9f6c204fe886 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 31 May 2024 15:55:14 +0200 Subject: [PATCH] updates audio files --- assets/0001Idle.mp3 | 3 - assets/0001WaitingForGameStart.mp3 | 3 + assets/0002Falsche Nebenstation.mp3 | 3 - assets/0002OnTheMoveMainStation.mp3 | 3 + assets/0003StationOneCorrect.mp3 | 3 + assets/0003Timer abgelaufen.mp3 | 3 - assets/0004Spiel gewonnen.mp3 | 3 - assets/0004StationTwoCorrekt.mp3 | 3 + ...05Objekt von der Nebenstation entfernt.mp3 | 3 - assets/0005StationTreeCorrekt.mp3 | 3 + ...006Objekt von der Haupstation entfernt.mp3 | 3 - assets/0006StationFourCorrekt.mp3 | 3 + assets/0007Objekt auf Hauptstation.mp3 | 3 - assets/0007WrongStation.mp3 | 3 + assets/0008Ende.mp3 | 3 + assets/0008Objekt auf einer Nebenstation.mp3 | 3 - assets/0009Stress.mp3 | 3 + assets/0010StationTwoPickUp-240528_1353.mp3 | 3 + assets/0011StationTreePickup-240528_1354.mp3 | 3 + assets/0012StationFourPickUp-240528_1357.mp3 | 3 + src/main.cpp | 17 ++- src/sequences.cpp | 17 --- src/sequences.h | 13 --- src/sounds.h | 31 ++++-- src/state.h | 47 -------- src/states.cpp | 104 ++++++++++++------ src/states.h | 6 +- 27 files changed, 138 insertions(+), 157 deletions(-) delete mode 100644 assets/0001Idle.mp3 create mode 100644 assets/0001WaitingForGameStart.mp3 delete mode 100644 assets/0002Falsche Nebenstation.mp3 create mode 100644 assets/0002OnTheMoveMainStation.mp3 create mode 100644 assets/0003StationOneCorrect.mp3 delete mode 100644 assets/0003Timer abgelaufen.mp3 delete mode 100644 assets/0004Spiel gewonnen.mp3 create mode 100644 assets/0004StationTwoCorrekt.mp3 delete mode 100644 assets/0005Objekt von der Nebenstation entfernt.mp3 create mode 100644 assets/0005StationTreeCorrekt.mp3 delete mode 100644 assets/0006Objekt von der Haupstation entfernt.mp3 create mode 100644 assets/0006StationFourCorrekt.mp3 delete mode 100644 assets/0007Objekt auf Hauptstation.mp3 create mode 100644 assets/0007WrongStation.mp3 create mode 100644 assets/0008Ende.mp3 delete mode 100644 assets/0008Objekt auf einer Nebenstation.mp3 create mode 100644 assets/0009Stress.mp3 create mode 100644 assets/0010StationTwoPickUp-240528_1353.mp3 create mode 100644 assets/0011StationTreePickup-240528_1354.mp3 create mode 100644 assets/0012StationFourPickUp-240528_1357.mp3 diff --git a/assets/0001Idle.mp3 b/assets/0001Idle.mp3 deleted file mode 100644 index 97690f6..0000000 --- a/assets/0001Idle.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:007daa6dd0fcda10a4c31ce0fb6d2f75ec623bb094557e37d977df861fe4b2ed -size 11886 diff --git a/assets/0001WaitingForGameStart.mp3 b/assets/0001WaitingForGameStart.mp3 new file mode 100644 index 0000000..770243b --- /dev/null +++ b/assets/0001WaitingForGameStart.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec88a517b806134f631356e8d1fdee31f1bb7680d9a444d799376e00268228ef +size 160913 diff --git a/assets/0002Falsche Nebenstation.mp3 b/assets/0002Falsche Nebenstation.mp3 deleted file mode 100644 index 57fdfb8..0000000 --- a/assets/0002Falsche Nebenstation.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c7782fc7bc2ff00baaf2e59109efe8f6cb7c4485c3e90bc5d215186b97c289ec -size 30238 diff --git a/assets/0002OnTheMoveMainStation.mp3 b/assets/0002OnTheMoveMainStation.mp3 new file mode 100644 index 0000000..a031088 --- /dev/null +++ b/assets/0002OnTheMoveMainStation.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:77f0d5058b2cec382951dd88e4d1cb34b62f083bcb0ac466895d93a34b47152a +size 788688 diff --git a/assets/0003StationOneCorrect.mp3 b/assets/0003StationOneCorrect.mp3 new file mode 100644 index 0000000..74cf115 --- /dev/null +++ b/assets/0003StationOneCorrect.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:412db447abde936505799b6b1db4b382712c890ee333a8d52b8568fd844d818e +size 496952 diff --git a/assets/0003Timer abgelaufen.mp3 b/assets/0003Timer abgelaufen.mp3 deleted file mode 100644 index bc0a18c..0000000 --- a/assets/0003Timer abgelaufen.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:98ea95f497c3d77e312c953ee5d0d317026b1317976491b9ae2c488524cd418c -size 27690 diff --git a/assets/0004Spiel gewonnen.mp3 b/assets/0004Spiel gewonnen.mp3 deleted file mode 100644 index b4e6662..0000000 --- a/assets/0004Spiel gewonnen.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aacc30cf4fee2d815ecb8d5374d527ab23534c54656a88fb4acf567a2f043e28 -size 25864 diff --git a/assets/0004StationTwoCorrekt.mp3 b/assets/0004StationTwoCorrekt.mp3 new file mode 100644 index 0000000..4924619 --- /dev/null +++ b/assets/0004StationTwoCorrekt.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0876d584bd52ff56d25fe38ff8fc33e90c2a10bd56f3879bc503954554e8802f +size 529135 diff --git a/assets/0005Objekt von der Nebenstation entfernt.mp3 b/assets/0005Objekt von der Nebenstation entfernt.mp3 deleted file mode 100644 index 429bfd9..0000000 --- a/assets/0005Objekt von der Nebenstation entfernt.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:51c18a31dd9f7b338ae2c43a41eaeb53f0a649b13fe7f750ecb01adaad991971 -size 37334 diff --git a/assets/0005StationTreeCorrekt.mp3 b/assets/0005StationTreeCorrekt.mp3 new file mode 100644 index 0000000..c765810 --- /dev/null +++ b/assets/0005StationTreeCorrekt.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:02f59fbe2074954153b434e0d5ee7ed9ccf1a04e38aa138f7d7e036b28b87b4a +size 577200 diff --git a/assets/0006Objekt von der Haupstation entfernt.mp3 b/assets/0006Objekt von der Haupstation entfernt.mp3 deleted file mode 100644 index 14364b6..0000000 --- a/assets/0006Objekt von der Haupstation entfernt.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f4be3d3e0130a9825cb388959e15d2d103776cf495c32fdadf6b016d265e27a0 -size 41317 diff --git a/assets/0006StationFourCorrekt.mp3 b/assets/0006StationFourCorrekt.mp3 new file mode 100644 index 0000000..3352851 --- /dev/null +++ b/assets/0006StationFourCorrekt.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f976b55be7544fd935cbd6641814b6ad68d159f0196d1beb5c325f8398000eb9 +size 560900 diff --git a/assets/0007Objekt auf Hauptstation.mp3 b/assets/0007Objekt auf Hauptstation.mp3 deleted file mode 100644 index 2e22898..0000000 --- a/assets/0007Objekt auf Hauptstation.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6e1c509f2c3ea6329e37c57c120c44dae7c4814e045a048af5b2dd5e2917f71a -size 31153 diff --git a/assets/0007WrongStation.mp3 b/assets/0007WrongStation.mp3 new file mode 100644 index 0000000..8a9302a --- /dev/null +++ b/assets/0007WrongStation.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db9a11bf61e119fa54e2c1076c927a9f5e7ae8456bccbc218f93b6f9e977f40f +size 112848 diff --git a/assets/0008Ende.mp3 b/assets/0008Ende.mp3 new file mode 100644 index 0000000..7189145 --- /dev/null +++ b/assets/0008Ende.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:72ae1487606e80e17c1feaf3d658bda123fd5899ecc093cd7b1f76c2a30395a9 +size 433004 diff --git a/assets/0008Objekt auf einer Nebenstation.mp3 b/assets/0008Objekt auf einer Nebenstation.mp3 deleted file mode 100644 index 6f424a4..0000000 --- a/assets/0008Objekt auf einer Nebenstation.mp3 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:df11e75f9b213b6bf05230ca4a7854f50a54effd4c02cd2c7182f7681c96b4e8 -size 31711 diff --git a/assets/0009Stress.mp3 b/assets/0009Stress.mp3 new file mode 100644 index 0000000..be66a66 --- /dev/null +++ b/assets/0009Stress.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b397a70389e33a600499e5099f877aae097efee606fb5c4d20a26d99deac2e3c +size 177213 diff --git a/assets/0010StationTwoPickUp-240528_1353.mp3 b/assets/0010StationTwoPickUp-240528_1353.mp3 new file mode 100644 index 0000000..193d8db --- /dev/null +++ b/assets/0010StationTwoPickUp-240528_1353.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7ce4b76e0861a9b09d0c0eb91887c57d725f00f7679077eab78307b4b00dc8d7 +size 114101 diff --git a/assets/0011StationTreePickup-240528_1354.mp3 b/assets/0011StationTreePickup-240528_1354.mp3 new file mode 100644 index 0000000..9673539 --- /dev/null +++ b/assets/0011StationTreePickup-240528_1354.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5715202057ba2064c689c4aece267dc05dbb779c4646ac59a4bbfd7814ebaa4c +size 168854 diff --git a/assets/0012StationFourPickUp-240528_1357.mp3 b/assets/0012StationFourPickUp-240528_1357.mp3 new file mode 100644 index 0000000..6db8374 --- /dev/null +++ b/assets/0012StationFourPickUp-240528_1357.mp3 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:531ff46ad49986287d2a460b283d225cf0514b2318202af6ffe175e939867559 +size 152972 diff --git a/src/main.cpp b/src/main.cpp index 6b6f09f..ccb1681 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,15 +19,14 @@ // The library in use is slightly modified to fix this issue: https://github.com/adafruit/Adafruit-PN532/issues/117 Adafruit_PN532 nfc(PN532_CS); -constexpr int rs = 9, en = 8, d4 = 5, d5 = 4, d6 = 3, d7 = 2; -LiquidCrystal lcd(rs, en, d4, d5, d6, d7); +LiquidCrystal lcd(9, 8, 5, 4, 3, 2); SoftwareSerial softSerial(6, 7); // RX, TX DFRobotDFPlayerMini dfPlayer; Station stations[5] = { - Station(1680767519, "Yellow"), Station(3346823711, "Green"), Station(3569318175, "Pink"), - Station(2174777887, "Blue"), Station(102951984, "Weird") + Station(1680767519, "Main"), Station(102951984, "Muhvella"), Station(3346823711, "Magie"), + Station(2174777887, "Bicola"), Station(3569318175, "Tobione") }; Station* currentStation; int currentStationIndex = -1; @@ -158,17 +157,17 @@ void loop(void) void setup(void) { - initSequences(); - setupNFC(); Serial.begin(9600); // Serial.println(ON_MAIN_STATION.getEntryAtIndex(0)->isAudio); + setupNFC(); lcd.begin(16, 2); + stationDetectionTimer.start(); softSerial.begin(9600); - + lcd.print("Initializing MP3"); lcd.clear(); if (!dfPlayer.begin(softSerial, true, true)) @@ -182,6 +181,6 @@ void setup(void) // printMp3Detail(&lcd, dfPlayer.readType(), dfPlayer.read()); } } - - dfPlayer.volume(7); + + dfPlayer.volume(18); } diff --git a/src/sequences.cpp b/src/sequences.cpp index 38a9968..896a4da 100644 --- a/src/sequences.cpp +++ b/src/sequences.cpp @@ -2,20 +2,3 @@ #include "sequence.h" #include "sounds.h" -// Define global sequences -Sequence ON_MAIN_STATION(0); -Sequence AFTER_MAIN_STATION(0); -Sequence HACKING_STATION_MUHVELLA(0); -Sequence AFTER_MUHVELLA(0); -Sequence HACKING_STATION_MAGIE(0); -Sequence AFTER_MAGIE(0); -Sequence HACKING_STATION_BICOLA(0); -Sequence AFTER_BICOLA(0); -Sequence HACKING_STATION_TOBIONE(0); -Sequence AFTER_TOBIONE(0); - -void initSequences() { - ON_MAIN_STATION.addEntry(SequenceEntry(true, 1000, IDLE)); - ON_MAIN_STATION.addEntry(SequenceEntry(false, 3000, 0)); - ON_MAIN_STATION.addEntry(SequenceEntry(true, 1000, IDLE)); -} \ No newline at end of file diff --git a/src/sequences.h b/src/sequences.h index d2c9690..1ce68e7 100644 --- a/src/sequences.h +++ b/src/sequences.h @@ -1,16 +1,3 @@ #pragma once #include "sequences.h" #include "sequence.h" - -extern Sequence ON_MAIN_STATION; -extern Sequence AFTER_MAIN_STATION; -extern Sequence HACKING_STATION_MUHVELLA; -extern Sequence AFTER_MUHVELLA; -extern Sequence HACKING_STATION_MAGIE; -extern Sequence AFTER_MAGIE; -extern Sequence HACKING_STATION_BICOLA; -extern Sequence AFTER_BICOLA; -extern Sequence HACKING_STATION_TOBIONE; -extern Sequence AFTER_TOBIONE; - -void initSequences(); diff --git a/src/sounds.h b/src/sounds.h index 8ae16ad..8c1c6aa 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -1,11 +1,26 @@ #include #define NONE 0 -#define IDLE 1 -#define WRONG_SIDE_STATION 2 -#define TIMER_DOWN 3 -#define GAME_WON 4 -#define REMOVED_FROM_SIDE_STATION 5 -#define REMOVED_FROM_MAIN_STATION 6 -#define OBJECT_PLACED_ON_MAIN_STATION 7 -#define OBJECT_PLACED_ON_SIDE_STATION 8 +#define WAITING_FOR_GAME_START 1 +#define AFTER_MAIN_STATION 2 + +#define HACKING_STATION_MUHVELLA 3 +#define PICKUP_STATION_MUHVELLA 10 +#define AFTER_MUHVELLA 10 // incorrect + +#define HACKING_STATION_MAGIE 4 +#define PICKUP_STATION_MAGIE 11 +#define AFTER_MAGIE 11 // incorrect + +#define HACKING_STATION_BICOLA 5 +#define PICKUP_STATION_BICOLA 12 +#define AFTER_BICOLA 12 // incorrect + +#define HACKING_STATION_TOBIONE 6 +#define PICKUP_STATION_TOBIONE 13 +#define AFTER_TOBIONE 13 // incorrect + +#define END 8 +#define WRONG_STATION 7 + +#define STRESS 9 diff --git a/src/state.h b/src/state.h index 7615be1..a9774c5 100644 --- a/src/state.h +++ b/src/state.h @@ -10,23 +10,9 @@ class Station; class State { -private: - Timer sequenceTimer; - bool currentEntryHandled; - -protected: - Sequence* sequence; - int sequencePointer; - bool sequenceDone; - public: virtual ~State() = default; - explicit State(Sequence* sequence): sequenceTimer(Timer(0, false)), currentEntryHandled(false), sequence(sequence), - sequencePointer(0), sequenceDone(false) - { - } - virtual State* pickedUp(Context context) { return this; } virtual State* putDown(Context context, Station* newStation) { return this; } virtual State* update(Context context) { return this; } @@ -37,37 +23,4 @@ public: virtual String updateDisplay() { return ""; } - void updateSeqence(const Context& context) - { - if (sequence == nullptr || sequence->getLength() == 0) - { - return; - } - if (!currentEntryHandled) - { - const auto currentEntry = sequence->getEntryAtIndex(sequencePointer); - const auto addressInt = reinterpret_cast(currentEntry); - this->sequenceTimer = Timer(currentEntry->duration, false); - this->sequenceTimer.start(); - if (currentEntry->isAudio) - { - // printMp3Detail(context.dfPlayer->readType(), context.dfPlayer->read()); - context.dfPlayer->play(currentEntry->audioId); - } - currentEntryHandled = true; - } - const bool timeOut = this->sequenceTimer.update(context.delta); - if (timeOut) - { - if (this->sequencePointer + 2 >= this->sequence->getLength()) - { - sequencePointer = sequence->getRepeatIndex(); - sequenceDone = true; - currentEntryHandled = false; - return; - } - this->sequencePointer += 1; - currentEntryHandled = false; - } - } }; diff --git a/src/states.cpp b/src/states.cpp index e717945..ef9a478 100644 --- a/src/states.cpp +++ b/src/states.cpp @@ -6,9 +6,7 @@ #include "station.h" #include "sounds.h" -Startup::Startup(): State(nullptr) -{ -} +Startup::Startup() = default; State* Startup::putDown(const Context context, Station* newStation) { @@ -23,7 +21,6 @@ State* Startup::putDown(const Context context, Station* newStation) State* Startup::update(const Context context) { - updateSeqence(context); return this; } @@ -41,20 +38,15 @@ void Startup::activated(Context context) //------------------------------------ -WaitingForGameStart::WaitingForGameStart() : State(&ON_MAIN_STATION) -{ -} +WaitingForGameStart::WaitingForGameStart() = default; State* WaitingForGameStart::pickedUp(const Context context) { - return new OnTheMove(context.stations + 1, &AFTER_MAIN_STATION); // first element of the array + return new OnTheMove(context.stations + 1); // first element of the array } State* WaitingForGameStart::update(const Context context) { - // Serial.println("update wait"); - updateSeqence(context); - // Serial.println("after"); return this; } @@ -66,14 +58,14 @@ String WaitingForGameStart::updateDisplay() void WaitingForGameStart::activated(const Context context) { - context.dfPlayer->play(IDLE); + context.dfPlayer->loop(WAITING_FOR_GAME_START); } //------------------------------------ -OnTheMove::OnTheMove(Station* targetStation, Sequence* sequence): State(sequence) +OnTheMove::OnTheMove(Station* targetStation) { this->targetStation = targetStation; } @@ -86,7 +78,7 @@ State* OnTheMove::putDown(const Context context, Station* newStation) { return new End(); } - return new Hacking(this->targetStation, nullptr); + return new Hacking(this->targetStation); } return new IncorrectStation(targetStation); @@ -94,7 +86,6 @@ State* OnTheMove::putDown(const Context context, Station* newStation) State* OnTheMove::update(const Context context) { - updateSeqence(context); return this; } @@ -108,11 +99,19 @@ void OnTheMove::activated(const Context context) const int index = context.getStationIndex(this->targetStation); if (index == 1) { - context.dfPlayer->play(REMOVED_FROM_MAIN_STATION); + context.dfPlayer->play(AFTER_MAIN_STATION); } - else + else if (index == 2) { - context.dfPlayer->play(REMOVED_FROM_SIDE_STATION); + context.dfPlayer->play(AFTER_MUHVELLA); + } + else if (index == 3) + { + context.dfPlayer->play(AFTER_MAGIE); + } + else if (index == 4) + { + context.dfPlayer->play(AFTER_BICOLA); } } @@ -120,19 +119,18 @@ void OnTheMove::activated(const Context context) //------------------------------------ -IncorrectStation::IncorrectStation(Station* targetStation): State(nullptr) // todo remove nullptr +IncorrectStation::IncorrectStation(Station* targetStation) { this->targetStation = targetStation; } State* IncorrectStation::pickedUp(const Context context) { - return new OnTheMove(this->targetStation, nullptr); // todo fix nullptr + return new OnTheMove(this->targetStation); // todo fix nullptr } State* IncorrectStation::update(const Context context) { - updateSeqence(context); return this; } @@ -141,15 +139,16 @@ String IncorrectStation::updateDisplay() return "Wrong Station! "; } -void IncorrectStation::activated(Context context) +void IncorrectStation::activated(const Context context) { + context.dfPlayer->play(WRONG_STATION); } //------------------------------------ -Hacking::Hacking(Station* currentStation, Sequence* sequence): State(sequence), timer(5000, false) +Hacking::Hacking(Station* currentStation): timer(5000, false) { this->currentStation = currentStation; this->timer.start(); @@ -162,7 +161,6 @@ State* Hacking::pickedUp(const Context context) State* Hacking::update(const Context context) { - updateSeqence(context); Serial.println(String(context.delta)); const bool done = timer.update(context.delta); @@ -171,7 +169,7 @@ State* Hacking::update(const Context context) const int currentStationIndex = context.getStationIndex(currentStation); const int nextStationIndex = (currentStationIndex + 1) % context.stationCount; Station* nextStation = context.stations + nextStationIndex; - return new WaitingForPickup(currentStation, nextStation, nullptr); + return new WaitingForPickup(currentStation, nextStation); } return this; } @@ -183,14 +181,35 @@ String Hacking::updateDisplay() void Hacking::activated(const Context context) { - context.dfPlayer->play(OBJECT_PLACED_ON_MAIN_STATION); + auto currentStationIndex = context.getStationIndex(this->currentStation); + if (currentStationIndex == 1) + { + timer = Timer(31000, false); + context.dfPlayer->play(HACKING_STATION_MUHVELLA); + } + if (currentStationIndex == 2) + { + timer = Timer(33000, false); + context.dfPlayer->play(HACKING_STATION_MAGIE); + } + if (currentStationIndex == 3) + { + timer = Timer(36000, false); + context.dfPlayer->play(HACKING_STATION_BICOLA); + } + if (currentStationIndex == 4) + { + timer = Timer(35000, false); + context.dfPlayer->play(HACKING_STATION_TOBIONE); + } + timer.start(); } //------------------------------------ -Complain::Complain(Station* currentStation): State(nullptr) +Complain::Complain(Station* currentStation) { this->currentStation = currentStation; } @@ -199,7 +218,7 @@ State* Complain::putDown(const Context context, Station* newStation) { if (this->currentStation == newStation) // was put back on correct station { - return new Hacking(this->currentStation, nullptr); + return new Hacking(this->currentStation); } return this; // was not put back on correct station (just keeps complaining) } @@ -222,7 +241,7 @@ void Complain::activated(Context context) //------------------------------------ -WaitingForPickup::WaitingForPickup(Station* currentStation, Station* targetStation, Sequence* sequence): State(sequence) +WaitingForPickup::WaitingForPickup(Station* currentStation, Station* targetStation) { this->currentStation = currentStation; this->targetStation = targetStation; @@ -230,7 +249,7 @@ WaitingForPickup::WaitingForPickup(Station* currentStation, Station* targetStati State* WaitingForPickup::pickedUp(Context context) { - return new OnTheMove(targetStation, nullptr); + return new OnTheMove(targetStation); } State* WaitingForPickup::update(Context context) @@ -245,17 +264,30 @@ String WaitingForPickup::updateDisplay() void WaitingForPickup::activated(Context context) { + auto currentStationIndex = context.getStationIndex(this->currentStation); + if (currentStationIndex == 1) + { + context.dfPlayer->loop(PICKUP_STATION_MUHVELLA); + } + if (currentStationIndex == 2) + { + context.dfPlayer->loop(PICKUP_STATION_MAGIE); + } + if (currentStationIndex == 3) + { + context.dfPlayer->loop(PICKUP_STATION_BICOLA); + } + if (currentStationIndex == 4) + { + context.dfPlayer->loop(PICKUP_STATION_TOBIONE); + } } //------------------------------------ -End::End():State(nullptr) -{ - -} - +End::End() = default; State* End::pickedUp(const Context context) { @@ -276,5 +308,5 @@ String End::updateDisplay() void End::activated(const Context context) { - context.dfPlayer->play(GAME_WON); + context.dfPlayer->play(END); } diff --git a/src/states.h b/src/states.h index 12a05d6..f89b856 100644 --- a/src/states.h +++ b/src/states.h @@ -33,7 +33,7 @@ private: Station* targetStation; public: - explicit OnTheMove(Station* targetStation, Sequence* sequence); + explicit OnTheMove(Station* targetStation); State* putDown(Context context, Station* newStation) override; State* update(Context context) override; String updateDisplay() override; @@ -61,7 +61,7 @@ private: Station* currentStation; public: - explicit Hacking(Station* currentStation, Sequence* sequence); + explicit Hacking(Station* currentStation); State* pickedUp(Context context) override; State* update(Context context) override; String updateDisplay() override; @@ -88,7 +88,7 @@ private: Station* targetStation; public: - WaitingForPickup(Station* currentStation, Station* targetStation, Sequence* sequence); + WaitingForPickup(Station* currentStation, Station* targetStation); State* pickedUp(Context context) override; State* update(Context context) override; String updateDisplay() override;