V3.1.1 优化代码

优化可读性与规范化命名方式
This commit is contained in:
Koha9 2023-06-30 18:30:12 +09:00
parent 64e477d6c2
commit cfccd12820
43 changed files with 912 additions and 1118 deletions

View File

@ -1 +1 @@
{"count":1,"self":32.1479424,"total":32.5224426,"children":{"InitializeActuators":{"count":2,"self":0.0015004999999999999,"total":0.0015004999999999999,"children":null},"InitializeSensors":{"count":2,"self":0.0009999,"total":0.0009999,"children":null},"AgentSendState":{"count":1395,"self":0.0098739,"total":0.054415599999999995,"children":{"CollectObservations":{"count":1395,"self":0.040894599999999996,"total":0.040894599999999996,"children":null},"WriteActionMask":{"count":1395,"self":2.5399999999999997E-05,"total":2.5399999999999997E-05,"children":null},"RequestDecision":{"count":1395,"self":0.0036217,"total":0.0036217,"children":null}}},"DecideAction":{"count":1395,"self":0.0059974999999999994,"total":0.0059974999999999994,"children":null},"AgentAct":{"count":1395,"self":0.3105879,"total":0.3105879,"children":null}},"gauges":{"AKMAgent.CumulativeReward":{"count":1,"max":-497.4348,"min":-497.4348,"runningAverage":-497.4348,"value":-497.4348,"weightedAverage":-497.4348}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1688018681","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 f0cd9b14-9448-48b8-a171-832b56425f1a -accessToken 4Ih0Fmgn-qcBzV7BmmRSC3-07nfbMRhn-v5RdyzS41800ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Play","end_time_seconds":"1688018713"}}
{"count":1,"self":16.8006864,"total":16.973945399999998,"children":{"InitializeActuators":{"count":2,"self":0.0010003,"total":0.0010003,"children":null},"InitializeSensors":{"count":2,"self":0.0015002,"total":0.0015002,"children":null},"AgentSendState":{"count":616,"self":0.0048017,"total":0.027126599999999997,"children":{"CollectObservations":{"count":616,"self":0.020827,"total":0.020827,"children":null},"WriteActionMask":{"count":616,"self":0,"total":0,"children":null},"RequestDecision":{"count":616,"self":0.0014979,"total":0.0014979,"children":null}}},"DecideAction":{"count":616,"self":0.0055005,"total":0.0055005,"children":null},"AgentAct":{"count":616,"self":0.1376329,"total":0.1376329,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1688115931","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 9e41b3f8-f619-4c21-bfd0-3deb9ef4a3a3 -accessToken 5_-tFrPoI03Gst7aaMZzwX2aQ0DUh9t9XlhQKlaeR7M00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Play","end_time_seconds":"1688115948"}}

View File

@ -1694,8 +1694,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8e1ae09061637cf4ead72321c221f783, type: 3}
m_Name:
m_EditorClassIdentifier:
FirebasesAreaObj: {fileID: 8752325863075491123}
EnemyContainerObj: {fileID: 1738303626243613018}
firebasesAreaObj: {fileID: 8752325863075491123}
enemyContainerObj: {fileID: 1738303626243613018}
group1InareaNum: 0
group2InareaNum: 0
belongRatio: 0

View File

@ -1694,8 +1694,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8e1ae09061637cf4ead72321c221f783, type: 3}
m_Name:
m_EditorClassIdentifier:
FirebasesAreaObj: {fileID: 8752325863075491123}
EnemyContainerObj: {fileID: 1738303626243613018}
firebasesAreaObj: {fileID: 8752325863075491123}
enemyContainerObj: {fileID: 1738303626243613018}
group1InareaNum: 0
group2InareaNum: 0
belongRatio: 0

View File

@ -2011,8 +2011,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8e1ae09061637cf4ead72321c221f783, type: 3}
m_Name:
m_EditorClassIdentifier:
FirebasesAreaObj: {fileID: 8752325863075491123}
EnemyContainerObj: {fileID: 1738303626243613018}
firebasesAreaObj: {fileID: 8752325863075491123}
enemyContainerObj: {fileID: 1738303626243613018}
group1InareaNum: 0
group2InareaNum: 0
belongRatio: 0

View File

@ -158,8 +158,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8e1ae09061637cf4ead72321c221f783, type: 3}
m_Name:
m_EditorClassIdentifier:
FirebasesAreaObj: {fileID: 771219355294398680}
EnemyContainerObj: {fileID: 6409500528995947518}
firebasesAreaObj: {fileID: 771219355294398680}
enemyContainerObj: {fileID: 6409500528995947518}
group1InareaNum: 0
group2InareaNum: 0
belongRatio: 0

View File

@ -79,8 +79,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8e1ae09061637cf4ead72321c221f783, type: 3}
m_Name:
m_EditorClassIdentifier:
FirebasesAreaObj: {fileID: 5210138615741576696}
EnemyContainerObj: {fileID: 5157670622552495051}
firebasesAreaObj: {fileID: 5210138615741576696}
enemyContainerObj: {fileID: 5157670622552495051}
group1InareaNum: 0
group2InareaNum: 0
belongRatio: 0

View File

@ -1,144 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &395223127228427279
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6088153073699997735}
- component: {fileID: 3883336356577164080}
- component: {fileID: 5931586663366854329}
- component: {fileID: 3319472584262705651}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6088153073699997735
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 395223127228427279}
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: 6561472780860268577}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &3883336356577164080
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 395223127228427279}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &5931586663366854329
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 395223127228427279}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &3319472584262705651
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 395223127228427279}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!1 &6561472780860268583
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6561472780860268577}
- component: {fileID: 6561472780860268582}
m_Layer: 0
m_Name: SelectEffect
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6561472780860268577
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6561472780860268583}
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:
- {fileID: 6088153073699997735}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &6561472780860268582
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6561472780860268583}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 42a602efe0639c144907a166e7e59a79, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 66420aca630480743a18632a2ac888e9
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1453,9 +1453,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e3ddb0247fbea1b4799dd33b60ab4f12, type: 3}
m_Name:
m_EditorClassIdentifier:
TargetControllerObj: {fileID: 1692325237}
ParameterContainerObj: {fileID: 707336050}
GroundCanvasObj: {fileID: 9036011469363144088, guid: 8dbc038adffc1104ba0f6a4332a3c15a, type: 3}
targetControllerObj: {fileID: 1692325237}
parameterContainerObj: {fileID: 707336050}
groundCanvasObj: {fileID: 366190003}
chartObj: {fileID: 942746279}
HUDObj: {fileID: 2082200184}
remainTimeText: {fileID: 591260567}
@ -2492,7 +2492,7 @@ MonoBehaviour:
m_Calls:
- m_Target: {fileID: 2082200190}
m_TargetAssemblyTypeName: TargetUIController, Assembly-CSharp
m_MethodName: setAttackPressed
m_MethodName: SetAttackPressed
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -3518,7 +3518,7 @@ MonoBehaviour:
m_Calls:
- m_Target: {fileID: 2082200190}
m_TargetAssemblyTypeName: TargetUIController, Assembly-CSharp
m_MethodName: setGotoPressed
m_MethodName: SetGotoPressed
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -5432,6 +5432,170 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 567604020}
m_CullTransparentMesh: 1
--- !u!43 &572193095
Mesh:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: pb_Mesh23968
serializedVersion: 10
m_SubMeshes:
- serializedVersion: 2
firstByte: 0
indexCount: 36
topology: 0
baseVertex: 0
firstVertex: 0
vertexCount: 24
localAABB:
m_Center: {x: 5, y: 1, z: -0.5}
m_Extent: {x: 5, y: 1, z: 0.5}
m_Shapes:
vertices: []
shapes: []
channels: []
fullWeights: []
m_BindPose: []
m_BoneNameHashes:
m_RootBoneNameHash: 0
m_BonesAABB: []
m_VariableBoneCountWeights:
m_Data:
m_MeshCompression: 0
m_IsReadable: 1
m_KeepVertices: 1
m_KeepIndices: 1
m_IndexFormat: 0
m_IndexBuffer: 000001000200010003000200040005000600050007000600080009000a0009000b000a000c000d000e000d000f000e00100011001200110013001200140015001600150017001600
m_VertexData:
serializedVersion: 3
m_VertexCount: 24
m_Channels:
- stream: 0
offset: 0
format: 0
dimension: 3
- stream: 0
offset: 12
format: 0
dimension: 3
- stream: 0
offset: 24
format: 0
dimension: 4
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 40
format: 0
dimension: 2
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
m_DataSize: 1152
_typelessdata: 00000000000000000000000000000000000000000000803f000080bf0000000000000000000080bf000000000000000000002041000000000000000000000000000000000000803f000080bf0000000000000000000080bf000020c10000000000000000000000400000000000000000000000000000803f000080bf0000000000000000000080bf000000000000004000002041000000400000000000000000000000000000803f000080bf0000000000000000000080bf000020c1000000400000204100000000000000000000803f000000000000000000000000000000000000803f000080bf00000000000000000000204100000000000080bf0000803f000000000000000000000000000000000000803f000080bf000080bf000000000000204100000040000000000000803f000000000000000000000000000000000000803f000080bf00000000000000400000204100000040000080bf0000803f000000000000000000000000000000000000803f000080bf000080bf000000400000204100000000000080bf0000000000000000000080bf0000803f0000000000000000000080bf00002041000000000000000000000000000080bf0000000000000000000080bf0000803f0000000000000000000080bf00000000000000000000204100000040000080bf0000000000000000000080bf0000803f0000000000000000000080bf00002041000000400000000000000040000080bf0000000000000000000080bf0000803f0000000000000000000080bf00000000000000400000000000000000000080bf000080bf00000000000000000000000000000000000080bf000080bf0000803f00000000000000000000000000000000000080bf00000000000000000000000000000000000080bf000080bf00000000000000000000000000000040000080bf000080bf00000000000000000000000000000000000080bf000080bf0000803f00000040000000000000004000000000000080bf00000000000000000000000000000000000080bf000080bf0000000000000040000000000000004000000000000000000000803f000000000000803f0000000000000000000080bf0000000000000000000020410000004000000000000000000000803f000000000000803f0000000000000000000080bf00002041000000000000000000000040000080bf000000000000803f000000000000803f0000000000000000000080bf00000000000080bf0000204100000040000080bf000000000000803f000000000000803f0000000000000000000080bf00002041000080bf0000000000000000000080bf00000000000080bf00000000000080bf0000000000000000000080bf00000000000080bf0000204100000000000080bf00000000000080bf00000000000080bf0000000000000000000080bf000020c1000080bf00000000000000000000000000000000000080bf00000000000080bf0000000000000000000080bf000000000000000000002041000000000000000000000000000080bf00000000000080bf0000000000000000000080bf000020c100000000
m_CompressedMesh:
m_Vertices:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_UV:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Normals:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Tangents:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Weights:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_NormalSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_TangentSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_FloatColors:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_BoneIndices:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_Triangles:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_UVInfo: 0
m_LocalAABB:
m_Center: {x: 5, y: 1, z: -0.5}
m_Extent: {x: 5, y: 1, z: 0.5}
m_MeshUsageFlags: 0
m_BakedConvexCollisionMesh:
m_BakedTriangleCollisionMesh:
m_MeshMetrics[0]: 1
m_MeshMetrics[1]: 1
m_MeshOptimizationFlags: 1
m_StreamData:
serializedVersion: 2
offset: 0
size: 0
path:
--- !u!1 &579229720
GameObject:
m_ObjectHideFlags: 0
@ -6320,15 +6484,15 @@ MonoBehaviour:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 0
ParameterContainerObj: {fileID: 707336050}
EnvironmentObj: {fileID: 749443372}
EnemyContainerObj: {fileID: 891195334}
SceneBlockContainerObj: {fileID: 1811162388}
EnvironmentUIControlObj: {fileID: 156390936}
TargetControllerObj: {fileID: 1692325237}
parameterContainerObj: {fileID: 707336050}
environmentObj: {fileID: 749443372}
enemyContainerObj: {fileID: 891195334}
sceneBlockContainerObj: {fileID: 1811162388}
environmentUIControlObj: {fileID: 156390936}
targetControllerObj: {fileID: 1692325237}
HUDObj: {fileID: 2082200184}
thisCam: {fileID: 1633276149}
MoveSpeed: 9
moveSpeed: 9
vX: 0
vZ: 0
thisMovement: {x: 0, y: 0, z: 0}
@ -6433,7 +6597,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
isDead: 0
MaxHP: 100
maxHP: 100
--- !u!1 &636386815
GameObject:
m_ObjectHideFlags: 0
@ -7366,7 +7530,7 @@ MonoBehaviour:
blockConObj: {fileID: 1811162388}
agentObj: {fileID: 629870337}
lockMouse: 0
Damage: 50
damage: 50
fireRate: 0.5
timeLimit: 30
lockCameraX: 0
@ -8658,8 +8822,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
enemyPrefab: {fileID: 8240453774489061354, guid: c044b8f18a5ed2f4eaabb8d40095018f, type: 3}
EnvironmentObj: {fileID: 749443372}
TargetControllerObj: {fileID: 1692325237}
environmentObj: {fileID: 749443372}
targetControllerObj: {fileID: 1692325237}
--- !u!1 &898640494
GameObject:
m_ObjectHideFlags: 0
@ -9812,7 +9976,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: fe230edb81d2a59409af4d033c8d2e7a, type: 3}
m_Name:
m_EditorClassIdentifier:
WinChart: {fileID: 1833480578}
winChart: {fileID: 1833480578}
totalGames:
winGames:
--- !u!114 &1052251815
@ -11456,7 +11620,7 @@ MonoBehaviour:
m_Calls:
- m_Target: {fileID: 2082200190}
m_TargetAssemblyTypeName: TargetUIController, Assembly-CSharp
m_MethodName: setFreePressed
m_MethodName: SetFreePressed
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -11590,7 +11754,7 @@ MonoBehaviour:
m_Calls:
- m_Target: {fileID: 2082200190}
m_TargetAssemblyTypeName: TargetUIController, Assembly-CSharp
m_MethodName: setStayPressed
m_MethodName: SetStayPressed
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -12356,7 +12520,7 @@ MonoBehaviour:
m_Calls:
- m_Target: {fileID: 2082200190}
m_TargetAssemblyTypeName: TargetUIController, Assembly-CSharp
m_MethodName: setEnemyPressed
m_MethodName: SetEnemyPressed
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -13326,7 +13490,7 @@ MonoBehaviour:
m_Calls:
- m_Target: {fileID: 2082200190}
m_TargetAssemblyTypeName: TargetUIController, Assembly-CSharp
m_MethodName: clearGamePressed
m_MethodName: ClearGamePressed
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
@ -13734,14 +13898,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 92a93d5d33962bc44b9fd2368358d47e, type: 3}
m_Name:
m_EditorClassIdentifier:
EnvironmentObj: {fileID: 749443372}
AgentObj: {fileID: 629870337}
environmentObj: {fileID: 749443372}
agentObj: {fileID: 629870337}
HUDObj: {fileID: 2082200184}
SceneBlockContainerObj: {fileID: 1811162388}
EnemyContainerObj: {fileID: 891195334}
ParameterContainerObj: {fileID: 707336050}
EnvironmentUIObj: {fileID: 156390936}
WorldUIObj: {fileID: 1052251813}
sceneBlockContainerObj: {fileID: 1811162388}
enemyContainerObj: {fileID: 891195334}
parameterContainerObj: {fileID: 707336050}
environmentUIObj: {fileID: 156390936}
worldUIObj: {fileID: 1052251813}
edgeUp: {fileID: 1352953080}
edgeDown: {fileID: 1571061029}
edgeLeft: {fileID: 1551793502}
@ -14924,7 +15088,7 @@ MeshCollider:
serializedVersion: 4
m_Convex: 0
m_CookingOptions: 30
m_Mesh: {fileID: 2136225666}
m_Mesh: {fileID: 572193095}
--- !u!33 &1790388461
MeshFilter:
m_ObjectHideFlags: 10
@ -14932,7 +15096,7 @@ MeshFilter:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1790388458}
m_Mesh: {fileID: 2136225666}
m_Mesh: {fileID: 572193095}
--- !u!23 &1790388462
MeshRenderer:
m_ObjectHideFlags: 0
@ -15186,8 +15350,8 @@ MonoBehaviour:
m_AreaError: 15
m_PreserveMeshAssetOnDestroy: 0
assetGuid:
m_Mesh: {fileID: 2136225666}
m_VersionIndex: 6
m_Mesh: {fileID: 572193095}
m_VersionIndex: 9
m_IsSelectable: 1
m_SelectedFaces:
m_SelectedEdges: []
@ -15320,7 +15484,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
sceneSize: 10
EnvironmentObj: {fileID: 749443372}
environmentObj: {fileID: 749443372}
attackBlockPrefabs:
- {fileID: 771219355588494022, guid: 38e1219bc0e854642a1ec4d55715632c, type: 3}
- {fileID: 5210138614873161068, guid: bd97e077540d4884d8fccc315932005c, type: 3}
@ -17549,11 +17713,11 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
playCamera: {fileID: 1586670226}
EnvironmentObj: {fileID: 749443372}
environmentObj: {fileID: 749443372}
selectEffect: {fileID: 6561472780860268583, guid: 66420aca630480743a18632a2ac888e9, type: 3}
EnemyContainerObj: {fileID: 891195334}
SceneBlockContainerObj: {fileID: 1811162388}
TargetControllerObj: {fileID: 1692325237}
enemyContainerObj: {fileID: 891195334}
sceneBlockContainerObj: {fileID: 1811162388}
targetControllerObj: {fileID: 1692325237}
HUDObj: {fileID: 2082200184}
mouseMode: 0
--- !u!4 &1962276267
@ -19011,9 +19175,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3e5f471594a32c24194088f10d716a89, type: 3}
m_Name:
m_EditorClassIdentifier:
TargetControllerObj: {fileID: 1692325237}
MouseSelectorObj: {fileID: 1962276265}
EnvironmentUIObj: {fileID: 156390936}
targetControllerObj: {fileID: 1692325237}
mouseSelectorObj: {fileID: 1962276265}
environmentUIObj: {fileID: 156390936}
setAttackButton: {fileID: 320729027}
setGotoButton: {fileID: 371362500}
setFreeButton: {fileID: 1411671494}
@ -19480,170 +19644,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2134501847}
m_CullTransparentMesh: 1
--- !u!43 &2136225666
Mesh:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: pb_Mesh23980
serializedVersion: 10
m_SubMeshes:
- serializedVersion: 2
firstByte: 0
indexCount: 36
topology: 0
baseVertex: 0
firstVertex: 0
vertexCount: 24
localAABB:
m_Center: {x: 5, y: 1, z: -0.5}
m_Extent: {x: 5, y: 1, z: 0.5}
m_Shapes:
vertices: []
shapes: []
channels: []
fullWeights: []
m_BindPose: []
m_BoneNameHashes:
m_RootBoneNameHash: 0
m_BonesAABB: []
m_VariableBoneCountWeights:
m_Data:
m_MeshCompression: 0
m_IsReadable: 1
m_KeepVertices: 1
m_KeepIndices: 1
m_IndexFormat: 0
m_IndexBuffer: 000001000200010003000200040005000600050007000600080009000a0009000b000a000c000d000e000d000f000e00100011001200110013001200140015001600150017001600
m_VertexData:
serializedVersion: 3
m_VertexCount: 24
m_Channels:
- stream: 0
offset: 0
format: 0
dimension: 3
- stream: 0
offset: 12
format: 0
dimension: 3
- stream: 0
offset: 24
format: 0
dimension: 4
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 40
format: 0
dimension: 2
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
m_DataSize: 1152
_typelessdata: 00000000000000000000000000000000000000000000803f000080bf0000000000000000000080bf000000000000000000002041000000000000000000000000000000000000803f000080bf0000000000000000000080bf000020c10000000000000000000000400000000000000000000000000000803f000080bf0000000000000000000080bf000000000000004000002041000000400000000000000000000000000000803f000080bf0000000000000000000080bf000020c1000000400000204100000000000000000000803f000000000000000000000000000000000000803f000080bf00000000000000000000204100000000000080bf0000803f000000000000000000000000000000000000803f000080bf000080bf000000000000204100000040000000000000803f000000000000000000000000000000000000803f000080bf00000000000000400000204100000040000080bf0000803f000000000000000000000000000000000000803f000080bf000080bf000000400000204100000000000080bf0000000000000000000080bf0000803f0000000000000000000080bf00002041000000000000000000000000000080bf0000000000000000000080bf0000803f0000000000000000000080bf00000000000000000000204100000040000080bf0000000000000000000080bf0000803f0000000000000000000080bf00002041000000400000000000000040000080bf0000000000000000000080bf0000803f0000000000000000000080bf00000000000000400000000000000000000080bf000080bf00000000000000000000000000000000000080bf000080bf0000803f00000000000000000000000000000000000080bf00000000000000000000000000000000000080bf000080bf00000000000000000000000000000040000080bf000080bf00000000000000000000000000000000000080bf000080bf0000803f00000040000000000000004000000000000080bf00000000000000000000000000000000000080bf000080bf0000000000000040000000000000004000000000000000000000803f000000000000803f0000000000000000000080bf0000000000000000000020410000004000000000000000000000803f000000000000803f0000000000000000000080bf00002041000000000000000000000040000080bf000000000000803f000000000000803f0000000000000000000080bf00000000000080bf0000204100000040000080bf000000000000803f000000000000803f0000000000000000000080bf00002041000080bf0000000000000000000080bf00000000000080bf00000000000080bf0000000000000000000080bf00000000000080bf0000204100000000000080bf00000000000080bf00000000000080bf0000000000000000000080bf000020c1000080bf00000000000000000000000000000000000080bf00000000000080bf0000000000000000000080bf000000000000000000002041000000000000000000000000000080bf00000000000080bf0000000000000000000080bf000020c100000000
m_CompressedMesh:
m_Vertices:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_UV:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Normals:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Tangents:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Weights:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_NormalSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_TangentSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_FloatColors:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_BoneIndices:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_Triangles:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_UVInfo: 0
m_LocalAABB:
m_Center: {x: 5, y: 1, z: -0.5}
m_Extent: {x: 5, y: 1, z: 0.5}
m_MeshUsageFlags: 0
m_BakedConvexCollisionMesh:
m_BakedTriangleCollisionMesh:
m_MeshMetrics[0]: 1
m_MeshMetrics[1]: 1
m_MeshOptimizationFlags: 1
m_StreamData:
serializedVersion: 2
offset: 0
size: 0
path:
--- !u!1 &2139943208
GameObject:
m_ObjectHideFlags: 0

View File

@ -1352,11 +1352,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7761fd42cad2b9544a15df1264649677, type: 3}
m_Name:
m_EditorClassIdentifier:
WaitTimeLimit: 45
SceneLoaderObj: {fileID: 1206568295}
StartSceneDataObj: {fileID: 1072325866}
MessageTextObj: {fileID: 294404781}
WaitTimeTextObj: {fileID: 431112176}
waitTimeLimit: 45
sceneLoaderObj: {fileID: 1206568295}
startSceneDataObj: {fileID: 1072325866}
messageTextObj: {fileID: 294404781}
waitTimeTextObj: {fileID: 431112176}
--- !u!1 &1575146385
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,13 +1,10 @@
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Sensors;
using Unity.MLAgents.Actuators;
using System.Linq;
using Unity.MLAgents;
using Unity.MLAgents.Actuators;
using Unity.MLAgents.Sensors;
using UnityEngine;
/*TODO:
tag
@ -18,17 +15,18 @@
public class AgentWithGun : Agent
{
public GameObject ParameterContainerObj;
public GameObject EnvironmentObj;
public GameObject EnemyContainerObj;
public GameObject SceneBlockContainerObj;
public GameObject EnvironmentUIControlObj;
public GameObject TargetControllerObj;
public GameObject parameterContainerObj;
public GameObject environmentObj;
public GameObject enemyContainerObj;
public GameObject sceneBlockContainerObj;
public GameObject environmentUIControlObj;
public GameObject targetControllerObj;
public GameObject HUDObj;
public Camera thisCam;
[Header("GetAxis() Simulate")]
public float MoveSpeed = 9.0f;
public float moveSpeed = 9.0f;
public float vX = 0f;
public float vZ = 0f;
public Vector3 thisMovement;
@ -39,9 +37,10 @@ public class AgentWithGun : Agent
[Header("Env")]
public bool oneHotRayTag = true;
private List<float> spinRecord = new List<float>();
private bool lockMouse;
private float Damage;
private float damage;
private float fireRate;
private int enemyNum;
private bool lockCameraX;
@ -49,6 +48,7 @@ public class AgentWithGun : Agent
// environment
private int shoot = 0;
private float lastShootTime = 0.0f;
private int enemyKillCount = 0;
private Vector3 killEnemyPosition;
@ -59,10 +59,12 @@ public class AgentWithGun : Agent
private string myTag = "";
private float lastEnemyFacingDistance = 0f; // record last enemy facing minimum distance
private float lastTargetFacingDistance = 0f; // record last target facing minimum distance
// scripts
private RaySensors raySensors;
private CharacterController PlayerController;
private EnvironmentUIControl EnvUICon;
private CharacterController playerController;
private EnvironmentUIControl envUICon;
private ParameterContainer paramContainer;
private SceneBlockContainer blockContainer;
private EnemyContainer eneContainer;
@ -71,13 +73,14 @@ public class AgentWithGun : Agent
private StartSeneData startSceneData;
// observation
float[] myObserve = new float[4];
float[] rayTagResult;
float[] rayTagResultOnehot;
float[] rayDisResult;
float[] targetStates;
float remainTime;
float inAreaState;
private float[] myObserve = new float[4];
private float[] rayTagResult;
private float[] rayTagResultOnehot;
private float[] rayDisResult;
private float[] targetStates;
private float remainTime;
private float inAreaState;
[System.NonSerialized] public int finishedState;
@ -88,7 +91,8 @@ private void Start()
{
// initialize startSceneData & datas
// while GameObject StartSceneDataTransfer is exist
try {
try
{
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
gamemode = startSceneData.gamemode;
}
@ -100,18 +104,18 @@ private void Start()
}
// initialize scripts
paramContainer = ParameterContainerObj.GetComponent<ParameterContainer>();
eneContainer = EnemyContainerObj.GetComponent<EnemyContainer>();
blockContainer = SceneBlockContainerObj.GetComponent<SceneBlockContainer>();
EnvUICon = EnvironmentUIControlObj.GetComponent<EnvironmentUIControl>();
targetCon = TargetControllerObj.GetComponent<TargetController>();
paramContainer = parameterContainerObj.GetComponent<ParameterContainer>();
eneContainer = enemyContainerObj.GetComponent<EnemyContainer>();
blockContainer = sceneBlockContainerObj.GetComponent<SceneBlockContainer>();
envUICon = environmentUIControlObj.GetComponent<EnvironmentUIControl>();
targetCon = targetControllerObj.GetComponent<TargetController>();
hudController = HUDObj.GetComponent<HUDController>();
raySensors = GetComponent<RaySensors>();
PlayerController = this.transform.GetComponent<CharacterController>();
playerController = this.transform.GetComponent<CharacterController>();
// initialize Environment parameters
lockMouse = paramContainer.lockMouse;
Damage = paramContainer.Damage;
damage = paramContainer.damage;
fireRate = paramContainer.fireRate;
enemyNum = hudController.enemyNum;
lockCameraX = paramContainer.lockCameraX;
@ -124,13 +128,13 @@ private void Start()
// ------------动作处理--------------
// moveAgent 用于模拟Input.GetAxis移动
public void moveAgent(int vertical, int horizontal)
public void MoveAgent(int vertical, int horizontal)
{
// Vector3 thisMovement;
if (horizontal != 0)//当按下按键(水平方向)
{
if (vX < MoveSpeed && vX > -MoveSpeed)//当前速度小于最大速度
if (vX < moveSpeed && vX > -moveSpeed)//当前速度小于最大速度
{
vX += (float)horizontal * acceleration;//增加加速度
}
@ -139,13 +143,12 @@ public void moveAgent(int vertical, int horizontal)
//防止在一瞬间切换输入时速度仍保持不变
if ((vX * horizontal) > 0)//输入与当前速度方向同向
{
vX = (float)horizontal * MoveSpeed; //限制最大速度
vX = (float)horizontal * moveSpeed; //限制最大速度
}
else
{
vX += (float)horizontal * acceleration;//增加加速度
}
}
}
else
@ -162,7 +165,7 @@ public void moveAgent(int vertical, int horizontal)
if (vertical != 0)//当按下按键(垂直方向)
{
if (vZ < MoveSpeed && vZ > -MoveSpeed)//当前速度小于最大速度
if (vZ < moveSpeed && vZ > -moveSpeed)//当前速度小于最大速度
{
vZ += (float)vertical * acceleration;//增加加速度
}
@ -170,7 +173,7 @@ public void moveAgent(int vertical, int horizontal)
{
if ((vZ * vertical) > 0)//输入与当前速度方向同向
{
vZ = (float)vertical * MoveSpeed; //限制最大速度
vZ = (float)vertical * moveSpeed; //限制最大速度
}
else
{
@ -192,17 +195,17 @@ public void moveAgent(int vertical, int horizontal)
thisMovement = (transform.forward * vZ + transform.right * vX);
//PlayerController下的.Move为实现物体运动的函数
//Move()括号内放入一个Vector3类型的量本例中为Player_Move
if (thisMovement.magnitude > MoveSpeed)
if (thisMovement.magnitude > moveSpeed)
{
thisMovement = thisMovement.normalized * MoveSpeed;
thisMovement = thisMovement.normalized * moveSpeed;
}
PlayerController.Move(thisMovement * Time.deltaTime);
playerController.Move(thisMovement * Time.deltaTime);
// update Key Viewer
}
// ------------动作处理--------------
// cameraControl 用于控制Agent视角转动
public void cameraControl(float Mouse_X, float Mouse_Y)
public void CameraControl(float Mouse_X, float Mouse_Y)
{
//Mouse_X = Input.GetAxis("Mouse X") * MouseSensitivity * Time.deltaTime;
//Debug.Log(Input.GetAxis("Mouse X"));
@ -224,7 +227,6 @@ public void cameraControl(float Mouse_X, float Mouse_Y)
//limit UP DOWN between -90 -> 90
yRotation = Mathf.Clamp(yRotation, -90f, 90f);
//相机左右旋转时是以Y轴为中心旋转的上下旋转时是以X轴为中心旋转的
transform.Rotate(Vector3.up * Mouse_X);
//Vector3.up相当于Vector3(0,1,0),CameraRotation.Rotate(Vector3.up * Mouse_X)相当于使CameraRotation对象绕y轴旋转Mouse_X个单位
@ -240,14 +242,14 @@ public void cameraControl(float Mouse_X, float Mouse_Y)
}
// GotKill 获得击杀时用于被呼出
public void killRecord(Vector3 thiskillEnemyPosition)
public void KillRecord(Vector3 thiskillEnemyPosition)
{
enemyKillCount += 1;
killEnemyPosition = thiskillEnemyPosition;
}
// check gun is ready to shoot
bool gunReady()
private bool GunReady()
{
if ((Time.time - lastShootTime) >= fireRate)
{
@ -260,7 +262,7 @@ bool gunReady()
}
// ballistic 射击弹道处理并返回获得reward
float ballistic()
private float Ballistic()
{
Vector3 point = new Vector3(thisCam.pixelWidth / 2, thisCam.pixelHeight / 2, 0);//发射位置
Ray ray = thisCam.ScreenPointToRay(point);
@ -269,7 +271,6 @@ float ballistic()
//按下鼠标左键
if (shoot != 0 && gunReadyToggle == true)
{
lastShootTime = Time.time;
if (Physics.Raycast(ray, out hit, 100))
{
@ -277,9 +278,9 @@ float ballistic()
{
// kill enemy
GameObject gotHitObj = hit.transform.gameObject;//获取受到Ray撞击的对象
gotHitObj.GetComponent<states>().ReactToHit(Damage, gameObject);
gotHitObj.GetComponent<States>().ReactToHit(damage, gameObject);
shoot = 0;
return targetCon.hitEnemyReward(gotHitObj.transform.position);
return targetCon.HitEnemyReward(gotHitObj.transform.position);
}
}
if (targetCon.targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
@ -314,7 +315,7 @@ float ballistic()
}
}
float facingReward()
private float FacingReward()
{
float thisReward = 0;
bool isFacingtoEnemy = false;
@ -333,7 +334,8 @@ float facingReward()
isFacingtoEnemy = true;
}
}
if (raySensors.inViewEnemies.Count > 0 && !isFacingtoEnemy) {
if (raySensors.inViewEnemies.Count > 0 && !isFacingtoEnemy)
{
// have enemy in view
List<float> projectionDis = new List<float>();
foreach (GameObject thisEnemy in raySensors.inViewEnemies)
@ -349,7 +351,7 @@ float facingReward()
// Debug.DrawRay(thisEnemy.transform.position, verticalToRay, Color.magenta);
}
enemyFacingDistance = projectionDis.Min();
if(enemyFacingDistance <= lastEnemyFacingDistance)
if (enemyFacingDistance <= lastEnemyFacingDistance)
{
// closing to enemy
thisReward = 1 / MathF.Sqrt(paramContainer.facingInviewEnemyDisCOEF * enemyFacingDistance + 0.00001f);
@ -365,14 +367,14 @@ float facingReward()
// Debug.Log("ninimum = " + thisReward);
}
}
else if(targetCon.targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
else if (targetCon.targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
{
// attack mode
// Target to Agent distance
float targetDis = Vector3.Distance(blockContainer.thisBlock.transform.position, transform.position);
// center of screen between target's distance
float camCenterToTarget = Vector3.Distance(ray.origin + (ray.direction * targetDis), blockContainer.thisBlock.transform.position);
if(targetDis <= raySensors.viewDistance)
if (targetDis <= raySensors.viewDistance)
{
// Debug.DrawRay(new Vector3(0,0,0), viewPoint, Color.red);
// while center of screen between target's distance is lower than firebasesAreaDiameter
@ -382,7 +384,8 @@ float facingReward()
// Debug.DrawRay(ray.origin, viewPoint-ray.origin, Color.blue);
thisReward = paramContainer.facingReward;
}else
}
else
{
// while not facing to target
thisReward = (lastTargetFacingDistance - camCenterToTarget) * paramContainer.facingTargetReward;
@ -396,7 +399,7 @@ float facingReward()
// ------------Reward--------------
// rewardCalculate 计算本动作的Reward
public float rewardCalculate(float sceneReward,float mouseX,float movement)
public float RewardCalculate(float sceneReward, float mouseX, float movement)
{
float epreward = 0f;
// 击杀reward判断
@ -405,7 +408,7 @@ public float rewardCalculate(float sceneReward,float mouseX,float movement)
for (int i = 0; i < enemyKillCount; i++)
{
// get
epreward += targetCon.killReward(killEnemyPosition);
epreward += targetCon.KillReward(killEnemyPosition);
}
enemyKillCount = 0;
}
@ -414,9 +417,9 @@ public float rewardCalculate(float sceneReward,float mouseX,float movement)
enemyKillCount = 0;
}
// 射击动作reward判断
epreward += ballistic() + sceneReward;
epreward += Ballistic() + sceneReward;
// facing reward
epreward += facingReward();
epreward += FacingReward();
// Penalty
// spin penalty
spinRecord.Add(mouseX);
@ -425,7 +428,7 @@ public float rewardCalculate(float sceneReward,float mouseX,float movement)
spinRecord.RemoveAt(0);
}
float spinPenaltyReward = Math.Abs(spinRecord.ToArray().Sum() * paramContainer.spinPenalty);
if(spinPenaltyReward >= paramContainer.spinPenaltyThreshold)
if (spinPenaltyReward >= paramContainer.spinPenaltyThreshold)
{
epreward -= spinPenaltyReward;
}
@ -441,7 +444,6 @@ public float rewardCalculate(float sceneReward,float mouseX,float movement)
return epreward;
}
// ML-AGENTS处理-------------------------------------------------------------------------------------------ML-AGENTS
// env开始执行初始化
public override void OnEpisodeBegin()
@ -452,26 +454,27 @@ public override void OnEpisodeBegin()
{
Cursor.lockState = CursorLockMode.Locked; // hide and lock the mouse
}
paramContainer.resetTimeBonusReward();
paramContainer.ResetTimeBonusReward();
//thisAgentObj.name = thisAgentObj.GetInstanceID().ToString();
if (gamemode == 0)
{
// train mode
targetCon.rollNewScene();
targetCon.RollNewScene();
}
else
{
// play mode
targetCon.playInitialize();
targetCon.PlayInitialize();
}
// give default Reward to Reward value will be used.
if (hudController.chartOn)
{
EnvUICon.initChart();
envUICon.InitChart();
}
raySensors.updateRayInfo(); // update raycast
raySensors.UpdateRayInfo(); // update raycast
}
// ML-AGENTS处理-------------------------------------------------------------------------------------------ML-AGENTS
// 观察情报
public override void CollectObservations(VectorSensor sensor)
@ -491,8 +494,8 @@ public override void CollectObservations(VectorSensor sensor)
rayDisResult = raySensors.rayDisResult; // 探测用RayDis结果 float[](raySensorNum,1)
targetStates = targetCon.targetState; // (6) targettype, target x,y,z, firebasesAreaDiameter
remainTime = targetCon.leftTime;
inAreaState = targetCon.getInAreaState();
gunReadyToggle = gunReady();
inAreaState = targetCon.GetInAreaState();
gunReadyToggle = GunReady();
//float[] focusEnemyObserve = RaySensors.focusEnemyInfo;// 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
//sensor.AddObservation(allEnemyNum); // 敌人数量 int
@ -510,7 +513,7 @@ public override void CollectObservations(VectorSensor sensor)
sensor.AddObservation(rayTagResult);
}
sensor.AddObservation(rayDisResult); // 探测用RayDis结果 float[](raySensorNum,1)
EnvUICon.updateStateText(targetStates, inAreaState, remainTime, gunReadyToggle, myObserve, rayTagResultOnehot, rayDisResult);
envUICon.UpdateStateText(targetStates, inAreaState, remainTime, gunReadyToggle, myObserve, rayTagResultOnehot, rayDisResult);
/*foreach(float aaa in rayDisResult)
{
Debug.Log(aaa);
@ -535,22 +538,22 @@ public override void OnActionReceived(ActionBuffers actionBuffers)
//应用输入
shoot = mouseShoot;
cameraControl(Mouse_X, 0);
moveAgent(vertical, horizontal);
raySensors.updateRayInfo(); // update raycast
CameraControl(Mouse_X, 0);
MoveAgent(vertical, horizontal);
raySensors.UpdateRayInfo(); // update raycast
//判断结束
float sceneReward = 0f;
float endReward = 0f;
(finishedState, sceneReward, endReward) = targetCon.checkOverAndRewards();
float thisRoundReward = rewardCalculate(sceneReward+ endReward,Mouse_X,Math.Abs(vertical)+Math.Abs(horizontal));
(finishedState, sceneReward, endReward) = targetCon.CheckOverAndRewards();
float thisRoundReward = RewardCalculate(sceneReward + endReward, Mouse_X, Math.Abs(vertical) + Math.Abs(horizontal));
if (hudController.chartOn)
{
EnvUICon.updateChart(thisRoundReward);
envUICon.UpdateChart(thisRoundReward);
}
else
{
EnvUICon.removeChart();
envUICon.RemoveChart();
}
//Debug.Log("reward = " + thisRoundReward);
if (finishedState != (int)TargetController.EndType.Running)
@ -562,11 +565,13 @@ public override void OnActionReceived(ActionBuffers actionBuffers)
switch (finishedState)
{
case (int)TargetController.EndType.Win:
Debug.LogWarning("Result|"+targetString+"|Win");
Debug.LogWarning("Result|" + targetString + "|Win");
break;
case (int)TargetController.EndType.Lose:
Debug.LogWarning("Result|"+targetString+"|Lose");
Debug.LogWarning("Result|" + targetString + "|Lose");
break;
default:
Debug.LogWarning("TypeError");
break;
@ -645,6 +650,5 @@ public override void Heuristic(in ActionBuffers actionsOut)
//continuousActions[1] = Mouse_Y;
//continuousActions[2] = timeLimit;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^continuous-Control^^^^^^^^^^^^^^^^^^^^^^
}
}

View File

@ -1,8 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.SideChannels;
using UnityEngine;
public class AimBotSideChennelController : MonoBehaviour
{
@ -20,7 +18,6 @@ public void Awake()
SideChannelManager.RegisterSideChannel(aimbotSideChannel);
}
// Side Channel
public void OnDestroy()
{
@ -31,4 +28,4 @@ public void OnDestroy()
SideChannelManager.UnregisterSideChannel(aimbotSideChannel);
}
}
}
}

View File

@ -1,9 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.SideChannels;
using System;
using Unity.MLAgents.SideChannels;
using UnityEngine;
public class AimbotSideChannel : SideChannel
{
@ -11,6 +8,7 @@ public AimbotSideChannel()
{
ChannelId = new Guid("8bbfb62a-99b4-457c-879d-b78b69066b5e");
}
protected override void OnMessageReceived(IncomingMessage msg)
{
var receivedString = msg.ReadString();
@ -30,7 +28,7 @@ public void SendDebugStatementToPython(string logString, string stackTrace, LogT
}
if (type == LogType.Error)
{
var stringToSend = "Error|"+logString;
var stringToSend = "Error|" + logString;
using (var msgOut = new OutgoingMessage())
{
msgOut.WriteString(stringToSend);
@ -38,4 +36,4 @@ public void SendDebugStatementToPython(string logString, string stackTrace, LogT
}
}
}
}
}

View File

@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine;
public class Enemy : MonoBehaviour
{
@ -22,12 +19,12 @@ public class Enemy : MonoBehaviour
/// <param name="target">目标</param>
/// <returns>目标target在扇形区域内返回true 否则返回false</returns>
void Start()
private void Start()
{
}
// Update is called once per frame
void Update()
private void Update()
{
//detactDeath();
//flag = IsInRange(angle, radius, transform, b);
@ -43,6 +40,7 @@ public bool IsInRange(float sectorAngle, float sectorRadius, Transform attacker,
float offsetAngle = Mathf.Acos(dot) * Mathf.Rad2Deg;
return offsetAngle < sectorAngle * .5f && direction.magnitude < sectorRadius;
}
/*
private void OnDrawGizmos()
{
@ -81,4 +79,4 @@ private void OnDrawGizmos()
}
}
*/
}
}

View File

@ -1,35 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyContainer : MonoBehaviour
{
public GameObject enemyPrefab;
public GameObject EnvironmentObj;
public GameObject TargetControllerObj;
public GameObject environmentObj;
public GameObject targetControllerObj;
private TargetController targetCon;
private void Start()
{
targetCon = TargetControllerObj.GetComponent<TargetController>();
targetCon = targetControllerObj.GetComponent<TargetController>();
}
// initialize enemy by random
public void randomInitEnemys(int EnemyNum)
public void RandomInitEnemys(int EnemyNum)
{
for (int i = 0; i < EnemyNum; i++)
{
float randX = UnityEngine.Random.Range(targetCon.minEnemyAreaX, targetCon.maxEnemyAreaX);
float randZ = UnityEngine.Random.Range(targetCon.minEnemyAreaZ, targetCon.maxEnemyAreaZ);
int enemyY = 1;
initEnemyAtHere(new Vector3(randX, enemyY, randZ));
InitEnemyAtHere(new Vector3(randX, enemyY, randZ));
}
}
// initialize enemy by random but not in block area
public void randomInitEnemysExcept(int enemyNum,Vector3 blockPosition,float sceneSize)
public void RandomInitEnemysExcept(int enemyNum, Vector3 blockPosition, float sceneSize)
{
float randX = 0f;
float randZ = 0f;
@ -37,7 +34,7 @@ public void randomInitEnemysExcept(int enemyNum,Vector3 blockPosition,float scen
{
randX = UnityEngine.Random.Range(targetCon.minEnemyAreaX, targetCon.maxEnemyAreaX);
randZ = UnityEngine.Random.Range(targetCon.minEnemyAreaZ, targetCon.maxEnemyAreaZ);
while (Vector3.Distance(blockPosition, new Vector3(randX,0f,randZ)) < sceneSize/2)
while (Vector3.Distance(blockPosition, new Vector3(randX, 0f, randZ)) < sceneSize / 2)
{
// while in scene area then respawn
Debug.Log("spawn enemy in area, re:roll");
@ -46,22 +43,22 @@ public void randomInitEnemysExcept(int enemyNum,Vector3 blockPosition,float scen
}
int enemyY = 1;
initEnemyAtHere(new Vector3(randX, enemyY, randZ));
InitEnemyAtHere(new Vector3(randX, enemyY, randZ));
}
}
// initialize enemy to thisPosition
public void initEnemyAtHere(Vector3 thisPosition)
public void InitEnemyAtHere(Vector3 thisPosition)
{
Instantiate(enemyPrefab, thisPosition + EnvironmentObj.transform.position, Quaternion.identity, this.transform);
Instantiate(enemyPrefab, thisPosition + environmentObj.transform.position, Quaternion.identity, this.transform);
}
// destroyEnemy delete enemyContainer's all enemy
public void destroyAllEnemys()
public void DestroyAllEnemys()
{
foreach (Transform childObj in this.transform)
{
childObj.GetComponent<states>().destroyMe();
childObj.GetComponent<States>().DestroyMe();
}
}
}
}

View File

@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using TMPro;
using UnityEngine;
@ -9,9 +7,9 @@
public class EnvironmentUIControl : MonoBehaviour
{
public GameObject TargetControllerObj;
public GameObject ParameterContainerObj;
public GameObject GroundCanvasObj;
public GameObject targetControllerObj;
public GameObject parameterContainerObj;
public GameObject groundCanvasObj;
public GameObject chartObj;
public GameObject HUDObj;
public TextMeshProUGUI remainTimeText;
@ -32,16 +30,16 @@ public class EnvironmentUIControl : MonoBehaviour
private bool resultActive = false;
// Start is called before the first frame update
void Start()
private void Start()
{
targetController = TargetControllerObj.GetComponent<TargetController>();
paramContainer = ParameterContainerObj.GetComponent<ParameterContainer>();
targetController = targetControllerObj.GetComponent<TargetController>();
paramContainer = parameterContainerObj.GetComponent<ParameterContainer>();
gaugeImg = gaugeImgObj.GetComponent<Image>();
hudController = HUDObj.GetComponent<HUDController>();
}
// Update is called once per frame
void Update()
private void Update()
{
// int remainTime = Convert.ToInt32(targetController.startTime + paramContainer.timeLimit - Time.time);
remainTimeText.text = "RemainTime:" + Convert.ToInt32(targetController.leftTime).ToString();
@ -55,22 +53,23 @@ void Update()
resultActive = false;
}
}
public void updateChart(float reward)
public void UpdateChart(float reward)
{
if (hudController.chartOn && realTimeRewardChart == null)
{
initChart();
InitChart();
}
step += 1;
realTimeRewardChart.AddXAxisData(Convert.ToString(step));
realTimeRewardChart.AddData(0, reward);
}
public void initChart()
public void InitChart()
{
if (hudController.chartOn && realTimeRewardChart == null)
{
Vector3 chartPos = new Vector3(-210f, 90f, 0f) * GroundCanvasObj.transform.localScale.x;
Vector3 chartPos = new Vector3(-210f, 90f, 0f) * groundCanvasObj.transform.localScale.x;
realTimeRewardChart = chartObj.AddComponent<LineChart>();
realTimeRewardChart.Init();
}
@ -78,15 +77,14 @@ public void initChart()
realTimeRewardChart.AddSerie<Line>("Rewards");
}
public void removeChart()
public void RemoveChart()
{
GameObject.Destroy(realTimeRewardChart);
realTimeRewardChart = null;
}
// show result in UI
public void showResult(int resultState)
public void ShowResult(int resultState)
{
switch (resultState)
{
@ -98,6 +96,7 @@ public void showResult(int resultState)
overTime = Time.time;
resultActive = true;
break;
case (int)TargetController.EndType.Lose:
//lose
Debug.Log("lose");
@ -106,13 +105,14 @@ public void showResult(int resultState)
overTime = Time.time;
resultActive = true;
break;
default:
break;
}
}
// update firebases target state gauge
public void updateTargetGauge(float firebasesBelong, float belongMaxPoint)
public void UpdateTargetGauge(float firebasesBelong, float belongMaxPoint)
{
if (firebasesBelong >= 0)
{
@ -129,8 +129,9 @@ public void updateTargetGauge(float firebasesBelong, float belongMaxPoint)
gaugeImg.fillAmount = -firebasesBelong / belongMaxPoint;
}
}
// update targetType text
public void updateTargetType(int targetInt)
public void UpdateTargetType(int targetInt)
{
switch (targetInt)
{
@ -138,22 +139,27 @@ public void updateTargetType(int targetInt)
targetTypeText.text = "GOTO";
targetTypeText.color = Color.blue;
break;
case (int)SceneBlockContainer.Targets.Attack:
targetTypeText.text = "Attack!";
targetTypeText.color = Color.red;
break;
case (int)SceneBlockContainer.Targets.Defence:
targetTypeText.text = "Defence";
targetTypeText.color = Color.green;
break;
case (int)SceneBlockContainer.Targets.Free:
targetTypeText.text = "Free";
targetTypeText.color = Color.yellow;
break;
case (int)SceneBlockContainer.Targets.Stay:
targetTypeText.text = "Stay";
targetTypeText.color = Color.white;
break;
default:
targetTypeText.text = "TYPE ERROR";
targetTypeText.color = Color.red;
@ -171,7 +177,7 @@ public void updateTargetType(int targetInt)
// targetState[5] = blockCont.thisBlock.belongRatio;
// float[] myObserve = { transform.localPosition.x/raySensors.viewDistance, transform.localPosition.y / raySensors.viewDistance, transform.localPosition.z / raySensors.viewDistance, transform.eulerAngles.y/360f }
// ??????????string??"targetType: 1.0 \r\n targetX: 2.0 \r\n"
public void updateStateText(float[] targetStates,float inAreaState,float remainTime, bool gunReadyToggle, float[] myObserve, float[] rayTagResultOnehot, float[] rayDisResult)
public void UpdateStateText(float[] targetStates, float inAreaState, float remainTime, bool gunReadyToggle, float[] myObserve, float[] rayTagResultOnehot, float[] rayDisResult)
{
stateBuilder.Clear();
@ -195,4 +201,4 @@ public void updateStateText(float[] targetStates,float inAreaState,float remainT
stateText.text = stateBuilder.ToString();
}
}
}

View File

@ -1,35 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HPBar : MonoBehaviour
{
GameObject thisObj;
GameObject BGOBJ;
GameObject gaugeImgOBJ;
private GameObject thisObj;
private GameObject backgroundObj;
private GameObject gaugeImgOBJ;
void Start()
private void Start()
{
thisObj = transform.parent.gameObject;
BGOBJ = transform.GetChild(0).gameObject;
gaugeImgOBJ = BGOBJ.transform.GetChild(0).gameObject;
backgroundObj = transform.GetChild(0).gameObject;
gaugeImgOBJ = backgroundObj.transform.GetChild(0).gameObject;
Vector3 v = Camera.main.transform.position - transform.position;
v.x = v.z = 0.0f;
transform.LookAt(Camera.main.transform.position - v);
transform.Rotate(0, 180, 0);
}
void Update()
private void Update()
{
Vector3 v = Camera.main.transform.position - transform.position;
v.x = v.z = 0.0f;
transform.LookAt(Camera.main.transform.position - v);
transform.Rotate(0, 180, 0);
float maxHP = thisObj.GetComponent<states>().MaxHP;
float nowHP = thisObj.GetComponent<states>().getnowHP();
float maxHP = thisObj.GetComponent<States>().maxHP;
float nowHP = thisObj.GetComponent<States>().GetnowHP();
gaugeImgOBJ.GetComponent<Image>().fillAmount = nowHP / maxHP;
}
}
}

View File

@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@ -12,7 +10,7 @@ public class HUDController : MonoBehaviour
public TMP_InputField chartOnTimeOutInputObj;
public TMP_InputField enemyNumInputObj;
public float chartOnTimeOut = 1;
public int enemyNum= 3;
public int enemyNum = 3;
public float chartOnTimeOutDefault = 120f;
private float chatOntimeStart = 0;
@ -20,7 +18,7 @@ private void Update()
{
if (chartOn)
{
if (Time.time - chatOntimeStart >= chartOnTimeOut )
if (Time.time - chatOntimeStart >= chartOnTimeOut)
{
chartOn = false;
chartOnToggleObj.isOn = false;
@ -28,13 +26,13 @@ private void Update()
}
}
public void onChartOnToggleChange()
public void OnChartOnToggleChange()
{
chatOntimeStart = Time.time;
chartOn = chartOnToggleObj.isOn;
}
public void onEnemyNumTextChange()
public void OnEnemyNumTextChange()
{
try
{
@ -46,7 +44,7 @@ public void onEnemyNumTextChange()
}
}
public void onChartTimeOutTextChange()
public void OnChartTimeOutTextChange()
{
try
{
@ -57,4 +55,4 @@ public void onChartTimeOutTextChange()
chartOnTimeOut = chartOnTimeOutDefault;
}
}
}
}

View File

@ -1,15 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
public class Onehot
{
private List<string> tags = new List<string>();
public List<List<float>> onehot = new List<List<float>>();
private float totalNum;
public void initialize(List<string> inputTags)
public void Initialize(List<string> inputTags)
{
tags = inputTags;
totalNum = tags.Count;
@ -21,7 +19,8 @@ public void initialize(List<string> inputTags)
onehot.Add(thisOnehot);
}
}
public List<float> encoder(string name = null)
public List<float> Encoder(string name = null)
{
if (name == null)
{
@ -34,7 +33,8 @@ public List<float> encoder(string name = null)
try
{
return onehot[tags.IndexOf(name)];
}catch(ArgumentOutOfRangeException)
}
catch (ArgumentOutOfRangeException)
{
List<float> allZeroOnehot = new List<float>();
for (int j = 0; j < totalNum; j++) allZeroOnehot.Add(0);
@ -43,8 +43,8 @@ public List<float> encoder(string name = null)
}
}
public string decoder(List<float> thisOnehot)
public string Decoder(List<float> thisOnehot)
{
return tags[onehot.IndexOf(thisOnehot)];
}
}
}

View File

@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParameterContainer : MonoBehaviour
@ -12,10 +10,10 @@ public class ParameterContainer : MonoBehaviour
private float agentDistance;
private int agentInArea;
[Header("Env")]
public bool lockMouse = false;
public float Damage = 50; // damage to enemy
public float damage = 50; // damage to enemy
public float fireRate = 0.5f;
public int timeLimit = 30;
public bool lockCameraX = false;
@ -25,80 +23,106 @@ public class ParameterContainer : MonoBehaviour
public float spinPenaltyThreshold = 50;
public float facingInviewEnemyDisCOEF = 0.5f;
[Header("Dynamic Defaut Rewards")]
//[Tooltip("Hit Enemy reward")]
//public float hitRewardDefault = 60.0f;
[Tooltip("Free mode Hit Enemy reward")]
public float hitTargetRewardDefault = 60.0f;
//[Tooltip("Enemy down reward")]
//public float killRewardDefault = 60.0f;
[Tooltip("Enemy down in area Reward")]
public float killTargetEnemyRewardDefault = 100.0f;
[Tooltip("stay in firebasesArea reward")]
public float inAreaRewardDefault = 10.0f;
[Tooltip("free left time bonus reward. ALLR + leftTime * r")]
public float freeTimeBonusPerSec = 1.0f;
[Tooltip("target left time bonus reward. ALLR + leftTime * r")]
public float targetTimeBonusPerSec = 3.0f;
[Tooltip("in area left time bonus reward. ALLR + leftTime * r")]
public float areaTimeBonusPerSec = 1.0f;
[Tooltip("distance reward reward = r*(1-(nowDis/startDis))")]
public float distanceReward = 20.0f;
[Tooltip("facing to Target distance reward reward = r*(1-(nowDis/startDis))")]
public float facingTargetReward = 20.0f;
[Space(10)]
[Tooltip("Goto Win reward")]
public float goWinRewardDefault = 100.0f;
[Tooltip("Attack Win reward")]
public float attackWinRewardDefault = 100.0f;
[Tooltip("Defence Win reward")]
public float defenceWinRewardDefault = 100.0f;
[Tooltip("free Win reward")]
public float freeWinRewardDefault = 100.0f;
[Header("Static Rewards")]
[Tooltip("Nothing happened reward")]
public float nonReward = -0.05f;
[Tooltip("Episode Lose reward")]
public float loseReward = -0.05f;
[Tooltip("Agent Do shoot action reward")]
public float shootReward = -0.1f;
[Tooltip("Hit Not target Enemy reward")]
public float hitReward = 30.0f;
[Tooltip("Not Target Enemy down reward")]
public float killReward = 40.0f;
[Tooltip("Agent Do shoot action but gun is not read")]
public float shootWithoutReadyReward = -0.15f;
[Tooltip("Kill bonus reward stack to nothing happend reward")]
public float killBonusReward = 0.0f;
[Tooltip("Facing to enemy's reward")]
public float facingReward = 2.0f;
[Tooltip("Shoot at target area but didn't hit enemy")]
public float shootTargetAreaReward = 5.0f;
[Header("Penalty Rewards")]
[Tooltip("move Penalty Reward")]
public float movePenalty = 0f;
[Tooltip("spiiiiiiin Panalty Reward")]
public float spinPenalty = 0f;
[Tooltip("while move mouse a little bit's penalty")]
public float mousePenalty = 0f;
[Header("Dynamic Rewards")]
[Tooltip("Free mode Hit Enemy reward")]
public float hitTargetReward = 60.0f;
[Tooltip("Enemy down in area Reward")]
public float killTargetEnemyReward = 80.0f;
[Tooltip("stay in firebasesArea reward")]
public float inAreaReward = 1.0f;
[Space(10)]
[Tooltip("go Win reward")]
public float goWinReward = 50.0f;
[Tooltip("attack Win reward")]
public float attackWinReward = 50.0f;
[Tooltip("defence Win reward")]
public float defenceWinReward = 50.0f;
[Tooltip("free Win reward")]
public float freeWinReward = 50.0f;
@ -122,7 +146,7 @@ private void Update()
// get target distance and in area
if (targetCon.targetTypeInt is (int)SceneBlockContainer.Targets.Go or (int)SceneBlockContainer.Targets.Attack)
{
(agentDistance, agentInArea) = blockCont.getAgentTargetDistanceAndInside(agentObj.transform.position);
(agentDistance, agentInArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
// attack goto or defence target
if (agentInArea == 1)
{
@ -153,10 +177,10 @@ private void Update()
freeWinReward = freeWinRewardDefault;
}
public void resetTimeBonusReward()
public void ResetTimeBonusReward()
{
areaTimeBonus = areaTimeBonusPerSec * timeLimit;
freeTimeBonus = freeTimeBonusPerSec * timeLimit;
targetInAreaTime = 0f;
}
}
}

View File

@ -1,12 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
/*该scrip用于创建复数条ray于视角内并探测被ray射到的物体*/
public class RaySensors : MonoBehaviour
{
public Camera agentCam;
@ -16,32 +13,35 @@ public class RaySensors : MonoBehaviour
public GameObject agentCanvas;
[SerializeField, Range(0, 500)] public float viewDistance = 100; // how long the ray can detect
//[SerializeField, Range(0, 1)] public float totalRange = 1f; // Total view range Max = 1
[SerializeField, Range(0, 1)] public float focusRange = 0.15f; // center focus range
public int halfOuterRayNum = 3; // >=2
public int focusRayNum = 5; // >= 1 and must be odd num!
[Header("InGameLineSetting")]
public bool showInGameRay = true;
public bool showDebugRay = true;
public bool showInGameRayInfo = true;
public float lineWidth = 0.05f;
[Header("RayCastResult")]
public float[] rayTagResult;
public List<float> rayTagResultOneHot;
public float[] rayDisResult;
[System.NonSerialized] public int totalRayNum;
private string myTag = "";
GameObject[] linesOBJ;
GameObject[] rayInfoOBJ;
LineRenderer[] lineRenderers;
rayInfoUI[] rayInfoUIs;
private GameObject[] linesOBJ;
private GameObject[] rayInfoOBJ;
private LineRenderer[] lineRenderers;
private RayInfoUI[] rayInfoUIs;
public List<GameObject> inViewEnemies = new List<GameObject>();
private List<string> tags = new List<string> {"Wall","Enemy"};
private List<string> tags = new List<string> { "Wall", "Enemy" };
private Onehot oneHotTags = new Onehot();
private void Start()
{
@ -52,8 +52,8 @@ private void Start()
linesOBJ = new GameObject[totalRayNum];
lineRenderers = new LineRenderer[totalRayNum];
rayInfoOBJ = new GameObject[totalRayNum];
rayInfoUIs = new rayInfoUI[totalRayNum];
oneHotTags.initialize(tags);
rayInfoUIs = new RayInfoUI[totalRayNum];
oneHotTags.Initialize(tags);
for (int i = 0; i < totalRayNum; i++)
{
linesOBJ[i] = new GameObject();
@ -64,20 +64,21 @@ private void Start()
lineRenderers[i].material = lineMeterial;
rayInfoOBJ[i] = (GameObject)Instantiate(rayInfoPrefab);
rayInfoOBJ[i].transform.SetParent(agentCanvas.transform,false);
rayInfoOBJ[i].transform.SetParent(agentCanvas.transform, false);
rayInfoOBJ[i].name = "rayInfo-" + Convert.ToString(i);
rayInfoUIs[i] = rayInfoOBJ[i].GetComponent<rayInfoUI>();
rayInfoUIs[i] = rayInfoOBJ[i].GetComponent<RayInfoUI>();
}
}
public int tagToInt(string tag)
public int TagToInt(string tag)
{
switch (tag)
{
case "Wall":
return 1;
default:
if(tag != myTag)
if (tag != myTag)
{
return 2;
}
@ -85,7 +86,7 @@ public int tagToInt(string tag)
}
}
private void singleRaycastUpdate(Ray ray,LineRenderer thisLineRenderer,rayInfoUI thisRayInfoUI, out float rayTagResult, out float rayDisResult)
private void SingleRaycastUpdate(Ray ray, LineRenderer thisLineRenderer, RayInfoUI thisRayInfoUI, out float rayTagResult, out float rayDisResult)
{
// get Raycast hit infomation and return Tag and distance
RaycastHit thisHit;
@ -96,8 +97,8 @@ private void singleRaycastUpdate(Ray ray,LineRenderer thisLineRenderer,rayInfoUI
if (Physics.Raycast(ray, out thisHit, viewDistance)) // 若在viewDistance范围内有碰撞
{
rayInfoText = thisHit.collider.tag;
rayTagResult = tagToInt(rayInfoText);
rayTagResultOneHot.AddRange(oneHotTags.encoder(rayInfoText));
rayTagResult = TagToInt(rayInfoText);
rayTagResultOneHot.AddRange(oneHotTags.Encoder(rayInfoText));
rayDisResult = thisHit.distance;
lineLength = rayDisResult;
rayInfoText += "\n" + Convert.ToString(rayDisResult);
@ -108,13 +109,16 @@ private void singleRaycastUpdate(Ray ray,LineRenderer thisLineRenderer,rayInfoUI
case 1:// Wall
rayColor = Color.white;
break;
case 2: // Enemy
rayColor = Color.red;
inViewEnemies.Add(thisHit.transform.gameObject);
break;
case -1: // Hit Nothing
rayColor = Color.gray;
break;
default: // default,got wrong
rayColor = Color.cyan;
break;
@ -122,7 +126,7 @@ private void singleRaycastUpdate(Ray ray,LineRenderer thisLineRenderer,rayInfoUI
}
else // 若在viewDistance范围无碰撞
{
rayTagResultOneHot.AddRange(oneHotTags.encoder());
rayTagResultOneHot.AddRange(oneHotTags.Encoder());
rayTagResult = -1f;
rayDisResult = -1f;
//输出log
@ -132,14 +136,14 @@ private void singleRaycastUpdate(Ray ray,LineRenderer thisLineRenderer,rayInfoUI
rayInfoPosition = ray.origin + (ray.direction * lineLength);
if (showInGameRay)
{
drawLine(ray, lineLength, thisLineRenderer, rayColor);
DrawLine(ray, lineLength, thisLineRenderer, rayColor);
}
else
{
turnOffLine(thisLineRenderer, rayColor);
TurnOffLine(thisLineRenderer, rayColor);
}
// drawRay in game
if (showInGameRayInfo) thisRayInfoUI.updateInfo(rayInfoText, rayInfoPosition, rayColor,TPSCam);
if (showInGameRayInfo) thisRayInfoUI.UpdateInfo(rayInfoText, rayInfoPosition, rayColor, TPSCam);
// Show log
if (showDebugRay) Debug.DrawRay(ray.origin, ray.direction * viewDistance, rayColor); // drawRay in debug
// Debug.Log(ray.origin + ray.direction);
@ -147,7 +151,7 @@ private void singleRaycastUpdate(Ray ray,LineRenderer thisLineRenderer,rayInfoUI
// Debug.Log(tagToInt(thisHit.collider.tag));
}
private void drawLine(Ray ray,float lineLength, LineRenderer thisLineRenderer, Color lineColor)
private void DrawLine(Ray ray, float lineLength, LineRenderer thisLineRenderer, Color lineColor)
{
thisLineRenderer.startColor = lineColor;
thisLineRenderer.endColor = lineColor;
@ -157,7 +161,7 @@ private void drawLine(Ray ray,float lineLength, LineRenderer thisLineRenderer, C
thisLineRenderer.SetPosition(1, ray.origin + (ray.direction * lineLength));
}
private void turnOffLine(LineRenderer thisLineRenderer, Color lineColor)
private void TurnOffLine(LineRenderer thisLineRenderer, Color lineColor)
{
thisLineRenderer.startColor = lineColor;
thisLineRenderer.endColor = lineColor;
@ -167,7 +171,7 @@ private void turnOffLine(LineRenderer thisLineRenderer, Color lineColor)
thisLineRenderer.SetPosition(1, new Vector3(0, 0, 0));
}
public void updateRayInfo()
public void UpdateRayInfo()
{
float focusLEdge = agentCam.pixelWidth * (1 - focusRange) / 2;
float focusREdge = agentCam.pixelWidth * (1 + focusRange) / 2;
@ -178,19 +182,19 @@ public void updateRayInfo()
{
Vector3 point = new Vector3(i * focusLEdge / (halfOuterRayNum - 1), thisCamPixelHeight / 2, 0);
Ray thisRay = agentCam.ScreenPointToRay(point);
singleRaycastUpdate(thisRay,lineRenderers[i], rayInfoUIs[i] , out rayTagResult[i], out rayDisResult[i]);
SingleRaycastUpdate(thisRay, lineRenderers[i], rayInfoUIs[i], out rayTagResult[i], out rayDisResult[i]);
}
for (int i = 0; i < halfOuterRayNum; i++) // create right outside rays; focusRightEdge ~ MaxPixelHeight
{
Vector3 point = new Vector3(focusREdge + (i * focusLEdge / (halfOuterRayNum - 1)), thisCamPixelHeight / 2, 0);
Ray thisRay = agentCam.ScreenPointToRay(point);
singleRaycastUpdate(thisRay, lineRenderers[halfOuterRayNum + i], rayInfoUIs[halfOuterRayNum + i], out rayTagResult[halfOuterRayNum + i], out rayDisResult[halfOuterRayNum + i]);
SingleRaycastUpdate(thisRay, lineRenderers[halfOuterRayNum + i], rayInfoUIs[halfOuterRayNum + i], out rayTagResult[halfOuterRayNum + i], out rayDisResult[halfOuterRayNum + i]);
}
for (int i = 0; i < focusRayNum; i++) // create center focus rays; focusLeftEdge ~ focusLeftEdge
{
Vector3 point = new Vector3(focusLEdge + ((i + 1) * (focusREdge - focusLEdge) / (focusRayNum + 1)), thisCamPixelHeight / 2, 0);
Ray thisRay = agentCam.ScreenPointToRay(point);
singleRaycastUpdate(thisRay, lineRenderers[halfOuterRayNum * 2 + i], rayInfoUIs[halfOuterRayNum * 2 + i], out rayTagResult[halfOuterRayNum*2 + i], out rayDisResult[halfOuterRayNum*2 + i]);
SingleRaycastUpdate(thisRay, lineRenderers[halfOuterRayNum * 2 + i], rayInfoUIs[halfOuterRayNum * 2 + i], out rayTagResult[halfOuterRayNum * 2 + i], out rayDisResult[halfOuterRayNum * 2 + i]);
}
}
}
}

View File

@ -1,12 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class SceneBlock : MonoBehaviour
{
public GameObject FirebasesAreaObj;
public GameObject EnemyContainerObj;
public GameObject firebasesAreaObj;
public GameObject enemyContainerObj;
public float group1InareaNum = 0;
public float group2InareaNum = 0;
public float belongRatio = 0;
@ -15,12 +13,15 @@ public class SceneBlock : MonoBehaviour
public float firebasesAreaScale;
public float firebasesAreaDiameter;
public enum SceneType { Go, Attack, Defence }
public enum SceneType
{ Go, Attack, Defence }
public SceneType sceneType;
public bool isDestroyed = false;
// firebase state
public string group1Tag = "Player";
public string group2Tag = "Enemy";
public float belongMaxPoint = 10f;
public float firebasesBelong; // -10 mean's belon to group2Tag 10 = belon to group1Tag
@ -29,15 +30,25 @@ public enum SceneType { Go, Attack, Defence }
private float addPointEachInterval; // add point in each interval
private float intervalStart;
private GameObject EnvironmentObj;
private GameObject environmentObj;
public GameObject[] group1Objs;
public GameObject[] group2Objs;
// Start is called before the first frame update
void Start()
private void Start()
{
firebasesAreaPosition = transform.position + FirebasesAreaObj.transform.position;
firebasesAreaScale = FirebasesAreaObj.transform.localScale.x;
// if firebasesAreaObj is null, find sub object by name
if (firebasesAreaObj == null)
{
firebasesAreaObj = transform.Find("FirebasesArea").gameObject;
}
// if enemyContainerObj is null, find them by name
if (enemyContainerObj == null)
{
enemyContainerObj = transform.Find("EnemyContainer").gameObject;
}
firebasesAreaPosition = transform.position + firebasesAreaObj.transform.position;
firebasesAreaScale = firebasesAreaObj.transform.localScale.x;
firebasesAreaDiameter = firebasesAreaScale * blockSize;
firebasesBelong = -belongMaxPoint;
addPointEachInterval = belongMaxPoint / (stayTimeNeeded / addPointInterval);
@ -45,13 +56,13 @@ void Start()
}
// Update is called once per frame
void Update()
private void Update()
{
if (Time.time - intervalStart >= addPointInterval)
{
// update belong ratio every addPointInterval scecond
group1InareaNum = getInAreaNumber(group1Tag);
group2InareaNum = getInAreaNumber(group2Tag);
group1InareaNum = GetInAreaNumber(group1Tag);
group2InareaNum = GetInAreaNumber(group2Tag);
belongRatio = group1InareaNum - group2InareaNum;
if (belongRatio > 0)
{
@ -76,24 +87,24 @@ void Update()
}
//Initialize this scene block should be excuted after enemy created
public void initBlock(GameObject envObj)
public void InitBlock(GameObject envObj)
{
//Buffer all Player or enemy obj int this environment to list
EnvironmentObj = envObj;
environmentObj = envObj;
GameObject[] allGroup1Objs = GameObject.FindGameObjectsWithTag(group1Tag);
GameObject[] allGroup2Objs = GameObject.FindGameObjectsWithTag(group2Tag);
List<GameObject> group1ObjsList = new List<GameObject>();
List<GameObject> group2ObjsList = new List<GameObject>();
foreach (GameObject obj in allGroup1Objs)
{
if (obj.transform.root.gameObject == envObj && !obj.GetComponent<states>().isDead)
if (obj.transform.root.gameObject == envObj && !obj.GetComponent<States>().isDead)
{
group1ObjsList.Add(obj);
}
}
foreach (GameObject obj in allGroup2Objs)
{
if(obj.transform.root.gameObject == envObj && !obj.GetComponent<states>().isDead)
if (obj.transform.root.gameObject == envObj && !obj.GetComponent<States>().isDead)
{
group2ObjsList.Add(obj);
}
@ -103,13 +114,13 @@ public void initBlock(GameObject envObj)
}
//check game over 0=notover 1=win
public int checkOver()
public int CheckOver()
{
return 0;
}
// get in area player number by tag
public float getInAreaNumber(string thisTag)
public float GetInAreaNumber(string thisTag)
{
float inAreaNum = 0;
float dist = 0f;
@ -117,7 +128,7 @@ public float getInAreaNumber(string thisTag)
int index = 0;
if (thisTag == group1Tag)
{
foreach(GameObject obj in group1Objs)
foreach (GameObject obj in group1Objs)
{
// if object is dead then delete it from list
if (obj == null)
@ -129,7 +140,7 @@ public float getInAreaNumber(string thisTag)
}
else
{
(dist, isInarea) = getDist_inArea(obj.transform.position);
(dist, isInarea) = GetDistInArea(obj.transform.position);
if (isInarea != 0f)
{
inAreaNum += 1;
@ -137,9 +148,10 @@ public float getInAreaNumber(string thisTag)
}
index++;
}
}else if(thisTag == group2Tag)
}
else if (thisTag == group2Tag)
{
foreach(GameObject obj in group2Objs)
foreach (GameObject obj in group2Objs)
{
// if object is dead then delete it from list
if (obj == null)
@ -151,7 +163,7 @@ public float getInAreaNumber(string thisTag)
}
else
{
(dist, isInarea) = getDist_inArea(obj.transform.position);
(dist, isInarea) = GetDistInArea(obj.transform.position);
if (isInarea != 0f)
{
inAreaNum += 1;
@ -168,10 +180,10 @@ public float getInAreaNumber(string thisTag)
}
// get this position and target's distance and is in firebase area
public (float, int) getDist_inArea(Vector3 thisPosition)
public (float, int) GetDistInArea(Vector3 thisPosition)
{
thisPosition.y = FirebasesAreaObj.transform.position.y;
float dist = Vector3.Distance(thisPosition, FirebasesAreaObj.transform.position) - (firebasesAreaDiameter/2);
thisPosition.y = firebasesAreaObj.transform.position.y;
float dist = Vector3.Distance(thisPosition, firebasesAreaObj.transform.position) - (firebasesAreaDiameter / 2);
int isinarea = 0;
if (dist <= 0)
{
@ -186,13 +198,13 @@ public float getInAreaNumber(string thisTag)
}
//destroy this block
public void destroyMe()
public void DestroyMe()
{
Destroy(this.gameObject);
foreach (Transform childObj in EnemyContainerObj.transform)
foreach (Transform childObj in enemyContainerObj.transform)
{
childObj.GetComponent<states>().destroyMe();
childObj.GetComponent<States>().DestroyMe();
}
isDestroyed = true;
}
}
}

View File

@ -1,13 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SceneBlockContainer : MonoBehaviour
{
public enum Targets { Free, Go, Attack, Defence, Stay, Num };// Num is use for get total target bumber
public enum Targets
{ Free, Go, Attack, Defence, Stay, Num };// Num is use for get total target bumber
public float sceneSize = 10f;
public GameObject EnvironmentObj;
public GameObject environmentObj;
public GameObject[] attackBlockPrefabs = new GameObject[1];
public GameObject[] goBlockPrefabs = new GameObject[1];
public GameObject[] defencePrefabs = new GameObject[1];
@ -18,38 +17,41 @@ public class SceneBlockContainer : MonoBehaviour
private void Start()
{
}
// create block random
public void createNewBlock(Targets targetType, int blockType, Vector3 blockPosition,string tag1 = "Player", string tag2 = "Enemy")
public void CreateNewBlock(Targets targetType, int blockType, Vector3 blockPosition, string tag1 = "Player", string tag2 = "Enemy")
{
// check if thisBlock is deleted
if (thisBlockObj != null)
{
// delete thisBlock
Debug.LogWarning("Block not clear!");
destroyBlock();
DestroyBlock();
}
// choose target type
switch (targetType)
{
case Targets.Go:
// goto
thisBlockObj = Instantiate(goBlockPrefabs[blockType], blockPosition + EnvironmentObj.transform.position, Quaternion.identity, transform);
thisBlockObj = Instantiate(goBlockPrefabs[blockType], blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
thisBlock = thisBlockObj.GetComponent<SceneBlock>();
thisBlock.group1Tag = tag1;
thisBlock.group2Tag = tag2;
sceneSize = thisBlock.blockSize;
break;
case Targets.Attack:
// attack
thisBlockObj = Instantiate(attackBlockPrefabs[blockType], blockPosition+ EnvironmentObj.transform.position, Quaternion.identity, transform);
thisBlockObj = Instantiate(attackBlockPrefabs[blockType], blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
thisBlock = thisBlockObj.GetComponent<SceneBlock>();
thisBlock.group1Tag = tag1;
thisBlock.group2Tag = tag2;
sceneSize = thisBlock.blockSize;
break;
case Targets.Defence:
// defence
thisBlockObj = Instantiate(defencePrefabs[blockType], blockPosition + EnvironmentObj.transform.position, Quaternion.identity, transform);
thisBlockObj = Instantiate(defencePrefabs[blockType], blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
thisBlock = thisBlockObj.GetComponent<SceneBlock>();
thisBlock.group1Tag = tag1;
thisBlock.group2Tag = tag2;
@ -59,23 +61,23 @@ public void createNewBlock(Targets targetType, int blockType, Vector3 blockPosit
}
// delete thisBlock
public void destroyBlock()
public void DestroyBlock()
{
if (thisBlock != null)
{
thisBlock.destroyMe();
thisBlock.DestroyMe();
}
thisBlockObj = null;
thisBlock = null;
}
public (float, int) getAgentTargetDistanceAndInside(Vector3 agentPosition)
public (float, int) GetAgentTargetDistanceAndInside(Vector3 agentPosition)
{
return thisBlock.getDist_inArea(agentPosition);
return thisBlock.GetDistInArea(agentPosition);
}
public void initializeBlock(GameObject envObj)
public void InitializeBlock(GameObject envObj)
{
thisBlock.initBlock(envObj);
thisBlock.InitBlock(envObj);
}
}
}

View File

@ -1,22 +1,22 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml.Serialization;
using UnityEngine;
using Random = UnityEngine.Random;
public class TargetController : MonoBehaviour
{
public GameObject EnvironmentObj;
public GameObject AgentObj;
public GameObject environmentObj;
public GameObject agentObj;
public GameObject HUDObj;
public GameObject SceneBlockContainerObj;
public GameObject EnemyContainerObj;
public GameObject ParameterContainerObj;
public GameObject EnvironmentUIObj;
public GameObject WorldUIObj;
public GameObject sceneBlockContainerObj;
public GameObject enemyContainerObj;
public GameObject parameterContainerObj;
public GameObject environmentUIObj;
public GameObject worldUIObj;
// area
public GameObject edgeUp;
public GameObject edgeDown;
public GameObject edgeLeft;
public GameObject edgeRight;
@ -24,6 +24,7 @@ public class TargetController : MonoBehaviour
//group
public string group1Tag = "Player";
public string group2Tag = "Enemy";
public float minEnemyAreaX;
@ -43,7 +44,10 @@ public class TargetController : MonoBehaviour
[System.NonSerialized] public int targetTypeInt;
public float[] targetState = new float[6];
public enum EndType { Win, Lose, Running, Num };
public enum EndType
{ Win, Lose, Running, Num };
[System.NonSerialized] public int targetNum = 0;
private Dictionary<int, float[]> oneHotRarget = new Dictionary<int, float[]>();
@ -64,11 +68,12 @@ public enum EndType { Win, Lose, Running, Num };
private HUDController hudCon;
private RaySensors raySensors;
private StartSeneData startSceneData;
// start scene datas 0=train 1=play
private int gamemode;
// Start is called before the first frame update
void Start()
private void Start()
{
minEnemyAreaX = edgeLeft.transform.localPosition.x + 1.0f;
maxEnemyAreaX = edgeRight.transform.localPosition.x - 1.0f;
@ -80,14 +85,14 @@ void Start()
minAgentAreaZ = edgeDown.transform.localPosition.z + 1.0f;
maxAgentAreaZ = edgeAgent_Enemy.transform.localPosition.z - 1.0f;
blockCont = SceneBlockContainerObj.GetComponent<SceneBlockContainer>();
envUICon = EnvironmentUIObj.GetComponent<EnvironmentUIControl>();
enemyCont = EnemyContainerObj.GetComponent<EnemyContainer>();
agentCharaCon = AgentObj.GetComponent<CharacterController>();
paramCon = ParameterContainerObj.GetComponent<ParameterContainer>();
worldUICon = WorldUIObj.GetComponent<WorldUIController>();
blockCont = sceneBlockContainerObj.GetComponent<SceneBlockContainer>();
envUICon = environmentUIObj.GetComponent<EnvironmentUIControl>();
enemyCont = enemyContainerObj.GetComponent<EnemyContainer>();
agentCharaCon = agentObj.GetComponent<CharacterController>();
paramCon = parameterContainerObj.GetComponent<ParameterContainer>();
worldUICon = worldUIObj.GetComponent<WorldUIController>();
hudCon = HUDObj.GetComponent<HUDController>();
raySensors = AgentObj.GetComponent<RaySensors>();
raySensors = agentObj.GetComponent<RaySensors>();
freeProb = 1 - attackProb - gotoProb - defenceProb;
targetNum = (int)SceneBlockContainer.Targets.Num;
if (freeProb < 0)
@ -136,7 +141,7 @@ private void Update()
}
}
public void rollNewScene()
public void RollNewScene()
{
startTime = Time.time;// Reset StartTime as now time
leftTime = paramCon.timeLimit - Time.time + startTime;
@ -147,19 +152,19 @@ public void rollNewScene()
Debug.Log("GOTO THIS TARGET!");
targetTypeInt = (int)SceneBlockContainer.Targets.Go;
int randBlockType = Random.Range(0, blockCont.goBlockPrefabs.Length);
// get choosed scene size
// get choosed scene size
sceneSize = blockCont.goBlockPrefabs[randBlockType].GetComponent<SceneBlock>().blockSize;
float randX = UnityEngine.Random.Range(minEnemyAreaX + sceneSize/2 + 1f, maxEnemyAreaX - sceneSize/2 - 1f);
float randZ = UnityEngine.Random.Range(minEnemyAreaZ + sceneSize/2 + 1f, maxEnemyAreaZ - sceneSize/2 - 1f);
float randX = UnityEngine.Random.Range(minEnemyAreaX + sceneSize / 2 + 1f, maxEnemyAreaX - sceneSize / 2 - 1f);
float randZ = UnityEngine.Random.Range(minEnemyAreaZ + sceneSize / 2 + 1f, maxEnemyAreaZ - sceneSize / 2 - 1f);
targetPosition = new Vector3(randX, 0f, randZ);
// Init Agent position
moveAgentToSpwanArea();
MoveAgentToSpwanArea();
// init scene block
blockCont.destroyBlock();
blockCont.createNewBlock(SceneBlockContainer.Targets.Go, randBlockType, targetPosition, group1Tag, group2Tag);
enemyCont.destroyAllEnemys();
enemyCont.randomInitEnemysExcept(hudCon.enemyNum, targetPosition, sceneSize);
blockCont.thisBlock.initBlock(EnvironmentObj);
blockCont.DestroyBlock();
blockCont.CreateNewBlock(SceneBlockContainer.Targets.Go, randBlockType, targetPosition, group1Tag, group2Tag);
enemyCont.DestroyAllEnemys();
enemyCont.RandomInitEnemysExcept(hudCon.enemyNum, targetPosition, sceneSize);
blockCont.thisBlock.InitBlock(environmentObj);
// set startDistance
firstRewardFlag = true;
}
@ -169,19 +174,19 @@ public void rollNewScene()
Debug.Log("ATTACK!");
targetTypeInt = (int)SceneBlockContainer.Targets.Attack;
int randBlockType = Random.Range(0, blockCont.attackBlockPrefabs.Length);
// get choosed scene size
// get choosed scene size
sceneSize = blockCont.attackBlockPrefabs[randBlockType].GetComponent<SceneBlock>().blockSize;
float randX = UnityEngine.Random.Range(minEnemyAreaX + sceneSize/2 + 1f, maxEnemyAreaX - sceneSize/2 - 1f);
float randZ = UnityEngine.Random.Range(minEnemyAreaZ + sceneSize/2 + 1f, maxEnemyAreaZ - sceneSize/2 - 1f);
float randX = UnityEngine.Random.Range(minEnemyAreaX + sceneSize / 2 + 1f, maxEnemyAreaX - sceneSize / 2 - 1f);
float randZ = UnityEngine.Random.Range(minEnemyAreaZ + sceneSize / 2 + 1f, maxEnemyAreaZ - sceneSize / 2 - 1f);
targetPosition = new Vector3(randX, 0f, randZ);
// Init Agent position
moveAgentToSpwanArea();
MoveAgentToSpwanArea();
// init scene block
blockCont.destroyBlock();
blockCont.createNewBlock(SceneBlockContainer.Targets.Attack, randBlockType, targetPosition, group1Tag, group2Tag);
enemyCont.destroyAllEnemys();
enemyCont.randomInitEnemysExcept(hudCon.enemyNum, targetPosition, sceneSize);
blockCont.thisBlock.initBlock(EnvironmentObj);
blockCont.DestroyBlock();
blockCont.CreateNewBlock(SceneBlockContainer.Targets.Attack, randBlockType, targetPosition, group1Tag, group2Tag);
enemyCont.DestroyAllEnemys();
enemyCont.RandomInitEnemysExcept(hudCon.enemyNum, targetPosition, sceneSize);
blockCont.thisBlock.InitBlock(environmentObj);
// set startDistance
firstRewardFlag = true;
targetEnemySpawnFinish = false;
@ -192,19 +197,19 @@ public void rollNewScene()
Debug.Log("DEFENCE!");
targetTypeInt = (int)SceneBlockContainer.Targets.Defence;
int randBlockType = Random.Range(0, blockCont.attackBlockPrefabs.Length);
// get choosed scene size
// get choosed scene size
sceneSize = blockCont.defencePrefabs[randBlockType].GetComponent<SceneBlock>().blockSize;
float randX = UnityEngine.Random.Range(minEnemyAreaX + sceneSize/2 + 1f, maxEnemyAreaX - sceneSize/2 - 1f);
float randZ = UnityEngine.Random.Range(minEnemyAreaZ + sceneSize/2 + 1f, maxEnemyAreaZ - sceneSize/2 - 1f);
float randX = UnityEngine.Random.Range(minEnemyAreaX + sceneSize / 2 + 1f, maxEnemyAreaX - sceneSize / 2 - 1f);
float randZ = UnityEngine.Random.Range(minEnemyAreaZ + sceneSize / 2 + 1f, maxEnemyAreaZ - sceneSize / 2 - 1f);
targetPosition = new Vector3(randX, 0f, randZ);
// Init Agent position
moveAgentTo(targetPosition);
MoveAgentTo(targetPosition);
// init scene block
blockCont.destroyBlock();
blockCont.createNewBlock(SceneBlockContainer.Targets.Defence, randBlockType, targetPosition, group1Tag, group2Tag);
enemyCont.destroyAllEnemys();
enemyCont.randomInitEnemysExcept(hudCon.enemyNum, targetPosition, sceneSize);
blockCont.thisBlock.initBlock(EnvironmentObj);
blockCont.DestroyBlock();
blockCont.CreateNewBlock(SceneBlockContainer.Targets.Defence, randBlockType, targetPosition, group1Tag, group2Tag);
enemyCont.DestroyAllEnemys();
enemyCont.RandomInitEnemysExcept(hudCon.enemyNum, targetPosition, sceneSize);
blockCont.thisBlock.InitBlock(environmentObj);
// set startDistance
firstRewardFlag = true;
}
@ -212,23 +217,23 @@ public void rollNewScene()
{
//Debug.Log("Free");
targetTypeInt = (int)SceneBlockContainer.Targets.Free;
enemyCont.destroyAllEnemys();
enemyCont.randomInitEnemys(hudCon.enemyNum);
moveAgentToSpwanArea();
blockCont.destroyBlock();
enemyCont.DestroyAllEnemys();
enemyCont.RandomInitEnemys(hudCon.enemyNum);
MoveAgentToSpwanArea();
blockCont.DestroyBlock();
}
updateTargetStates();
envUICon.updateTargetType(targetTypeInt);
UpdateTargetStates();
envUICon.UpdateTargetType(targetTypeInt);
}
// get target observation states
public void updateTargetStates()
public void UpdateTargetStates()
{
// targettype, x,y,z, firebasesAreaDiameter
if (targetTypeInt == (int)SceneBlockContainer.Targets.Free)
{
targetState[0] = targetTypeInt;
for(int i = 1; i < targetState.Length; i++)
for (int i = 1; i < targetState.Length; i++)
targetState[i] = 0f;
}
else
@ -246,7 +251,7 @@ public void updateTargetStates()
}
// move Agent into Agent Spawn Area
public void moveAgentToSpwanArea()
public void MoveAgentToSpwanArea()
{
float randX = UnityEngine.Random.Range(minAgentAreaX, maxAgentAreaX); ;
float randZ = 0f;
@ -263,22 +268,22 @@ public void moveAgentToSpwanArea()
int Y = 1;
Vector3 initAgentLoc = new Vector3(randX, Y, randZ);
moveAgentTo(initAgentLoc);
MoveAgentTo(initAgentLoc);
}
// move Agent to this position
public void moveAgentTo(Vector3 thisPosition)
public void MoveAgentTo(Vector3 thisPosition)
{
// while using transform.localPosition to move character
// u should turn off character Controller or it won't work
agentCharaCon.enabled = false;
AgentObj.transform.localPosition = thisPosition;
agentObj.transform.localPosition = thisPosition;
agentCharaCon.enabled = true;
}
// check over and get rewards
// 1 = success,2 = overtime,0 = notover
public (int, float,float) checkOverAndRewards()
public (int, float, float) CheckOverAndRewards()
{
int endTypeInt = 0;
float thisReward = 0;
@ -288,9 +293,9 @@ public void moveAgentTo(Vector3 thisPosition)
{
case (int)SceneBlockContainer.Targets.Go:
// goto
(nowDistance, inArea) = blockCont.getAgentTargetDistanceAndInside(AgentObj.transform.position);
envUICon.updateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint);
float areaTargetReward = getDistanceReward(nowDistance, inArea);
(nowDistance, inArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
envUICon.UpdateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint);
float areaTargetReward = GetDistanceReward(nowDistance, inArea);
//if(inArea != 0)
if (blockCont.thisBlock.firebasesBelong >= blockCont.thisBlock.belongMaxPoint)
{
@ -316,13 +321,14 @@ public void moveAgentTo(Vector3 thisPosition)
endTypeInt = (int)EndType.Running;
}
break;
case (int)SceneBlockContainer.Targets.Attack:
// attack
(nowDistance, inArea) = blockCont.getAgentTargetDistanceAndInside(AgentObj.transform.position);
envUICon.updateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint);
if (blockCont.thisBlock.getInAreaNumber(group2Tag) <= 0 && targetEnemySpawnFinish)
(nowDistance, inArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
envUICon.UpdateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint);
if (blockCont.thisBlock.GetInAreaNumber(group2Tag) <= 0 && targetEnemySpawnFinish)
{
Debug.Log(blockCont.thisBlock.getInAreaNumber(group2Tag));
Debug.Log(blockCont.thisBlock.GetInAreaNumber(group2Tag));
// win
// let the area belongs to me and kill every enmy in this area.
thisReward = 0;
@ -350,11 +356,12 @@ public void moveAgentTo(Vector3 thisPosition)
endTypeInt = (int)EndType.Running;
}
break;
case (int)SceneBlockContainer.Targets.Defence:
//defence
// !!! DIDN't FINISH!!!
(nowDistance, inArea) = blockCont.getAgentTargetDistanceAndInside(AgentObj.transform.position);
envUICon.updateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint);
(nowDistance, inArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
envUICon.UpdateTargetGauge(blockCont.thisBlock.firebasesBelong, blockCont.thisBlock.belongMaxPoint);
if (leftTime <= 0 && blockCont.thisBlock.firebasesBelong >= 0f)
{
// win
@ -377,6 +384,7 @@ public void moveAgentTo(Vector3 thisPosition)
endTypeInt = (int)EndType.Running;
}
break;
case (int)SceneBlockContainer.Targets.Stay:
// Stay
// endless
@ -384,9 +392,10 @@ public void moveAgentTo(Vector3 thisPosition)
endReward = 0;
endTypeInt = (int)EndType.Running;
break;
default:
//free kill
if (EnemyContainerObj.transform.childCount <= 0)
if (enemyContainerObj.transform.childCount <= 0)
{
// win
// thisReward = paramCon.winReward + (paramCon.timeBonusPerSecReward * leftTime);
@ -411,18 +420,18 @@ public void moveAgentTo(Vector3 thisPosition)
}
break;
}
envUICon.showResult(endTypeInt);
worldUICon.updateChart(targetTypeInt, endTypeInt);
return (endTypeInt, thisReward,endReward);
envUICon.ShowResult(endTypeInt);
worldUICon.UpdateChart(targetTypeInt, endTypeInt);
return (endTypeInt, thisReward, endReward);
}
// caulculate sceneReward if close to target then get great reward
public float getDistanceReward(float nowDistance,int inarea)
public float GetDistanceReward(float nowDistance, int inarea)
{
if (firstRewardFlag)
{
// first distance record
(lastDistance, _) = blockCont.getAgentTargetDistanceAndInside(AgentObj.transform.position);
(lastDistance, _) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
firstRewardFlag = false;
}
float thisSceneReward = 0f;
@ -442,13 +451,13 @@ public float getDistanceReward(float nowDistance,int inarea)
}
// calculate kill reward base on killed enemy's position
public float killReward(Vector3 enemyPosition)
public float KillReward(Vector3 enemyPosition)
{
float thisKillReward = 0f;
if (targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
{
// attack mode
(_, int isInArea) = blockCont.thisBlock.getDist_inArea(enemyPosition);
(_, int isInArea) = blockCont.thisBlock.GetDistInArea(enemyPosition);
if (isInArea == 1)
{
// kill in area enemy
@ -473,13 +482,13 @@ public float killReward(Vector3 enemyPosition)
}
// calculate hit reward base on killed enemy's position and now mode
public float hitEnemyReward(Vector3 enemyPosition)
public float HitEnemyReward(Vector3 enemyPosition)
{
float thisHitReward = 0f;
if (targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
{
// attack mode
(_, int isInArea) = blockCont.thisBlock.getDist_inArea(enemyPosition);
(_, int isInArea) = blockCont.thisBlock.GetDistInArea(enemyPosition);
if (isInArea == 1)
{
// hit in area enemy
@ -505,9 +514,9 @@ public float hitEnemyReward(Vector3 enemyPosition)
}
// get in area state
public int getInAreaState()
public int GetInAreaState()
{
if(targetTypeInt == (int)SceneBlockContainer.Targets.Go)
if (targetTypeInt == (int)SceneBlockContainer.Targets.Go)
{
return inArea;
}
@ -519,41 +528,40 @@ public int getInAreaState()
// Play Mode method
// Initialize Play mode
public void playInitialize()
public void PlayInitialize()
{
targetTypeInt = (int)SceneBlockContainer.Targets.Stay;
envUICon.updateTargetType(targetTypeInt);
moveAgentToSpwanArea();
enemyCont.destroyAllEnemys();
blockCont.destroyBlock();
envUICon.UpdateTargetType(targetTypeInt);
MoveAgentToSpwanArea();
enemyCont.DestroyAllEnemys();
blockCont.DestroyBlock();
}
// change to attack mode
public void attackModeChange()
public void AttackModeChange()
{
targetTypeInt = (int)SceneBlockContainer.Targets.Attack;
envUICon.updateTargetType(targetTypeInt);
envUICon.UpdateTargetType(targetTypeInt);
}
// change to free mode
public void freeModeChange()
public void FreeModeChange()
{
targetTypeInt = (int)SceneBlockContainer.Targets.Free;
envUICon.updateTargetType(targetTypeInt);
envUICon.UpdateTargetType(targetTypeInt);
}
// change to goto mode
public void gotoModeChange()
public void GotoModeChange()
{
targetTypeInt = (int)SceneBlockContainer.Targets.Go;
envUICon.updateTargetType(targetTypeInt);
envUICon.UpdateTargetType(targetTypeInt);
}
// change to stay mode
public void stayModeChange()
public void StayModeChange()
{
targetTypeInt = (int)SceneBlockContainer.Targets.Stay;
envUICon.updateTargetType(targetTypeInt);
envUICon.UpdateTargetType(targetTypeInt);
}
}
}

View File

@ -1,33 +1,32 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XCharts.Runtime;
public class WorldUIController : MonoBehaviour
{
public LineChart WinChart;
public LineChart winChart;
public int[] totalGames;
public int[] winGames;
private int maxXAxis = 0;
// Start is called before the first frame update
void Start()
private void Start()
{
totalGames = new int[(int)SceneBlockContainer.Targets.Num];
winGames = new int[(int)SceneBlockContainer.Targets.Num];
Array.Clear(totalGames, 0, (int)SceneBlockContainer.Targets.Num);
Array.Clear(winGames, 0, (int)SceneBlockContainer.Targets.Num);
//WinChart.Init();
WinChart.RemoveData();
winChart.RemoveData();
for (int i = 0; i < (int)SceneBlockContainer.Targets.Num; i++)
{
string lineName = Enum.GetName(typeof(SceneBlockContainer.Targets), i);
WinChart.AddSerie<Line>(lineName);
winChart.AddSerie<Line>(lineName);
}
}
public void updateChart(int targetType, int endType)
public void UpdateChart(int targetType, int endType)
{
float winRatio = 0f;
switch (endType)
@ -37,27 +36,28 @@ public void updateChart(int targetType, int endType)
totalGames[targetType] += 1;
winGames[targetType] += 1;
winRatio = (float)winGames[targetType] / totalGames[targetType];
WinChart.AddData(targetType, winRatio);
winChart.AddData(targetType, winRatio);
if (totalGames[targetType] > maxXAxis)
{
maxXAxis = totalGames[targetType];
WinChart.AddXAxisData(Convert.ToString(maxXAxis));
winChart.AddXAxisData(Convert.ToString(maxXAxis));
}
break;
case (int)TargetController.EndType.Lose:
//lose
totalGames[targetType] += 1;
winRatio = (float)winGames[targetType] / totalGames[targetType];
WinChart.AddData(targetType, winRatio);
winChart.AddData(targetType, winRatio);
if (totalGames[targetType] > maxXAxis)
{
maxXAxis = totalGames[targetType];
WinChart.AddXAxisData(Convert.ToString(maxXAxis));
winChart.AddXAxisData(Convert.ToString(maxXAxis));
}
break;
default:
break;
}
}
}
}

View File

@ -1,13 +1,13 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine;
public class rayInfoUI : MonoBehaviour
public class RayInfoUI : MonoBehaviour
{
TextMeshProUGUI infoText;
bool infoTextReady = false;
private TextMeshProUGUI infoText;
private bool infoTextReady = false;
// Start is called before the first frame update
void Start()
private void Start()
{
try
{
@ -20,7 +20,7 @@ void Start()
}
}
public void updateInfo(string info,Vector3 infoPosition, Color infoColor,Camera facetoCamera)
public void UpdateInfo(string info, Vector3 infoPosition, Color infoColor, Camera facetoCamera)
{
if (!infoTextReady)
{
@ -34,4 +34,4 @@ public void updateInfo(string info,Vector3 infoPosition, Color infoColor,Camera
transform.LookAt(facetoCamera.transform.position - v);
transform.Rotate(0, 180, 0);
}
}
}

View File

@ -1,22 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class states : MonoBehaviour
public class States : MonoBehaviour
{
public bool isDead = false;
public float MaxHP = 100;
float myHP = 100;
public float maxHP = 100;
private float myHP = 100;
void Start()
private void Start()
{
myHP = MaxHP;
myHP = maxHP;
}
void Update()
private void Update()
{
}
private void detactDeath()
private void DetactDeath()
{
if (myHP <= 0)
{
@ -24,6 +23,7 @@ private void detactDeath()
isDead = true;
}
}
// while got hit
public void ReactToHit(float Damage, GameObject damageSource)
{
@ -33,7 +33,7 @@ public void ReactToHit(float Damage, GameObject damageSource)
{
if (damageSource.tag == "Player")
{
damageSource.GetComponent<AgentWithGun>().killRecord(transform.position);
damageSource.GetComponent<AgentWithGun>().KillRecord(transform.position);
Destroy(this.gameObject);
isDead = true;
}
@ -44,15 +44,16 @@ public void ReactToHit(float Damage, GameObject damageSource)
}
}
}
// get my hp from other script
public float getnowHP()
public float GetnowHP()
{
return myHP;
}
public void destroyMe()
public void DestroyMe()
{
Destroy(this.gameObject);
isDead = true;
}
}
}

View File

@ -1,16 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MouseInMap : MonoBehaviour
{
public Camera playCamera;
public GameObject EnvironmentObj;
public GameObject environmentObj;
public GameObject selectEffect;
public GameObject EnemyContainerObj;
public GameObject SceneBlockContainerObj;
public GameObject TargetControllerObj;
public GameObject enemyContainerObj;
public GameObject sceneBlockContainerObj;
public GameObject targetControllerObj;
public GameObject HUDObj;
private Vector3 mouseInMapPosition = Vector3.zero;
@ -31,46 +28,50 @@ public enum MouseMode
GotoSet,
EnemySet
}
public MouseMode mouseMode = MouseMode.Default;
private void Start()
{
groundMask = LayerMask.GetMask("Ground");
targetCon = TargetControllerObj.GetComponent<TargetController>();
targetCon = targetControllerObj.GetComponent<TargetController>();
mousePreviewCon = this.GetComponent<MousePreview>();
enemyCon = EnemyContainerObj.GetComponent<EnemyContainer>();
sceneBlockCon = SceneBlockContainerObj.GetComponent<SceneBlockContainer>();
enemyCon = enemyContainerObj.GetComponent<EnemyContainer>();
sceneBlockCon = sceneBlockContainerObj.GetComponent<SceneBlockContainer>();
targetUICon = HUDObj.GetComponent<TargetUIController>();
}
void Update()
private void Update()
{
nowHitPosition = getMouseOnMapPosition();
nowHitPosition = GetMouseOnMapPosition();
// if mouse position in area, update mouseInMapPosition as nowHitPosition
if (nowHitPosition.x < targetCon.maxAgentAreaX && nowHitPosition.x > targetCon.minAgentAreaX && nowHitPosition.z < targetCon.maxEnemyAreaZ && nowHitPosition.z > targetCon.minAgentAreaZ)
{
mouseInMapPosition = nowHitPosition;
mousePreviewCon.updatePreviewPosition(mouseInMapPosition);
mousePreviewCon.UpdatePreviewPosition(mouseInMapPosition);
// Mouse button R pressed
if (Input.GetMouseButtonDown(1))
{
switch(mouseMode)
switch (mouseMode)
{
case MouseMode.AttackSet:
sceneBlockCon.createNewBlock(SceneBlockContainer.Targets.Attack, randBlockNum, mouseInMapPosition);
sceneBlockCon.initializeBlock(EnvironmentObj);
targetCon.attackModeChange();
changeMouseModeTo(MouseMode.Default);
sceneBlockCon.CreateNewBlock(SceneBlockContainer.Targets.Attack, randBlockNum, mouseInMapPosition);
sceneBlockCon.InitializeBlock(environmentObj);
targetCon.AttackModeChange();
ChangeMouseModeTo(MouseMode.Default);
break;
case MouseMode.GotoSet:
sceneBlockCon.createNewBlock(SceneBlockContainer.Targets.Go, randBlockNum, mouseInMapPosition);
sceneBlockCon.initializeBlock(EnvironmentObj);
targetCon.gotoModeChange();
changeMouseModeTo(MouseMode.Default);
sceneBlockCon.CreateNewBlock(SceneBlockContainer.Targets.Go, randBlockNum, mouseInMapPosition);
sceneBlockCon.InitializeBlock(environmentObj);
targetCon.GotoModeChange();
ChangeMouseModeTo(MouseMode.Default);
break;
case MouseMode.EnemySet:
enemyCon.initEnemyAtHere(new Vector3(mouseInMapPosition.x,1,mouseInMapPosition.z));
enemyCon.InitEnemyAtHere(new Vector3(mouseInMapPosition.x, 1, mouseInMapPosition.z));
break;
default:
break;
}
@ -78,7 +79,7 @@ void Update()
}
}
public void changeMouseModeTo(MouseMode thisMouseMode)
public void ChangeMouseModeTo(MouseMode thisMouseMode)
{
mouseMode = thisMouseMode;
switch (thisMouseMode)
@ -87,26 +88,29 @@ public void changeMouseModeTo(MouseMode thisMouseMode)
// random choose attack scene block type and set as preview
randBlockNum = Random.Range(0, sceneBlockCon.attackBlockPrefabs.Length);
preSet = sceneBlockCon.attackBlockPrefabs[randBlockNum];
mousePreviewCon.changePreviewTo(preSet);
mousePreviewCon.ChangePreviewTo(preSet);
break;
case MouseMode.GotoSet:
// random choose Goto scene block type and set as preview
randBlockNum = Random.Range(0, sceneBlockCon.goBlockPrefabs.Length);
preSet = sceneBlockCon.goBlockPrefabs[randBlockNum];
mousePreviewCon.changePreviewTo(preSet);
mousePreviewCon.ChangePreviewTo(preSet);
break;
case MouseMode.EnemySet:
preSet = enemyCon.enemyPrefab;
mousePreviewCon.changePreviewTo(preSet);
mousePreviewCon.ChangePreviewTo(preSet);
break;
default:
mousePreviewCon.deleteAllPreviewModele();
mousePreviewCon.DeleteAllPreviewModele();
break;
}
}
// get mouse position on map, return a Vector3
public Vector3 getMouseOnMapPosition()
public Vector3 GetMouseOnMapPosition()
{
// shoot raycast from mainCamera center to mousepositon
RaycastHit thisHit;
@ -125,4 +129,4 @@ public Vector3 getMouseOnMapPosition()
return Vector3.zero;
}
}
}
}

View File

@ -7,17 +7,17 @@ public class MousePreview : MonoBehaviour
{
// show mousePreviewObj in mouse position
public void changePreviewTo(GameObject mousePreviewObj)
public void ChangePreviewTo(GameObject mousePreviewObj)
{
deleteAllPreviewModele();
DeleteAllPreviewModele();
Instantiate(mousePreviewObj, this.transform.position, Quaternion.identity, this.transform);
}
public void updatePreviewPosition(Vector3 previewPos)
public void UpdatePreviewPosition(Vector3 previewPos)
{
// move this gameobject to previewPos
this.transform.position = previewPos;
}
public void deleteAllPreviewModele()
public void DeleteAllPreviewModele()
{
// delete all child object
foreach (Transform childObj in this.transform)

View File

@ -1,17 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseSelector : MonoBehaviour
{
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(1))
{
// shoot raycast from mainCamera center to mousepositon
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 3460b8ea83509ed41b69b84ba0c86b87
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,118 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayGameModeController : MonoBehaviour
{
public GameObject ParameterContainerObj;
public GameObject EnemyContainerObj;
public GameObject AgentObj;
public GameObject SceneBlockContainerObj;
// area
public GameObject edgeUp;
public GameObject edgeDown;
public GameObject edgeLeft;
public GameObject edgeRight;
public GameObject edgeAgent_Enemy;
public float minEnemyAreaX;
public float maxEnemyAreaX;
public float minEnemyAreaZ;
public float maxEnemyAreaZ;
public float minAgentAreaX;
public float maxAgentAreaX;
public float minAgentAreaZ;
public float maxAgentAreaZ;
private ParameterContainer paramCon;
private CharacterController agentCharaCon;
private EnemyContainer enemyCon;
private SceneBlockContainer sceneBlockCon;
private void Start()
{
minEnemyAreaX = edgeLeft.transform.localPosition.x + 1.0f;
maxEnemyAreaX = edgeRight.transform.localPosition.x - 1.0f;
minEnemyAreaZ = edgeAgent_Enemy.transform.localPosition.z + 1.0f;
maxEnemyAreaZ = edgeUp.transform.localPosition.z - 1.0f;
minAgentAreaX = edgeLeft.transform.localPosition.x + 1.0f;
maxAgentAreaX = edgeRight.transform.localPosition.x - 1.0f;
minAgentAreaZ = edgeDown.transform.localPosition.z + 1.0f;
maxAgentAreaZ = edgeAgent_Enemy.transform.localPosition.z - 1.0f;
paramCon = ParameterContainerObj.GetComponent<ParameterContainer>();
agentCharaCon = AgentObj.GetComponent<CharacterController>();
enemyCon = EnemyContainerObj.GetComponent<EnemyContainer>();
sceneBlockCon = SceneBlockContainerObj.GetComponent<SceneBlockContainer>();
}
public enum GameMode
{
Stay,
Free,
Attack,
Goto
}
public GameMode gameMode = GameMode.Stay;// default stay mode
public void startInitialize()
{
gameMode = GameMode.Stay;
moveAgentToSpwanArea();
enemyCon.destroyAllEnemys();
sceneBlockCon.destroyBlock();
}
// change to attack mode
public void attackModeChange()
{
}
// change to free mode
public void freeModeChange()
{
gameMode = GameMode.Free;
}
// change to goto mode
public void gotoModeChange()
{
}
// move Agent into Agent Spawn Area
public void moveAgentToSpwanArea()
{
float randX = UnityEngine.Random.Range(minAgentAreaX, maxAgentAreaX); ;
float randZ = 0f;
if (paramCon.spawnAgentInAllMap)
{
// spawn agent in all around map
randZ = UnityEngine.Random.Range(minAgentAreaZ, maxEnemyAreaZ);
}
else
{
// spawn agent in only agent spawn area
randZ = UnityEngine.Random.Range(minAgentAreaZ, maxAgentAreaZ);
}
int Y = 1;
Vector3 initAgentLoc = new Vector3(randX, Y, randZ);
moveAgentTo(initAgentLoc);
}
// move Agent to this position
public void moveAgentTo(Vector3 thisPosition)
{
// while using transform.localPosition to move character
// u should turn off character Controller or it won't work
agentCharaCon.enabled = false;
AgentObj.transform.localPosition = thisPosition;
agentCharaCon.enabled = true;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 77518fe48235bbe47bd3adde3630eb02
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,7 +4,7 @@
public class PlayerCamera : MonoBehaviour
{
public float normalSpeed = 0.035f;
public float normalSpeed = 0.0035f;
public float shiftSpeed = 0.06f;
public float zoomSpeed = -10.0f;
public float rotateSpeed = 0.1f;
@ -59,10 +59,10 @@ void Update()
Vector3 move = verticalMove + lateralMove + fowardMove; // total movement
transform.position += move; // move the camera
cameraRotation();
CameraRotation();
}
void cameraRotation()
void CameraRotation()
{
// camera rotation while press middle mousebutton
if(Input.GetMouseButtonDown(2))

View File

@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@ -7,9 +5,10 @@ public class TargetUIController : MonoBehaviour
{
// Controller to control the UI of the target,
// select target type, select prefeb to set or sth.
public GameObject TargetControllerObj;
public GameObject MouseSelectorObj;
public GameObject EnvironmentUIObj;
public GameObject targetControllerObj;
public GameObject mouseSelectorObj;
public GameObject environmentUIObj;
public Button setAttackButton;
public Button setGotoButton;
@ -22,77 +21,56 @@ public class TargetUIController : MonoBehaviour
private void Start()
{
targetCon = TargetControllerObj.GetComponent<TargetController>();
mouseInMapCon = MouseSelectorObj.GetComponent<MouseInMap>();
envUICon = EnvironmentUIObj.GetComponent<EnvironmentUIControl>();
targetCon = targetControllerObj.GetComponent<TargetController>();
mouseInMapCon = mouseSelectorObj.GetComponent<MouseInMap>();
envUICon = environmentUIObj.GetComponent<EnvironmentUIControl>();
}
public void clearGamePressed()
public void ClearGamePressed()
{
// Clear all enemies and targets. set gamemode to Stay mode
targetCon.stayModeChange();
mouseInMapCon.changeMouseModeTo(MouseInMap.MouseMode.Default);
targetCon.StayModeChange();
mouseInMapCon.ChangeMouseModeTo(MouseInMap.MouseMode.Default);
// disable setStayButton and enable other buttons
setStayButton.interactable = false;
setAttackButton.interactable = true;
setGotoButton.interactable = true;
setFreeButton.interactable = true;
targetCon.playInitialize();
targetCon.PlayInitialize();
}
public void setEnemyPressed()
public void SetEnemyPressed()
{
mouseInMapCon.changeMouseModeTo(MouseInMap.MouseMode.EnemySet);
mouseInMapCon.ChangeMouseModeTo(MouseInMap.MouseMode.EnemySet);
}
public void setGotoPressed()
public void SetGotoPressed()
{
mouseInMapCon.changeMouseModeTo(MouseInMap.MouseMode.GotoSet);
mouseInMapCon.ChangeMouseModeTo(MouseInMap.MouseMode.GotoSet);
}
public void setAttackPressed()
public void SetAttackPressed()
{
mouseInMapCon.changeMouseModeTo(MouseInMap.MouseMode.AttackSet);
mouseInMapCon.ChangeMouseModeTo(MouseInMap.MouseMode.AttackSet);
}
public void setFreePressed()
public void SetFreePressed()
{
mouseInMapCon.changeMouseModeTo(MouseInMap.MouseMode.Default);
targetCon.freeModeChange();
mouseInMapCon.ChangeMouseModeTo(MouseInMap.MouseMode.Default);
targetCon.FreeModeChange();
setStayButton.interactable = true;
setAttackButton.interactable = true;
setGotoButton.interactable = true;
setFreeButton.interactable = false;
}
public void setStayPressed()
public void SetStayPressed()
{
mouseInMapCon.changeMouseModeTo(MouseInMap.MouseMode.Default);
targetCon.stayModeChange();
mouseInMapCon.ChangeMouseModeTo(MouseInMap.MouseMode.Default);
targetCon.StayModeChange();
setStayButton.interactable = false;
setAttackButton.interactable = true;
setGotoButton.interactable = true;
setFreeButton.interactable = true;
}
public void UIButtonInteractable(PlayGameModeController.GameMode nowMode = PlayGameModeController.GameMode.Stay)
{
setStayButton.interactable = true;
setAttackButton.interactable = true;
setGotoButton.interactable = true;
setFreeButton.interactable = true;
switch(nowMode)
{
case PlayGameModeController.GameMode.Attack:
setAttackButton.interactable = false;
break;
case PlayGameModeController.GameMode.Free:
setFreeButton.interactable = false;
break;
case PlayGameModeController.GameMode.Goto:
setGotoButton.interactable = false;
break;
case PlayGameModeController.GameMode.Stay:
setStayButton.interactable = false;
break;
default:
Debug.Log("TargetUIController.UIButtonInteractable : Type error");
break;
}
}
}
}

View File

@ -1,16 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class selectEffect : MonoBehaviour
{
// Update is called once per frame
void Update()
{
// if this gameobject exist over 5s, destroy it
if (Time.time > 5)
{
Destroy(gameObject);
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 42a602efe0639c144907a166e7e59a79
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -8,7 +8,7 @@ public enum SceneType
Train,
Play,
}
public void loadScene(SceneType sceneType)
public void LoadGameScene(SceneType sceneType)
{
switch (sceneType)
{

View File

@ -4,11 +4,11 @@
public class StartUIManager : MonoBehaviour
{
public int WaitTimeLimit = 45;
public GameObject SceneLoaderObj;
public GameObject StartSceneDataObj;
public TextMeshProUGUI MessageTextObj;
public TextMeshProUGUI WaitTimeTextObj;
public int waitTimeLimit = 45;
public GameObject sceneLoaderObj;
public GameObject startSceneDataObj;
public TextMeshProUGUI messageTextObj;
public TextMeshProUGUI waitTimeTextObj;
private SceneLoader sceneLoader;
private StartSeneData startSceneData;
private float startTime;
@ -16,20 +16,20 @@ public class StartUIManager : MonoBehaviour
// Start is called before the first frame update
void Start()
{
sceneLoader = SceneLoaderObj.GetComponent<SceneLoader>();
startSceneData = StartSceneDataObj.GetComponent<StartSeneData>();
MessageTextObj.text = "";
sceneLoader = sceneLoaderObj.GetComponent<SceneLoader>();
startSceneData = startSceneDataObj.GetComponent<StartSeneData>();
messageTextObj.text = "";
}
private void Update()
{
// update time limit left;
float leftTime = WaitTimeLimit - Time.realtimeSinceStartup;
WaitTimeTextObj.text = ((int)Math.Round(leftTime)).ToString();
float leftTime = waitTimeLimit - Time.realtimeSinceStartup;
waitTimeTextObj.text = ((int)Math.Round(leftTime)).ToString();
if (leftTime <= 1)
{
// if time limit is over, load Train Scene
sceneLoader.loadScene(SceneLoader.SceneType.Train);
sceneLoader.LoadGameScene(SceneLoader.SceneType.Train);
}
}
@ -38,15 +38,15 @@ private void Update()
public void OnTrainStartButtonPressed()
{
startSceneData.gamemode = 0;
sceneLoader.loadScene(SceneLoader.SceneType.Train);
MessageTextObj.text = "Loading Train Scene...";
sceneLoader.LoadGameScene(SceneLoader.SceneType.Train);
messageTextObj.text = "Loading Train Scene...";
}
// while StartButton-Play Pressed
public void OnPlayButtonPressed()
{
startSceneData.gamemode = 1;
sceneLoader.loadScene(SceneLoader.SceneType.Play);
MessageTextObj.text = "Loading Play Scene...";
sceneLoader.LoadGameScene(SceneLoader.SceneType.Play);
messageTextObj.text = "Loading Play Scene...";
}
}

View File

@ -6,17 +6,17 @@ EditorUserSettings:
serializedVersion: 4
m_ConfigSettings:
RecentlyUsedSceneGuid-0:
value: 5703025650035e5d090f087148715d4443161e2c7e2c20357b281b31b0e43060
flags: 0
RecentlyUsedSceneGuid-1:
value: 55090405535008090b5608764626074415151c79747c74602b7c1861e4b96c6c
flags: 0
RecentlyUsedSceneGuid-2:
RecentlyUsedSceneGuid-1:
value: 06570c0704040b0e5a575520137b5e44154f192e292d22367c2c4866b7b3376f
flags: 0
RecentlyUsedSceneGuid-3:
RecentlyUsedSceneGuid-2:
value: 5453565f53020f085f5d0e72157a0844454f4c2b757d7265757a4f64b7b4313c
flags: 0
RecentlyUsedSceneGuid-3:
value: 5703025650035e5d090f087148715d4443161e2c7e2c20357b281b31b0e43060
flags: 0
RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0

View File

@ -14,12 +14,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_PixelRect:
serializedVersion: 2
x: 346
y: 218
width: 1016
x: -212
y: 259
width: 1794
height: 1037
m_ShowMode: 4
m_Title: Inspector
m_Title: Console
m_RootView: {fileID: 9}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
@ -41,7 +41,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 716
width: 594
width: 1038
height: 271
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
@ -70,12 +70,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 594
width: 1038
height: 987
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 42
controlID: 134
--- !u!114 &4
MonoBehaviour:
m_ObjectHideFlags: 52
@ -92,9 +92,9 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 716
width: 182
height: 271
y: 295
width: 321
height: 692
m_MinSize: {x: 102, y: 121}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 19}
@ -119,14 +119,14 @@ MonoBehaviour:
- {fileID: 4}
m_Position:
serializedVersion: 2
x: 594
x: 1038
y: 0
width: 182
width: 321
height: 987
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 17
controlID: 47
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
@ -144,8 +144,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 182
height: 716
width: 321
height: 295
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 17}
@ -173,12 +173,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 30
width: 1016
width: 1794
height: 987
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 41
controlID: 133
--- !u!114 &8
MonoBehaviour:
m_ObjectHideFlags: 52
@ -194,9 +194,9 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 776
x: 1359
y: 0
width: 240
width: 435
height: 987
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
@ -225,7 +225,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1016
width: 1794
height: 1037
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
@ -250,7 +250,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1016
width: 1794
height: 30
m_MinSize: {x: 0, y: 0}
m_MaxSize: {x: 0, y: 0}
@ -272,7 +272,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 1017
width: 1016
width: 1794
height: 20
m_MinSize: {x: 0, y: 0}
m_MaxSize: {x: 0, y: 0}
@ -293,7 +293,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 594
width: 1038
height: 716
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
@ -325,7 +325,7 @@ MonoBehaviour:
serializedVersion: 2
x: 64
y: 73
width: 1085
width: 1073
height: 695
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@ -337,7 +337,7 @@ MonoBehaviour:
m_ShowGizmos: 0
m_TargetDisplay: 0
m_ClearColor: {r: 0, g: 0, b: 0, a: 0}
m_TargetSize: {x: 1085, y: 674}
m_TargetSize: {x: 1073, y: 674}
m_TextureFilterMode: 0
m_TextureHideFlags: 61
m_RenderIMGUI: 1
@ -352,8 +352,8 @@ MonoBehaviour:
m_VRangeLocked: 0
hZoomLockedByDefault: 0
vZoomLockedByDefault: 0
m_HBaseRangeMin: -542.5
m_HBaseRangeMax: 542.5
m_HBaseRangeMin: -536.5
m_HBaseRangeMax: 536.5
m_VBaseRangeMin: -337
m_VBaseRangeMax: 337
m_HAllowExceedBaseRangeMin: 1
@ -373,23 +373,23 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 21
width: 1085
width: 1073
height: 674
m_Scale: {x: 1, y: 1}
m_Translation: {x: 542.5, y: 337}
m_Translation: {x: 536.5, y: 337}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -542.5
x: -536.5
y: -337
width: 1085
width: 1073
height: 674
m_MinimalGUI: 1
m_defaultScale: 1
m_LastWindowPixelSize: {x: 1085, y: 695}
m_LastWindowPixelSize: {x: 1073, y: 695}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000
@ -443,9 +443,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 0
y: 735
width: 593
x: -212
y: 1005
width: 1037
height: 250
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@ -464,36 +464,36 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/Script/InGame
- Assets/Script
m_Globs: []
m_OriginalText:
m_ViewMode: 1
m_StartGridSize: 16
m_LastFolders:
- Assets/Script/InGame
- Assets/Script
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: 138}
m_SelectedIDs: 186a0000
m_LastClickedID: 27160
m_ExpandedIDs: 00000000a4690000a6690000a8690000aa690000ac690000d8690000de69000000ca9a3bffffff7f
scrollPos: {x: 0, y: 122}
m_SelectedIDs: 06670000
m_LastClickedID: 26374
m_ExpandedIDs: 00000000e2660000e4660000e6660000e8660000ea6600000667000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: Prefeb
m_OriginalName: Prefeb
m_Name:
m_OriginalName:
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 1000000003
m_UserData: 0
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 0
m_OriginalEventType: 11
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 2}
m_SearchString:
@ -507,7 +507,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 00000000a4690000a6690000a8690000aa690000ac690000
m_ExpandedIDs: 00000000e2660000e4660000e6660000e8660000ea660000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -538,15 +538,15 @@ MonoBehaviour:
m_ExpandedInstanceIDs: c623000000000000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: Attack-1Wall-0
m_OriginalName: Attack-1Wall-0
m_Name: PlayerCamera
m_OriginalName: PlayerCamera
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 24398
m_UserData: 5744
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 0
@ -583,9 +583,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1122
y: 248
width: 239
x: 1147
y: 289
width: 434
height: 966
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@ -624,10 +624,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 940
y: 248
width: 180
height: 695
x: 826
y: 289
width: 319
height: 274
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@ -635,23 +635,23 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: ba5d0000
m_LastClickedID: 23994
m_ExpandedIDs: 86f0ffffdaf0ffff32fbffff025b0000145c0000905e0000
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 9232ffff32fbffffa65900009c5a0000025b0000cc5b0000d85b0000145c0000b25c0000845e000088cb0000a6cb0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
m_OriginalName:
m_Name: WaitTimeTime
m_OriginalName: WaitTimeTime
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 0
m_UserData: 52074
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 11
m_OriginalEventType: 0
m_IsRenamingFilename: 0
m_ClientGUIView: {fileID: 6}
m_SearchString:
@ -681,9 +681,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 346
y: 248
width: 593
x: -212
y: 289
width: 1037
height: 695
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@ -716,7 +716,7 @@ MonoBehaviour:
floating: 0
collapsed: 0
displayed: 1
snapOffset: {x: 0, y: 0}
snapOffset: {x: 0, y: 25}
snapOffsetDelta: {x: 0, y: 0}
snapCorner: 0
id: unity-scene-view-toolbar
@ -919,9 +919,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: -1.9757904, y: 37.38048, z: -3.9826856}
m_Target: {x: 527.9375, y: 203.3164, z: 406.25055}
speed: 2
m_Value: {x: 66.24889, y: -54.049023, z: -29.673973}
m_Value: {x: 527.9375, y: 203.3164, z: 406.25055}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@ -968,13 +968,13 @@ MonoBehaviour:
m_GridAxis: 1
m_gridOpacity: 0.5
m_Rotation:
m_Target: {x: 0.3737313, y: 0.35359865, z: -0.1568066, w: 0.8430081}
m_Target: {x: 0.19678506, y: 0.23813863, z: -0.049381696, w: 0.9497747}
speed: 2
m_Value: {x: -0.17065884, y: -0.79835737, z: 0.2657279, w: -0.51272774}
m_Value: {x: 0.19536556, y: 0.23821901, z: -0.049025822, w: 0.950095}
m_Size:
m_Target: 5.2687497
m_Target: 718.14734
speed: 2
m_Value: 50.033897
m_Value: 751.98676
m_Ortho:
m_Target: 0
speed: 2
@ -1019,10 +1019,10 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1
y: 735
width: 180
height: 250
x: 826
y: 584
width: 319
height: 671
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default

13
UserSettings/Search.index Normal file
View File

@ -0,0 +1,13 @@
{
"name": "Assets",
"roots": ["Assets"],
"includes": [],
"excludes": [],
"options": {
"types": true,
"properties": true,
"extended": false,
"dependencies": false
},
"baseScore": 999
}

View File

@ -1 +1,89 @@
{}
trackSelection = true
fetchPreview = true
defaultFlags = 0
keepOpen = false
queryFolder = "Assets"
onBoardingDoNotAskAgain = true
showPackageIndexes = false
showStatusBar = false
scopes = {
"last_search.DD5CDD96" = "StartUIManager"
"OpenInspectorPreview.DD5CDD96" = "0"
"currentGroup.DD5CDD96" = "scene"
"last_search.2138236A" = "t:selectEffect"
"OpenInspectorPreview.2138236A" = "0"
"currentGroup.2138236A" = "asset"
}
providers = {
adb = {
active = false
priority = 2500
defaultAction = null
}
asset = {
active = true
priority = 25
defaultAction = null
}
store = {
active = true
priority = 100
defaultAction = null
}
find = {
active = true
priority = 25
defaultAction = null
}
log = {
active = false
priority = 210
defaultAction = null
}
packages = {
active = true
priority = 90
defaultAction = null
}
performance = {
active = false
priority = 100
defaultAction = null
}
scene = {
active = true
priority = 50
defaultAction = null
}
}
objectSelectors = {
}
recentSearches = [
"StartUIManager"
"t:PlayerCamera"
"t"
"t:PlayGameModeController"
"t:TargetUIController"
"SelectEffect"
"t:selectEffect"
"t:MouseSelector"
"M"
"t:WorldUIController"
"t:rayInfoUI"
"t:我使用Unity制作游戏我想知道哪些gameobject使用了某个script我该怎么做"
"t"
"rayInfoUIrayInfoUI"
"rayInfoUI"
"SceneBlockContainer"
"HUDController"
]
searchItemFavorites = [
]
savedSearchesSortOrder = 0
showSavedSearchPanel = false
expandedQueries = [
]
queryBuilder = false
ignoredProperties = "id;name;classname;imagecontentshash"
helperWidgetCurrentArea = "all"
disabledIndexers = ""