| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of dartcombatlib; | 5 part of dartcombatlib; |
| 6 | 6 |
| 7 void spawnPlayer() { | 7 void spawnPlayer() { |
| 8 PlayerState state = new PlayerState(); | 8 PlayerState state = new PlayerState(); |
| 9 port.receive(state.dispatch); | 9 port.receive(state.dispatch); |
| 10 } | 10 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 static const DOWN_DIR = const [0, 1]; | 181 static const DOWN_DIR = const [0, 1]; |
| 182 | 182 |
| 183 Future<bool> _exploreAllDirections(int x, int y, bool parallel) { | 183 Future<bool> _exploreAllDirections(int x, int y, bool parallel) { |
| 184 Completer<bool> superShot_ = new Completer<bool>(); | 184 Completer<bool> superShot_ = new Completer<bool>(); |
| 185 if (parallel) { | 185 if (parallel) { |
| 186 final arr = new List<Future<bool>>(); | 186 final arr = new List<Future<bool>>(); |
| 187 arr.add(_exploreDirectionHelper(LEFT_DIR, x, y)); | 187 arr.add(_exploreDirectionHelper(LEFT_DIR, x, y)); |
| 188 arr.add(_exploreDirectionHelper(RIGHT_DIR, x, y)); | 188 arr.add(_exploreDirectionHelper(RIGHT_DIR, x, y)); |
| 189 arr.add(_exploreDirectionHelper(UP_DIR, x, y)); | 189 arr.add(_exploreDirectionHelper(UP_DIR, x, y)); |
| 190 arr.add(_exploreDirectionHelper(DOWN_DIR, x, y)); | 190 arr.add(_exploreDirectionHelper(DOWN_DIR, x, y)); |
| 191 Futures.wait(arr).then((arrValues) { | 191 Future.wait(arr).then((arrValues) { |
| 192 superShot_.complete(true); | 192 superShot_.complete(true); |
| 193 }); | 193 }); |
| 194 } else { | 194 } else { |
| 195 _seqExploreDirectionHelper(LEFT_DIR, x, y, superShot_, | 195 _seqExploreDirectionHelper(LEFT_DIR, x, y, superShot_, |
| 196 _seqExploreDirectionHelper(RIGHT_DIR, x, y, superShot_, | 196 _seqExploreDirectionHelper(RIGHT_DIR, x, y, superShot_, |
| 197 _seqExploreDirectionHelper(UP_DIR, x, y, superShot_, | 197 _seqExploreDirectionHelper(UP_DIR, x, y, superShot_, |
| 198 _seqExploreDirectionHelper(DOWN_DIR, x, y, superShot_, null))))(fa
lse); | 198 _seqExploreDirectionHelper(DOWN_DIR, x, y, superShot_, null))))(fa
lse); |
| 199 } | 199 } |
| 200 return superShot_.future; | 200 return superShot_.future; |
| 201 } | 201 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 case Constants.SUNK: | 296 case Constants.SUNK: |
| 297 totalHits++; | 297 totalHits++; |
| 298 boatsSunk++; | 298 boatsSunk++; |
| 299 _enemyView.addHit(x, y); | 299 _enemyView.addHit(x, y); |
| 300 enemyGrid.hit(x, y); | 300 enemyGrid.hit(x, y); |
| 301 break; | 301 break; |
| 302 } | 302 } |
| 303 _enemyView.statusBar.updateStatus(); | 303 _enemyView.statusBar.updateStatus(); |
| 304 } | 304 } |
| 305 } | 305 } |
| OLD | NEW |