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