Merge remote-tracking branch 'origin/master' into LouDi_Pig
This commit is contained in:
commit
4adefdd889
@ -92,10 +92,10 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Padding:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 10
|
||||
m_Bottom: 10
|
||||
m_Left: 100
|
||||
m_Right: 100
|
||||
m_Top: 15
|
||||
m_Bottom: 15
|
||||
m_ChildAlignment: 4
|
||||
m_Spacing: 5
|
||||
m_ChildForceExpandWidth: 0
|
||||
@ -177,7 +177,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: -14.2, y: -11}
|
||||
m_AnchoredPosition: {x: -14.200012, y: -11}
|
||||
m_SizeDelta: {x: 20, y: 22}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &2796669925366751870
|
||||
|
||||
@ -194,8 +194,8 @@ public class ActionHelper
|
||||
}
|
||||
case "ResultTip":
|
||||
{
|
||||
var strAction = (XMLTool.StringListAction)act;
|
||||
return ResultTipAction.Allocate(act.Value, strAction.args[0], strAction.args[1]);
|
||||
var strAction = (XMLTool.DictionaryAction)act;
|
||||
return ResultTipAction.Allocate(act.Value, strAction.args);
|
||||
}
|
||||
case "Led":
|
||||
{
|
||||
@ -254,27 +254,30 @@ public class ActionHelper
|
||||
/// <returns></returns>
|
||||
public static ICondition GetCondition(XMLTool.ActionItem condition)
|
||||
{
|
||||
switch (condition.Type)
|
||||
if (condition!=null)
|
||||
{
|
||||
case "And":
|
||||
case "Or":
|
||||
var group = ConditionGroup.Allocate(condition.Type);
|
||||
foreach (var item in condition.SubActions)
|
||||
{
|
||||
group.AddCondition(GetCondition(item));
|
||||
}
|
||||
return group;
|
||||
case "UIClick":
|
||||
return UIClickCondition.Allocate(condition.Value);
|
||||
case "ObjClick":
|
||||
var dict = (XMLTool.DictionaryCondition)condition;
|
||||
return ObjClickCondition.Allocate(dict.Value, dict.args);
|
||||
case "Input":
|
||||
return InputCondition.Allocate(condition.Value);
|
||||
case "Var":
|
||||
return VarCondition.Allocate(condition.Name, condition.Value);
|
||||
case "StrEvent":
|
||||
return StrEventCondition.Allocate(condition.Value);
|
||||
switch (condition.Type)
|
||||
{
|
||||
case "And":
|
||||
case "Or":
|
||||
var group = ConditionGroup.Allocate(condition.Type);
|
||||
foreach (var item in condition.SubActions)
|
||||
{
|
||||
group.AddCondition(GetCondition(item));
|
||||
}
|
||||
return group;
|
||||
case "UIClick":
|
||||
return UIClickCondition.Allocate(condition.Value);
|
||||
case "ObjClick":
|
||||
var dict = (XMLTool.DictionaryCondition)condition;
|
||||
return ObjClickCondition.Allocate(dict.Value, dict.args);
|
||||
case "Input":
|
||||
return InputCondition.Allocate(condition.Value);
|
||||
case "Var":
|
||||
return VarCondition.Allocate(condition.Name, condition.Value);
|
||||
case "StrEvent":
|
||||
return StrEventCondition.Allocate(condition.Value);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
using DG.Tweening.Plugins.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using static OperationController;
|
||||
|
||||
namespace QFramework
|
||||
{
|
||||
@ -27,6 +30,8 @@ namespace QFramework
|
||||
string frame;
|
||||
string speed;
|
||||
string deviceName;
|
||||
|
||||
float totalTime;
|
||||
public static AnimationAction Allocate(string path, Dictionary<string, string> datas, System.Action OnFinished = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
@ -43,7 +48,7 @@ namespace QFramework
|
||||
}
|
||||
public ulong ActionID { get; set; }
|
||||
public ActionStatus Status { get; set; }
|
||||
|
||||
TweenerCore<float, float, FloatOptions> animDot;
|
||||
public void OnStart()
|
||||
{
|
||||
GameObject obj = null;
|
||||
@ -87,7 +92,8 @@ namespace QFramework
|
||||
{
|
||||
anim.Play(animName);
|
||||
anim[animName].normalizedTime = 1;
|
||||
DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed)).onComplete = () =>
|
||||
animDot = DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed));
|
||||
animDot.onComplete = () =>
|
||||
{
|
||||
anim.Stop();
|
||||
};
|
||||
@ -95,16 +101,13 @@ namespace QFramework
|
||||
else
|
||||
{
|
||||
anim[animName].speed = curSpeed;
|
||||
|
||||
anim.Play(animName);
|
||||
|
||||
if (anim[animName].wrapMode == WrapMode.Loop)
|
||||
{
|
||||
this.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
totalTime = Math.Abs(anim[animName].length / curSpeed);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
@ -120,9 +123,11 @@ namespace QFramework
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnExecute(float dt)
|
||||
{
|
||||
if (anim != null && anim.isPlaying == false)
|
||||
totalTime -= Time.deltaTime;
|
||||
if (anim != null && (anim.isPlaying == false || totalTime <= 0))
|
||||
{
|
||||
this.Finish();
|
||||
}
|
||||
@ -144,6 +149,8 @@ namespace QFramework
|
||||
{
|
||||
if (!Deinited)
|
||||
{
|
||||
animDot?.Kill();
|
||||
anim?.Stop();
|
||||
OnFinished = null;
|
||||
Deinited = true;
|
||||
mPool.Recycle(this);
|
||||
|
||||
@ -47,9 +47,14 @@ namespace QFramework
|
||||
}
|
||||
else
|
||||
{
|
||||
data.nearPos = Utility.GetVector3FromStrArray(datas["nearPos"]);
|
||||
data.nearRot = Utility.GetVector3FromStrArray(datas["nearRot"]);
|
||||
|
||||
if (datas.ContainsKey("nearPos"))
|
||||
{
|
||||
data.nearPos = Utility.GetVector3FromStrArray(datas["nearPos"]);
|
||||
}
|
||||
if (datas.ContainsKey("nearRot"))
|
||||
{
|
||||
data.nearRot = Utility.GetVector3FromStrArray(datas["nearRot"]);
|
||||
}
|
||||
}
|
||||
|
||||
if (datas.ContainsKey("normalDevice"))
|
||||
@ -60,8 +65,14 @@ namespace QFramework
|
||||
}
|
||||
else
|
||||
{
|
||||
data.normalPos = Utility.GetVector3FromStrArray(datas["normalPos"]);
|
||||
data.normalRot = Utility.GetVector3FromStrArray(datas["normalRot"]);
|
||||
if (datas.ContainsKey("normalPos"))
|
||||
{
|
||||
data.normalPos = Utility.GetVector3FromStrArray(datas["normalPos"]);
|
||||
}
|
||||
if (datas.ContainsKey("normalRot"))
|
||||
{
|
||||
data.normalRot = Utility.GetVector3FromStrArray(datas["normalRot"]);
|
||||
}
|
||||
}
|
||||
if (datas.ContainsKey("isOn"))
|
||||
{
|
||||
|
||||
@ -24,6 +24,7 @@ namespace QFramework
|
||||
string deviceName;
|
||||
string matName;
|
||||
string index;
|
||||
string mainTexture;
|
||||
public static MatAction Allocate(Dictionary<string, string> datas, System.Action OnFinished = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
@ -34,6 +35,7 @@ namespace QFramework
|
||||
retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : "";
|
||||
retNode.matName = datas.ContainsKey("matName") ? datas["matName"] : "";
|
||||
retNode.index = datas.ContainsKey("index") ? datas["index"] : "0";
|
||||
retNode.mainTexture = datas.ContainsKey("mainTexture") ? datas["mainTexture"] : null;
|
||||
retNode.OnFinished = OnFinished;
|
||||
return retNode;
|
||||
}
|
||||
@ -56,7 +58,22 @@ namespace QFramework
|
||||
var mesh = obj.GetComponent<Renderer>();
|
||||
int matIndex = 0;
|
||||
int.TryParse(index, out matIndex);
|
||||
mesh.materials[matIndex] = Resources.Load<Material>("Mat/" + matName);
|
||||
if (string.IsNullOrEmpty(matName) == false)
|
||||
{
|
||||
mesh.materials[matIndex] = Resources.Load<Material>("Mat/" + matName);
|
||||
}
|
||||
if (mainTexture != null)
|
||||
{
|
||||
if (mainTexture == "")
|
||||
{
|
||||
mesh.materials[matIndex].mainTexture = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.materials[matIndex].mainTexture = Resources.Load<Texture>("Mat/" + mainTexture);
|
||||
}
|
||||
}
|
||||
|
||||
this.Finish();
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using QFramework.Example;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QFramework
|
||||
@ -19,15 +20,17 @@ namespace QFramework
|
||||
public string txt;
|
||||
public string isRight;
|
||||
public string finishedEvent;
|
||||
public static ResultTipAction Allocate(string txt, string isRight, string finishedEvent, System.Action OnFinished = null)
|
||||
string autoHide;
|
||||
public static ResultTipAction Allocate(string txt, Dictionary<string, string> datas, System.Action OnFinished = null)
|
||||
{
|
||||
var retNode = mPool.Allocate();
|
||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||
retNode.Deinited = false;
|
||||
retNode.Reset();
|
||||
retNode.txt = txt;
|
||||
retNode.isRight = isRight;
|
||||
retNode.finishedEvent = finishedEvent;
|
||||
retNode.isRight = datas.ContainsKey("isRight") ? datas["isRight"] : "";
|
||||
retNode.finishedEvent = datas.ContainsKey("finishedEvent") ? datas["finishedEvent"] : "";
|
||||
retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : "-1";
|
||||
retNode.OnFinished = OnFinished;
|
||||
return retNode;
|
||||
}
|
||||
@ -45,6 +48,7 @@ namespace QFramework
|
||||
{
|
||||
data.callback = () => StringEventSystem.Global.Send(finishedEvent);
|
||||
}
|
||||
float.TryParse(autoHide, out data.autoHideTime);
|
||||
UIKit.OpenPanelAsync<UIResultTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ public class ShowAction : IAction
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
Debug.LogError("没有找到物体 :" + path);
|
||||
Debug.LogError($"没有找到物体 path:{path} deviceName:{deviceName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -23,6 +23,7 @@ public class UIToolsAction : IAction
|
||||
string wrongEvent;
|
||||
string rightScore;
|
||||
string wrongScore;
|
||||
string totalScore;
|
||||
string scoreStepName;
|
||||
string autoHide;
|
||||
public static UIToolsAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
|
||||
@ -40,6 +41,7 @@ public class UIToolsAction : IAction
|
||||
retNode.wrongEvent = datas.ContainsKey("wrongEvent") ? datas["wrongEvent"] : "";
|
||||
retNode.rightScore = datas.ContainsKey("rightScore") ? datas["rightScore"] : "";
|
||||
retNode.wrongScore = datas.ContainsKey("wrongScore") ? datas["wrongScore"] : "";
|
||||
retNode.totalScore = datas.ContainsKey("totalScore") ? datas["totalScore"] : "";
|
||||
retNode.scoreStepName = datas.ContainsKey("scoreStepName") ? datas["scoreStepName"] : "";
|
||||
retNode.autoHide = datas.ContainsKey("autoHide") ? datas["autoHide"] : "";
|
||||
return retNode;
|
||||
@ -75,6 +77,7 @@ public class UIToolsAction : IAction
|
||||
data.wrongEvent = wrongEvent;
|
||||
float.TryParse(rightScore, out data.rightScore);
|
||||
float.TryParse(wrongScore, out data.wrongScore);
|
||||
float.TryParse(totalScore, out data.totalScore);
|
||||
data.scoreStepName = scoreStepName;
|
||||
bool.TryParse(setActive, out data.SetActive);
|
||||
if (float.TryParse(autoHide, out data.autoHideResult) == false)
|
||||
|
||||
@ -7,24 +7,65 @@ using XMLTool;
|
||||
|
||||
public class ScoreController : MonoSingleton<ScoreController>
|
||||
{
|
||||
public Dictionary<string, ScoreStep> scoreDict;
|
||||
public class Data
|
||||
{
|
||||
public Dictionary<string, ScoreStep> scoreDict;
|
||||
}
|
||||
|
||||
public Dictionary<string, Data> moduleDict;
|
||||
public override void OnSingletonInit()
|
||||
{
|
||||
base.OnSingletonInit();
|
||||
scoreDict = new Dictionary<string, ScoreStep>();
|
||||
TypeEventSystem.Global.Register<OnModuleStart>(OnStart).UnRegisterWhenGameObjectDestroyed(gameObject);
|
||||
TypeEventSystem.Global.Register<OnModuleQuit>(OnQuit).UnRegisterWhenGameObjectDestroyed(gameObject);
|
||||
InitData();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (Global.Instance.curModule.type == "Exam" || Global.Instance.curModule.type == "All")
|
||||
{
|
||||
TypeEventSystem.Global.Register<OnModuleStart>(OnStart);
|
||||
TypeEventSystem.Global.Register<OnModuleQuit>(OnQuit);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitData()
|
||||
{
|
||||
moduleDict = new Dictionary<string, Data>();
|
||||
foreach (var item in Global.Instance.appData.Modules)
|
||||
{
|
||||
if (item.type == "Exam" || item.type == "All")
|
||||
{
|
||||
Data data = new Data() { scoreDict = new Dictionary<string, ScoreStep>() };
|
||||
moduleDict.Add(item.ModuleName, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnStart(OnModuleStart start)
|
||||
{
|
||||
var data = moduleDict[Global.Instance.curModule.ModuleName];
|
||||
data.scoreDict.Clear();
|
||||
foreach (var item in Global.Instance.curModule.score.scores)
|
||||
{
|
||||
item.value = 0;
|
||||
scoreDict.Add(item.step + item.name, item);
|
||||
data.scoreDict.Add(item.step + item.name, item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<string, ScoreStep> GetCurScore()
|
||||
{
|
||||
var data = moduleDict[Global.Instance.curModule.ModuleName];
|
||||
return data.scoreDict;
|
||||
}
|
||||
|
||||
|
||||
public void Add(string key, float value)
|
||||
{
|
||||
var data = moduleDict[Global.Instance.curModule.ModuleName];
|
||||
var scoreDict = data.scoreDict;
|
||||
if (scoreDict.ContainsKey(key))
|
||||
{
|
||||
scoreDict[key].value += value;
|
||||
@ -43,6 +84,8 @@ public class ScoreController : MonoSingleton<ScoreController>
|
||||
|
||||
public void Set(string key, float value)
|
||||
{
|
||||
var data = moduleDict[Global.Instance.curModule.ModuleName];
|
||||
var scoreDict = data.scoreDict;
|
||||
if (scoreDict.ContainsKey(key))
|
||||
{
|
||||
scoreDict[key].value = value;
|
||||
@ -53,7 +96,11 @@ public class ScoreController : MonoSingleton<ScoreController>
|
||||
|
||||
private void OnQuit(OnModuleQuit quit)
|
||||
{
|
||||
var data = moduleDict[Global.Instance.curModule.ModuleName];
|
||||
var scoreDict = data.scoreDict;
|
||||
scoreDict.Clear();
|
||||
TypeEventSystem.Global.UnRegister<OnModuleStart>(OnStart);
|
||||
TypeEventSystem.Global.UnRegister<OnModuleQuit>(OnQuit);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -48,31 +48,22 @@ public class StateMachineController : MonoSingleton<StateMachineController>
|
||||
{
|
||||
firstState = state.Key;
|
||||
}
|
||||
IAction enterAct = null;
|
||||
IAction exitAct = null;
|
||||
|
||||
|
||||
fsm.State(state.Key).OnEnter(() =>
|
||||
var vfState = new VfState();
|
||||
vfState.OnEnter(() =>
|
||||
{
|
||||
if (state.Value.Enter != null)
|
||||
{
|
||||
enterAct = ActionHelper.GetActionAndSub(state.Value.Enter.Action);
|
||||
enterAct?.Start(this);
|
||||
}
|
||||
|
||||
vfState.enterAct = ActionHelper.GetActionAndSub(state.Value.Enter?.Action);
|
||||
vfState.enterAct?.Start(this);
|
||||
}).OnExit(() =>
|
||||
{
|
||||
if (enterAct != null)
|
||||
if (vfState.enterAct != null)
|
||||
{
|
||||
enterAct.Deinit();
|
||||
vfState.enterAct.Deinit();
|
||||
}
|
||||
if (state.Value.Exit != null)
|
||||
{
|
||||
exitAct = ActionHelper.GetActionAndSub(state.Value.Exit.Action);
|
||||
exitAct?.Start(this);
|
||||
vfState.exitAct = ActionHelper.GetActionAndSub(state.Value.Exit?.Action);
|
||||
vfState.exitAct?.Start(this);
|
||||
|
||||
}
|
||||
});
|
||||
fsm.AddState(state.Key, vfState);
|
||||
}
|
||||
foreach (var transision in item.Value.Transisions)
|
||||
{
|
||||
@ -84,7 +75,7 @@ public class StateMachineController : MonoSingleton<StateMachineController>
|
||||
}
|
||||
fsmInfo.fsm = fsm;
|
||||
fsmInfo.fsm.StartState(firstState);
|
||||
if (FSMDitc.ContainsKey(item.Key)==false)
|
||||
if (FSMDitc.ContainsKey(item.Key) == false)
|
||||
{
|
||||
FSMDitc.Add(item.Key, fsmInfo);
|
||||
}
|
||||
@ -106,14 +97,18 @@ public class StateMachineController : MonoSingleton<StateMachineController>
|
||||
{
|
||||
foreach (var item in FSMDitc)
|
||||
{
|
||||
var curState = item.Value.fsm.CurrentStateId;
|
||||
foreach (var trans in item.Value.transisions)
|
||||
VfState state = item.Value.fsm.CurrentState as VfState;
|
||||
if (state.enterAct == null || state.enterAct.Status == ActionStatus.Finished)
|
||||
{
|
||||
if (trans.from == "any" || trans.from == item.Value.fsm.CurrentStateId)
|
||||
foreach (var trans in item.Value.transisions)
|
||||
{
|
||||
if (trans.condition.Check())
|
||||
if ((trans.from == "any" && trans.to != item.Value.fsm.CurrentStateId) || trans.from == item.Value.fsm.CurrentStateId)
|
||||
{
|
||||
item.Value.fsm.ChangeState(trans.to);
|
||||
if (trans.condition == null || trans.condition.Check())
|
||||
{
|
||||
item.Value.fsm.ChangeState(trans.to);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d7f9813c337725468c8739dba68c439
|
||||
guid: 8b474fbd8dd5f4c49b70b10f5328d67e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
8
Assets/Scripts/FSM/CustomState.meta
Normal file
8
Assets/Scripts/FSM/CustomState.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5feaaac014488434681db44e2face542
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/FSM/CustomState/VfState.cs
Normal file
14
Assets/Scripts/FSM/CustomState/VfState.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using QFramework;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VfState : CustomState
|
||||
{
|
||||
|
||||
|
||||
public IAction enterAct = null;
|
||||
public IAction exitAct = null;
|
||||
|
||||
|
||||
}
|
||||
11
Assets/Scripts/FSM/CustomState/VfState.cs.meta
Normal file
11
Assets/Scripts/FSM/CustomState/VfState.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a5f77690765e1f44b3f3ac7783076fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using static OperationController;
|
||||
|
||||
public class DeviceItem : MonoBehaviour
|
||||
{
|
||||
@ -19,6 +20,7 @@ public class DeviceItem : MonoBehaviour
|
||||
gameObject.GetOrAddComponent<HighlightTrigger>();
|
||||
effect.outlineColor = Color.green;
|
||||
StringEventSystem.Global.Register<string[]>(Global.HighLightTrigger, OnHighLightTriggerEvent);
|
||||
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
|
||||
}
|
||||
if (device.MeshCollider)
|
||||
{
|
||||
@ -40,11 +42,21 @@ public class DeviceItem : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStepChanged(StepStatusOnChange change)
|
||||
{
|
||||
var effect = gameObject.GetComponent<HighlightEffect>();
|
||||
if (effect != null)
|
||||
{
|
||||
effect.highlighted = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
device = null;
|
||||
tipItem = null;
|
||||
StringEventSystem.Global.UnRegister<string[]>(Global.HighLightTrigger, OnHighLightTriggerEvent);
|
||||
TypeEventSystem.Global.UnRegister<StepStatusOnChange>(OnStepChanged);
|
||||
}
|
||||
|
||||
private void OnHighLightTriggerEvent(string[] obj)
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using XMLTool;
|
||||
using static OperationController;
|
||||
|
||||
public class Point3DItem : MonoBehaviour
|
||||
{
|
||||
@ -35,12 +36,20 @@ public class Point3DItem : MonoBehaviour
|
||||
|
||||
}
|
||||
rotSpeed = data.rotateSpeed;
|
||||
gameObject.GetComponent<SpriteRenderer>().sortingOrder = data.order;
|
||||
TypeEventSystem.Global.Register<OnPoint3DQuestionDestroy>(OnObjDestroy).UnRegisterWhenGameObjectDestroyed(gameObject);
|
||||
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged);
|
||||
|
||||
}
|
||||
|
||||
private void OnStepChanged(StepStatusOnChange change)
|
||||
{
|
||||
OnObjDestroy(default);
|
||||
}
|
||||
|
||||
private void OnObjDestroy(OnPoint3DQuestionDestroy destroy)
|
||||
{
|
||||
TypeEventSystem.Global.UnRegister<StepStatusOnChange>(OnStepChanged);
|
||||
GameObject.Destroy(gameObject);
|
||||
}
|
||||
|
||||
|
||||
@ -59,13 +59,18 @@ namespace QFramework.Example
|
||||
protected override void OnOpen(IUIData uiData = null)
|
||||
{
|
||||
mData = uiData as UICameraSwitchData ?? new UICameraSwitchData();
|
||||
|
||||
Near.gameObject.SetActive(mData.nearPos != default);
|
||||
Far.gameObject.SetActive(mData.normalPos != default);
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(mData.isOn))
|
||||
{
|
||||
if (Near.isOn)
|
||||
if (Near.isOn && Near.gameObject.activeSelf)
|
||||
{
|
||||
SetNear();
|
||||
}
|
||||
if (Far.isOn)
|
||||
if (Far.isOn && Far.gameObject.activeSelf)
|
||||
{
|
||||
SetNormal();
|
||||
}
|
||||
@ -75,13 +80,29 @@ namespace QFramework.Example
|
||||
switch (mData.isOn)
|
||||
{
|
||||
case "near":
|
||||
SetNear();
|
||||
if (Near.isOn == false)
|
||||
{
|
||||
Near.isOn = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNear();
|
||||
}
|
||||
break;
|
||||
case "normal":
|
||||
SetNormal();
|
||||
if (Far.isOn == false)
|
||||
{
|
||||
Far.isOn = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNormal();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
@ -84,7 +84,7 @@ namespace QFramework.Example
|
||||
var machin = StateMachineController.Instance;
|
||||
var op = OperationController.Instance;
|
||||
var dev = DeviceController.Instance;
|
||||
var score = ScoreController.Instance;
|
||||
ScoreController.Instance.Init();
|
||||
UIKit.OpenPanelAsync<UIRightTop>().ToAction().StartGlobal(() =>
|
||||
{
|
||||
|
||||
|
||||
@ -49,20 +49,26 @@ namespace QFramework.Example
|
||||
{
|
||||
|
||||
Content.RemoveAllChildren();
|
||||
|
||||
float sum = 0;
|
||||
float score = 0;
|
||||
foreach (var item in ScoreController.Instance.scoreDict)
|
||||
foreach (var moduleDict in ScoreController.Instance.moduleDict)
|
||||
{
|
||||
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;
|
||||
foreach (var item in moduleDict.Value.scoreDict)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
this.Score.text = score.ToString();
|
||||
this.Sum.text = sum.ToString();
|
||||
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
|
||||
@ -20,6 +20,7 @@ namespace QFramework.Example
|
||||
public string wrongEvent;
|
||||
public float rightScore;
|
||||
public float wrongScore;
|
||||
public float totalScore;
|
||||
public string scoreStepName;
|
||||
public float autoHideResult = -1;
|
||||
}
|
||||
@ -42,6 +43,10 @@ namespace QFramework.Example
|
||||
protected override void OnOpen(IUIData uiData = null)
|
||||
{
|
||||
TypeEventSystem.Global.Register<StepStatusOnChange>(OnStepChanged).UnRegisterWhenDisabled(gameObject);
|
||||
if (mData.totalScore > 0)
|
||||
{
|
||||
ScoreController.Instance.Add(mData.scoreStepName, mData.totalScore);
|
||||
}
|
||||
mResLoader = ResLoader.Allocate();
|
||||
mData = uiData as UIToolsData ?? new UIToolsData();
|
||||
if (string.IsNullOrEmpty(mData.answer) == false)
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
using static UnityEngine.Rendering.DebugUI;
|
||||
namespace XMLTool
|
||||
{
|
||||
public class AppData
|
||||
@ -46,6 +47,9 @@ namespace XMLTool
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public class Score
|
||||
{
|
||||
public List<ScoreStep> scores;
|
||||
@ -85,6 +89,7 @@ namespace XMLTool
|
||||
public Vector3 rotate;
|
||||
public Vector3 scale;
|
||||
public float rotateSpeed;
|
||||
public int order = 1;
|
||||
public string clickEvent;
|
||||
}
|
||||
public List<Data> datas = new List<Data>();
|
||||
@ -440,6 +445,11 @@ namespace XMLTool
|
||||
{
|
||||
act.args.Add("wrongScore", wrongScore.Value);
|
||||
}
|
||||
var totalScore = action.Attribute("totalScore");
|
||||
if (totalScore != null)
|
||||
{
|
||||
act.args.Add("totalScore", totalScore.Value);
|
||||
}
|
||||
var scoreStepName = action.Attribute("scoreStepName");
|
||||
if (scoreStepName != null)
|
||||
{
|
||||
@ -779,7 +789,7 @@ namespace XMLTool
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case "LoadRes":
|
||||
{
|
||||
@ -884,24 +894,21 @@ namespace XMLTool
|
||||
break;
|
||||
case "ResultTip":
|
||||
{
|
||||
var act = new StringListAction();
|
||||
var act = new DictionaryAction();
|
||||
XAttribute isRight = action.Attribute("isRight");
|
||||
if (isRight != null)
|
||||
{
|
||||
act.args.Add(isRight.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
act.args.Add("false");
|
||||
act.args.Add("isRight", isRight.Value);
|
||||
}
|
||||
XAttribute finishedEvent = action.Attribute("finishedEvent");
|
||||
if (finishedEvent != null)
|
||||
{
|
||||
act.args.Add(finishedEvent.Value);
|
||||
act.args.Add("finishedEvent", finishedEvent.Value);
|
||||
}
|
||||
else
|
||||
XAttribute autoHide = action.Attribute("autoHide");
|
||||
if (autoHide != null)
|
||||
{
|
||||
act.args.Add("");
|
||||
act.args.Add("autoHide", autoHide.Value);
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
@ -1088,6 +1095,12 @@ namespace XMLTool
|
||||
data.scale = Utility.GetVector3FromStrArray(item.Attribute("scale")?.Value);
|
||||
}
|
||||
float.TryParse(item.Attribute("rotateSpeed")?.Value, out data.rotateSpeed);
|
||||
var order = item.Attribute("order");
|
||||
if (order != null)
|
||||
{
|
||||
int.TryParse(order.Value, out data.order);
|
||||
}
|
||||
|
||||
data.clickEvent = item.Attribute("clickEvent")?.Value;
|
||||
act.datas.Add(data);
|
||||
}
|
||||
@ -1117,6 +1130,11 @@ namespace XMLTool
|
||||
{
|
||||
act.args.Add("index", index.Value);
|
||||
}
|
||||
XAttribute mainTexture = action.Attribute("mainTexture");
|
||||
if (mainTexture != null)
|
||||
{
|
||||
act.args.Add("mainTexture", mainTexture.Value);
|
||||
}
|
||||
newAction = act;
|
||||
}
|
||||
break;
|
||||
@ -1136,6 +1154,10 @@ namespace XMLTool
|
||||
|
||||
public static Condition ParseCondition(XElement action)
|
||||
{
|
||||
if (action == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Condition newAction = null;
|
||||
string type = action.Attribute("type")?.Value;
|
||||
switch (type)
|
||||
|
||||
@ -23,7 +23,8 @@
|
||||
<Action type="Btns" value="按钮1,按钮2,按钮3"></Action>
|
||||
<!--用于右侧道具栏选择正确的道具 event用于配合StrEventCondition 做检测
|
||||
rightScore 正确选择一个 得分 wrongScore 错误一个 得分 scoreStepName是评分的key
|
||||
autoHide =-1 则点击结束 否则 等待对应时间后自动结束-->
|
||||
autoHide =-1 则点击结束 否则 等待对应时间后自动结束
|
||||
totalScore 是配合wrongScore的用于初始化一个分数 然后选择扣分-->
|
||||
<Action type="UITools" devices="道具名字1" answers="正确道具"
|
||||
setActive="true"
|
||||
rightLabel="提示:器械选择正确。"
|
||||
@ -32,6 +33,7 @@
|
||||
wrongEvent=""
|
||||
rightScore=""
|
||||
wrongScore=""
|
||||
totalScore=""
|
||||
scoreStepName="手术准备器械选择"
|
||||
autoHide="-1"></Action>
|
||||
|
||||
@ -72,6 +74,7 @@
|
||||
<Action type="SetScore" name="步骤名字" value="1"></Action>
|
||||
<!--镜头切换 近距离和默认 如果有了nearDevice就可以不用nearPos和nearRot了 按照device的坐标和旋转来处理镜头 normalDevice同理
|
||||
只设置坐标 不执行镜头切换 是否执行要根据UI的按钮操作来
|
||||
如果不配置 nearPos或者normalPos 则自动隐藏对应的视角UI按钮
|
||||
-->
|
||||
<Action type="CameraSwitch" nearDevice="肠钳" normalDevice="组织钳" nearPos="-3.942,3.24,-4.319" nearRot="16.42331,180,0" nearTime="1" normalPos="-3.942,3.24,-3.946" normalRot="16.42331,180,-5.305351E-14" normalTime="1"></Action>
|
||||
<!--文字弹窗 按钮可以多个 点击事件使用UIClick-->
|
||||
@ -113,7 +116,7 @@
|
||||
<!--相机锁定 是否可以移动 isMove 是否可以旋转镜头 isRotate-->
|
||||
<Action type="CameraLock" isMove="false" isRotate="false"></Action>
|
||||
<!--正确和错误的弹窗 isRight 是否正确-->
|
||||
<Action type="ResultTip" value="这里是一个弹窗" isRight="true" finishedEvent="关闭弹窗事件"></Action>
|
||||
<Action type="ResultTip" value="这里是一个弹窗" isRight="true" finishedEvent="关闭弹窗事件" autoHide="1"></Action>
|
||||
|
||||
<!--Led数字显示 要求每个数字单独一个模型面片,所有数字面片放在一个物体的子级,第一个物体是最右侧的数字,只能放数字面片模型 不要放其他的东西
|
||||
number 是数值 支持 小数点和横线 例如 12.34 3-5 -->
|
||||
@ -159,7 +162,8 @@
|
||||
<!--弹窗 btns可支持多个按钮-->
|
||||
<Action type="TipWindow" value="恭喜你完成当前模块" btns="确定,取消" audio=""></Action>
|
||||
|
||||
|
||||
<!--动态更换材质球和主贴图 材质球优先级高于贴图 同时写的情况下 先换材质球再换贴图-->
|
||||
<Action type="Mat" value="Models/zhudao/nan_shoushufu.012" matName="yiyongshoutao_yellow1" index="1" mainTexture="贴图名字"></Action>
|
||||
|
||||
<!--预加载模块 要在app.xml的Data标签内-->
|
||||
<PreLoad>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user