diff --git a/DungeonShooting_Godot/prefab/shell/Shell0001.tscn b/DungeonShooting_Godot/prefab/shell/Shell0001.tscn
index b798a43..24a0fd2 100644
--- a/DungeonShooting_Godot/prefab/shell/Shell0001.tscn
+++ b/DungeonShooting_Godot/prefab/shell/Shell0001.tscn
@@ -9,20 +9,22 @@
shader = ExtResource("2_tdny6")
shader_parameter/blend = Color(0, 0, 0, 0.470588)
shader_parameter/schedule = 1.0
-shader_parameter/alpha = 1.0
+shader_parameter/modulate = Color(1, 1, 1, 1)
shader_parameter/show_outline = false
shader_parameter/outline_color = Color(0, 0, 0, 1)
shader_parameter/outline_rainbow = false
+shader_parameter/outline_use_blend = true
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7e6fo"]
resource_local_to_scene = true
shader = ExtResource("2_tdny6")
shader_parameter/blend = Color(1, 1, 1, 1)
shader_parameter/schedule = 0.0
-shader_parameter/alpha = 1.0
+shader_parameter/modulate = Color(1, 1, 1, 1)
shader_parameter/show_outline = true
shader_parameter/outline_color = Color(0, 0, 0, 1)
shader_parameter/outline_rainbow = false
+shader_parameter/outline_use_blend = true
[node name="Shell0001" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")]
collision_layer = 128
diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot
index 5224fa6..9fe9c84 100644
--- a/DungeonShooting_Godot/project.godot
+++ b/DungeonShooting_Godot/project.godot
@@ -11,7 +11,7 @@
[application]
config/name="DungeonShooting"
-run/main_scene="res://scene/test/TestDrawSprite.tscn"
+run/main_scene="res://scene/Main.tscn"
config/features=PackedStringArray("4.2", "C#")
config/icon="res://icon.png"
@@ -21,8 +21,8 @@
[display]
-window/size/viewport_width=1600
-window/size/viewport_height=900
+window/size/viewport_width=1270
+window/size/viewport_height=720
window/stretch/aspect="keep_width"
window/vsync/use_vsync=false
diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
index b8c6d62..74b925a 100644
--- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
@@ -1459,4 +1459,22 @@
{
return _processingBecomesStaticImage;
}
+
+ private ProxySprite _proxySprite;
+ public void Freeze()
+ {
+ if (_proxySprite == null)
+ {
+ _proxySprite = new ProxySprite();
+ }
+ }
+
+ public void Unfreeze()
+ {
+ if (_proxySprite == null)
+ {
+ return;
+ }
+
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
index 1992fbe..fa074af 100644
--- a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
+++ b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
@@ -307,7 +307,7 @@
Master.Rotation += rotationSpeed * delta;
}
//衰减旋转速率
- var friction = Master.GetCurrentFriction();
+ var friction = !Master.IsThrowing ? Master.GetCurrentFriction() : 0;
for (var i = 0; i < _forceList.Count; i++)
{
var force = _forceList[i];
diff --git a/DungeonShooting_Godot/src/framework/map/AffiliationArea.cs b/DungeonShooting_Godot/src/framework/map/AffiliationArea.cs
index 90fac99..84e66ad 100644
--- a/DungeonShooting_Godot/src/framework/map/AffiliationArea.cs
+++ b/DungeonShooting_Godot/src/framework/map/AffiliationArea.cs
@@ -29,7 +29,12 @@
/// 玩家是否是第一次进入
///
public bool IsFirstEnterFlag { get; private set; } = true;
-
+
+ ///
+ /// 静态渲染精灵根节点, 用于放置sprite
+ ///
+ public AffiliationSpriteRoot SpriteRoot { get; private set; }
+
private bool _init = false;
private Vector2 _initSize;
private RectangleShape2D _shape;
@@ -48,6 +53,10 @@
_initSize = rect2.Size;
RoomInfo = roomInfo;
+ SpriteRoot = new AffiliationSpriteRoot();
+ SpriteRoot.Name = "SpriteRoot";
+ World.Current.StaticSpriteRoot.AddChild(SpriteRoot);
+
var collisionShape = new CollisionShape2D();
collisionShape.GlobalPosition = rect2.Position + rect2.Size / 2;
var shape = new RectangleShape2D();
@@ -273,6 +282,10 @@
QueueFree();
_includeItems.Clear();
_enterItems.Clear();
+ if (SpriteRoot != null)
+ {
+ SpriteRoot.Destroy();
+ }
}
///
diff --git a/DungeonShooting_Godot/src/framework/map/image/AffiliationSpriteRoot.cs b/DungeonShooting_Godot/src/framework/map/image/AffiliationSpriteRoot.cs
new file mode 100644
index 0000000..e13864c
--- /dev/null
+++ b/DungeonShooting_Godot/src/framework/map/image/AffiliationSpriteRoot.cs
@@ -0,0 +1,17 @@
+
+using Godot;
+
+public partial class AffiliationSpriteRoot : Node2D, IDestroy
+{
+ public bool IsDestroyed { get; private set; }
+ public void Destroy()
+ {
+ if (IsDestroyed)
+ {
+ return;
+ }
+
+ IsDestroyed = true;
+ QueueFree();
+ }
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/map/image/ProxySprite.cs b/DungeonShooting_Godot/src/framework/map/image/ProxySprite.cs
new file mode 100644
index 0000000..dc4449d
--- /dev/null
+++ b/DungeonShooting_Godot/src/framework/map/image/ProxySprite.cs
@@ -0,0 +1,71 @@
+
+using Godot;
+
+public class ProxySprite : IDestroy
+{
+ public bool IsDestroyed { get; private set; }
+ public bool IsRecycled { get; set; }
+ public string Logotype => nameof(ProxySprite);
+
+ public Vector2 Position { get; private set; }
+ public Sprite2D Sprite { get; }
+ public Sprite2D ShadowSprite { get; }
+
+ private Node _root;
+
+ public ProxySprite()
+ {
+ Sprite = new Sprite2D();
+ ShadowSprite = new Sprite2D();
+ ShadowSprite.Modulate = new Color(0, 0, 0, 0.471f);
+ }
+
+ public void SetTexture(Node root, ActivityObject activityObject)
+ {
+ var animatedSprite = activityObject.AnimatedSprite;
+ SetTexture(
+ root,
+ activityObject.GetCurrentTexture(),
+ animatedSprite.GlobalPosition,
+ animatedSprite.GlobalRotation,
+ animatedSprite.GlobalScale,
+ activityObject.ShadowOffset
+ );
+ }
+
+ public void SetTexture(Node root, Texture2D texture, Vector2 position, float rotation, Vector2 scale, Vector2 shadowOffset)
+ {
+ Position = position;
+ Sprite.Position = position;
+ Sprite.Rotation = rotation;
+ Sprite.Scale = scale;
+ Sprite.Texture = texture;
+
+ ShadowSprite.Position = position + shadowOffset;
+ ShadowSprite.Rotation = rotation;
+ ShadowSprite.Scale = scale;
+ ShadowSprite.Texture = texture;
+
+ root.AddChild(ShadowSprite);
+ root.AddChild(Sprite);
+ }
+
+ public void Destroy()
+ {
+ if (IsDestroyed)
+ {
+ return;
+ }
+
+ IsDestroyed = true;
+ if (Sprite != null)
+ {
+ Sprite.QueueFree();
+ }
+
+ if (ShadowSprite != null)
+ {
+ ShadowSprite.QueueFree();
+ }
+ }
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/pool/IPoolItem.cs b/DungeonShooting_Godot/src/framework/pool/IPoolItem.cs
index 6cb897a..8ff53da 100644
--- a/DungeonShooting_Godot/src/framework/pool/IPoolItem.cs
+++ b/DungeonShooting_Godot/src/framework/pool/IPoolItem.cs
@@ -11,13 +11,13 @@
///
/// 对象唯一标识,用于在对象池中区分对象类型,可以是资源路径,也可以是配置表id
///
- string Logotype { get; set; }
+ string Logotype { get; }
///
/// 当物体被回收时调用,也就是进入对象池
///
void OnReclaim();
///
- ///
+ /// 离开对象池时调用
///
void OnLeavePool();
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs
index b5a7da5..cdffdd6 100644
--- a/DungeonShooting_Godot/src/game/GameApplication.cs
+++ b/DungeonShooting_Godot/src/game/GameApplication.cs
@@ -168,15 +168,15 @@
///
public void DestroyWorld()
{
- //销毁池中所有物体
- ObjectPool.DisposeAllItem();
-
//销毁所有物体
if (World != null)
{
ClearWorld();
World.QueueFree();
}
+
+ //销毁池中所有物体
+ ObjectPool.DisposeAllItem();
World = null;
}
@@ -297,7 +297,6 @@
//清理世界
private void ClearWorld()
{
-
var childCount = World.NormalLayer.GetChildCount();
for (var i = 0; i < childCount; i++)
{
diff --git a/DungeonShooting_Godot/src/game/activity/shell/Shell.cs b/DungeonShooting_Godot/src/game/activity/shell/Shell.cs
index 5b58591..4c223d2 100644
--- a/DungeonShooting_Godot/src/game/activity/shell/Shell.cs
+++ b/DungeonShooting_Godot/src/game/activity/shell/Shell.cs
@@ -12,21 +12,32 @@
ShadowOffset = new Vector2(0, 1);
ThrowCollisionSize = new Vector2(5, 5);
}
-
- protected override void Process(float delta)
+
+ protected override void OnThrowOver()
{
- //落地后将弹壳变为静态贴图
- if (!IsThrowing)
+ if (AffiliationArea != null)
{
- if (AffiliationArea != null)
- {
- BecomesStaticImage();
- }
- else
- {
- Debug.Log("弹壳投抛到画布外了, 强制消除...");
- Destroy();
- }
+ Freeze();
+ // var proxySprite = ObjectManager.GetProxySprite();
+ // proxySprite.SetTexture(AffiliationArea.SpriteRoot, this);
+ // this.CallDelay(0.1f, Destroy);
}
}
+
+ // protected override void Process(float delta)
+ // {
+ // //落地后将弹壳变为静态贴图
+ // if (!IsThrowing)
+ // {
+ // if (AffiliationArea != null)
+ // {
+ // BecomesStaticImage();
+ // }
+ // else
+ // {
+ // Debug.Log("弹壳投抛到画布外了, 强制消除...");
+ // Destroy();
+ // }
+ // }
+ // }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs
index 822e63e..69998c8 100644
--- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs
+++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs
@@ -417,13 +417,13 @@
var worldPos = roomInfo.GetWorldPosition();
var rect = roomInfo.OuterRange;
- int minX = rect.Position.X - GameConfig.TileCellSize;
- int minY = rect.Position.Y - GameConfig.TileCellSize;
- int maxX = rect.End.X + GameConfig.TileCellSize;
- int maxY = rect.End.Y + GameConfig.TileCellSize;
+ var minX = rect.Position.X - GameConfig.TileCellSize;
+ var minY = rect.Position.Y - GameConfig.TileCellSize;
+ var maxX = rect.End.X + GameConfig.TileCellSize;
+ var maxY = rect.End.Y + GameConfig.TileCellSize;
var staticSpriteCanvas = new RoomStaticImageCanvas(
- World.StaticSpriteRoot,
+ roomInfo.AffiliationArea.SpriteRoot,
new Vector2I(minX, minY),
maxX - minX, maxY - minY
);
diff --git a/DungeonShooting_Godot/src/test/TestDrawSprite.cs b/DungeonShooting_Godot/src/test/TestDrawSprite.cs
index a6afacf..c7a0729 100644
--- a/DungeonShooting_Godot/src/test/TestDrawSprite.cs
+++ b/DungeonShooting_Godot/src/test/TestDrawSprite.cs
@@ -12,7 +12,22 @@
public override void _Ready()
{
-
+ // for (var i = 0; i < 10000; i++)
+ // {
+ // var image = Image.Create(50, 50, false, Image.Format.Rgba8);
+ // image.Fill(new Color(Utils.Random.RandomRangeFloat(0, 1), Utils.Random.RandomRangeFloat(0, 1),
+ // Utils.Random.RandomRangeFloat(0, 1), Utils.Random.RandomRangeFloat(0, 1)));
+ // var imageTexture = ImageTexture.CreateFromImage(image);
+ // var proxySprite = new ProxySprite();
+ // proxySprite.SetTexture(
+ // this,
+ // imageTexture,
+ // new Vector2(Utils.Random.RandomRangeInt(0, 1600), Utils.Random.RandomRangeInt(0, 900)),
+ // Utils.Random.RandomRangeFloat(0, Mathf.Pi),
+ // new Vector2(Utils.Random.RandomRangeFloat(0.2f, 2f), Utils.Random.RandomRangeFloat(0.2f, 2f)),
+ // new Vector2(0, 5)
+ // );
+ // }
}
public override void _Process(double delta)
@@ -21,6 +36,8 @@
PathFollow2D.Progress += 200 * (float)delta;
}
+ //-------------------------------------------------------------------------------------------------------------------------------
+
//使用sprite2d绘制精灵
// public override void _Ready()
// {