updates audio files
This commit is contained in:
parent
27fc0535b3
commit
0ba199a777
27 changed files with 138 additions and 157 deletions
104
src/states.cpp
104
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue