FututeWand初步
This commit is contained in:
@@ -13,6 +13,11 @@ namespace Cielonos.MainGame
|
||||
public float angularSpeed;
|
||||
public float angularAcceleration;
|
||||
|
||||
public float returnMoveSpeed = -1f;
|
||||
public float returnMoveAcceleration = -1f;
|
||||
public float returnAngularSpeed = -1f;
|
||||
public float returnAngularAcceleration = -1f;
|
||||
|
||||
public bool isReturning;
|
||||
public float catchRadius;
|
||||
public float autoReturnTime; // Time in seconds after which it automatically returns if not triggered manually
|
||||
@@ -112,15 +117,33 @@ namespace Cielonos.MainGame
|
||||
return this;
|
||||
}
|
||||
|
||||
public BoomerangMoveSubmodule WithReturnParameters(float speed, float acceleration, float angularSpeed, float angularAcceleration)
|
||||
{
|
||||
this.returnMoveSpeed = speed;
|
||||
this.returnMoveAcceleration = acceleration;
|
||||
this.returnAngularSpeed = angularSpeed;
|
||||
this.returnAngularAcceleration = angularAcceleration;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void TriggerReturn(float moveSpeed = -1f, float moveAcceleration = -1f, float angularSpeed = -1f, float angularAcceleration = -1f)
|
||||
{
|
||||
if (isReturning || !canMove) return;
|
||||
isReturning = true;
|
||||
target = owner.creator; // Start tracing the player/creator
|
||||
if (moveSpeed >= 0f) this.moveSpeed = moveSpeed;
|
||||
if (moveAcceleration >= 0f) this.moveAcceleration = moveAcceleration;
|
||||
if (angularSpeed >= 0f) this.angularSpeed = angularSpeed;
|
||||
if (angularAcceleration >= 0f) this.angularAcceleration = angularAcceleration;
|
||||
|
||||
float targetSpeed = moveSpeed >= 0f ? moveSpeed : returnMoveSpeed;
|
||||
if (targetSpeed >= 0f) this.moveSpeed = targetSpeed;
|
||||
|
||||
float targetAcceleration = moveAcceleration >= 0f ? moveAcceleration : returnMoveAcceleration;
|
||||
if (targetAcceleration >= 0f) this.moveAcceleration = targetAcceleration;
|
||||
|
||||
float targetAngularSpeed = angularSpeed >= 0f ? angularSpeed : returnAngularSpeed;
|
||||
if (targetAngularSpeed >= 0f) this.angularSpeed = targetAngularSpeed;
|
||||
|
||||
float targetAngularAcceleration = angularAcceleration >= 0f ? angularAcceleration : returnAngularAcceleration;
|
||||
if (targetAngularAcceleration >= 0f) this.angularAcceleration = targetAngularAcceleration;
|
||||
|
||||
autoConnect = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace Cielonos.MainGame
|
||||
private bool hasInvokedEnableAction;
|
||||
public Action enableAction;
|
||||
public Action timeOutAction;
|
||||
public List<ScheduledAction> scheduledActions;
|
||||
private List<ScheduledAction> toBeExecutedScheduledActions = new List<ScheduledAction>();
|
||||
|
||||
/// <summary>
|
||||
/// enable 阶段开始前允许反应的提前量(秒),默认 0 表示无提前 grace window。
|
||||
@@ -30,7 +28,6 @@ namespace Cielonos.MainGame
|
||||
this.lifeTime = lifeTime;
|
||||
this.remainingLifeTime = lifeTime;
|
||||
this.enablingTimer = 0;
|
||||
this.scheduledActions = new List<ScheduledAction>();
|
||||
|
||||
if (attackArea is NormalArea)
|
||||
{
|
||||
@@ -67,7 +64,6 @@ namespace Cielonos.MainGame
|
||||
this.lifeTime = lifeTime;
|
||||
this.delayTime = delayTime;
|
||||
this.attackArea.isEnabling = delayTime <= 0;
|
||||
this.scheduledActions = new List<ScheduledAction>();
|
||||
|
||||
this.timeOutAction = timeOutAction ?? (() =>
|
||||
{
|
||||
@@ -93,11 +89,7 @@ namespace Cielonos.MainGame
|
||||
this.reactionGraceBefore = graceBefore;
|
||||
}
|
||||
|
||||
public TimeSubmodule AddScheduleAction(Action action, float delay)
|
||||
{
|
||||
scheduledActions.Add(new ScheduledAction(action, delay));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断当前时刻是否处于反应窗口内(包含 grace 区间和 enable 阶段本身)。
|
||||
@@ -148,21 +140,7 @@ namespace Cielonos.MainGame
|
||||
enableAction?.Invoke();
|
||||
hasInvokedEnableAction = true;
|
||||
}
|
||||
|
||||
toBeExecutedScheduledActions.Clear();
|
||||
foreach (var scheduledAction in scheduledActions)
|
||||
{
|
||||
scheduledAction.delay -= attackArea.creator.selfTimeSm.DeltaTime;
|
||||
if (scheduledAction.delay <= 0)
|
||||
{
|
||||
toBeExecutedScheduledActions.Add(scheduledAction);
|
||||
}
|
||||
}
|
||||
foreach (var scheduledAction in toBeExecutedScheduledActions)
|
||||
{
|
||||
scheduledAction.action.Invoke();
|
||||
scheduledActions.Remove(scheduledAction);
|
||||
}
|
||||
|
||||
|
||||
if (remainingLifeTime <= 0)
|
||||
{
|
||||
@@ -187,18 +165,5 @@ namespace Cielonos.MainGame
|
||||
}
|
||||
}
|
||||
|
||||
public partial class TimeSubmodule
|
||||
{
|
||||
public class ScheduledAction
|
||||
{
|
||||
public Action action;
|
||||
public float delay;
|
||||
|
||||
public ScheduledAction(Action action, float delay)
|
||||
{
|
||||
this.action = action;
|
||||
this.delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user