优化“红外遥控器”道具效果

This commit is contained in:
小李xl 2024-03-20 00:29:21 +08:00
parent 8c0710190d
commit 27648b5de2
15 changed files with 199 additions and 26 deletions

View File

@ -11,7 +11,7 @@ width = 128
height = 128
fill = 1
fill_from = Vector2(0.5, 0.5)
fill_to = Vector2(0.827839, 0.291819)
fill_to = Vector2(1, 0.5)
[sub_resource type="CircleShape2D" id="CircleShape2D_1llif"]
radius = 15.0333

View File

@ -63,14 +63,16 @@
"Buff": null,
"Condition": null,
"Effect": {
"AreaTrigger": []
"AreaTrigger": [
200
]
},
"Charge": {
"Hurt": [
100
250
]
},
"Duration": 0,
"Duration": 6,
"CooldownTime": 0,
"IsConsumables": false,
"MaxCount": 1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 B

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 B

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 B

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 B

After

Width:  |  Height:  |  Size: 107 B

View File

@ -60,8 +60,7 @@ public static partial class ExcelConfig
/// <summary>
/// 使用道具的效果持续时间 <br/>
/// 单位: 秒 <br/>
/// 注意: 该持续时间与具体道具属性片段无关, 仅用于程序计算何时可以开始冷却道具
/// 单位: 秒
/// </summary>
[JsonInclude]
public float Duration;

View File

@ -84,8 +84,20 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
/// </summary>
public float AutoChargeSpeed { get; set; }
/// <summary>
/// 是否正使用中
/// </summary>
public bool IsUsing => _durationTimer > 0;
/// <summary>
/// 道具使用时间进度 (0 - 1)
/// </summary>
public float UsingProgress => 1 - _durationTimer / Attribute.Duration;
//冷却计时器
private float _cooldownTimer = 0;
//持续时间计时器
private float _durationTimer = 0;
//被动属性
private readonly List<BuffFragment> _buffFragment = new List<BuffFragment>();
@ -331,6 +343,14 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
{
fragment.OnUse();
}
}
/// <summary>
/// 道具使用持续时间完成时调用
/// </summary>
protected virtual void OnUsingFinish()
{
}
/// <summary>
@ -367,8 +387,23 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
{
return;
}
//持续时间
if (_durationTimer > 0)
{
_durationTimer -= delta;
//持续时间完成
if (_durationTimer <= 0)
{
_durationTimer = 0;
//冷却计时器
_cooldownTimer = Attribute.CooldownTime;
UsingFinish();
}
}
//冷却
if (_cooldownTimer > 0)
else if (_cooldownTimer > 0)
{
_cooldownTimer -= delta;
@ -416,7 +451,7 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
/// </summary>
public void Use()
{
if (Master == null)
if (Master == null || IsUsing)
{
return;
}
@ -428,8 +463,16 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
Count -= 1;
}
//冷却计时器
_cooldownTimer = Attribute.CooldownTime;
if (Attribute.Duration > 0) //持续时间
{
_durationTimer = Attribute.Duration;
}
else
{
//冷却计时器
_cooldownTimer = Attribute.CooldownTime;
UsingFinish();
}
}
}
@ -652,6 +695,22 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
fragment.OnPickUpItem();
}
}
//持续时间完成
private void UsingFinish()
{
OnUsingFinish();
foreach (var effectFragment in _effectFragment)
{
effectFragment.OnUsingFinish();
}
foreach (var chargeFragment in _chargeFragment)
{
chargeFragment.OnUsingFinish();
}
}
private static bool _init = false;

View File

@ -257,6 +257,9 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
//抖动计时器
private float _shakeTimer = 0;
//换弹完成后播放的动画
private string _reloadNextAnimation;
// ----------------------------------------------
private uint _tempLayer;
@ -804,6 +807,25 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
return Master == null && GetParent() == World.Current.NormalLayer;
}
/// <summary>
/// 清除触发角色开火标记数据
/// </summary>
public void ClearTriggerRole()
{
_triggerRoleFlag = false;
if (Master == null)
{
if (Reloading)
{
_reloadNextAnimation = AnimatorNames.Floodlight;
}
else
{
AnimationPlayer.Play(AnimatorNames.Floodlight);
}
}
}
/// <summary>
/// 扳机函数, 调用即视为按下扳机
/// </summary>
@ -819,6 +841,10 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
//更新武器属性信息
_triggerFlag = true;
if (!_triggerRoleFlag && AnimationPlayer.CurrentAnimation == AnimatorNames.Floodlight)
{
AnimationPlayer.Play(AnimatorNames.Reset);
}
_triggerRoleFlag = true;
_triggerCalcAmmon = calcAmmo;
if (triggerRole != null)
@ -1598,6 +1624,11 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
private void ReloadFinishHandler()
{
// Debug.Log("装弹完成.");
if (_reloadNextAnimation != null)
{
AnimationPlayer.Play(_reloadNextAnimation);
_reloadNextAnimation = null;
}
OnReloadFinish();
}

View File

@ -14,6 +14,13 @@ public abstract class ChargeFragment : PropFragment
/// </summary>
public abstract void OnUse();
/// <summary>
/// 道具持续时间完成时调用
/// </summary>
public virtual void OnUsingFinish()
{
}
public override void OnPickUpItem()
{
}

View File

@ -21,6 +21,13 @@ public abstract class EffectFragment : PropFragment
/// 使用道具的回调
/// </summary>
public abstract void OnUse();
/// <summary>
/// 道具持续时间完成时调用
/// </summary>
public virtual void OnUsingFinish()
{
}
public override void OnPickUpItem()
{

View File

@ -11,6 +11,19 @@ public class Cha_Hurt : ChargeFragment
}
public override void OnUse()
{
}
public override void Process(float delta)
{
if (Master.IsUsing)
{
Master.ChargeProgress = 1 - Master.UsingProgress;
}
}
public override void OnUsingFinish()
{
Master.ChargeProgress = 0;
}
@ -27,6 +40,10 @@ public class Cha_Hurt : ChargeFragment
private void OnDamageEvent(Role role, int value)
{
if (Master.IsUsing)
{
return;
}
Master.ChargeProgress += 1f / _value * value;
}
}

View File

@ -2,12 +2,22 @@
using System.Collections.Generic;
using Godot;
[EffectFragment("AreaTrigger", "")]
[EffectFragment("AreaTrigger",
"触发附近地上的武器开火, " +
"参数1为最大作用半径, ")]
public class Eff_AreaTrigger : EffectFragment
{
private Prop5003Area _areaNode;
private List<Weapon> _weaponList = new List<Weapon>();
private float _time = 0;
private int _radius = 250;
public override void InitParam(float arg1)
{
_radius = (int)arg1;
}
public override void Ready()
{
_areaNode = ResourceManager.LoadAndInstantiate<Prop5003Area>(ResourcePath.prefab_prop_activeComp_Prop5003_Area_tscn);
@ -23,19 +33,57 @@ public class Eff_AreaTrigger : EffectFragment
public override void OnUse()
{
_areaNode.PlayEffect(0, 250, 6);
_areaNode.PlayEffect(0, _radius, Master.Attribute.Duration);
}
public override void OnUsingFinish()
{
foreach (var weapon in _weaponList)
{
weapon.ClearTriggerRole();
}
_weaponList.Clear();
}
public override void Process(float delta)
{
if (!Master.IsUsing)
{
_time = 0;
return;
}
_time += delta;
var flag = false;
if (_time >= 0.5f)
{
flag = true;
_time %= 0.5f;
}
for (var i = 0; i < _weaponList.Count; i++)
{
var weapon = _weaponList[i];
if (weapon.Master != null)
{
_weaponList.RemoveAt(i--);
weapon.ClearTriggerRole();
continue;
}
if (flag)
{
var weaponBase = weapon.GetUseAttribute(Role);
if (!weaponBase.ContinuousShoot)
{
if (!weaponBase.LooseShoot)
{
continue;
}
else if (!weapon.IsCharging || weapon.IsChargeFinish())
{
continue;
}
}
}
weapon.Trigger(Role, false);
}
}
@ -67,7 +115,10 @@ public class Eff_AreaTrigger : EffectFragment
{
if (node is Weapon weapon && weapon.Master == null)
{
_weaponList.Remove(weapon);
if (_weaponList.Remove(weapon))
{
weapon.ClearTriggerRole();
}
}
}
}

View File

@ -22,30 +22,30 @@ public partial class Prop5003Area : Area2D
public void PlayEffect(int startRadius, int endRadius, float time)
{
var _tween = CreateTween();
_tween.SetParallel();
_tween.TweenCallback(Callable.From(() =>
var tween = CreateTween();
tween.SetParallel();
tween.TweenCallback(Callable.From(() =>
{
SetEnable(true);
Modulate = Colors.White;
}));
_tween.Chain();
tween.Chain();
_tween.TweenMethod(Callable.From<int>(SetRadius), startRadius, endRadius * 0.75f, time * 0.2f);
_tween.Chain();
tween.TweenMethod(Callable.From<int>(SetRadius), startRadius, endRadius * 0.75f, time * 0.2f);
tween.Chain();
_tween.TweenInterval(time * 0.55f);
_tween.Chain();
tween.TweenInterval(time * 0.55f);
tween.Chain();
_tween.TweenMethod(Callable.From<int>(SetRadius), endRadius * 0.75f, endRadius, time * 0.25f);
_tween.TweenProperty(this, "modulate", new Color(1, 1, 1, 0), time * 0.25f);
_tween.Chain();
tween.TweenMethod(Callable.From<int>(SetRadius), endRadius * 0.75f, endRadius, time * 0.25f);
tween.TweenProperty(this, "modulate", new Color(1, 1, 1, 0), time * 0.25f);
tween.Chain();
_tween.TweenCallback(Callable.From(() =>
tween.TweenCallback(Callable.From(() =>
{
SetEnable(false);
}));
_tween.Play();
tween.Play();
}
private void SetRadius(int radius)