V3.3.7 转移SceneBlockPrefabSet
转移SceneBlockPrefabSet至Scene Start的StartSceneData中
This commit is contained in:
@@ -29,7 +29,6 @@ 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++)
|
||||
|
||||
@@ -130,6 +130,9 @@ 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;
|
||||
@@ -175,6 +178,7 @@ public class ParameterContainer : MonoBehaviour
|
||||
gotoLevelProbs = startSceneData.gotoLevelProbs;
|
||||
defenceProb = startSceneData.defenceProb;
|
||||
defenceLevelProbs = startSceneData.defenceLevelProbs;
|
||||
scenePrefabSet = startSceneData.scenePrefabSet;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
@@ -4,20 +4,20 @@ public class SceneBlockContainer : MonoBehaviour
|
||||
{
|
||||
public float sceneSize = 10f;
|
||||
public GameObject environmentObj;
|
||||
public GameObject parameterContainerObj;
|
||||
public GameObject hudObj;
|
||||
|
||||
// public GameObject[] attackBlockPrefabs = new GameObject[1];
|
||||
// public GameObject[] goBlockPrefabs = new GameObject[1];
|
||||
// public GameObject[] defencePrefabs = new GameObject[1];
|
||||
public SceneBlocksSet scenePrefabSet;
|
||||
|
||||
private GameObject nowBlockObj;
|
||||
public SceneBlock nowBlock;
|
||||
private GameObject nowBlockObj;
|
||||
private ParameterContainer paramCon;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// initialize scene prefab set
|
||||
scenePrefabSet.InitializeSceneBlocksSet(hudObj);
|
||||
paramCon = parameterContainerObj.GetComponent<ParameterContainer>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -40,7 +40,7 @@ public class SceneBlockContainer : MonoBehaviour
|
||||
DestroyBlock();
|
||||
}
|
||||
// choose target type
|
||||
nowBlockObj = Instantiate(scenePrefabSet.GetPrefab(level, blockType, targetType), blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
|
||||
nowBlockObj = Instantiate(paramCon.scenePrefabSet.GetPrefab(level, blockType, targetType), blockPosition + environmentObj.transform.position, Quaternion.identity, transform);
|
||||
nowBlock = nowBlockObj.GetComponent<SceneBlock>();
|
||||
nowBlock.group1Tag = tag1;
|
||||
nowBlock.group2Tag = tag2;
|
||||
|
||||
@@ -105,8 +105,8 @@ public class TargetController : MonoBehaviour
|
||||
|
||||
freeProb = 1 - attackProb - gotoProb - defenceProb;
|
||||
targetNum = (int)Targets.Num;
|
||||
gotoLevelNum = sceneBlockCon.scenePrefabSet.GetLevelNumber(Targets.Go);
|
||||
attackLevelNum = sceneBlockCon.scenePrefabSet.GetLevelNumber(Targets.Attack);
|
||||
gotoLevelNum = paramCon.scenePrefabSet.GetLevelNumber(Targets.Go);
|
||||
attackLevelNum = paramCon.scenePrefabSet.GetLevelNumber(Targets.Attack);
|
||||
if (freeProb < 0)
|
||||
{
|
||||
Debug.LogError("TargetController.Start: target percentage wrong");
|
||||
@@ -166,7 +166,7 @@ public class TargetController : MonoBehaviour
|
||||
else if (randTargetType > gotoProb && randTargetType <= gotoProb + attackProb)
|
||||
{
|
||||
// attack target spawn
|
||||
Debug.Log("ATTACK!");
|
||||
Debug.Log("ATTACK Mode Start");
|
||||
targetTypeInt = (int)Targets.Attack;
|
||||
RandomSpawnSceneBlock(Targets.Attack);
|
||||
// set startDistance
|
||||
@@ -176,7 +176,7 @@ public class TargetController : MonoBehaviour
|
||||
else if (randTargetType > gotoProb + attackProb && randTargetType <= gotoProb + attackProb + defenceProb)
|
||||
{
|
||||
// defence target spawn
|
||||
Debug.Log("DEFENCE!");
|
||||
Debug.Log("DEFENCE Mode Start");
|
||||
targetTypeInt = (int)Targets.Defence;
|
||||
RandomSpawnSceneBlock(Targets.Defence);
|
||||
// set startDistance
|
||||
@@ -184,7 +184,7 @@ public class TargetController : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Free");
|
||||
Debug.Log("Free Mode Start");
|
||||
targetTypeInt = (int)Targets.Free;
|
||||
enemyCon.DestroyAllEnemys();
|
||||
enemyCon.RandomInitEnemys(hudCon.enemyNum);
|
||||
@@ -257,8 +257,8 @@ public class TargetController : MonoBehaviour
|
||||
private void RandomSpawnSceneBlock(Targets targetType)
|
||||
{
|
||||
randLevel = RollRandomLevelIndex(targetType);
|
||||
randBlockType = Random.Range(0, sceneBlockCon.scenePrefabSet.GetBlockNumber(randLevel,targetType));
|
||||
sceneBlockSize = sceneBlockCon.scenePrefabSet.GetBlockSize(randLevel, randBlockType, targetType);
|
||||
randBlockType = Random.Range(0, paramCon.scenePrefabSet.GetBlockNumber(randLevel,targetType));
|
||||
sceneBlockSize = paramCon.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);
|
||||
|
||||
@@ -13,12 +13,14 @@ public class MouseInMap : MonoBehaviour
|
||||
public GameObject enemyContainerObj;
|
||||
public GameObject sceneBlockContainerObj;
|
||||
public GameObject targetControllerObj;
|
||||
public GameObject parameterContainerObj;
|
||||
public GameObject HUDObj;
|
||||
|
||||
private Vector3 nowHitPosition = Vector3.zero;
|
||||
private Vector3 nowHitPositionRelative = Vector3.zero;
|
||||
private LayerMask groundMask;
|
||||
private int blockNum;
|
||||
private ParameterContainer paramCon;
|
||||
private GameObject previewModel;
|
||||
private TargetController targetCon;
|
||||
private MousePreview mousePreviewCon;
|
||||
@@ -45,6 +47,7 @@ public class MouseInMap : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
paramCon = parameterContainerObj.GetComponent<ParameterContainer>();
|
||||
groundMask = LayerMask.GetMask("Ground");
|
||||
targetCon = targetControllerObj.GetComponent<TargetController>();
|
||||
mousePreviewCon = mousePreviewObj.GetComponent<MousePreview>();
|
||||
@@ -137,7 +140,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 = sceneBlockCon.scenePrefabSet.GetLevelNumber(nowTargetType);
|
||||
blockLevel = paramCon.scenePrefabSet.GetLevelNumber(nowTargetType);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -149,7 +152,7 @@ public class MouseInMap : MonoBehaviour
|
||||
if (blockNum < 0)
|
||||
{
|
||||
// while blockNum is not set, random choose block type
|
||||
this.blockNum = Random.Range(0, sceneBlockCon.scenePrefabSet.GetBlockNumber(blockLevel, nowTargetType));
|
||||
this.blockNum = Random.Range(0, paramCon.scenePrefabSet.GetBlockNumber(blockLevel, nowTargetType));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -157,7 +160,7 @@ public class MouseInMap : MonoBehaviour
|
||||
this.blockNum = blockNum;
|
||||
}
|
||||
// set previewModel
|
||||
previewModel = sceneBlockCon.scenePrefabSet.GetPrefab(blockLevel, this.blockNum, nowTargetType);
|
||||
previewModel = paramCon.scenePrefabSet.GetPrefab(blockLevel, this.blockNum, nowTargetType);
|
||||
mousePreviewCon.ChangePreviewTo(previewModel);
|
||||
break;
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ using UnityEngine;
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is responsible for organizing and initializing different sets of scene blocks,
|
||||
/// which include levels, blocks, and their associated properties.
|
||||
/// which include targetLevels, blocks, and their associated properties.
|
||||
/// </remarks>
|
||||
[CreateAssetMenu(menuName = "All Scene Prefab Set")]
|
||||
public class SceneBlocksSet : ScriptableObject
|
||||
{
|
||||
public LevelsSet[] levels = new LevelsSet[3];
|
||||
public TargetLevelsSet[] targetLevels = new TargetLevelsSet[3];
|
||||
public Targets[] targets = new Targets[3];
|
||||
|
||||
private GameObject hudObj;
|
||||
@@ -31,10 +31,10 @@ public class SceneBlocksSet : ScriptableObject
|
||||
this.hudObj = hudObj;
|
||||
messageBoxController = this.hudObj.GetComponent<MessageBoxController>();
|
||||
}
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
for (int i = 0; i < targetLevels.Length; i++)
|
||||
{
|
||||
// initialize all level prefab set
|
||||
levels[i].InitializeLevelsSet();
|
||||
targetLevels[i].InitializeLevelsSet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SceneBlocksSet : ScriptableObject
|
||||
/// If the target type (targetType) or index (index) is provided, it returns the corresponding level prefab set.
|
||||
/// If neither the target type (targetType) nor the index (index) is provided, an exception will be thrown, and an error message will be logged.
|
||||
/// </remarks>
|
||||
public LevelsSet GetAllLevlePrefabSet(Targets? targetType = null, int? index = null)
|
||||
public TargetLevelsSet GetAllLevlePrefabSet(Targets? targetType = null, int? index = null)
|
||||
{
|
||||
if (targetType == null && index == null)
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public class SceneBlocksSet : ScriptableObject
|
||||
new List<string> { messageBoxController.errorColor });
|
||||
break;
|
||||
}
|
||||
return levels[levelIndex];
|
||||
return targetLevels[levelIndex];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -127,13 +127,13 @@ public class SceneBlocksSet : ScriptableObject
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of levels for a specific target type and index.
|
||||
/// Gets the number of targetLevels for a specific target type and index.
|
||||
/// </summary>
|
||||
/// <param name="targetType">The target type (optional).</param>
|
||||
/// <param name="index">The index (optional).</param>
|
||||
/// <returns>The number of levels.</returns>
|
||||
/// <returns>The number of targetLevels.</returns>
|
||||
/// <remarks>
|
||||
/// If the target type (targetType) or index (index) is provided, it returns the number of levels for the corresponding target type and index.
|
||||
/// If the target type (targetType) or index (index) is provided, it returns the number of targetLevels for the corresponding target type and index.
|
||||
/// </remarks>
|
||||
public int GetLevelNumber(Targets? targetType = null, int? index = null)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,9 @@ public class StartSeneData : MonoBehaviour
|
||||
{
|
||||
[Header("Game mode")]
|
||||
public int gameMode = 0;// default trainning mode
|
||||
[Header("ScenePrefabSet")]
|
||||
public SceneBlocksSet scenePrefabSet;
|
||||
|
||||
[Header("Targets Prob")]
|
||||
public float attackProb = 0f;
|
||||
public List<float> attackLevelProbs = new List<float>();
|
||||
@@ -13,6 +16,13 @@ public class StartSeneData : MonoBehaviour
|
||||
public float defenceProb = 0f;
|
||||
public List<float> defenceLevelProbs = new List<float>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
scenePrefabSet.InitializeSceneBlocksSet();
|
||||
attackLevelProbs = new List<float>(scenePrefabSet.targetLevels[0].levelSize);
|
||||
gotoLevelProbs = new List<float>(scenePrefabSet.targetLevels[1].levelSize);
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
DontDestroyOnLoad(transform.gameObject);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -7,11 +8,14 @@ public class StartUIManager : MonoBehaviour
|
||||
public int waitTimeLimit = 45;
|
||||
public GameObject sceneLoaderObj;
|
||||
public GameObject startSceneDataObj;
|
||||
public GameObject targetLevelProbabilityPanelOBJ;
|
||||
public TextMeshProUGUI messageTextObj;
|
||||
public TextMeshProUGUI waitTimeTextObj;
|
||||
|
||||
private SceneLoader sceneLoader;
|
||||
private StartSeneData startSceneData;
|
||||
private ButtonActivateColorChanger buttonActivateColorChanger;
|
||||
private StartMenuProbabilityPanel startMenuProbabilityPanel;
|
||||
private float startTime;
|
||||
private float nowTime;
|
||||
// Start is called before the first frame update
|
||||
@@ -20,6 +24,7 @@ public class StartUIManager : MonoBehaviour
|
||||
sceneLoader = sceneLoaderObj.GetComponent<SceneLoader>();
|
||||
startSceneData = startSceneDataObj.GetComponent<StartSeneData>();
|
||||
buttonActivateColorChanger = GetComponent<ButtonActivateColorChanger>();
|
||||
startMenuProbabilityPanel = targetLevelProbabilityPanelOBJ.GetComponent<StartMenuProbabilityPanel>();
|
||||
messageTextObj.text = "";
|
||||
buttonActivateColorChanger.InitializeAllButtonColor();
|
||||
}
|
||||
@@ -48,17 +53,22 @@ public class StartUIManager : MonoBehaviour
|
||||
{
|
||||
// while Train-Attack-Button Pressed
|
||||
startSceneData.attackProb = 1f;
|
||||
ApplicateProbabilityToData();
|
||||
LoadTrainScene();
|
||||
}
|
||||
public void OnGotoTrainButtonPressed()
|
||||
{
|
||||
// while Train-Goto-Button Pressed
|
||||
startSceneData.gotoProb = 1f;
|
||||
ApplicateProbabilityToData();
|
||||
LoadTrainScene();
|
||||
}
|
||||
public void OnFreeTrainButtonPressed()
|
||||
{
|
||||
// while Train-Free-Button Pressed
|
||||
startSceneData.attackProb = 0f;
|
||||
startSceneData.gotoProb = 0f;
|
||||
startSceneData.defenceProb = 0f;
|
||||
LoadTrainScene();
|
||||
}
|
||||
public void OnMixTrainButtonPressed()
|
||||
@@ -74,7 +84,16 @@ public class StartUIManager : MonoBehaviour
|
||||
sceneLoader.LoadGameScene(SceneLoader.SceneType.Train);
|
||||
messageTextObj.text = "Loading Train Scene...";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
private void ApplicateProbabilityToData()
|
||||
{
|
||||
for (int i = 0; i < startSceneData.scenePrefabSet.targetLevels[0].levelSize; i++)
|
||||
{
|
||||
startSceneData.gotoLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[0].singleLevelPanels[i].ProbabilityValue);
|
||||
}
|
||||
for(int i = 0; i < startSceneData.scenePrefabSet.targetLevels[1].levelSize; i++)
|
||||
{
|
||||
startSceneData.attackLevelProbs.Add(startMenuProbabilityPanel.targetLevelProbabilityPanel[1].singleLevelPanels[i].ProbabilityValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using UnityEngine;
|
||||
/// This class is used to organize and initialize multiple level prefab sets.
|
||||
/// </remarks>
|
||||
[CreateAssetMenu(menuName = "All Level Prefab Set")]
|
||||
public class LevelsSet : ScriptableObject
|
||||
public class TargetLevelsSet : ScriptableObject
|
||||
{
|
||||
public BlocksSet[] singleLevelSet;
|
||||
[NonSerialized] public int levelSize = 0;
|
||||
Reference in New Issue
Block a user