From 74c85cd5a7a9e74b2b783904a79ad8db58f68422 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Mon, 3 Jun 2024 22:58:59 +0800 Subject: [PATCH] =?UTF-8?q?Support=20for=20generating=20creatures=20on=20t?= =?UTF-8?q?he=20map,=20adding=20the=20game=20end=20screen.=20=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=9C=A8=E5=9C=B0=E5=9B=BE=E4=B8=8A=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=94=9F=E7=89=A9=E4=BA=86=EF=BC=8C=E5=8A=A0=E5=85=A5=E4=BA=86?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E7=BB=93=E6=9D=9F=E7=9A=84=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locals/Log.csv | 3 +- locals/Log.en.translation | Bin 1714 -> 1766 bytes locals/Log.jp.translation | Bin 2465 -> 2545 bytes locals/Log.zh.translation | Bin 1929 -> 1977 bytes locals/UI.csv | 5 +- locals/UI.en.translation | Bin 1770 -> 1850 bytes locals/UI.jp.translation | Bin 2233 -> 2333 bytes locals/UI.zh.translation | Bin 1881 -> 1973 bytes .../dungeon/horizontalCorridor.tscn | 8 ++- .../dungeon/horizontalCorridorWithSewer.tscn | 8 ++- prefab/roomTemplates/dungeon/initialRoom.tscn | 6 +- scenes/game.tscn | 8 ++- scenes/gameOverMenu.tscn | 60 ++++++++++++++++++ scripts/EventManager.cs | 27 ++++++++ scripts/GameSceneNodeHolder.cs | 6 ++ scripts/character/CharacterTemplate.cs | 1 + scripts/character/Player.cs | 19 +++++- scripts/loader/sceneLoader/GameSceneLoader.cs | 11 ++-- .../uiLoader/GameOverLoaderMenuLoader.cs | 43 +++++++++++++ scripts/map/AiCharacterSpawn.cs | 54 ++++++++++++++++ scripts/map/MapGenerator.cs | 42 ++++++------ scripts/map/PlayerSpawn.cs | 10 ++- .../map/events/AiCharacterGenerateEvent.cs | 21 ++++++ scripts/map/events/GameOverEvent.cs | 14 ++++ 24 files changed, 310 insertions(+), 36 deletions(-) create mode 100644 scenes/gameOverMenu.tscn create mode 100644 scripts/EventManager.cs create mode 100644 scripts/loader/uiLoader/GameOverLoaderMenuLoader.cs create mode 100644 scripts/map/AiCharacterSpawn.cs create mode 100644 scripts/map/events/AiCharacterGenerateEvent.cs create mode 100644 scripts/map/events/GameOverEvent.cs diff --git a/locals/Log.csv b/locals/Log.csv index 4a51308..b423213 100644 --- a/locals/Log.csv +++ b/locals/Log.csv @@ -21,4 +21,5 @@ time_range_debug,当前时间:{0}起始时间:{1},结束时间{2},是否 player_spawn_debug,玩家{0}生成在{1}。,"Player {0} spawned at {1}.",プレイヤー{0}が{1}に生成されました。 player_packed_scene_not_exist,玩家预制场景不存在。,Player packed scene does not exist.,プレイヤーのパックされたシーンが存在しません。 exit_the_room_debug,节点{0}退出房间{1}。,"Node {0} exits room {1}.",ノード{0}が部屋{1}を退出します。 -enter_the_room_debug,节点{0}进入房间{1}。,"Node {0} enters room {1}.",ノード{0}が部屋{1}に入ります。 \ No newline at end of file +enter_the_room_debug,节点{0}进入房间{1}。,"Node {0} enters room {1}.",ノード{0}が部屋{1}に入ります。 +death_info,生物{0}被{1}击败。,"Creature {0} was defeated by {1}.",生物{0}が{1}によって打ち負かされました。 \ No newline at end of file diff --git a/locals/Log.en.translation b/locals/Log.en.translation index 706224a7cb3eafff24835e3373650afbf242c88a..d2893ea22517ac118dae8674a38032ddb118d187 100644 GIT binary patch delta 242 zcmdnQ`;2#kG$U(bvROs>WCg~gdL;%11`Qzoj|TLBVkS^=J2ZJ0G(JeH7f>t!h{J$5 z0f^CzgLAWhas^QNG6n`Qh8iTrtU$H`5VuVhXPV3#qrnka%f!GS0~Ar(JfEqVk#Xi` wWtIje?SIaS>eIOYGgTYZ?iA0`sc@C6X8`gHYxDjA)iSUHF(VKM1qV3;03|VTg8%>k delta 188 zcmaFHyNP#$G$U)7VV*_aWCg~g`u{+n#K6D+qLG0HP)rXhZhsx5C diff --git a/locals/Log.jp.translation b/locals/Log.jp.translation index 0fd260bc869062a9b4e5421ffdd808d85036ceb7..d3df0953ff1385f3fd459e23bf54c5ba62ec350a 100644 GIT binary patch delta 254 zcmZ1|{84y=G$X4?u6aq?WCg}T1tkUs1`Qzoj|TLBVkSU5`5>c6q6-!UUO=$`APxiK z1RzG!59ek9i&Gn{O6r3s|{)&H}+H;0?E~nn>rphE`Hp&>{;jJ$BheLY+CTRvHNl3)W=Odj~n+r ZZk+zOasK0mCI$v}pka(a926Yn3;;c#e8K<# delta 184 zcmew;yij<9G$U)NX=*|4WCg}Tga1IF#K6D+qLG0HP)rXhZh<5}c_X7pAV{GLP|ypA z1AsURNddAUAa)8+E(n$7#P@rY8inzC^*O&0DBf@fdBvi delta 183 zcmdnV-^ss0nvvBYqafdOvI1kF!G9o7VqjnZ(a1mpD5eJ$w?LAgypd5P5TwurDCh;m z0YDsuqyX6v5IY4Zmj#tC0McbhYFUA71t4yitj08X^F^i#Mn<>IUM!x>d<+ciKygMO J4hjx(1^`=_SqA_B diff --git a/locals/UI.csv b/locals/UI.csv index bc8f044..bf834ff 100644 --- a/locals/UI.csv +++ b/locals/UI.csv @@ -31,4 +31,7 @@ delete_selected_node,删除选中的节点,Delete selected node,選択された re_create_map,重新创建地图,Re-create map,地図を再作成します seed_info,种子:{0},Seed: {0},シード:{0} tags,标签,Tags,と呼ぶ -room_injection_processor,房间注入处理器,Room injection processor,部屋注入処理器 \ No newline at end of file +room_injection_processor,房间注入处理器,Room injection processor,部屋注入処理器 +game_over_title,游戏结束!,Game Over!,ゲームオーバー! +death_info_describe,死因,death,死因 +restart,重新开始,Restart,ぶり返す diff --git a/locals/UI.en.translation b/locals/UI.en.translation index 4ab0903b6575f78af9b2dcbd14a6504dcce5bfd2..ef64281eca4313b79d5165339ff2e83730d0fab4 100644 GIT binary patch delta 299 zcmaFGyNhpwG$U(rWoBviWCg~edJhH$hW|j|2c$!wY!E*R$WB1wgTz1}4Jeia#AQI- z0K{!TJOPLyvJi3>l)nH-uL9x?K)elzk=5)0@>v-e*ccRmj6;*fnSQG>0a=VdEL$`E zT0W3YfMVg<2eqC9CAfin?#b%R!MrZw?UO$NMSun{uuaZqKCB4StFiPp56BP>pbQA# z^J%>O9mr>&?98&B@!#gpEUy?<-4kr{0lNW@#!B>H9HUk6*B|{ H2RQ=(coAu{ delta 229 zcmdnR_lkFeG$U(%hFO8dWCg~edKU%;hW|j|1*8L@Y!Dv=!qE62u^6CO5)kJAaTyTT z0C5`-gXCbK2g;uWq~`$fA|PG?6@#f+2jsIdFt9Nw02x~*i!=QeWdyQ7Shi;RwR|9* w0K${anS&=UV%{MLlhs&yn+K$fV{$diddBCQwOL;=@-nak)q+$61qV3;08l|$uK)l5 diff --git a/locals/UI.jp.translation b/locals/UI.jp.translation index 0b8d92ee694b9a477849db6e8e45fcb30ea9da45..28dcfd3653eeda0f899732ebf78f6a0dd25c6afe 100644 GIT binary patch delta 322 zcmdlfI9F(cG$U)OnMuCcWCg~?dJhH$hW|j|2c$!wY!E*R$WB1wgTz1}4Jeia#AQI- z0K{!TJOPLyvJi3>l)nH-uL9x?K)elzk=5)0@>v-e*ccRmj6;*vn0~7=0a=VdEL$`E z+A$!V0>#3!4{EJoW?&Ep^2H~cF$eRyh__GP4-{bsim*?vV?GSmtFiPp&orPR0zerM zzUR|;`xsCqFObbUIgDjB#=Q`d|AQyw?YgjfS|SWs|~GXUAHdVT-^ delta 232 zcmbO$v{P_{G$X5tQDJ)0WCg~?dKU%;hW|j|1*8L@Y!Dv=!qE62u^6CO5)kJAaTyTT z0C5`-gXCbK2g;uWq~`$fA|PG?6@#f+2jsIdFt9Nw02x~*t1l)nH-uL9x?K)elzk=5)0@>v-e*ccRmj6;*vn0~7=0a=VdEL$`E zT0W4Dfnwp=2esUQk^(@!z+^M#U|tvT_Q_#D5q6*m`{X+2!*IPCOKil8lEoi1{n^-ASVR{2RQ=(&z^LU delta 234 zcmdnWf0J*6G$X5_ae-;#WCg~?dKU%;hW|j|1*8L@Y!Dv=!qE62u^6CO5)kJAaTyTT z0C5`-gXCbK2g;uWq~`$fA|PG?6@#f+2jsIdFt9Nw02x~*t18*}jFjm$gXvKmWo^RNSzaRFtyCik(dW^~(Z#p=n#$H2f26apC#6ddFX0H=sp Ac>n+a diff --git a/prefab/roomTemplates/dungeon/horizontalCorridor.tscn b/prefab/roomTemplates/dungeon/horizontalCorridor.tscn index 07de535..101de0d 100644 --- a/prefab/roomTemplates/dungeon/horizontalCorridor.tscn +++ b/prefab/roomTemplates/dungeon/horizontalCorridor.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://b0uurp551pku"] +[gd_scene load_steps=7 format=3 uid="uid://b0uurp551pku"] [ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="1_a15hy"] +[ext_resource type="Script" path="res://scripts/map/AiCharacterSpawn.cs" id="2_wamhd"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] size = Vector2(443, 118) @@ -53,3 +54,8 @@ shape = SubResource("RectangleShape2D_30r3c") [node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D3"] position = Vector2(193, 15) shape = SubResource("RectangleShape2D_7tsse") + +[node name="Marker2D" type="Marker2D" parent="."] +position = Vector2(220, 103) +script = ExtResource("2_wamhd") +metadata/ResPath = "res://prefab/entitys/DelivererOfDarkMagic.tscn" diff --git a/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn b/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn index ac538d2..ca8aaa1 100644 --- a/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn +++ b/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://dslr5tdbp4noq"] +[gd_scene load_steps=7 format=3 uid="uid://dslr5tdbp4noq"] [ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="1_rn2om"] +[ext_resource type="Script" path="res://scripts/map/AiCharacterSpawn.cs" id="2_7q101"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] size = Vector2(441, 122) @@ -54,3 +55,8 @@ position = Vector2(498, 109) [node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D2"] position = Vector2(0, 17) shape = SubResource("RectangleShape2D_131jn") + +[node name="Marker2D" type="Marker2D" parent="."] +position = Vector2(183, 72) +script = ExtResource("2_7q101") +metadata/ResPath = "res://prefab/entitys/DelivererOfDarkMagic.tscn" diff --git a/prefab/roomTemplates/dungeon/initialRoom.tscn b/prefab/roomTemplates/dungeon/initialRoom.tscn index 0bad359..73bfc19 100644 --- a/prefab/roomTemplates/dungeon/initialRoom.tscn +++ b/prefab/roomTemplates/dungeon/initialRoom.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://du5ldsp613fei"] +[gd_scene load_steps=6 format=3 uid="uid://du5ldsp613fei"] [ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="1_rn2om"] [ext_resource type="Script" path="res://scripts/map/PlayerSpawn.cs" id="2_6p8mv"] +[ext_resource type="PackedScene" uid="uid://dnnn2xyayiehk" path="res://prefab/weapons/staffOfTheUndead.tscn" id="3_ud0w8"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] size = Vector2(450, 191) @@ -41,3 +42,6 @@ debug_color = Color(0.854902, 0.14902, 0.823529, 0.419608) [node name="Marker2D" type="Marker2D" parent="."] position = Vector2(216, 113) script = ExtResource("2_6p8mv") + +[node name="StaffOfTheUndead" parent="." instance=ExtResource("3_ud0w8")] +position = Vector2(231, 116) diff --git a/scenes/game.tscn b/scenes/game.tscn index 1a2f1ff..36421ee 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=6 format=3 uid="uid://bnftvkj2cido7"] +[gd_scene load_steps=7 format=3 uid="uid://bnftvkj2cido7"] [ext_resource type="Script" path="res://scripts/loader/sceneLoader/GameSceneLoader.cs" id="1_mqdgt"] [ext_resource type="Texture2D" uid="uid://cs6e0af876ss5" path="res://sprites/ui/HeartEmpty.png" id="2_n1yht"] [ext_resource type="Script" path="res://scripts/inventory/HotBar.cs" id="2_owrhq"] [ext_resource type="Script" path="res://scripts/HealthBarUi.cs" id="2_xrm3v"] [ext_resource type="Script" path="res://scripts/FpsLabel.cs" id="5_dis4v"] +[ext_resource type="PackedScene" uid="uid://bb188382q7btp" path="res://scenes/gameOverMenu.tscn" id="6_yjmrv"] [node name="Game" type="Node2D"] script = ExtResource("1_mqdgt") @@ -83,6 +84,9 @@ offset_right = 20.0 offset_bottom = 25.0 grow_horizontal = 2 +[node name="GameOverMenu" parent="CanvasLayer" instance=ExtResource("6_yjmrv")] +visible = false + [node name="ProjectileContainer" type="Node2D" parent="."] [node name="DamageNumberContainer" type="Node2D" parent="."] @@ -90,3 +94,5 @@ grow_horizontal = 2 [node name="WeaponContainer" type="Node2D" parent="."] [node name="PlayerContainer" type="Node2D" parent="."] + +[node name="AICharacterContainer" type="Node2D" parent="."] diff --git a/scenes/gameOverMenu.tscn b/scenes/gameOverMenu.tscn new file mode 100644 index 0000000..6382439 --- /dev/null +++ b/scenes/gameOverMenu.tscn @@ -0,0 +1,60 @@ +[gd_scene load_steps=2 format=3 uid="uid://bb188382q7btp"] + +[ext_resource type="Script" path="res://scripts/loader/uiLoader/GameOverLoaderMenuLoader.cs" id="1_vj6du"] + +[node name="GameOverMenu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_vj6du") + +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.941176, 0.243137, 0.243137, 0.258824) + +[node name="CenterContainer" type="CenterContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] +layout_mode = 2 + +[node name="CenterContainer" type="CenterContainer" parent="CenterContainer/VBoxContainer"] +layout_mode = 2 + +[node name="GameOverLabel" type="Label" parent="CenterContainer/VBoxContainer/CenterContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 30 +text = "game_over_title" + +[node name="MarginContainer" type="MarginContainer" parent="CenterContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 18 + +[node name="CenterContainer2" type="CenterContainer" parent="CenterContainer/VBoxContainer/MarginContainer"] +layout_mode = 2 + +[node name="DeathInfoLabel" type="Label" parent="CenterContainer/VBoxContainer/MarginContainer/CenterContainer2"] +layout_mode = 2 +text = "death_info_describe" + +[node name="MarginContainer2" type="MarginContainer" parent="CenterContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_bottom = 150 + +[node name="Button" type="Button" parent="CenterContainer/VBoxContainer/MarginContainer2"] +layout_mode = 2 +text = "restart" diff --git a/scripts/EventManager.cs b/scripts/EventManager.cs new file mode 100644 index 0000000..641a95a --- /dev/null +++ b/scripts/EventManager.cs @@ -0,0 +1,27 @@ +using System; +using ColdMint.scripts.map.events; + +namespace ColdMint.scripts; + +public class EventManager +{ + /// + /// Event when the AI character is generated + /// AI角色生成事件 + /// + public static Action? AiCharacterGenerateEvent; + + public static Action? GameOverEvent; + + /// + /// Map starts generating events + /// 地图开始生成的事件 + /// + public static Action? MapGenerationStartEvent; + + /// + /// Map generation completion event + /// 地图生成完成事件 + /// + public static Action? MapGenerationCompleteEvent; +} \ No newline at end of file diff --git a/scripts/GameSceneNodeHolder.cs b/scripts/GameSceneNodeHolder.cs index 3d32841..ea387a7 100644 --- a/scripts/GameSceneNodeHolder.cs +++ b/scripts/GameSceneNodeHolder.cs @@ -24,6 +24,12 @@ public static class GameSceneNodeHolder public static Node2D? PlayerContainer { get; set; } + /// + /// AICharacterContainer + /// AICharacter角色 + /// + public static Node2D? AICharacterContainer { get; set; } + public static HotBar? HotBar { get; set; } diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index 18c5429..5ddd4bf 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -5,6 +5,7 @@ using ColdMint.scripts.damage; using ColdMint.scripts.debug; using ColdMint.scripts.health; using ColdMint.scripts.inventory; +using ColdMint.scripts.map.events; using ColdMint.scripts.utils; using ColdMint.scripts.weapon; using Godot; diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index 75ce4a0..bea515b 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -1,6 +1,7 @@ using System; using System.Text; using ColdMint.scripts.damage; +using ColdMint.scripts.map.events; using ColdMint.scripts.utils; using ColdMint.scripts.weapon; using Godot; @@ -100,7 +101,8 @@ public partial class Player : CharacterTemplate operationTipBuilder.Append("[color="); operationTipBuilder.Append(Config.OperationTipActionColor); operationTipBuilder.Append(']'); - operationTipBuilder.Append(TranslationServerUtils.Translate(InputMap.ActionGetEvents("ui_down")[0].AsText())); + operationTipBuilder.Append( + TranslationServerUtils.Translate(InputMap.ActionGetEvents("ui_down")[0].AsText())); operationTipBuilder.Append("[/color]"); operationTipBuilder.Append(TranslationServerUtils.Translate("jump_down")); } @@ -292,6 +294,7 @@ public partial class Player : CharacterTemplate rigidBody2D.LinearVelocity = GetThrowVelocity(); break; } + CurrentItem = null; var hotBar = GameSceneNodeHolder.HotBar; hotBar?.RemoveItemFromItemSlotBySelectIndex(1); @@ -363,6 +366,20 @@ public partial class Player : CharacterTemplate } } + protected override void OnDie(DamageTemplate damageTemplate) + { + if (EventManager.GameOverEvent != null) + { + var gameOverEvent = new GameOverEvent + { + DeathInfo = "\"白纸\"失手将自己杀死。" + }; + EventManager.GameOverEvent(gameOverEvent); + } + + Visible = false; + } + protected override void EnterThePickingRangeBody(Node node) { base.EnterThePickingRangeBody(node); diff --git a/scripts/loader/sceneLoader/GameSceneLoader.cs b/scripts/loader/sceneLoader/GameSceneLoader.cs index 79a80f0..3e9474c 100644 --- a/scripts/loader/sceneLoader/GameSceneLoader.cs +++ b/scripts/loader/sceneLoader/GameSceneLoader.cs @@ -31,6 +31,10 @@ public partial class GameSceneLoader : SceneLoaderTemplate //加载武器容器 var weaponContainer = GetNode("WeaponContainer"); GameSceneNodeHolder.WeaponContainer = weaponContainer; + //Load AICharacter container + //加载AICharacter容器 + var aiCharacterContainer = GetNode("AICharacterContainer"); + GameSceneNodeHolder.AICharacterContainer = aiCharacterContainer; //Load player container //加载玩家容器 var playerContainer = GetNode("PlayerContainer"); @@ -58,13 +62,6 @@ public partial class GameSceneLoader : SceneLoaderTemplate MapGenerator.LayoutStrategy = new TestLayoutStrategy(); MapGenerator.LayoutParsingStrategy = new SequenceLayoutParsingStrategy(); MapGenerator.RoomPlacementStrategy = new PatchworkRoomPlacementStrategy(); - MapGenerator.MapGenerationCompleteEvent += (_) => - { - }; - MapGenerator.MapGenerationStartEvent+= (_) => - { - - }; await GenerateMap(); } diff --git a/scripts/loader/uiLoader/GameOverLoaderMenuLoader.cs b/scripts/loader/uiLoader/GameOverLoaderMenuLoader.cs new file mode 100644 index 0000000..a1fedc9 --- /dev/null +++ b/scripts/loader/uiLoader/GameOverLoaderMenuLoader.cs @@ -0,0 +1,43 @@ +using System.Threading.Tasks; +using ColdMint.scripts.map.events; +using Godot; + +namespace ColdMint.scripts.loader.uiLoader; + +/// +/// GameOverLoaderMenuLoader +/// 游戏结束菜单加载器 +/// +public partial class GameOverLoaderMenuLoader : UiLoaderTemplate +{ + private Label? _deathInfoLabel; + + public override void InitializeUi() + { + Visible = false; + } + + public override void InitializeData() + { + _deathInfoLabel = + GetNode