119 lines
4.0 KiB
C#
119 lines
4.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using QFramework;
|
|
using System;
|
|
using QFramework.Example;
|
|
using System.Linq;
|
|
public class UIToolsAction : IAction
|
|
{
|
|
public ulong ActionID { get; set; }
|
|
public bool Deinited { get; set; }
|
|
public bool Paused { get; set; }
|
|
public ActionStatus Status { get; set; }
|
|
|
|
private static readonly SimpleObjectPool<UIToolsAction> mPool =
|
|
new SimpleObjectPool<UIToolsAction>(() => new UIToolsAction(), null, 10);
|
|
string answer;
|
|
string devices;
|
|
string setActive;
|
|
string rightLabel;
|
|
string wrongLabel;
|
|
string rightEvent;
|
|
string wrongEvent;
|
|
string rightScore;
|
|
string wrongScore;
|
|
string totalScore;
|
|
string scoreStepName;
|
|
string autoHide;
|
|
string random;
|
|
string scrollSpeed;
|
|
string position;
|
|
string errorCount;
|
|
public static UIToolsAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.Reset();
|
|
retNode.answer = datas.ContainsKey("answers") ? datas["answers"] : "";
|
|
retNode.devices = datas.ContainsKey("devices") ? datas["devices"] : "";
|
|
retNode.setActive = datas.ContainsKey("setActive") ? datas["setActive"] : "true";
|
|
retNode.rightLabel = datas.ContainsKey("rightLabel") ? datas["rightLabel"] : "";
|
|
retNode.wrongLabel = datas.ContainsKey("wrongLabel") ? datas["wrongLabel"] : "";
|
|
retNode.rightEvent = datas.ContainsKey("rightEvent") ? datas["rightEvent"] : "";
|
|
retNode.wrongEvent = datas.ContainsKey("wrongEvent") ? datas["wrongEvent"] : "";
|
|
retNode.rightScore = datas.ContainsKey("rightScore") ? datas["rightScore"] : "";
|
|
retNode.wrongScore = datas.ContainsKey("wrongScore") ? datas["wrongScore"] : "";
|
|
retNode.totalScore = datas.ContainsKey("totalScore") ? datas["totalScore"] : "";
|
|
retNode.scoreStepName = datas.ContainsKey("scoreStepName") ? datas["scoreStepName"] : "";
|
|
retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : "";
|
|
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;
|
|
}
|
|
|
|
|
|
|
|
public void Deinit()
|
|
{
|
|
if (!Deinited)
|
|
{
|
|
Deinited = true;
|
|
mPool.Recycle(this);
|
|
}
|
|
}
|
|
|
|
public void OnExecute(float dt)
|
|
{
|
|
}
|
|
|
|
public void OnFinish()
|
|
{
|
|
}
|
|
|
|
public void OnStart()
|
|
{
|
|
UIToolsData data = new UIToolsData();
|
|
data.answer = answer;
|
|
data.devices = devices.Split(',').ToList();
|
|
data.rightEvent = rightEvent;
|
|
data.rightLable = rightLabel;
|
|
data.wrongLabel = wrongLabel;
|
|
data.wrongEvent = wrongEvent;
|
|
float.TryParse(rightScore, out data.rightScore);
|
|
float.TryParse(wrongScore, out data.wrongScore);
|
|
float.TryParse(totalScore, out data.totalScore);
|
|
data.scoreStepName = scoreStepName;
|
|
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)
|
|
{
|
|
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());
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Status = ActionStatus.NotStart;
|
|
Paused = false;
|
|
}
|
|
}
|