阶段性完成
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7cd62be9d3532d846ae8c4befb64b172
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,190 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cielonos.MainGame.Characters;
|
||||
using Cielonos.MainGame.Inventory;
|
||||
using SLSFramework.General;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame
|
||||
{
|
||||
public abstract partial class CharacterBuffBase : BuffBase<CharacterBase>
|
||||
{
|
||||
public CharacterBase attachedCharacter;
|
||||
public CharacterBase sourceCharacter;
|
||||
public ItemBase sourceItem;
|
||||
/// <summary>
|
||||
/// 图标子模块
|
||||
/// </summary>
|
||||
public IconSubmodule iconSubmodule;
|
||||
/// <summary>
|
||||
/// 事件子模块
|
||||
/// </summary>
|
||||
public EventSubmodule eventSubmodule;
|
||||
/// <summary>
|
||||
/// 回合计数,每回合开始时计数-1。
|
||||
/// </summary>
|
||||
public CountSubmodule roundCountSubmodule;
|
||||
/// <summary>
|
||||
/// 时间模块
|
||||
/// </summary>
|
||||
public TimeSubmodule timeSubmodule;
|
||||
|
||||
public UnitedStackSubmodule unitedStackSubmodule;
|
||||
public IndependentStackSubmodule independentStackSubmodule;
|
||||
public AttributeSubmodule attributeSubmodule;
|
||||
public StatusSubmodule statusSubmodule;
|
||||
}
|
||||
|
||||
public partial class CharacterBuffBase
|
||||
{
|
||||
public sealed override bool OnBuffApply(out BuffBase<CharacterBase> existingBuff)
|
||||
{
|
||||
throw new System.NotImplementedException("请使用类型约束更强的OnBuffApply方法");
|
||||
}
|
||||
|
||||
public abstract bool OnBuffApply(out CharacterBuffBase existingBuff);
|
||||
public override void OnAfterFirstApply()
|
||||
{
|
||||
statusSubmodule?.AddStatus();
|
||||
attachedCharacter.buffSm.buffList.Exclude(this).For(buff => buff.eventSubmodule?.onOtherBuffFirstApplied.Invoke(this));
|
||||
}
|
||||
|
||||
protected float DeltaTime => attachedCharacter.selfTimeSm.DeltaTime;
|
||||
|
||||
public override void OnBuffUpdate()
|
||||
{
|
||||
timeSubmodule?.Update(DeltaTime);
|
||||
independentStackSubmodule?.Update(DeltaTime);
|
||||
}
|
||||
|
||||
public override void OnBuffRemove()
|
||||
{
|
||||
attributeSubmodule?.RefreshAllModifiedAttributes();
|
||||
statusSubmodule?.RemoveStatus();
|
||||
iconSubmodule?.Remove();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CharacterBuffBase
|
||||
{
|
||||
protected bool FindExistingSameBuff<T>(out T existingBuff) where T : CharacterBuffBase
|
||||
{
|
||||
return FindExistingSameBuff(out existingBuff, attachedCharacter.buffSm.buffList);
|
||||
}
|
||||
|
||||
public override void Apply(CharacterBase attachedCharacter)
|
||||
{
|
||||
this.Apply(attachedCharacter, null, null);
|
||||
}
|
||||
|
||||
public void Apply(CharacterBase attachedCharacter, CharacterBase sourceCharacter = null, ItemBase sourceItem = null)
|
||||
{
|
||||
this.attachedCharacter = attachedCharacter;
|
||||
this.sourceCharacter = sourceCharacter;
|
||||
this.sourceItem = sourceItem;
|
||||
|
||||
if (OnBuffApply(out CharacterBuffBase existingBuff))
|
||||
{
|
||||
this.attachedCharacter.buffSm.buffList.AddByPriority(this);
|
||||
|
||||
OnAfterFirstApply();
|
||||
|
||||
if (iconSubmodule != null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
existingBuff.iconSubmodule?.Update();
|
||||
}
|
||||
|
||||
attachedCharacter.buffSm.buffList.Exclude(this).For(buff => buff.eventSubmodule?.onOtherBuffApplied.Invoke(this));
|
||||
attributeSubmodule?.RefreshAllModifiedAttributes();
|
||||
iconSubmodule?.Update();
|
||||
}
|
||||
|
||||
public override void Remove()
|
||||
{
|
||||
OnBuffRemove();
|
||||
this.attachedCharacter.buffSm.buffList.Remove(this);
|
||||
attachedCharacter.buffSm.buffList.Exclude(this).For(buff => buff.eventSubmodule?.onOtherBuffRemoved.Invoke(this));
|
||||
}
|
||||
|
||||
public override void UntriggerRemove()
|
||||
{
|
||||
this.attachedCharacter.buffSm.buffList.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CharacterBuffBase
|
||||
{
|
||||
public abstract class CharacterBuffSubmodule : BuffSubmodule
|
||||
{
|
||||
public CharacterBase character => (buff as CharacterBuffBase)?.attachedCharacter;
|
||||
|
||||
protected CharacterBuffSubmodule(CharacterBuffBase buff) : base(buff)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Buff的角色状态调整模块
|
||||
/// </summary>
|
||||
public class StatusSubmodule : CharacterBuffSubmodule
|
||||
{
|
||||
public List<StatusType> statusList;
|
||||
|
||||
public StatusSubmodule(CharacterBuffBase buff, params StatusType[] statusTypes) : base(buff)
|
||||
{
|
||||
statusList = statusTypes.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将Buff内含的状态添加到角色身上(1层)
|
||||
/// </summary>
|
||||
public void AddStatus()
|
||||
{
|
||||
statusList.ForEach(status => character.statusSm.AddStatus(status));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将Buff内含的状态从角色身上移除(1层),注意,如果某个状态有其它的来源,这个状态的效果仍然存在。
|
||||
/// </summary>
|
||||
public void RemoveStatus()
|
||||
{
|
||||
statusList.ForEach(status => character.statusSm.RemoveStatus(status));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Buff的角色通常属性调整模块
|
||||
/// </summary>
|
||||
public class AttributeSubmodule : CharacterBuffSubmodule
|
||||
{
|
||||
public Dictionary<string, float> numericChange;
|
||||
public Dictionary<string, float> percentageChangeOfAccumulation;
|
||||
public Dictionary<string, float> percentageChangeOfMultiplication;
|
||||
|
||||
public AttributeSubmodule(CharacterBuffBase buff) : base(buff)
|
||||
{
|
||||
this.numericChange = new Dictionary<string, float>();
|
||||
this.percentageChangeOfAccumulation = new Dictionary<string, float>();
|
||||
this.percentageChangeOfMultiplication = new Dictionary<string, float>();
|
||||
}
|
||||
|
||||
public List<string> RefreshAllModifiedAttributes()
|
||||
{
|
||||
List<string> modifiedAttributes = new List<string>();
|
||||
modifiedAttributes.AddRange(numericChange.Select(kvp => kvp.Key));
|
||||
modifiedAttributes.AddRange(percentageChangeOfAccumulation.Select(kvp => kvp.Key));
|
||||
modifiedAttributes.AddRange(percentageChangeOfMultiplication.Select(kvp => kvp.Key));
|
||||
|
||||
modifiedAttributes.ForEach(attr => character.attributeSm.RefreshAttribute(attr));
|
||||
|
||||
return modifiedAttributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f9fac70e4b0fa949a34199cc5486deb
|
||||
@@ -0,0 +1,46 @@
|
||||
using Cielonos.UI;
|
||||
using SLSUtilities.FunctionalAnimation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Characters.Buffs
|
||||
{
|
||||
public class ElectronicDisturbance : CharacterBuffBase
|
||||
{
|
||||
public ElectronicDisturbance(int stackAmount)
|
||||
{
|
||||
Initialize(BuffType.Negative, BuffDispelLevel.Strong);
|
||||
this.contentSubmodule = new ContentSubmodule(this);
|
||||
this.unitedStackSubmodule = new UnitedStackSubmodule(this, stackAmount);
|
||||
this.timeSubmodule = new TimeSubmodule(this, true);
|
||||
this.timeSubmodule.AddIntervalAction(() =>
|
||||
{
|
||||
this.unitedStackSubmodule.ReduceStack(1);
|
||||
}, 1f);
|
||||
//this.independentStackSubmodule = new IndependentStackSubmodule(this, stackAmount, duration);
|
||||
}
|
||||
|
||||
public override bool OnBuffApply(out CharacterBuffBase existingBuff)
|
||||
{
|
||||
if (FindExistingSameBuff(out existingBuff))
|
||||
{
|
||||
//existingBuff.independentStackSubmodule.Merge(this.independentStackSubmodule);
|
||||
existingBuff.unitedStackSubmodule.AddStack(this.unitedStackSubmodule.stackAmount);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnBuffUpdate()
|
||||
{
|
||||
base.OnBuffUpdate();
|
||||
if (unitedStackSubmodule.stackAmount >= 100)
|
||||
{
|
||||
new GeneralIncapacitation(5f).Apply(attachedCharacter, sourceCharacter);
|
||||
Remove();
|
||||
}
|
||||
|
||||
PlayerCanvas.Instance.bossInfoUIArea[attachedCharacter]?.UpdateArmor();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec8c49cf217c61f4895906d08e37e5b9
|
||||
@@ -0,0 +1,50 @@
|
||||
using Cielonos.UI;
|
||||
using SLSUtilities.FunctionalAnimation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Characters.Buffs
|
||||
{
|
||||
public class GeneralIncapacitation : CharacterBuffBase
|
||||
{
|
||||
public GeneralIncapacitation(float duration)
|
||||
{
|
||||
Initialize(BuffType.Negative, BuffDispelLevel.Strong);
|
||||
this.contentSubmodule = new ContentSubmodule(this);
|
||||
this.statusSubmodule = new StatusSubmodule(this, StatusType.Incapacitation);
|
||||
this.independentStackSubmodule = new IndependentStackSubmodule(this, 1, duration);
|
||||
}
|
||||
|
||||
public override bool OnBuffApply(out CharacterBuffBase existingBuff)
|
||||
{
|
||||
//GeneralUtilities.InstantiateInfo(attachedEntity.flexibleCenterPoint.position, "失能", Color.white, 2);
|
||||
|
||||
if (FindExistingSameBuff(out existingBuff))
|
||||
{
|
||||
existingBuff.independentStackSubmodule.Merge(this.independentStackSubmodule);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnAfterFirstApply()
|
||||
{
|
||||
base.OnAfterFirstApply();
|
||||
attachedCharacter.animationSc.fullBodyFuncAnimSm.Stop(DisruptionType.ForcedExternal);
|
||||
attachedCharacter.animationSc.fullBodyFuncAnimSm.Play("KnockOut");
|
||||
}
|
||||
|
||||
public override void OnBuffUpdate()
|
||||
{
|
||||
base.OnBuffUpdate();
|
||||
PlayerCanvas.Instance.bossInfoUIArea[attachedCharacter]?.UpdateArmor();
|
||||
}
|
||||
|
||||
public override void OnBuffRemove()
|
||||
{
|
||||
statusSubmodule.RemoveStatus();
|
||||
attachedCharacter.animationSc.fullBodyFuncAnimSm.Play("Rise");
|
||||
//(attachedCharacter as Automata)?.behaviorTree.RestartBehavior();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bd16f7ab5fd3bf4181b5f026610f4ed
|
||||
Reference in New Issue
Block a user