新增弹窗获取得分

This commit is contained in:
shenjianxing 2025-03-25 10:46:22 +08:00
parent e748045436
commit a1f29f328b
3 changed files with 25 additions and 3 deletions

View File

@ -2,7 +2,9 @@ using QFramework;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;
using XMLTool;
public class ScoreController : MonoSingleton<ScoreController>
@ -59,7 +61,7 @@ public class ScoreController : MonoSingleton<ScoreController>
}
public Dictionary<string, ScoreStep> GetCurScore()
public Dictionary<string, ScoreStep> GetCurScoreData()
{
var data = moduleDict[Global.Instance.curModule.ModuleName];
return data.scoreDict;
@ -100,6 +102,20 @@ public class ScoreController : MonoSingleton<ScoreController>
}
}
/// <summary>
/// 获取当前所得总分
/// </summary>
public float GetCurScore()
{
float score = 0;
var data = moduleDict[Global.Instance.curModule.ModuleName];
foreach (var item in data.scoreDict)
{
score += item.Value.value;
}
return score;
}
private void OnQuit(OnModuleQuit quit)

View File

@ -39,6 +39,10 @@ namespace QFramework.Example
{
mData = uiData as UITipWindowData ?? new UITipWindowData();
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(gameObject);
if (mData.txt.Contains("{Score}"))
{
mData.txt = mData.txt.Replace("{Score}", ScoreController.Instance.GetCurScore().ToString());
}
Label.text = mData.txt;
BtnContent.RemoveAllChildren();
if (mData != null)

View File

@ -222,8 +222,10 @@
<!--支持deviceName isWait是只Action是否等待结束 frame 从哪一帧开始播放 endFrame 从哪一帧结束-->
<Action type="TimeLine" value="Models/CZ_FengXian_Timeline" isShow="true" finishedEvent="播放完毕" isWait="true" frame="140" endFrame="240"></Action>
<!--弹窗 btns可支持多个按钮-->
<Action type="TipWindow" value="恭喜你完成当前模块" btns="确定,取消" audio=""></Action>
<!--弹窗 btns可支持多个按钮
如果value中包含{Score} 则{Score}会替换成当前模块实际得分来显示-->
<Action type="TipWindow" value="恭喜你完成当前模块 得分:{Score}" btns="确定,取消" audio=""></Action>
<!--动态更换材质球和主贴图 材质球优先级高于贴图 同时写的情况下 先换材质球再换贴图-->
<Action type="Mat" value="Models/zhudao/nan_shoushufu.012" matName="yiyongshoutao_yellow1" index="1" mainTexture="贴图名字"></Action>