V3.3.2 LevelProbabilityPanel初始化完成
LevelProbabilityPanel初始化完成 独立Target enum类
This commit is contained in:
@@ -215,7 +215,7 @@ public class AgentController : MonoBehaviour
|
||||
return targetCon.HitEnemyReward(gotHitObj.transform.position);
|
||||
}
|
||||
}
|
||||
if (targetCon.targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
|
||||
if (targetCon.targetTypeInt == (int)Targets.Attack)
|
||||
{
|
||||
// while if attack mode
|
||||
float targetDis = Vector3.Distance(blockContainer.nowBlock.transform.position, transform.position);
|
||||
@@ -253,7 +253,7 @@ public class AgentController : MonoBehaviour
|
||||
bool isFacingtoEnemy = false;
|
||||
float enemyFacingDistance = 0f;
|
||||
Ray ray = fpsCam.ScreenPointToRay(new Vector3(fpsCam.pixelWidth / 2, fpsCam.pixelHeight / 2, 0));
|
||||
if (targetCon.targetTypeInt == (int)SceneBlockContainer.Targets.Free)
|
||||
if (targetCon.targetTypeInt == (int)Targets.Free)
|
||||
{
|
||||
//free mode
|
||||
RaycastHit hit;
|
||||
@@ -299,7 +299,7 @@ public class AgentController : MonoBehaviour
|
||||
// Debug.Log("ninimum = " + nowReward);
|
||||
}
|
||||
}
|
||||
else if (targetCon.targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
|
||||
else if (targetCon.targetTypeInt == (int)Targets.Attack)
|
||||
{
|
||||
// attack mode
|
||||
// Target to Agent distance
|
||||
|
||||
@@ -135,27 +135,27 @@ public class EnvironmentUIControl : MonoBehaviour
|
||||
{
|
||||
switch (targetInt)
|
||||
{
|
||||
case (int)SceneBlockContainer.Targets.Go:
|
||||
case (int)Targets.Go:
|
||||
targetTypeText.text = "GOTO";
|
||||
targetTypeText.color = Color.blue;
|
||||
break;
|
||||
|
||||
case (int)SceneBlockContainer.Targets.Attack:
|
||||
case (int)Targets.Attack:
|
||||
targetTypeText.text = "Attack!";
|
||||
targetTypeText.color = Color.red;
|
||||
break;
|
||||
|
||||
case (int)SceneBlockContainer.Targets.Defence:
|
||||
case (int)Targets.Defence:
|
||||
targetTypeText.text = "Defence";
|
||||
targetTypeText.color = Color.green;
|
||||
break;
|
||||
|
||||
case (int)SceneBlockContainer.Targets.Free:
|
||||
case (int)Targets.Free:
|
||||
targetTypeText.text = "Free";
|
||||
targetTypeText.color = Color.yellow;
|
||||
break;
|
||||
|
||||
case (int)SceneBlockContainer.Targets.Stay:
|
||||
case (int)Targets.Stay:
|
||||
targetTypeText.text = "Stay";
|
||||
targetTypeText.color = Color.white;
|
||||
break;
|
||||
|
||||
@@ -171,7 +171,7 @@ public class MLAgentsCustomController : Agent
|
||||
// Win or lose Finished
|
||||
Debug.Log("Finish reward = " + nowRoundReward);
|
||||
EP += 1;
|
||||
string targetString = Enum.GetName(typeof(SceneBlockContainer.Targets), targetController.targetTypeInt);
|
||||
string targetString = Enum.GetName(typeof(Targets), targetController.targetTypeInt);
|
||||
switch (finishedState)
|
||||
{
|
||||
case (int)TargetController.EndType.Win:
|
||||
|
||||
@@ -180,7 +180,7 @@ public class ParameterContainer : MonoBehaviour
|
||||
private void Update()
|
||||
{
|
||||
// get target distance and in area
|
||||
if (targetCon.targetTypeInt is (int)SceneBlockContainer.Targets.Go or (int)SceneBlockContainer.Targets.Attack)
|
||||
if (targetCon.targetTypeInt is (int)Targets.Go or (int)Targets.Attack)
|
||||
{
|
||||
(agentDistance, agentInArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
|
||||
// attack goto or defence target
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
public class SceneBlockContainer : MonoBehaviour
|
||||
{
|
||||
public enum Targets
|
||||
{ Free, Go, Attack, Defence, Stay, Num };// Num is use for get total target bumber
|
||||
|
||||
public float sceneSize = 10f;
|
||||
public GameObject environmentObj;
|
||||
public GameObject hudObj;
|
||||
|
||||
// public GameObject[] attackBlockPrefabs = new GameObject[1];
|
||||
// public GameObject[] goBlockPrefabs = new GameObject[1];
|
||||
// public GameObject[] defencePrefabs = new GameObject[1];
|
||||
@@ -42,7 +40,7 @@ public class SceneBlockContainer : MonoBehaviour
|
||||
DestroyBlock();
|
||||
}
|
||||
// choose target type
|
||||
nowBlockObj = Instantiate(scenePrefabSet.GetPrefab(targetType, level, blockType), blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
|
||||
nowBlockObj = Instantiate(scenePrefabSet.GetPrefab(level, blockType, targetType), blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
|
||||
nowBlock = nowBlockObj.GetComponent<SceneBlock>();
|
||||
nowBlock.group1Tag = tag1;
|
||||
nowBlock.group2Tag = tag2;
|
||||
|
||||
@@ -104,9 +104,9 @@ public class TargetController : MonoBehaviour
|
||||
maxAgentAreaZ = edgeAgent_Enemy.transform.localPosition.z - 1.0f;
|
||||
|
||||
freeProb = 1 - attackProb - gotoProb - defenceProb;
|
||||
targetNum = (int)SceneBlockContainer.Targets.Num;
|
||||
gotoLevelNum = sceneBlockCon.scenePrefabSet.GetLevelNumber(SceneBlockContainer.Targets.Go);
|
||||
attackLevelNum = sceneBlockCon.scenePrefabSet.GetLevelNumber(SceneBlockContainer.Targets.Attack);
|
||||
targetNum = (int)Targets.Num;
|
||||
gotoLevelNum = sceneBlockCon.scenePrefabSet.GetLevelNumber(Targets.Go);
|
||||
attackLevelNum = sceneBlockCon.scenePrefabSet.GetLevelNumber(Targets.Attack);
|
||||
if (freeProb < 0)
|
||||
{
|
||||
Debug.LogError("TargetController.Start: target percentage wrong");
|
||||
@@ -158,8 +158,8 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// goto target spawn
|
||||
Debug.Log("GOTO THIS TARGET!");
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Go;
|
||||
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Go);
|
||||
targetTypeInt = (int)Targets.Go;
|
||||
RandomSpawnSceneBlock(Targets.Go);
|
||||
// set startDistance
|
||||
firstRewardFlag = true;
|
||||
}
|
||||
@@ -167,8 +167,8 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// attack target spawn
|
||||
Debug.Log("ATTACK!");
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Attack;
|
||||
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Attack);
|
||||
targetTypeInt = (int)Targets.Attack;
|
||||
RandomSpawnSceneBlock(Targets.Attack);
|
||||
// set startDistance
|
||||
firstRewardFlag = true;
|
||||
targetEnemySpawnFinish = false;
|
||||
@@ -177,15 +177,15 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// defence target spawn
|
||||
Debug.Log("DEFENCE!");
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Defence;
|
||||
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Defence);
|
||||
targetTypeInt = (int)Targets.Defence;
|
||||
RandomSpawnSceneBlock(Targets.Defence);
|
||||
// set startDistance
|
||||
firstRewardFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Free");
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Free;
|
||||
targetTypeInt = (int)Targets.Free;
|
||||
enemyCon.DestroyAllEnemys();
|
||||
enemyCon.RandomInitEnemys(hudCon.enemyNum);
|
||||
MoveAgentToSpwanArea();
|
||||
@@ -254,11 +254,11 @@ public class TargetController : MonoBehaviour
|
||||
/// This method generates a random scene block based on the target type and spawns enemies at the specified location.
|
||||
/// 此方法根据目标类型生成一个随机场景块,并在指定位置生成敌人。
|
||||
/// </remarks>
|
||||
private void RandomSpawnSceneBlock(SceneBlockContainer.Targets targetType)
|
||||
private void RandomSpawnSceneBlock(Targets targetType)
|
||||
{
|
||||
randLevel = RollRandomLevelIndex(targetType);
|
||||
randBlockType = Random.Range(0, sceneBlockCon.scenePrefabSet.GetBlockNumber(targetType,randLevel));
|
||||
sceneBlockSize = sceneBlockCon.scenePrefabSet.GetBlockSize(targetType, randLevel, randBlockType);
|
||||
randBlockType = Random.Range(0, sceneBlockCon.scenePrefabSet.GetBlockNumber(randLevel,targetType));
|
||||
sceneBlockSize = sceneBlockCon.scenePrefabSet.GetBlockSize(randLevel, randBlockType, targetType);
|
||||
|
||||
float randX = UnityEngine.Random.Range(minEnemyAreaX + sceneBlockSize / 2 + 1f, maxEnemyAreaX - sceneBlockSize / 2 - 1f);
|
||||
float randZ = UnityEngine.Random.Range(minEnemyAreaZ + sceneBlockSize / 2 + 1f, maxEnemyAreaZ - sceneBlockSize / 2 - 1f);
|
||||
@@ -289,7 +289,7 @@ public class TargetController : MonoBehaviour
|
||||
float nowDistance = 0f;
|
||||
switch (targetTypeInt)
|
||||
{
|
||||
case (int)SceneBlockContainer.Targets.Go:
|
||||
case (int)Targets.Go:
|
||||
// goto
|
||||
(nowDistance, inArea) = sceneBlockCon.GetAgentTargetDistanceAndInside(agentObj.transform.position);
|
||||
envUICon.UpdateTargetGauge(sceneBlockCon.nowBlock.firebasesBelong, sceneBlockCon.nowBlock.belongMaxPoint);
|
||||
@@ -320,7 +320,7 @@ public class TargetController : MonoBehaviour
|
||||
}
|
||||
break;
|
||||
|
||||
case (int)SceneBlockContainer.Targets.Attack:
|
||||
case (int)Targets.Attack:
|
||||
// attack
|
||||
(nowDistance, inArea) = sceneBlockCon.GetAgentTargetDistanceAndInside(agentObj.transform.position);
|
||||
envUICon.UpdateTargetGauge(sceneBlockCon.nowBlock.firebasesBelong, sceneBlockCon.nowBlock.belongMaxPoint);
|
||||
@@ -354,7 +354,7 @@ public class TargetController : MonoBehaviour
|
||||
}
|
||||
break;
|
||||
|
||||
case (int)SceneBlockContainer.Targets.Defence:
|
||||
case (int)Targets.Defence:
|
||||
//defence
|
||||
// !!! DIDN't FINISH!!!
|
||||
(nowDistance, inArea) = sceneBlockCon.GetAgentTargetDistanceAndInside(agentObj.transform.position);
|
||||
@@ -382,7 +382,7 @@ public class TargetController : MonoBehaviour
|
||||
}
|
||||
break;
|
||||
|
||||
case (int)SceneBlockContainer.Targets.Stay:
|
||||
case (int)Targets.Stay:
|
||||
// Stay
|
||||
// endless
|
||||
nowReward = 0;
|
||||
@@ -462,7 +462,7 @@ public class TargetController : MonoBehaviour
|
||||
public float KillReward(Vector3 enemyPosition)
|
||||
{
|
||||
float nowKillReward = 0f;
|
||||
if (targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
|
||||
if (targetTypeInt == (int)Targets.Attack)
|
||||
{
|
||||
// attack mode
|
||||
(_, int isInArea) = sceneBlockCon.nowBlock.GetDistInArea(enemyPosition);
|
||||
@@ -476,7 +476,7 @@ public class TargetController : MonoBehaviour
|
||||
nowKillReward = paramCon.killNonTargetReward;
|
||||
}
|
||||
}
|
||||
else if (targetTypeInt == (int)SceneBlockContainer.Targets.Free)
|
||||
else if (targetTypeInt == (int)Targets.Free)
|
||||
{
|
||||
// free mode hit
|
||||
nowKillReward = paramCon.killTargetEnemyReward;
|
||||
@@ -498,7 +498,7 @@ public class TargetController : MonoBehaviour
|
||||
public float HitEnemyReward(Vector3 enemyPosition)
|
||||
{
|
||||
float nowHitReward = 0f;
|
||||
if (targetTypeInt == (int)SceneBlockContainer.Targets.Attack)
|
||||
if (targetTypeInt == (int)Targets.Attack)
|
||||
{
|
||||
// attack mode
|
||||
(_, int isInArea) = sceneBlockCon.nowBlock.GetDistInArea(enemyPosition);
|
||||
@@ -513,7 +513,7 @@ public class TargetController : MonoBehaviour
|
||||
nowHitReward = paramCon.hitNonTargetReward;
|
||||
}
|
||||
}
|
||||
else if (targetTypeInt == (int)SceneBlockContainer.Targets.Free)
|
||||
else if (targetTypeInt == (int)Targets.Free)
|
||||
{
|
||||
// free mode hit
|
||||
nowHitReward = paramCon.hitTargetReward;
|
||||
@@ -544,7 +544,7 @@ public class TargetController : MonoBehaviour
|
||||
/// </remarks>
|
||||
public void PlayInitialize()
|
||||
{
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Stay;
|
||||
targetTypeInt = (int)Targets.Stay;
|
||||
UpdateTargetStates();
|
||||
envUICon.UpdateTargetType(targetTypeInt);
|
||||
MoveAgentToSpwanArea();
|
||||
@@ -555,7 +555,7 @@ public class TargetController : MonoBehaviour
|
||||
// change to attack mode
|
||||
public void AttackModeChange(Vector3 targetPosition)
|
||||
{
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Attack;
|
||||
targetTypeInt = (int)Targets.Attack;
|
||||
UpdateTargetStates(targetPosition);
|
||||
envUICon.UpdateTargetType(targetTypeInt);
|
||||
}
|
||||
@@ -563,7 +563,7 @@ public class TargetController : MonoBehaviour
|
||||
// change to free mode
|
||||
public void FreeModeChange()
|
||||
{
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Free;
|
||||
targetTypeInt = (int)Targets.Free;
|
||||
UpdateTargetStates();
|
||||
envUICon.UpdateTargetType(targetTypeInt);
|
||||
}
|
||||
@@ -571,7 +571,7 @@ public class TargetController : MonoBehaviour
|
||||
// change to goto mode
|
||||
public void GotoModeChange(Vector3 targetPosition)
|
||||
{
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Go;
|
||||
targetTypeInt = (int)Targets.Go;
|
||||
UpdateTargetStates(targetPosition);
|
||||
envUICon.UpdateTargetType(targetTypeInt);
|
||||
}
|
||||
@@ -579,7 +579,7 @@ public class TargetController : MonoBehaviour
|
||||
// change to stay mode
|
||||
public void StayModeChange()
|
||||
{
|
||||
targetTypeInt = (int)SceneBlockContainer.Targets.Stay;
|
||||
targetTypeInt = (int)Targets.Stay;
|
||||
UpdateTargetStates();
|
||||
envUICon.UpdateTargetType(targetTypeInt);
|
||||
}
|
||||
@@ -599,7 +599,7 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
this.targetPosition = (Vector3)targetPosition;
|
||||
}
|
||||
if (targetTypeInt == (int)SceneBlockContainer.Targets.Free || targetTypeInt == (int)SceneBlockContainer.Targets.Stay)
|
||||
if (targetTypeInt == (int)Targets.Free || targetTypeInt == (int)Targets.Stay)
|
||||
{
|
||||
for (int i = 1; i < targetState.Length; i++)
|
||||
// set target position state to 0
|
||||
@@ -622,7 +622,7 @@ public class TargetController : MonoBehaviour
|
||||
/// <returns>The in-area state.</returns>
|
||||
public int GetInAreaState()
|
||||
{
|
||||
if (targetTypeInt == (int)SceneBlockContainer.Targets.Go)
|
||||
if (targetTypeInt == (int)Targets.Go)
|
||||
{
|
||||
return inArea;
|
||||
}
|
||||
@@ -638,19 +638,19 @@ public class TargetController : MonoBehaviour
|
||||
/// </summary>
|
||||
/// <param name="target">The target type.</param>
|
||||
/// <returns>A random level index.</returns>
|
||||
public int RollRandomLevelIndex(SceneBlockContainer.Targets target)
|
||||
public int RollRandomLevelIndex(Targets target)
|
||||
{
|
||||
List<float> targetProbs;
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case SceneBlockContainer.Targets.Attack:
|
||||
case Targets.Attack:
|
||||
targetProbs = paramCon.attackLevelProbs;
|
||||
break;
|
||||
case SceneBlockContainer.Targets.Go:
|
||||
case Targets.Go:
|
||||
targetProbs = paramCon.gotoLevelProbs;
|
||||
break;
|
||||
case SceneBlockContainer.Targets.Defence:
|
||||
case Targets.Defence:
|
||||
targetProbs = paramCon.defenceLevelProbs;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -13,15 +13,15 @@ public class WorldUIController : MonoBehaviour
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
totalGames = new int[(int)SceneBlockContainer.Targets.Num];
|
||||
winGames = new int[(int)SceneBlockContainer.Targets.Num];
|
||||
Array.Clear(totalGames, 0, (int)SceneBlockContainer.Targets.Num);
|
||||
Array.Clear(winGames, 0, (int)SceneBlockContainer.Targets.Num);
|
||||
totalGames = new int[(int)Targets.Num];
|
||||
winGames = new int[(int)Targets.Num];
|
||||
Array.Clear(totalGames, 0, (int)Targets.Num);
|
||||
Array.Clear(winGames, 0, (int)Targets.Num);
|
||||
//WinChart.Init();
|
||||
winChart.RemoveData();
|
||||
for (int i = 0; i < (int)SceneBlockContainer.Targets.Num; i++)
|
||||
for (int i = 0; i < (int)Targets.Num; i++)
|
||||
{
|
||||
string lineName = Enum.GetName(typeof(SceneBlockContainer.Targets), i);
|
||||
string lineName = Enum.GetName(typeof(Targets), i);
|
||||
winChart.AddSerie<Line>(lineName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user