V3.1.2 追加Train Button选择
引入DOTween Plugin 追加Train Button选择和其动画 优化代码
This commit is contained in:
@@ -85,24 +85,10 @@ public class AgentWithGun : Agent
|
||||
[System.NonSerialized] public int finishedState;
|
||||
|
||||
// start scene datas 0=train 1=play
|
||||
private int gamemode;
|
||||
private int gameMode;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// initialize startSceneData & datas
|
||||
// while GameObject StartSceneDataTransfer is exist
|
||||
try
|
||||
{
|
||||
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
|
||||
gamemode = startSceneData.gamemode;
|
||||
}
|
||||
// while GameObject StartSceneDataTransfer is not exist
|
||||
catch
|
||||
{
|
||||
Debug.LogError("Run WithOut StartScreen");
|
||||
gamemode = 1;
|
||||
}
|
||||
|
||||
// initialize scripts
|
||||
paramContainer = parameterContainerObj.GetComponent<ParameterContainer>();
|
||||
eneContainer = enemyContainerObj.GetComponent<EnemyContainer>();
|
||||
@@ -113,6 +99,9 @@ public class AgentWithGun : Agent
|
||||
raySensors = GetComponent<RaySensors>();
|
||||
playerController = this.transform.GetComponent<CharacterController>();
|
||||
|
||||
// initialize gamemode from PrameterContainer
|
||||
gameMode = paramContainer.gameMode;
|
||||
|
||||
// initialize Environment parameters
|
||||
lockMouse = paramContainer.lockMouse;
|
||||
damage = paramContainer.damage;
|
||||
@@ -456,7 +445,7 @@ public class AgentWithGun : Agent
|
||||
}
|
||||
paramContainer.ResetTimeBonusReward();
|
||||
//thisAgentObj.name = thisAgentObj.GetInstanceID().ToString();
|
||||
if (gamemode == 0)
|
||||
if (gameMode == 0)
|
||||
{
|
||||
// train mode
|
||||
targetCon.RollNewScene();
|
||||
|
||||
@@ -7,6 +7,7 @@ public class ParameterContainer : MonoBehaviour
|
||||
public GameObject agentObj;
|
||||
private TargetController targetCon;
|
||||
private SceneBlockContainer blockCont;
|
||||
private StartSeneData startSceneData;
|
||||
private float agentDistance;
|
||||
private int agentInArea;
|
||||
|
||||
@@ -132,6 +133,11 @@ public class ParameterContainer : MonoBehaviour
|
||||
private float targetInAreaTime = 0f;
|
||||
private float lastFrameTime = 0f;
|
||||
|
||||
[System.NonSerialized] public int gameMode;
|
||||
[System.NonSerialized] public float attackProb = 0f;
|
||||
[System.NonSerialized] public float gotoProb = 0f;
|
||||
[System.NonSerialized] public float defenceProb = 0f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
targetCon = targetConObj.GetComponent<TargetController>();
|
||||
@@ -139,6 +145,19 @@ public class ParameterContainer : MonoBehaviour
|
||||
areaTimeBonus = areaTimeBonusPerSec * timeLimit;
|
||||
freeTimeBonus = freeTimeBonusPerSec * timeLimit;
|
||||
targetTimeBonus = targetTimeBonusPerSec * timeLimit;
|
||||
try
|
||||
{
|
||||
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
|
||||
gameMode = startSceneData.gamemode;
|
||||
attackProb = startSceneData.attackProb;
|
||||
gotoProb = startSceneData.gotoProb;
|
||||
defenceProb = startSceneData.defenceProb;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.LogError("PrameterContainer:Run WithOut StartScreen!");
|
||||
gameMode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
@@ -4,7 +4,7 @@ MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
executionOrder: -1100
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
||||
@@ -16,7 +16,6 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
// area
|
||||
public GameObject edgeUp;
|
||||
|
||||
public GameObject edgeDown;
|
||||
public GameObject edgeLeft;
|
||||
public GameObject edgeRight;
|
||||
@@ -24,7 +23,6 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
//group
|
||||
public string group1Tag = "Player";
|
||||
|
||||
public string group2Tag = "Enemy";
|
||||
|
||||
public float minEnemyAreaX;
|
||||
@@ -67,7 +65,6 @@ public class TargetController : MonoBehaviour
|
||||
private WorldUIController worldUICon;
|
||||
private HUDController hudCon;
|
||||
private RaySensors raySensors;
|
||||
private StartSeneData startSceneData;
|
||||
|
||||
// start scene datas 0=train 1=play
|
||||
private int gamemode;
|
||||
@@ -75,6 +72,22 @@ public class TargetController : MonoBehaviour
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
blockCont = sceneBlockContainerObj.GetComponent<SceneBlockContainer>();
|
||||
envUICon = environmentUIObj.GetComponent<EnvironmentUIControl>();
|
||||
enemyCont = enemyContainerObj.GetComponent<EnemyContainer>();
|
||||
agentCharaCon = agentObj.GetComponent<CharacterController>();
|
||||
paramCon = parameterContainerObj.GetComponent<ParameterContainer>();
|
||||
worldUICon = worldUIObj.GetComponent<WorldUIController>();
|
||||
hudCon = HUDObj.GetComponent<HUDController>();
|
||||
raySensors = agentObj.GetComponent<RaySensors>();
|
||||
|
||||
// get parameter from ParameterContainer
|
||||
gamemode = paramCon.gameMode;
|
||||
attackProb = paramCon.attackProb;
|
||||
gotoProb = paramCon.gotoProb;
|
||||
defenceProb = paramCon.defenceProb;
|
||||
|
||||
// initialize spawn area
|
||||
minEnemyAreaX = edgeLeft.transform.localPosition.x + 1.0f;
|
||||
maxEnemyAreaX = edgeRight.transform.localPosition.x - 1.0f;
|
||||
minEnemyAreaZ = edgeAgent_Enemy.transform.localPosition.z + 1.0f;
|
||||
@@ -85,33 +98,12 @@ public class TargetController : MonoBehaviour
|
||||
minAgentAreaZ = edgeDown.transform.localPosition.z + 1.0f;
|
||||
maxAgentAreaZ = edgeAgent_Enemy.transform.localPosition.z - 1.0f;
|
||||
|
||||
blockCont = sceneBlockContainerObj.GetComponent<SceneBlockContainer>();
|
||||
envUICon = environmentUIObj.GetComponent<EnvironmentUIControl>();
|
||||
enemyCont = enemyContainerObj.GetComponent<EnemyContainer>();
|
||||
agentCharaCon = agentObj.GetComponent<CharacterController>();
|
||||
paramCon = parameterContainerObj.GetComponent<ParameterContainer>();
|
||||
worldUICon = worldUIObj.GetComponent<WorldUIController>();
|
||||
hudCon = HUDObj.GetComponent<HUDController>();
|
||||
raySensors = agentObj.GetComponent<RaySensors>();
|
||||
freeProb = 1 - attackProb - gotoProb - defenceProb;
|
||||
targetNum = (int)SceneBlockContainer.Targets.Num;
|
||||
if (freeProb < 0)
|
||||
{
|
||||
Debug.LogError("target percentage wrong");
|
||||
}
|
||||
// initialize startSceneData & datas
|
||||
// while GameObject StartSceneDataTransfer is exist
|
||||
try
|
||||
{
|
||||
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
|
||||
gamemode = startSceneData.gamemode;
|
||||
}
|
||||
// while GameObject StartSceneDataTransfer is not exist
|
||||
catch
|
||||
{
|
||||
Debug.LogError("Run WithOut StartScreen");
|
||||
gamemode = 1;
|
||||
}
|
||||
|
||||
// initialize a simple fake onehot encoder.
|
||||
for (int i = 0; i < targetNum; i++)
|
||||
|
||||
Reference in New Issue
Block a user