115 lines
3.4 KiB
C#
115 lines
3.4 KiB
C#
using QFramework.Example;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using XMLTool;
|
|
|
|
namespace QFramework
|
|
{
|
|
internal class ImageSelectMapAction : IAction
|
|
{
|
|
public string txt;
|
|
|
|
|
|
public System.Action OnFinished { get; set; }
|
|
|
|
|
|
private ImageSelectMapAction()
|
|
{
|
|
}
|
|
|
|
private static readonly SimpleObjectPool<ImageSelectMapAction> mPool =
|
|
new SimpleObjectPool<ImageSelectMapAction>(() => new ImageSelectMapAction(), null, 10);
|
|
Dictionary<string, string> datas;
|
|
List<XMLTool.ImageSelectMapAction.Item> items;
|
|
public static ImageSelectMapAction Allocate(Dictionary<string, string> datas, List<XMLTool.ImageSelectMapAction.Item> items, System.Action OnFinished = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.datas = datas;
|
|
retNode.items = items;
|
|
retNode.Reset();
|
|
retNode.OnFinished = OnFinished;
|
|
return retNode;
|
|
}
|
|
|
|
|
|
public ulong ActionID { get; set; }
|
|
public ActionStatus Status { get; set; }
|
|
|
|
public void OnStart()
|
|
{
|
|
|
|
UIImageSelectMapData data = new UIImageSelectMapData();
|
|
data.totalScore = 0;
|
|
if (datas.ContainsKey("totalScore"))
|
|
{
|
|
float.TryParse(datas["totalScore"], out data.totalScore);
|
|
}
|
|
data.rightScore = 0;
|
|
if (datas.ContainsKey("rightScore"))
|
|
{
|
|
float.TryParse(datas["rightScore"], out data.rightScore);
|
|
}
|
|
data.wrongScore = 0;
|
|
if (datas.ContainsKey("wrongScore"))
|
|
{
|
|
float.TryParse(datas["wrongScore"], out data.wrongScore);
|
|
}
|
|
data.scoreName = datas.ContainsKey("scoreName") ? datas["scoreName"] : "";
|
|
data.rightLabel = datas.ContainsKey("rightLabel") ? datas["rightLabel"] : "";
|
|
data.wrongLabel = datas.ContainsKey("wrongLabel") ? datas["wrongLabel"] : "";
|
|
data.finishedEvent = datas.ContainsKey("finishedEvent") ? datas["finishedEvent"] : "";
|
|
data.rightBg = datas.ContainsKey("rightBg") ? datas["rightBg"] : "";
|
|
|
|
foreach (var item in items)
|
|
{
|
|
data.items.Add(new UIImageSelectMapData.OptionItem()
|
|
{
|
|
pic = item.pic,
|
|
pos = Utility.GetVector2FromStrArray(item.pos),
|
|
size = Utility.GetVector2FromStrArray(item.size)
|
|
});
|
|
}
|
|
|
|
UIKit.OpenPanelAsync<UIImageSelectMap>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() =>
|
|
{
|
|
|
|
this.Finish();
|
|
OnFinished?.Invoke();
|
|
});
|
|
|
|
}
|
|
|
|
public void OnExecute(float dt)
|
|
{
|
|
}
|
|
|
|
public void OnFinish()
|
|
{
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Status = ActionStatus.NotStart;
|
|
Paused = false;
|
|
}
|
|
|
|
public bool Paused { get; set; }
|
|
|
|
public void Deinit()
|
|
{
|
|
if (!Deinited)
|
|
{
|
|
OnFinished = null;
|
|
Deinited = true;
|
|
mPool.Recycle(this);
|
|
}
|
|
}
|
|
|
|
public bool Deinited { get; set; }
|
|
}
|
|
|
|
|
|
} |