convert game playing..
This commit is contained in:
@@ -22,6 +22,7 @@ namespace BumpCombat.Enemies
|
||||
private bool lancerTipNeedsRebase;
|
||||
private bool necrofireRayActive;
|
||||
private bool necrofireRayHitConfirmed;
|
||||
private float necrofireRayLength;
|
||||
private bool meleeAttackActive;
|
||||
private bool meleeHitConfirmed;
|
||||
private StageEnemyEffectVisual necrofireRayVisual;
|
||||
@@ -392,12 +393,16 @@ namespace BumpCombat.Enemies
|
||||
Vector2 direction = lockedDirection.sqrMagnitude > 0.0001f
|
||||
? lockedDirection
|
||||
: Vector2.right;
|
||||
float length = controller.AttackLength;
|
||||
necrofireRayLength = GetTerrainBlockedLength(
|
||||
attackOrigin,
|
||||
direction,
|
||||
controller.AttackLength,
|
||||
controller.AttackWidth * 0.5f);
|
||||
necrofireRayVisual = StageEnemyEffectVisual.PlayRay(
|
||||
gameObject,
|
||||
attackOrigin,
|
||||
direction,
|
||||
length,
|
||||
necrofireRayLength,
|
||||
controller.AttackWidth,
|
||||
controller.ActiveDuration);
|
||||
TickNecrofireRay();
|
||||
@@ -982,7 +987,13 @@ namespace BumpCombat.Enemies
|
||||
Vector2 direction = lockedDirection.sqrMagnitude > 0.0001f
|
||||
? lockedDirection
|
||||
: Vector2.right;
|
||||
float length = controller.AttackLength;
|
||||
float length = necrofireRayLength > 0f
|
||||
? necrofireRayLength
|
||||
: GetTerrainBlockedLength(
|
||||
attackOrigin,
|
||||
direction,
|
||||
controller.AttackLength,
|
||||
controller.AttackWidth * 0.5f);
|
||||
float width = Mathf.Max(0.001f, controller.AttackWidth);
|
||||
Vector2 center = attackOrigin + direction * (length * 0.5f);
|
||||
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
@@ -1018,5 +1029,44 @@ namespace BumpCombat.Enemies
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetTerrainBlockedLength(
|
||||
Vector2 origin,
|
||||
Vector2 direction,
|
||||
float maxLength,
|
||||
float radius)
|
||||
{
|
||||
float clampedLength = Mathf.Max(0f, maxLength);
|
||||
if (clampedLength <= 0f || direction.sqrMagnitude <= 0.0001f)
|
||||
{
|
||||
return clampedLength;
|
||||
}
|
||||
|
||||
RaycastHit2D[] hits = Physics2D.CircleCastAll(
|
||||
origin,
|
||||
Mathf.Max(0.01f, radius),
|
||||
direction.normalized,
|
||||
clampedLength,
|
||||
Physics2D.AllLayers);
|
||||
float blockedLength = clampedLength;
|
||||
for (int i = 0; i < hits.Length; i++)
|
||||
{
|
||||
Collider2D collider = hits[i].collider;
|
||||
if (collider == null || collider.isTrigger)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isTerrain = collider.GetComponentInParent<BumpCombat.Stage.StageObstacle>() != null
|
||||
|| collider.name.StartsWith("Wall_")
|
||||
|| collider.gameObject.name.Contains("Wall");
|
||||
if (isTerrain)
|
||||
{
|
||||
blockedLength = Mathf.Min(blockedLength, hits[i].distance);
|
||||
}
|
||||
}
|
||||
|
||||
return blockedLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user