89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
using Cielonos.MainGame.Characters;
|
|
using SLSFramework.General;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame
|
|
{
|
|
public class ForceSubmodule : AttackAreaSubmoduleBase
|
|
{
|
|
public bool isCustomForce => !isRepulsion && !isSuction;
|
|
public Vector3 customForce;
|
|
|
|
public bool isRepulsion, isSuction;
|
|
public float strengthXZ;
|
|
public float strengthY;
|
|
public Vector3 finalForce;
|
|
|
|
public bool isDynamicForce;
|
|
public float dynamicStrength;
|
|
|
|
/// <summary>
|
|
/// 施加自定义力
|
|
/// </summary>
|
|
public ForceSubmodule(AttackAreaBase attackArea, float dynamicStrength) : base(attackArea)
|
|
{
|
|
this.isDynamicForce = true;
|
|
this.isRepulsion = false;
|
|
this.isSuction = false;
|
|
this.dynamicStrength = dynamicStrength;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 施加自定义力
|
|
/// </summary>
|
|
public ForceSubmodule(AttackAreaBase attackArea, Vector3 customForce) : base(attackArea)
|
|
{
|
|
this.isDynamicForce = false;
|
|
this.customForce = customForce;
|
|
this.isRepulsion = false;
|
|
this.isSuction = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 施加斥力或吸力
|
|
/// </summary>
|
|
public ForceSubmodule(AttackAreaBase attackArea, float strengthXZ, bool isRepulsion, float strengthY = 0) : base(attackArea)
|
|
{
|
|
this.isDynamicForce = false;
|
|
this.strengthXZ = strengthXZ;
|
|
this.isRepulsion = isRepulsion;
|
|
this.isSuction = !isRepulsion;
|
|
this.strengthY = strengthY;
|
|
}
|
|
|
|
public Vector3 GetFinalForce(CharacterBase target)
|
|
{
|
|
if (isRepulsion)
|
|
{
|
|
Vector3 repulsionDirection = (target.flexibleCenterPoint.position - attackArea.transform.position).Flatten().normalized;
|
|
finalForce = repulsionDirection * strengthXZ + Vector3.up * strengthY;
|
|
}
|
|
else if (isSuction)
|
|
{
|
|
Vector3 suctionDirection = (attackArea.transform.position - target.flexibleCenterPoint.position).Flatten().normalized;
|
|
finalForce = suctionDirection * strengthXZ + Vector3.up * strengthY;
|
|
}
|
|
else if(isDynamicForce)
|
|
{
|
|
Vector3 projectileDirection = owner.topParent.transform.forward;
|
|
finalForce = projectileDirection * dynamicStrength;
|
|
}
|
|
else
|
|
{
|
|
finalForce = customForce;
|
|
}
|
|
|
|
return finalForce;
|
|
}
|
|
|
|
public void ApplyForce(CharacterBase target)
|
|
{
|
|
target.additionalForceSm.AddForce(GetFinalForce(target));
|
|
|
|
/*if(strengthY != 0)
|
|
{
|
|
target.movementController.landMovementModule.gravitationalMovement = 0;
|
|
}*/
|
|
}
|
|
}
|
|
} |