Demon boss balance
This commit is contained in:
@@ -9660,7 +9660,7 @@ MonoBehaviour:
|
||||
serializedVersion: 2
|
||||
m_Bits: 1410334711
|
||||
explosionRadius: 5
|
||||
damage: 10
|
||||
damage: 15
|
||||
knockbackForce: 5
|
||||
impactVfxPrefab: {fileID: 1031498901634068, guid: 0ff49e2dd236f364ab8b6ece0a44d04a,
|
||||
type: 3}
|
||||
|
||||
@@ -88,6 +88,9 @@ namespace DemonBoss.Magic
|
||||
// timers for auto-advance
|
||||
private float _phaseScheduledEnd = 0f; // absolute Time.time when Start/End should be done
|
||||
|
||||
// Flag to prevent multiple endings
|
||||
private bool _hasEnded = false;
|
||||
|
||||
public override void DoAction(vIFSMBehaviourController fsm, vFSMComponentExecutionType execType = vFSMComponentExecutionType.OnStateUpdate)
|
||||
{
|
||||
if (execType == vFSMComponentExecutionType.OnStateEnter) OnEnter(fsm);
|
||||
@@ -99,12 +102,20 @@ namespace DemonBoss.Magic
|
||||
|
||||
private void OnEnter(vIFSMBehaviourController fsm)
|
||||
{
|
||||
// Reset all state
|
||||
_hasEnded = false;
|
||||
_phase = Phase.None;
|
||||
_shieldActive = false;
|
||||
|
||||
_npc = fsm.transform;
|
||||
_anim = _npc.GetComponent<Animator>();
|
||||
|
||||
if (_anim != null && !string.IsNullOrEmpty(animatorBlockingBool))
|
||||
_anim.SetBool(animatorBlockingBool, true);
|
||||
|
||||
// SET COOLDOWN IMMEDIATELY when shield is used
|
||||
DEC_CheckCooldown.SetCooldownStatic(fsm, "Shield", 60f);
|
||||
|
||||
SpawnShieldFX();
|
||||
|
||||
_shieldStartTime = Time.time;
|
||||
@@ -125,10 +136,15 @@ namespace DemonBoss.Magic
|
||||
if (debugLogs) Debug.Log("[SA_CastShield] No Start/Keep clips; waiting to End.");
|
||||
_phase = Phase.Keep; // logical keep (no anim)
|
||||
}
|
||||
|
||||
if (debugLogs) Debug.Log($"[SA_CastShield] Shield started - duration: {shieldDuration}s, cooldown set to 60s");
|
||||
}
|
||||
|
||||
private void OnUpdate(vIFSMBehaviourController fsm)
|
||||
{
|
||||
// Don't process if we're already done
|
||||
if (_hasEnded || _phase == Phase.Done) return;
|
||||
|
||||
// handle crossfade
|
||||
if (_fading)
|
||||
{
|
||||
@@ -149,16 +165,15 @@ namespace DemonBoss.Magic
|
||||
// When shield timer is up, begin End
|
||||
if (_shieldActive && (Time.time - _shieldStartTime) >= shieldDuration)
|
||||
{
|
||||
if (debugLogs) Debug.Log("[SA_CastShield] Shield duration expired, beginning end phase");
|
||||
BeginEnd();
|
||||
}
|
||||
}
|
||||
else if (_phase == Phase.End && Time.time >= _phaseScheduledEnd)
|
||||
{
|
||||
// End completed
|
||||
_phase = Phase.Done;
|
||||
TeardownGraph();
|
||||
CleanupShieldFX();
|
||||
_shieldActive = false;
|
||||
if (debugLogs) Debug.Log("[SA_CastShield] End phase completed, finishing shield");
|
||||
FinishShield();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,8 +182,8 @@ namespace DemonBoss.Magic
|
||||
if (_anim != null && !string.IsNullOrEmpty(animatorBlockingBool))
|
||||
_anim.SetBool(animatorBlockingBool, false);
|
||||
|
||||
// If we left early, optionally play End briefly (best-effort)
|
||||
if (playEndOnEarlyExit && _phase != Phase.End && _phase != Phase.Done && endClip != null)
|
||||
// If we left early and haven't ended yet, optionally play End briefly
|
||||
if (playEndOnEarlyExit && !_hasEnded && _phase != Phase.End && _phase != Phase.Done && endClip != null)
|
||||
{
|
||||
if (debugLogs) Debug.Log("[SA_CastShield] Early exit: playing End quickly.");
|
||||
// build graph if it was never built (e.g., no Start/Keep)
|
||||
@@ -177,14 +192,11 @@ namespace DemonBoss.Magic
|
||||
_phase = Phase.End;
|
||||
_phaseScheduledEnd = Time.time + Mathf.Min(endClip.length / SafeSpeed(), 0.25f); // quick outro
|
||||
}
|
||||
else
|
||||
{
|
||||
// otherwise normal cleanup
|
||||
TeardownGraph();
|
||||
}
|
||||
|
||||
CleanupShieldFX();
|
||||
_shieldActive = false;
|
||||
// Always cleanup when exiting
|
||||
FinishShield();
|
||||
|
||||
if (debugLogs) Debug.Log("[SA_CastShield] State exited and cleaned up");
|
||||
}
|
||||
|
||||
// ------------------ Phase Transitions ------------------
|
||||
@@ -218,14 +230,13 @@ namespace DemonBoss.Magic
|
||||
|
||||
private void BeginEnd()
|
||||
{
|
||||
// Prevent multiple end calls
|
||||
if (_hasEnded) return;
|
||||
|
||||
if (endClip == null)
|
||||
{
|
||||
// No end clip; just finish
|
||||
_phase = Phase.Done;
|
||||
TeardownGraph();
|
||||
CleanupShieldFX();
|
||||
_shieldActive = false;
|
||||
if (debugLogs) Debug.Log("[SA_CastShield] No End clip; finished.");
|
||||
FinishShield();
|
||||
return;
|
||||
}
|
||||
CrossfadeTo(endClip, out _pEnd, quick: false);
|
||||
@@ -234,6 +245,20 @@ namespace DemonBoss.Magic
|
||||
if (debugLogs) Debug.Log("[SA_CastShield] End phase.");
|
||||
}
|
||||
|
||||
private void FinishShield()
|
||||
{
|
||||
// Prevent multiple finish calls
|
||||
if (_hasEnded) return;
|
||||
_hasEnded = true;
|
||||
|
||||
_phase = Phase.Done;
|
||||
TeardownGraph();
|
||||
CleanupShieldFX();
|
||||
_shieldActive = false;
|
||||
|
||||
if (debugLogs) Debug.Log("[SA_CastShield] Shield finished and cleaned up");
|
||||
}
|
||||
|
||||
// ------------------ Graph Setup / Crossfade ------------------
|
||||
|
||||
private void BuildGraphIfNeeded()
|
||||
@@ -312,6 +337,12 @@ namespace DemonBoss.Magic
|
||||
newPlayable.SetApplyPlayableIK(false);
|
||||
newPlayable.SetSpeed(speed);
|
||||
|
||||
// Set looping if requested
|
||||
if (loop)
|
||||
{
|
||||
newPlayable.SetDuration(double.PositiveInfinity);
|
||||
}
|
||||
|
||||
// Connect to mixer
|
||||
_graph.Connect(newPlayable, 0, _mixer, targetInput);
|
||||
_mixer.SetInputWeight(targetInput, 0f);
|
||||
@@ -364,11 +395,11 @@ namespace DemonBoss.Magic
|
||||
|
||||
// ------------------ Public Query ------------------
|
||||
|
||||
public bool IsShieldActive() => _shieldActive;
|
||||
public bool IsShieldActive() => _shieldActive && !_hasEnded;
|
||||
|
||||
public float GetRemainingShieldTime()
|
||||
{
|
||||
if (!_shieldActive) return 0f;
|
||||
if (!_shieldActive || _hasEnded) return 0f;
|
||||
float t = Mathf.Max(0f, shieldDuration - (Time.time - _shieldStartTime));
|
||||
return (_phase == Phase.End || _phase == Phase.Done) ? 0f : t;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user