增加传送门逻辑

增加无敌时间
This commit is contained in:
2026-07-05 22:50:58 +08:00
parent b7aac301ba
commit c06a8abad0
7 changed files with 322 additions and 697 deletions
+37 -2
View File
@@ -19,6 +19,10 @@ namespace IndianOceanAssets.Engine2_5D
[Tooltip("玩家预制体")]
[SerializeField] GameObject playerPrefab;
[Header("传送门")]
[Tooltip("传送门/出口预制体(DoorPortal")]
[SerializeField] GameObject doorPrefab;
[Header("敌人配置")]
[Tooltip("敌人预制体数组(enemy_01 ~ enemy_05")]
[SerializeField] GameObject[] enemyPrefabs;
@@ -93,7 +97,38 @@ namespace IndianOceanAssets.Engine2_5D
}
}
// 2. 生成敌人
// 2. 生成传送门(选择离玩家最远的出生点)
if (doorPrefab != null && usedIndex < _allSpawnPoints.Count)
{
Vector3 playerPos = _spawnedPlayer != null ? _spawnedPlayer.transform.position : _allSpawnPoints[0].position;
Transform doorSpawn = null;
float maxDist = -1f;
for (int i = usedIndex; i < _allSpawnPoints.Count; i++)
{
float dist = Vector3.Distance(_allSpawnPoints[i].position, playerPos);
if (dist > maxDist)
{
maxDist = dist;
doorSpawn = _allSpawnPoints[i];
}
}
if (doorSpawn == null)
doorSpawn = _allSpawnPoints[usedIndex];
int doorIdx = _allSpawnPoints.IndexOf(doorSpawn);
if (doorIdx != usedIndex)
{
var temp = _allSpawnPoints[usedIndex];
_allSpawnPoints[usedIndex] = _allSpawnPoints[doorIdx];
_allSpawnPoints[doorIdx] = temp;
}
usedIndex++;
Instantiate(doorPrefab, doorSpawn.position, doorSpawn.rotation);
Debug.Log($"[GameSpawnManager] 传送门出生在 #{GetSpawnPointIndex(doorSpawn)} 位置=({doorSpawn.position.x:F1}, {doorSpawn.position.y:F1}, {doorSpawn.position.z:F1}) 距玩家={maxDist:F1}");
}
// 3. 生成敌人
if (enemyPrefabs != null && enemyCounts != null)
{
int prefabCount = Mathf.Min(enemyPrefabs.Length, enemyCounts.Length);
@@ -121,7 +156,7 @@ namespace IndianOceanAssets.Engine2_5D
}
}
Debug.Log($"[GameSpawnManager] 生成完毕:1 个玩家 + {_spawnedEnemies.Count} 个敌人");
Debug.Log($"[GameSpawnManager] 生成完毕:1 个玩家 + {(doorPrefab != null ? "1 + " : "")}{_spawnedEnemies.Count} 个敌人");
}
/// <summary>