From c2eaa8cbfc042ec3e2a02aa30620711ae598bd89 Mon Sep 17 00:00:00 2001 From: Koha9 Date: Thu, 16 Nov 2023 01:03:54 +0900 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=BD=BF=E7=94=A8StartSceneD?= =?UTF-8?q?ata=E6=9D=A5=E8=B7=A8Scene=E4=BC=A0=E8=BE=93=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E7=94=A8CommonParameterContainer=20Singleton?= =?UTF-8?q?=E6=9D=A5=E7=BB=9F=E4=B8=80=E4=BF=9D=E5=AD=98=E6=89=80=E9=9C=80?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ML-Agents/Timers/Play_timers.json | 2 +- .../ML-Agents/Timers/StartScene_timers.json | 2 +- Assets/ML-Agents/Timers/Train_timers.json | 2 +- Assets/Scenes/StartScene.unity | 141 +++++++++++------- Assets/Scenes/Train.unity | 10 +- .../GameScript/CommonParameterContainer.cs | 43 +----- .../Script/GameScript/ParameterContainer.cs | 22 +-- Assets/Script/GameScript/TargetController.cs | 7 +- Assets/Script/Singleton.cs | 12 +- ...artSeneData.cs => StartSeneData-remove.cs} | 2 +- ...a.cs.meta => StartSeneData-remove.cs.meta} | 0 Assets/Script/UI/LevelProbabilityPanel.cs | 19 +-- Assets/Script/UI/StartMenuProbabilityPanel.cs | 2 +- Assets/Script/UI/StartUIManager.cs | 29 ++-- UserSettings/Layouts/default-2021.dwlt | 96 ++++++------ 15 files changed, 179 insertions(+), 210 deletions(-) rename Assets/Script/Start/{StartSeneData.cs => StartSeneData-remove.cs} (94%) rename Assets/Script/Start/{StartSeneData.cs.meta => StartSeneData-remove.cs.meta} (100%) diff --git a/Assets/ML-Agents/Timers/Play_timers.json b/Assets/ML-Agents/Timers/Play_timers.json index eb3252f..090796a 100644 --- a/Assets/ML-Agents/Timers/Play_timers.json +++ b/Assets/ML-Agents/Timers/Play_timers.json @@ -1 +1 @@ -{"count":1,"self":756.2826752,"total":764.8523027,"children":{"InitializeActuators":{"count":2,"self":0.0009995,"total":0.0009995,"children":null},"InitializeSensors":{"count":2,"self":0.0009996,"total":0.0009996,"children":null},"AgentSendState":{"count":37100,"self":0.21125339999999998,"total":1.2830407,"children":{"CollectObservations":{"count":37100,"self":0.9267048,"total":0.9267048,"children":null},"WriteActionMask":{"count":37100,"self":0.0387572,"total":0.0387572,"children":null},"RequestDecision":{"count":37100,"self":0.1063253,"total":0.1063253,"children":null}}},"DecideAction":{"count":37100,"self":0.20722459999999998,"total":0.20722459999999998,"children":null},"AgentAct":{"count":37100,"self":7.0768464,"total":7.076846,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1698982970","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-UCUNI -hubSessionId d5984e41-9eb5-419b-b909-c7102a7a038f -accessToken RDU4dwbHFHagpTZ1DzxqC9PfukLNfl08b_FimOGj3eo00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Play","end_time_seconds":"1698983735"}} \ No newline at end of file +{"count":1,"self":113.55664639999999,"total":114.9330107,"children":{"InitializeActuators":{"count":2,"self":0.00099969999999999985,"total":0.00099969999999999985,"children":null},"InitializeSensors":{"count":2,"self":0.0015095999999999998,"total":0.0015095999999999998,"children":null},"AgentSendState":{"count":5526,"self":0.0352491,"total":0.2273044,"children":{"CollectObservations":{"count":5526,"self":0.1629312,"total":0.1629312,"children":null},"WriteActionMask":{"count":5526,"self":0.0095122,"total":0.0095122,"children":null},"RequestDecision":{"count":5526,"self":0.019611899999999998,"total":0.019611899999999998,"children":null}}},"DecideAction":{"count":5526,"self":0.0385606,"total":0.0385606,"children":null},"AgentAct":{"count":5526,"self":1.1079914,"total":1.1079914,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1700043195","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-Koha9 -hubSessionId 54250353-7623-46bc-bba3-639785619018 -accessToken dmg7obCqK6FT1OSbiLk7TkfQFUczEL1FqgnKIHh02iQ00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Play","end_time_seconds":"1700043310"}} \ No newline at end of file diff --git a/Assets/ML-Agents/Timers/StartScene_timers.json b/Assets/ML-Agents/Timers/StartScene_timers.json index 9f81242..00bdcb0 100644 --- a/Assets/ML-Agents/Timers/StartScene_timers.json +++ b/Assets/ML-Agents/Timers/StartScene_timers.json @@ -1 +1 @@ -{"count":1,"self":65.1525952,"total":65.6026151,"children":{"InitializeActuators":{"count":2,"self":0.0015,"total":0.0015,"children":null},"InitializeSensors":{"count":2,"self":0.0005001,"total":0.0005001,"children":null},"AgentSendState":{"count":1994,"self":0.0115036,"total":0.073176999999999992,"children":{"CollectObservations":{"count":1994,"self":0.0546691,"total":0.0546691,"children":null},"WriteActionMask":{"count":1994,"self":0.0005,"total":0.0005,"children":null},"RequestDecision":{"count":1994,"self":0.0065042999999999993,"total":0.0065042999999999993,"children":null}}},"DecideAction":{"count":1994,"self":0.0091503,"total":0.0091503,"children":null},"AgentAct":{"count":1994,"self":0.36569229999999997,"total":0.36569229999999997,"children":null}},"gauges":{"AKMAgent.CumulativeReward":{"count":1,"max":-2512.52466,"min":-2512.52466,"runningAverage":-2512.52466,"value":-2512.52466,"weightedAverage":-2512.52466}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1697992942","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-3RTM9hQ6yJRZGQKZx8Slg -hubSessionId a9694f1b-42f4-414c-9f3a-decdfec467f4 -accessToken _-EoIL8F11LvGF_SbanmzPmRWk7d3mJZ66R4Zf61pY400ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"StartScene","end_time_seconds":"1697993008"}} \ No newline at end of file +{"count":1,"self":127.34176,"total":127.45347029999999,"children":{"InitializeActuators":{"count":2,"self":0.0015118999999999998,"total":0.0015118999999999998,"children":null},"InitializeSensors":{"count":2,"self":0.0014979,"total":0.0014979,"children":null},"AgentSendState":{"count":440,"self":0.0025188999999999997,"total":0.0211316,"children":{"CollectObservations":{"count":440,"self":0.0146118,"total":0.0146118,"children":null},"WriteActionMask":{"count":440,"self":0.0019995,"total":0.0019995,"children":null},"RequestDecision":{"count":440,"self":0.0020014,"total":0.0020014,"children":null}}},"DecideAction":{"count":440,"self":0.0020119,"total":0.0020119,"children":null},"AgentAct":{"count":440,"self":0.08556,"total":0.08556,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1700063905","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-FDy4mXKexQ6X1xL3HWyzB -hubSessionId 8d021f9c-c18a-42ae-b0f7-4f4093f87cc2 -accessToken K_UtjVRjVp9Nhbf1MZoN5JxRN3F_Qnk7hi8pO7re9pw00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"StartScene","end_time_seconds":"1700064032"}} \ No newline at end of file diff --git a/Assets/ML-Agents/Timers/Train_timers.json b/Assets/ML-Agents/Timers/Train_timers.json index 56f9853..cbfad6f 100644 --- a/Assets/ML-Agents/Timers/Train_timers.json +++ b/Assets/ML-Agents/Timers/Train_timers.json @@ -1 +1 @@ -{"count":1,"self":18.910166399999998,"total":19.0959014,"children":{"InitializeActuators":{"count":2,"self":0.0015099999999999998,"total":0.0015099999999999998,"children":null},"InitializeSensors":{"count":2,"self":0.0010000999999999999,"total":0.0010000999999999999,"children":null},"AgentSendState":{"count":730,"self":0.0039997999999999995,"total":0.0365276,"children":{"CollectObservations":{"count":730,"self":0.0295184,"total":0.0295184,"children":null},"WriteActionMask":{"count":730,"self":0.0005009,"total":0.0005009,"children":null},"RequestDecision":{"count":730,"self":0.0025085,"total":0.0025085,"children":null}}},"DecideAction":{"count":730,"self":0.0045105,"total":0.0045105,"children":null},"AgentAct":{"count":730,"self":0.1421873,"total":0.1421873,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1699169896","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-J7rVe1b8G4wb35aRr9Xtk -hubSessionId f93adee2-a02d-4be6-8e5a-ff3415a80af3 -accessToken EpvziLiMwlBOKFobSXCiZAOF1Shp6ZnBy7-u-y4-4og00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1699169915"}} \ No newline at end of file +{"count":1,"self":15.929832,"total":16.087497199999998,"children":{"InitializeActuators":{"count":2,"self":0.0015029,"total":0.0015029,"children":null},"InitializeSensors":{"count":2,"self":0.0004984,"total":0.0004984,"children":null},"AgentSendState":{"count":588,"self":0.0030039,"total":0.0190315,"children":{"CollectObservations":{"count":588,"self":0.0135233,"total":0.0135233,"children":null},"WriteActionMask":{"count":588,"self":0.0005006,"total":0.0005006,"children":null},"RequestDecision":{"count":588,"self":0.0020036999999999998,"total":0.0020036999999999998,"children":null}}},"DecideAction":{"count":588,"self":0.0075122999999999995,"total":0.0075122999999999995,"children":null},"AgentAct":{"count":588,"self":0.1281163,"total":0.1281163,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1700064038","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-FDy4mXKexQ6X1xL3HWyzB -hubSessionId 8d021f9c-c18a-42ae-b0f7-4f4093f87cc2 -accessToken K_UtjVRjVp9Nhbf1MZoN5JxRN3F_Qnk7hi8pO7re9pw00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1700064054"}} \ No newline at end of file diff --git a/Assets/Scenes/StartScene.unity b/Assets/Scenes/StartScene.unity index 3539b63..3356132 100644 --- a/Assets/Scenes/StartScene.unity +++ b/Assets/Scenes/StartScene.unity @@ -492,7 +492,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: singleTargetLevelProbabilityPanel: {fileID: 5589415219770305710, guid: 324d8e84c24cdd04ba087763705db1d0, type: 3} - startSceneData: {fileID: 1072325866} + startSceneData: {fileID: 0} targetLevelProbabilityPanel: [] --- !u!1 &294404779 GameObject: @@ -1763,6 +1763,90 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 852513428} m_CullTransparentMesh: 1 +--- !u!1 &968918527 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 968918529} + - component: {fileID: 968918528} + m_Layer: 0 + m_Name: CommonParameterContainer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &968918528 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 968918527} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 34839c2831b759d4a8347ab655b00f36, type: 3} + m_Name: + m_EditorClassIdentifier: + lockMouse: 0 + damage: 50 + fireRate: 0.5 + timeLimit: 30 + lockCameraX: 0 + lockCameraY: 1 + spawnAgentInAllMap: 1 + spinRecordMax: 40 + spinPenaltyThreshold: 10 + facingInviewEnemyDisCOEF: 0.5 + group1Tag: Player + group2Tag: Enemy + hitTargetRewardDefault: 25 + killTargetEnemyRewardDefault: 25 + inAreaRewardDefault: 25 + freeTimeBonusPerSec: 1 + targetTimeBonusPerSec: 0.5 + areaTimeBonusPerSec: 0.2 + distanceReward: 50 + facingTargetReward: 10 + goWinRewardDefault: 999 + attackWinRewardDefault: 999 + defenceWinRewardDefault: 999 + freeWinRewardDefault: 999 + nonReward: -1 + loseReward: -999 + shootReward: -0.5 + hitNonTargetReward: -5 + killNonTargetReward: -5 + shootWithoutReadyReward: -1.15 + killBonusReward: 0 + facingReward: 5 + shootTargetAreaReward: 10 + movePenalty: 0.1 + spinPenalty: 0.08 + mousePenalty: 0.06 + scenePrefabSet: {fileID: 11400000, guid: 6ebbd27eb466c4a41bd2584c1b9c2e1f, type: 2} + attackLevelProbs: [] + gotoLevelProbs: [] + defenceLevelProbs: [] +--- !u!4 &968918529 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 968918527} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 462, y: 315.5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1064099385 GameObject: m_ObjectHideFlags: 0 @@ -2044,58 +2128,6 @@ RectTransform: m_AnchoredPosition: {x: -100, y: -7} m_SizeDelta: {x: 160, y: 30} m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &1072325866 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1072325868} - - component: {fileID: 1072325867} - m_Layer: 0 - m_Name: StartSceneDataTransfer - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1072325867 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1072325866} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 52ba7faaa6129cf418f26c5933d4ea0e, type: 3} - m_Name: - m_EditorClassIdentifier: - gameMode: 0 - scenePrefabSet: {fileID: 11400000, guid: 6ebbd27eb466c4a41bd2584c1b9c2e1f, type: 2} - attackProb: 0 - attackLevelProbs: [] - gotoProb: 0 - gotoLevelProbs: [] - defenceProb: 0 - defenceLevelProbs: [] ---- !u!4 &1072325868 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1072325866} - 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_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1144208395 GameObject: m_ObjectHideFlags: 0 @@ -2248,7 +2280,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1273196676 GameObject: @@ -2573,7 +2605,6 @@ MonoBehaviour: m_EditorClassIdentifier: waitTimeLimit: 45 sceneLoaderObj: {fileID: 1206568295} - startSceneDataObj: {fileID: 1072325866} targetLevelProbabilityPanelOBJ: {fileID: 237721381} messageTextObj: {fileID: 294404781} waitTimeTextObj: {fileID: 431112176} diff --git a/Assets/Scenes/Train.unity b/Assets/Scenes/Train.unity index 772a46b..07674a2 100644 --- a/Assets/Scenes/Train.unity +++ b/Assets/Scenes/Train.unity @@ -11176,7 +11176,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0.000030517578, y: -246.20192} + m_AnchoredPosition: {x: 0.000030517578, y: -246.20218} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 0} --- !u!114 &1442113294 @@ -12158,8 +12158,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 34839c2831b759d4a8347ab655b00f36, type: 3} m_Name: m_EditorClassIdentifier: - persistThroughScene: 0 - hudObj: {fileID: 2082200184} lockMouse: 0 damage: 50 fireRate: 0.5 @@ -12196,6 +12194,10 @@ MonoBehaviour: movePenalty: 0.1 spinPenalty: 0.08 mousePenalty: 0.06 + scenePrefabSet: {fileID: 11400000, guid: 6ebbd27eb466c4a41bd2584c1b9c2e1f, type: 2} + attackLevelProbs: [] + gotoLevelProbs: [] + defenceLevelProbs: [] --- !u!4 &1580123441 Transform: m_ObjectHideFlags: 0 @@ -16597,7 +16599,7 @@ MonoBehaviour: m_HandleRect: {fileID: 1766662801} m_Direction: 2 m_Value: 0 - m_Size: 0.9998482 + m_Size: 0.9999959 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: diff --git a/Assets/Script/GameScript/CommonParameterContainer.cs b/Assets/Script/GameScript/CommonParameterContainer.cs index 67c3c48..eeed904 100644 --- a/Assets/Script/GameScript/CommonParameterContainer.cs +++ b/Assets/Script/GameScript/CommonParameterContainer.cs @@ -4,11 +4,6 @@ public class CommonParameterContainer : Singleton { - [SerializeField] private GameObject hudObj; - - private StartSeneData startSceneData; - private MessageBoxController messageCon; - [Header("Env")] public bool lockMouse = false; public float damage = 50; // damage to enemy @@ -83,43 +78,21 @@ public class CommonParameterContainer : Singleton [Tooltip("while move mouse a little bit's penalty")] public float mousePenalty = 0.06f; - [NonSerialized] public SceneBlocksSet scenePrefabSet; + public SceneBlocksSet scenePrefabSet; [NonSerialized] public int gameMode; // 0 = trainning mode, 1 = play mode [NonSerialized] public float attackProb = 0f; - [NonSerialized] public List attackLevelProbs = new List(); + public List attackLevelProbs = new List(); [NonSerialized] public float gotoProb = 0f; - [NonSerialized] public List gotoLevelProbs = new List(); + public List gotoLevelProbs = new List(); [NonSerialized] public float defenceProb = 0f; - [NonSerialized] public List defenceLevelProbs = new List(); + public List defenceLevelProbs = new List(); private void Start() { - Instance.persistThroughScene = false; - messageCon = hudObj.GetComponent(); - try - { - // try get start scene data - startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent(); - messageCon.PushMessage( - new List { "ParameterContainer:", "StartSceneDataTransfer found!" }, - new List { "green", "white" }); - } - catch - { - // if not found, find dummy StartSeneData - startSceneData = GameObject.Find("StartSceneDataTransferDummy").GetComponent(); - messageCon.PushMessage( - new List { "ParameterContainer:", "StartSceneDataTransfer not found!Use Dummy." }, - new List { "orange" }); - } - gameMode = startSceneData.gameMode; - attackProb = startSceneData.attackProb; - attackLevelProbs = startSceneData.attackLevelProbs; - gotoProb = startSceneData.gotoProb; - gotoLevelProbs = startSceneData.gotoLevelProbs; - defenceProb = startSceneData.defenceProb; - defenceLevelProbs = startSceneData.defenceLevelProbs; - scenePrefabSet = startSceneData.scenePrefabSet; + Instance.KeepThroughSceneChange(); + scenePrefabSet.InitializeSceneBlocksSet(); + attackLevelProbs = new List(scenePrefabSet.targetLevels[0].levelSize); + gotoLevelProbs = new List(scenePrefabSet.targetLevels[1].levelSize); } } \ No newline at end of file diff --git a/Assets/Script/GameScript/ParameterContainer.cs b/Assets/Script/GameScript/ParameterContainer.cs index ac82544..f720ea4 100644 --- a/Assets/Script/GameScript/ParameterContainer.cs +++ b/Assets/Script/GameScript/ParameterContainer.cs @@ -10,10 +10,7 @@ public class ParameterContainer : MonoBehaviour private TargetController targetCon; private SceneBlockContainer blockCont; - private StartSeneData startSceneData; - private MessageBoxController messageCon; private CommonParameterContainer commonParamCont; - private float agentDistance; private int agentInArea; [Header("Dynamic Rewards")] @@ -54,7 +51,6 @@ private void Start() { targetCon = targetConObj.GetComponent(); blockCont = blockConObj.GetComponent(); - messageCon = hudObj.GetComponent(); commonParamCont = CommonParameterContainer.Instance; areaTimeBonusPerSec = commonParamCont.areaTimeBonusPerSec; @@ -65,22 +61,6 @@ private void Start() areaTimeBonus = areaTimeBonusPerSec * timeLimit; freeTimeBonus = freeTimeBonusPerSec * timeLimit; targetTimeBonus = targetTimeBonusPerSec * timeLimit; - try - { - // try get start scene data - startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent(); - messageCon.PushMessage( - new List { "ParameterContainer:", "StartSceneDataTransfer found!" }, - new List { "green", "white" }); - } - catch - { - // if not found, find dummy StartSeneData - startSceneData = GameObject.Find("StartSceneDataTransferDummy").GetComponent(); - messageCon.PushMessage( - new List { "ParameterContainer:", "StartSceneDataTransfer not found!Use Dummy." }, - new List { "orange" }); - } // Win Rewards goWinReward = commonParamCont.goWinRewardDefault; @@ -94,7 +74,7 @@ private void Update() // get target distance and in area if (targetCon.targetType is Targets.Go or Targets.Attack) { - (agentDistance, agentInArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position); + (_, agentInArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position); // attack goto or defence target if (agentInArea == 1) { diff --git a/Assets/Script/GameScript/TargetController.cs b/Assets/Script/GameScript/TargetController.cs index d9f4a9e..b379d0d 100644 --- a/Assets/Script/GameScript/TargetController.cs +++ b/Assets/Script/GameScript/TargetController.cs @@ -377,6 +377,7 @@ public int GetInAreaState() /// A random level index. public int RollRandomLevelIndex(Targets target) { + Debug.Log(target); List targetProbs; switch (target) @@ -392,9 +393,9 @@ public int RollRandomLevelIndex(Targets target) break; default: messageBoxCon.PushMessage( - new List { "[ERROR]TargetController:RandomLevel", "target type error" }, + new List { "[ERROR]TargetController:RollRandomLevelIndex", "target type error" }, new List { "#800000ff" }); - Debug.LogWarning("[ERROR]TargetController:RandomLevel:target type error"); + Debug.LogWarning("[ERROR]TargetController:RollRandomLevelIndex:target type error"); return -1; // Exit early on default case } @@ -412,7 +413,7 @@ public int RollRandomLevelIndex(Targets target) // If no level was returned, log an error and return -1 messageBoxCon.PushMessage( - new List { "[ERROR]TargetController:RandomLevel", "level index out of range" }, + new List { "[ERROR]TargetController:RollRandomLevelIndex", "level index out of range" }, new List { "orange" }); return -1; } diff --git a/Assets/Script/Singleton.cs b/Assets/Script/Singleton.cs index 725dc2c..4e1ef9d 100644 --- a/Assets/Script/Singleton.cs +++ b/Assets/Script/Singleton.cs @@ -20,21 +20,21 @@ public static T Instance } } - public bool persistThroughScene = false; - protected virtual void Awake() { if (_instance == null) { _instance = this as T; - if (persistThroughScene) - { - DontDestroyOnLoad(gameObject); - } } else { Destroy(gameObject); } } + + // keep this instance through scene change + public void KeepThroughSceneChange() + { + DontDestroyOnLoad(this.gameObject); + } } \ No newline at end of file diff --git a/Assets/Script/Start/StartSeneData.cs b/Assets/Script/Start/StartSeneData-remove.cs similarity index 94% rename from Assets/Script/Start/StartSeneData.cs rename to Assets/Script/Start/StartSeneData-remove.cs index f1372b0..7ce1c34 100644 --- a/Assets/Script/Start/StartSeneData.cs +++ b/Assets/Script/Start/StartSeneData-remove.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using UnityEngine; -public class StartSeneData : MonoBehaviour +public class StartSeneDataremove : MonoBehaviour { [Header("Game mode")] public int gameMode = 0;// default trainning mode diff --git a/Assets/Script/Start/StartSeneData.cs.meta b/Assets/Script/Start/StartSeneData-remove.cs.meta similarity index 100% rename from Assets/Script/Start/StartSeneData.cs.meta rename to Assets/Script/Start/StartSeneData-remove.cs.meta diff --git a/Assets/Script/UI/LevelProbabilityPanel.cs b/Assets/Script/UI/LevelProbabilityPanel.cs index b332d45..bce791e 100644 --- a/Assets/Script/UI/LevelProbabilityPanel.cs +++ b/Assets/Script/UI/LevelProbabilityPanel.cs @@ -1,4 +1,3 @@ -using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -12,23 +11,7 @@ public class LevelProbabilityPanel : MonoBehaviour private void Start() { - if (startSceneData == null) - { - try - { - // try get start scene data - scenePrefabSet = GameObject.Find("StartSceneDataTransfer").GetComponent().scenePrefabSet; - } - catch - { - // if not found, find dummy StartSeneData - scenePrefabSet = GameObject.Find("StartSceneDataTransferDummy").GetComponent().scenePrefabSet; - } - } - else - { - scenePrefabSet = startSceneData.GetComponent().scenePrefabSet; - } + scenePrefabSet = CommonParameterContainer.Instance.scenePrefabSet; for (int i = 0; i < scenePrefabSet.targetLevels.Length; i++) { Targets nowTarget = scenePrefabSet.targets[i]; diff --git a/Assets/Script/UI/StartMenuProbabilityPanel.cs b/Assets/Script/UI/StartMenuProbabilityPanel.cs index 6bc5205..57defa2 100644 --- a/Assets/Script/UI/StartMenuProbabilityPanel.cs +++ b/Assets/Script/UI/StartMenuProbabilityPanel.cs @@ -11,7 +11,7 @@ public class StartMenuProbabilityPanel : MonoBehaviour private void Start() { - scenePrefabSet = startSceneData.GetComponent().scenePrefabSet; + scenePrefabSet = CommonParameterContainer.Instance.scenePrefabSet; for (int i = 0; i < scenePrefabSet.targetLevels.Length; i++) { Targets nowTarget = scenePrefabSet.targets[i]; diff --git a/Assets/Script/UI/StartUIManager.cs b/Assets/Script/UI/StartUIManager.cs index 578fd20..954fb6b 100644 --- a/Assets/Script/UI/StartUIManager.cs +++ b/Assets/Script/UI/StartUIManager.cs @@ -7,24 +7,23 @@ public class StartUIManager : MonoBehaviour { [SerializeField] private int waitTimeLimit = 45; [SerializeField] private GameObject sceneLoaderObj; - [SerializeField] private GameObject startSceneDataObj; [SerializeField] private GameObject targetLevelProbabilityPanelOBJ; [SerializeField] private TextMeshProUGUI messageTextObj; [SerializeField] private TextMeshProUGUI waitTimeTextObj; private SceneLoader sceneLoader; - private StartSeneData startSceneData; private ButtonActivateColorChanger buttonActivateColorChanger; private StartMenuProbabilityPanel startMenuProbabilityPanel; + private CommonParameterContainer commonParameterContainer; private float startTime; private float nowTime; // Start is called before the first frame update void Start() { sceneLoader = sceneLoaderObj.GetComponent(); - startSceneData = startSceneDataObj.GetComponent(); buttonActivateColorChanger = GetComponent(); startMenuProbabilityPanel = targetLevelProbabilityPanelOBJ.GetComponent(); + commonParameterContainer = CommonParameterContainer.Instance; messageTextObj.text = ""; buttonActivateColorChanger.InitializeAllButtonColor(); } @@ -44,7 +43,7 @@ private void Update() // while StartButton-Play Pressed public void OnPlayButtonPressed() { - startSceneData.gameMode = 1; + commonParameterContainer.gameMode = 1; sceneLoader.LoadGameScene(SceneLoader.SceneType.Play); messageTextObj.text = "Loading Play Scene..."; } @@ -52,30 +51,30 @@ public void OnPlayButtonPressed() public void OnAttackTrainButtonPressed() { // while Train-Attack-Button Pressed - startSceneData.attackProb = 1f; + commonParameterContainer.attackProb = 1f; ApplicateProbabilityToData(); LoadTrainScene(); } public void OnGotoTrainButtonPressed() { // while Train-Goto-Button Pressed - startSceneData.gotoProb = 1f; + commonParameterContainer.gotoProb = 1f; ApplicateProbabilityToData(); LoadTrainScene(); } public void OnFreeTrainButtonPressed() { // while Train-Free-Button Pressed - startSceneData.attackProb = 0f; - startSceneData.gotoProb = 0f; - startSceneData.defenceProb = 0f; + commonParameterContainer.attackProb = 0f; + commonParameterContainer.gotoProb = 0f; + commonParameterContainer.defenceProb = 0f; LoadTrainScene(); } public void OnMixTrainButtonPressed() { // while Train-Mix-Button Pressed - startSceneData.attackProb = 0.333f; - startSceneData.gotoProb = 0.333f; + commonParameterContainer.attackProb = 0.333f; + commonParameterContainer.gotoProb = 0.333f; LoadTrainScene(); } private void LoadTrainScene() @@ -87,13 +86,13 @@ private void LoadTrainScene() private void ApplicateProbabilityToData() { - for (int i = 0; i < startSceneData.scenePrefabSet.targetLevels[0].levelSize; i++) + for (int i = 0; i < commonParameterContainer.scenePrefabSet.targetLevels[0].levelSize; i++) { - startSceneData.gotoLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[0].singleLevelPanels[i].ProbabilityValue); + commonParameterContainer.gotoLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[0].singleLevelPanels[i].ProbabilityValue); } - for(int i = 0; i < startSceneData.scenePrefabSet.targetLevels[1].levelSize; i++) + for(int i = 0; i < commonParameterContainer.scenePrefabSet.targetLevels[1].levelSize; i++) { - startSceneData.attackLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[1].singleLevelPanels[i].ProbabilityValue); + commonParameterContainer.attackLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[1].singleLevelPanels[i].ProbabilityValue); } } } \ No newline at end of file diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt index e13b0d4..38f5a1a 100644 --- a/UserSettings/Layouts/default-2021.dwlt +++ b/UserSettings/Layouts/default-2021.dwlt @@ -14,12 +14,12 @@ MonoBehaviour: m_EditorClassIdentifier: m_PixelRect: serializedVersion: 2 - x: 70 - y: 237 + x: -185 + y: 143 width: 1842 height: 835 m_ShowMode: 4 - m_Title: Project + m_Title: Inspector m_RootView: {fileID: 2} m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} @@ -120,7 +120,7 @@ MonoBehaviour: m_MinSize: {x: 300, y: 200} m_MaxSize: {x: 24288, y: 16192} vertical: 0 - controlID: 128 + controlID: 122 --- !u!114 &6 MonoBehaviour: m_ObjectHideFlags: 52 @@ -145,7 +145,7 @@ MonoBehaviour: m_MinSize: {x: 100, y: 200} m_MaxSize: {x: 8096, y: 16192} vertical: 1 - controlID: 129 + controlID: 123 --- !u!114 &7 MonoBehaviour: m_ObjectHideFlags: 52 @@ -224,7 +224,7 @@ MonoBehaviour: m_MinSize: {x: 100, y: 200} m_MaxSize: {x: 8096, y: 16192} vertical: 1 - controlID: 106 + controlID: 58 --- !u!114 &10 MonoBehaviour: m_ObjectHideFlags: 52 @@ -324,8 +324,8 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 70 - y: 267 + x: -185 + y: 173 width: 1038 height: 541 m_ViewDataDictionary: {fileID: 0} @@ -557,14 +557,14 @@ MonoBehaviour: m_OverrideSceneCullingMask: 6917529027641081856 m_SceneIsLit: 1 m_SceneLighting: 1 - m_2DMode: 0 + m_2DMode: 1 m_isRotationLocked: 0 m_PlayAudio: 0 m_AudioPlay: 0 m_Position: - m_Target: {x: 1304.15, y: -363.07422, z: 779.8682} + m_Target: {x: 523.5, y: 332.7, z: -2.5} speed: 2 - m_Value: {x: 1304.15, y: -363.07422, z: 779.8682} + m_Value: {x: 523.5, y: 332.7, z: -2.5} m_RenderMode: 0 m_CameraMode: drawMode: 0 @@ -611,17 +611,17 @@ MonoBehaviour: m_GridAxis: 1 m_gridOpacity: 0.529 m_Rotation: - m_Target: {x: 0.24245703, y: 0.3826798, z: -0.104802005, w: 0.88532037} + m_Target: {x: 0, y: 0, z: 0, w: 1} speed: 2 - m_Value: {x: 0.24245703, y: 0.3826798, z: -0.104802005, w: 0.88532037} + m_Value: {x: 0, y: 0, z: 0, w: 1} m_Size: - m_Target: 1452.5306 + m_Target: 620.32074 speed: 2 - m_Value: 1452.5306 + m_Value: 620.32074 m_Ortho: - m_Target: 0 + m_Target: 1 speed: 2 - m_Value: 0 + m_Value: 1 m_CameraSettings: m_Speed: 1.0005 m_SpeedNormalized: 0.5 @@ -635,7 +635,7 @@ MonoBehaviour: m_FarClip: 10000 m_DynamicClip: 1 m_OcclusionCulling: 0 - m_LastSceneViewRotation: {x: -0.08717229, y: 0.89959055, z: -0.21045254, w: -0.3726226} + m_LastSceneViewRotation: {x: 0.24245703, y: 0.3826798, z: -0.104802005, w: 0.88532037} m_LastSceneViewOrtho: 0 m_ReplacementShader: {fileID: 0} m_ReplacementString: @@ -662,9 +662,9 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1920 + x: 62 y: 73 - width: 1082 + width: 1047 height: 686 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: @@ -676,7 +676,7 @@ MonoBehaviour: m_ShowGizmos: 0 m_TargetDisplay: 0 m_ClearColor: {r: 0, g: 0, b: 0, a: 0} - m_TargetSize: {x: 1082, y: 665} + m_TargetSize: {x: 1047, y: 665} m_TextureFilterMode: 0 m_TextureHideFlags: 61 m_RenderIMGUI: 1 @@ -691,8 +691,8 @@ MonoBehaviour: m_VRangeLocked: 0 hZoomLockedByDefault: 0 vZoomLockedByDefault: 0 - m_HBaseRangeMin: -541 - m_HBaseRangeMax: 541 + m_HBaseRangeMin: -523.5 + m_HBaseRangeMax: 523.5 m_VBaseRangeMin: -332.5 m_VBaseRangeMax: 332.5 m_HAllowExceedBaseRangeMin: 1 @@ -712,23 +712,23 @@ MonoBehaviour: serializedVersion: 2 x: 0 y: 21 - width: 1082 + width: 1047 height: 665 m_Scale: {x: 1, y: 1} - m_Translation: {x: 541, y: 332.5} + m_Translation: {x: 523.5, y: 332.5} m_MarginLeft: 0 m_MarginRight: 0 m_MarginTop: 0 m_MarginBottom: 0 m_LastShownAreaInsideMargins: serializedVersion: 2 - x: -541 + x: -523.5 y: -332.5 - width: 1082 + width: 1047 height: 665 m_MinimalGUI: 1 m_defaultScale: 1 - m_LastWindowPixelSize: {x: 1082, y: 686} + m_LastWindowPixelSize: {x: 1047, y: 686} m_ClearInEditMode: 1 m_NoCameraWarning: 1 m_LowResolutionForAspectRatios: 01000000000000000000 @@ -754,8 +754,8 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 70 - y: 829 + x: -185 + y: 735 width: 1038 height: 202 m_ViewDataDictionary: {fileID: 0} @@ -775,22 +775,22 @@ MonoBehaviour: m_SkipHidden: 0 m_SearchArea: 1 m_Folders: - - Assets + - Assets/Script/UI m_Globs: [] m_OriginalText: m_ViewMode: 1 m_StartGridSize: 16 m_LastFolders: - - Assets + - Assets/Script/UI m_LastFoldersGridSize: 16 m_LastProjectPath: C:\Users\UCUNI\OneDrive\Unity\ML-Agents\Aimbot-ParallelEnv m_LockTracker: m_IsLocked: 0 m_FolderTreeState: - scrollPos: {x: 0, y: 159} - m_SelectedIDs: aa820000 - m_LastClickedID: 33450 - m_ExpandedIDs: 00000000688200006a8200006c8200006e82000070820000728200007482000076820000788200007a8200007c8200007e82000080820000828200008482000086820000aa82000000ca9a3bffffff7f + scrollPos: {x: 0, y: 321} + m_SelectedIDs: e2830000 + m_LastClickedID: 33762 + m_ExpandedIDs: 000000001e830000528300005a83000000ca9a3bffffff7f m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -818,7 +818,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 00000000688200006a8200006c8200006e82000070820000728200007482000076820000788200007a8200007c8200007e82000080820000828200008482000086820000 + m_ExpandedIDs: 000000001e830000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -870,7 +870,7 @@ MonoBehaviour: m_Icon: {fileID: 0} m_ResourceFile: m_NewAssetIndexInList: -1 - m_ScrollPosition: {x: 0, y: 0} + m_ScrollPosition: {x: 0, y: 60} m_GridSize: 16 m_SkipHiddenPackages: 0 m_DirectoriesAreaWidth: 355 @@ -922,8 +922,8 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1109 - y: 267 + x: 854 + y: 173 width: 451 height: 421 m_ViewDataDictionary: {fileID: 0} @@ -933,9 +933,9 @@ MonoBehaviour: m_SceneHierarchy: m_TreeViewState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: - m_LastClickedID: 0 - m_ExpandedIDs: 32fbffff + m_SelectedIDs: fca50000 + m_LastClickedID: 42492 + m_ExpandedIDs: b8aaffff5cacfffff0b9ffff32fbfffff4ffffff7ea60000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -979,8 +979,8 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1109 - y: 709 + x: 854 + y: 615 width: 451 height: 322 m_ViewDataDictionary: {fileID: 0} @@ -999,7 +999,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6c262c1329a02fa49b5cb4c297106f3f, type: 3} m_Name: m_EditorClassIdentifier: - m_MinSize: {x: 129, y: 28} + m_MinSize: {x: 136, y: 30} m_MaxSize: {x: 4000, y: 4000} m_TitleContent: m_Text: ProBuilder @@ -1035,8 +1035,8 @@ MonoBehaviour: m_Tooltip: m_Pos: serializedVersion: 2 - x: 1562 - y: 267 + x: 1307 + y: 173 width: 349 height: 764 m_ViewDataDictionary: {fileID: 0}