diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
index 6d84ded..5c931d3 100644
--- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
@@ -204,7 +204,60 @@
/// 所在的 World 对象
///
public World World { get; private set; }
-
+
+ ///
+ /// 是否开启描边
+ ///
+ public bool ShowOutline
+ {
+ get => _showOutline;
+ set
+ {
+ if (_blendShaderMaterial != null)
+ {
+ if (value != _showOutline)
+ {
+ _blendShaderMaterial.SetShaderParameter("show_outline", value);
+ if (_shadowBlendShaderMaterial != null)
+ {
+ _shadowBlendShaderMaterial.SetShaderParameter("show_outline", value);
+ }
+ _showOutline = value;
+ }
+ }
+ }
+ }
+
+ ///
+ /// 描边颜色
+ ///
+ public Color OutlineColor
+ {
+ get
+ {
+ if (!_initOutlineColor)
+ {
+ _initOutlineColor = true;
+ if (_blendShaderMaterial != null)
+ {
+ _outlineColor = _blendShaderMaterial.GetShaderParameter("outline_color").AsColor();
+ }
+ }
+
+ return _outlineColor;
+ }
+ set
+ {
+ _initOutlineColor = true;
+ if (value != _outlineColor)
+ {
+ _blendShaderMaterial.SetShaderParameter("outline_color", value);
+ }
+
+ _outlineColor = value;
+ }
+ }
+
// --------------------------------------------------------------------------------
//组件集合
@@ -264,6 +317,13 @@
//实例索引
private static long _instanceIndex = 0;
+ //是否启用描边
+ private bool _showOutline = false;
+
+ //描边颜色
+ private bool _initOutlineColor = false;
+ private Color _outlineColor = new Color(0, 0, 0, 1);
+
//初始化节点
private void _InitNode(RegisterActivityData activityData, World world)
{
@@ -281,6 +341,16 @@
Name = GetType().Name + (_instanceIndex++);
_blendShaderMaterial = AnimatedSprite.Material as ShaderMaterial;
_shadowBlendShaderMaterial = ShadowSprite.Material as ShaderMaterial;
+ if (_blendShaderMaterial != null)
+ {
+ _showOutline = _blendShaderMaterial.GetShaderParameter("show_outline").AsBool();
+ }
+
+ if (_shadowBlendShaderMaterial != null)
+ {
+ _shadowBlendShaderMaterial.SetShaderParameter("show_outline", _showOutline);
+ }
+
ShadowSprite.Visible = false;
MotionMode = MotionModeEnum.Floating;
MoveController = AddComponent();
diff --git a/DungeonShooting_Godot/src/game/activity/role/Player.cs b/DungeonShooting_Godot/src/game/activity/role/Player.cs
index 3411aec..9367d76 100644
--- a/DungeonShooting_Godot/src/game/activity/role/Player.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/Player.cs
@@ -130,7 +130,7 @@
//播放动画
PlayAnim();
}
-
+
public override bool PickUpWeapon(Weapon weapon, bool exchange = true)
{
//拾起武器
@@ -189,8 +189,16 @@
EventManager.EmitEvent(EventEnum.OnPlayerMaxHpChange, maxHp);
}
- protected override void ChangeInteractiveItem(CheckInteractiveResult result)
+ protected override void ChangeInteractiveItem(CheckInteractiveResult prev, CheckInteractiveResult result)
{
+ if (prev != null && prev.Target.ShowOutline)
+ {
+ prev.Target.OutlineColor = Colors.Black;
+ }
+ if (result != null && result.Target.ShowOutline)
+ {
+ result.Target.OutlineColor = Colors.White;
+ }
//派发互动对象改变事件
EventManager.EmitEvent(EventEnum.OnPlayerChangeInteractiveItem, result);
}
diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs
index 4a2129b..fd711db 100644
--- a/DungeonShooting_Godot/src/game/activity/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs
@@ -204,8 +204,8 @@
private Vector2 _startScale;
//所有角色碰撞的物体
private readonly List _interactiveItemList = new List();
-
- private CheckInteractiveResult _tempResultData;
+ //当前可互动的物体
+ private CheckInteractiveResult _currentResultData;
private uint _currentLayer;
//闪烁计时器
private float _flashingInvincibleTimer = -1;
@@ -277,8 +277,9 @@
///
/// 当可互动的物体改变时调用, result 参数为 null 表示变为不可互动
///
- /// 检测是否可互动时的返回值
- protected virtual void ChangeInteractiveItem(CheckInteractiveResult result)
+ /// 上一个互动的物体
+ /// 当前物体, 检测是否可互动时的返回值
+ protected virtual void ChangeInteractiveItem(CheckInteractiveResult prev, CheckInteractiveResult result)
{
}
@@ -341,28 +342,32 @@
if (!findFlag)
{
var result = item.CheckInteractive(this);
+ var prev = _currentResultData;
+ _currentResultData = result;
if (result.CanInteractive) //可以互动
{
findFlag = true;
if (InteractiveItem != item) //更改互动物体
{
InteractiveItem = item;
- ChangeInteractiveItem(result);
+ ChangeInteractiveItem(prev, result);
}
- else if (result.ShowIcon != _tempResultData.ShowIcon) //切换状态
+ else if (result.ShowIcon != _currentResultData.ShowIcon) //切换状态
{
- ChangeInteractiveItem(result);
+ ChangeInteractiveItem(prev, result);
}
}
- _tempResultData = result;
+
}
}
}
//没有可互动的物体
if (!findFlag && InteractiveItem != null)
{
+ var prev = _currentResultData;
+ _currentResultData = null;
InteractiveItem = null;
- ChangeInteractiveItem(null);
+ ChangeInteractiveItem(prev, null);
}
//无敌状态, 播放闪烁动画
@@ -757,8 +762,10 @@
}
if (InteractiveItem == propObject)
{
+ var prev = _currentResultData;
+ _currentResultData = null;
InteractiveItem = null;
- ChangeInteractiveItem(null);
+ ChangeInteractiveItem(prev, null);
}
}
}