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 mPool = new SimpleObjectPool(() => new UIToolsAction(), null, 10); string answer = string.Empty; string devices = string.Empty; string setActive = string.Empty; string rightLabel = string.Empty; string wrongLabel = string.Empty; string rightEvent = string.Empty; string wrongEvent = string.Empty; string rightScore = string.Empty; string wrongScore = string.Empty; string scoreStepName = string.Empty; public static UIToolsAction Allocate(string devices, string answer, string setActive, string rightLabel, string wrongLabel, string rightEvent, string wrongEvent,string rightScore, string wrongScore, string scoreStepName, System.Action onDelayFinish = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); retNode.answer = answer; retNode.devices = devices; retNode.setActive = setActive; retNode.rightLabel = rightLabel; retNode.wrongLabel = wrongLabel; retNode.rightEvent = rightEvent; retNode.wrongEvent = wrongEvent; retNode.rightScore = rightScore; retNode.wrongScore = wrongScore; retNode.scoreStepName = scoreStepName; 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); data.scoreStepName = scoreStepName; bool.TryParse(setActive, out data.SetActive); UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish()); } public void Reset() { Status = ActionStatus.NotStart; Paused = false; } }