diff --git a/Assets/ResWork/Prefab/IngameCharacter.prefab b/Assets/ResWork/Prefab/IngameCharacter.prefab index e17d2b0..fbed05e 100644 --- a/Assets/ResWork/Prefab/IngameCharacter.prefab +++ b/Assets/ResWork/Prefab/IngameCharacter.prefab @@ -626,7 +626,6 @@ MonoBehaviour: m_EditorClassIdentifier: arrow: {fileID: 7666490936302876945} m_AngleSpeed: 5 - projectilePrefab: {fileID: 6506108141890977998, guid: 1432f0b0801152b43a2f86aa07a8fe0b, type: 3} projectileParent: {fileID: 0} --- !u!223 &5978298300487608438 Canvas: diff --git a/Assets/SampleScene.unity b/Assets/SampleScene.unity index c3a86d3..52a19fe 100644 --- a/Assets/SampleScene.unity +++ b/Assets/SampleScene.unity @@ -17336,6 +17336,198 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 901909686} m_Modifications: + - target: {fileID: 351787396953488355, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 351787396953488355, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 351787396953488355, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 351787396953488355, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 351787397989201312, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 351787397989201312, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 351787397989201312, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 351787397989201312, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1467771610490817847, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1467771610490817847, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1467771610490817847, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1467771610490817847, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2027362653857723309, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2027362653857723309, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2027362653857723309, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2027362653857723309, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2775089715950143664, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2775089715950143664, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2775089715950143664, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2775089715950143664, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3034941298722984408, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3034941298722984408, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3034941298722984408, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3034941298722984408, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3217378376239936541, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3217378376239936541, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3217378376239936541, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3217378376239936541, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3851091814487837347, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3851091814487837347, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3851091814487837347, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3851091814487837347, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377604873454816, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377604873454816, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377604873454816, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377604873454816, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605057742992, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605057742992, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605057742992, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605057742992, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605223402641, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605223402641, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605223402641, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605223402641, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605604120026, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605604120026, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605604120026, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377605604120026, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 4111377606588400904, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} propertyPath: m_Pivot.x value: 0.5 @@ -17428,6 +17620,134 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 4111377606646784701, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377606646784701, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377606646784701, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4111377606646784701, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4241219922751532992, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4241219922751532992, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4241219922751532992, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4241219922751532992, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4330008501081147663, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4330008501081147663, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4330008501081147663, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4330008501081147663, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5691718172133534467, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5691718172133534467, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5691718172133534467, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5691718172133534467, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5961969503056597898, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5961969503056597898, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5961969503056597898, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 5961969503056597898, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6093049785316884920, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6093049785316884920, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6093049785316884920, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6093049785316884920, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6715526188961711891, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6715526188961711891, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6715526188961711891, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6715526188961711891, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7053290558194657676, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7053290558194657676, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7053290558194657676, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7053290558194657676, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 7296985114498065767, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} propertyPath: m_AnchorMax.x value: 0 @@ -17436,6 +17756,54 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 8473443759915544516, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8473443759915544516, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8473443759915544516, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8473443759915544516, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8809062110974703447, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8809062110974703447, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8809062110974703447, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8809062110974703447, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 9045579651515305713, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 9045579651515305713, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 9045579651515305713, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 9045579651515305713, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] @@ -86580,6 +86948,11 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 368788154} m_CullTransparentMesh: 1 +--- !u!224 &368806902 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 5061678075927086196, guid: 7a72290f58c260649a424bb4dd1d8726, type: 3} + m_PrefabInstance: {fileID: 73956442} + m_PrefabAsset: {fileID: 0} --- !u!1 &369417069 GameObject: m_ObjectHideFlags: 0 @@ -293871,6 +294244,54 @@ MonoBehaviour: m_OnValueChanged: m_PersistentCalls: m_Calls: [] +--- !u!1 &1293320784 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1293320786} + - component: {fileID: 1293320785} + m_Layer: 0 + m_Name: Mgr + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1293320785 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1293320784} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ab49994372de82649878bfdb8faf3b90, type: 3} + m_Name: + m_EditorClassIdentifier: + go_child: {fileID: 0} + tf_parent: {fileID: 368806902} + projectilePrefab: {fileID: 5283165188844738288, guid: 1432f0b0801152b43a2f86aa07a8fe0b, type: 3} + poolSize: 10 +--- !u!4 &1293320786 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1293320784} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1293420715 GameObject: m_ObjectHideFlags: 0 @@ -494797,3 +495218,4 @@ SceneRoots: - {fileID: 519420032} - {fileID: 1571370885} - {fileID: 11995857} + - {fileID: 1293320786} diff --git a/Assets/Script/InGame/Actor/AimArrowController.cs b/Assets/Script/InGame/Actor/AimArrowController.cs index 96d9f58..3ef1a94 100644 --- a/Assets/Script/InGame/Actor/AimArrowController.cs +++ b/Assets/Script/InGame/Actor/AimArrowController.cs @@ -5,7 +5,6 @@ public class AimArrowController : MonoBehaviour { public Image arrow; public float m_AngleSpeed = 1.5f; - public GameObject projectilePrefab; public Transform projectileParent; Vector2 startPos; @@ -35,7 +34,7 @@ public class AimArrowController : MonoBehaviour arrow.enabled = false; isAiming = false; - var proj = DSUtil.Get_Clone(projectilePrefab, projectileParent); + var proj = ProjectileMgr.Ins.Get(); proj.transform.position = arrow.transform.position; proj.transform.rotation = arrow.transform.rotation; proj.Set(); diff --git a/Assets/Script/InGame/Actor/AimController.cs b/Assets/Script/InGame/Actor/AimController.cs index 0698bbc..3335c95 100644 --- a/Assets/Script/InGame/Actor/AimController.cs +++ b/Assets/Script/InGame/Actor/AimController.cs @@ -31,7 +31,6 @@ public class AimController : MonoBehaviour Vector2 endPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 shootDir = (endPos - startPos).normalized; - GetComponent().Shoot(shootDir); line.enabled = false; isAiming = false; } diff --git a/Assets/Script/InGame/Actor/Shooter.cs b/Assets/Script/InGame/Actor/Shooter.cs deleted file mode 100644 index 1451f01..0000000 --- a/Assets/Script/InGame/Actor/Shooter.cs +++ /dev/null @@ -1,19 +0,0 @@ -using UnityEngine; - -public class Shooter : MonoBehaviour -{ - public GameObject projectilePrefab; - public float shootPower = 10f; - - public void Shoot(Vector2 dir) - { - GameObject proj = Instantiate( - projectilePrefab, - transform.position, - Quaternion.identity - ); - - Rigidbody2D rb = proj.GetComponent(); - rb.linearVelocity = dir * shootPower; - } -} \ No newline at end of file diff --git a/Assets/Script/InGame/Actor/Shooter.cs.meta b/Assets/Script/InGame/Actor/Shooter.cs.meta deleted file mode 100644 index d07f2a8..0000000 --- a/Assets/Script/InGame/Actor/Shooter.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 2c841fc89245f2344962b3dd0b85a4b8 \ No newline at end of file diff --git a/Assets/Script/InGame/Projectile/Projectile.cs b/Assets/Script/InGame/Projectile/Projectile.cs index cc2e86e..2aef31d 100644 --- a/Assets/Script/InGame/Projectile/Projectile.cs +++ b/Assets/Script/InGame/Projectile/Projectile.cs @@ -10,6 +10,11 @@ public class Projectile : MonoBehaviour Vector2 prevPos; int bounceCount; + #region 투사체 매니저 + ProjectileMgr owner; + public void SetOwner(ProjectileMgr mgr) { owner = mgr; } + void Kill() { owner.Return(this); } + #endregion public void Set() { @@ -29,7 +34,7 @@ public class Projectile : MonoBehaviour { if (bounceCount <= 0) { - gameObject.SetActive(false); + Kill(); return; } diff --git a/Assets/Script/InGame/Projectile/ProjectileMgr.cs b/Assets/Script/InGame/Projectile/ProjectileMgr.cs index 9e11c23..09b72b9 100644 --- a/Assets/Script/InGame/Projectile/ProjectileMgr.cs +++ b/Assets/Script/InGame/Projectile/ProjectileMgr.cs @@ -1,4 +1,48 @@ +using System.Collections.Generic; +using UnityEngine; + public class ProjectileMgr : MonoBehaviourSingletonTemplate { + [Header("Pool Setting")] + public Transform tf_parent; + public Projectile projectilePrefab; + public int poolSize = 50; + Queue pool = new Queue(); + + protected override void Awake() + { + base.Awake(); + InitPool(); + } + + void InitPool() + { + for (int i = 0; i < poolSize; i++) + { + Projectile p = CreateExtra(); + p.gameObject.SetActive(false); + pool.Enqueue(p); + } + } + + public Projectile Get() + { + Projectile p = pool.Count > 0 ? pool.Dequeue() : CreateExtra(); + p.gameObject.SetActive(true); + return p; + } + + public void Return(Projectile p) + { + p.gameObject.SetActive(false); + pool.Enqueue(p); + } + + Projectile CreateExtra() + { + Projectile p = Instantiate(projectilePrefab, tf_parent); + p.SetOwner(this); + return p; + } } \ No newline at end of file