-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d359ac
commit bd34511
Showing
6 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:bonfire/bonfire.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:make_a_dream/common/toast_utils.dart'; | ||
import 'package:make_a_dream/game/notifiers/player_notifier.dart'; | ||
|
||
class Chair extends GameDecoration with Sensor<Player> { | ||
Chair({required super.position, required super.size, required this.ref}); | ||
|
||
bool isTouched = false; | ||
final WidgetRef ref; | ||
|
||
@override | ||
void onContact(Player component) { | ||
super.onContact(component); | ||
if (gameRef.player != null && !isTouched) { | ||
gameRef.player!.stopMove(); | ||
isTouched = true; | ||
if (ref.read(playerProvider).current!.knowledge.total > 650) { | ||
ToastUtils.decorationTip(null, tip: "是时候了!"); | ||
} else { | ||
ToastUtils.decorationTip(null, tip: "时机尚未成熟,我的朋友..."); | ||
// [23 * 16 = 368,58 * 928] | ||
gameRef.player!.translate(Vector2(368 - position.x, 928 - position.y)); | ||
gameRef.player!.moveDown(); | ||
} | ||
} | ||
} | ||
|
||
@override | ||
void onContactExit(Player component) { | ||
isTouched = false; | ||
super.onContactExit(component); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters