Delete near Enemy Detect future. Use different density sensor.
Unity: No more detect Closest enemy info. Add different density sensor let agent get more state information on the center of view. Adjust Start Scene UI manager. Add in game visible rayCast & information that rayCast detect. Python: Start use mypy black and flake8 to format Python.
This commit is contained in:
@@ -1 +1 @@
|
||||
{"count":1,"self":116.3625216,"total":117.6937916,"children":{"InitializeActuators":{"count":2,"self":0.0010000999999999999,"total":0.0010000999999999999,"children":null},"InitializeSensors":{"count":2,"self":0.0010000999999999999,"total":0.0010000999999999999,"children":null},"AgentSendState":{"count":5234,"self":0.0425063,"total":0.074009499999999992,"children":{"CollectObservations":{"count":5234,"self":0.0149973,"total":0.0149973,"children":null},"WriteActionMask":{"count":5234,"self":0.005502,"total":0.005502,"children":null},"RequestDecision":{"count":5234,"self":0.011003899999999999,"total":0.011003899999999999,"children":null}}},"DecideAction":{"count":5234,"self":0.0335113,"total":0.0335113,"children":null},"AgentAct":{"count":5234,"self":1.2207531,"total":1.2207531,"children":null}},"gauges":{"AKMAgent.CumulativeReward":{"count":1,"max":-243.509537,"min":-243.509537,"runningAverage":-243.509537,"value":-243.509537,"weightedAverage":-243.509537}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1662500472","unity_version":"2020.3.19f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.19f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-PPO\\Aimbot-PPO-MultiScene -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-UCUNI -hubSessionId 209fdf30-2c1f-11ed-916f-33e85f4223cc -accessToken 78EBbrn-dg5kE__h3rNOqQVTDU3b1xUmmwWF1c5sFLc00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.0","scene_name":"InGame","end_time_seconds":"1662500589"}}
|
||||
{"count":1,"self":33.6679968,"total":34.5046305,"children":{"InitializeActuators":{"count":2,"self":0.0010002,"total":0.0010002,"children":null},"InitializeSensors":{"count":2,"self":0.0010004,"total":0.0010004,"children":null},"AgentSendState":{"count":1489,"self":0.011503399999999999,"total":0.2010688,"children":{"CollectObservations":{"count":1489,"self":0.1780647,"total":0.1780647,"children":null},"WriteActionMask":{"count":1488,"self":0.0019993999999999997,"total":0.0019993999999999997,"children":null},"RequestDecision":{"count":1488,"self":0.009501299999999999,"total":0.009501299999999999,"children":null}}},"DecideAction":{"count":1488,"self":0.0117408,"total":0.0117408,"children":null},"AgentAct":{"count":1488,"self":0.6208231,"total":0.6208231,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1663089804","unity_version":"2020.3.19f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.19f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-PPO\\Aimbot-PPO-MultiScene -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-UCUNI -hubSessionId 4cf980b0-326c-11ed-87c2-a7333acffe7c -accessToken j61gZPw8-vc4ZH7TJMvrSAAPQLV9SK6U72z_dek2xhw00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.0","scene_name":"InGame","end_time_seconds":"1663089838"}}
|
||||
@@ -0,0 +1,229 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &2963094767320567766
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2963094767320567753}
|
||||
- component: {fileID: 2963094767320567755}
|
||||
- component: {fileID: 2963094767320567752}
|
||||
m_Layer: 0
|
||||
m_Name: infoText
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2963094767320567753
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2963094767320567766}
|
||||
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_Children: []
|
||||
m_Father: {fileID: 2963094767576631242}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 3, y: 2}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &2963094767320567755
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2963094767320567766}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2963094767320567752
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2963094767320567766}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: 'Enemy
|
||||
|
||||
123123
|
||||
|
||||
123123'
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: f653ac5b85a721e4c9383008e6a565a7, type: 2}
|
||||
m_sharedMaterial: {fileID: -4662725986004701985, guid: f653ac5b85a721e4c9383008e6a565a7, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 0.5
|
||||
m_fontSizeBase: 0.5
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 256
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &2963094767576631243
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2963094767576631242}
|
||||
- component: {fileID: 2963094767576631244}
|
||||
- component: {fileID: 2963094767576631245}
|
||||
- component: {fileID: 5699170692795172790}
|
||||
m_Layer: 0
|
||||
m_Name: infoImageBG
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2963094767576631242
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2963094767576631243}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 4.28}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 2963094767320567753}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0}
|
||||
m_AnchorMax: {x: 0.5, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 295}
|
||||
m_SizeDelta: {x: 3, y: 2}
|
||||
m_Pivot: {x: 0.5, y: -1}
|
||||
--- !u!222 &2963094767576631244
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2963094767576631243}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2963094767576631245
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2963094767576631243}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.6603774, g: 0.6572624, b: 0.6572624, a: 0.53333336}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &5699170692795172790
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2963094767576631243}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 812dfed7ee1d09c4fa7c3ed8372f54ae, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e13f99706bb4ffe459a06857048ece22
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -299,7 +299,7 @@ MonoBehaviour:
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1544423168}
|
||||
- m_Target: {fileID: 0}
|
||||
m_TargetAssemblyTypeName: StartSceneTimeLimChanger, Assembly-CSharp
|
||||
m_MethodName: onValueTimeChanged
|
||||
m_Mode: 1
|
||||
@@ -854,7 +854,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 289162992}
|
||||
- component: {fileID: 289162993}
|
||||
m_Layer: 5
|
||||
m_Name: EnemyNum
|
||||
m_TagString: Untagged
|
||||
@@ -876,28 +875,13 @@ RectTransform:
|
||||
- {fileID: 409680776}
|
||||
- {fileID: 1746261329}
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 6
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 214, y: -290}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &289162993
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 289162991}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 64d0bcf55e4db0c488996ba1051c279f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
EnemyNumInput: {fileID: 409680777}
|
||||
EnemyNumText: {fileID: 1746261330}
|
||||
--- !u!1 &293920964
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -910,7 +894,6 @@ GameObject:
|
||||
- component: {fileID: 293920968}
|
||||
- component: {fileID: 293920967}
|
||||
- component: {fileID: 293920966}
|
||||
- component: {fileID: 293920969}
|
||||
m_Layer: 5
|
||||
m_Name: LoadDirTextBox-Date
|
||||
m_TagString: Untagged
|
||||
@@ -932,7 +915,7 @@ RectTransform:
|
||||
- {fileID: 884034940}
|
||||
- {fileID: 746911212}
|
||||
m_Father: {fileID: 1539152182}
|
||||
m_RootOrder: 2
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@@ -996,9 +979,9 @@ MonoBehaviour:
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 293920969}
|
||||
m_TargetAssemblyTypeName: LoadDirDateTextChange, Assembly-CSharp
|
||||
m_MethodName: OnValueChanged
|
||||
- m_Target: {fileID: 2024406052}
|
||||
m_TargetAssemblyTypeName: LoadDirChanger, Assembly-CSharp
|
||||
m_MethodName: OnDateValueChanged
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
@@ -1054,19 +1037,6 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 293920964}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &293920969
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 293920964}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cce4f6a22ca8eba4b94c1bfc6ac08072, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
--- !u!1 &350269940
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1245,7 +1215,7 @@ MonoBehaviour:
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 289162993}
|
||||
- m_Target: {fileID: 0}
|
||||
m_TargetAssemblyTypeName: StartSceneEnemyNumChanger, Assembly-CSharp
|
||||
m_MethodName: onValueChanged
|
||||
m_Mode: 1
|
||||
@@ -1936,7 +1906,6 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 651349052}
|
||||
- component: {fileID: 651349054}
|
||||
- component: {fileID: 651349053}
|
||||
m_Layer: 5
|
||||
m_Name: LoadDirToggle
|
||||
m_TagString: Untagged
|
||||
@@ -1964,22 +1933,6 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 10, y: 0}
|
||||
m_SizeDelta: {x: 20, y: 20}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &651349053
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 651349051}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e18f417f93a39c74481660da3236c133, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
LoadDirDateTextBox: {fileID: 293920966}
|
||||
LoadDirTimeTextBox: {fileID: 653235284}
|
||||
Toggle: {fileID: 651349054}
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
--- !u!114 &651349054
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2027,9 +1980,9 @@ MonoBehaviour:
|
||||
onValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 651349053}
|
||||
m_TargetAssemblyTypeName: LoadDirToggle, Assembly-CSharp
|
||||
m_MethodName: OnToggleChanged
|
||||
- m_Target: {fileID: 2024406052}
|
||||
m_TargetAssemblyTypeName: LoadDirChanger, Assembly-CSharp
|
||||
m_MethodName: OnDirToggleChanged
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
@@ -2052,7 +2005,6 @@ GameObject:
|
||||
- component: {fileID: 653235286}
|
||||
- component: {fileID: 653235285}
|
||||
- component: {fileID: 653235284}
|
||||
- component: {fileID: 653235287}
|
||||
m_Layer: 5
|
||||
m_Name: LoadDirTextBox-Time
|
||||
m_TagString: Untagged
|
||||
@@ -2074,7 +2026,7 @@ RectTransform:
|
||||
- {fileID: 112144286}
|
||||
- {fileID: 1086771388}
|
||||
m_Father: {fileID: 1539152182}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@@ -2138,9 +2090,9 @@ MonoBehaviour:
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 653235287}
|
||||
m_TargetAssemblyTypeName: LoadDirTimeTextChange, Assembly-CSharp
|
||||
m_MethodName: OnValueChanged
|
||||
- m_Target: {fileID: 2024406052}
|
||||
m_TargetAssemblyTypeName: LoadDirChanger, Assembly-CSharp
|
||||
m_MethodName: OnTimeValueChanged
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
@@ -2196,19 +2148,6 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 653235282}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &653235287
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 653235282}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8396a1a162e012447a0e4f7626e70dc7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
--- !u!1 &658127036
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3041,7 +2980,6 @@ GameObject:
|
||||
- component: {fileID: 883289519}
|
||||
- component: {fileID: 883289518}
|
||||
- component: {fileID: 883289517}
|
||||
- component: {fileID: 883289520}
|
||||
m_Layer: 5
|
||||
m_Name: Start
|
||||
m_TagString: Untagged
|
||||
@@ -3062,7 +3000,7 @@ RectTransform:
|
||||
m_Children:
|
||||
- {fileID: 42682888}
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 2
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0}
|
||||
m_AnchorMax: {x: 0.5, y: 0}
|
||||
@@ -3113,7 +3051,7 @@ MonoBehaviour:
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 883289520}
|
||||
- m_Target: {fileID: 2024406053}
|
||||
m_TargetAssemblyTypeName: SceneChange, Assembly-CSharp
|
||||
m_MethodName: onStartClick
|
||||
m_Mode: 1
|
||||
@@ -3163,20 +3101,6 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 883289515}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &883289520
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 883289515}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 73ae3df5f5faba1428ab2529c043b7ae, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
errorText: {fileID: 1951625460}
|
||||
--- !u!1 &884034939
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4400,6 +4324,7 @@ RectTransform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_Children:
|
||||
- {fileID: 2024406050}
|
||||
- {fileID: 1982556591}
|
||||
- {fileID: 1951625459}
|
||||
- {fileID: 883289516}
|
||||
@@ -4714,11 +4639,11 @@ RectTransform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 132436945}
|
||||
- {fileID: 653235283}
|
||||
- {fileID: 293920965}
|
||||
- {fileID: 653235283}
|
||||
- {fileID: 651349052}
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 3
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
@@ -4734,7 +4659,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1544423167}
|
||||
- component: {fileID: 1544423168}
|
||||
m_Layer: 5
|
||||
m_Name: TimeLimit
|
||||
m_TagString: Untagged
|
||||
@@ -4756,28 +4680,13 @@ RectTransform:
|
||||
- {fileID: 83479714}
|
||||
- {fileID: 1165772551}
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 7
|
||||
m_RootOrder: 8
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 214, y: -320}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1544423168
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1544423166}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7857e2b2e5caf6b4686c4a7d87fa998e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
TimeLimText: {fileID: 1165772552}
|
||||
TimelimInput: {fileID: 83479715}
|
||||
--- !u!1 &1546066799
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4821,7 +4730,7 @@ RectTransform:
|
||||
- {fileID: 658127037}
|
||||
- {fileID: 1792678409}
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 4
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
@@ -5019,9 +4928,9 @@ MonoBehaviour:
|
||||
onValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 2046915485}
|
||||
m_TargetAssemblyTypeName: DecisionPeriodChanger, Assembly-CSharp
|
||||
m_MethodName: onToggleChanged
|
||||
- m_Target: {fileID: 2024406051}
|
||||
m_TargetAssemblyTypeName: EnvArgsChanger, Assembly-CSharp
|
||||
m_MethodName: onABDToggleChanged
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
@@ -5845,7 +5754,7 @@ RectTransform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@@ -6082,7 +5991,7 @@ RectTransform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 0
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@@ -6206,6 +6115,94 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2010289379}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &2024406049
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2024406050}
|
||||
- component: {fileID: 2024406053}
|
||||
- component: {fileID: 2024406052}
|
||||
- component: {fileID: 2024406051}
|
||||
m_Layer: 5
|
||||
m_Name: UIManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &2024406050
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2024406049}
|
||||
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_Children: []
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2024406051
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2024406049}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ccfe892ab0f980343b6df0fafaec38e2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
EnemyNumText: {fileID: 1746261330}
|
||||
EnemyNumInput: {fileID: 409680777}
|
||||
TimeLimText: {fileID: 1165772552}
|
||||
TimelimInput: {fileID: 83479715}
|
||||
DecisionPeriodSlide: {fileID: 2025428252}
|
||||
DecisionPeriodDataText: {fileID: 901241037}
|
||||
TakeActionsBetweenDecisionsToggle: {fileID: 1633180793}
|
||||
--- !u!114 &2024406052
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2024406049}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 664e98da80fb4d842b0c3aff09fd4dc9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
LoadDirDateTextBox: {fileID: 293920966}
|
||||
LoadDirTimeTextBox: {fileID: 653235284}
|
||||
Toggle: {fileID: 651349054}
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
--- !u!114 &2024406053
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2024406049}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 73ae3df5f5faba1428ab2529c043b7ae, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
errorText: {fileID: 1951625460}
|
||||
--- !u!1 &2025428250
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -6296,9 +6293,9 @@ MonoBehaviour:
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 2046915485}
|
||||
m_TargetAssemblyTypeName: DecisionPeriodChanger, Assembly-CSharp
|
||||
m_MethodName: onSlideValueChanged
|
||||
- m_Target: {fileID: 2024406051}
|
||||
m_TargetAssemblyTypeName: EnvArgsChanger, Assembly-CSharp
|
||||
m_MethodName: onDPSlideValueChanged
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
@@ -6317,7 +6314,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2046915484}
|
||||
- component: {fileID: 2046915485}
|
||||
m_Layer: 5
|
||||
m_Name: DecisionPeriod
|
||||
m_TagString: Untagged
|
||||
@@ -6341,29 +6337,13 @@ RectTransform:
|
||||
- {fileID: 473186479}
|
||||
- {fileID: 901241036}
|
||||
m_Father: {fileID: 1375409014}
|
||||
m_RootOrder: 5
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 214, y: -348.5}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2046915485
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2046915483}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0d097ecbef2d7b843b772144dd301b2b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
DataTransfer: {fileID: 1483319556}
|
||||
DecisionPeriodSlide: {fileID: 2025428252}
|
||||
DecisionPeriodDataText: {fileID: 901241037}
|
||||
TakeActionsBetweenDecisionsToggle: {fileID: 1633180793}
|
||||
--- !u!1 &2070899079
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -65,7 +65,6 @@ public class AgentWithGun : Agent
|
||||
public float mouseYSensitivity = 200;
|
||||
public float yRotation = 0.1f;//定义一个浮点类型的量,记录‘围绕’X轴旋转的角度
|
||||
|
||||
|
||||
private float startTime = 0;
|
||||
private int shoot = 0;
|
||||
private float lastShootTime = 0.0f;
|
||||
@@ -95,47 +94,80 @@ public class AgentWithGun : Agent
|
||||
|
||||
void Start()
|
||||
{
|
||||
DataTransfer = GameObject.Find("StartSeneDataTransfer").GetComponent<StartSeneData>();
|
||||
UICon = transform.GetComponent<UIController>();
|
||||
HistoryRec = transform.GetComponent<HistoryRecorder>();
|
||||
rayScript = GetComponent<RaySensors>();
|
||||
try
|
||||
{
|
||||
// get DataTranfer
|
||||
DataTransfer = GameObject.Find("StartSeneDataTransfer").GetComponent<StartSeneData>();
|
||||
// Enemy Num
|
||||
enemyNum = DataTransfer.EnemyNum;
|
||||
|
||||
// Enemy Num
|
||||
enemyNum = DataTransfer.EnemyNum;
|
||||
// Time Limit
|
||||
timeLimit = DataTransfer.Timelim;
|
||||
|
||||
// Time Limit
|
||||
timeLimit = DataTransfer.Timelim;
|
||||
// get load directory.
|
||||
LoadDirDate = DataTransfer.LoadDirDate;
|
||||
LoadDirTime = DataTransfer.LoadDirTime;
|
||||
LoadDirDateF = float.Parse(LoadDirDate);
|
||||
loadDirTimeF = float.Parse(LoadDirTime);
|
||||
|
||||
// get load directory.
|
||||
LoadDirDate = DataTransfer.LoadDirDate;
|
||||
LoadDirTime = DataTransfer.LoadDirTime;
|
||||
LoadDirDateF = float.Parse(LoadDirDate);
|
||||
loadDirTimeF = float.Parse(LoadDirTime);
|
||||
// get Default reward.
|
||||
nonRewardDefault = DataTransfer.nonReward;
|
||||
shootRewardDefault = DataTransfer.shootReward;
|
||||
shootWithoutReadyRewardDefault = DataTransfer.shootWithoutReadyReward;
|
||||
hitRewardDefault = DataTransfer.hitReward;
|
||||
killRewardDefault = DataTransfer.killReward;
|
||||
winRewardDefault = DataTransfer.winReward;
|
||||
loseRewardDefault = DataTransfer.loseReward;
|
||||
|
||||
// get Default reward.
|
||||
nonRewardDefault = DataTransfer.nonReward;
|
||||
shootRewardDefault = DataTransfer.shootReward;
|
||||
shootWithoutReadyRewardDefault = DataTransfer.shootWithoutReadyReward;
|
||||
hitRewardDefault = DataTransfer.hitReward;
|
||||
killRewardDefault = DataTransfer.killReward;
|
||||
winRewardDefault = DataTransfer.winReward;
|
||||
loseRewardDefault = DataTransfer.loseReward;
|
||||
|
||||
// give default Reward to Reward value will be used.
|
||||
nonReward = nonRewardDefault;
|
||||
shootReward = shootRewardDefault;
|
||||
shootWithoutReadyReward = shootWithoutReadyRewardDefault;
|
||||
hitReward = hitRewardDefault;
|
||||
winReward = winRewardDefault;
|
||||
loseReward = loseRewardDefault;
|
||||
killReward = killRewardDefault;
|
||||
// change Decision Period & Take Actions Between Decisions
|
||||
transform.GetComponent<DecisionRequester>().DecisionPeriod = DataTransfer.DecisionPeriod;
|
||||
transform.GetComponent<DecisionRequester>().TakeActionsBetweenDecisions = DataTransfer.ActionsBetweenDecisions;
|
||||
|
||||
// change Decision Period & Take Actions Between Decisions
|
||||
transform.GetComponent<DecisionRequester>().DecisionPeriod = DataTransfer.DecisionPeriod;
|
||||
transform.GetComponent<DecisionRequester>().TakeActionsBetweenDecisions = DataTransfer.ActionsBetweenDecisions;
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// Enemy Num
|
||||
enemyNum = 3;
|
||||
|
||||
//initialize remainTime
|
||||
remainTime = (int)(timeLimit - Time.time + startTime);
|
||||
// Time Limit
|
||||
timeLimit = 30;
|
||||
|
||||
// get load directory.
|
||||
LoadDirDate = "0";
|
||||
LoadDirTime = "0";
|
||||
LoadDirDateF = float.Parse(LoadDirDate);
|
||||
loadDirTimeF = float.Parse(LoadDirTime);
|
||||
|
||||
// get Default reward.
|
||||
nonRewardDefault = -0.05f;
|
||||
shootRewardDefault = -0.06f;
|
||||
shootWithoutReadyRewardDefault = -0.06f;
|
||||
hitRewardDefault = 5.0f;
|
||||
killRewardDefault = 10.0f;
|
||||
winRewardDefault = 20.0f;
|
||||
loseRewardDefault = -10.0f;
|
||||
|
||||
// change Decision Period & Take Actions Between Decisions
|
||||
transform.GetComponent<DecisionRequester>().DecisionPeriod = 1;
|
||||
transform.GetComponent<DecisionRequester>().TakeActionsBetweenDecisions = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
UICon = transform.GetComponent<UIController>();
|
||||
HistoryRec = transform.GetComponent<HistoryRecorder>();
|
||||
rayScript = GetComponent<RaySensors>();
|
||||
|
||||
// give default Reward to Reward value will be used.
|
||||
nonReward = nonRewardDefault;
|
||||
shootReward = shootRewardDefault;
|
||||
shootWithoutReadyReward = shootWithoutReadyRewardDefault;
|
||||
hitReward = hitRewardDefault;
|
||||
winReward = winRewardDefault;
|
||||
loseReward = loseRewardDefault;
|
||||
killReward = killRewardDefault;
|
||||
//initialize remainTime
|
||||
remainTime = (int)(timeLimit - Time.time + startTime);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------此Update用于debug,Build前删除或注释掉!----------*/
|
||||
@@ -300,7 +332,7 @@ public class AgentWithGun : Agent
|
||||
//且绕轴旋转的坐标轴是父节点本地坐标系的坐标轴
|
||||
}
|
||||
|
||||
// GotKill 获得击杀时用于呼出
|
||||
// GotKill 获得击杀时用于被呼出
|
||||
public void GotKill()
|
||||
{
|
||||
enemyKillCount += 1;
|
||||
@@ -493,19 +525,17 @@ public class AgentWithGun : Agent
|
||||
//List<float> enemyLDisList = RaySensors.enemyLDisList;// All Enemy Lside Distances
|
||||
//List<float> enemyRDisList = RaySensors.enemyRDisList;// All Enemy Rside Distances
|
||||
|
||||
|
||||
int allEnemyNum = RaySensors.allEnemyNum;
|
||||
rayScript.updateRayInfo();
|
||||
float[] myObserve = { thisAgent.position.x, thisAgent.position.y, thisAgent.position.z, thisAgent.rotation.w };
|
||||
float[] rayTagResult = RaySensors.rayTagResult;// 探测用RayTag结果 float[](raySensorNum,1)
|
||||
float[] rayDisResult = RaySensors.rayDisResult; // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
float[] focusEnemyObserve = RaySensors.focusEnemyInfo;// 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
int raySensorNum = rayScript.rayNum;// raySensor数量 int
|
||||
float[] rayTagResult = rayScript.rayTagResult;// 探测用RayTag结果 float[](raySensorNum,1)
|
||||
float[] rayDisResult = rayScript.rayDisResult; // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
//float[] focusEnemyObserve = RaySensors.focusEnemyInfo;// 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
|
||||
//sensor.AddObservation(allEnemyNum); // 敌人数量 int
|
||||
sensor.AddObservation(myObserve); // 自机位置xyz+朝向 float[](4,1)
|
||||
sensor.AddObservation(rayTagResult); // 探测用RayTag结果 float[](raySensorNum,1)
|
||||
sensor.AddObservation(rayDisResult); // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
sensor.AddObservation(focusEnemyObserve); // 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
//sensor.AddObservation(focusEnemyObserve); // 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
//sensor.AddObservation(raySensorNum); // raySensor数量 int
|
||||
sensor.AddObservation(LoadDirDateF); // 用于loadModel的第一级dir
|
||||
sensor.AddObservation(loadDirTimeF); // 用于loadModel的第二级dir
|
||||
|
||||
@@ -6,6 +6,7 @@ public class CameraChange : MonoBehaviour
|
||||
{
|
||||
public Camera FPSCamera;
|
||||
public Camera TPSCamera;
|
||||
public GameObject AgentOBJ;
|
||||
|
||||
public void switchCamera()
|
||||
{
|
||||
@@ -26,10 +27,12 @@ public class CameraChange : MonoBehaviour
|
||||
{
|
||||
TPSCamera.enabled = true;
|
||||
FPSCamera.enabled = false;
|
||||
AgentOBJ.GetComponent<RaySensors>().showInGameRay = true;
|
||||
}
|
||||
public void ShowFPSView()
|
||||
{
|
||||
FPSCamera.enabled = true;
|
||||
TPSCamera.enabled = false;
|
||||
AgentOBJ.GetComponent<RaySensors>().showInGameRay = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Camera_Control : MonoBehaviour
|
||||
{
|
||||
public Transform Agent;
|
||||
public Camera Cam;
|
||||
public float MouseSensitivity = 100;
|
||||
public float yRotation = 0.1f;//定义一个浮点类型的量,记录‘围绕’X轴旋转的角度
|
||||
public float viewDistance = 100;
|
||||
|
||||
private float Mouse_X;
|
||||
private float Mouse_Y;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;// 隐藏并且锁定鼠标
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
//Mouse_X = Input.GetAxis("Mouse X") * MouseSensitivity * Time.deltaTime;
|
||||
//Debug.Log(Input.GetAxis("Mouse X"));
|
||||
//Mouse_Y = Input.GetAxis("Mouse Y") * MouseSensitivity * Time.deltaTime;
|
||||
|
||||
//yRotation = yRotation - Mouse_Y;
|
||||
//xRotation值为正时,屏幕下移,当xRotation值为负时,屏幕上移
|
||||
//当鼠标向上滑动,Mouse_Y值为正,xRotation-Mouse_Y的值为负,xRotation总的值为负,屏幕视角向上滑动
|
||||
//当鼠标向下滑动,Mouse_Y值为负,xRotation-Mouse_Y的值为正,xRotation总的值为正,屏幕视角向下滑动
|
||||
//简单来说就是要控制鼠标滑动的方向与屏幕移动的方向要相同
|
||||
|
||||
//limit UP DOWN between -90 -> 90
|
||||
//yRotation = Mathf.Clamp(yRotation, -90f, 90f);
|
||||
|
||||
|
||||
//相机左右旋转时,是以Y轴为中心旋转的,上下旋转时,是以X轴为中心旋转的
|
||||
//Agent.Rotate(Vector3.up * Mouse_X);
|
||||
//Vector3.up相当于Vector3(0,1,0),CameraRotation.Rotate(Vector3.up * Mouse_X)相当于使CameraRotation对象绕y轴旋转Mouse_X个单位
|
||||
//即相机左右旋转时,是以Y轴为中心旋转的,此时Mouse_X控制着值的大小
|
||||
|
||||
//相机在上下旋转移动时,相机方向不会随着移动,类似于低头和抬头,左右移动时,相机方向会随着向左向右移动,类似于向左向右看
|
||||
//所以在控制相机向左向右旋转时,要保证和父物体一起转动
|
||||
//this.transform.localRotation = Quaternion.Euler(yRotation, 0, 0);
|
||||
//this.transform指这个CameraRotation的位置,localRotation指的是旋转轴
|
||||
//transform.localRotation = Quaternion.Eular(x,y,z)控制旋转的时候,按照X-Y-Z轴的旋转顺规
|
||||
//即以围绕X轴旋转x度,围绕Y轴旋转y度,围绕Z轴旋转z度
|
||||
//且绕轴旋转的坐标轴是父节点本地坐标系的坐标轴
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -15,6 +15,10 @@ public class EnemyHPBar : MonoBehaviour
|
||||
EnemyOBJ = transform.parent.gameObject;
|
||||
BGOBJ = transform.GetChild(0).gameObject;
|
||||
gaugeImgOBJ = BGOBJ.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()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,30 +8,59 @@ using UnityEngine;
|
||||
|
||||
public class RaySensors : MonoBehaviour
|
||||
{
|
||||
|
||||
public Camera agentCam;
|
||||
public GameObject myself;
|
||||
public int rayNum = 6;
|
||||
public string EnemyTagName;
|
||||
public string WallTagName;
|
||||
public float viewDistance = 100; // how long the ray can detect
|
||||
public float Damage = 50; // damage to enemy
|
||||
public float attentionRange = 1f; //注意力范围,1为最大
|
||||
public float MaxDistance = 9999999999f;
|
||||
public float EnemyWidthRedundancy = 0.01f; //为了确保Ray可以击中Enemy,用于缩小EnemyWidth的长度
|
||||
//public List<string> tagNames = new List<string>();
|
||||
public static int allEnemyNum = 0;//All Enemy Num
|
||||
public static float[] focusEnemyInfo = new float[3];
|
||||
public static float[] rayTagResult; // Array to save Tag Result
|
||||
public static float[] rayDisResult; // Array to save Distance Result
|
||||
public static List<float> enemyLDisList = new List<float>();// All Enemy Lside Distances
|
||||
public static List<float> enemyRDisList = new List<float>();// All Enemy Rside Distances
|
||||
public Material lineMeterial;
|
||||
public GameObject rayInfoPrefab;
|
||||
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;
|
||||
|
||||
public bool showEnemySensor = true;
|
||||
public bool showEyeSensor = true;
|
||||
[Header("RayCastResult")]
|
||||
public float[] rayTagResult;
|
||||
public float[] rayDisResult;
|
||||
|
||||
[System.NonSerialized] public int totalRayNum;
|
||||
GameObject[] linesOBJ;
|
||||
GameObject[] rayInfoOBJ;
|
||||
LineRenderer[] lineRenderers;
|
||||
rayInfoUI[] rayInfoUIs;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
totalRayNum = halfOuterRayNum * 2 + focusRayNum;
|
||||
rayTagResult = new float[totalRayNum];
|
||||
rayDisResult = new float[totalRayNum];
|
||||
linesOBJ = new GameObject[totalRayNum];
|
||||
lineRenderers = new LineRenderer[totalRayNum];
|
||||
rayInfoOBJ = new GameObject[totalRayNum];
|
||||
rayInfoUIs = new rayInfoUI[totalRayNum];
|
||||
for(int i = 0; i < totalRayNum; i++)
|
||||
{
|
||||
linesOBJ[i] = new GameObject();
|
||||
linesOBJ[i].name = "rayCastLine-" + Convert.ToString(i);
|
||||
linesOBJ[i].transform.parent = agentCam.transform;
|
||||
linesOBJ[i].AddComponent<LineRenderer>();
|
||||
lineRenderers[i] = linesOBJ[i].GetComponent<LineRenderer>();
|
||||
lineRenderers[i].material = lineMeterial;
|
||||
|
||||
rayInfoOBJ[i] = (GameObject)Instantiate(rayInfoPrefab);
|
||||
rayInfoOBJ[i].transform.SetParent(agentCanvas.transform,false);
|
||||
rayInfoOBJ[i].name = "rayInfo-" + Convert.ToString(i);
|
||||
rayInfoUIs[i] = rayInfoOBJ[i].GetComponent<rayInfoUI>();
|
||||
}
|
||||
}
|
||||
|
||||
static int tagToInt(string tag)
|
||||
{
|
||||
@@ -45,277 +75,107 @@ public class RaySensors : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 敌人Ray探测处理
|
||||
// 返回
|
||||
(int, List<float>, List<float>, float[]) enemySensorRay(GameObject myself, Camera agentCam, float attentionRange)
|
||||
private void singleRaycastUpdate(Ray ray,LineRenderer thisLineRenderer,rayInfoUI thisRayInfoUI, out float rayTagResult, out float rayDisResult)
|
||||
{
|
||||
List<float> thisLDistanceList = new List<float>();
|
||||
List<float> thisRDistanceList = new List<float>();
|
||||
|
||||
GameObject[] EnemyGameObjs;
|
||||
EnemyGameObjs = GameObject.FindGameObjectsWithTag("Enemy");
|
||||
int EnemyIndex = 0;
|
||||
float MinEnemyDis = MaxDistance+1.0f;
|
||||
int MinEnemyIndex = 0;
|
||||
float[] MinEnemyInfo = new float[3];
|
||||
|
||||
//遍历所有Enemy
|
||||
foreach (GameObject EnemyObj in EnemyGameObjs)
|
||||
// get Raycast hit infomation and return Tag and distance
|
||||
RaycastHit thisHit;
|
||||
Color rayColor = Color.cyan;
|
||||
float lineLength = viewDistance;
|
||||
string rayInfoText = "";
|
||||
Vector3 rayInfoPosition;
|
||||
if (Physics.Raycast(ray, out thisHit, viewDistance)) // 若在viewDistance范围内有碰撞
|
||||
{
|
||||
Vector3 thisEnemyPosition = EnemyObj.transform.position;
|
||||
Vector3 thisEnemyScale = EnemyObj.transform.localScale;
|
||||
Vector3 MyselfPosition = myself.transform.position;
|
||||
float thisEnemyWidth = (float)(thisEnemyScale.x / 2) - EnemyWidthRedundancy;
|
||||
float thisEnemyDistance = Vector3.Distance(MyselfPosition, thisEnemyPosition);
|
||||
|
||||
//探测到Agent为自己时的处理
|
||||
if (thisEnemyPosition == MyselfPosition)
|
||||
rayInfoText = thisHit.collider.tag;
|
||||
rayTagResult = tagToInt(thisHit.collider.tag);
|
||||
rayDisResult = thisHit.distance;
|
||||
lineLength = rayDisResult;
|
||||
rayInfoText += "\n" + Convert.ToString(rayDisResult);
|
||||
//输出log
|
||||
switch (rayTagResult)
|
||||
{
|
||||
//Debug.Log("OH It's me");
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
thisRDistanceList.Add(MaxDistance);
|
||||
}
|
||||
//非己Agent处理
|
||||
else
|
||||
{
|
||||
EnemyIndex += 1;
|
||||
Vector3 Vertical = new Vector3(0, 100, 0);//垂直向上的向量
|
||||
Vector3 EnemytoMe = MyselfPosition - thisEnemyPosition;//Enemy和自机连线,指向自机的向量
|
||||
Vector3 LHorizontal = Vector3.Cross(Vertical, EnemytoMe);// 垂直于EnemytoMe与Vertical向量所组成的面的,且指向<-左侧的小向量<- Enemy
|
||||
Vector3 RHorizontal = Vector3.Cross(EnemytoMe, Vertical);// 垂直于EnemytoMe与Vertical向量所组成的面的,且指向->右侧的小向量Enemy ->
|
||||
//此时RHorizontal,LHorizontal的长度巨几把长,需要下面操作标准化为1/2Enemy宽度
|
||||
float standaedization = (float)thisEnemyWidth / Vector3.Distance(thisEnemyPosition, RHorizontal);//计算需要缩小的比例
|
||||
RHorizontal *= standaedization;//应用缩小比例,标准化完成
|
||||
LHorizontal *= standaedization;//应用缩小比例,标准化完成
|
||||
Vector3 LMetoEnemy = LHorizontal - EnemytoMe;//自机与左侧边界连线Me<- Enemy
|
||||
Vector3 RMetoEnemy = RHorizontal - EnemytoMe;//自机与右侧边界连线Enemy ->Me
|
||||
Vector3 L0toEnemy = LHorizontal + thisEnemyPosition;// Enemy左侧绝对坐标
|
||||
Vector3 R0toEnemy = RHorizontal + thisEnemyPosition;// Enemy右侧绝对坐标
|
||||
float LMetoEnemyDist = Vector3.Distance(MyselfPosition, L0toEnemy);
|
||||
float RMetoEnemyDist = Vector3.Distance(MyselfPosition, R0toEnemy);
|
||||
Vector3 LEnemyInView = agentCam.WorldToViewportPoint(L0toEnemy);//Enemy左侧于视角中位置
|
||||
Vector3 REnemyInView = agentCam.WorldToViewportPoint(R0toEnemy);//Enemy右侧于视角中位置
|
||||
//Debug连线,颜色遵循飞机航行灯基本使用规则,左红右绿尾翼白。
|
||||
//Debug.DrawRay(thisEnemyPosition, EnemytoMe, Color.white);//Enemy和自机连线,指向自机的向量
|
||||
//Debug.DrawRay(thisEnemyPosition, Vertical, Color.white);//垂直向上的向量
|
||||
//Debug.DrawRay(thisEnemyPosition, LHorizontal, Color.red);// 垂直于Vc与Vertical向量所组成的面的,且指向<-左侧的小向量<- Enemy
|
||||
//Debug.DrawRay(thisEnemyPosition, RHorizontal, Color.green);// 垂直于Vc与Vertical向量所组成的面的,且指向->右侧的小向量Enemy ->
|
||||
//Debug.DrawRay(MyselfPosition, LMetoEnemy, Color.red);//自机与左侧边界连线<- Enemy
|
||||
//Debug.DrawRay(MyselfPosition, RMetoEnemy, Color.green);//自机与右侧边界连线Enemy ->
|
||||
//Debug.Log("EnemyObj" + EnemyIndex + "Position:" + thisEnemyPosition);
|
||||
|
||||
|
||||
//左侧于可见范围内--<--<--<--<--<--<--<--<--<--<--<--<--<--<
|
||||
if (LEnemyInView.x >= (thisEnemyWidth - attentionRange / 2) && LEnemyInView.x <= (thisEnemyWidth + attentionRange / 2) && LEnemyInView.z > 0)
|
||||
{
|
||||
//射出Raycast
|
||||
Ray LRay = new Ray(MyselfPosition, LMetoEnemy);
|
||||
RaycastHit LHit;
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(LRay.origin, LRay.direction * LMetoEnemyDist, Color.white);//自机与左侧边界连线<- Enemy
|
||||
}
|
||||
//Ray Hit Something
|
||||
if (Physics.Raycast(MyselfPosition, LMetoEnemy, out LHit, LMetoEnemyDist))
|
||||
{
|
||||
//Ray Hit Enemy
|
||||
//并且当射线射到的Enemy的距离与当前判断Enemy的距离差小于该Enemy半径时
|
||||
//既该射线所射到的Enemy为当前Enemy而不是别的时
|
||||
if (LHit.collider.tag == EnemyTagName && System.Math.Abs(LHit.distance - thisEnemyDistance) <= thisEnemyWidth)
|
||||
{
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(LRay.origin, LRay.direction * LHit.distance, Color.red);//自机与所击中物体的连线
|
||||
}
|
||||
thisLDistanceList.Add(LHit.distance);
|
||||
//Debug.Log("Hit Tag = " + LHit.collider.tag);
|
||||
//Debug.Log(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYL");
|
||||
}
|
||||
//当射线所hit的不是enemy或hit的enemy不是当前所判断的enemy
|
||||
else
|
||||
{
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(LRay.origin, LRay.direction * LHit.distance, Color.cyan);//自机与所击中物体的连线
|
||||
}
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
//Debug.LogWarning("Hit Tag = " + LHit.collider.tag);
|
||||
//Debug.LogWarning(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYL");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
Debug.LogError("LRAY HIT NOTHING, Check Code!");
|
||||
}
|
||||
}
|
||||
//左侧不在可见范围内时--<--<--<--<--<--<--<--<--<--<--<--<--<--<
|
||||
else
|
||||
{
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
//Debug.LogError("NoVisual");
|
||||
//Debug.LogError(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYL_ELSE");
|
||||
}
|
||||
|
||||
//右侧于可见范围内-->-->-->-->-->-->-->-->-->-->-->-->-->-->
|
||||
if (REnemyInView.x >= (thisEnemyWidth - attentionRange / 2) && REnemyInView.x <= (thisEnemyWidth + attentionRange / 2) && REnemyInView.z > 0)
|
||||
{
|
||||
//射出Raycast
|
||||
Ray RRay = new Ray(MyselfPosition, RMetoEnemy);
|
||||
RaycastHit RHit;
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(RRay.origin, RRay.direction * RMetoEnemyDist, Color.white);//自机与左侧边界连线<- Enemy
|
||||
}
|
||||
//Ray Hit Something
|
||||
if (Physics.Raycast(MyselfPosition, RMetoEnemy, out RHit, RMetoEnemyDist))
|
||||
{
|
||||
//Ray Hit Enemy
|
||||
//并且当射线射到的Enemy的距离与当前判断Enemy的距离差小于该Enemy半径时
|
||||
//既该射线所射到的Enemy为当前Enemy而不是别的时
|
||||
if (RHit.collider.tag == EnemyTagName && System.Math.Abs(RHit.distance - thisEnemyDistance) <= thisEnemyWidth)
|
||||
{
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(RRay.origin, RRay.direction * RHit.distance, Color.red);//自机与所击中物体的连线
|
||||
}
|
||||
thisRDistanceList.Add(RHit.distance);
|
||||
//Debug.Log("Hit Tag = " + LHit.collider.tag);
|
||||
//Debug.Log(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYR");
|
||||
}
|
||||
//当射线所hit的不是enemy或hit的enemy不是当前所判断的enemy
|
||||
else
|
||||
{
|
||||
if (showEnemySensor)
|
||||
{
|
||||
Debug.DrawRay(RRay.origin, RRay.direction * RHit.distance, Color.cyan);//自机与所击中物体的连线
|
||||
}
|
||||
thisRDistanceList.Add(MaxDistance);
|
||||
//Debug.LogWarning("Hit Tag = " + LHit.collider.tag);
|
||||
//Debug.LogWarning(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYR");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
thisLDistanceList.Add(MaxDistance);
|
||||
Debug.LogError("RRAY HIT NOTHING, Check Code!");
|
||||
}
|
||||
}
|
||||
//右侧不在可见范围内时-->-->-->-->-->-->-->-->-->-->-->-->-->-->
|
||||
else
|
||||
{
|
||||
thisRDistanceList.Add(MaxDistance);
|
||||
//Debug.LogError("NoVisual");
|
||||
//Debug.LogError(LDistance[EnemyIndex-1]);
|
||||
//Debug.Log("ADD_LIST_ENEMYR_ELSE");
|
||||
}
|
||||
}
|
||||
//Debug.LogWarning("EnemyIndex" + EnemyIndex);
|
||||
//Debug.LogWarning(thisLDistanceList.Count);
|
||||
//Debug.LogWarning(MinEnemyIndex);
|
||||
//Debug.Log("thisLDistanceList" + thisLDistanceList.Count);
|
||||
//Debug.Log("thisRDistanceList" + thisRDistanceList.Count);
|
||||
|
||||
//检查最近Enemy
|
||||
if (System.Math.Min(thisLDistanceList[EnemyIndex], thisRDistanceList[EnemyIndex]) < MinEnemyDis)
|
||||
{
|
||||
//Debug.Log("EnemyIndex" + EnemyIndex);
|
||||
MinEnemyDis = System.Math.Min(thisLDistanceList[EnemyIndex], thisRDistanceList[EnemyIndex]);
|
||||
MinEnemyIndex = EnemyIndex;
|
||||
case 1:// Wall
|
||||
rayColor = Color.white;
|
||||
break;
|
||||
case 2: // Enemy
|
||||
rayColor = Color.red;
|
||||
break;
|
||||
case -1: // Hit Nothing
|
||||
rayColor = Color.gray;
|
||||
break;
|
||||
default: // default,got wrong
|
||||
rayColor = Color.cyan;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 获取最近敌人的准确位置信息
|
||||
MinEnemyInfo[0] = (float)MinEnemyIndex;
|
||||
if(MinEnemyInfo[0] <= 0)
|
||||
else // 若在viewDistance范围无碰撞
|
||||
{
|
||||
MinEnemyInfo[1] = MaxDistance;
|
||||
MinEnemyInfo[2] = MaxDistance;
|
||||
rayTagResult = -1f;
|
||||
rayDisResult = -1f;
|
||||
//输出log
|
||||
//Debug.Log(0);
|
||||
//Debug.Log(0);
|
||||
}
|
||||
rayInfoPosition = ray.origin + (ray.direction * lineLength);
|
||||
if (showInGameRay)
|
||||
{
|
||||
drawLine(ray, lineLength, thisLineRenderer, rayColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
MinEnemyInfo[1] = EnemyGameObjs[MinEnemyIndex].transform.position.x;
|
||||
MinEnemyInfo[2] = EnemyGameObjs[MinEnemyIndex].transform.position.z;
|
||||
turnOffLine(thisLineRenderer, rayColor);
|
||||
}
|
||||
return (EnemyIndex, thisLDistanceList, thisRDistanceList,MinEnemyInfo);
|
||||
// drawRay in game
|
||||
if (showInGameRayInfo) thisRayInfoUI.updateInfo(rayInfoText, rayInfoPosition, rayColor);
|
||||
// Show log
|
||||
if (showDebugRay) Debug.DrawRay(ray.origin, ray.direction * viewDistance, rayColor); // drawRay in debug
|
||||
// Debug.Log(ray.origin + ray.direction);
|
||||
// Debug.Log(rayTagResult);
|
||||
// Debug.Log(tagToInt(thisHit.collider.tag));
|
||||
}
|
||||
|
||||
|
||||
// 全局Ray探测处理
|
||||
(float[], float[]) eyeSensorRay(int rayNum, Camera agentCam, float viewDistance)
|
||||
private void drawLine(Ray ray,float lineLength, LineRenderer thisLineRenderer, Color lineColor)
|
||||
{
|
||||
//初始化result Array
|
||||
float[] thisRayTagResult = new float[rayNum];
|
||||
float[] thisRayDisResult = new float[rayNum];
|
||||
|
||||
//于视角范围内一帧射出rayNum条射线
|
||||
for (int a = 0; a <= rayNum - 1; a = a + 1)
|
||||
{
|
||||
//射线射出
|
||||
Vector3 point = new Vector3(a * agentCam.pixelWidth / (rayNum - 1), agentCam.pixelHeight / 2, 0);//发射位置
|
||||
Ray ray = agentCam.ScreenPointToRay(point);
|
||||
RaycastHit hit;
|
||||
if (showEyeSensor)
|
||||
{
|
||||
Debug.DrawRay(ray.origin, ray.direction * viewDistance, Color.black);
|
||||
}
|
||||
//若在viewDistance范围内有碰撞
|
||||
if (Physics.Raycast(ray, out hit, viewDistance))
|
||||
{
|
||||
thisRayTagResult[a] = tagToInt(hit.collider.tag);
|
||||
thisRayDisResult[a] = hit.distance;
|
||||
if (showEyeSensor)
|
||||
{
|
||||
Debug.DrawRay(ray.origin, ray.direction * hit.distance, Color.yellow);
|
||||
}
|
||||
//输出log
|
||||
//Debug.Log(rayTagResult[a]);
|
||||
//Debug.Log(tagToInt(hit.collider.tag));
|
||||
|
||||
}
|
||||
//若在viewDistance范围无碰撞
|
||||
else
|
||||
{
|
||||
thisRayTagResult[a] = -1f;
|
||||
thisRayDisResult[a] = -1f;
|
||||
//输出log
|
||||
//Debug.Log(0);
|
||||
//Debug.Log(0);
|
||||
}
|
||||
}
|
||||
return (thisRayTagResult, thisRayDisResult);
|
||||
thisLineRenderer.startColor = lineColor;
|
||||
thisLineRenderer.endColor = lineColor;
|
||||
thisLineRenderer.startWidth = lineWidth;
|
||||
thisLineRenderer.endWidth = lineWidth;
|
||||
thisLineRenderer.SetPosition(0, ray.origin);
|
||||
thisLineRenderer.SetPosition(1, ray.origin + (ray.direction * lineLength));
|
||||
}
|
||||
|
||||
void Start()
|
||||
private void turnOffLine(LineRenderer thisLineRenderer, Color lineColor)
|
||||
{
|
||||
rayTagResult = new float[rayNum];
|
||||
rayDisResult = new float[rayNum];
|
||||
thisLineRenderer.startColor = lineColor;
|
||||
thisLineRenderer.endColor = lineColor;
|
||||
thisLineRenderer.startWidth = 0f;
|
||||
thisLineRenderer.endWidth = 0f;
|
||||
thisLineRenderer.SetPosition(0, new Vector3(0, 0, 0));
|
||||
thisLineRenderer.SetPosition(1, new Vector3(0, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Update()
|
||||
public void updateRayInfo()
|
||||
{
|
||||
(rayTagResult, rayDisResult) = eyeSensorRay(rayNum, agentCam, viewDistance);
|
||||
(allEnemyNum, enemyLDisList, enemyRDisList, focusEnemyInfo) = enemySensorRay(myself, agentCam, attentionRange);
|
||||
transform.gameObject.GetComponent<UIController>().updateRemainEnemy(allEnemyNum);
|
||||
/*
|
||||
Debug.LogWarning("rayNum :" + rayNum);
|
||||
for (int i =0;i < rayNum; i++)
|
||||
float focusLEdge = agentCam.pixelWidth * (1 - focusRange) / 2;
|
||||
float focusREdge = agentCam.pixelWidth * (1 + focusRange) / 2;
|
||||
float thisCamPixelHeight = agentCam.pixelHeight;
|
||||
|
||||
for (int i = 0; i < halfOuterRayNum; i++) // create left outside rays; 0 ~ focusLeftEdge
|
||||
{
|
||||
Debug.Log("rayTagResult" + rayTagResult[i] + "rayDisResult"+ rayDisResult[i]);
|
||||
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]);
|
||||
}
|
||||
Debug.LogWarning("EnemyNum Include Me:" + allEnemyNum);
|
||||
for(int i = 0; i < allEnemyNum; i++)
|
||||
for (int i = 0; i < halfOuterRayNum; i++) // create right outside rays; focusRightEdge ~ MaxPixelHeight
|
||||
{
|
||||
Debug.Log("enemyLDisList" + enemyLDisList[i] + "enemyRDisList" + enemyRDisList[i]);
|
||||
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]);
|
||||
}
|
||||
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]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class rayInfoUI : MonoBehaviour
|
||||
{
|
||||
TextMeshProUGUI infoText;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
infoText = transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
public void updateInfo(string info,Vector3 infoPosition, Color infoColor)
|
||||
{
|
||||
infoText.text = info;
|
||||
infoText.color = infoColor;
|
||||
transform.position = infoPosition;
|
||||
Vector3 v = Camera.main.transform.position - infoPosition;
|
||||
v.x = v.z = 0.0f;
|
||||
transform.LookAt(Camera.main.transform.position - v);
|
||||
transform.Rotate(0, 180, 0);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cce4f6a22ca8eba4b94c1bfc6ac08072
|
||||
guid: 812dfed7ee1d09c4fa7c3ed8372f54ae
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,22 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DecisionPeriodChanger : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public Slider DecisionPeriodSlide;
|
||||
public Text DecisionPeriodDataText;
|
||||
public Toggle TakeActionsBetweenDecisionsToggle;
|
||||
|
||||
public void onSlideValueChanged()
|
||||
{
|
||||
DataTransfer.GetComponent<StartSeneData>().DecisionPeriod = (int)(DecisionPeriodSlide.GetComponent<Slider>().value);
|
||||
DecisionPeriodDataText.text = DataTransfer.GetComponent<StartSeneData>().DecisionPeriod.ToString();
|
||||
}
|
||||
public void onToggleChanged()
|
||||
{
|
||||
DataTransfer.GetComponent<StartSeneData>().ActionsBetweenDecisions = TakeActionsBetweenDecisionsToggle.isOn;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d097ecbef2d7b843b772144dd301b2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EnvArgsChanger : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
|
||||
[Header("EnemyNum")]
|
||||
public Text EnemyNumText;
|
||||
public InputField EnemyNumInput;
|
||||
|
||||
[Header("TimeLimit")]
|
||||
public Text TimeLimText;
|
||||
public InputField TimelimInput;
|
||||
|
||||
[Header("Decision Period")]
|
||||
public Slider DecisionPeriodSlide;
|
||||
public Text DecisionPeriodDataText;
|
||||
public Toggle TakeActionsBetweenDecisionsToggle;
|
||||
|
||||
|
||||
public void onEnemynumValueChanged()
|
||||
{
|
||||
// enemy total num value control
|
||||
if (EnemyNumInput.GetComponent<InputField>().text == "" || EnemyNumInput.GetComponent<InputField>().text.Contains("-"))
|
||||
{
|
||||
EnemyNumText.color = Color.gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnemyNumText.color = Color.yellow;
|
||||
DataTransfer.GetComponent<StartSeneData>().EnemyNum = Math.Abs(int.Parse(EnemyNumInput.GetComponent<InputField>().text));
|
||||
}
|
||||
}
|
||||
|
||||
public void onTimeValueChanged()
|
||||
{
|
||||
// time limit value control
|
||||
if (TimelimInput.GetComponent<InputField>().text == "" || TimelimInput.GetComponent<InputField>().text.Contains("-"))
|
||||
{
|
||||
TimeLimText.color = Color.gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeLimText.color = Color.yellow;
|
||||
DataTransfer.GetComponent<StartSeneData>().Timelim = Math.Abs(int.Parse(TimelimInput.GetComponent<InputField>().text));
|
||||
}
|
||||
}
|
||||
|
||||
public void onDPSlideValueChanged()
|
||||
{
|
||||
// DecisionPeriod(DP) value Control
|
||||
DataTransfer.GetComponent<StartSeneData>().DecisionPeriod = (int)(DecisionPeriodSlide.GetComponent<Slider>().value);
|
||||
DecisionPeriodDataText.text = DataTransfer.GetComponent<StartSeneData>().DecisionPeriod.ToString();
|
||||
}
|
||||
public void onABDToggleChanged()
|
||||
{
|
||||
// Actions Between Decisions(ABD) Toggle Control
|
||||
DataTransfer.GetComponent<StartSeneData>().ActionsBetweenDecisions = TakeActionsBetweenDecisionsToggle.isOn;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ab8f48d4eac07f44b093f714ede051c
|
||||
guid: ccfe892ab0f980343b6df0fafaec38e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+14
-7
@@ -3,19 +3,15 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadDirToggle : MonoBehaviour
|
||||
public class LoadDirChanger : MonoBehaviour
|
||||
{
|
||||
public InputField LoadDirDateTextBox;
|
||||
public InputField LoadDirTimeTextBox;
|
||||
public Toggle Toggle;
|
||||
public GameObject DataTransfer;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnToggleChanged()
|
||||
|
||||
public void OnDirToggleChanged()
|
||||
{
|
||||
// if loadDirToggle is on then turn off the input text boxs.
|
||||
LoadDirDateTextBox.interactable = Toggle.isOn;
|
||||
@@ -27,4 +23,15 @@ public class LoadDirToggle : MonoBehaviour
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirTime = "0";
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDateValueChanged()
|
||||
{
|
||||
string input = LoadDirDateTextBox.GetComponent<InputField>().text;
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirDate = input;
|
||||
}
|
||||
public void OnTimeValueChanged()
|
||||
{
|
||||
string input = LoadDirTimeTextBox.GetComponent<InputField>().text;
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirTime = input;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8396a1a162e012447a0e4f7626e70dc7
|
||||
guid: 664e98da80fb4d842b0c3aff09fd4dc9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadDirDateTextChange : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public void OnValueChanged()
|
||||
{
|
||||
string input = this.GetComponent<InputField>().text;
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirDate = input;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadDirTimeTextChange : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public void OnValueChanged()
|
||||
{
|
||||
string input = this.GetComponent<InputField>().text;
|
||||
DataTransfer.GetComponent<StartSeneData>().LoadDirTime = input;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e18f417f93a39c74481660da3236c133
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class StartSceneEnemyNumChanger : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public InputField EnemyNumInput;
|
||||
public Text EnemyNumText;
|
||||
|
||||
public void onValueChanged()
|
||||
{
|
||||
if (EnemyNumInput.GetComponent<InputField>().text == "" || EnemyNumInput.GetComponent<InputField>().text.Contains("-"))
|
||||
{
|
||||
EnemyNumText.color = Color.gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnemyNumText.color = Color.yellow;
|
||||
DataTransfer.GetComponent<StartSeneData>().EnemyNum = Math.Abs(int.Parse(EnemyNumInput.GetComponent<InputField>().text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64d0bcf55e4db0c488996ba1051c279f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class StartSceneTimeLimChanger : MonoBehaviour
|
||||
{
|
||||
public GameObject DataTransfer;
|
||||
public Text TimeLimText;
|
||||
public InputField TimelimInput;
|
||||
|
||||
public void onValueTimeChanged()
|
||||
{
|
||||
if (TimelimInput.GetComponent<InputField>().text == "" || TimelimInput.GetComponent<InputField>().text.Contains("-"))
|
||||
{
|
||||
TimeLimText.color = Color.gray;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeLimText.color = Color.yellow;
|
||||
DataTransfer.GetComponent<StartSeneData>().Timelim = Math.Abs(int.Parse(TimelimInput.GetComponent<InputField>().text));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7857e2b2e5caf6b4686c4a7d87fa998e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user