V3.1.6 修正TrainMode中Target不更新问题
修正TrainMode中Target不更新问题
This commit is contained in:
@@ -16,6 +16,7 @@ public class EnemyContainer : MonoBehaviour
|
||||
// initialize enemy by random
|
||||
public void RandomInitEnemys(int EnemyNum)
|
||||
{
|
||||
Debug.Log("RandomInitEnemys");
|
||||
for (int i = 0; i < EnemyNum; i++)
|
||||
{
|
||||
float randX = UnityEngine.Random.Range(targetCon.minEnemyAreaX, targetCon.maxEnemyAreaX);
|
||||
@@ -28,6 +29,7 @@ public class EnemyContainer : MonoBehaviour
|
||||
// initialize enemy by random but not in block area
|
||||
public void RandomInitEnemysExcept(int enemyNum, Vector3 blockPosition, float sceneSize)
|
||||
{
|
||||
Debug.Log("RandomInitEnemysExcept");
|
||||
float randX = 0f;
|
||||
float randZ = 0f;
|
||||
for (int i = 0; i < enemyNum; i++)
|
||||
|
||||
@@ -60,10 +60,12 @@ public class MLAgentsCustomController : Agent
|
||||
if (paramContainer.gameMode == 0)
|
||||
{
|
||||
// train mode
|
||||
Debug.Log("MLAgentCustomController.OnEpisodeBegin: train mode start");
|
||||
targetController.RollNewScene();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("MLAgentCustomController.OnEpisodeBegin: play mode start");
|
||||
// play mode
|
||||
targetController.PlayInitialize();
|
||||
// reset target UI
|
||||
|
||||
@@ -147,6 +147,7 @@ public class ParameterContainer : MonoBehaviour
|
||||
targetTimeBonus = targetTimeBonusPerSec * timeLimit;
|
||||
try
|
||||
{
|
||||
// try get start scene data
|
||||
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
|
||||
gameMode = startSceneData.gameMode;
|
||||
attackProb = startSceneData.attackProb;
|
||||
@@ -157,6 +158,9 @@ public class ParameterContainer : MonoBehaviour
|
||||
{
|
||||
Debug.LogError("PrameterContainer:Run WithOut StartScreen!");
|
||||
gameMode = 0;
|
||||
attackProb = 0.3333f;
|
||||
gotoProb = 0.3333f;
|
||||
defenceProb = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,13 +100,13 @@ public class SceneBlock : MonoBehaviour
|
||||
// if firebasesAreaObj is null, find sub object by name
|
||||
if (fireBasesAreaObj == null)
|
||||
{
|
||||
Debug.Log("SceneBlock.Start: fireBasesAreaObj not found, get it by name");
|
||||
// Debug.Log("SceneBlock.Start: fireBasesAreaObj not found, get it by name");
|
||||
fireBasesAreaObj = transform.Find("FirebasesArea").gameObject;
|
||||
}
|
||||
// if enemyContainerObj is null, find them by name
|
||||
if (enemyContainerObj == null)
|
||||
{
|
||||
Debug.Log("SceneBlock.Start: enemyContainerObj not found, get it by name");
|
||||
// Debug.Log("SceneBlock.Start: enemyContainerObj not found, get it by name");
|
||||
enemyContainerObj = transform.Find("EnemyContainer").gameObject;
|
||||
}
|
||||
firebasesAreaPosition = transform.position + fireBasesAreaObj.transform.position;
|
||||
|
||||
@@ -142,6 +142,7 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// goto target spawn
|
||||
Debug.Log("GOTO THIS TARGET!");
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Go;
|
||||
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Go);
|
||||
// set startDistance
|
||||
firstRewardFlag = true;
|
||||
@@ -150,6 +151,7 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// attack target spawn
|
||||
Debug.Log("ATTACK!");
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Attack;
|
||||
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Attack);
|
||||
// set startDistance
|
||||
firstRewardFlag = true;
|
||||
@@ -159,13 +161,14 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// defence target spawn
|
||||
Debug.Log("DEFENCE!");
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Defence;
|
||||
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Defence);
|
||||
// set startDistance
|
||||
firstRewardFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log("Free");
|
||||
Debug.Log("Free");
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Free;
|
||||
enemyCon.DestroyAllEnemys();
|
||||
enemyCon.RandomInitEnemys(hudCon.enemyNum);
|
||||
@@ -184,14 +187,18 @@ public class TargetController : MonoBehaviour
|
||||
if (thisTargetPosition != null)
|
||||
{
|
||||
targetPosition = (Vector3)thisTargetPosition;
|
||||
Debug.Log("Target Position != null" + targetPosition);
|
||||
}
|
||||
if (targetTypeInt == (int)SceneBlockContainer.Targets.Free || targetTypeInt == (int)SceneBlockContainer.Targets.Stay)
|
||||
{
|
||||
Debug.Log("UpdateTargetStates Target Position: set all zeros ");
|
||||
for (int i = 1; i < targetState.Length; i++)
|
||||
// set target position state to 0
|
||||
targetState[i] = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Target Position == null" + targetPosition);
|
||||
targetState[1] = targetPosition.x;
|
||||
targetState[2] = targetPosition.y;
|
||||
targetState[3] = targetPosition.z;
|
||||
|
||||
Reference in New Issue
Block a user