diff --git a/assets/images/tiled/maps/city.tmj b/assets/images/tiled/maps/city.tmj index 20f8993..cdebdf4 100644 --- a/assets/images/tiled/maps/city.tmj +++ b/assets/images/tiled/maps/city.tmj @@ -988,6 +988,17 @@ "width":50, "x":1454.66666666667, "y":50 + }, + { + "height":16, + "id":25, + "name":"chair", + "rotation":0, + "type":"", + "visible":true, + "width":17.2727272727273, + "x":159.454545454545, + "y":975.454545454545 }], "opacity":1, "type":"objectgroup", @@ -1018,7 +1029,7 @@ "y":0 }], "nextlayerid":16, - "nextobjectid":25, + "nextobjectid":26, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.10.2", diff --git a/lib/common/toast_utils.dart b/lib/common/toast_utils.dart index 74c778e..906976b 100644 --- a/lib/common/toast_utils.dart +++ b/lib/common/toast_utils.dart @@ -11,7 +11,7 @@ class ToastUtils { alignment: Alignment.bottomCenter, builder: (ctx, holder) { return SizedBox( - width: 200, + width: tip.length > 10 ? 400 : 200, height: 50, child: Center( child: Text( diff --git a/lib/game/decorations/chair.dart b/lib/game/decorations/chair.dart new file mode 100644 index 0000000..b876728 --- /dev/null +++ b/lib/game/decorations/chair.dart @@ -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 { + 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); + } +} diff --git a/lib/game/decorations/gaoshi.dart b/lib/game/decorations/gaoshi.dart index 8cc0c4b..f7613b0 100644 --- a/lib/game/decorations/gaoshi.dart +++ b/lib/game/decorations/gaoshi.dart @@ -17,7 +17,7 @@ class Gaoshi extends GameDecoration with Sensor, DecorationMixin { gameRef.player!.stopMove(); showGeneralDialog( - barrierLabel: "fes", + barrierLabel: "gaoshi", barrierDismissible: true, context: context, barrierColor: Colors.transparent, diff --git a/lib/game/maps/city_of_dream.dart b/lib/game/maps/city_of_dream.dart index 7d9cfad..71f0eaf 100644 --- a/lib/game/maps/city_of_dream.dart +++ b/lib/game/maps/city_of_dream.dart @@ -5,6 +5,7 @@ import 'package:bonfire/bonfire.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:make_a_dream/game/decorations/chair.dart'; import 'package:make_a_dream/game/decorations/classroom_entry.dart'; import 'package:make_a_dream/game/decorations/fes.dart'; import 'package:make_a_dream/game/decorations/fountain.dart'; @@ -49,6 +50,8 @@ class CityOfDream extends ConsumerWidget { ClassroomEntry(position: p.position, size: p.size, ref: ref), "gaoshi": (p) => Gaoshi(position: p.position, size: p.size, ref: ref), + "chair": (p) => + Chair(position: p.position, size: p.size, ref: ref) // "teacher2": (p) => BaseMentor( // position: p.position, // size: p.size, diff --git a/lib/isar/player_record.dart b/lib/isar/player_record.dart index 7d2871a..7da466f 100644 --- a/lib/isar/player_record.dart +++ b/lib/isar/player_record.dart @@ -210,6 +210,16 @@ class PlayerKnowledge { late double /* 生物 */ biography = 0; late double /* IT */ it = 0; + double get total => + math + + language + + history + + geography + + chemistry + + physics + + biography + + it; + String getKnowledgePrompt( {String teacherType = 'science teacher', String? his}) { String s = "你的学生基本情况如下:\n";