Colocados los disparadores de los logros en su sitio
This commit is contained in:
@@ -23,6 +23,7 @@ void Cheevos::init()
|
|||||||
cheevos_t c;
|
cheevos_t c;
|
||||||
c.completed = false;
|
c.completed = false;
|
||||||
c.valid = true;
|
c.valid = true;
|
||||||
|
c.icon = 2;
|
||||||
|
|
||||||
c.id = 1;
|
c.id = 1;
|
||||||
c.caption = "SHINY THINGS";
|
c.caption = "SHINY THINGS";
|
||||||
@@ -86,7 +87,7 @@ void Cheevos::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Busca un logro por id y devuelve el indice
|
// Busca un logro por id y devuelve el indice
|
||||||
int Cheevos::findCheevo(int id)
|
int Cheevos::find(int id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < (int)cheevos.size(); ++i)
|
for (int i = 0; i < (int)cheevos.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -100,18 +101,34 @@ int Cheevos::findCheevo(int id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Desbloquea un logro
|
// Desbloquea un logro
|
||||||
void Cheevos::unlockCheevo(int id)
|
void Cheevos::unlock(int id)
|
||||||
{
|
{
|
||||||
const int index = findCheevo(id);
|
const int index = find(id);
|
||||||
|
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!cheevos[index].valid)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!cheevos[index].completed)
|
if (!cheevos[index].completed)
|
||||||
{
|
{
|
||||||
cheevos[index].completed = true;
|
cheevos[index].completed = true;
|
||||||
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption);
|
screen->showNotification("ACHIEVEMENT UNLOCKED!", cheevos[index].caption, cheevos[index].icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invalida un logro
|
||||||
|
void Cheevos::invalidate(int id)
|
||||||
|
{
|
||||||
|
const int index = find(id);
|
||||||
|
if (index == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cheevos[index].valid = false;
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ struct cheevos_t
|
|||||||
int id; // Identificador del logro
|
int id; // Identificador del logro
|
||||||
std::string caption; // Texto con el nombre del logro
|
std::string caption; // Texto con el nombre del logro
|
||||||
std::string description; // Texto que describe el logro
|
std::string description; // Texto que describe el logro
|
||||||
|
int icon; // Indice del icono a utilizar en la notificación
|
||||||
bool completed; // Indica si se ha obtenido el logro
|
bool completed; // Indica si se ha obtenido el logro
|
||||||
bool valid; // Indica si se puede obtener el logro
|
bool valid; // Indica si se puede obtener el logro
|
||||||
};
|
};
|
||||||
@@ -31,7 +32,7 @@ private:
|
|||||||
void init();
|
void init();
|
||||||
|
|
||||||
// Busca un logro por id y devuelve el indice
|
// Busca un logro por id y devuelve el indice
|
||||||
int findCheevo(int id);
|
int find(int id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@@ -41,7 +42,10 @@ public:
|
|||||||
~Cheevos();
|
~Cheevos();
|
||||||
|
|
||||||
// Desbloquea un logro
|
// Desbloquea un logro
|
||||||
void unlockCheevo(int id);
|
void unlock(int id);
|
||||||
|
|
||||||
|
// Invalida un logro
|
||||||
|
void invalidate(int id);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Director::Director(int argc, char *argv[])
|
|||||||
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
section->subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
section->name = SECTION_PROG_LOGO;
|
section->name = SECTION_PROG_GAME;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crea e inicializa las opciones del programa
|
// Crea e inicializa las opciones del programa
|
||||||
|
|||||||
@@ -467,6 +467,9 @@ void Game::killPlayer()
|
|||||||
// Actualiza las estadisticas
|
// Actualiza las estadisticas
|
||||||
stats->addDeath(room->getName());
|
stats->addDeath(room->getName());
|
||||||
|
|
||||||
|
// Invalida el logro de pasarse el juego sin morir
|
||||||
|
cheevos->invalidate(11);
|
||||||
|
|
||||||
// Destruye la habitacion y el jugador
|
// Destruye la habitacion y el jugador
|
||||||
delete room;
|
delete room;
|
||||||
delete this->player;
|
delete this->player;
|
||||||
@@ -583,6 +586,9 @@ bool Game::checkEndGame()
|
|||||||
|
|
||||||
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
if (haveTheItems && isOnTheRoom && isOnTheDoor)
|
||||||
{
|
{
|
||||||
|
// Comprueba los logros de completar el juego
|
||||||
|
checkEndGameCheevos();
|
||||||
|
|
||||||
section->name = SECTION_PROG_ENDING;
|
section->name = SECTION_PROG_ENDING;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -655,6 +661,14 @@ void Game::checkRestoringJail()
|
|||||||
board.lives++;
|
board.lives++;
|
||||||
JA_PlaySound(deathSound);
|
JA_PlaySound(deathSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invalida el logro de completar el juego sin entrar a la jail
|
||||||
|
const bool haveTheItems = board.items >= int(totalItems * 0.9f) || options->cheat.jailEnabled; // Con mas del 90% de los items recogidos
|
||||||
|
if (!haveTheItems)
|
||||||
|
{
|
||||||
|
cheevos->invalidate(9);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el diccionario de las estadísticas
|
// Inicializa el diccionario de las estadísticas
|
||||||
@@ -692,8 +706,69 @@ void Game::fillRoomNameTexture()
|
|||||||
// Comprueba algunos logros
|
// Comprueba algunos logros
|
||||||
void Game::checkSomeCheevos()
|
void Game::checkSomeCheevos()
|
||||||
{
|
{
|
||||||
if (board.items == 1)
|
// Logros sobre la cantidad de items
|
||||||
|
if (board.items == totalItems)
|
||||||
{
|
{
|
||||||
cheevos->unlockCheevo(2);
|
cheevos->unlock(4);
|
||||||
|
cheevos->unlock(3);
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.75f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(3);
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.5f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(2);
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
else if (board.items >= totalItems * 0.25f)
|
||||||
|
{
|
||||||
|
cheevos->unlock(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logros sobre las habitaciones visitadas
|
||||||
|
if (board.rooms >= 60)
|
||||||
|
{
|
||||||
|
cheevos->unlock(7);
|
||||||
|
cheevos->unlock(6);
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
else if (board.rooms >= 40)
|
||||||
|
{
|
||||||
|
cheevos->unlock(6);
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
else if (board.rooms >= 20)
|
||||||
|
{
|
||||||
|
cheevos->unlock(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba los logros de completar el juego
|
||||||
|
void Game::checkEndGameCheevos()
|
||||||
|
{
|
||||||
|
// "Complete the game"
|
||||||
|
cheevos->unlock(8);
|
||||||
|
|
||||||
|
// "Complete the game without entering the jail"
|
||||||
|
cheevos->unlock(9);
|
||||||
|
|
||||||
|
// "Complete the game with all items"
|
||||||
|
if (board.items == totalItems)
|
||||||
|
{
|
||||||
|
cheevos->unlock(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Complete the game without dying"
|
||||||
|
cheevos->unlock(11);
|
||||||
|
|
||||||
|
// "Complete the game in under 30 minutes"
|
||||||
|
if (scoreboard->getMinutes() < 30)
|
||||||
|
{
|
||||||
|
cheevos->unlock(12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,6 +143,9 @@ private:
|
|||||||
// Comprueba algunos logros
|
// Comprueba algunos logros
|
||||||
void checkSomeCheevos();
|
void checkSomeCheevos();
|
||||||
|
|
||||||
|
// Comprueba los logros de completar el juego
|
||||||
|
void checkEndGameCheevos();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug);
|
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, section_t *section, Debug *debug);
|
||||||
|
|||||||
@@ -170,3 +170,9 @@ void ScoreBoard::updateItemsColor()
|
|||||||
itemsColor = stringToColor(options->palette, "magenta");
|
itemsColor = stringToColor(options->palette, "magenta");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Devuelve la cantidad de minutos de juego transcurridos
|
||||||
|
int ScoreBoard::getMinutes()
|
||||||
|
{
|
||||||
|
return getTime().minutes;
|
||||||
|
}
|
||||||
@@ -84,6 +84,9 @@ public:
|
|||||||
|
|
||||||
// Quita el modo pausa del marcador
|
// Quita el modo pausa del marcador
|
||||||
void resume();
|
void resume();
|
||||||
|
|
||||||
|
// Devuelve la cantidad de minutos de juego transcurridos
|
||||||
|
int getMinutes();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user