V3.3.9 LevelProbabilityPanel追加对Inputfiled支持
LevelProbabilityPanel追加对Inputfiled支持
This commit is contained in:
@@ -14,3 +14,8 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
singleLevelSet:
|
||||
- {fileID: 11400000, guid: 8fc444f0771edf64f8bfc352977d8597, type: 2}
|
||||
- {fileID: 11400000, guid: 824206b6150173f4ab356e3cab2011c1, type: 2}
|
||||
- {fileID: 11400000, guid: bf01cc7b27025bb42b08f85f974dffdc, type: 2}
|
||||
- {fileID: 11400000, guid: 20e2f42b37b20f54b90e75d1cd18fefd, type: 2}
|
||||
- {fileID: 11400000, guid: 95510ba257a6a6b4090e442ac0ebdea4, type: 2}
|
||||
- {fileID: 11400000, guid: 89a57384b37c260478f5ae0d8f6e4e70, type: 2}
|
||||
|
||||
@@ -12,4 +12,12 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: db8f30e5213a1754699f4eda49cb3e63, type: 3}
|
||||
m_Name: Attack-Level-3
|
||||
m_EditorClassIdentifier:
|
||||
prefabs: []
|
||||
prefabs:
|
||||
- {fileID: 153724040464013533, guid: 25090bb6da3a3a144bc7308bf8ee1ddc, type: 3}
|
||||
- {fileID: 6932241698995909476, guid: 3b92359e52c9ec14fb0ac66d88680564, type: 3}
|
||||
- {fileID: 8811406908067387120, guid: 18ddbc2ec71e5324fb123e1871dedf83, type: 3}
|
||||
- {fileID: 7680806552874981335, guid: 296457b13a26f8b47bc75a00d0e63ab0, type: 3}
|
||||
- {fileID: 3771963018917625986, guid: df95264657c12d044840f07604f64b05, type: 3}
|
||||
- {fileID: 4632827343611451248, guid: 45098a2d9f390084ca3dbc5be1a37fc2, type: 3}
|
||||
- {fileID: 6227114820474435122, guid: a58ef869c9f73a84487cc8c6c5868768, type: 3}
|
||||
- {fileID: 4683095661607992907, guid: 9e439c29550618c43b0f467eff89d778, type: 3}
|
||||
|
||||
@@ -12,4 +12,12 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: db8f30e5213a1754699f4eda49cb3e63, type: 3}
|
||||
m_Name: Attack-Level-4
|
||||
m_EditorClassIdentifier:
|
||||
prefabs: []
|
||||
prefabs:
|
||||
- {fileID: 2868400889033167268, guid: 130c5826bf21ac34a9d2f73b0c433f97, type: 3}
|
||||
- {fileID: 7064833557264840747, guid: 2e0c5cd751a45c44b93cfa8f5453b963, type: 3}
|
||||
- {fileID: 2980891294243248750, guid: 96d5fe65469ff004089f43bb0fc1b9ae, type: 3}
|
||||
- {fileID: 8037128401047184452, guid: 71224e1986254924b8b5a938cb66e2e3, type: 3}
|
||||
- {fileID: 4621523416105491377, guid: f1559bd3904dd53458e744a59ed0cb69, type: 3}
|
||||
- {fileID: 9133506841816092732, guid: 8fa6fc423c8822749bf4f72a33fba696, type: 3}
|
||||
- {fileID: 1784126616450114382, guid: 0c7ec1d1c61772c45931a8207ff74a63, type: 3}
|
||||
- {fileID: 7781315202289332697, guid: 33bbd85803525814c8343995827a23df, type: 3}
|
||||
|
||||
@@ -12,4 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: db8f30e5213a1754699f4eda49cb3e63, type: 3}
|
||||
m_Name: Attack-Level-5
|
||||
m_EditorClassIdentifier:
|
||||
prefabs: []
|
||||
prefabs:
|
||||
- {fileID: 4889017667857126960, guid: d79eeedf6ed13d74f84d4153e2a2b284, type: 3}
|
||||
- {fileID: 6726598211612887349, guid: c5f7939eed90cce4e8e67d73226c8fb2, type: 3}
|
||||
- {fileID: 2974204549381235631, guid: 4994a976d1a7f2a4a8a77f9475486203, type: 3}
|
||||
|
||||
@@ -476,14 +476,14 @@ MonoBehaviour:
|
||||
m_VerticalScrollbarEventHandler: {fileID: 0}
|
||||
m_LayoutGroup: {fileID: 0}
|
||||
m_ScrollSensitivity: 1
|
||||
m_ContentType: 0
|
||||
m_ContentType: 3
|
||||
m_InputType: 0
|
||||
m_AsteriskChar: 42
|
||||
m_KeyboardType: 0
|
||||
m_KeyboardType: 2
|
||||
m_LineType: 0
|
||||
m_HideMobileInput: 0
|
||||
m_HideSoftKeyboard: 0
|
||||
m_CharacterValidation: 0
|
||||
m_CharacterValidation: 3
|
||||
m_RegexValue:
|
||||
m_GlobalPointSize: 14
|
||||
m_CharacterLimit: 0
|
||||
@@ -1067,6 +1067,7 @@ MonoBehaviour:
|
||||
lockImg: {fileID: 5717613260432307835}
|
||||
unlockImg: {fileID: 5816262599943080368}
|
||||
probabilitySlider: {fileID: 2237638637685423040}
|
||||
probabilityValue: 0
|
||||
--- !u!1 &6883838559566756852
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
@@ -36,7 +37,8 @@ public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
singleLevelPanels.Add(singleLevelPanelsObjs[i].GetComponent<SingleLevelProbabilityPanel>());
|
||||
singleLevelPanels[i].InitializeLevelProbabilityPanel(i, i == levelNum - 1 ? lastLevelProbability : averageProbability);
|
||||
//add onValueChanged event to slider and input field
|
||||
singleLevelPanels[i].probabilitySlider.onValueChanged.AddListener((value) => OnSliderValueChange(value, tempIndex));
|
||||
singleLevelPanels[i].probabilitySlider.onValueChanged.AddListener((value) => OnProbabilityValueChange(value, tempIndex));
|
||||
singleLevelPanels[i].inputField.onEndEdit.AddListener((value) => OnProbabilityValueChange(value, tempIndex));
|
||||
}
|
||||
panelNum = levelNum;
|
||||
}
|
||||
@@ -65,8 +67,30 @@ public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
/// </summary>
|
||||
/// <param name="value">change to this value</param>
|
||||
/// <param name="exceptedIndex">changed panel index</param>
|
||||
private void OnSliderValueChange(float value, int exceptedIndex)
|
||||
private void OnProbabilityValueChange<T>(T value, int exceptedIndex)
|
||||
{
|
||||
float changedValue = 0f;
|
||||
switch (value)
|
||||
{
|
||||
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)
|
||||
{
|
||||
changedValue /= 100;
|
||||
}else if(changedValue>100)
|
||||
{
|
||||
changedValue = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug.LogError("Invalid value type!");
|
||||
throw new ArgumentException("Unsupported value type");
|
||||
}
|
||||
Debug.Log(value);
|
||||
float newTotalValue = 0; // new total probability value without locked panel
|
||||
int unlockedPanelNum = 0;
|
||||
int remainCorrectionNum = panelNum;
|
||||
@@ -82,7 +106,7 @@ public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
if (singleLevelPanels[i].UnLocked)
|
||||
{
|
||||
unlockedPanelNum++;
|
||||
newTotalValue += (i == exceptedIndex ? value : singleLevelPanels[i].ProbabilityValue);
|
||||
newTotalValue += (i == exceptedIndex ? changedValue : singleLevelPanels[i].ProbabilityValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -114,7 +138,7 @@ public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
while (remainCorrectionNum > 0)
|
||||
{
|
||||
iterationCount++;
|
||||
(correctionValues, remainCorrectionNum) = reCalculateCorrectionValues(correctionValues, exceptedIndex, value, extraValue, maxLimitValue);
|
||||
(correctionValues, remainCorrectionNum) = reCalculateCorrectionValues(correctionValues, exceptedIndex, changedValue, extraValue, maxLimitValue);
|
||||
// protect the infinite loop
|
||||
if (iterationCount >= 100)
|
||||
{
|
||||
@@ -136,7 +160,7 @@ public class TargetLevelProbabilityPanel : MonoBehaviour
|
||||
for (int i = 0; i < panelNum; i++)
|
||||
{
|
||||
int tempIndex = i;
|
||||
singleLevelPanels[i].probabilitySlider.onValueChanged.AddListener((value) => OnSliderValueChange(value, tempIndex));
|
||||
singleLevelPanels[i].probabilitySlider.onValueChanged.AddListener((value) => OnProbabilityValueChange(value, tempIndex));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user