convert game playing..
This commit is contained in:
@@ -27,6 +27,9 @@ namespace BumpCombat.Combat
|
||||
private float cameraShakeDuration => GameplayConstants.Current.CombatFeedback.CameraShakeDuration;
|
||||
private float cameraShakePixels => GameplayConstants.Current.CombatFeedback.CameraShakePixels;
|
||||
private float heavyCameraShakePixels => GameplayConstants.Current.CombatFeedback.HeavyCameraShakePixels;
|
||||
private float rearHitCameraPunchDuration => GameplayConstants.Current.CombatFeedback.RearHitCameraPunchDuration;
|
||||
private float rearHitCameraPunchPixels => GameplayConstants.Current.CombatFeedback.RearHitCameraPunchPixels;
|
||||
private float rearHitCameraPunchRearmDelay => GameplayConstants.Current.CombatFeedback.RearHitCameraPunchRearmDelay;
|
||||
private float heavyKnockbackThreshold => GameplayConstants.Current.CombatFeedback.HeavyKnockbackThreshold;
|
||||
[SerializeField, Min(1f)] private float assetsPixelsPerUnit = 32f;
|
||||
|
||||
@@ -96,6 +99,7 @@ namespace BumpCombat.Combat
|
||||
private float flashUntil;
|
||||
private float blinkUntil;
|
||||
private Vector3 cameraRestPosition;
|
||||
private float lastRearHitCameraPunchAt = float.NegativeInfinity;
|
||||
private Material effectMaterial;
|
||||
private Vector3 lastCycloneSamplePosition;
|
||||
private Vector2 lastDashAfterimagePosition;
|
||||
@@ -309,6 +313,7 @@ namespace BumpCombat.Combat
|
||||
private void OnEnable()
|
||||
{
|
||||
activeInstance = this;
|
||||
lastRearHitCameraPunchAt = float.NegativeInfinity;
|
||||
CombatEvents.OnValidHit += HandleValidHit;
|
||||
CombatEvents.OnStunApplied += HandleStunApplied;
|
||||
CombatEvents.OnAttackCancelled += HandleAttackCancelled;
|
||||
@@ -1354,6 +1359,19 @@ namespace BumpCombat.Combat
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.IsOrdinaryBump && result.HasBackBonus)
|
||||
{
|
||||
float now = Time.time;
|
||||
bool rearHitCameraPunchRearmed =
|
||||
now - lastRearHitCameraPunchAt >= rearHitCameraPunchRearmDelay;
|
||||
lastRearHitCameraPunchAt = now;
|
||||
|
||||
if (rearHitCameraPunchRearmed)
|
||||
{
|
||||
RequestRearHitCameraPunch(result.KnockbackDirection);
|
||||
}
|
||||
}
|
||||
|
||||
Color color;
|
||||
float strength;
|
||||
int rayCount;
|
||||
@@ -2203,6 +2221,63 @@ namespace BumpCombat.Combat
|
||||
playerVisualCoroutine = null;
|
||||
}
|
||||
|
||||
private void RequestRearHitCameraPunch(Vector2 direction)
|
||||
{
|
||||
if (worldCamera == null ||
|
||||
rearHitCameraPunchDuration <= 0f ||
|
||||
rearHitCameraPunchPixels <= 0f ||
|
||||
rearHitCameraPunchRearmDelay < 0f ||
|
||||
assetsPixelsPerUnit <= 0f ||
|
||||
direction.sqrMagnitude <= Mathf.Epsilon ||
|
||||
cameraShakeCoroutine != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cameraRestPosition = worldCamera.transform.position;
|
||||
cameraShakeCoroutine = StartCoroutine(
|
||||
RearHitCameraPunchRoutine(direction.normalized));
|
||||
}
|
||||
|
||||
private IEnumerator RearHitCameraPunchRoutine(Vector2 normalizedDirection)
|
||||
{
|
||||
float startTime = Time.unscaledTime;
|
||||
|
||||
while (Time.unscaledTime - startTime < rearHitCameraPunchDuration)
|
||||
{
|
||||
float t =
|
||||
(Time.unscaledTime - startTime) / rearHitCameraPunchDuration;
|
||||
Vector2 pixelOffset =
|
||||
normalizedDirection * (rearHitCameraPunchPixels * (1f - t));
|
||||
Vector2 offset = new Vector2(
|
||||
Mathf.Round(pixelOffset.x) / assetsPixelsPerUnit,
|
||||
Mathf.Round(pixelOffset.y) / assetsPixelsPerUnit);
|
||||
|
||||
if (cameraFollow != null)
|
||||
{
|
||||
cameraFollow.SetExternalShakeOffset(offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldCamera.transform.position =
|
||||
cameraRestPosition + new Vector3(offset.x, offset.y, 0f);
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
if (cameraFollow != null)
|
||||
{
|
||||
cameraFollow.SetExternalShakeOffset(Vector2.zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldCamera.transform.position = cameraRestPosition;
|
||||
}
|
||||
|
||||
cameraShakeCoroutine = null;
|
||||
}
|
||||
|
||||
private void RequestCameraShake(float pixels)
|
||||
{
|
||||
if (worldCamera == null || pixels <= 0f || cameraShakeDuration <= 0f)
|
||||
|
||||
Reference in New Issue
Block a user