Refactor NPC behavior and teleportation logic; enhance tile material properties

This commit is contained in:
2025-12-13 01:16:59 +01:00
parent 53de85a269
commit 189bbb7ae7
7 changed files with 66 additions and 22 deletions

View File

@@ -19,6 +19,7 @@ namespace Infrastructure.Unity
[SerializeField] private float floorHeightDistance = 15f;
[SerializeField] private float decayTime = 0.5f;
[SerializeField] private float fallingTime = 2.0f;
[SerializeField] private float minimumDistanceBetweenTeleporters = 3f;
public float FloorHeightDistance => floorHeightDistance;
public int FloorsCount => floorsCount;
@@ -72,6 +73,24 @@ namespace Infrastructure.Unity
var posA = new Vector3(spotA.x - xOffset, yOffset + 0.6f, spotA.y - zOffset);
var posB = new Vector3(spotB.x - xOffset, yOffset + 0.6f, spotB.y - zOffset);
// check if positions are not too close
if (Vector3.Distance(posA, posB) < minimumDistanceBetweenTeleporters)
{
// find a new position for teleporter B
for (var i = 0; i < coordinates.Count; i++)
{
if (i == indexA) continue;
var newSpotB = coordinates[i];
var newPosB = new Vector3(newSpotB.x - xOffset, yOffset + 0.6f, newSpotB.y - zOffset);
if (Vector3.Distance(posA, newPosB) >= minimumDistanceBetweenTeleporters)
{
posB = newPosB;
break;
}
}
}
var telA = Instantiate(teleporterPrefab, posA, Quaternion.identity, transform);
var telB = Instantiate(teleporterPrefab, posB, Quaternion.identity, transform);