EnemyPortal이 작동하지 않는 문제 수정
Network 환경 대응
This commit is contained in:
@@ -154,3 +154,8 @@ MonoBehaviour:
|
|||||||
SourcePrefabToOverride: {fileID: 0}
|
SourcePrefabToOverride: {fileID: 0}
|
||||||
SourceHashToOverride: 0
|
SourceHashToOverride: 0
|
||||||
OverridingTargetPrefab: {fileID: 0}
|
OverridingTargetPrefab: {fileID: 0}
|
||||||
|
- Override: 0
|
||||||
|
Prefab: {fileID: 3432047510330746227, guid: 11e3760dda2c0164abf759c18d918893, type: 3}
|
||||||
|
SourcePrefabToOverride: {fileID: 0}
|
||||||
|
SourceHashToOverride: 0
|
||||||
|
OverridingTargetPrefab: {fileID: 0}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 228462577495887354}
|
- component: {fileID: 228462577495887354}
|
||||||
|
- component: {fileID: 8411098988276399395}
|
||||||
- component: {fileID: 6859825394817103090}
|
- component: {fileID: 6859825394817103090}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: EnemyPortal
|
m_Name: EnemyPortal
|
||||||
@@ -33,6 +34,31 @@ Transform:
|
|||||||
- {fileID: 1144932316349886388}
|
- {fileID: 1144932316349886388}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &8411098988276399395
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3432047510330746227}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkObject
|
||||||
|
GlobalObjectIdHash: 2651171896
|
||||||
|
InScenePlacedSourceGlobalObjectIdHash: 0
|
||||||
|
DeferredDespawnTick: 0
|
||||||
|
Ownership: 1
|
||||||
|
AlwaysReplicateAsRoot: 0
|
||||||
|
SynchronizeTransform: 1
|
||||||
|
ActiveSceneSynchronization: 0
|
||||||
|
SceneMigrationSynchronization: 1
|
||||||
|
SpawnWithObservers: 1
|
||||||
|
DontDestroyWithOwner: 0
|
||||||
|
AutoObjectParentSync: 1
|
||||||
|
SyncOwnerTransformWhenParented: 1
|
||||||
|
AllowOwnerToParent: 0
|
||||||
--- !u!114 &6859825394817103090
|
--- !u!114 &6859825394817103090
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -45,8 +71,10 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: cb91abd3aae74d941a739a48aefb74a1, type: 3}
|
m_Script: {fileID: 11500000, guid: cb91abd3aae74d941a739a48aefb74a1, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::EnemyPortal
|
m_EditorClassIdentifier: Assembly-CSharp::EnemyPortal
|
||||||
Enemies:
|
ShowTopMostFoldoutHeaderGroup: 1
|
||||||
- {fileID: 5176576196123937037, guid: 951b69041a2ace947afd721fefb3eaba, type: 3}
|
monsterEntries: []
|
||||||
|
initialCost: 4
|
||||||
|
costIncreaseRate: 10
|
||||||
--- !u!1001 &606055883085645919
|
--- !u!1001 &606055883085645919
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -1762,6 +1762,18 @@ PrefabInstance:
|
|||||||
propertyPath: monsterEntries.Array.data[1].monsterData
|
propertyPath: monsterEntries.Array.data[1].monsterData
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8411098988276399395, guid: 11e3760dda2c0164abf759c18d918893, type: 3}
|
||||||
|
propertyPath: GlobalObjectIdHash
|
||||||
|
value: 3475466684
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8411098988276399395, guid: 11e3760dda2c0164abf759c18d918893, type: 3}
|
||||||
|
propertyPath: SceneMigrationSynchronization
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8411098988276399395, guid: 11e3760dda2c0164abf759c18d918893, type: 3}
|
||||||
|
propertyPath: InScenePlacedSourceGlobalObjectIdHash
|
||||||
|
value: 2651171896
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
@@ -2231,7 +2243,7 @@ MonoBehaviour:
|
|||||||
cycleLength: 90
|
cycleLength: 90
|
||||||
autoStart: 1
|
autoStart: 1
|
||||||
pauseOnZero: 0
|
pauseOnZero: 0
|
||||||
exceptionalFirstCycleLength: 0
|
exceptionalFirstCycleLength: 10
|
||||||
showDebugLogs: 1
|
showDebugLogs: 1
|
||||||
--- !u!4 &1442785555
|
--- !u!4 &1442785555
|
||||||
Transform:
|
Transform:
|
||||||
@@ -2989,6 +3001,18 @@ PrefabInstance:
|
|||||||
propertyPath: monsterEntries.Array.data[1].monsterData
|
propertyPath: monsterEntries.Array.data[1].monsterData
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8411098988276399395, guid: 11e3760dda2c0164abf759c18d918893, type: 3}
|
||||||
|
propertyPath: GlobalObjectIdHash
|
||||||
|
value: 4252027324
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8411098988276399395, guid: 11e3760dda2c0164abf759c18d918893, type: 3}
|
||||||
|
propertyPath: SceneMigrationSynchronization
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8411098988276399395, guid: 11e3760dda2c0164abf759c18d918893, type: 3}
|
||||||
|
propertyPath: InScenePlacedSourceGlobalObjectIdHash
|
||||||
|
value: 2651171896
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
|
|||||||
@@ -4,42 +4,53 @@ using System.Collections.Generic;
|
|||||||
using Unity.Netcode;
|
using Unity.Netcode;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class EnemyPortal : NetworkBehaviour
|
public class EnemyPortal : NetworkBehaviour
|
||||||
{
|
|
||||||
[System.Serializable]
|
|
||||||
public class MonsterEntry
|
|
||||||
{
|
{
|
||||||
public GameObject prefab;
|
[System.Serializable]
|
||||||
}
|
public class MonsterEntry
|
||||||
|
{
|
||||||
|
public GameObject prefab;
|
||||||
|
}
|
||||||
|
|
||||||
[Header("Spawn Settings")]
|
[Header("Spawn Settings")]
|
||||||
[Tooltip("몬스터 프리팹 목록 (Editor에서 자동 로드 가능)")]
|
[Tooltip("몬스터 프리팹 목록 (Editor에서 자동 로드 가능)")]
|
||||||
[SerializeField] private List<MonsterEntry> monsterEntries = new();
|
[SerializeField] private List<MonsterEntry> monsterEntries = new();
|
||||||
|
|
||||||
[Header("Cost Settings")]
|
[Header("Cost Settings")]
|
||||||
[Tooltip("시간당 코스트 시작 값")]
|
[Tooltip("시간당 코스트 시작 값")]
|
||||||
[SerializeField] private float initialCost = 4f;
|
[SerializeField] private float initialCost = 4f;
|
||||||
[Tooltip("사이클마다 코스트 증가율 (%)")]
|
[Tooltip("사이클마다 코스트 증가율 (%)")]
|
||||||
[SerializeField] private float costIncreaseRate = 10f;
|
[SerializeField] private float costIncreaseRate = 10f;
|
||||||
|
|
||||||
private float currentCost;
|
private float currentCost;
|
||||||
|
|
||||||
void Start()
|
public override void OnNetworkSpawn()
|
||||||
{
|
{
|
||||||
currentCost = initialCost;
|
base.OnNetworkSpawn();
|
||||||
GlobalTimer.Instance.OnCycleStart += OnCycleStart;
|
GlobalTimer.Instance.OnCycleStart += OnCycleStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCycleStart(int cycleNumber)
|
public override void OnNetworkDespawn()
|
||||||
{
|
{
|
||||||
SpawnMonsters();
|
GlobalTimer.Instance.OnCycleStart -= OnCycleStart;
|
||||||
IncreaseCost();
|
base.OnNetworkDespawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpawnMonsters()
|
void Start()
|
||||||
{
|
{
|
||||||
float remainingCost = currentCost;
|
currentCost = initialCost;
|
||||||
int spawnedCount = 0;
|
}
|
||||||
|
|
||||||
|
private void OnCycleStart(int cycleNumber)
|
||||||
|
{
|
||||||
|
SpawnMonsters();
|
||||||
|
IncreaseCost();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SpawnMonsters()
|
||||||
|
{
|
||||||
|
float remainingCost = currentCost;
|
||||||
|
int spawnedCount = 0;
|
||||||
|
|
||||||
while (remainingCost > 0 && monsterEntries.Count > 0)
|
while (remainingCost > 0 && monsterEntries.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -129,21 +140,21 @@ public class EnemyPortal : NetworkBehaviour
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpawnEnemy(GameObject prefab)
|
private void SpawnEnemy(GameObject prefab)
|
||||||
{
|
|
||||||
if (!IsServer) return;
|
|
||||||
|
|
||||||
GameObject enemy = Instantiate(prefab, transform);
|
|
||||||
|
|
||||||
if (enemy.GetComponent<FogOfWarVisibility>() == null)
|
|
||||||
{
|
{
|
||||||
var visibility = enemy.AddComponent<FogOfWarVisibility>();
|
if (!IsServer) return;
|
||||||
visibility.showInExploredAreas = false;
|
|
||||||
visibility.updateInterval = 0.2f;
|
|
||||||
}
|
|
||||||
|
|
||||||
enemy.GetComponent<NetworkObject>().SpawnWithOwnership(NetworkManager.Singleton.LocalClientId);
|
GameObject enemy = Instantiate(prefab, transform);
|
||||||
}
|
|
||||||
|
if (enemy.GetComponent<FogOfWarVisibility>() == null)
|
||||||
|
{
|
||||||
|
var visibility = enemy.AddComponent<FogOfWarVisibility>();
|
||||||
|
visibility.showInExploredAreas = false;
|
||||||
|
visibility.updateInterval = 0.2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
enemy.GetComponent<NetworkObject>().SpawnWithOwnership(NetworkManager.Singleton.LocalClientId);
|
||||||
|
}
|
||||||
|
|
||||||
private void IncreaseCost()
|
private void IncreaseCost()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user