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