增加滑动速度和乱序的设置
This commit is contained in:
parent
b87a45b622
commit
b1682e11d0
@ -411,5 +411,16 @@ public class Utility
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 使用Unity的Random实现洗牌
|
||||||
|
public static void Shuffle<T>(IList<T> list)
|
||||||
|
{
|
||||||
|
int n = list.Count;
|
||||||
|
for (int i = n - 1; i > 0; i--)
|
||||||
|
{
|
||||||
|
int j = UnityEngine.Random.Range(0, i + 1);
|
||||||
|
T temp = list[i];
|
||||||
|
list[i] = list[j];
|
||||||
|
list[j] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -26,6 +26,8 @@ public class UIToolsAction : IAction
|
|||||||
string totalScore;
|
string totalScore;
|
||||||
string scoreStepName;
|
string scoreStepName;
|
||||||
string autoHide;
|
string autoHide;
|
||||||
|
string random;
|
||||||
|
string scrollSpeed;
|
||||||
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();
|
||||||
@ -44,6 +46,8 @@ public class UIToolsAction : IAction
|
|||||||
retNode.totalScore = datas.ContainsKey("totalScore") ? datas["totalScore"] : "";
|
retNode.totalScore = datas.ContainsKey("totalScore") ? datas["totalScore"] : "";
|
||||||
retNode.scoreStepName = datas.ContainsKey("scoreStepName") ? datas["scoreStepName"] : "";
|
retNode.scoreStepName = datas.ContainsKey("scoreStepName") ? datas["scoreStepName"] : "";
|
||||||
retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : "";
|
retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : "";
|
||||||
|
retNode.random = datas.ContainsKey("random") ? datas["random"] : "";
|
||||||
|
retNode.scrollSpeed = datas.ContainsKey("scrollSpeed") ? datas["scrollSpeed"] : "";
|
||||||
return retNode;
|
return retNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +84,15 @@ public class UIToolsAction : IAction
|
|||||||
float.TryParse(totalScore, out data.totalScore);
|
float.TryParse(totalScore, out data.totalScore);
|
||||||
data.scoreStepName = scoreStepName;
|
data.scoreStepName = scoreStepName;
|
||||||
bool.TryParse(setActive, out data.SetActive);
|
bool.TryParse(setActive, out data.SetActive);
|
||||||
|
if (bool.TryParse(random, out data.random) == false)
|
||||||
|
{
|
||||||
|
data.random = false;
|
||||||
|
}
|
||||||
|
if (float.TryParse(scrollSpeed, out data.scrollSpeed) == false)
|
||||||
|
{
|
||||||
|
data.scrollSpeed = 25;
|
||||||
|
}
|
||||||
|
|
||||||
if (float.TryParse(autoHide, out data.autoHideResult) == false)
|
if (float.TryParse(autoHide, out data.autoHideResult) == false)
|
||||||
{
|
{
|
||||||
data.autoHideResult = -1;
|
data.autoHideResult = -1;
|
||||||
|
|||||||
@ -23,6 +23,8 @@ namespace QFramework.Example
|
|||||||
public float totalScore;
|
public float totalScore;
|
||||||
public string scoreStepName;
|
public string scoreStepName;
|
||||||
public float autoHideResult = -1;
|
public float autoHideResult = -1;
|
||||||
|
public bool random = false;
|
||||||
|
public float scrollSpeed = 25;
|
||||||
}
|
}
|
||||||
public partial class UITools : UIPanel
|
public partial class UITools : UIPanel
|
||||||
{
|
{
|
||||||
@ -55,6 +57,11 @@ namespace QFramework.Example
|
|||||||
answers = mData.answer.Split(',')?.ToList();
|
answers = mData.answer.Split(',')?.ToList();
|
||||||
}
|
}
|
||||||
Content.RemoveAllChildren();
|
Content.RemoveAllChildren();
|
||||||
|
if (mData.devices.Count > 0 && mData.random)
|
||||||
|
{
|
||||||
|
Utility.Shuffle(mData.devices);
|
||||||
|
}
|
||||||
|
Scroll.scrollSensitivity = mData.scrollSpeed;
|
||||||
foreach (var device in mData.devices)
|
foreach (var device in mData.devices)
|
||||||
{
|
{
|
||||||
var item = DeviceController.Instance.GetDevice(device);
|
var item = DeviceController.Instance.GetDevice(device);
|
||||||
|
|||||||
@ -570,6 +570,16 @@ namespace XMLTool
|
|||||||
{
|
{
|
||||||
act.args.Add("autoHide", autoHide.Value);
|
act.args.Add("autoHide", autoHide.Value);
|
||||||
}
|
}
|
||||||
|
var random = action.Attribute("random");
|
||||||
|
if (random != null)
|
||||||
|
{
|
||||||
|
act.args.Add("random", random.Value);
|
||||||
|
}
|
||||||
|
var scrollSpeed = action.Attribute("scrollSpeed");
|
||||||
|
if (scrollSpeed != null)
|
||||||
|
{
|
||||||
|
act.args.Add("scrollSpeed", scrollSpeed.Value);
|
||||||
|
}
|
||||||
newAction = act;
|
newAction = act;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -29,7 +29,9 @@
|
|||||||
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测
|
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测
|
||||||
rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key
|
rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key
|
||||||
autoHide =-1 则点击结束 否则 等待对应时间后自动结束
|
autoHide =-1 则点击结束 否则 等待对应时间后自动结束
|
||||||
totalScore 是配合wrongScore的用于初始化一个分数 然后选择扣分-->
|
totalScore 是配合wrongScore的用于初始化一个分数 然后选择扣分
|
||||||
|
random 是否打乱devices的顺序
|
||||||
|
scrollSpeed 鼠标滚轮的滑动速度-->
|
||||||
<Action type="UITools" devices="道具名字1" answers="正确道具"
|
<Action type="UITools" devices="道具名字1" answers="正确道具"
|
||||||
setActive="true"
|
setActive="true"
|
||||||
rightLabel="提示:器械选择正确。"
|
rightLabel="提示:器械选择正确。"
|
||||||
@ -40,7 +42,9 @@
|
|||||||
wrongScore=""
|
wrongScore=""
|
||||||
totalScore=""
|
totalScore=""
|
||||||
scoreStepName="手术准备器械选择"
|
scoreStepName="手术准备器械选择"
|
||||||
autoHide="-1"></Action>
|
autoHide="-1"
|
||||||
|
random="true"
|
||||||
|
scrollSpeed="25"></Action>
|
||||||
|
|
||||||
<!--物体点位选择 物体的中心点-->
|
<!--物体点位选择 物体的中心点-->
|
||||||
<Action type="PointQuestion" value="路径1,路径2"></Action>
|
<Action type="PointQuestion" value="路径1,路径2"></Action>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user