分离Parameter为Common Parameter和会随着游戏State改变的Parameter。
将不需要public的一些变量改为private。
This commit is contained in:
@@ -5,14 +5,22 @@ using UnityEngine;
|
||||
|
||||
public class AgentController : MonoBehaviour
|
||||
{
|
||||
public GameObject parameterContainerObj;
|
||||
public GameObject environmentObj;
|
||||
public GameObject enemyContainerObj;
|
||||
public GameObject sceneBlockContainerObj;
|
||||
public GameObject environmentUIControlObj;
|
||||
public GameObject targetControllerObj;
|
||||
public GameObject HUDObj;
|
||||
public Camera fpsCam;
|
||||
[SerializeField]
|
||||
private GameObject commonParameterContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject environmentObj;
|
||||
[SerializeField]
|
||||
private GameObject enemyContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject sceneBlockContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject environmentUIControlObj;
|
||||
[SerializeField]
|
||||
private GameObject targetControllerObj;
|
||||
[SerializeField]
|
||||
private GameObject HUDObj;
|
||||
[SerializeField]
|
||||
private Camera fpsCam;
|
||||
|
||||
[Header("GetAxis() Simulate")]
|
||||
public float moveSpeed = 9.0f;
|
||||
@@ -48,25 +56,25 @@ public class AgentController : MonoBehaviour
|
||||
private RaySensors raySensors;
|
||||
|
||||
private CharacterController playerController;
|
||||
private ParameterContainer paramContainer;
|
||||
private CommonParameterContainer commonPramCon;
|
||||
private SceneBlockContainer blockContainer;
|
||||
private TargetController targetCon;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// initialize scripts
|
||||
paramContainer = parameterContainerObj.GetComponent<ParameterContainer>();
|
||||
commonPramCon = commonParameterContainerObj.GetComponent<CommonParameterContainer>();
|
||||
blockContainer = sceneBlockContainerObj.GetComponent<SceneBlockContainer>();
|
||||
targetCon = targetControllerObj.GetComponent<TargetController>();
|
||||
raySensors = GetComponent<RaySensors>();
|
||||
playerController = this.transform.GetComponent<CharacterController>();
|
||||
|
||||
// initialize Environment parameters
|
||||
lockMouse = paramContainer.lockMouse;
|
||||
damage = paramContainer.damage;
|
||||
fireRate = paramContainer.fireRate;
|
||||
lockCameraX = paramContainer.lockCameraX;
|
||||
lockCameraY = paramContainer.lockCameraY;
|
||||
lockMouse = commonPramCon.lockMouse;
|
||||
damage = commonPramCon.damage;
|
||||
fireRate = commonPramCon.fireRate;
|
||||
lockCameraX = commonPramCon.lockCameraX;
|
||||
lockCameraY = commonPramCon.lockCameraY;
|
||||
|
||||
// initialize remainTime
|
||||
// this agent's tag
|
||||
@@ -226,24 +234,24 @@ public class AgentController : MonoBehaviour
|
||||
{
|
||||
// im shooting at target but didn't hit enemy
|
||||
// Debug.DrawRay(centerRay.origin, viewPoint-centerRay.origin, Color.blue);
|
||||
return paramContainer.shootTargetAreaReward;
|
||||
return commonPramCon.shootTargetAreaReward;
|
||||
}
|
||||
}
|
||||
}
|
||||
shootState = 0;
|
||||
return paramContainer.shootReward;
|
||||
return commonPramCon.shootReward;
|
||||
}
|
||||
else if (shootState != 0 && gunReadyToggle == false)
|
||||
{
|
||||
// shoot without ready
|
||||
shootState = 0;
|
||||
return paramContainer.shootWithoutReadyReward;
|
||||
return commonPramCon.shootWithoutReadyReward;
|
||||
}
|
||||
else
|
||||
{
|
||||
// do not shoot
|
||||
shootState = 0;
|
||||
return paramContainer.nonReward;
|
||||
return commonPramCon.nonReward;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +302,7 @@ public class AgentController : MonoBehaviour
|
||||
// facing to an enemy
|
||||
if (hit.collider.tag != myTag && hit.collider.tag != "Wall")
|
||||
{
|
||||
nowReward = paramContainer.facingReward;
|
||||
nowReward = commonPramCon.facingReward;
|
||||
isFacingtoEnemy = true;
|
||||
}
|
||||
}
|
||||
@@ -318,7 +326,7 @@ public class AgentController : MonoBehaviour
|
||||
if (enemyFacingDistance <= lastEnemyFacingDistance)
|
||||
{
|
||||
// closing to enemy
|
||||
nowReward = 1 / MathF.Sqrt(paramContainer.facingInviewEnemyDisCOEF * enemyFacingDistance + 0.00001f);
|
||||
nowReward = 1 / MathF.Sqrt(commonPramCon.facingInviewEnemyDisCOEF * enemyFacingDistance + 0.00001f);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -326,8 +334,8 @@ public class AgentController : MonoBehaviour
|
||||
}
|
||||
// enemy in view Reward
|
||||
lastEnemyFacingDistance = enemyFacingDistance;
|
||||
if (nowReward >= paramContainer.facingReward) nowReward = paramContainer.facingReward; // limit
|
||||
if (nowReward <= -paramContainer.facingReward) nowReward = -paramContainer.facingReward; // limit
|
||||
if (nowReward >= commonPramCon.facingReward) nowReward = commonPramCon.facingReward; // limit
|
||||
if (nowReward <= -commonPramCon.facingReward) nowReward = -commonPramCon.facingReward; // limit
|
||||
// Debug.Log("ninimum = " + nowReward);
|
||||
}
|
||||
break;
|
||||
@@ -341,12 +349,12 @@ public class AgentController : MonoBehaviour
|
||||
if (camCenterToTarget <= blockContainer.nowBlock.firebasesAreaDiameter / 2)
|
||||
{
|
||||
// Debug.DrawRay(centerRay.origin, viewPoint-centerRay.origin, Color.blue);
|
||||
nowReward = paramContainer.facingReward;
|
||||
nowReward = commonPramCon.facingReward;
|
||||
}
|
||||
else
|
||||
{
|
||||
// while not facing to target
|
||||
nowReward = (lastTargetFacingDistance - camCenterToTarget) * paramContainer.facingTargetReward;
|
||||
nowReward = (lastTargetFacingDistance - camCenterToTarget) * commonPramCon.facingTargetReward;
|
||||
}
|
||||
}
|
||||
// update lastTargetFacingDistance
|
||||
@@ -357,7 +365,7 @@ public class AgentController : MonoBehaviour
|
||||
if (camCenterToTarget <= camCenterToViewEdge)
|
||||
{
|
||||
// fireArea is in view
|
||||
nowReward = paramContainer.facingReward;
|
||||
nowReward = commonPramCon.facingReward;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -395,23 +403,23 @@ public class AgentController : MonoBehaviour
|
||||
// Penalty
|
||||
// spin penalty
|
||||
spinRecord.Add(mouseX);
|
||||
if (spinRecord.Count >= paramContainer.spinRecordMax)
|
||||
if (spinRecord.Count >= commonPramCon.spinRecordMax)
|
||||
{
|
||||
spinRecord.RemoveAt(0);
|
||||
}
|
||||
float spinPenaltyReward = Math.Abs(spinRecord.ToArray().Sum() * paramContainer.spinPenalty);
|
||||
if (spinPenaltyReward >= paramContainer.spinPenaltyThreshold)
|
||||
float spinPenaltyReward = Math.Abs(spinRecord.ToArray().Sum() * commonPramCon.spinPenalty);
|
||||
if (spinPenaltyReward >= commonPramCon.spinPenaltyThreshold)
|
||||
{
|
||||
epreward -= spinPenaltyReward;
|
||||
}
|
||||
else
|
||||
{
|
||||
epreward -= Math.Abs(mouseX) * paramContainer.mousePenalty;
|
||||
epreward -= Math.Abs(mouseX) * commonPramCon.mousePenalty;
|
||||
}
|
||||
// move penalty
|
||||
if (movement != 0)
|
||||
{
|
||||
epreward -= paramContainer.movePenalty;
|
||||
epreward -= commonPramCon.movePenalty;
|
||||
}
|
||||
return epreward;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ using UnityEngine;
|
||||
|
||||
public class EnemyContainer : MonoBehaviour
|
||||
{
|
||||
public GameObject enemyPrefab;
|
||||
public GameObject environmentObj;
|
||||
public GameObject targetControllerObj;
|
||||
[SerializeField] public GameObject enemyPrefab;
|
||||
[SerializeField] private GameObject environmentObj;
|
||||
[SerializeField] private GameObject targetControllerObj;
|
||||
|
||||
private TargetController targetCon;
|
||||
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CommonParameterContainer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject hudObj;
|
||||
|
||||
private StartSeneData startSceneData;
|
||||
private MessageBoxController messageCon;
|
||||
|
||||
[Header("Env")]
|
||||
public bool lockMouse = false;
|
||||
|
||||
public float damage = 50; // damage to enemy
|
||||
public float fireRate = 0.5f;
|
||||
public int timeLimit = 30;
|
||||
public bool lockCameraX = false;
|
||||
public bool lockCameraY = true;
|
||||
public bool spawnAgentInAllMap = true;
|
||||
public int spinRecordMax = 40;
|
||||
public float spinPenaltyThreshold = 10;
|
||||
public float facingInviewEnemyDisCOEF = 0.5f;
|
||||
|
||||
[Header("Dynamic Defaut Rewards")]
|
||||
//[Tooltip("Hit Enemy reward")]
|
||||
//public float hitRewardDefault = 60.0f;
|
||||
[Tooltip("Free mode Hit Enemy reward")]
|
||||
public float hitTargetRewardDefault = 25f;
|
||||
//[Tooltip("Enemy down reward")]
|
||||
//public float killRewardDefault = 60.0f;
|
||||
[Tooltip("Enemy down in area Reward")]
|
||||
public float killTargetEnemyRewardDefault = 25f;
|
||||
[Tooltip("stay in firebasesArea reward")]
|
||||
public float inAreaRewardDefault = 12f;
|
||||
[Tooltip("free left time bonus reward. ALLR + leftTime * r")]
|
||||
public float freeTimeBonusPerSec = 1.0f;
|
||||
[Tooltip("target left time bonus reward. ALLR + leftTime * r")]
|
||||
public float targetTimeBonusPerSec = 0.5f;
|
||||
[Tooltip("in area left time bonus reward. ALLR + leftTime * r")]
|
||||
public float areaTimeBonusPerSec = 0.2f;
|
||||
[Tooltip("distance reward reward = r*(1-(nowDis/startDis))")]
|
||||
public float distanceReward = 50.0f;
|
||||
[Tooltip("facing to Target distance reward reward = r*(1-(nowDis/startDis))")]
|
||||
public float facingTargetReward = 10.0f;
|
||||
|
||||
[Space(10)]
|
||||
[Tooltip("Goto Win reward")]
|
||||
public float goWinRewardDefault = 999f;
|
||||
[Tooltip("Attack Win reward")]
|
||||
public float attackWinRewardDefault = 999f;
|
||||
[Tooltip("Defence Win reward")]
|
||||
public float defenceWinRewardDefault = 999f;
|
||||
[Tooltip("free Win reward")]
|
||||
public float freeWinRewardDefault = 999f;
|
||||
|
||||
[Header("Static Rewards")]
|
||||
[Tooltip("Nothing happened reward")]
|
||||
public float nonReward = -1f;
|
||||
[Tooltip("Episode Lose reward")]
|
||||
public float loseReward = -999f;
|
||||
[Tooltip("Agent Do shoot action reward")]
|
||||
public float shootReward = -0.5f;
|
||||
[Tooltip("Hit Not target Enemy reward")]
|
||||
public float hitNonTargetReward = -5f;
|
||||
[Tooltip("Not Target Enemy down reward")]
|
||||
public float killNonTargetReward = -5f;
|
||||
[Tooltip("Agent Do shoot action but gun is not read")]
|
||||
public float shootWithoutReadyReward = -1.15f;
|
||||
[Tooltip("Kill bonus reward stack to nothing happend reward")]
|
||||
public float killBonusReward = 0.0f;
|
||||
[Tooltip("Facing to enemy's reward")]
|
||||
public float facingReward = 5f;
|
||||
[Tooltip("Shoot at target area but didn't hit enemy")]
|
||||
public float shootTargetAreaReward = 10f;
|
||||
|
||||
[Header("Penalty Rewards")]
|
||||
[Tooltip("move Penalty Reward")]
|
||||
public float movePenalty = 0.1f;
|
||||
[Tooltip("spiiiiiiin Panalty Reward")]
|
||||
public float spinPenalty = 0.08f;
|
||||
[Tooltip("while move mouse a little bit's penalty")]
|
||||
public float mousePenalty = 0.06f;
|
||||
|
||||
[NonSerialized] 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>();
|
||||
[NonSerialized] public float gotoProb = 0f;
|
||||
[NonSerialized] public List<float> gotoLevelProbs = new List<float>();
|
||||
[NonSerialized] public float defenceProb = 0f;
|
||||
[NonSerialized] public List<float> defenceLevelProbs = new List<float>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34839c2831b759d4a8347ab655b00f36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,11 +7,12 @@ using UnityEngine;
|
||||
|
||||
public class MLAgentsCustomController : Agent
|
||||
{
|
||||
public GameObject paramContainerObj;
|
||||
public GameObject targetControllerObj;
|
||||
public GameObject environmentUIObj;
|
||||
public GameObject sideChannelObj;
|
||||
public GameObject hudUIObj;
|
||||
[SerializeField] private GameObject paramContainerObj;
|
||||
[SerializeField] private GameObject CommonParameterContainer;
|
||||
[SerializeField] private GameObject targetControllerObj;
|
||||
[SerializeField] private GameObject environmentUIObj;
|
||||
[SerializeField] private GameObject sideChannelObj;
|
||||
[SerializeField] private GameObject hudUIObj;
|
||||
|
||||
[Header("Env")]
|
||||
public bool oneHotRayTag = true;
|
||||
@@ -20,6 +21,7 @@ public class MLAgentsCustomController : Agent
|
||||
private AgentController agentController;
|
||||
|
||||
private ParameterContainer paramContainer;
|
||||
private CommonParameterContainer commonParamCon;
|
||||
private TargetController targetController;
|
||||
private EnvironmentUIControl envUIController;
|
||||
private HUDController hudController;
|
||||
@@ -47,6 +49,7 @@ public class MLAgentsCustomController : Agent
|
||||
agentController = transform.GetComponent<AgentController>();
|
||||
raySensors = transform.GetComponent<RaySensors>();
|
||||
paramContainer = paramContainerObj.GetComponent<ParameterContainer>();
|
||||
commonParamCon = CommonParameterContainer.GetComponent<CommonParameterContainer>();
|
||||
targetController = targetControllerObj.GetComponent<TargetController>();
|
||||
envUIController = environmentUIObj.GetComponent<EnvironmentUIControl>();
|
||||
hudController = hudUIObj.GetComponent<HUDController>();
|
||||
@@ -62,7 +65,7 @@ public class MLAgentsCustomController : Agent
|
||||
step = 0;
|
||||
agentController.UpdateLockMouse();
|
||||
paramContainer.ResetTimeBonusReward();
|
||||
if (paramContainer.gameMode == 0)
|
||||
if (commonParamCon.gameMode == 0)
|
||||
{
|
||||
// train mode
|
||||
Debug.Log("MLAgentCustomController.OnEpisodeBegin: train mode start");
|
||||
@@ -178,7 +181,7 @@ public class MLAgentsCustomController : Agent
|
||||
switch (finishedState)
|
||||
{
|
||||
case (int)TargetController.EndType.Win:
|
||||
sideChannelController.SendSideChannelMessage("Result",targetString+ "|Win");
|
||||
sideChannelController.SendSideChannelMessage("Result", targetString + "|Win");
|
||||
messageBoxController.PushMessage(
|
||||
new List<string> { "Game Win" },
|
||||
new List<string> { "green" });
|
||||
|
||||
@@ -3,110 +3,20 @@ using UnityEngine;
|
||||
|
||||
public class ParameterContainer : MonoBehaviour
|
||||
{
|
||||
public GameObject targetConObj;
|
||||
public GameObject blockConObj;
|
||||
public GameObject agentObj;
|
||||
public GameObject hudObj;
|
||||
[SerializeField] private GameObject targetConObj;
|
||||
[SerializeField] private GameObject blockConObj;
|
||||
[SerializeField] private GameObject agentObj;
|
||||
[SerializeField] private GameObject hudObj;
|
||||
[SerializeField] private GameObject CommonParamObj;
|
||||
|
||||
private TargetController targetCon;
|
||||
private SceneBlockContainer blockCont;
|
||||
private StartSeneData startSceneData;
|
||||
private MessageBoxController messageCon;
|
||||
private CommonParameterContainer commonParamCont;
|
||||
private float agentDistance;
|
||||
private int agentInArea;
|
||||
|
||||
[Header("Env")]
|
||||
public bool lockMouse = false;
|
||||
|
||||
public float damage = 50; // damage to enemy
|
||||
public float fireRate = 0.5f;
|
||||
public int timeLimit = 30;
|
||||
public bool lockCameraX = false;
|
||||
public bool lockCameraY = true;
|
||||
public bool spawnAgentInAllMap = true;
|
||||
public int spinRecordMax = 40;
|
||||
public float spinPenaltyThreshold = 10;
|
||||
public float facingInviewEnemyDisCOEF = 0.5f;
|
||||
|
||||
[Header("Dynamic Defaut Rewards")]
|
||||
//[Tooltip("Hit Enemy reward")]
|
||||
//public float hitRewardDefault = 60.0f;
|
||||
[Tooltip("Free mode Hit Enemy reward")]
|
||||
public float hitTargetRewardDefault = 25f;
|
||||
|
||||
//[Tooltip("Enemy down reward")]
|
||||
//public float killRewardDefault = 60.0f;
|
||||
[Tooltip("Enemy down in area Reward")]
|
||||
public float killTargetEnemyRewardDefault = 25f;
|
||||
|
||||
[Tooltip("stay in firebasesArea reward")]
|
||||
public float inAreaRewardDefault = 12f;
|
||||
|
||||
[Tooltip("free left time bonus reward. ALLR + leftTime * r")]
|
||||
public float freeTimeBonusPerSec = 1.0f;
|
||||
|
||||
[Tooltip("target left time bonus reward. ALLR + leftTime * r")]
|
||||
public float targetTimeBonusPerSec = 0.5f;
|
||||
|
||||
[Tooltip("in area left time bonus reward. ALLR + leftTime * r")]
|
||||
public float areaTimeBonusPerSec = 0.2f;
|
||||
|
||||
[Tooltip("distance reward reward = r*(1-(nowDis/startDis))")]
|
||||
public float distanceReward = 50.0f;
|
||||
|
||||
[Tooltip("facing to Target distance reward reward = r*(1-(nowDis/startDis))")]
|
||||
public float facingTargetReward = 10.0f;
|
||||
|
||||
[Space(10)]
|
||||
[Tooltip("Goto Win reward")]
|
||||
public float goWinRewardDefault = 999f;
|
||||
|
||||
[Tooltip("Attack Win reward")]
|
||||
public float attackWinRewardDefault = 999f;
|
||||
|
||||
[Tooltip("Defence Win reward")]
|
||||
public float defenceWinRewardDefault = 999f;
|
||||
|
||||
[Tooltip("free Win reward")]
|
||||
public float freeWinRewardDefault = 999f;
|
||||
|
||||
[Header("Static Rewards")]
|
||||
[Tooltip("Nothing happened reward")]
|
||||
public float nonReward = -1f;
|
||||
|
||||
[Tooltip("Episode Lose reward")]
|
||||
public float loseReward = -999f;
|
||||
|
||||
[Tooltip("Agent Do shoot action reward")]
|
||||
public float shootReward = -0.5f;
|
||||
|
||||
[Tooltip("Hit Not target Enemy reward")]
|
||||
public float hitNonTargetReward = -5f;
|
||||
|
||||
[Tooltip("Not Target Enemy down reward")]
|
||||
public float killNonTargetReward = -5f;
|
||||
|
||||
[Tooltip("Agent Do shoot action but gun is not read")]
|
||||
public float shootWithoutReadyReward = -1.15f;
|
||||
|
||||
[Tooltip("Kill bonus reward stack to nothing happend reward")]
|
||||
public float killBonusReward = 0.0f;
|
||||
|
||||
[Tooltip("Facing to enemy's reward")]
|
||||
public float facingReward = 5f;
|
||||
|
||||
[Tooltip("Shoot at target area but didn't hit enemy")]
|
||||
public float shootTargetAreaReward = 10f;
|
||||
|
||||
[Header("Penalty Rewards")]
|
||||
[Tooltip("move Penalty Reward")]
|
||||
public float movePenalty = 0.1f;
|
||||
|
||||
[Tooltip("spiiiiiiin Panalty Reward")]
|
||||
public float spinPenalty = 0.08f;
|
||||
|
||||
[Tooltip("while move mouse a little bit's penalty")]
|
||||
public float mousePenalty = 0.06f;
|
||||
|
||||
[Header("Dynamic Rewards")]
|
||||
[Tooltip("Free mode Hit Enemy reward")]
|
||||
public float hitTargetReward = 60.0f;
|
||||
@@ -130,28 +40,29 @@ public class ParameterContainer : MonoBehaviour
|
||||
[Tooltip("free Win reward")]
|
||||
public float freeWinReward = 50.0f;
|
||||
|
||||
[Tooltip("Scene Prefab Set")]
|
||||
public SceneBlocksSet scenePrefabSet;
|
||||
|
||||
private float targetTimeBonus = 0f;
|
||||
private float areaTimeBonus = 0f;
|
||||
private float freeTimeBonus = 0f;
|
||||
private float targetInAreaTime = 0f;
|
||||
private float lastFrameTime = 0f;
|
||||
|
||||
[System.NonSerialized] public int gameMode; // 0 = trainning mode, 1 = play mode
|
||||
[System.NonSerialized] public float attackProb = 0f;
|
||||
[System.NonSerialized] public List<float> attackLevelProbs = new List<float>();
|
||||
[System.NonSerialized] public float gotoProb = 0f;
|
||||
[System.NonSerialized] public List<float> gotoLevelProbs = new List<float>();
|
||||
[System.NonSerialized] public float defenceProb = 0f;
|
||||
[System.NonSerialized] public List<float> defenceLevelProbs = new List<float>();
|
||||
private float areaTimeBonusPerSec;
|
||||
private float freeTimeBonusPerSec;
|
||||
private float targetTimeBonusPerSec;
|
||||
private int timeLimit = 30;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
targetCon = targetConObj.GetComponent<TargetController>();
|
||||
blockCont = blockConObj.GetComponent<SceneBlockContainer>();
|
||||
messageCon = hudObj.GetComponent<MessageBoxController>();
|
||||
commonParamCont = CommonParamObj.GetComponent<CommonParameterContainer>();
|
||||
|
||||
areaTimeBonusPerSec = commonParamCont.areaTimeBonusPerSec;
|
||||
freeTimeBonusPerSec = commonParamCont.freeTimeBonusPerSec;
|
||||
targetTimeBonusPerSec = commonParamCont.targetTimeBonusPerSec;
|
||||
timeLimit = commonParamCont.timeLimit;
|
||||
|
||||
areaTimeBonus = areaTimeBonusPerSec * timeLimit;
|
||||
freeTimeBonus = freeTimeBonusPerSec * timeLimit;
|
||||
targetTimeBonus = targetTimeBonusPerSec * timeLimit;
|
||||
@@ -171,14 +82,12 @@ public class ParameterContainer : MonoBehaviour
|
||||
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;
|
||||
|
||||
// Win Rewards
|
||||
goWinReward = commonParamCont.goWinRewardDefault;
|
||||
attackWinReward = commonParamCont.attackWinRewardDefault;
|
||||
defenceWinReward = commonParamCont.defenceWinRewardDefault;
|
||||
freeWinReward = commonParamCont.freeWinRewardDefault;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -206,15 +115,9 @@ public class ParameterContainer : MonoBehaviour
|
||||
targetTimeBonus = targetTimeBonusPerSec * targetCon.leftTime;
|
||||
}
|
||||
|
||||
hitTargetReward = hitTargetRewardDefault + targetTimeBonus;
|
||||
killTargetEnemyReward = killTargetEnemyRewardDefault + targetTimeBonus;
|
||||
inAreaReward = inAreaRewardDefault + areaTimeBonus;
|
||||
|
||||
// Win Rewards
|
||||
goWinReward = goWinRewardDefault;
|
||||
attackWinReward = attackWinRewardDefault;
|
||||
defenceWinReward = defenceWinRewardDefault;
|
||||
freeWinReward = freeWinRewardDefault;
|
||||
hitTargetReward = commonParamCont.hitTargetRewardDefault + targetTimeBonus;
|
||||
killTargetEnemyReward = commonParamCont.killTargetEnemyRewardDefault + targetTimeBonus;
|
||||
inAreaReward = commonParamCont.inAreaRewardDefault + areaTimeBonus;
|
||||
}
|
||||
|
||||
public void ResetTimeBonusReward()
|
||||
|
||||
@@ -6,11 +6,11 @@ using UnityEngine;
|
||||
|
||||
public class RaySensors : MonoBehaviour
|
||||
{
|
||||
public Camera agentCam;
|
||||
public Camera TPSCam;
|
||||
public Material lineMeterial;
|
||||
public GameObject rayInfoPrefab;
|
||||
public GameObject agentCanvas;
|
||||
[SerializeField] private Camera agentCam;
|
||||
[SerializeField] private Camera TPSCam;
|
||||
[SerializeField] private Material lineMeterial;
|
||||
[SerializeField] private GameObject rayInfoPrefab;
|
||||
[SerializeField] private GameObject agentCanvas;
|
||||
|
||||
[SerializeField, Range(0, 500)] public float viewDistance = 100; // how long the ray can detect
|
||||
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
public class SceneBlockContainer : MonoBehaviour
|
||||
{
|
||||
public float sceneSize = 10f;
|
||||
public GameObject environmentObj;
|
||||
public GameObject parameterContainerObj;
|
||||
public GameObject hudObj;
|
||||
[SerializeField]
|
||||
private float sceneSize = 10f;
|
||||
[SerializeField]
|
||||
private GameObject environmentObj;
|
||||
[SerializeField]
|
||||
private GameObject commonParameterContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject hudObj;
|
||||
|
||||
// public GameObject[] attackBlockPrefabs = new GameObject[1];
|
||||
// public GameObject[] goBlockPrefabs = new GameObject[1];
|
||||
@@ -13,11 +17,11 @@ public class SceneBlockContainer : MonoBehaviour
|
||||
|
||||
public SceneBlock nowBlock;
|
||||
private GameObject nowBlockObj;
|
||||
private ParameterContainer paramCon;
|
||||
private CommonParameterContainer commonParamCon;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
paramCon = parameterContainerObj.GetComponent<ParameterContainer>();
|
||||
commonParamCon = commonParameterContainerObj.GetComponent<CommonParameterContainer>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -40,7 +44,7 @@ public class SceneBlockContainer : MonoBehaviour
|
||||
DestroyBlock();
|
||||
}
|
||||
// choose target type
|
||||
nowBlockObj = Instantiate(paramCon.scenePrefabSet.GetPrefab(level, blockType, targetType), blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
|
||||
nowBlockObj = Instantiate(commonParamCon.scenePrefabSet.GetPrefab(level, blockType, targetType), blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
|
||||
nowBlock = nowBlockObj.GetComponent<SceneBlock>();
|
||||
nowBlock.group1Tag = tag1;
|
||||
nowBlock.group2Tag = tag2;
|
||||
|
||||
@@ -5,14 +5,24 @@ using Random = UnityEngine.Random;
|
||||
|
||||
public class TargetController : MonoBehaviour
|
||||
{
|
||||
public GameObject environmentObj;
|
||||
public GameObject agentObj;
|
||||
public GameObject HUDObj;
|
||||
public GameObject sceneBlockContainerObj;
|
||||
public GameObject enemyContainerObj;
|
||||
public GameObject parameterContainerObj;
|
||||
public GameObject environmentUIObj;
|
||||
public GameObject worldUIObj;
|
||||
[SerializeField]
|
||||
private GameObject environmentObj;
|
||||
[SerializeField]
|
||||
private GameObject agentObj;
|
||||
[SerializeField]
|
||||
private GameObject HUDObj;
|
||||
[SerializeField]
|
||||
private GameObject sceneBlockContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject enemyContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject parameterContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject commonParameterContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject environmentUIObj;
|
||||
[SerializeField]
|
||||
private GameObject worldUIObj;
|
||||
|
||||
// area
|
||||
public GameObject edgeUp;
|
||||
@@ -62,10 +72,12 @@ public class TargetController : MonoBehaviour
|
||||
public Vector3 targetPosition;
|
||||
private bool firstRewardFlag = true;
|
||||
private bool targetEnemySpawnFinish = false;
|
||||
|
||||
private SceneBlockContainer sceneBlockCon;
|
||||
private EnemyContainer enemyCon;
|
||||
private EnvironmentUIControl envUICon;
|
||||
private ParameterContainer paramCon;
|
||||
private CommonParameterContainer commonParamCon;
|
||||
private CharacterController agentCharaCon;
|
||||
private WorldUIController worldUICon;
|
||||
private HUDController hudCon;
|
||||
@@ -77,6 +89,7 @@ public class TargetController : MonoBehaviour
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
commonParamCon = commonParameterContainerObj.GetComponent<CommonParameterContainer>();
|
||||
sceneBlockCon = sceneBlockContainerObj.GetComponent<SceneBlockContainer>();
|
||||
envUICon = environmentUIObj.GetComponent<EnvironmentUIControl>();
|
||||
enemyCon = enemyContainerObj.GetComponent<EnemyContainer>();
|
||||
@@ -87,10 +100,10 @@ public class TargetController : MonoBehaviour
|
||||
messageBoxCon = HUDObj.GetComponent<MessageBoxController>();
|
||||
|
||||
// get parameter from ParameterContainer
|
||||
gamemode = paramCon.gameMode;
|
||||
attackProb = paramCon.attackProb;
|
||||
gotoProb = paramCon.gotoProb;
|
||||
defenceProb = paramCon.defenceProb;
|
||||
gamemode = commonParamCon.gameMode;
|
||||
attackProb = commonParamCon.attackProb;
|
||||
gotoProb = commonParamCon.gotoProb;
|
||||
defenceProb = commonParamCon.defenceProb;
|
||||
|
||||
// initialize spawn area
|
||||
minEnemyAreaX = edgeLeft.transform.localPosition.x + 1.0f;
|
||||
@@ -105,8 +118,8 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
freeProb = 1 - attackProb - gotoProb - defenceProb;
|
||||
targetNum = (int)Targets.Num;
|
||||
gotoLevelNum = paramCon.scenePrefabSet.GetLevelNumber(Targets.Go);
|
||||
attackLevelNum = paramCon.scenePrefabSet.GetLevelNumber(Targets.Attack);
|
||||
gotoLevelNum = commonParamCon.scenePrefabSet.GetLevelNumber(Targets.Go);
|
||||
attackLevelNum = commonParamCon.scenePrefabSet.GetLevelNumber(Targets.Attack);
|
||||
if (freeProb < 0)
|
||||
{
|
||||
Debug.LogError("TargetController.Start: target percentage wrong");
|
||||
@@ -130,13 +143,13 @@ public class TargetController : MonoBehaviour
|
||||
// if gamemode is play, then time will keep paramCon.timeLimit
|
||||
if (gamemode == 1)
|
||||
{
|
||||
leftTime = paramCon.timeLimit;
|
||||
leftTime = commonParamCon.timeLimit;
|
||||
// print out time
|
||||
// Debug.Log("Playing Time: " + leftTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
leftTime = paramCon.timeLimit - Time.time + startTime;
|
||||
leftTime = commonParamCon.timeLimit - Time.time + startTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +165,7 @@ public class TargetController : MonoBehaviour
|
||||
public void RollNewScene()
|
||||
{
|
||||
startTime = Time.time;// Reset StartTime as now time
|
||||
leftTime = paramCon.timeLimit - Time.time + startTime;
|
||||
leftTime = commonParamCon.timeLimit - Time.time + startTime;
|
||||
float randTargetType = UnityEngine.Random.Range(0f, 1f);
|
||||
if (randTargetType <= gotoProb)
|
||||
{
|
||||
@@ -205,7 +218,7 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
float randX = UnityEngine.Random.Range(minAgentAreaX, maxAgentAreaX); ;
|
||||
float randZ = 0f;
|
||||
if (paramCon.spawnAgentInAllMap)
|
||||
if (commonParamCon.spawnAgentInAllMap)
|
||||
{
|
||||
// spawn agent in all around map
|
||||
randZ = UnityEngine.Random.Range(minAgentAreaZ, maxEnemyAreaZ);
|
||||
@@ -257,8 +270,8 @@ public class TargetController : MonoBehaviour
|
||||
private void RandomSpawnSceneBlock(Targets targetType)
|
||||
{
|
||||
randLevel = RollRandomLevelIndex(targetType);
|
||||
randBlockType = Random.Range(0, paramCon.scenePrefabSet.GetBlockNumber(randLevel,targetType));
|
||||
sceneBlockSize = paramCon.scenePrefabSet.GetBlockSize(randLevel, randBlockType, targetType);
|
||||
randBlockType = Random.Range(0, commonParamCon.scenePrefabSet.GetBlockNumber(randLevel,targetType));
|
||||
sceneBlockSize = commonParamCon.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);
|
||||
@@ -308,7 +321,7 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// time out lose
|
||||
nowReward = areaTargetReward;
|
||||
endReward = paramCon.loseReward;
|
||||
endReward = commonParamCon.loseReward;
|
||||
endTypeInt = (int)EndType.Lose;
|
||||
}
|
||||
else
|
||||
@@ -338,7 +351,7 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// time out lose
|
||||
nowReward = 0;
|
||||
endReward = paramCon.loseReward;
|
||||
endReward = commonParamCon.loseReward;
|
||||
//nowReward = (paramCon.inAreaReward * inArea) + getSceneReward(nowDistance);
|
||||
endTypeInt = (int)EndType.Lose;
|
||||
targetEnemySpawnFinish = false;
|
||||
@@ -370,7 +383,7 @@ public class TargetController : MonoBehaviour
|
||||
else if (sceneBlockCon.nowBlock.firebasesBelong <= sceneBlockCon.nowBlock.belongMaxPoint)
|
||||
{
|
||||
// lost area lose
|
||||
nowReward = paramCon.loseReward;
|
||||
nowReward = commonParamCon.loseReward;
|
||||
//nowReward = (paramCon.inAreaReward * inArea) + getSceneReward(nowDistance);
|
||||
endTypeInt = (int)EndType.Lose;
|
||||
}
|
||||
@@ -405,7 +418,7 @@ public class TargetController : MonoBehaviour
|
||||
// lose
|
||||
//nowReward = paramCon.loseReward;
|
||||
nowReward = 0;
|
||||
endReward = paramCon.loseReward;
|
||||
endReward = commonParamCon.loseReward;
|
||||
endTypeInt = (int)EndType.Lose;
|
||||
}
|
||||
else
|
||||
@@ -447,7 +460,7 @@ public class TargetController : MonoBehaviour
|
||||
{
|
||||
// out of area
|
||||
// nowSeneReward = paramCon.distanceReward * Math.Clamp(lastDistance - nowDistance, 0, 100);
|
||||
nowSeneReward = paramCon.distanceReward * (lastDistance - nowDistance);
|
||||
nowSeneReward = commonParamCon.distanceReward * (lastDistance - nowDistance);
|
||||
}
|
||||
lastDistance = nowDistance;
|
||||
return nowSeneReward;
|
||||
@@ -473,7 +486,7 @@ public class TargetController : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
nowKillReward = paramCon.killNonTargetReward;
|
||||
nowKillReward = commonParamCon.killNonTargetReward;
|
||||
}
|
||||
}
|
||||
else if (targetTypeInt == (int)Targets.Free)
|
||||
@@ -484,7 +497,7 @@ public class TargetController : MonoBehaviour
|
||||
else
|
||||
{
|
||||
// goto & defence
|
||||
nowKillReward = paramCon.killNonTargetReward;
|
||||
nowKillReward = commonParamCon.killNonTargetReward;
|
||||
}
|
||||
return nowKillReward;
|
||||
}
|
||||
@@ -510,7 +523,7 @@ public class TargetController : MonoBehaviour
|
||||
else
|
||||
{
|
||||
// hit not in area enemy
|
||||
nowHitReward = paramCon.hitNonTargetReward;
|
||||
nowHitReward = commonParamCon.hitNonTargetReward;
|
||||
}
|
||||
}
|
||||
else if (targetTypeInt == (int)Targets.Free)
|
||||
@@ -521,7 +534,7 @@ public class TargetController : MonoBehaviour
|
||||
else
|
||||
{
|
||||
// goto & defence
|
||||
nowHitReward = paramCon.hitNonTargetReward;
|
||||
nowHitReward = commonParamCon.hitNonTargetReward;
|
||||
}
|
||||
return nowHitReward;
|
||||
}
|
||||
@@ -645,13 +658,13 @@ public class TargetController : MonoBehaviour
|
||||
switch (target)
|
||||
{
|
||||
case Targets.Attack:
|
||||
targetProbs = paramCon.attackLevelProbs;
|
||||
targetProbs = commonParamCon.attackLevelProbs;
|
||||
break;
|
||||
case Targets.Go:
|
||||
targetProbs = paramCon.gotoLevelProbs;
|
||||
targetProbs = commonParamCon.gotoLevelProbs;
|
||||
break;
|
||||
case Targets.Defence:
|
||||
targetProbs = paramCon.defenceLevelProbs;
|
||||
targetProbs = commonParamCon.defenceLevelProbs;
|
||||
break;
|
||||
default:
|
||||
messageBoxCon.PushMessage(
|
||||
|
||||
@@ -6,21 +6,30 @@ public class MouseInMap : MonoBehaviour
|
||||
public float targetDistanceThreshold = 6f;
|
||||
public float enemyDistanceThreshold = 1f;
|
||||
|
||||
public Camera playCamera;
|
||||
public GameObject AgentObj;
|
||||
public GameObject environmentObj;
|
||||
public GameObject mousePreviewObj;
|
||||
public GameObject enemyContainerObj;
|
||||
public GameObject sceneBlockContainerObj;
|
||||
public GameObject targetControllerObj;
|
||||
public GameObject parameterContainerObj;
|
||||
public GameObject HUDObj;
|
||||
[SerializeField]
|
||||
private Camera playCamera;
|
||||
[SerializeField]
|
||||
private GameObject AgentObj;
|
||||
[SerializeField]
|
||||
private GameObject environmentObj;
|
||||
[SerializeField]
|
||||
private GameObject mousePreviewObj;
|
||||
[SerializeField]
|
||||
private GameObject enemyContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject sceneBlockContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject targetControllerObj;
|
||||
[SerializeField]
|
||||
private GameObject parameterContainerObj;
|
||||
[SerializeField]
|
||||
private GameObject HUDObj;
|
||||
|
||||
private Vector3 nowHitPosition = Vector3.zero;
|
||||
private Vector3 nowHitPositionRelative = Vector3.zero;
|
||||
private LayerMask groundMask;
|
||||
private int blockNum;
|
||||
private ParameterContainer paramCon;
|
||||
private CommonParameterContainer commonParamCon;
|
||||
private GameObject previewModel;
|
||||
private TargetController targetCon;
|
||||
private MousePreview mousePreviewCon;
|
||||
@@ -47,7 +56,7 @@ public class MouseInMap : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
paramCon = parameterContainerObj.GetComponent<ParameterContainer>();
|
||||
commonParamCon = parameterContainerObj.GetComponent<CommonParameterContainer>();
|
||||
groundMask = LayerMask.GetMask("Ground");
|
||||
targetCon = targetControllerObj.GetComponent<TargetController>();
|
||||
mousePreviewCon = mousePreviewObj.GetComponent<MousePreview>();
|
||||
@@ -140,7 +149,7 @@ public class MouseInMap : MonoBehaviour
|
||||
// while blockLevel is not set, send error message
|
||||
messageCon.PushMessage(new List<string> { "[ERROR]MouseInMap:ChangeMouseMode:", "Level not set!", "mouseMode=", mouseMode.ToString() },
|
||||
new List<string> { messageCon.errorColor });
|
||||
blockLevel = paramCon.scenePrefabSet.GetLevelNumber(nowTargetType);
|
||||
blockLevel = commonParamCon.scenePrefabSet.GetLevelNumber(nowTargetType);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -152,7 +161,7 @@ public class MouseInMap : MonoBehaviour
|
||||
if (blockNum < 0)
|
||||
{
|
||||
// while blockNum is not set, random choose block type
|
||||
this.blockNum = Random.Range(0, paramCon.scenePrefabSet.GetBlockNumber(blockLevel, nowTargetType));
|
||||
this.blockNum = Random.Range(0, commonParamCon.scenePrefabSet.GetBlockNumber(blockLevel, nowTargetType));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -160,7 +169,7 @@ public class MouseInMap : MonoBehaviour
|
||||
this.blockNum = blockNum;
|
||||
}
|
||||
// set previewModel
|
||||
previewModel = paramCon.scenePrefabSet.GetPrefab(blockLevel, this.blockNum, nowTargetType);
|
||||
previewModel = commonParamCon.scenePrefabSet.GetPrefab(blockLevel, this.blockNum, nowTargetType);
|
||||
mousePreviewCon.ChangePreviewTo(previewModel);
|
||||
break;
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ using UnityEngine.UI;
|
||||
|
||||
public class ButtonActivateColorChanger : MonoBehaviour
|
||||
{
|
||||
public List<Button> clickableButton = new List<Button>();
|
||||
public List<Button> unclickableButton = new List<Button>();
|
||||
[SerializeField] private List<Button> clickableButton = new List<Button>();
|
||||
[SerializeField] private List<Button> unclickableButton = new List<Button>();
|
||||
|
||||
public float colorChangeSpeed = 0.1f;
|
||||
[SerializeField] private float colorChangeSpeed = 0.1f;
|
||||
|
||||
public bool clickable = true;
|
||||
|
||||
|
||||
@@ -7,17 +7,17 @@ using XCharts.Runtime;
|
||||
|
||||
public class EnvironmentUIControl : MonoBehaviour
|
||||
{
|
||||
public GameObject targetControllerObj;
|
||||
public GameObject parameterContainerObj;
|
||||
public GameObject groundCanvasObj;
|
||||
public GameObject chartObj;
|
||||
public GameObject HUDObj;
|
||||
public TextMeshProUGUI remainTimeText;
|
||||
public TextMeshProUGUI targetTypeText;
|
||||
public TextMeshProUGUI winLoseText;
|
||||
public TextMeshProUGUI stateText;
|
||||
public float resultTimeout = 1f;
|
||||
public GameObject gaugeImgObj;
|
||||
[SerializeField] private GameObject targetControllerObj;
|
||||
[SerializeField] private GameObject parameterContainerObj;
|
||||
[SerializeField] private GameObject groundCanvasObj;
|
||||
[SerializeField] private GameObject chartObj;
|
||||
[SerializeField] private GameObject HUDObj;
|
||||
[SerializeField] private TextMeshProUGUI remainTimeText;
|
||||
[SerializeField] private TextMeshProUGUI targetTypeText;
|
||||
[SerializeField] private TextMeshProUGUI winLoseText;
|
||||
[SerializeField] private TextMeshProUGUI stateText;
|
||||
[SerializeField] private float resultTimeout = 1f;
|
||||
[SerializeField] private GameObject gaugeImgObj;
|
||||
|
||||
private StringBuilder stateBuilder = new StringBuilder();
|
||||
private LineChart realTimeRewardChart = null;
|
||||
|
||||
@@ -7,11 +7,11 @@ using UnityEngine.UI;
|
||||
public class HUDController : MonoBehaviour
|
||||
{
|
||||
public bool chartOn = false;
|
||||
public GameObject sideChannelObj;
|
||||
public Toggle chartOnToggleObj;
|
||||
public Button saveModelButton;
|
||||
public TMP_InputField chartOnTimeOutInputObj;
|
||||
public TMP_InputField enemyNumInputObj;
|
||||
[SerializeField] private GameObject sideChannelObj;
|
||||
[SerializeField] private Toggle chartOnToggleObj;
|
||||
[SerializeField] private Button saveModelButton;
|
||||
[SerializeField] private TMP_InputField chartOnTimeOutInputObj;
|
||||
[SerializeField] private TMP_InputField enemyNumInputObj;
|
||||
public float chartOnTimeOut = 1;
|
||||
public int enemyNum = 3;
|
||||
public float chartOnTimeOutDefault = 120f;
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
public class LevelButton : MonoBehaviour
|
||||
{
|
||||
public int level;
|
||||
public TextMeshProUGUI levelText;
|
||||
[SerializeField] private TextMeshProUGUI levelText;
|
||||
public void Initialization(int level)
|
||||
{
|
||||
this.level = level;
|
||||
|
||||
@@ -8,9 +8,9 @@ public class LevelPanel : MonoBehaviour
|
||||
{
|
||||
private int levelNum = 0;
|
||||
private float buttonHeight = 30;
|
||||
public TargetUIController.PrimaryButtonType primaryButtonType;
|
||||
public GameObject levelButtonPrefab;
|
||||
public GameObject hudObj;
|
||||
[SerializeField] private TargetUIController.PrimaryButtonType primaryButtonType;
|
||||
[SerializeField] private GameObject levelButtonPrefab;
|
||||
[SerializeField] private GameObject hudObj;
|
||||
private TargetUIController targetUIController;
|
||||
public Vector2 defaultPosition = Vector2.zero;
|
||||
public Vector2 targetPosition = Vector2.zero;
|
||||
|
||||
@@ -4,8 +4,8 @@ using UnityEngine;
|
||||
|
||||
public class LevelProbabilityPanel : MonoBehaviour
|
||||
{
|
||||
public GameObject singleTargetLevelProbabilityPanel;
|
||||
public GameObject startSceneData;
|
||||
[SerializeField] private GameObject singleTargetLevelProbabilityPanel;
|
||||
[SerializeField] private GameObject startSceneData;
|
||||
private SceneBlocksSet scenePrefabSet;
|
||||
|
||||
public List<TargetLevelProbabilityPanel> targetLevelProbabilityPanel = new List<TargetLevelProbabilityPanel>();
|
||||
|
||||
@@ -9,11 +9,10 @@ public class MessageBoxController : MonoBehaviour
|
||||
public string warningColor = "#ffa500ff";
|
||||
public string errorColor = "#800000ff";
|
||||
public string goodColor = "#00ff00ff";
|
||||
public GameObject messagePanelObj;
|
||||
public GameObject messageTextPrefab;
|
||||
[SerializeField] private GameObject messagePanelObj;
|
||||
[SerializeField] private GameObject messageTextPrefab;
|
||||
|
||||
[SerializeField]
|
||||
private List<Message> messages = new List<Message>();
|
||||
[SerializeField] private List<Message> messages = new List<Message>();
|
||||
|
||||
/// <summary>
|
||||
/// Pushes a simple message to the message list.
|
||||
@@ -45,7 +44,7 @@ public class MessageBoxController : MonoBehaviour
|
||||
/// This method pushes multi-color text messages to the message list and handles message overflow to ensure that the message list does not grow indefinitely.
|
||||
/// If the lengths of the message text list and the color list do not match, it either removes excess colors or adds white color to the extra messages.
|
||||
/// </remarks>
|
||||
public void PushMessage(List<string> messageList,List<string> colorList)
|
||||
public void PushMessage(List<string> messageList, List<string> colorList)
|
||||
{
|
||||
// check messages and colors list length match
|
||||
if (messageList.Count != colorList.Count)
|
||||
@@ -53,7 +52,7 @@ public class MessageBoxController : MonoBehaviour
|
||||
// delete extra colors or add white color to extra messages
|
||||
if (messageList.Count > colorList.Count)
|
||||
{
|
||||
while(messageList.Count > colorList.Count)
|
||||
while (messageList.Count > colorList.Count)
|
||||
{
|
||||
colorList.Add(defaultColor);
|
||||
}
|
||||
@@ -62,7 +61,6 @@ public class MessageBoxController : MonoBehaviour
|
||||
{
|
||||
colorList.RemoveRange(messageList.Count, colorList.Count - messageList.Count);
|
||||
}
|
||||
|
||||
}
|
||||
MessageOverflowHandler();
|
||||
Message newMessage = new Message();
|
||||
|
||||
@@ -5,11 +5,11 @@ using UnityEngine.UI;
|
||||
|
||||
public class SingleLevelProbabilityPanel : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI levelNameText;
|
||||
public TMP_InputField inputField;
|
||||
public Button lockButton;
|
||||
public Image lockImg;
|
||||
public Image unlockImg;
|
||||
[SerializeField] private TextMeshProUGUI levelNameText;
|
||||
[SerializeField] private Button lockButton;
|
||||
[SerializeField] private Image lockImg;
|
||||
[SerializeField] private Image unlockImg;
|
||||
|
||||
public Slider probabilitySlider;
|
||||
|
||||
|
||||
@@ -3,22 +3,23 @@ using UnityEngine;
|
||||
|
||||
public class StartMenuAnimations : MonoBehaviour
|
||||
{
|
||||
public GameObject maskObj;
|
||||
public GameObject mixButton;
|
||||
public GameObject attackButton;
|
||||
public GameObject gotoButton;
|
||||
public GameObject freeButton;
|
||||
[SerializeField] private GameObject maskObj;
|
||||
[SerializeField] private GameObject mixButton;
|
||||
[SerializeField] private GameObject attackButton;
|
||||
[SerializeField] private GameObject gotoButton;
|
||||
[SerializeField] private GameObject freeButton;
|
||||
|
||||
public float animeDuration = 0.2f;
|
||||
[Header("Animation Parameter")]
|
||||
[SerializeField] private float animeDuration = 0.2f;
|
||||
|
||||
public float animeMoveXDistance = 20f;
|
||||
public float animeMoveYDistance = 20f;
|
||||
[SerializeField] private float animeMoveXDistance = 20f;
|
||||
[SerializeField] private float animeMoveYDistance = 20f;
|
||||
|
||||
public float animeScaleX = 1.2f;
|
||||
public float animeScaleY = 1.2f;
|
||||
[SerializeField] private float animeScaleX = 1.2f;
|
||||
[SerializeField] private float animeScaleY = 1.2f;
|
||||
|
||||
public float maskScaleX = 1;
|
||||
public float maskScaleY = 0.4f;
|
||||
[SerializeField] private float maskScaleX = 1;
|
||||
[SerializeField] private float maskScaleY = 0.4f;
|
||||
|
||||
private Vector3 mixOriginDestination;
|
||||
private Vector3 attackOriginDestination;
|
||||
@@ -109,6 +110,6 @@ public class StartMenuAnimations : MonoBehaviour
|
||||
private Vector3 fixCanvas(Vector3 vector)
|
||||
{
|
||||
// fix position of button while canvas is changed
|
||||
return vector.FixCanvas(originalCanvas,transform.parent.position);
|
||||
return vector.FixCanvas(originalCanvas, transform.parent.position);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ using UnityEngine;
|
||||
|
||||
public class StartMenuProbabilityPanel : MonoBehaviour
|
||||
{
|
||||
public GameObject singleTargetLevelProbabilityPanel;
|
||||
public GameObject startSceneData;
|
||||
[SerializeField] private GameObject singleTargetLevelProbabilityPanel;
|
||||
[SerializeField] private GameObject startSceneData;
|
||||
private SceneBlocksSet scenePrefabSet;
|
||||
|
||||
public List<TargetLevelProbabilityPanel> targetLevelProbabilityPanel = new List<TargetLevelProbabilityPanel>();
|
||||
|
||||
@@ -5,12 +5,12 @@ using UnityEngine;
|
||||
|
||||
public class StartUIManager : MonoBehaviour
|
||||
{
|
||||
public int waitTimeLimit = 45;
|
||||
public GameObject sceneLoaderObj;
|
||||
public GameObject startSceneDataObj;
|
||||
public GameObject targetLevelProbabilityPanelOBJ;
|
||||
public TextMeshProUGUI messageTextObj;
|
||||
public TextMeshProUGUI waitTimeTextObj;
|
||||
[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;
|
||||
|
||||
@@ -3,12 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
{
|
||||
public GameObject singleLevelProbabilityPanel;
|
||||
public GameObject targetTitleText;
|
||||
[SerializeField] private GameObject singleLevelProbabilityPanel;
|
||||
[SerializeField] private GameObject targetTitleText;
|
||||
|
||||
private GameObject titleText;
|
||||
public List<GameObject> singleLevelPanelsObjs = new List<GameObject>();
|
||||
@@ -43,25 +42,6 @@ public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
panelNum = levelNum;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an event trigger entry to an event trigger.
|
||||
/// </summary>
|
||||
/// <param name="trigger">The event trigger object.</param>
|
||||
/// <param name="type">The event trigger type.</param>
|
||||
/// <param name="action">The event handler method to execute.</param>
|
||||
private void AddEventTrigger(GameObject gameObject, EventTriggerType triggerType, System.Action<BaseEventData> action)
|
||||
{
|
||||
EventTrigger eventTrigger = gameObject.GetComponent<EventTrigger>();
|
||||
if (eventTrigger == null)
|
||||
{
|
||||
eventTrigger = gameObject.AddComponent<EventTrigger>();
|
||||
}
|
||||
EventTrigger.Entry entry = new EventTrigger.Entry();
|
||||
entry.eventID = triggerType;
|
||||
entry.callback.AddListener(new UnityEngine.Events.UnityAction<BaseEventData>(action));
|
||||
eventTrigger.triggers.Add(entry);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Probability Slider Value Change.Adjust other sliders' value to make sure the total value is 1.
|
||||
/// </summary>
|
||||
@@ -75,17 +55,20 @@ public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
case float floatValue:
|
||||
changedValue = floatValue;
|
||||
break;
|
||||
|
||||
case string stringValue:
|
||||
changedValue = float.Parse(stringValue);
|
||||
// limit the value between 0 and 1
|
||||
if(changedValue>1 && changedValue <=100)
|
||||
if (changedValue > 1 && changedValue <= 100)
|
||||
{
|
||||
changedValue /= 100;
|
||||
}else if(changedValue>100)
|
||||
}
|
||||
else if (changedValue > 100)
|
||||
{
|
||||
changedValue = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.LogError("Invalid value type!");
|
||||
throw new ArgumentException("Unsupported value type");
|
||||
@@ -164,8 +147,19 @@ public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calculate the correction value to each panel,while the total value is not equal to 1
|
||||
/// Recalculates correction values.
|
||||
/// </summary>
|
||||
/// <param name="correctionValues">The current array of correction values.</param>
|
||||
/// <param name="exceptedIndex">The index of the panel that is expected not to change.</param>
|
||||
/// <param name="value">The expected probability value.</param>
|
||||
/// <param name="extraValue">Additional correction value.</param>
|
||||
/// <param name="maxLimitValue">The maximum limit for the probability value.</param>
|
||||
/// <returns>Returns a tuple containing a float array and an integer.
|
||||
/// The float array is the new correction values, and the integer is the number of panels that need to be corrected in the next iteration.</returns>
|
||||
/// <remarks>
|
||||
/// This method calculates new correction values based on the provided parameters.
|
||||
/// During the iteration, some panels might exceed set limits, and their values will need to be corrected in the next iteration.
|
||||
/// </remarks>
|
||||
private (float[], int) reCalculateCorrectionValues(float[] correctionValues, int exceptedIndex, float value, float extraValue, float maxLimitValue)
|
||||
{
|
||||
// the number of panels which need to be corrected in next iteration
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
@@ -8,27 +7,28 @@ public class TargetUIController : MonoBehaviour
|
||||
{
|
||||
// Controller to control the UI of the target,
|
||||
// select target type, select prefeb to set or sth.
|
||||
public GameObject targetControllerObj;
|
||||
|
||||
public GameObject mouseSelectorObj;
|
||||
public GameObject environmentUIObj;
|
||||
[SerializeField] private GameObject targetControllerObj;
|
||||
[SerializeField] private GameObject mouseSelectorObj;
|
||||
[SerializeField] private GameObject environmentUIObj;
|
||||
|
||||
public float levelButtonHeight = 30;
|
||||
[SerializeField] private float levelButtonHeight = 30;
|
||||
|
||||
[Header("PrimaryButton")]
|
||||
public Button clearGameButton;
|
||||
public Button setEnemyButton;
|
||||
public Button setAttackButton;
|
||||
public Button setGotoButton;
|
||||
public Button setFreeButton;
|
||||
public Button setStayButton;
|
||||
public int primaryButtonNumber = 6;
|
||||
[SerializeField] private Button clearGameButton;
|
||||
|
||||
[SerializeField] private Button setEnemyButton;
|
||||
[SerializeField] private Button setAttackButton;
|
||||
[SerializeField] private Button setGotoButton;
|
||||
[SerializeField] private Button setFreeButton;
|
||||
[SerializeField] private Button setStayButton;
|
||||
[SerializeField] private int primaryButtonNumber = 6;
|
||||
|
||||
[Header("LevelPanel")]
|
||||
public GameObject gotoLevelPanel;
|
||||
[SerializeField] private GameObject gotoLevelPanel;
|
||||
|
||||
public GameObject attackLevelPanel;
|
||||
public float levelPanelAnimeTime = 0.2f;
|
||||
[SerializeField] private GameObject attackLevelPanel;
|
||||
[SerializeField] private float levelPanelAnimeTime = 0.2f;
|
||||
|
||||
private MouseInMap mouseInMapCon;
|
||||
private EnvironmentUIControl envUICon;
|
||||
@@ -162,9 +162,9 @@ public class TargetUIController : MonoBehaviour
|
||||
/// <param name="levelPanel">The level panel object containing the level buttons.</param>
|
||||
private void AddLevelButtonToColorChanger(GameObject levelPanel)
|
||||
{
|
||||
foreach(Button btn in levelPanel.GetComponent<LevelPanel>().LevelButtonList)
|
||||
foreach (Button btn in levelPanel.GetComponent<LevelPanel>().LevelButtonList)
|
||||
{
|
||||
buttonColorChanger.AddButtonToColorChangerButtonList(btn,true);
|
||||
buttonColorChanger.AddButtonToColorChangerButtonList(btn, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using XCharts.Runtime;
|
||||
|
||||
public class WorldUIController : MonoBehaviour
|
||||
{
|
||||
public LineChart winChart;
|
||||
[SerializeField] private LineChart winChart;
|
||||
public int[] totalGames;
|
||||
public int[] winGames;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user