取消使用StartSceneData来跨Scene传输数据,改用CommonParameterContainer Singleton来统一保存所需数据。
This commit is contained in:
@@ -1 +1 @@
|
||||
{"count":1,"self":756.2826752,"total":764.8523027,"children":{"InitializeActuators":{"count":2,"self":0.0009995,"total":0.0009995,"children":null},"InitializeSensors":{"count":2,"self":0.0009996,"total":0.0009996,"children":null},"AgentSendState":{"count":37100,"self":0.21125339999999998,"total":1.2830407,"children":{"CollectObservations":{"count":37100,"self":0.9267048,"total":0.9267048,"children":null},"WriteActionMask":{"count":37100,"self":0.0387572,"total":0.0387572,"children":null},"RequestDecision":{"count":37100,"self":0.1063253,"total":0.1063253,"children":null}}},"DecideAction":{"count":37100,"self":0.20722459999999998,"total":0.20722459999999998,"children":null},"AgentAct":{"count":37100,"self":7.0768464,"total":7.076846,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1698982970","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-UCUNI -hubSessionId d5984e41-9eb5-419b-b909-c7102a7a038f -accessToken RDU4dwbHFHagpTZ1DzxqC9PfukLNfl08b_FimOGj3eo00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Play","end_time_seconds":"1698983735"}}
|
||||
{"count":1,"self":113.55664639999999,"total":114.9330107,"children":{"InitializeActuators":{"count":2,"self":0.00099969999999999985,"total":0.00099969999999999985,"children":null},"InitializeSensors":{"count":2,"self":0.0015095999999999998,"total":0.0015095999999999998,"children":null},"AgentSendState":{"count":5526,"self":0.0352491,"total":0.2273044,"children":{"CollectObservations":{"count":5526,"self":0.1629312,"total":0.1629312,"children":null},"WriteActionMask":{"count":5526,"self":0.0095122,"total":0.0095122,"children":null},"RequestDecision":{"count":5526,"self":0.019611899999999998,"total":0.019611899999999998,"children":null}}},"DecideAction":{"count":5526,"self":0.0385606,"total":0.0385606,"children":null},"AgentAct":{"count":5526,"self":1.1079914,"total":1.1079914,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1700043195","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-Koha9 -hubSessionId 54250353-7623-46bc-bba3-639785619018 -accessToken dmg7obCqK6FT1OSbiLk7TkfQFUczEL1FqgnKIHh02iQ00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Play","end_time_seconds":"1700043310"}}
|
||||
@@ -1 +1 @@
|
||||
{"count":1,"self":65.1525952,"total":65.6026151,"children":{"InitializeActuators":{"count":2,"self":0.0015,"total":0.0015,"children":null},"InitializeSensors":{"count":2,"self":0.0005001,"total":0.0005001,"children":null},"AgentSendState":{"count":1994,"self":0.0115036,"total":0.073176999999999992,"children":{"CollectObservations":{"count":1994,"self":0.0546691,"total":0.0546691,"children":null},"WriteActionMask":{"count":1994,"self":0.0005,"total":0.0005,"children":null},"RequestDecision":{"count":1994,"self":0.0065042999999999993,"total":0.0065042999999999993,"children":null}}},"DecideAction":{"count":1994,"self":0.0091503,"total":0.0091503,"children":null},"AgentAct":{"count":1994,"self":0.36569229999999997,"total":0.36569229999999997,"children":null}},"gauges":{"AKMAgent.CumulativeReward":{"count":1,"max":-2512.52466,"min":-2512.52466,"runningAverage":-2512.52466,"value":-2512.52466,"weightedAverage":-2512.52466}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1697992942","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-3RTM9hQ6yJRZGQKZx8Slg -hubSessionId a9694f1b-42f4-414c-9f3a-decdfec467f4 -accessToken _-EoIL8F11LvGF_SbanmzPmRWk7d3mJZ66R4Zf61pY400ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"StartScene","end_time_seconds":"1697993008"}}
|
||||
{"count":1,"self":127.34176,"total":127.45347029999999,"children":{"InitializeActuators":{"count":2,"self":0.0015118999999999998,"total":0.0015118999999999998,"children":null},"InitializeSensors":{"count":2,"self":0.0014979,"total":0.0014979,"children":null},"AgentSendState":{"count":440,"self":0.0025188999999999997,"total":0.0211316,"children":{"CollectObservations":{"count":440,"self":0.0146118,"total":0.0146118,"children":null},"WriteActionMask":{"count":440,"self":0.0019995,"total":0.0019995,"children":null},"RequestDecision":{"count":440,"self":0.0020014,"total":0.0020014,"children":null}}},"DecideAction":{"count":440,"self":0.0020119,"total":0.0020119,"children":null},"AgentAct":{"count":440,"self":0.08556,"total":0.08556,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1700063905","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-FDy4mXKexQ6X1xL3HWyzB -hubSessionId 8d021f9c-c18a-42ae-b0f7-4f4093f87cc2 -accessToken K_UtjVRjVp9Nhbf1MZoN5JxRN3F_Qnk7hi8pO7re9pw00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"StartScene","end_time_seconds":"1700064032"}}
|
||||
@@ -1 +1 @@
|
||||
{"count":1,"self":18.910166399999998,"total":19.0959014,"children":{"InitializeActuators":{"count":2,"self":0.0015099999999999998,"total":0.0015099999999999998,"children":null},"InitializeSensors":{"count":2,"self":0.0010000999999999999,"total":0.0010000999999999999,"children":null},"AgentSendState":{"count":730,"self":0.0039997999999999995,"total":0.0365276,"children":{"CollectObservations":{"count":730,"self":0.0295184,"total":0.0295184,"children":null},"WriteActionMask":{"count":730,"self":0.0005009,"total":0.0005009,"children":null},"RequestDecision":{"count":730,"self":0.0025085,"total":0.0025085,"children":null}}},"DecideAction":{"count":730,"self":0.0045105,"total":0.0045105,"children":null},"AgentAct":{"count":730,"self":0.1421873,"total":0.1421873,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1699169896","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-J7rVe1b8G4wb35aRr9Xtk -hubSessionId f93adee2-a02d-4be6-8e5a-ff3415a80af3 -accessToken EpvziLiMwlBOKFobSXCiZAOF1Shp6ZnBy7-u-y4-4og00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1699169915"}}
|
||||
{"count":1,"self":15.929832,"total":16.087497199999998,"children":{"InitializeActuators":{"count":2,"self":0.0015029,"total":0.0015029,"children":null},"InitializeSensors":{"count":2,"self":0.0004984,"total":0.0004984,"children":null},"AgentSendState":{"count":588,"self":0.0030039,"total":0.0190315,"children":{"CollectObservations":{"count":588,"self":0.0135233,"total":0.0135233,"children":null},"WriteActionMask":{"count":588,"self":0.0005006,"total":0.0005006,"children":null},"RequestDecision":{"count":588,"self":0.0020036999999999998,"total":0.0020036999999999998,"children":null}}},"DecideAction":{"count":588,"self":0.0075122999999999995,"total":0.0075122999999999995,"children":null},"AgentAct":{"count":588,"self":0.1281163,"total":0.1281163,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1700064038","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-FDy4mXKexQ6X1xL3HWyzB -hubSessionId 8d021f9c-c18a-42ae-b0f7-4f4093f87cc2 -accessToken K_UtjVRjVp9Nhbf1MZoN5JxRN3F_Qnk7hi8pO7re9pw00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1700064054"}}
|
||||
@@ -492,7 +492,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
singleTargetLevelProbabilityPanel: {fileID: 5589415219770305710, guid: 324d8e84c24cdd04ba087763705db1d0, type: 3}
|
||||
startSceneData: {fileID: 1072325866}
|
||||
startSceneData: {fileID: 0}
|
||||
targetLevelProbabilityPanel: []
|
||||
--- !u!1 &294404779
|
||||
GameObject:
|
||||
@@ -1763,6 +1763,90 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 852513428}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &968918527
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 968918529}
|
||||
- component: {fileID: 968918528}
|
||||
m_Layer: 0
|
||||
m_Name: CommonParameterContainer
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &968918528
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 968918527}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 34839c2831b759d4a8347ab655b00f36, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
lockMouse: 0
|
||||
damage: 50
|
||||
fireRate: 0.5
|
||||
timeLimit: 30
|
||||
lockCameraX: 0
|
||||
lockCameraY: 1
|
||||
spawnAgentInAllMap: 1
|
||||
spinRecordMax: 40
|
||||
spinPenaltyThreshold: 10
|
||||
facingInviewEnemyDisCOEF: 0.5
|
||||
group1Tag: Player
|
||||
group2Tag: Enemy
|
||||
hitTargetRewardDefault: 25
|
||||
killTargetEnemyRewardDefault: 25
|
||||
inAreaRewardDefault: 25
|
||||
freeTimeBonusPerSec: 1
|
||||
targetTimeBonusPerSec: 0.5
|
||||
areaTimeBonusPerSec: 0.2
|
||||
distanceReward: 50
|
||||
facingTargetReward: 10
|
||||
goWinRewardDefault: 999
|
||||
attackWinRewardDefault: 999
|
||||
defenceWinRewardDefault: 999
|
||||
freeWinRewardDefault: 999
|
||||
nonReward: -1
|
||||
loseReward: -999
|
||||
shootReward: -0.5
|
||||
hitNonTargetReward: -5
|
||||
killNonTargetReward: -5
|
||||
shootWithoutReadyReward: -1.15
|
||||
killBonusReward: 0
|
||||
facingReward: 5
|
||||
shootTargetAreaReward: 10
|
||||
movePenalty: 0.1
|
||||
spinPenalty: 0.08
|
||||
mousePenalty: 0.06
|
||||
scenePrefabSet: {fileID: 11400000, guid: 6ebbd27eb466c4a41bd2584c1b9c2e1f, type: 2}
|
||||
attackLevelProbs: []
|
||||
gotoLevelProbs: []
|
||||
defenceLevelProbs: []
|
||||
--- !u!4 &968918529
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 968918527}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 462, y: 315.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1064099385
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2044,58 +2128,6 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: -100, y: -7}
|
||||
m_SizeDelta: {x: 160, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &1072325866
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1072325868}
|
||||
- component: {fileID: 1072325867}
|
||||
m_Layer: 0
|
||||
m_Name: StartSceneDataTransfer
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1072325867
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1072325866}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 52ba7faaa6129cf418f26c5933d4ea0e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
gameMode: 0
|
||||
scenePrefabSet: {fileID: 11400000, guid: 6ebbd27eb466c4a41bd2584c1b9c2e1f, type: 2}
|
||||
attackProb: 0
|
||||
attackLevelProbs: []
|
||||
gotoProb: 0
|
||||
gotoLevelProbs: []
|
||||
defenceProb: 0
|
||||
defenceLevelProbs: []
|
||||
--- !u!4 &1072325868
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1072325866}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1144208395
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2248,7 +2280,7 @@ Transform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1273196676
|
||||
GameObject:
|
||||
@@ -2573,7 +2605,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
waitTimeLimit: 45
|
||||
sceneLoaderObj: {fileID: 1206568295}
|
||||
startSceneDataObj: {fileID: 1072325866}
|
||||
targetLevelProbabilityPanelOBJ: {fileID: 237721381}
|
||||
messageTextObj: {fileID: 294404781}
|
||||
waitTimeTextObj: {fileID: 431112176}
|
||||
|
||||
@@ -11176,7 +11176,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0.000030517578, y: -246.20192}
|
||||
m_AnchoredPosition: {x: 0.000030517578, y: -246.20218}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!114 &1442113294
|
||||
@@ -12158,8 +12158,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 34839c2831b759d4a8347ab655b00f36, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
persistThroughScene: 0
|
||||
hudObj: {fileID: 2082200184}
|
||||
lockMouse: 0
|
||||
damage: 50
|
||||
fireRate: 0.5
|
||||
@@ -12196,6 +12194,10 @@ MonoBehaviour:
|
||||
movePenalty: 0.1
|
||||
spinPenalty: 0.08
|
||||
mousePenalty: 0.06
|
||||
scenePrefabSet: {fileID: 11400000, guid: 6ebbd27eb466c4a41bd2584c1b9c2e1f, type: 2}
|
||||
attackLevelProbs: []
|
||||
gotoLevelProbs: []
|
||||
defenceLevelProbs: []
|
||||
--- !u!4 &1580123441
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -16597,7 +16599,7 @@ MonoBehaviour:
|
||||
m_HandleRect: {fileID: 1766662801}
|
||||
m_Direction: 2
|
||||
m_Value: 0
|
||||
m_Size: 0.9998482
|
||||
m_Size: 0.9999959
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
|
||||
@@ -4,11 +4,6 @@ using UnityEngine;
|
||||
|
||||
public class CommonParameterContainer : Singleton<CommonParameterContainer>
|
||||
{
|
||||
[SerializeField] private GameObject hudObj;
|
||||
|
||||
private StartSeneData startSceneData;
|
||||
private MessageBoxController messageCon;
|
||||
|
||||
[Header("Env")]
|
||||
public bool lockMouse = false;
|
||||
public float damage = 50; // damage to enemy
|
||||
@@ -83,43 +78,21 @@ public class CommonParameterContainer : Singleton<CommonParameterContainer>
|
||||
[Tooltip("while move mouse a little bit's penalty")]
|
||||
public float mousePenalty = 0.06f;
|
||||
|
||||
[NonSerialized] public SceneBlocksSet scenePrefabSet;
|
||||
public SceneBlocksSet scenePrefabSet;
|
||||
|
||||
[NonSerialized] public int gameMode; // 0 = trainning mode, 1 = play mode
|
||||
[NonSerialized] public float attackProb = 0f;
|
||||
[NonSerialized] public List<float> attackLevelProbs = new List<float>();
|
||||
public List<float> attackLevelProbs = new List<float>();
|
||||
[NonSerialized] public float gotoProb = 0f;
|
||||
[NonSerialized] public List<float> gotoLevelProbs = new List<float>();
|
||||
public List<float> gotoLevelProbs = new List<float>();
|
||||
[NonSerialized] public float defenceProb = 0f;
|
||||
[NonSerialized] public List<float> defenceLevelProbs = new List<float>();
|
||||
public List<float> defenceLevelProbs = new List<float>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Instance.persistThroughScene = false;
|
||||
messageCon = hudObj.GetComponent<MessageBoxController>();
|
||||
try
|
||||
{
|
||||
// try get start scene data
|
||||
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
|
||||
messageCon.PushMessage(
|
||||
new List<string> { "ParameterContainer:", "StartSceneDataTransfer found!" },
|
||||
new List<string> { "green", "white" });
|
||||
}
|
||||
catch
|
||||
{
|
||||
// if not found, find dummy StartSeneData
|
||||
startSceneData = GameObject.Find("StartSceneDataTransferDummy").GetComponent<StartSeneData>();
|
||||
messageCon.PushMessage(
|
||||
new List<string> { "ParameterContainer:", "StartSceneDataTransfer not found!Use Dummy." },
|
||||
new List<string> { "orange" });
|
||||
}
|
||||
gameMode = startSceneData.gameMode;
|
||||
attackProb = startSceneData.attackProb;
|
||||
attackLevelProbs = startSceneData.attackLevelProbs;
|
||||
gotoProb = startSceneData.gotoProb;
|
||||
gotoLevelProbs = startSceneData.gotoLevelProbs;
|
||||
defenceProb = startSceneData.defenceProb;
|
||||
defenceLevelProbs = startSceneData.defenceLevelProbs;
|
||||
scenePrefabSet = startSceneData.scenePrefabSet;
|
||||
Instance.KeepThroughSceneChange();
|
||||
scenePrefabSet.InitializeSceneBlocksSet();
|
||||
attackLevelProbs = new List<float>(scenePrefabSet.targetLevels[0].levelSize);
|
||||
gotoLevelProbs = new List<float>(scenePrefabSet.targetLevels[1].levelSize);
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,7 @@ public class ParameterContainer : MonoBehaviour
|
||||
|
||||
private TargetController targetCon;
|
||||
private SceneBlockContainer blockCont;
|
||||
private StartSeneData startSceneData;
|
||||
private MessageBoxController messageCon;
|
||||
private CommonParameterContainer commonParamCont;
|
||||
private float agentDistance;
|
||||
private int agentInArea;
|
||||
|
||||
[Header("Dynamic Rewards")]
|
||||
@@ -54,7 +51,6 @@ public class ParameterContainer : MonoBehaviour
|
||||
{
|
||||
targetCon = targetConObj.GetComponent<TargetController>();
|
||||
blockCont = blockConObj.GetComponent<SceneBlockContainer>();
|
||||
messageCon = hudObj.GetComponent<MessageBoxController>();
|
||||
commonParamCont = CommonParameterContainer.Instance;
|
||||
|
||||
areaTimeBonusPerSec = commonParamCont.areaTimeBonusPerSec;
|
||||
@@ -65,22 +61,6 @@ public class ParameterContainer : MonoBehaviour
|
||||
areaTimeBonus = areaTimeBonusPerSec * timeLimit;
|
||||
freeTimeBonus = freeTimeBonusPerSec * timeLimit;
|
||||
targetTimeBonus = targetTimeBonusPerSec * timeLimit;
|
||||
try
|
||||
{
|
||||
// try get start scene data
|
||||
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
|
||||
messageCon.PushMessage(
|
||||
new List<string> { "ParameterContainer:", "StartSceneDataTransfer found!" },
|
||||
new List<string> { "green", "white" });
|
||||
}
|
||||
catch
|
||||
{
|
||||
// if not found, find dummy StartSeneData
|
||||
startSceneData = GameObject.Find("StartSceneDataTransferDummy").GetComponent<StartSeneData>();
|
||||
messageCon.PushMessage(
|
||||
new List<string> { "ParameterContainer:", "StartSceneDataTransfer not found!Use Dummy." },
|
||||
new List<string> { "orange" });
|
||||
}
|
||||
|
||||
// Win Rewards
|
||||
goWinReward = commonParamCont.goWinRewardDefault;
|
||||
@@ -94,7 +74,7 @@ public class ParameterContainer : MonoBehaviour
|
||||
// get target distance and in area
|
||||
if (targetCon.targetType is Targets.Go or Targets.Attack)
|
||||
{
|
||||
(agentDistance, agentInArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
|
||||
(_, agentInArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
|
||||
// attack goto or defence target
|
||||
if (agentInArea == 1)
|
||||
{
|
||||
|
||||
@@ -377,6 +377,7 @@ public class TargetController : MonoBehaviour
|
||||
/// <returns>A random level index.</returns>
|
||||
public int RollRandomLevelIndex(Targets target)
|
||||
{
|
||||
Debug.Log(target);
|
||||
List<float> targetProbs;
|
||||
|
||||
switch (target)
|
||||
@@ -392,9 +393,9 @@ public class TargetController : MonoBehaviour
|
||||
break;
|
||||
default:
|
||||
messageBoxCon.PushMessage(
|
||||
new List<string> { "[ERROR]TargetController:RandomLevel", "target type error" },
|
||||
new List<string> { "[ERROR]TargetController:RollRandomLevelIndex", "target type error" },
|
||||
new List<string> { "#800000ff" });
|
||||
Debug.LogWarning("[ERROR]TargetController:RandomLevel:target type error");
|
||||
Debug.LogWarning("[ERROR]TargetController:RollRandomLevelIndex:target type error");
|
||||
return -1; // Exit early on default case
|
||||
}
|
||||
|
||||
@@ -412,7 +413,7 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
// If no level was returned, log an error and return -1
|
||||
messageBoxCon.PushMessage(
|
||||
new List<string> { "[ERROR]TargetController:RandomLevel", "level index out of range" },
|
||||
new List<string> { "[ERROR]TargetController:RollRandomLevelIndex", "level index out of range" },
|
||||
new List<string> { "orange" });
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -20,21 +20,21 @@ public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public bool persistThroughScene = false;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = this as T;
|
||||
if (persistThroughScene)
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
// keep this instance through scene change
|
||||
public void KeepThroughSceneChange()
|
||||
{
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class StartSeneData : MonoBehaviour
|
||||
public class StartSeneDataremove : MonoBehaviour
|
||||
{
|
||||
[Header("Game mode")]
|
||||
public int gameMode = 0;// default trainning mode
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -12,23 +11,7 @@ public class LevelProbabilityPanel : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (startSceneData == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// try get start scene data
|
||||
scenePrefabSet = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>().scenePrefabSet;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// if not found, find dummy StartSeneData
|
||||
scenePrefabSet = GameObject.Find("StartSceneDataTransferDummy").GetComponent<StartSeneData>().scenePrefabSet;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scenePrefabSet = startSceneData.GetComponent<StartSeneData>().scenePrefabSet;
|
||||
}
|
||||
scenePrefabSet = CommonParameterContainer.Instance.scenePrefabSet;
|
||||
for (int i = 0; i < scenePrefabSet.targetLevels.Length; i++)
|
||||
{
|
||||
Targets nowTarget = scenePrefabSet.targets[i];
|
||||
|
||||
@@ -11,7 +11,7 @@ public class StartMenuProbabilityPanel : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
scenePrefabSet = startSceneData.GetComponent<StartSeneData>().scenePrefabSet;
|
||||
scenePrefabSet = CommonParameterContainer.Instance.scenePrefabSet;
|
||||
for (int i = 0; i < scenePrefabSet.targetLevels.Length; i++)
|
||||
{
|
||||
Targets nowTarget = scenePrefabSet.targets[i];
|
||||
|
||||
@@ -7,24 +7,23 @@ public class StartUIManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private int waitTimeLimit = 45;
|
||||
[SerializeField] private GameObject sceneLoaderObj;
|
||||
[SerializeField] private GameObject startSceneDataObj;
|
||||
[SerializeField] private GameObject targetLevelProbabilityPanelOBJ;
|
||||
[SerializeField] private TextMeshProUGUI messageTextObj;
|
||||
[SerializeField] private TextMeshProUGUI waitTimeTextObj;
|
||||
|
||||
private SceneLoader sceneLoader;
|
||||
private StartSeneData startSceneData;
|
||||
private ButtonActivateColorChanger buttonActivateColorChanger;
|
||||
private StartMenuProbabilityPanel startMenuProbabilityPanel;
|
||||
private CommonParameterContainer commonParameterContainer;
|
||||
private float startTime;
|
||||
private float nowTime;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
sceneLoader = sceneLoaderObj.GetComponent<SceneLoader>();
|
||||
startSceneData = startSceneDataObj.GetComponent<StartSeneData>();
|
||||
buttonActivateColorChanger = GetComponent<ButtonActivateColorChanger>();
|
||||
startMenuProbabilityPanel = targetLevelProbabilityPanelOBJ.GetComponent<StartMenuProbabilityPanel>();
|
||||
commonParameterContainer = CommonParameterContainer.Instance;
|
||||
messageTextObj.text = "";
|
||||
buttonActivateColorChanger.InitializeAllButtonColor();
|
||||
}
|
||||
@@ -44,7 +43,7 @@ public class StartUIManager : MonoBehaviour
|
||||
// while StartButton-Play Pressed
|
||||
public void OnPlayButtonPressed()
|
||||
{
|
||||
startSceneData.gameMode = 1;
|
||||
commonParameterContainer.gameMode = 1;
|
||||
sceneLoader.LoadGameScene(SceneLoader.SceneType.Play);
|
||||
messageTextObj.text = "Loading Play Scene...";
|
||||
}
|
||||
@@ -52,30 +51,30 @@ public class StartUIManager : MonoBehaviour
|
||||
public void OnAttackTrainButtonPressed()
|
||||
{
|
||||
// while Train-Attack-Button Pressed
|
||||
startSceneData.attackProb = 1f;
|
||||
commonParameterContainer.attackProb = 1f;
|
||||
ApplicateProbabilityToData();
|
||||
LoadTrainScene();
|
||||
}
|
||||
public void OnGotoTrainButtonPressed()
|
||||
{
|
||||
// while Train-Goto-Button Pressed
|
||||
startSceneData.gotoProb = 1f;
|
||||
commonParameterContainer.gotoProb = 1f;
|
||||
ApplicateProbabilityToData();
|
||||
LoadTrainScene();
|
||||
}
|
||||
public void OnFreeTrainButtonPressed()
|
||||
{
|
||||
// while Train-Free-Button Pressed
|
||||
startSceneData.attackProb = 0f;
|
||||
startSceneData.gotoProb = 0f;
|
||||
startSceneData.defenceProb = 0f;
|
||||
commonParameterContainer.attackProb = 0f;
|
||||
commonParameterContainer.gotoProb = 0f;
|
||||
commonParameterContainer.defenceProb = 0f;
|
||||
LoadTrainScene();
|
||||
}
|
||||
public void OnMixTrainButtonPressed()
|
||||
{
|
||||
// while Train-Mix-Button Pressed
|
||||
startSceneData.attackProb = 0.333f;
|
||||
startSceneData.gotoProb = 0.333f;
|
||||
commonParameterContainer.attackProb = 0.333f;
|
||||
commonParameterContainer.gotoProb = 0.333f;
|
||||
LoadTrainScene();
|
||||
}
|
||||
private void LoadTrainScene()
|
||||
@@ -87,13 +86,13 @@ public class StartUIManager : MonoBehaviour
|
||||
|
||||
private void ApplicateProbabilityToData()
|
||||
{
|
||||
for (int i = 0; i < startSceneData.scenePrefabSet.targetLevels[0].levelSize; i++)
|
||||
for (int i = 0; i < commonParameterContainer.scenePrefabSet.targetLevels[0].levelSize; i++)
|
||||
{
|
||||
startSceneData.gotoLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[0].singleLevelPanels[i].ProbabilityValue);
|
||||
commonParameterContainer.gotoLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[0].singleLevelPanels[i].ProbabilityValue);
|
||||
}
|
||||
for(int i = 0; i < startSceneData.scenePrefabSet.targetLevels[1].levelSize; i++)
|
||||
for(int i = 0; i < commonParameterContainer.scenePrefabSet.targetLevels[1].levelSize; i++)
|
||||
{
|
||||
startSceneData.attackLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[1].singleLevelPanels[i].ProbabilityValue);
|
||||
commonParameterContainer.attackLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[1].singleLevelPanels[i].ProbabilityValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user