From ba11bf06da7a716662ae224a0afa6c71fc2cd6ae Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Fri, 13 Sep 2024 23:04:39 +0800 Subject: [PATCH] =?UTF-8?q?Make=20spell=20separation=20table.=20=E5=88=B6?= =?UTF-8?q?=E4=BD=9C=E6=B3=95=E6=9C=AF=E5=88=86=E7=A6=BB=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E5=8F=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prefab/entitys/Character.tscn | 2 +- prefab/furnitures/MagicSeparator.tscn | 28 ++++++ prefab/roomTemplates/dungeon/chest.tscn | 87 ++++++++++++++++++ prefab/roomTemplates/dungeon/initialRoom.tscn | 8 +- prefab/roomTemplates/dungeon/utilityRoom.tscn | 2 +- project.godot | 1 + scripts/Config.cs | 23 +++++ scripts/character/CharacterTemplate.cs | 25 +++-- scripts/furniture/Furniture.cs | 52 +++++++++++ scripts/furniture/GuiFurniture.cs | 47 ++++++++++ scripts/map/PlayerSpawn.cs | 2 +- sprites/ui/Null.png | Bin 0 -> 197 bytes sprites/ui/Null.png.import | 34 +++++++ 13 files changed, 298 insertions(+), 13 deletions(-) create mode 100644 prefab/furnitures/MagicSeparator.tscn create mode 100644 prefab/roomTemplates/dungeon/chest.tscn create mode 100644 scripts/furniture/Furniture.cs create mode 100644 scripts/furniture/GuiFurniture.cs create mode 100644 sprites/ui/Null.png create mode 100644 sprites/ui/Null.png.import diff --git a/prefab/entitys/Character.tscn b/prefab/entitys/Character.tscn index 392a813..f61d783 100644 --- a/prefab/entitys/Character.tscn +++ b/prefab/entitys/Character.tscn @@ -31,7 +31,7 @@ platform_wall_layers = 128 script = ExtResource("1_1dlls") CharacterName = null CanMutateAfterDeath = null -InitialHp = null +_initialHp = null MaxHp = 32 CampId = "Default" LootListId = null diff --git a/prefab/furnitures/MagicSeparator.tscn b/prefab/furnitures/MagicSeparator.tscn new file mode 100644 index 0000000..2a88e09 --- /dev/null +++ b/prefab/furnitures/MagicSeparator.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=5 format=3 uid="uid://djsh4unystlf0"] + +[ext_resource type="Texture2D" uid="uid://qowlv0viyqbb" path="res://sprites/ui/Null.png" id="1_346je"] +[ext_resource type="Script" path="res://scripts/furniture/GuiFurniture.cs" id="1_t1qdg"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_vx4tg"] +size = Vector2(31, 31) + +[sub_resource type="CircleShape2D" id="CircleShape2D_in1f7"] +radius = 52.6118 + +[node name="RigidBody2D" type="RigidBody2D"] +collision_layer = 256 +collision_mask = 160 +script = ExtResource("1_t1qdg") + +[node name="Null" type="Sprite2D" parent="."] +texture = ExtResource("1_346je") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-0.5, -0.5) +shape = SubResource("RectangleShape2D_vx4tg") + +[node name="OperateArea2D" type="Area2D" parent="."] +visible = false + +[node name="CollisionShape2D" type="CollisionShape2D" parent="OperateArea2D"] +shape = SubResource("CircleShape2D_in1f7") diff --git a/prefab/roomTemplates/dungeon/chest.tscn b/prefab/roomTemplates/dungeon/chest.tscn new file mode 100644 index 0000000..bdbf478 --- /dev/null +++ b/prefab/roomTemplates/dungeon/chest.tscn @@ -0,0 +1,87 @@ +[gd_scene load_steps=9 format=4 uid="uid://br778i2b0skil"] + +[ext_resource type="Script" path="res://scripts/map/AiCharacterSpawn.cs" id="1_y2vgj"] +[ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="2_ngfnn"] +[ext_resource type="Texture2D" uid="uid://drw45jlmfo0su" path="res://sprites/light/White_100.png" id="3_r2p3x"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] +size = Vector2(505, 186) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_o85u0"] +size = Vector2(20, 48) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_30r3c"] +size = Vector2(20, 46) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_7tsse"] +size = Vector2(53, 24) + +[sub_resource type="NavigationPolygon" id="NavigationPolygon_rh1gx"] +vertices = PackedVector2Array(499.469, 106.328, 501.523, 150.039, 9.3125, 151.953, 470.156, 107.352, 10.7031, 107, 43.1562, 107, 170.328, 40.6797, 169.344, 11, 216.617, 11, 218.617, 41.9297, 469.148, 43.9219, 42.1484, 44.6875) +polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(3, 2, 4, 5), PackedInt32Array(6, 7, 8, 9), PackedInt32Array(10, 3, 5, 9), PackedInt32Array(6, 9, 5, 11)]) +outlines = Array[PackedVector2Array]([PackedVector2Array(479, 34, 228, 32, 226, 1, 159, 1, 160, 31, 32, 35, 33, 97, 1, 97, -1, 162, 512, 160, 509, 96, 480, 97)]) +source_geometry_group_name = &"navigation_polygon_source_group" + +[node name="InitialRoom" type="Node2D"] + +[node name="RoomArea" type="Area2D" parent="."] +collision_mask = 0 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"] +position = Vector2(255.5, 97) +shape = SubResource("RectangleShape2D_kiih8") + +[node name="RoomSlotList" type="Node2D" parent="."] + +[node name="Area2D" type="Area2D" parent="RoomSlotList"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D"] +position = Vector2(17, 129) +shape = SubResource("RectangleShape2D_o85u0") + +[node name="Area2D2" type="Area2D" parent="RoomSlotList"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D2"] +position = Vector2(498, 128) +shape = SubResource("RectangleShape2D_30r3c") + +[node name="Area2D3" type="Area2D" parent="RoomSlotList"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomSlotList/Area2D3"] +position = Vector2(193, 15) +shape = SubResource("RectangleShape2D_7tsse") + +[node name="Marker2D" type="Marker2D" parent="."] +position = Vector2(260, 87) +script = ExtResource("1_y2vgj") +ResPath = "res://prefab/entitys/DelivererOfDarkMagic.tscn" + +[node name="NavigationRegion2D" type="NavigationRegion2D" parent="."] +navigation_polygon = SubResource("NavigationPolygon_rh1gx") + +[node name="TileMap" type="Node2D" parent="."] + +[node name="BackgroundWall" type="TileMapLayer" parent="TileMap"] +use_parent_material = true +tile_map_data = PackedByteArray("AAAOAAEAAQAGAAUAAAAOAAIAAQAGAAUAAAAOAAMAAQAGAAUAAAAOAAQAAQAGAAUAAAANAAQAAQAGAAUAAAANAAMAAQAGAAUAAAANAAIAAQAGAAUAAAANAAEAAQAGAAUAAAAMAAEAAQAGAAUAAAALAAEAAQAGAAUAAAAKAAEAAQAGAAUAAAAJAAEAAQAGAAUAAAAIAAEAAQAGAAUAAAAHAAEAAQAGAAUAAAAGAAEAAQAGAAUAAAAFAAEAAQAGAAUAAAAEAAEAAQAGAAUAAAADAAEAAQAGAAUAAAACAAEAAQAGAAUAAAABAAEAAQAGAAUAAAABAAIAAQAGAAUAAAACAAIAAQAGAAUAAAADAAIAAQAGAAUAAAAEAAIAAQAGAAUAAAAFAAIAAQAGAAUAAAAGAAIAAQAGAAUAAAAHAAIAAQAGAAUAAAAIAAIAAQAGAAUAAAAJAAIAAQAGAAUAAAAKAAIAAQAGAAUAAAALAAIAAQAGAAUAAAAMAAIAAQAGAAUAAAAMAAMAAQAGAAUAAAALAAMAAQAGAAUAAAAKAAMAAQAGAAUAAAAJAAMAAQAGAAUAAAAIAAMAAQAEAAUAAAAHAAMAAQAGAAUAAAAGAAMAAQAGAAUAAAAFAAMAAQAEAAUAAAAEAAMAAQAGAAUAAAADAAMAAQAGAAUAAAACAAMAAQAGAAUAAAABAAMAAQAGAAUAAAABAAQAAQAGAAUAAAACAAQAAQAGAAUAAAADAAQAAQAGAAUAAAAEAAQAAQAGAAUAAAAFAAQAAQAGAAUAAAAGAAQAAQAGAAUAAAAHAAQAAQAGAAUAAAAIAAQAAQAGAAUAAAAJAAQAAQAGAAUAAAAKAAQAAQAGAAUAAAALAAQAAQAGAAUAAAAMAAQAAQAGAAUAAAAAAAMAAQAGAAUAAAAAAAQAAQAGAAUAAAAPAAQAAQAGAAUAAAAPAAMAAQAGAAUAAAAFAAAAAQAGAAUAAAAGAAAAAQAGAAUAAAA=") +tile_set = ExtResource("2_ngfnn") +navigation_enabled = false + +[node name="BackgroundDecoration" type="TileMapLayer" parent="TileMap"] +use_parent_material = true +tile_set = ExtResource("2_ngfnn") + +[node name="Ground" type="TileMapLayer" parent="TileMap"] +use_parent_material = true +tile_map_data = PackedByteArray("AAAAAAAAAQAAAAMAAAAAAAEAAQACAAEAAAAAAAIAAQACAAEAAAABAAAAAQABAAIAAAACAAAAAQABAAIAAAADAAAAAQABAAIAAAAEAAAAAQABAAIAAAAHAAAAAQABAAIAAAAIAAAAAQABAAIAAAAJAAAAAQABAAIAAAAKAAAAAQABAAIAAAALAAAAAQABAAIAAAAMAAAAAQABAAIAAAANAAAAAQABAAIAAAAOAAAAAQABAAMAAAAPAAAAAQACAAMAAAAPAAEAAQACAAQAAAAPAAIAAQACAAQAAAABAAUAAQABAAAAAAACAAUAAQABAAAAAAADAAUAAQABAAAAAAAEAAUAAQABAAAAAAAFAAUAAQABAAAAAAAGAAUAAQABAAAAAAAHAAUAAQABAAAAAAAIAAUAAQABAAAAAAAJAAUAAQABAAAAAAAKAAUAAQABAAAAAAALAAUAAQABAAAAAAAMAAUAAQABAAAAAAANAAUAAQABAAAAAAAOAAUAAQABAAAAAAAAAAUAAQAAAAUAAAAPAAUAAQACAAUAAAAFAAAAAQAEAAQAAAAGAAAAAQAEAAQAAAA=") +tile_set = ExtResource("2_ngfnn") + +[node name="Barrier" type="TileMapLayer" parent="TileMap"] +tile_map_data = PackedByteArray("AAAPAAMAAQAAAAEAAAAPAAQAAQAAAAEAAAAAAAMAAQACAAEAAAAAAAQAAQACAAEAAAAFAAAAAQABAAIAAAAGAAAAAQABAAIAAAA=") +tile_set = ExtResource("2_ngfnn") + +[node name="PointLight2D" type="PointLight2D" parent="."] +visible = false +position = Vector2(256, 96.5) +scale = Vector2(15.875, 5.96875) +texture = ExtResource("3_r2p3x") diff --git a/prefab/roomTemplates/dungeon/initialRoom.tscn b/prefab/roomTemplates/dungeon/initialRoom.tscn index eea3783..5387b44 100644 --- a/prefab/roomTemplates/dungeon/initialRoom.tscn +++ b/prefab/roomTemplates/dungeon/initialRoom.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=8 format=4 uid="uid://du5ldsp613fei"] +[gd_scene load_steps=9 format=4 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="Script" path="res://scripts/map/ItemSpawn.cs" id="3_v1tlc"] [ext_resource type="Texture2D" uid="uid://drw45jlmfo0su" path="res://sprites/light/White_100.png" id="5_4pssd"] +[ext_resource type="PackedScene" uid="uid://djsh4unystlf0" path="res://prefab/furnitures/MagicSeparator.tscn" id="5_7c8bh"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] size = Vector2(507, 251) @@ -75,3 +76,8 @@ visible = false position = Vector2(259.5, 128.5) scale = Vector2(16.0312, 7.96875) texture = ExtResource("5_4pssd") + +[node name="RigidBody2D" parent="." instance=ExtResource("5_7c8bh")] +position = Vector2(149, 109) +collision_layer = 256 +collision_mask = 0 diff --git a/prefab/roomTemplates/dungeon/utilityRoom.tscn b/prefab/roomTemplates/dungeon/utilityRoom.tscn index b69727f..4184acc 100644 --- a/prefab/roomTemplates/dungeon/utilityRoom.tscn +++ b/prefab/roomTemplates/dungeon/utilityRoom.tscn @@ -21,7 +21,7 @@ polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3, 4), PackedInt32 outlines = Array[PackedVector2Array]([PackedVector2Array(35, 39, 36, 415, 0, 417, 3, 481, 733, 477, 729, 415, 706, 415, 701, 93, 734, 89, 731, 34)]) source_geometry_group_name = &"navigation_polygon_source_group" -[node name="InitialRoom" type="Node2D"] +[node name="InitialRoom2" type="Node2D"] [node name="RoomArea" type="Area2D" parent="."] collision_mask = 0 diff --git a/project.godot b/project.godot index 36ed46e..a9e7a2e 100644 --- a/project.godot +++ b/project.godot @@ -162,6 +162,7 @@ locale/translations=PackedStringArray("res://locals/DeathInfo.en.translation", " 2d_physics/layer_6="Platform" 2d_physics/layer_7="Mob" 2d_physics/layer_8="Wall" +2d_physics/layer_9="Furniture" [physics] diff --git a/scripts/Config.cs b/scripts/Config.cs index 3535ab2..0c7a679 100644 --- a/scripts/Config.cs +++ b/scripts/Config.cs @@ -377,6 +377,12 @@ public static class Config /// public const int DefaultMaxHp = 100; + /// + /// The default durability of furniture + /// 家具的默认耐久度 + /// + public const int DefaultMaxDurability = 50; + /// /// When a creature takes damage, how long to hide the bloodline again /// 生物受到伤害时,要在多长时间后再次隐藏血条 @@ -448,13 +454,30 @@ public static class Config public static class LayerNumber { public const int RoomArea = 1; + /// + /// Floor + /// 地板 + /// public const int Floor = 2; public const int Player = 3; public const int PickAbleItem = 4; public const int Projectile = 5; + /// + /// Platform + /// 平台 + /// public const int Platform = 6; public const int Mob = 7; + /// + /// Wall + /// 墙壁 + /// public const int Wall = 8; + /// + /// Furniture + /// 家具 + /// + public const int Furniture = 9; } /// diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index 8e720e1..5966795 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -163,9 +163,9 @@ public partial class CharacterTemplate : CharacterBody2D //The initial health of the character after creation //角色创建后的初始血量 - [Export] public int InitialHp; + [Export] private int _initialHp; - [Export] public int MaxHp; + [Export] protected int MaxHp; /// /// The camp ID of the role @@ -189,6 +189,16 @@ public partial class CharacterTemplate : CharacterBody2D public Node[] PickingRangeBodies => PickingRangeBodiesList?.ToArray() ?? []; + + /// + /// Full Hp Revive + /// 满血复活 + /// + public void FullHpRevive() + { + Revive(MaxHp); + } + /// /// Resurrected character /// 复活角色 @@ -266,19 +276,17 @@ public partial class CharacterTemplate : CharacterBody2D if (MaxHp <= 0) { - //If Max blood volume is 0 or less, set Max blood volume to 10 - //若最大血量为0或小于0,则将最大血量设置为10 MaxHp = Config.DefaultMaxHp; } - if (InitialHp <= 0 || InitialHp > MaxHp) + if (_initialHp <= 0 || _initialHp > MaxHp) { //If the initial health is less than or equal to 0 or greater than the maximum health, then set it to the maximum health //如果初始血量小于等于0或者大于最大血量,那么将其设置为最大血量 - InitialHp = MaxHp; + _initialHp = MaxHp; } - CurrentHp = InitialHp; + CurrentHp = _initialHp; //The health bar of a creature may be null. //生物的健康条,可能为null。 _healthBar = GetNodeOrNull("HealthBar"); @@ -322,8 +330,6 @@ public partial class CharacterTemplate : CharacterBody2D } - - public override void _MouseEnter() { if (GameSceneDepend.Player != null) @@ -622,6 +628,7 @@ public partial class CharacterTemplate : CharacterBody2D { throw new InvalidOperationException("AddForce called more than once"); } + _additionalForce = force; } diff --git a/scripts/furniture/Furniture.cs b/scripts/furniture/Furniture.cs new file mode 100644 index 0000000..21ef69b --- /dev/null +++ b/scripts/furniture/Furniture.cs @@ -0,0 +1,52 @@ +using ColdMint.scripts.damage; +using Godot; + +namespace ColdMint.scripts.furniture; + +/// +/// FurnitureTemplate +/// 家具模板 +/// +public partial class Furniture : RigidBody2D +{ + [Export] private int _initialDurability; + [Export] private int _maxDurability; + + /// + /// + /// 家具的耐久度 + /// + private int _durability; + + public override void _Ready() + { + if (_maxDurability <= 0) + { + _maxDurability = Config.DefaultMaxDurability; + } + + if (_initialDurability <= 0 || _initialDurability > _maxDurability) + { + _initialDurability = _maxDurability; + } + + _durability = _initialDurability; + SetCollisionMaskValue(Config.LayerNumber.Wall, true); + SetCollisionMaskValue(Config.LayerNumber.Platform, true); + SetCollisionMaskValue(Config.LayerNumber.Floor, true); + } + + /// + /// This method is called when furniture is damaged + /// 当家具损害时调用此方法 + /// + /// + /// + ///Return whether the damage completely destroyed the furniture + ///返回本次伤害是否彻底破坏了家具 + /// + public bool Damage(DamageTemplate damageTemplate) + { + return false; + } +} \ No newline at end of file diff --git a/scripts/furniture/GuiFurniture.cs b/scripts/furniture/GuiFurniture.cs new file mode 100644 index 0000000..e5e4caa --- /dev/null +++ b/scripts/furniture/GuiFurniture.cs @@ -0,0 +1,47 @@ +using Godot; + +namespace ColdMint.scripts.furniture; + +/// +/// GUIFurnitureTemplate +/// 带有图形用户页面的家居模板 +/// +public partial class GuiFurniture : Furniture +{ + /// + /// Operating range of furniture + /// 家具的操作范围 + /// + /// + ///For furniture with graphical user pages, the player must enter the action range and press the shortcut key to display the UI page. + ///对于带有图形用户页面的家具来说,玩家必须进入操作范围内按下快捷键才能显示UI页面。 + /// + private Area2D? _operateArea2D; + + public override void _Ready() + { + base._Ready(); + _operateArea2D = GetNode("OperateArea2D"); + _operateArea2D.BodyEntered += OnBodyEntered; + _operateArea2D.BodyExited += OnBodyExited; + } + + private void OnBodyEntered(Node node) + { + + } + + private void OnBodyExited(Node2D node2D) + { + + } + + public override void _ExitTree() + { + if (_operateArea2D != null) + { + _operateArea2D.BodyEntered -= OnBodyEntered; + _operateArea2D.BodyExited -= OnBodyExited; + } + } +} \ No newline at end of file diff --git a/scripts/map/PlayerSpawn.cs b/scripts/map/PlayerSpawn.cs index d422a55..beaed5b 100644 --- a/scripts/map/PlayerSpawn.cs +++ b/scripts/map/PlayerSpawn.cs @@ -27,7 +27,7 @@ public partial class PlayerSpawn : Marker2D { if (GameSceneDepend.Player != null) { - GameSceneDepend.Player.Revive(GameSceneDepend.Player.MaxHp); + GameSceneDepend.Player.FullHpRevive(); GameSceneDepend.Player.GlobalPosition = GlobalPosition; return; } diff --git a/sprites/ui/Null.png b/sprites/ui/Null.png new file mode 100644 index 0000000000000000000000000000000000000000..e9ae90d0e30a5b9707f1e5da4132f2b76d5c0303 GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}^`0({ArY-_ zr*Gsvpdi5Pd&K4c;uK$r)|nm?)sz}8u>{|k`*ixhC;9@4GeZSL86W7hZnD|^ctK8` z2LqEp1H(6_6YnH`Mqc|Izd4+F^F#YB*Et)0r^ehoRL9GZ9lgL@z}@k-)A{XL(bea8 uHm8I|dZkURV`AiRU|?Fn%<}E~AEvE7^UBXh=RE~Fg~8L+&t;ucLK6THbVzRi literal 0 HcmV?d00001 diff --git a/sprites/ui/Null.png.import b/sprites/ui/Null.png.import new file mode 100644 index 0000000..9a7c953 --- /dev/null +++ b/sprites/ui/Null.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://qowlv0viyqbb" +path="res://.godot/imported/Null.png-df7e65aefa4cf6fc02334dbb7c788923.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/ui/Null.png" +dest_files=["res://.godot/imported/Null.png-df7e65aefa4cf6fc02334dbb7c788923.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1