efbb: clear targets del callback on level unload
Otherwise it will create the timer to show win layout when user calls the menu, or loses and retry the game. SVN revision: 77474
This commit is contained in:
parent
46991342bb
commit
1347026337
|
@ -44,13 +44,13 @@ struct _Game {
|
||||||
Ecore_Timer *end_timer;
|
Ecore_Timer *end_timer;
|
||||||
Eina_List *levels;
|
Eina_List *levels;
|
||||||
Eina_List *extra_obj;
|
Eina_List *extra_obj;
|
||||||
|
Eina_List *targets;
|
||||||
|
|
||||||
Etrophy_Gamescore *gamescore;
|
Etrophy_Gamescore *gamescore;
|
||||||
Score *score;
|
Score *score;
|
||||||
Level *cur_level;
|
Level *cur_level;
|
||||||
World *world;
|
World *world;
|
||||||
|
|
||||||
int targets;
|
|
||||||
int old_cx;
|
int old_cx;
|
||||||
int strength;
|
int strength;
|
||||||
int angle;
|
int angle;
|
||||||
|
@ -113,17 +113,11 @@ _win_cb(void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_target_dec(void *data, EPhysics_Body *body __UNUSED__,
|
_target_dec(void *data, EPhysics_Body *body, void *event_info __UNUSED__)
|
||||||
void *event_info __UNUSED__)
|
|
||||||
{
|
{
|
||||||
Game *game = data;
|
Game *game = data;
|
||||||
|
game->targets = eina_list_remove(game->targets, body);
|
||||||
if (!game->cur_world)
|
if (!eina_list_count(game->targets))
|
||||||
return;
|
|
||||||
|
|
||||||
game->targets--;
|
|
||||||
|
|
||||||
if (!game->targets)
|
|
||||||
game->end_timer = ecore_timer_add(3, _win_cb, game);
|
game->end_timer = ecore_timer_add(3, _win_cb, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,7 +654,7 @@ _create_target(Game *game, const char *type, int w, int h, int x, int y)
|
||||||
_target_dec, game);
|
_target_dec, game);
|
||||||
ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_DEL,
|
ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_DEL,
|
||||||
_body_del, NULL);
|
_body_del, NULL);
|
||||||
game->targets++;
|
game->targets = eina_list_append(game->targets, body);
|
||||||
|
|
||||||
DBG("Target created at (%i, %i)", x, y);
|
DBG("Target created at (%i, %i)", x, y);
|
||||||
}
|
}
|
||||||
|
@ -694,6 +688,11 @@ static void
|
||||||
level_unload(Game *game)
|
level_unload(Game *game)
|
||||||
{
|
{
|
||||||
Evas_Object *extra_object;
|
Evas_Object *extra_object;
|
||||||
|
EPhysics_Body *target;
|
||||||
|
|
||||||
|
EINA_LIST_FREE(game->targets, target)
|
||||||
|
ephysics_body_event_callback_del(target, EPHYSICS_CALLBACK_BODY_DEL,
|
||||||
|
_target_dec);
|
||||||
|
|
||||||
if (game->cur_world)
|
if (game->cur_world)
|
||||||
{
|
{
|
||||||
|
@ -945,12 +944,13 @@ _wstopped(void *data, EPhysics_World *world __UNUSED__,
|
||||||
|
|
||||||
if (((cannon_ammo_get(game->cannon) > 0) ||
|
if (((cannon_ammo_get(game->cannon) > 0) ||
|
||||||
(cannon_loaded_get(game->cannon))) &&
|
(cannon_loaded_get(game->cannon))) &&
|
||||||
((game->targets > 0) && (!level_time_attack_get(game->cur_level))))
|
((eina_list_count(game->targets)) &&
|
||||||
|
(!level_time_attack_get(game->cur_level))))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
game->camera_moving = EINA_FALSE;
|
game->camera_moving = EINA_FALSE;
|
||||||
|
|
||||||
if (game->targets <= 0)
|
if (!eina_list_count(game->targets))
|
||||||
{
|
{
|
||||||
_level_win(game);
|
_level_win(game);
|
||||||
return;
|
return;
|
||||||
|
@ -1000,7 +1000,6 @@ _level_load(Game *game)
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
int hiscore;
|
int hiscore;
|
||||||
|
|
||||||
game->targets = 0;
|
|
||||||
game->old_cx = 0;
|
game->old_cx = 0;
|
||||||
|
|
||||||
game->bg = bg_add(game->win, level_bg_get(game->cur_level));
|
game->bg = bg_add(game->win, level_bg_get(game->cur_level));
|
||||||
|
|
Loading…
Reference in New Issue