重构buff中
This commit is contained in:
parent
dfad25e513
commit
c4f1104f43
|
@ -1951,7 +1951,7 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置是否启用碰撞层, 该函数是设置下载状态下原碰撞层
|
||||
/// 设置是否启用碰撞层, 该函数是设置下坠状态下原碰撞层
|
||||
/// </summary>
|
||||
public void SetOriginCollisionLayerValue(uint layer, bool vale)
|
||||
{
|
||||
|
|
|
@ -6,8 +6,9 @@ using Godot;
|
|||
/// 通用被动道具实体类
|
||||
/// </summary>
|
||||
[Tool]
|
||||
public partial class BuffActivity : Prop
|
||||
public partial class BuffActivity : PropActivity
|
||||
{
|
||||
//被动属性
|
||||
private readonly List<BuffFragment> _buffFragment = new List<BuffFragment>();
|
||||
|
||||
public override void OnPickUpItem()
|
||||
|
@ -26,55 +27,69 @@ public partial class BuffActivity : Prop
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加被动属性
|
||||
/// </summary>
|
||||
public void AddBuffFragment<T>() where T : BuffFragment, new()
|
||||
{
|
||||
var fragment = AddComponent<T>();
|
||||
_buffFragment.Add(fragment);
|
||||
fragment.Init();
|
||||
if (Master != null)
|
||||
{
|
||||
fragment.OnPickUpItem();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加被动属性
|
||||
/// </summary>
|
||||
public void AddBuffFragment<T>(float arg1) where T : BuffFragment, new()
|
||||
{
|
||||
var fragment = AddComponent<T>();
|
||||
_buffFragment.Add(fragment);
|
||||
fragment.Init(arg1);
|
||||
fragment.InitParam(arg1);
|
||||
if (Master != null)
|
||||
{
|
||||
fragment.OnPickUpItem();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加被动属性
|
||||
/// </summary>
|
||||
public void AddBuffFragment<T>(float arg1, float arg2) where T : BuffFragment, new()
|
||||
{
|
||||
var fragment = AddComponent<T>();
|
||||
_buffFragment.Add(fragment);
|
||||
fragment.Init(arg1, arg2);
|
||||
fragment.InitParam(arg1, arg2);
|
||||
if (Master != null)
|
||||
{
|
||||
fragment.OnPickUpItem();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加被动属性
|
||||
/// </summary>
|
||||
public void AddBuffFragment<T>(float arg1, float arg2, float arg3) where T : BuffFragment, new()
|
||||
{
|
||||
var fragment = AddComponent<T>();
|
||||
_buffFragment.Add(fragment);
|
||||
fragment.Init(arg1, arg2, arg3);
|
||||
fragment.InitParam(arg1, arg2, arg3);
|
||||
if (Master != null)
|
||||
{
|
||||
fragment.OnPickUpItem();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加被动属性
|
||||
/// </summary>
|
||||
public void AddBuffFragment<T>(float arg1, float arg2, float arg3, float arg4) where T : BuffFragment, new()
|
||||
{
|
||||
var fragment = AddComponent<T>();
|
||||
_buffFragment.Add(fragment);
|
||||
fragment.Init(arg1, arg2, arg3, arg4);
|
||||
fragment.InitParam(arg1, arg2, arg3, arg4);
|
||||
if (Master != null)
|
||||
{
|
||||
fragment.OnPickUpItem();
|
|
@ -4,7 +4,7 @@ using Godot;
|
|||
/// <summary>
|
||||
/// 道具基类
|
||||
/// </summary>
|
||||
public abstract partial class Prop : ActivityObject
|
||||
public abstract partial class PropActivity : ActivityObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 道具所属角色
|
|
@ -5,7 +5,7 @@ using Godot;
|
|||
/// 医药箱, 使用后恢复一颗红心
|
||||
/// </summary>
|
||||
[Tool]
|
||||
public partial class ActiveProp5000 : ActiveProp
|
||||
public partial class ActiveProp5000 : ActivePropActivity
|
||||
{
|
||||
public override void OnInit()
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ using Godot;
|
|||
/// 弹药箱, 使用后补全当前武器备用弹药
|
||||
/// </summary>
|
||||
[Tool]
|
||||
public partial class ActiveProp5001 : ActiveProp
|
||||
public partial class ActiveProp5001 : ActivePropActivity
|
||||
{
|
||||
public override void OnInit()
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using Godot;
|
|||
/// <summary>
|
||||
/// 主动使用道具
|
||||
/// </summary>
|
||||
public abstract partial class ActiveProp : Prop, IPackageItem<Role>
|
||||
public abstract partial class ActivePropActivity : PropActivity, IPackageItem<Role>
|
||||
{
|
||||
public int PackageIndex { get; set; }
|
||||
|
|
@ -59,7 +59,7 @@ public abstract partial class Role : ActivityObject
|
|||
/// <summary>
|
||||
/// 携带的主动道具包裹
|
||||
/// </summary>
|
||||
public Package<ActiveProp, Role> ActivePropsPack { get; private set; }
|
||||
public Package<ActivePropActivity, Role> ActivePropsPack { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 互动碰撞区域
|
||||
|
@ -431,21 +431,21 @@ public abstract partial class Role : ActivityObject
|
|||
/// <summary>
|
||||
/// 当拾起某个主动道具时调用
|
||||
/// </summary>
|
||||
protected virtual void OnPickUpActiveProp(ActiveProp activeProp)
|
||||
protected virtual void OnPickUpActiveProp(ActivePropActivity activePropActivity)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当移除某个主动道具时调用
|
||||
/// </summary>
|
||||
protected virtual void OnRemoveActiveProp(ActiveProp activeProp)
|
||||
protected virtual void OnRemoveActiveProp(ActivePropActivity activePropActivity)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当切换到某个主动道具时调用
|
||||
/// </summary>
|
||||
protected virtual void OnExchangeActiveProp(ActiveProp activeProp)
|
||||
protected virtual void OnExchangeActiveProp(ActivePropActivity activePropActivity)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -466,7 +466,7 @@ public abstract partial class Role : ActivityObject
|
|||
public override void OnInit()
|
||||
{
|
||||
RoleState = OnCreateRoleState();
|
||||
ActivePropsPack = AddComponent<Package<ActiveProp, Role>>();
|
||||
ActivePropsPack = AddComponent<Package<ActivePropActivity, Role>>();
|
||||
ActivePropsPack.SetCapacity(RoleState.CanPickUpWeapon ? 1 : 0);
|
||||
|
||||
_startScale = Scale;
|
||||
|
@ -617,7 +617,7 @@ public abstract partial class Role : ActivityObject
|
|||
var props = ActivePropsPack.ItemSlot;
|
||||
if (props.Length > 0)
|
||||
{
|
||||
props = (ActiveProp[])props.Clone();
|
||||
props = (ActivePropActivity[])props.Clone();
|
||||
foreach (var prop in props)
|
||||
{
|
||||
if (prop != null && !prop.IsDestroyed)
|
||||
|
@ -673,15 +673,15 @@ public abstract partial class Role : ActivityObject
|
|||
/// <summary>
|
||||
/// 拾起主动道具, 返回是否成功拾起, 如果不想立刻切换到该道具, exchange 请传 false
|
||||
/// </summary>
|
||||
/// <param name="activeProp">主动道具对象</param>
|
||||
/// <param name="activePropActivity">主动道具对象</param>
|
||||
/// <param name="exchange">是否立即切换到该道具, 默认 true </param>
|
||||
public bool PickUpActiveProp(ActiveProp activeProp, bool exchange = true)
|
||||
public bool PickUpActiveProp(ActivePropActivity activePropActivity, bool exchange = true)
|
||||
{
|
||||
if (ActivePropsPack.PickupItem(activeProp, exchange) != -1)
|
||||
if (ActivePropsPack.PickupItem(activePropActivity, exchange) != -1)
|
||||
{
|
||||
//从可互动队列中移除
|
||||
InteractiveItemList.Remove(activeProp);
|
||||
OnPickUpActiveProp(activeProp);
|
||||
InteractiveItemList.Remove(activePropActivity);
|
||||
OnPickUpActiveProp(activePropActivity);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -354,14 +354,14 @@ public partial class Player : Role
|
|||
UiManager.Open_Settlement();
|
||||
}
|
||||
|
||||
protected override void OnPickUpActiveProp(ActiveProp activeProp)
|
||||
protected override void OnPickUpActiveProp(ActivePropActivity activePropActivity)
|
||||
{
|
||||
EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, activeProp);
|
||||
EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, activePropActivity);
|
||||
}
|
||||
|
||||
protected override void OnRemoveActiveProp(ActiveProp activeProp)
|
||||
protected override void OnRemoveActiveProp(ActivePropActivity activePropActivity)
|
||||
{
|
||||
EventManager.EmitEvent(EventEnum.OnPlayerRemoveProp, activeProp);
|
||||
EventManager.EmitEvent(EventEnum.OnPlayerRemoveProp, activePropActivity);
|
||||
}
|
||||
|
||||
protected override void OnPickUpBuffProp(BuffActivity buffActivity)
|
||||
|
|
21
DungeonShooting_Godot/src/game/buff/BuffAttribute.cs
Normal file
21
DungeonShooting_Godot/src/game/buff/BuffAttribute.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class BuffAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Buff属性名称
|
||||
/// </summary>
|
||||
public string BuffName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
public BuffAttribute(string buffName, string description)
|
||||
{
|
||||
BuffName = buffName;
|
||||
Description = description;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// 被动道具逻辑基类
|
||||
/// 被动属性逻辑基类
|
||||
/// </summary>
|
||||
public abstract partial class BuffFragment : Component<BuffActivity>
|
||||
{
|
||||
|
@ -20,28 +20,35 @@ public abstract partial class BuffFragment : Component<BuffActivity>
|
|||
/// 当道具被移除时调用 (在 Master 置为 null 之前调用)
|
||||
/// </summary>
|
||||
public abstract void OnRemoveItem();
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
Debug.LogError($"'{GetType().FullName}'为实现0参数初始化函数!");
|
||||
}
|
||||
|
||||
public virtual void Init(float arg1)
|
||||
|
||||
/// <summary>
|
||||
/// 初始化被动属性参数
|
||||
/// </summary>
|
||||
public virtual void InitParam(float arg1)
|
||||
{
|
||||
Debug.LogError($"'{GetType().FullName}'为实现1参数初始化函数!");
|
||||
}
|
||||
|
||||
public virtual void Init(float arg1, float arg2)
|
||||
/// <summary>
|
||||
/// 初始化被动属性参数
|
||||
/// </summary>
|
||||
public virtual void InitParam(float arg1, float arg2)
|
||||
{
|
||||
Debug.LogError($"'{GetType().FullName}'为实现2参数初始化函数!");
|
||||
}
|
||||
|
||||
public virtual void Init(float arg1, float arg2, float arg3)
|
||||
/// <summary>
|
||||
/// 初始化被动属性参数
|
||||
/// </summary>
|
||||
public virtual void InitParam(float arg1, float arg2, float arg3)
|
||||
{
|
||||
Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!");
|
||||
}
|
||||
|
||||
public virtual void Init(float arg1, float arg2, float arg3, float arg4)
|
||||
/// <summary>
|
||||
/// 初始化被动属性参数
|
||||
/// </summary>
|
||||
public virtual void InitParam(float arg1, float arg2, float arg3, float arg4)
|
||||
{
|
||||
Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!");
|
||||
}
|
||||
|
|
|
@ -1,18 +1,28 @@
|
|||
|
||||
/// <summary>
|
||||
/// 移速 buff
|
||||
/// </summary>
|
||||
[Buff("MoveSpeed", "移速 buff, 参数 1 为移动速度值")]
|
||||
public class Buff_MoveSpeed : BuffFragment
|
||||
{
|
||||
public override void Init(float arg1)
|
||||
private float _moveSpeed;
|
||||
|
||||
public override void InitParam(float arg1)
|
||||
{
|
||||
|
||||
_moveSpeed = arg1;
|
||||
}
|
||||
|
||||
public override void OnPickUpItem()
|
||||
{
|
||||
|
||||
Role.RoleState.MoveSpeed += _moveSpeed;
|
||||
Role.RoleState.Acceleration += _moveSpeed * 1.4f;
|
||||
Role.RoleState.Friction += _moveSpeed;
|
||||
}
|
||||
|
||||
public override void OnRemoveItem()
|
||||
{
|
||||
|
||||
Role.RoleState.MoveSpeed -= _moveSpeed;
|
||||
Role.RoleState.Acceleration -= _moveSpeed * 1.4f;
|
||||
Role.RoleState.Friction -= _moveSpeed;
|
||||
}
|
||||
}
|
|
@ -59,11 +59,11 @@ public enum EventEnum
|
|||
/// </summary>
|
||||
OnPlayerRemoveWeapon,
|
||||
/// <summary>
|
||||
/// 玩家拾起道具, 参数为<see cref="Prop"/>
|
||||
/// 玩家拾起道具, 参数为<see cref="PropActivity"/>
|
||||
/// </summary>
|
||||
OnPlayerPickUpProp,
|
||||
/// <summary>
|
||||
/// 玩家丢弃道具, 参数为<see cref="Prop"/>
|
||||
/// 玩家丢弃道具, 参数为<see cref="PropActivity"/>
|
||||
/// </summary>
|
||||
OnPlayerRemoveProp,
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public partial class RoomUIPanel : RoomUI
|
|||
//玩家拾起道具, 弹出提示
|
||||
private void OnPlayerPickUpProp(object propObj)
|
||||
{
|
||||
var prop = (Prop)propObj;
|
||||
var prop = (PropActivity)propObj;
|
||||
var message = $"{prop.ActivityBase.Name}\n{prop.ActivityBase.Intro}";
|
||||
BottomTipsPanel.ShowTips(prop.GetDefaultTexture(), message);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user