UITools支持错误次数
This commit is contained in:
parent
0f2f49dd01
commit
d1ab8046f9
@ -29,6 +29,7 @@ public class UIToolsAction : IAction
|
||||
string random;
|
||||
string scrollSpeed;
|
||||
string position;
|
||||
string errorCount;
|
||||
public static UIToolsAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
@ -50,6 +51,7 @@ public class UIToolsAction : IAction
|
||||
retNode.random = datas.ContainsKey("random") ? datas["random"] : "";
|
||||
retNode.scrollSpeed = datas.ContainsKey("scrollSpeed") ? datas["scrollSpeed"] : "";
|
||||
retNode.position = datas.ContainsKey("position") ? datas["position"] : "";
|
||||
retNode.errorCount = datas.ContainsKey("errorCount") ? datas["errorCount"] : "";
|
||||
return retNode;
|
||||
}
|
||||
|
||||
@ -100,6 +102,11 @@ public class UIToolsAction : IAction
|
||||
data.autoHideResult = -1;
|
||||
}
|
||||
data.position = position;
|
||||
if (int.TryParse(errorCount, out data.errorCount) == false)
|
||||
{
|
||||
data.errorCount = 0;
|
||||
}
|
||||
|
||||
UIKit.OpenPanelAsync<UITools>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
|
||||
}
|
||||
|
||||
|
||||
@ -26,11 +26,13 @@ namespace QFramework.Example
|
||||
public bool random = false;
|
||||
public float scrollSpeed = 25;
|
||||
public string position;
|
||||
public int errorCount = 0;
|
||||
}
|
||||
public partial class UITools : UIPanel
|
||||
{
|
||||
ResLoader mResLoader;
|
||||
public List<string> answers;
|
||||
int curErrorCount = 0;
|
||||
protected override void OnInit(IUIData uiData = null)
|
||||
{
|
||||
mData = uiData as UIToolsData ?? new UIToolsData();
|
||||
@ -47,6 +49,7 @@ namespace QFramework.Example
|
||||
protected override void OnOpen(IUIData uiData = null)
|
||||
{
|
||||
mData = uiData as UIToolsData ?? new UIToolsData();
|
||||
curErrorCount = 0;
|
||||
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(gameObject);
|
||||
if (mData.totalScore > 0)
|
||||
{
|
||||
@ -90,6 +93,7 @@ namespace QFramework.Example
|
||||
Button btn = obj.GetComponent<Button>();
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
|
||||
if (answers != null)
|
||||
{
|
||||
if (answers.Contains(item.Name))
|
||||
@ -121,12 +125,15 @@ namespace QFramework.Example
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(mData.rightEvent) == false)
|
||||
{
|
||||
if (curErrorCount >= mData.errorCount)
|
||||
{
|
||||
StringEventSystem.Global.Send(mData.rightEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ScoreController.Instance.Add(mData.scoreStepName, mData.wrongScore);
|
||||
@ -139,9 +146,12 @@ namespace QFramework.Example
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(mData.wrongEvent) == false)
|
||||
{
|
||||
if (curErrorCount >= mData.errorCount)
|
||||
{
|
||||
StringEventSystem.Global.Send(mData.wrongEvent);
|
||||
}
|
||||
}
|
||||
SetSelected(obj, false);
|
||||
};
|
||||
data.autoHideTime = mData.autoHideResult;
|
||||
@ -150,15 +160,18 @@ namespace QFramework.Example
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(mData.wrongEvent) == false)
|
||||
{
|
||||
if (curErrorCount >= mData.errorCount)
|
||||
{
|
||||
StringEventSystem.Global.Send(mData.wrongEvent);
|
||||
}
|
||||
}
|
||||
SetSelected(obj, false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.curErrorCount++;
|
||||
});
|
||||
}
|
||||
mResLoader.LoadAsync();
|
||||
|
||||
@ -592,6 +592,11 @@ namespace XMLTool
|
||||
{
|
||||
act.args.Add("position", position.Value);
|
||||
}
|
||||
var errorCount = action.Attribute("errorCount");
|
||||
if (errorCount != null)
|
||||
{
|
||||
act.args.Add("errorCount", errorCount.Value);
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user