private void FixedUpdate() { if (useState == MagicalWeaponUseState.Default) { currentCD = Mathf.Max(currentCD - Time.fixedDeltaTime, 0f); if (currentCD == 0f) { canUse = true; } } else if (useState == MagicalWeaponUseState.Charging) { currentChargeTime = Mathf.Min(currentChargeTime + Time.fixedDeltaTime, maxChargeTime); float scaleFactor = currentChargeTime / maxChargeTime; scaleFactor *= sizeChargeScale; scaleFactor += 1f; transform.localScale = baseScale * scaleFactor; } else if (useState == MagicalWeaponUseState.Launching) { LaunchProjectile(); currentChargeTime = 0f; transform.localScale = baseScale; useState = MagicalWeaponUseState.Default; canUse = false; currentCD = cooldown; } }
public void Primary() { if (!canUse) { return; } if (useState == MagicalWeaponUseState.Default) { if (OnPrimary != null) { OnPrimary(this, new EventArgs()); } if (MaxChargeTime > 0f) { useState = MagicalWeaponUseState.Charging; loopSource = AudioManager.PlaySfx(loopChargeClip, transform, 1.0f, true); } else { if (OnEndPrimary != null) { OnEndPrimary(this, new EventArgs()); } useState = MagicalWeaponUseState.Launching; } baseScale = transform.localScale; } }
public void EndPrimary() { if (!canUse) { return; } if (useState == MagicalWeaponUseState.Charging) { if (OnPrimary != null) { OnEndPrimary(this, new EventArgs()); } useState = MagicalWeaponUseState.Launching; if (loopSource != null) { Destroy(loopSource.gameObject); } } }