internal override void OnTimer(int id, float dt) { if (m_fTickGoal) { t += dt; if (State.time_state() < 1) { game_server.game_server_step(dt); game_client.game_client_step(); } else if (t > 0.05f && st_goal.coins_id != 0) { int coins = gui.gui_value(st_goal.coins_id); if (coins > 0) { int score = gui.gui_value(st_goal.score_id); int balls = gui.gui_value(st_goal.balls_id); gui.gui_set_count(st_goal.coins_id, coins - 1); gui.gui_pulse(st_goal.coins_id, 1.1f); gui.gui_set_count(st_goal.score_id, score + 1); gui.gui_pulse(st_goal.score_id, 1.1f); if (Progress.progress_reward_ball(score + 1) != 0) { gui.gui_set_count(st_goal.balls_id, balls + 1); gui.gui_pulse(st_goal.balls_id, 2.0f); Audio.audio_play(Common.AUD_BALL, 1.0f); } } t = 0.0f; } } gui.gui_timer(id, dt); }
internal override int OnEnter() { string s1 = "New Record"; string s2 = "GOAL"; int id, jd, kd, ld, md; Level l = Set.get_level(Progress.curr_level()); int high = Progress.progress_lvl_high(); if (st_goal.new_name != 0) { Progress.progress_rename(0); st_goal.new_name = 0; } if ((id = gui.gui_vstack(0)) != 0) { int gid; if (high != 0) { gid = gui.gui_label(id, s1, gui.GUI_MED, gui.GUI_ALL, widget.gui_grn, widget.gui_grn); } else { gid = gui.gui_label(id, s2, gui.GUI_LRG, gui.GUI_ALL, widget.gui_blu, widget.gui_grn); } gui.gui_space(id); if (Progress.curr_mode() == MODE.MODE_CHALLENGE) { int coins, score, balls; int i; /* Reverse-engineer initial score and balls. */ if (st_goal.resume != 0) { coins = 0; score = Progress.curr_score(); balls = Progress.curr_balls(); } else { coins = game_client.curr_coins(); score = Progress.curr_score() - coins; balls = Progress.curr_balls(); for (i = Progress.curr_score(); i > score; i--) { if (Progress.progress_reward_ball(i) != 0) { balls--; } } } string msg = Progress.curr_bonus().ToString() + (Progress.curr_bonus() == 1 ? " new bonus level" : " new bonus levels"); if ((jd = gui.gui_hstack(id)) != 0) { gui.gui_filler(jd); if ((kd = gui.gui_vstack(jd)) != 0) { if ((ld = gui.gui_hstack(kd)) != 0) { if ((md = gui.gui_harray(ld)) != 0) { st_goal.balls_id = gui.gui_count(md, 100, gui.GUI_MED, gui.GUI_NE); gui.gui_label(md, "Balls", gui.GUI_SML, 0, widget.gui_wht, widget.gui_wht); } if ((md = gui.gui_harray(ld)) != 0) { st_goal.score_id = gui.gui_count(md, 1000, gui.GUI_MED, 0); gui.gui_label(md, "Score", gui.GUI_SML, 0, widget.gui_wht, widget.gui_wht); } if ((md = gui.gui_harray(ld)) != 0) { st_goal.coins_id = gui.gui_count(md, 100, gui.GUI_MED, 0); gui.gui_label(md, "Coins", gui.GUI_SML, gui.GUI_NW, widget.gui_wht, widget.gui_wht); } gui.gui_set_count(st_goal.balls_id, balls); gui.gui_set_count(st_goal.score_id, score); gui.gui_set_count(st_goal.coins_id, coins); } gui.gui_label(kd, msg, gui.GUI_SML, gui.GUI_BOT, null, null); } gui.gui_filler(jd); } gui.gui_space(id); } else { st_goal.balls_id = st_goal.score_id = st_goal.coins_id = 0; } Util.gui_score_board(id, (Util.GUI_MOST_COINS | Util.GUI_BEST_TIMES | Util.GUI_FAST_UNLOCK), 1, high); gui.gui_space(id); if ((jd = gui.gui_harray(id)) != 0) { if (Progress.progress_done() != 0) { gui.gui_start(jd, "Finish", gui.GUI_SML, st_goal.GOAL_DONE, 0); } else if (Progress.progress_last() != 0) { gui.gui_start(jd, "Finish", gui.GUI_SML, st_goal.GOAL_LAST, 0); } if (Progress.progress_next_avail() != 0) { gui.gui_start(jd, "Next Level", gui.GUI_SML, st_goal.GOAL_NEXT, 0); } if (Progress.progress_same_avail() != 0) { gui.gui_start(jd, "Retry Level", gui.GUI_SML, st_goal.GOAL_SAME, 0); } } if (st_goal.resume == 0) { gui.gui_pulse(gid, 1.2f); } gui.gui_layout(id, 0, 0); } Util.set_score_board(l.most_coins, Progress.progress_coin_rank(), l.best_times, Progress.progress_time_rank(), l.fast_unlock, Progress.progress_goal_rank()); Audio.audio_music_fade_out(2.0f); Video.video_clr_grab(); /* Reset hack. */ st_goal.resume = 0; return(id); }