分离Parameter为Common Parameter和会随着游戏State改变的Parameter。
将不需要public的一些变量改为private。
This commit is contained in:
@@ -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