新增成绩页面 是否仅显示当前模块 可选参数
This commit is contained in:
parent
739dd53e02
commit
1203cccf31
@ -277,6 +277,11 @@ public class ActionHelper
|
||||
var dictAction = (XMLTool.DictionaryAction)act;
|
||||
return QFramework.OperationChangeAction.Allocate(dictAction.args);
|
||||
}
|
||||
case "ShowScore":
|
||||
{
|
||||
var dictAction = (XMLTool.DictionaryAction)act;
|
||||
return QFramework.ShowScoreAction.Allocate(dictAction.args);
|
||||
}
|
||||
default:
|
||||
Debug.LogError($"没有找到此Action的类型{act.Type}");
|
||||
break;
|
||||
|
||||
82
Assets/Scripts/Actions/ShowScoreAction.cs
Normal file
82
Assets/Scripts/Actions/ShowScoreAction.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using QFramework.Example;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFramework
|
||||
{
|
||||
internal class ShowScoreAction : IAction
|
||||
{
|
||||
|
||||
public System.Action OnFinished { get; set; }
|
||||
|
||||
|
||||
private ShowScoreAction()
|
||||
{
|
||||
}
|
||||
|
||||
private static readonly SimpleObjectPool<ShowScoreAction> mPool =
|
||||
new SimpleObjectPool<ShowScoreAction>(() => new ShowScoreAction(), null, 10);
|
||||
|
||||
Dictionary<string, string> datas;
|
||||
public static ShowScoreAction Allocate(Dictionary<string, string> datas, System.Action OnFinished = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||
retNode.Deinited = false;
|
||||
retNode.Reset();
|
||||
retNode.datas = datas;
|
||||
retNode.OnFinished = OnFinished;
|
||||
return retNode;
|
||||
}
|
||||
|
||||
|
||||
public ulong ActionID { get; set; }
|
||||
public ActionStatus Status { get; set; }
|
||||
|
||||
public void OnStart()
|
||||
{
|
||||
UIScoreData data = new UIScoreData();
|
||||
if (datas.ContainsKey("onlyCurModule"))
|
||||
{
|
||||
if (bool.TryParse(datas["onlyCurModule"], out data.onlyCurModule) == false)
|
||||
{
|
||||
data.onlyCurModule = false;
|
||||
}
|
||||
}
|
||||
UIKit.OpenPanelAsync<UIScore>(canvasLevel: UILevel.PopUI, uiData: data).ToAction().StartGlobal(() => this.Finish());
|
||||
}
|
||||
|
||||
public void OnExecute(float dt)
|
||||
{
|
||||
//this.Finish();
|
||||
//OnFinished?.Invoke();
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
3
Assets/Scripts/Actions/ShowScoreAction.cs.meta
Normal file
3
Assets/Scripts/Actions/ShowScoreAction.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ba81906fe012d2468c5a69a833ed765
|
||||
timeCreated: 1647655796
|
||||
@ -6,6 +6,10 @@ namespace QFramework.Example
|
||||
{
|
||||
public class UIScoreData : UIPanelData
|
||||
{
|
||||
/// <summary>
|
||||
/// Ö»ÏÔʾµ±Ç°Ä£¿éµÄÆÀ·Ö
|
||||
/// </summary>
|
||||
public bool onlyCurModule = false;
|
||||
}
|
||||
public partial class UIScore : UIPanel
|
||||
{
|
||||
@ -63,11 +67,42 @@ namespace QFramework.Example
|
||||
|
||||
protected override void OnOpen(IUIData uiData = null)
|
||||
{
|
||||
mData = uiData as UIScoreData ?? new UIScoreData();
|
||||
|
||||
Content.RemoveAllChildren();
|
||||
|
||||
float sum = 0;
|
||||
float score = 0;
|
||||
|
||||
bool onlyCur = false;
|
||||
if (uiData == null)
|
||||
{
|
||||
if (bool.TryParse(Global.Instance.curModule.OnlyCurScore, out onlyCur) == false)
|
||||
{
|
||||
onlyCur = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onlyCur = mData.onlyCurModule;
|
||||
}
|
||||
|
||||
|
||||
if (onlyCur)
|
||||
{
|
||||
foreach (var item in ScoreController.Instance.GetCurScoreData())
|
||||
{
|
||||
GameObject obj = GameObject.Instantiate(ItemPrefab.gameObject, Content);
|
||||
obj.transform.Find("Step").GetComponent<TextMeshProUGUI>().text = item.Value.step;
|
||||
obj.transform.Find("Name").GetComponent<TextMeshProUGUI>().text = item.Value.name;
|
||||
obj.transform.Find("Sum").GetComponent<TextMeshProUGUI>().text = item.Value.sum;
|
||||
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
||||
sum += float.Parse(item.Value.sum);
|
||||
score += item.Value.value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var moduleDict in ScoreController.Instance.moduleDict)
|
||||
{
|
||||
foreach (var item in moduleDict.Value.scoreDict)
|
||||
@ -81,6 +116,8 @@ namespace QFramework.Example
|
||||
score += item.Value.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.Score.text = score.ToString();
|
||||
this.Sum.text = sum.ToString();
|
||||
|
||||
@ -26,6 +26,7 @@ namespace XMLTool
|
||||
public string ModuleName { get; set; }
|
||||
public string Descript { get; set; }
|
||||
|
||||
public string OnlyCurScore { get; set; }
|
||||
public string Icon { get; set; }
|
||||
|
||||
public List<Operation> Operations { get; set; }
|
||||
@ -269,6 +270,7 @@ namespace XMLTool
|
||||
module.type = moduleElement.Element("Type")?.Value;
|
||||
module.ModuleName = moduleElement.Element("Name")?.Value;
|
||||
module.Icon = moduleElement.Element("Icon")?.Value;
|
||||
module.OnlyCurScore = moduleElement.Element("OnlyCurScore")?.Value;
|
||||
module.Descript = moduleElement.Element("Descript")?.Value.Trim();
|
||||
module.Scene = moduleElement.Element("Scene")?.Value;
|
||||
|
||||
@ -1557,6 +1559,17 @@ namespace XMLTool
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
case "ShowScore":
|
||||
{
|
||||
var act = new DictionaryAction();
|
||||
XAttribute onlyCurModule = action.Attribute("onlyCurModule");
|
||||
if (onlyCurModule != null)
|
||||
{
|
||||
act.args.Add("onlyCurModule", onlyCurModule.Value);
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
newAction = new Action();
|
||||
break;
|
||||
|
||||
@ -18,6 +18,9 @@
|
||||
<!--执行下一步左侧步骤列表 默认开始的时候为-1步 要主动调用一次才到第1步-->
|
||||
<Action type="NextOperation"></Action>
|
||||
|
||||
<!--显示得分UI界面 onlyCurModule 是否仅显示当前模块成绩 默认为false-->
|
||||
<Action type="ShowScore" onlyCurModule="true"></Action>
|
||||
|
||||
<!--切换operation模块 使用此功能 operation的配置中必须有name属性
|
||||
name为operation配置中的name
|
||||
执行此行后 不需要在执行NextOperationAction 框架底层执行了
|
||||
@ -262,6 +265,8 @@
|
||||
<Scene>Scene</Scene>
|
||||
<!--Study学习模式 Exam实训模式 All都有-->
|
||||
<Type>Study</Type>
|
||||
<!--右上角显示成绩的时候 是否只显示当前模块的-->
|
||||
<OnlyCurScore>false</OnlyCurScore>
|
||||
<!--
|
||||
用于显示模块选择页面的 模块图标
|
||||
图片存放于Data/Image/路径下面 可以自己构建子路径
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user