Merge branch 'master' into LouDi_Quan

This commit is contained in:
shenjianxing 2025-03-27 10:10:20 +08:00
commit f77a2e4f52
21 changed files with 606 additions and 72 deletions

View File

@ -1,5 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &362378255116206407
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4007744310226606941}
- component: {fileID: 7455571532591409758}
- component: {fileID: 8685952999310058692}
m_Layer: 5
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &4007744310226606941
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 362378255116206407}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1041589483741693935}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -20, y: -20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7455571532591409758
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 362378255116206407}
m_CullTransparentMesh: 1
--- !u!114 &8685952999310058692
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 362378255116206407}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &369348797227731928
GameObject:
m_ObjectHideFlags: 0
@ -379,6 +454,7 @@ GameObject:
- component: {fileID: 5800286210300119797}
- component: {fileID: 7870331819941572208}
- component: {fileID: 5640205172889648423}
- component: {fileID: 2499191464483522175}
m_Layer: 5
m_Name: Label
m_TagString: Untagged
@ -402,9 +478,9 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -30, y: -30}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 14.999985}
m_SizeDelta: {x: -30, y: -219}
m_Pivot: {x: 0.5, y: 0.000000029802322}
--- !u!222 &7870331819941572208
CanvasRenderer:
m_ObjectHideFlags: 0
@ -467,8 +543,8 @@ MonoBehaviour:
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_HorizontalAlignment: 32
m_VerticalAlignment: 1024
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
@ -502,6 +578,20 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &2499191464483522175
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2191389905807484100}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!1 &2417640497830947151
GameObject:
m_ObjectHideFlags: 0
@ -1265,6 +1355,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 4007744310226606941}
- {fileID: 5800286210300119797}
m_Father: {fileID: 5394197843809455320}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -43,6 +43,11 @@ namespace QFramework
public ActionStatus Status { get; set; }
public void OnStart()
{
foreach (var item in mCondition)
{
item.OnStart();
}
}
public void OnExecute(float dt)

View File

@ -44,6 +44,7 @@ namespace QFramework
public void Send(string key)
{
if (mEvents.TryGetValue(key, out var e))
{
var easyEvent = e.As<EasyEvent>();
@ -67,6 +68,10 @@ namespace QFramework
}
}
public bool HasRegister(string key)
{
return mEvents.ContainsKey(key);
}
public void UnRegister<T>(string key, Action<T> onEvent)
{

View File

@ -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;

View 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; }
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0ba81906fe012d2468c5a69a833ed765
timeCreated: 1647655796

View File

@ -29,6 +29,7 @@ public class UIToolsAction : IAction
string random;
string scrollSpeed;
string position;
string wrongCount;
public static UIToolsAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
{
var retNode = mPool.Allocate();
@ -50,6 +51,7 @@ public class UIToolsAction : IAction
retNode.random = datas.ContainsKey("random") ? datas["random"] : "";
retNode.scrollSpeed = datas.ContainsKey("scrollSpeed") ? datas["scrollSpeed"] : "";
retNode.position = datas.ContainsKey("position") ? datas["position"] : "";
retNode.wrongCount = datas.ContainsKey("wrongCount") ? datas["wrongCount"] : "";
return retNode;
}
@ -100,6 +102,11 @@ public class UIToolsAction : IAction
data.autoHideResult = -1;
}
data.position = position;
if (int.TryParse(wrongCount, out data.wrongCount) == false)
{
data.wrongCount = 0;
}
UIKit.OpenPanelAsync<UITools>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
}

View File

@ -13,7 +13,7 @@ namespace QFramework
private StrEventCondition() { }
string key;
bool isFinished = false;
public static StrEventCondition Allocate(string key)
{
var conditionAction = mSimpleObjectPool.Allocate();
@ -21,11 +21,12 @@ namespace QFramework
conditionAction.Deinited = false;
conditionAction.Reset();
conditionAction.key = key;
conditionAction.isFinished = false;
return conditionAction;
}
public bool Check()
{
return false;
return isFinished;
}
public bool Paused { get; set; }
public bool Deinited { get; set; }
@ -39,6 +40,7 @@ namespace QFramework
private void OnEventFnished()
{
StringEventSystem.Global.UnRegister(key, OnEventFnished);
isFinished = true;
this.Finish();
}

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

@ -0,0 +1,145 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System.IO;
using System;
public class WindowsLowercaseRenamer : EditorWindow
{
[MenuItem("Assets/Windows安全重命名")]
private static void SafeRenameAll()
{
string dataPath = Global.dataPath;
// 新增:处理根目录名称
ProcessRootDirectory(dataPath);
// 处理子目录和文件
ProcessDirectoriesRecursive(dataPath);
ProcessFilesRecursive(dataPath);
AssetDatabase.Refresh();
Debug.Log("安全重命名完成!");
}
// 新增方法:处理根目录
private static void ProcessRootDirectory(string originalPath)
{
try
{
DirectoryInfo rootInfo = new DirectoryInfo(originalPath);
string targetRootName = rootInfo.Name.ToLowerInvariant();
// 如果根目录名称不符合规范
if (rootInfo.Name != targetRootName)
{
string parentPath = rootInfo.Parent.FullName;
string newRootPath = Path.Combine(parentPath, targetRootName);
// 特殊处理:根目录重命名需要额外权限
if (Directory.Exists(newRootPath))
{
string tempPath = Path.Combine(parentPath, Guid.NewGuid().ToString());
Directory.Move(originalPath, tempPath);
Directory.Move(tempPath, newRootPath);
}
else
{
Directory.Move(originalPath, newRootPath);
}
Debug.Log($"根目录重命名成功: {originalPath} → {newRootPath}");
// 更新全局路径(如果需要)
Global.dataPath = newRootPath; // 根据实际Global类的实现可能需要调整
}
}
catch (Exception ex)
{
Debug.LogError($"根目录重命名失败: {ex.Message}");
}
}
private static void ProcessDirectoriesRecursive(string path)
{
foreach (var dirPath in Directory.GetDirectories(path))
{
// 递归处理子目录
ProcessDirectoriesRecursive(dirPath);
DirectoryInfo dirInfo = new DirectoryInfo(dirPath);
string targetName = dirInfo.Name.ToLowerInvariant();
// 仅当实际目录名不符合规范时才重命名
if (dirInfo.Name != targetName)
{
string parentPath = dirInfo.Parent.FullName;
string newPath = Path.Combine(parentPath, targetName);
try
{
// 特殊处理Windows需要先重命名到临时名称
//if (Directory.Exists(newPath))
//{
// string tempPath = Path.Combine(parentPath, Guid.NewGuid().ToString());
// Directory.Move(dirPath, tempPath);
// Directory.Move(tempPath, newPath);
//}
//else
//{
Directory.Move(dirPath, newPath);
//}
Debug.Log($"目录重命名成功: {dirPath} → {newPath}");
}
catch (Exception ex)
{
Debug.LogError($"目录重命名失败: {dirPath}\n{ex.Message}");
}
}
}
}
private static void ProcessFilesRecursive(string path)
{
foreach (var filePath in Directory.GetFiles(path))
{
FileInfo fileInfo = new FileInfo(filePath);
string targetName = Path.GetFileNameWithoutExtension(fileInfo.Name).ToLowerInvariant();
string targetExt = fileInfo.Extension.ToLowerInvariant();
string newFileName = $"{targetName}{targetExt}";
// 比较实际文件名
if (fileInfo.Name != newFileName)
{
string newPath = Path.Combine(fileInfo.DirectoryName, newFileName);
try
{
// Windows特殊处理如果目标存在但大小写不同
if (File.Exists(newPath))
{
string tempPath = Path.Combine(fileInfo.DirectoryName, Guid.NewGuid().ToString() + fileInfo.Extension);
File.Move(filePath, tempPath);
File.Move(tempPath, newPath);
}
else
{
File.Move(filePath, newPath);
}
Debug.Log($"文件重命名成功: {filePath} → {newPath}");
}
catch (Exception ex)
{
Debug.LogError($"文件重命名失败: {filePath}\n{ex.Message}");
}
}
}
// 递归子目录
foreach (var dirPath in Directory.GetDirectories(path))
{
ProcessFilesRecursive(dirPath);
}
}
}
#endif

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3fc1a350612ff074eb9880438ed8d526
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,60 +7,72 @@ using UnityEngine;
public class VirtualFPostProcess : IPostprocessBuildWithReport
{
// 定义回调优先级(越低越先执行)
public int callbackOrder => 0;
// 在打包完成后执行
public void OnPostprocessBuild(BuildReport report)
{
// 获取项目根目录路径
string projectPath = Application.dataPath;
// 获取Data文件夹的路径
string dataFolderPath = Path.Combine(projectPath, "../Data");
string buildOutputPath = GetValidBuildPath(report);
// 获取打包后的输出目录
string buildOutputPath = report.summary.outputPath;
if (buildOutputPath.Contains(".exe"))
{
var paths = buildOutputPath.Split('/');
buildOutputPath = buildOutputPath.Replace(paths[paths.Length - 1], "");
}
// 检查Data文件夹是否存在
if (Directory.Exists(dataFolderPath))
{
// 将Data文件夹复制到打包后的目标目录
string targetDataPath = Path.Combine(buildOutputPath, "Data");
CopyDirectory(dataFolderPath, targetDataPath);
Debug.Log($"Data folder copied to build output directory: {targetDataPath}");
// 目标目录强制小写
string targetDataPath = Path.Combine(buildOutputPath, "data");
CopyDirectoryWithLowerCaseNames(dataFolderPath, targetDataPath);
Debug.Log($"数据目录已复制到: {targetDataPath}");
}
else
{
Debug.LogWarning("Data folder not found at: " + dataFolderPath);
Debug.LogWarning("未找到数据目录: " + dataFolderPath);
}
}
// 递归复制文件夹的辅助方法,覆盖已有文件和文件夹
private void CopyDirectory(string sourceDir, string destinationDir)
private string GetValidBuildPath(BuildReport report)
{
// 确保目标目录存在
if (!Directory.Exists(destinationDir))
string path = report.summary.outputPath;
if (path.Contains(".exe"))
{
Directory.CreateDirectory(destinationDir);
return Path.GetDirectoryName(path);
}
return path;
}
// 遍历源目录中的文件
foreach (string file in Directory.GetFiles(sourceDir))
private void CopyDirectoryWithLowerCaseNames(string sourceDir, string targetDir)
{
string destFile = Path.Combine(destinationDir, Path.GetFileName(file));
File.Copy(file, destFile, true); // 覆盖已有文件
// 创建小写目标目录
var lowerTargetDir = ConvertToLowerPath(targetDir);
Directory.CreateDirectory(lowerTargetDir);
// 复制文件(带小写转换)
foreach (var file in Directory.GetFiles(sourceDir))
{
string fileName = Path.GetFileName(file);
string lowerName = ConvertToLowerPath(fileName);
File.Copy(file, Path.Combine(lowerTargetDir, lowerName), true);
}
// 遍历源目录中的子文件夹
foreach (string subDir in Directory.GetDirectories(sourceDir))
// 递归处理子目录(带小写转换)
foreach (var dir in Directory.GetDirectories(sourceDir))
{
string destSubDir = Path.Combine(destinationDir, Path.GetFileName(subDir));
CopyDirectory(subDir, destSubDir); // 递归复制子文件夹
string dirName = Path.GetFileName(dir);
string lowerDirName = ConvertToLowerPath(dirName);
CopyDirectoryWithLowerCaseNames(dir, Path.Combine(lowerTargetDir, lowerDirName));
}
}
// 中英文混合路径转小写
private string ConvertToLowerPath(string input)
{
char[] chars = input.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
// 只处理ASCII字母字符中文等Unicode字符保持不变
if (chars[i] >= 'A' && chars[i] <= 'Z')
{
chars[i] = (char)(chars[i] | 0x20); // 快速转小写
}
}
return new string(chars);
}
}

View File

@ -27,6 +27,7 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null)
{
mData = uiData as UIBackPackData ?? new UIBackPackData();
Content.RemoveAllChildren();
foreach (var device in mData.devices)

View File

@ -3,6 +3,7 @@ using UnityEngine.UI;
using QFramework;
using System.Collections.Generic;
using TMPro;
using System.Linq;
namespace QFramework.Example
{
@ -123,7 +124,8 @@ namespace QFramework.Example
{
foreach (var item in mData.inputs)
{
if (VarController.Instance.Get(item.var).ToString() != item.answer)
var list = item.answer.Split('|').ToList();
if (list.Contains(VarController.Instance.Get(item.var).ToString())==false)
{
return false;
}

View File

@ -12,7 +12,7 @@ namespace QFramework.Example
}
public partial class UIModuleSelect : UIPanel
{
ResLoader loader;
protected override void OnInit(IUIData uiData = null)
{
mData = uiData as UIModuleSelectData ?? new UIModuleSelectData();
@ -29,6 +29,7 @@ namespace QFramework.Example
{
Application.Quit();
});
loader = ResLoader.Allocate();
}
protected override void OnOpen(IUIData uiData = null)
@ -57,6 +58,23 @@ namespace QFramework.Example
SceneManager.sceneLoaded += OnLoadFinished;
});
});
if (string.IsNullOrEmpty(item.Icon)==false)
{
var icon = obj.transform.Find("Icon").GetComponent<Image>();
var localImageUrl = Global.imagePath + item.Icon;
loader.Add2Load(localImageUrl.ToNetImageResName(),
(bool success, IRes res) =>
{
if (success)
{
icon.sprite = Utility.GetSprite(res.Asset as Texture2D);
}
});
icon.gameObject.SetActive(true);
}
lastIndex = index;
}
}
@ -71,6 +89,14 @@ namespace QFramework.Example
});
}
else
{
UIKit.OpenPanelAsync<UILoading>(canvasLevel: UILevel.PopUI).ToAction().StartGlobal();
loader.LoadAsync(() =>
{
TypeEventSystem.Global.Send<OnLoadingHide>(new OnLoadingHide());
});
}

View File

@ -17,7 +17,6 @@ namespace QFramework.Example
protected override void OnInit(IUIData uiData = null)
{
mData = uiData as UIOperationListData ?? new UIOperationListData();
TypeEventSystem.Global.Register<OnOperationChanged>((arg) => Refresh()).UnRegisterWhenGameObjectDestroyed(gameObject);
TypeEventSystem.Global.Register<OnModuleQuit>((arg) => Hide()).UnRegisterWhenGameObjectDestroyed(gameObject);
}
@ -80,8 +79,9 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null)
{
TypeEventSystem.Global.Register<OnOperationChanged>((arg) => Refresh());
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(this);
Refresh();
}
public void Refresh()
@ -149,9 +149,17 @@ namespace QFramework.Example
protected override void OnShow()
{
Refresh();
}
protected override void OnClose()
{
TypeEventSystem.Global.UnRegister<OnOperationChanged>((arg) => Refresh());
}
public override void Hide()
{
base.Hide();
TypeEventSystem.Global.UnRegister<OnOperationChanged>((arg) => Refresh());
}
}
}

View File

@ -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();

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

@ -26,11 +26,13 @@ namespace QFramework.Example
public bool random = false;
public float scrollSpeed = 25;
public string position;
public int wrongCount = 0;
}
public partial class UITools : UIPanel
{
ResLoader mResLoader;
public List<string> answers;
int curWrongCount = 0;
protected override void OnInit(IUIData uiData = null)
{
mData = uiData as UIToolsData ?? new UIToolsData();
@ -47,6 +49,7 @@ namespace QFramework.Example
protected override void OnOpen(IUIData uiData = null)
{
mData = uiData as UIToolsData ?? new UIToolsData();
curWrongCount = 0;
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(gameObject);
if (mData.totalScore > 0)
{
@ -90,6 +93,7 @@ namespace QFramework.Example
Button btn = obj.GetComponent<Button>();
btn.onClick.AddListener(() =>
{
if (answers != null)
{
if (answers.Contains(item.Name))
@ -102,6 +106,8 @@ namespace QFramework.Example
ScoreController.Instance.Add(mData.scoreStepName, mData.rightScore);
answers.Remove(item.Name);
if (answers.Count <= 0)
{
if (string.IsNullOrEmpty(mData.rightLable) == false)
{
var data = new UIResultTipData();
data.label = mData.rightLable;
@ -116,27 +122,56 @@ namespace QFramework.Example
data.autoHideTime = mData.autoHideResult;
UIKit.OpenPanelAsync<UIResultTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal();
}
else
{
if (string.IsNullOrEmpty(mData.rightEvent) == false)
{
if (curWrongCount >= mData.wrongCount)
{
StringEventSystem.Global.Send(mData.rightEvent);
}
}
}
}
}
else
{
ScoreController.Instance.Add(mData.scoreStepName, mData.wrongScore);
if (string.IsNullOrEmpty(mData.wrongLabel) == false)
{
var data = new UIResultTipData();
data.label = mData.wrongLabel;
data.isRight = false;
data.callback = () =>
{
if (string.IsNullOrEmpty(mData.wrongEvent) == false)
{
if (curWrongCount >= mData.wrongCount)
{
StringEventSystem.Global.Send(mData.wrongEvent);
}
}
SetSelected(obj, false);
};
data.autoHideTime = mData.autoHideResult;
UIKit.OpenPanelAsync<UIResultTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().Start(this);
}
else
{
if (string.IsNullOrEmpty(mData.wrongEvent) == false)
{
if (curWrongCount >= mData.wrongCount)
{
StringEventSystem.Global.Send(mData.wrongEvent);
}
}
SetSelected(obj, false);
}
}
}
this.curWrongCount++;
});
}
mResLoader.LoadAsync();

View File

@ -25,6 +25,10 @@ namespace XMLTool
public string Scene { get; set; }
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; }
public List<Device> Devices { get; set; }
@ -265,6 +269,8 @@ 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;
@ -586,6 +592,11 @@ namespace XMLTool
{
act.args.Add("position", position.Value);
}
var wrongCount = action.Attribute("wrongCount");
if (wrongCount != null)
{
act.args.Add("wrongCount", wrongCount.Value);
}
newAction = act;
}
break;
@ -1553,6 +1564,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;

View File

@ -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 框架底层执行了
@ -34,7 +37,8 @@
totalScore 是配合wrongScore的用于初始化一个分数 然后选择扣分
random 是否打乱devices的顺序
scrollSpeed 鼠标滚轮的滑动速度
position left/right 可以让道具栏在左侧或者右侧-->
position left/right 可以让道具栏在左侧或者右侧
errorCount 错误的次数 不为0的情况下 大于这个次数才会触发WrongScore-->
<Action type="UITools" devices="道具名字1" answers="正确道具"
setActive="true"
rightLabel="提示:器械选择正确。"
@ -48,7 +52,8 @@
autoHide="-1"
random="true"
scrollSpeed="25"
position="right"></Action>
position="right"
wrongCount="0"></Action>
<!--道具背包,用于配合状态机进行道具的使用 目前是初步版本仅支持配合UIClick点击暂无道具数量等功能 详细参数可参考UITools-->
<Action type="UIBackPack" devices="道具名字1"
@ -79,6 +84,7 @@
Input 为输入框(可多个) var里面存储是输入值
btn 为按钮(可多个)
checkAnswer 是否开启检查答案
answer 是正确答案 用|分割 可以支持多个正确答案
wrongLabel 输入错误的提示文字
wrongCount 错误后重新输入的次数
autoHide 错误弹窗自动消失的停留时间
@ -87,8 +93,8 @@
wrongScore错误的分数 (每错一次扣一次分)
-->
<Action type="Input" title="请输入" finishedEvent="UI关闭事件通知用StrEvent接收">
<Input name="数字1:" var="变量1" answer="100"></Input>
<Input name="数字2:" var="变量2" answer="200"></Input>
<Input name="数字1:" var="变量1" answer="100|200"></Input>
<Input name="数字2:" var="变量2" answer="200|400"></Input>
<Btn name="确定" clickEvent="确定点击" checkAnswer="true" wrongLabel="输入错误" wrongCount="3" autoHide="-1" scoreStepName="" rightScore="0" wrongScore="-1"></Btn>
<Btn name="取消"></Btn>
</Action>
@ -221,8 +227,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>
@ -259,6 +267,13 @@
<Scene>Scene</Scene>
<!--Study学习模式 Exam实训模式 All都有-->
<Type>Study</Type>
<!--右上角显示成绩的时候 是否只显示当前模块的-->
<OnlyCurScore>false</OnlyCurScore>
<!--
用于显示模块选择页面的 模块图标
图片存放于Data/Image/路径下面 可以自己构建子路径
-->
<Icon>图片名字</Icon>
<!--模块名字-->
<Name>模块1</Name>