78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using QFramework;
|
|
using System;
|
|
using QFramework.Example;
|
|
using System.Linq;
|
|
public class TextQuestionAction : 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<TextQuestionAction> mPool =
|
|
new SimpleObjectPool<TextQuestionAction>(() => new TextQuestionAction(), null, 10);
|
|
string title = string.Empty;
|
|
string options = string.Empty;
|
|
string answers = string.Empty;
|
|
string btns = string.Empty;
|
|
string wait = string.Empty;
|
|
string showAnswer = string.Empty;
|
|
public static TextQuestionAction Allocate(string title, string options, string answers, string btns, string wait, string showAnswer, System.Action onDelayFinish = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.Reset();
|
|
retNode.title = title;
|
|
retNode.options = options;
|
|
retNode.btns = btns;
|
|
retNode.answers = answers;
|
|
retNode.wait = wait;
|
|
retNode.showAnswer = showAnswer;
|
|
return retNode;
|
|
}
|
|
|
|
|
|
|
|
public void Deinit()
|
|
{
|
|
if (!Deinited)
|
|
{
|
|
Deinited = true;
|
|
mPool.Recycle(this);
|
|
}
|
|
}
|
|
|
|
public void OnExecute(float dt)
|
|
{
|
|
}
|
|
|
|
public void OnFinish()
|
|
{
|
|
}
|
|
|
|
public void OnStart()
|
|
{
|
|
UITextQuestionData data = new UITextQuestionData();
|
|
data.title = title;
|
|
data.options = options.Split('|').ToList();
|
|
foreach (var item in answers.Split(','))
|
|
{
|
|
data.answers.Add(item);
|
|
}
|
|
data.btns = btns.Split(',').ToList();
|
|
float.TryParse(wait, out data.waitCloseTime);
|
|
bool.TryParse(showAnswer, out data.showAnswer);
|
|
UIKit.OpenPanelAsync<UITextQuestion>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Status = ActionStatus.NotStart;
|
|
Paused = false;
|
|
}
|
|
}
|