diff --git a/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx b/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx index 1c0ddcf..0e93ce5 100644 --- a/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx b/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx index 474fcbe..df603d2 100644 --- a/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx b/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx index edb6abc..f909ce4 100644 --- a/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx b/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx index 0d2d771..6f1a4d7 100644 --- a/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/EnemyBase.xlsx b/DungeonShooting_Godot/excel/excelFile/EnemyBase.xlsx index b3f6cab..52b0385 100644 --- a/DungeonShooting_Godot/excel/excelFile/EnemyBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/EnemyBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/LiquidMaterial.xlsx b/DungeonShooting_Godot/excel/excelFile/LiquidMaterial.xlsx new file mode 100644 index 0000000..c13160a --- /dev/null +++ b/DungeonShooting_Godot/excel/excelFile/LiquidMaterial.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/Sound.xlsx b/DungeonShooting_Godot/excel/excelFile/Sound.xlsx index ad0d8fe..0c85b96 100644 --- a/DungeonShooting_Godot/excel/excelFile/Sound.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/Sound.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx b/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx index 98e9781..49bb79e 100644 --- a/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/resource/config/LiquidMaterial.json b/DungeonShooting_Godot/resource/config/LiquidMaterial.json new file mode 100644 index 0000000..156a26d --- /dev/null +++ b/DungeonShooting_Godot/resource/config/LiquidMaterial.json @@ -0,0 +1,18 @@ +[ + { + "Id": "0001", + "Remark": "\u6BD2\u6DB2", + "BurshTexture": "res://resource/sprite/brush/Brush2.png", + "Ffm": 0.5, + "Duration": 5, + "WriteOffSpeed": 0.2 + }, + { + "Id": "0002", + "Remark": "\u654C\u4EBA0002\u7684\u7C98\u6DB2", + "BurshTexture": "res://resource/sprite/brush/Brush3.png", + "Ffm": 0.7, + "Duration": 4, + "WriteOffSpeed": 0.2 + } +] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/sprite/brush/Brush1.png b/DungeonShooting_Godot/resource/sprite/brush/Brush1.png new file mode 100644 index 0000000..c768e96 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/brush/Brush1.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/brush/Brush1.png.import b/DungeonShooting_Godot/resource/sprite/brush/Brush1.png.import new file mode 100644 index 0000000..1d0ac77 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/brush/Brush1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b1qqkdbgeiptt" +path="res://.godot/imported/Brush1.png-77a9f61d37eedcb2e34d8c6b4bac0049.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/brush/Brush1.png" +dest_files=["res://.godot/imported/Brush1.png-77a9f61d37eedcb2e34d8c6b4bac0049.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 diff --git a/DungeonShooting_Godot/resource/sprite/brush/Brush2.png b/DungeonShooting_Godot/resource/sprite/brush/Brush2.png new file mode 100644 index 0000000..b74c0ed --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/brush/Brush2.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/brush/Brush2.png.import b/DungeonShooting_Godot/resource/sprite/brush/Brush2.png.import new file mode 100644 index 0000000..126d1e2 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/brush/Brush2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://diehy0xukqgxk" +path="res://.godot/imported/Brush2.png-98e4673c392b5d8c4f415172ae2c4d5a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/brush/Brush2.png" +dest_files=["res://.godot/imported/Brush2.png-98e4673c392b5d8c4f415172ae2c4d5a.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 diff --git a/DungeonShooting_Godot/resource/sprite/brush/Brush3.png b/DungeonShooting_Godot/resource/sprite/brush/Brush3.png new file mode 100644 index 0000000..c77fef5 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/brush/Brush3.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/brush/Brush3.png.import b/DungeonShooting_Godot/resource/sprite/brush/Brush3.png.import new file mode 100644 index 0000000..18c8e64 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/brush/Brush3.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://jnx4wfn5hu3u" +path="res://.godot/imported/Brush3.png-1030dd2952f08d45fe719009951c0ba1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/brush/Brush3.png" +dest_files=["res://.godot/imported/Brush3.png-1030dd2952f08d45fe719009951c0ba1.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 diff --git a/DungeonShooting_Godot/resource/test/Brush1.png b/DungeonShooting_Godot/resource/test/Brush1.png deleted file mode 100644 index c768e96..0000000 --- a/DungeonShooting_Godot/resource/test/Brush1.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/test/Brush1.png.import b/DungeonShooting_Godot/resource/test/Brush1.png.import deleted file mode 100644 index 36e2337..0000000 --- a/DungeonShooting_Godot/resource/test/Brush1.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://b1qqkdbgeiptt" -path="res://.godot/imported/Brush1.png-c06cfaae2d1899be439c0c781f8ded8e.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/test/Brush1.png" -dest_files=["res://.godot/imported/Brush1.png-c06cfaae2d1899be439c0c781f8ded8e.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 diff --git a/DungeonShooting_Godot/resource/test/Brush2.png b/DungeonShooting_Godot/resource/test/Brush2.png deleted file mode 100644 index b74c0ed..0000000 --- a/DungeonShooting_Godot/resource/test/Brush2.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/test/Brush2.png.import b/DungeonShooting_Godot/resource/test/Brush2.png.import deleted file mode 100644 index e6c7edc..0000000 --- a/DungeonShooting_Godot/resource/test/Brush2.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://diehy0xukqgxk" -path="res://.godot/imported/Brush2.png-dbc4fb33763caf479092647cbe3b1dd8.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/test/Brush2.png" -dest_files=["res://.godot/imported/Brush2.png-dbc4fb33763caf479092647cbe3b1dd8.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 diff --git a/DungeonShooting_Godot/resource/test/Brush3.png b/DungeonShooting_Godot/resource/test/Brush3.png deleted file mode 100644 index c77fef5..0000000 --- a/DungeonShooting_Godot/resource/test/Brush3.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/test/Brush3.png.import b/DungeonShooting_Godot/resource/test/Brush3.png.import deleted file mode 100644 index 5c25409..0000000 --- a/DungeonShooting_Godot/resource/test/Brush3.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://jnx4wfn5hu3u" -path="res://.godot/imported/Brush3.png-c626025ee33281acc6b1ad59b29276c7.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/test/Brush3.png" -dest_files=["res://.godot/imported/Brush3.png-c626025ee33281acc6b1ad59b29276c7.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 diff --git a/DungeonShooting_Godot/scene/test/TestMask2.tscn b/DungeonShooting_Godot/scene/test/TestMask2.tscn index bdb3132..a18fde2 100644 --- a/DungeonShooting_Godot/scene/test/TestMask2.tscn +++ b/DungeonShooting_Godot/scene/test/TestMask2.tscn @@ -1,11 +1,12 @@ [gd_scene load_steps=6 format=3 uid="uid://d2b8jufx70mkl"] [ext_resource type="Script" path="res://src/test/TestMask2.cs" id="1_rtexh"] -[ext_resource type="Texture2D" uid="uid://b1qqkdbgeiptt" path="res://resource/test/Brush1.png" id="2_bgpg8"] -[ext_resource type="Texture2D" uid="uid://diehy0xukqgxk" path="res://resource/test/Brush2.png" id="3_207p4"] +[ext_resource type="Texture2D" uid="uid://b1qqkdbgeiptt" path="res://resource/sprite/brush/Brush1.png" id="2_bgpg8"] +[ext_resource type="Texture2D" uid="uid://diehy0xukqgxk" path="res://resource/sprite/brush/Brush2.png" id="3_207p4"] [ext_resource type="TileSet" uid="uid://b00g22o1cqhe8" path="res://resource/map/tileSet/map1/TileSet1.tres" id="4_10tef"] [ext_resource type="SpriteFrames" uid="uid://n11thtali6es" path="res://resource/spriteFrames/role/Role0001.tres" id="7_dqhlh"] + [node name="TestMask2" type="SubViewportContainer" node_paths=PackedStringArray("Message", "Player")] offset_right = 480.0 offset_bottom = 270.0 diff --git a/DungeonShooting_Godot/src/config/ExcelConfig.cs b/DungeonShooting_Godot/src/config/ExcelConfig.cs index 32a1ea5..bf3c620 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig.cs @@ -53,6 +53,15 @@ public static Dictionary EnemyBase_Map { get; private set; } /// + /// LiquidMaterial.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 + /// + public static List LiquidMaterial_List { get; private set; } + /// + /// LiquidMaterial.xlsx表数据集合, 里 Map 形式存储, key 为 Id + /// + public static Dictionary LiquidMaterial_Map { get; private set; } + + /// /// Sound.xlsx表数据集合, 以 List 形式存储, 数据顺序与 Excel 表相同 /// public static List Sound_List { get; private set; } @@ -85,6 +94,7 @@ _InitAiAttackAttrConfig(); _InitBulletBaseConfig(); _InitEnemyBaseConfig(); + _InitLiquidMaterialConfig(); _InitSoundConfig(); _InitWeaponBaseConfig(); @@ -182,6 +192,24 @@ throw new Exception("初始化表'EnemyBase'失败!"); } } + private static void _InitLiquidMaterialConfig() + { + try + { + var text = _ReadConfigAsText("res://resource/config/LiquidMaterial.json"); + LiquidMaterial_List = JsonSerializer.Deserialize>(text); + LiquidMaterial_Map = new Dictionary(); + foreach (var item in LiquidMaterial_List) + { + LiquidMaterial_Map.Add(item.Id, item); + } + } + catch (Exception e) + { + GD.PrintErr(e.ToString()); + throw new Exception("初始化表'LiquidMaterial'失败!"); + } + } private static void _InitSoundConfig() { try diff --git a/DungeonShooting_Godot/src/config/ExcelConfig_LiquidMaterial.cs b/DungeonShooting_Godot/src/config/ExcelConfig_LiquidMaterial.cs new file mode 100644 index 0000000..420d8a1 --- /dev/null +++ b/DungeonShooting_Godot/src/config/ExcelConfig_LiquidMaterial.cs @@ -0,0 +1,62 @@ +using System.Text.Json.Serialization; +using System.Collections.Generic; + +namespace Config; + +public static partial class ExcelConfig +{ + public class LiquidMaterial + { + /// + /// 表Id + /// + [JsonInclude] + public string Id; + + /// + /// 备注 + /// + [JsonInclude] + public string Remark; + + /// + /// 笔刷贴图 + /// + [JsonInclude] + public string BurshTexture; + + /// + /// 补帧间距倍率(0-1) + /// + [JsonInclude] + public float Ffm; + + /// + /// 开始消退时间,单位秒
+ /// 小于0则永远不会消退 + ///
+ [JsonInclude] + public float Duration; + + /// + /// 消退速度, 也就是 Alpha 值每秒变化的速度 + /// + [JsonInclude] + public float WriteOffSpeed; + + /// + /// 返回浅拷贝出的新对象 + /// + public LiquidMaterial Clone() + { + var inst = new LiquidMaterial(); + inst.Id = Id; + inst.Remark = Remark; + inst.BurshTexture = BurshTexture; + inst.Ffm = Ffm; + inst.Duration = Duration; + inst.WriteOffSpeed = WriteOffSpeed; + return inst; + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/liquid/BrushImageData.cs b/DungeonShooting_Godot/src/framework/map/liquid/BrushImageData.cs index 184ed35..337b8e1 100644 --- a/DungeonShooting_Godot/src/framework/map/liquid/BrushImageData.cs +++ b/DungeonShooting_Godot/src/framework/map/liquid/BrushImageData.cs @@ -1,6 +1,7 @@ using System; using Godot; using System.Collections.Generic; +using Config; /// /// 液体笔刷数据 @@ -8,11 +9,16 @@ public class BrushImageData { /// - /// + /// 笔刷宽度 /// public int Width; - + /// + /// 笔刷高度 + /// public int Height; + /// + /// 笔刷所有有效像素点 + /// public BrushPixelData[] Pixels; //有效像素范围 @@ -20,16 +26,26 @@ public int PixelMinY = int.MaxValue; public int PixelMaxX; public int PixelMaxY; - + + /// + /// 有效像素宽度 + /// public int PixelWidth; + /// + /// 有效像素高度 + /// public int PixelHeight; + /// + /// 笔刷材质 + /// + public ExcelConfig.LiquidMaterial Material; - //补帧间距倍率 - public float Ffm; + private static readonly Dictionary _imageData = new Dictionary(); - public BrushImageData(Image image, byte type, float ffm, float duration, float writeOffSpeed) + public BrushImageData(ExcelConfig.LiquidMaterial material) { - Ffm = ffm; + Material = material; + var image = GetImageData(material.BurshTexture); var list = new List(); var width = image.GetWidth(); var height = image.GetHeight(); @@ -47,9 +63,7 @@ X = x, Y = y, Color = pixel, - Type = type, - Duration = duration, - WriteOffSpeed = writeOffSpeed + Material = material }); if (x < PixelMinX) { @@ -84,4 +98,27 @@ PixelWidth = PixelMaxX - PixelMinX; PixelHeight = PixelMaxY - PixelMinY; } + + private static Image GetImageData(string path) + { + if (!_imageData.TryGetValue(path, out var image)) + { + var texture = ResourceManager.LoadTexture2D(path); + image = texture.GetImage(); + } + + return image; + } + + /// + /// 清除笔刷缓存数据 + /// + public static void ClearBrushData() + { + foreach (var keyValuePair in _imageData) + { + keyValuePair.Value.Dispose(); + } + _imageData.Clear(); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/liquid/BrushPixelData.cs b/DungeonShooting_Godot/src/framework/map/liquid/BrushPixelData.cs index 9b8d598..7535fe5 100644 --- a/DungeonShooting_Godot/src/framework/map/liquid/BrushPixelData.cs +++ b/DungeonShooting_Godot/src/framework/map/liquid/BrushPixelData.cs @@ -1,4 +1,5 @@ -using Godot; +using Config; +using Godot; /// /// 用于记录笔刷上的像素点 @@ -18,15 +19,7 @@ /// public Color Color; /// - /// 材质类型 + /// 材质液体材质 /// - public byte Type; - /// - /// 开始消退时间 - /// - public float Duration; - /// - /// 消退速度, 也就是 Alpha 值每秒变化的速度 - /// - public float WriteOffSpeed; + public ExcelConfig.LiquidMaterial Material; } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/liquid/LiquidCanvas.cs b/DungeonShooting_Godot/src/framework/map/liquid/LiquidCanvas.cs index 3587e56..0cebaec 100644 --- a/DungeonShooting_Godot/src/framework/map/liquid/LiquidCanvas.cs +++ b/DungeonShooting_Godot/src/framework/map/liquid/LiquidCanvas.cs @@ -25,7 +25,8 @@ //画布上的像素点 private LiquidPixel[,] _imagePixels; - private List _cacheImagePixels = new List(); + //需要执行更新的像素点 + private List _updateImagePixels = new List(); //画布已经运行的时间 private float _runTime = 0; private int _executeIndex = -1; @@ -66,12 +67,12 @@ //这里待优化, 应该每次绘制都将像素点放入 _tempList 中, 然后帧结束再统一提交 //更新消除逻辑 - if (_cacheImagePixels.Count > 0) + if (_updateImagePixels.Count > 0) { var startIndex = _executeIndex; - if (_executeIndex < 0 || _executeIndex >= _cacheImagePixels.Count) + if (_executeIndex < 0 || _executeIndex >= _updateImagePixels.Count) { - _executeIndex = _cacheImagePixels.Count - 1; + _executeIndex = _updateImagePixels.Count - 1; } var startTime = DateTime.UtcNow; @@ -80,10 +81,10 @@ for (; _executeIndex >= 0; _executeIndex--) { index++; - var imagePixel = _cacheImagePixels[_executeIndex]; + var imagePixel = _updateImagePixels[_executeIndex]; if (UpdateImagePixel(imagePixel)) //移除 { - _cacheImagePixels.RemoveAt(_executeIndex); + _updateImagePixels.RemoveAt(_executeIndex); if (_executeIndex < startIndex) { startIndex--; @@ -103,14 +104,14 @@ if (!isOver && startIndex >= 0 && _executeIndex < 0) { - _executeIndex = _cacheImagePixels.Count - 1; + _executeIndex = _updateImagePixels.Count - 1; for (; _executeIndex >= startIndex; _executeIndex--) { index++; - var imagePixel = _cacheImagePixels[_executeIndex]; + var imagePixel = _updateImagePixels[_executeIndex]; if (UpdateImagePixel(imagePixel)) //移除 { - _cacheImagePixels.RemoveAt(_executeIndex); + _updateImagePixels.RemoveAt(_executeIndex); } if (index > 200) @@ -141,6 +142,27 @@ { return (_roomInfo.ToCanvasPosition(position) / CanvasScale).AsVector2I(); } + + /// + /// 根据画笔数据在画布上绘制液体, 转换坐标请调用 ToLiquidCanvasPosition() 函数 + /// + /// 画笔数据 + /// 绘制坐标, 相对于画布坐标 + public void DrawBrush(BrushImageData brush, Vector2I position) + { + DrawBrush(brush, null, position, 0); + } + + /// + /// 根据画笔数据在画布上绘制液体, 转换坐标请调用 ToLiquidCanvasPosition() 函数 + /// + /// 画笔数据 + /// 绘制坐标, 相对于画布坐标 + /// 旋转角度, 弧度制 + public void DrawBrush(BrushImageData brush, Vector2I position, float rotation) + { + DrawBrush(brush, null, position, rotation); + } /// /// 根据画笔数据在画布上绘制液体, 转换坐标请调用 ToLiquidCanvasPosition() 函数 @@ -159,11 +181,11 @@ if (prevPosition != null) { var offset = new Vector2(position.X - prevPosition.Value.X, position.Y - prevPosition.Value.Y); - var maxL = Mathf.Lerp( + var maxL = brush.Material.Ffm * Mathf.Lerp( brush.PixelHeight, brush.PixelWidth, Mathf.Abs(Mathf.Sin(offset.Angle() - rotation + Mathf.Pi * 0.5f)) - ) * brush.Ffm; + ); var len = offset.Length(); if (len > maxL) //距离太大了, 需要补间 { @@ -267,7 +289,7 @@ } /// - /// 更新像素点数据逻辑 + /// 更新像素点数据逻辑, 返回是否擦除 /// private bool UpdateImagePixel(LiquidPixel imagePixel) { @@ -280,13 +302,14 @@ } else { - imagePixel.Color.A -= imagePixel.WriteOffSpeed * (_runTime - imagePixel.TempTime); + imagePixel.Color.A -= imagePixel.Material.WriteOffSpeed * (_runTime - imagePixel.TempTime); if (imagePixel.Color.A <= 0) //完全透明了 { _changeFlag = true; _image.SetPixel(imagePixel.X, imagePixel.Y, new Color(0, 0, 0, 0)); imagePixel.IsRun = false; + imagePixel.IsUpdate = false; return true; } else @@ -312,22 +335,25 @@ X = x, Y = y, Color = pixelData.Color, - Type = pixelData.Type, - Timer = pixelData.Duration, - WriteOffSpeed = pixelData.WriteOffSpeed, + Material = pixelData.Material, + Timer = pixelData.Material.Duration, }; _imagePixels[x, y] = temp; - - _cacheImagePixels.Add(temp); + temp.IsRun = true; + temp.IsUpdate = temp.Material.Duration >= 0; + if (temp.IsUpdate) + { + _updateImagePixels.Add(temp); + } temp.TempTime = _runTime; } else { - if (temp.Type != pixelData.Type) + if (temp.Material != pixelData.Material) { temp.Color = pixelData.Color; - temp.Type = pixelData.Type; + temp.Material = pixelData.Material; } else { @@ -335,14 +361,21 @@ temp.Color = new Color(tempColor.R, tempColor.G, tempColor.B, Mathf.Max(temp.Color.A, tempColor.A)); } - temp.WriteOffSpeed = pixelData.WriteOffSpeed; - temp.Timer = pixelData.Duration; - if (!temp.IsRun) + temp.Timer = pixelData.Material.Duration; + + var prevUpdate = temp.IsUpdate; + temp.IsUpdate = temp.Material.Duration >= 0; + if (!prevUpdate && temp.IsUpdate) { - _cacheImagePixels.Add(temp); - temp.IsRun = true; - temp.TempTime = _runTime; + _updateImagePixels.Add(temp); } + else if (prevUpdate && !temp.IsUpdate) + { + _updateImagePixels.Remove(temp); + } + + temp.IsRun = true; + temp.TempTime = _runTime; } return temp; diff --git a/DungeonShooting_Godot/src/framework/map/liquid/LiquidPixel.cs b/DungeonShooting_Godot/src/framework/map/liquid/LiquidPixel.cs index aa8dbde..318b627 100644 --- a/DungeonShooting_Godot/src/framework/map/liquid/LiquidPixel.cs +++ b/DungeonShooting_Godot/src/framework/map/liquid/LiquidPixel.cs @@ -1,5 +1,6 @@  +using Config; using Godot; /// @@ -20,22 +21,22 @@ /// public Color Color; /// - /// 材质类型 + /// 材质液体材质 /// - public byte Type; + public ExcelConfig.LiquidMaterial Material; /// /// 开始销退像素点的计时器 /// public float Timer; /// - /// 消退速度, 也就是 Alpha 值每秒变化的速度 - /// - public float WriteOffSpeed; - /// /// 记录是否正在画布上显示 /// public bool IsRun; /// + /// 是否执行更新逻辑 + /// + public bool IsUpdate; + /// /// 上一次操作 Alpha的 时间, 用该时间和画布的 RunTime 相减可以计算出 delta /// public float TempTime; diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs index ae95977..8cd04b7 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs @@ -242,8 +242,11 @@ MountPoint.SetLookAt(pos); } - //拾起武器操作 - EnemyPickUpWeapon(); + if (EnemyRoleState.CanPickUpWeapon) + { + //拾起武器操作 + EnemyPickUpWeapon(); + } } public override bool IsAllWeaponTotalAmmoEmpty() diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs index e6fc35e..1837b00 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/NoWeaponEnemy.cs @@ -17,7 +17,7 @@ NoWeaponAttack = true; AnimationPlayer.AnimationFinished += OnAnimationFinished; - _brushData3 = new BrushImageData(ResourceManager.LoadTexture2D(ResourcePath.resource_test_Brush3_png).GetImage(), 3, 0.7f, 4, 0.2f); + _brushData3 = new BrushImageData(ExcelConfig.LiquidMaterial_Map["0002"]); } protected override void Process(float delta) diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index ee136b2..d906c99 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -1,4 +1,5 @@ using System; +using Config; using Godot; @@ -82,7 +83,7 @@ //InitSubLine(); - _brushData2 = new BrushImageData(ResourceManager.LoadTexture2D(ResourcePath.resource_test_Brush2_png).GetImage(), 2, 0.5f, 5, 0.2f); + _brushData2 = new BrushImageData(ExcelConfig.LiquidMaterial_Map["0001"]); } protected override RoleState OnCreateRoleState() diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 2cf7f97..97ad5c7 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -166,6 +166,9 @@ public const string resource_sound_sfx_shooting_Shooting0009_ogg = "res://resource/sound/sfx/shooting/Shooting0009.ogg"; public const string resource_sound_sfx_shooting_Shooting0010_ogg = "res://resource/sound/sfx/shooting/Shooting0010.ogg"; public const string resource_sound_sfx_shooting_Shooting0011_ogg = "res://resource/sound/sfx/shooting/Shooting0011.ogg"; + public const string resource_sprite_brush_Brush1_png = "res://resource/sprite/brush/Brush1.png"; + public const string resource_sprite_brush_Brush2_png = "res://resource/sprite/brush/Brush2.png"; + public const string resource_sprite_brush_Brush3_png = "res://resource/sprite/brush/Brush3.png"; public const string resource_sprite_bullet_laser_Laser0001_png = "res://resource/sprite/bullet/laser/Laser0001.png"; public const string resource_sprite_bullet_normal_arrow_png = "res://resource/sprite/bullet/normal/arrow.png"; public const string resource_sprite_bullet_normal_bullet0001_png = "res://resource/sprite/bullet/normal/bullet0001.png"; @@ -370,9 +373,6 @@ public const string resource_spriteFrames_weapon_Weapon0007_tres = "res://resource/spriteFrames/weapon/Weapon0007.tres"; public const string resource_spriteFrames_weapon_Weapon0008_tres = "res://resource/spriteFrames/weapon/Weapon0008.tres"; public const string resource_spriteFrames_weapon_Weapon0009_tres = "res://resource/spriteFrames/weapon/Weapon0009.tres"; - public const string resource_test_Brush1_png = "res://resource/test/Brush1.png"; - public const string resource_test_Brush2_png = "res://resource/test/Brush2.png"; - public const string resource_test_Brush3_png = "res://resource/test/Brush3.png"; public const string resource_theme_mainTheme_tres = "res://resource/theme/mainTheme.tres"; public const string resource_theme_theme1_tres = "res://resource/theme/theme1.tres"; public const string scene_Main_tscn = "res://scene/Main.tscn"; diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index 57b3363..62e4256 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -299,6 +299,7 @@ GameApplication.Instance.DestroyWorld(); yield return 0; FogMaskHandler.ClearRecordRoom(); + BrushImageData.ClearBrushData(); QueueRedraw(); //鼠标还原 GameApplication.Instance.Cursor.SetGuiMode(true); @@ -325,10 +326,10 @@ CreateRoomAffiliation(roomInfo); //创建 RoomStaticSprite CreateRoomStaticSprite(roomInfo); - //创建液体区域 - CreateRoomLiquidCanvas(roomInfo); //创建静态精灵画布 CreateRoomStaticImageCanvas(roomInfo); + //创建液体区域 + CreateRoomLiquidCanvas(roomInfo); //创建迷雾遮罩 CreateRoomFogMask(roomInfo); } diff --git a/DungeonShooting_Godot/src/test/TestMask2.cs b/DungeonShooting_Godot/src/test/TestMask2.cs index d3388b7..1207a6f 100644 --- a/DungeonShooting_Godot/src/test/TestMask2.cs +++ b/DungeonShooting_Godot/src/test/TestMask2.cs @@ -1,6 +1,7 @@ using Godot; using System; using System.Collections.Generic; +using Config; public partial class TestMask2 : SubViewportContainer { @@ -27,8 +28,8 @@ { Engine.MaxFps = (int)DisplayServer.ScreenGetRefreshRate(); //Engine.MaxFps = 5; - _brushData1 = new BrushImageData(Brush1.GetImage(), 1, 0.5f, 5, 0.1f); - _brushData2 = new BrushImageData(Brush2.GetImage(), 2, 0.5f, 5, 0.2f); + _brushData1 = new BrushImageData(ExcelConfig.LiquidMaterial_Map["0001"]); + _brushData2 = new BrushImageData(ExcelConfig.LiquidMaterial_Map["0002"]); _liquidCanvas = new LiquidCanvas(null, (int)(Size.X / LiquidCanvas.CanvasScale), (int)(Size.X / LiquidCanvas.CanvasScale)); GetNode("SubViewport").AddChild(_liquidCanvas); }