Skip to content
This repository has been archived by the owner on Dec 10, 2017. It is now read-only.

Commit

Permalink
Transition from round end state
Browse files Browse the repository at this point in the history
  • Loading branch information
strager committed Aug 7, 2012
1 parent b2334ef commit 83098d2
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
Binary file modified assets/game.fla
Binary file not shown.
Binary file modified assets/game.swc
Binary file not shown.
4 changes: 3 additions & 1 deletion src/kacount/RoundController.as
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ package kacount {
{ name: 'unready', from: 'countdown', to: 'waiting' },
{ name: 'play', from: 'countdown', to: 'counting' },
{ name: 'stop', from: 'counting', to: 'score' },
{ name: 'reset', from: 'score', to: 'waiting' },
{ name: 'end', from: 'score', to: 'end' },
]);

Expand Down Expand Up @@ -230,10 +231,11 @@ package kacount {
var goalCount:uint = this._monsterHist.total(this._goals);
this._gameScreen.endRound(goalCount, this._playerHist.count);

this.addCancel(Async.timeout(3000, this._sm.end));
this.addCancel(Async.timeout(3000, this._sm.reset));
}

public function exit_score():void {
this._gameScreen.endResults();
this.runCancels();
}
}
Expand Down
16 changes: 11 additions & 5 deletions src/kacount/view/GameScreen.as
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ package kacount.view {

public final class GameScreen {
private static var template:StateMachineTemplate = new StateMachineTemplate([
{ name: 'init', from: 'none', to: 'ready_screen' },
{ name: 'show_goal', from: 'ready_screen', to: 'goal_screen' },
{ name: 'hide_goal', from: 'goal_screen', to: 'ready_screen' },
{ name: 'start_round', from: 'goal_screen', to: 'game_screen' },
{ name: 'end_round', from: 'game_screen', to: 'results_screen' },
{ name: 'init', from: 'none', to: 'ready_screen' },
{ name: 'show_goal', from: 'ready_screen', to: 'goal_screen' },
{ name: 'hide_goal', from: 'goal_screen', to: 'ready_screen' },
{ name: 'start_round', from: 'goal_screen', to: 'game_screen' },
{ name: 'end_round', from: 'game_screen', to: 'results_screen' },
{ name: 'reset', from: 'results_screen', to: 'ready_screen' },
]);

private var _art:Screen = new Screen();
Expand Down Expand Up @@ -85,6 +86,11 @@ package kacount.view {
this._sm.end_round();
}

public function endResults():void {
F.forEach(this._players, F.invoke('endResults'));
this._sm.reset();
}

public function enter_ready_screen():void {
this._art.gotoAndPlay('ready_screen');
}
Expand Down
22 changes: 14 additions & 8 deletions src/kacount/view/Player.as
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ package kacount.view {

public final class Player {
private static var template:StateMachineTemplate = new StateMachineTemplate([
{ name: 'click', from: 'unready', to: 'ready', label: 'click_ready' },
{ name: 'click', from: 'ready', to: 'unready', label: 'click_unready' },
{ name: 'start', from: 'unready', to: 'playing' }, // FIXME should be to CPU
{ name: 'start', from: 'ready', to: 'playing' },
{ name: 'click', from: 'playing', to: 'playing', label: 'in_game_click' },
{ name: 'results', from: 'playing', to: 'results' },
{ name: 'click', from: 'unready', to: 'ready', label: 'click_ready' },
{ name: 'click', from: 'ready', to: 'unready', label: 'click_unready' },
{ name: 'start', from: 'unready', to: 'playing' }, // FIXME should be to CPU
{ name: 'start', from: 'ready', to: 'playing' },
{ name: 'click', from: 'playing', to: 'playing', label: 'in_game_click' },
{ name: 'results', from: 'playing', to: 'results' },
{ name: 'end_results', from: 'results', to: 'ready', label: 'end_ready' },
]);

private var _art:MovieClip;
Expand All @@ -32,23 +33,28 @@ package kacount.view {
public function get isReady():Boolean {
return this._sm.currentState === 'ready';
}

public function click():void {
if (this._sm.canTransition('click')) {
this._sm.click();
Sounds.bloop.play();
}
}

public function endResults():void {
this._sm.end_results();
}

public function start():void { this._sm.start(); }
public function results():void { this._sm.results(); }

public function when_click_unready():void { this._art.gotoAndPlay('unready'); }
public function when_click_ready():void { this._art.gotoAndPlay('ready'); }
public function when_in_game_click():void { this._art.gotoAndPlay('click'); }
public function when_end_ready():void { this._art.gotoAndPlay('close_results'); }

public function enter_click_to_play():void { this._art.gotoAndPlay('click_to_play'); }
public function enter_playing():void { this._art.gotoAndPlay('play'); }
public function enter_results():void { this._art.gotoAndPlay('results'); }
}
}
}

0 comments on commit 83098d2

Please sign in to comment.