데이터 파이프라인 플레이어 부분 개선
This commit is contained in:
@@ -61,6 +61,7 @@
|
|||||||
<Compile Include="Assets\FlatKit\Shaders\GradientSkybox\Editor\GradientSkyboxEditor.cs" />
|
<Compile Include="Assets\FlatKit\Shaders\GradientSkybox\Editor\GradientSkyboxEditor.cs" />
|
||||||
<Compile Include="Assets\Scripts\Editor\CSVToSOImporter.cs" />
|
<Compile Include="Assets\Scripts\Editor\CSVToSOImporter.cs" />
|
||||||
<Compile Include="Assets\Scripts\Editor\TowerPrefabSetup.cs" />
|
<Compile Include="Assets\Scripts\Editor\TowerPrefabSetup.cs" />
|
||||||
|
<Compile Include="Assets\Scripts\Editor\PlayerPrefabSetup.cs" />
|
||||||
<Compile Include="Assets\Scripts\Editor\TemplateCreator.cs" />
|
<Compile Include="Assets\Scripts\Editor\TemplateCreator.cs" />
|
||||||
<Compile Include="Assets\FlatKit\Shaders\Editor\Tooltips.cs" />
|
<Compile Include="Assets\FlatKit\Shaders\Editor\Tooltips.cs" />
|
||||||
<Compile Include="Assets\FlatKit\Shaders\Editor\StylizedSurfaceEditor.cs" />
|
<Compile Include="Assets\FlatKit\Shaders\Editor\StylizedSurfaceEditor.cs" />
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::NetworkPlayerController
|
m_EditorClassIdentifier: Assembly-CSharp::NetworkPlayerController
|
||||||
ShowTopMostFoldoutHeaderGroup: 1
|
ShowTopMostFoldoutHeaderGroup: 1
|
||||||
moveSpeed: 5
|
moveSpeed: 10
|
||||||
rotationSpeed: 10
|
rotationSpeed: 10
|
||||||
initialTeam: 1
|
initialTeam: 1
|
||||||
maxHealth: 100
|
maxHealth: 100
|
||||||
@@ -211,9 +211,9 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Northbound.AttackAction
|
m_EditorClassIdentifier: Assembly-CSharp::Northbound.AttackAction
|
||||||
ShowTopMostFoldoutHeaderGroup: 1
|
ShowTopMostFoldoutHeaderGroup: 1
|
||||||
attackRange: 3
|
attackRange: 6
|
||||||
attackDamage: 100
|
attackDamage: 200
|
||||||
attackCooldown: 0.5
|
attackCooldown: 1
|
||||||
attackableLayer:
|
attackableLayer:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Bits: 4294967295
|
m_Bits: 4294967295
|
||||||
@@ -260,7 +260,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Northbound.PlayerResourceInventory
|
m_EditorClassIdentifier: Assembly-CSharp::Northbound.PlayerResourceInventory
|
||||||
ShowTopMostFoldoutHeaderGroup: 1
|
ShowTopMostFoldoutHeaderGroup: 1
|
||||||
maxResourceCapacity: 50
|
maxResourceCapacity: 100
|
||||||
--- !u!114 &2148255267416253297
|
--- !u!114 &2148255267416253297
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -274,7 +274,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Northbound.PlayerVisionProvider
|
m_EditorClassIdentifier: Assembly-CSharp::Northbound.PlayerVisionProvider
|
||||||
ShowTopMostFoldoutHeaderGroup: 1
|
ShowTopMostFoldoutHeaderGroup: 1
|
||||||
visionRange: 10
|
visionRange: 20
|
||||||
--- !u!1001 &1445453803682481668
|
--- !u!1001 &1445453803682481668
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -59,7 +59,8 @@ namespace Northbound.Editor
|
|||||||
prefabSetups = new Dictionary<string, IPrefabSetup>
|
prefabSetups = new Dictionary<string, IPrefabSetup>
|
||||||
{
|
{
|
||||||
{ "Monster", new MonsterPrefabSetup() },
|
{ "Monster", new MonsterPrefabSetup() },
|
||||||
{ "Tower", new TowerPrefabSetup() }
|
{ "Tower", new TowerPrefabSetup() },
|
||||||
|
{ "Player", new PlayerPrefabSetup() }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +113,14 @@ namespace Northbound.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeName == "Player")
|
||||||
|
{
|
||||||
|
Debug.Log($"[CSVToSOImporter] {typeName}: Player prefab updated successfully");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Debug.Log($"[CSVToSOImporter] {typeName}: {successCount} prefabs created/updated");
|
Debug.Log($"[CSVToSOImporter] {typeName}: {successCount} prefabs created/updated");
|
||||||
|
}
|
||||||
|
|
||||||
// If towers were imported, auto-configure BuildingManager
|
// If towers were imported, auto-configure BuildingManager
|
||||||
// TowerData now extends BuildingData, so it can be used directly!
|
// TowerData now extends BuildingData, so it can be used directly!
|
||||||
@@ -174,6 +182,14 @@ namespace Northbound.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameObject prefabObj;
|
||||||
|
if (typeName == "Player")
|
||||||
|
{
|
||||||
|
PlayerPrefabSetup.UpdatePlayerPrefab((PlayerData)data);
|
||||||
|
prefabObj = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
string prefabPath = $"Assets/Prefabs/{typeName}/{typeName}{id}.prefab";
|
string prefabPath = $"Assets/Prefabs/{typeName}/{typeName}{id}.prefab";
|
||||||
Directory.CreateDirectory(Path.Combine(Application.dataPath, $"Prefabs/{typeName}"));
|
Directory.CreateDirectory(Path.Combine(Application.dataPath, $"Prefabs/{typeName}"));
|
||||||
|
|
||||||
@@ -182,8 +198,9 @@ namespace Northbound.Editor
|
|||||||
|
|
||||||
prefabSetup.SetupPrefab(prefabInstance, data);
|
prefabSetup.SetupPrefab(prefabInstance, data);
|
||||||
|
|
||||||
GameObject prefabObj = PrefabUtility.SaveAsPrefabAsset(prefabInstance, prefabPath);
|
prefabObj = PrefabUtility.SaveAsPrefabAsset(prefabInstance, prefabPath);
|
||||||
GameObject.DestroyImmediate(prefabInstance);
|
GameObject.DestroyImmediate(prefabInstance);
|
||||||
|
}
|
||||||
|
|
||||||
// Now set the prefab reference on data
|
// Now set the prefab reference on data
|
||||||
if (data is BuildingData buildingData)
|
if (data is BuildingData buildingData)
|
||||||
|
|||||||
92
Assets/Scripts/Editor/PlayerPrefabSetup.cs
Normal file
92
Assets/Scripts/Editor/PlayerPrefabSetup.cs
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
using Northbound.Data;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Northbound.Editor
|
||||||
|
{
|
||||||
|
public class PlayerPrefabSetup : IPrefabSetup
|
||||||
|
{
|
||||||
|
public string GetTemplateName()
|
||||||
|
{
|
||||||
|
return "Player";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdatePlayerPrefab(PlayerData playerData)
|
||||||
|
{
|
||||||
|
string prefabPath = playerData.prefabPath;
|
||||||
|
if (!prefabPath.EndsWith(".prefab"))
|
||||||
|
{
|
||||||
|
prefabPath += ".prefab";
|
||||||
|
}
|
||||||
|
|
||||||
|
GameObject prefabObj = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
|
||||||
|
if (prefabObj == null)
|
||||||
|
{
|
||||||
|
Debug.LogError($"[PlayerPrefabSetup] Player prefab not found at: {prefabPath}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetupPrefabComponents(prefabObj, playerData);
|
||||||
|
EditorUtility.SetDirty(prefabObj);
|
||||||
|
PrefabUtility.SavePrefabAsset(prefabObj);
|
||||||
|
Debug.Log($"[PlayerPrefabSetup] Player prefab updated from: {prefabPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetupPrefab(GameObject prefab, ScriptableObject data)
|
||||||
|
{
|
||||||
|
if (!(data is PlayerData playerData))
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"[PlayerPrefabSetup] Expected PlayerData, got {data.GetType().Name}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetupPrefabComponents(prefab, playerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetupPrefabComponents(GameObject prefab, PlayerData playerData)
|
||||||
|
{
|
||||||
|
var networkController = prefab.GetComponent<NetworkPlayerController>();
|
||||||
|
if (networkController != null)
|
||||||
|
{
|
||||||
|
SerializedObject so = new SerializedObject(networkController);
|
||||||
|
so.FindProperty("moveSpeed").floatValue = playerData.moveSpeed;
|
||||||
|
so.FindProperty("maxHealth").intValue = playerData.maxHp;
|
||||||
|
so.ApplyModifiedProperties();
|
||||||
|
Debug.Log($"[PlayerPrefabSetup] Updated NetworkPlayerController: moveSpeed={playerData.moveSpeed}, maxHealth={playerData.maxHp}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var attackAction = prefab.GetComponent<AttackAction>();
|
||||||
|
if (attackAction != null)
|
||||||
|
{
|
||||||
|
SerializedObject so = new SerializedObject(attackAction);
|
||||||
|
so.FindProperty("attackRange").intValue = playerData.atkRange;
|
||||||
|
so.FindProperty("attackDamage").intValue = playerData.atkDamage;
|
||||||
|
so.FindProperty("attackCooldown").floatValue = playerData.atkIntervalSec;
|
||||||
|
so.ApplyModifiedProperties();
|
||||||
|
Debug.Log($"[PlayerPrefabSetup] Updated AttackAction: attackRange={playerData.atkRange}, attackDamage={playerData.atkDamage}, attackCooldown={playerData.atkIntervalSec}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var visionProvider = prefab.GetComponent<PlayerVisionProvider>();
|
||||||
|
if (visionProvider != null)
|
||||||
|
{
|
||||||
|
SerializedObject so = new SerializedObject(visionProvider);
|
||||||
|
so.FindProperty("visionRange").floatValue = playerData.visionRadius;
|
||||||
|
so.ApplyModifiedProperties();
|
||||||
|
Debug.Log($"[PlayerPrefabSetup] Updated PlayerVisionProvider: visionRange={playerData.visionRadius}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var resourceInventory = prefab.GetComponent<PlayerResourceInventory>();
|
||||||
|
if (resourceInventory != null)
|
||||||
|
{
|
||||||
|
SerializedObject so = new SerializedObject(resourceInventory);
|
||||||
|
so.FindProperty("maxResourceCapacity").intValue = playerData.capacity;
|
||||||
|
so.ApplyModifiedProperties();
|
||||||
|
Debug.Log($"[PlayerPrefabSetup] Updated PlayerResourceInventory: maxResourceCapacity={playerData.capacity}");
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorUtility.SetDirty(prefab);
|
||||||
|
PrefabUtility.SavePrefabAsset(prefab);
|
||||||
|
Debug.Log($"[PlayerPrefabSetup] Player prefab updated successfully from {playerData.name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Editor/PlayerPrefabSetup.cs.meta
Normal file
2
Assets/Scripts/Editor/PlayerPrefabSetup.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e5d9fa32f3480914abc8b2320d315554
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
id,memo,move_speed,vision_radius,capacity,manpower,max_hp,atk_range,atk_damage,atk_interval_sec,prefab_path
|
id,memo,move_speed,vision_radius,capacity,manpower,max_hp,atk_range,atk_damage,atk_interval_sec,prefab_path
|
||||||
1,,10,20,100,10,100,6,200,1,Assets/Prefabs/Player
|
1,,10,20,100,10,100,6,200,1,Assets/Prefabs/Player/Player
|
||||||
|
|||||||
|
Reference in New Issue
Block a user