From 0381bfecbacf436856b0d44cfb55144370e24aa5 Mon Sep 17 00:00:00 2001
From: shenjianxing <”315615051@qq.com“>
Date: Thu, 6 Feb 2025 13:11:06 +0800
Subject: [PATCH 01/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=8F=E8=BF=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Doc/Xml配置文档.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml
index c658c7f1..ddcb472a 100644
--- a/Doc/Xml配置文档.xml
+++ b/Doc/Xml配置文档.xml
@@ -106,7 +106,7 @@
-
+
From 53beb1ec4e94d2797a022b2f587627d9d1f1c066 Mon Sep 17 00:00:00 2001
From: shenjianxing <”315615051@qq.com“>
Date: Thu, 6 Feb 2025 14:50:19 +0800
Subject: [PATCH 02/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0finish?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Assets/Scripts/Actions/LedAction.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Assets/Scripts/Actions/LedAction.cs b/Assets/Scripts/Actions/LedAction.cs
index 2b4d020a..86e3a110 100644
--- a/Assets/Scripts/Actions/LedAction.cs
+++ b/Assets/Scripts/Actions/LedAction.cs
@@ -58,7 +58,6 @@ namespace QFramework
var mat = obj.GetComponent().material;
//"99.99"
char item = number[i];
- Debug.LogError(item);
if (item == '.')
{
isPoint = true;
@@ -90,6 +89,8 @@ namespace QFramework
mat.mainTexture = Resources.Load($"Number/Mask").As();
}
}
+
+ this.Finish();
}
public void OnExecute(float dt)
From c9529a1216a7c2b147fdb6e7b2851ae632a52920 Mon Sep 17 00:00:00 2001
From: shenjianxing <”315615051@qq.com“>
Date: Thu, 6 Feb 2025 15:17:08 +0800
Subject: [PATCH 03/11] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=95=BF=E6=8C=89?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Assets/Scripts/Actions/ActionHelper.cs | 11 +-
.../Conditions/ObjClickLongCondition.cs | 146 ++++++++++++++++++
.../Conditions/ObjClickLongCondition.cs.meta | 3 +
Assets/Scripts/Xml/XmlParser.cs | 36 +++--
Doc/Xml配置文档.xml | 7 +-
5 files changed, 190 insertions(+), 13 deletions(-)
create mode 100644 Assets/Scripts/Conditions/ObjClickLongCondition.cs
create mode 100644 Assets/Scripts/Conditions/ObjClickLongCondition.cs.meta
diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs
index b1ff7e73..ef39f9a8 100644
--- a/Assets/Scripts/Actions/ActionHelper.cs
+++ b/Assets/Scripts/Actions/ActionHelper.cs
@@ -269,8 +269,15 @@ public class ActionHelper
case "UIClick":
return UIClickCondition.Allocate(condition.Value);
case "ObjClick":
- var dict = (XMLTool.DictionaryCondition)condition;
- return ObjClickCondition.Allocate(dict.Value, dict.args);
+ {
+ var dict = (XMLTool.DictionaryCondition)condition;
+ return ObjClickCondition.Allocate(dict.Value, dict.args);
+ }
+ case "ObjClickLong":
+ {
+ var dict = (XMLTool.DictionaryCondition)condition;
+ return ObjClickLongCondition.Allocate(dict.Value, dict.args);
+ }
case "Input":
return InputCondition.Allocate(condition.Value);
case "Var":
diff --git a/Assets/Scripts/Conditions/ObjClickLongCondition.cs b/Assets/Scripts/Conditions/ObjClickLongCondition.cs
new file mode 100644
index 00000000..c8a490d9
--- /dev/null
+++ b/Assets/Scripts/Conditions/ObjClickLongCondition.cs
@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using UnityEngine;
+using UnityEngine.EventSystems;
+
+namespace QFramework
+{
+ public class ObjClickLongCondition : ICondition
+ {
+
+ private static SimpleObjectPool mSimpleObjectPool =
+ new SimpleObjectPool(() => new ObjClickLongCondition(), null, 10);
+
+ private ObjClickLongCondition() { }
+ public GameObject obj = null;
+ string path;
+ string deviceName;
+ float time;
+ float curTime;
+ bool isDown = false;
+ public static ObjClickLongCondition Allocate(string path, Dictionary datas)
+ {
+ var conditionAction = mSimpleObjectPool.Allocate();
+ conditionAction.ActionID = ActionKit.ID_GENERATOR++;
+ conditionAction.Deinited = false;
+ conditionAction.Reset();
+ conditionAction.path = path;
+ conditionAction.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : null;
+ if (datas.ContainsKey("time"))
+ {
+ float.TryParse(datas["time"], out conditionAction.time);
+ }
+ return conditionAction;
+ }
+ public bool Check()
+ {
+ if (obj == null)
+ {
+ if (string.IsNullOrEmpty(deviceName))
+ {
+ obj = Utility.FindObj(path);
+ }
+ else
+ {
+ obj = DeviceController.Instance.GetDeviceObj(deviceName);
+ if (obj == null)
+ {
+ Debug.LogError($"ûҵ path:{path} deviceName:{deviceName}");
+ }
+ }
+ }
+
+ //
+ if (Input.GetMouseButtonDown(0))
+ {
+ OnMouseDown();
+ }
+
+ // ɿ
+ if (Input.GetMouseButtonUp(0))
+ {
+ OnMouseUp();
+ }
+
+ if (isDown && EventSystem.current.IsPointerOverGameObject() == false)
+ {
+ Vector3 mousePos = Input.mousePosition;
+ Ray ray = Camera.main.ScreenPointToRay(mousePos);
+ RaycastHit hit;
+ if (Physics.Raycast(ray, out hit))
+ {
+ if (obj == hit.collider.gameObject)
+ {
+ curTime -= Time.deltaTime;
+ if (curTime <= 0)
+ {
+ return true;
+ }
+ }
+
+ }
+ }
+
+ return false;
+ }
+
+ public void OnMouseDown()
+ {
+ curTime = this.time;
+ isDown = true;
+ }
+
+ public void OnMouseUp()
+ {
+ isDown = false;
+ }
+
+
+ public bool Paused { get; set; }
+ public bool Deinited { get; set; }
+ public ulong ActionID { get; set; }
+ public ActionStatus Status { get; set; }
+ public void OnStart()
+ {
+ }
+
+ public void OnExecute(float dt)
+ {
+ if (Check())
+ {
+ this.Finish();
+ }
+ }
+
+ public void OnFinish()
+ {
+ }
+
+ public void Deinit()
+ {
+ if (!Deinited)
+ {
+ Deinited = true;
+ obj = null;
+ path = null;
+ mSimpleObjectPool.Recycle(this);
+ }
+ }
+
+ public void Reset()
+ {
+ curTime = 0;
+ Paused = false;
+ Status = ActionStatus.NotStart;
+ }
+ }
+
+ //public static class ObjClickLongConditionExtension
+ //{
+ // public static ISequence ObjClickLongCondition(this ISequence self, string uipath)
+ // {
+ // return self.Append(QFramework.ObjClickLongCondition.Allocate(uipath));
+ // }
+ //}
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Conditions/ObjClickLongCondition.cs.meta b/Assets/Scripts/Conditions/ObjClickLongCondition.cs.meta
new file mode 100644
index 00000000..91bfa937
--- /dev/null
+++ b/Assets/Scripts/Conditions/ObjClickLongCondition.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 297e67e3bc7868a4cae6623426c359b9
+timeCreated: 1647673104
\ No newline at end of file
diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs
index ab5080b1..ce2a5804 100644
--- a/Assets/Scripts/Xml/XmlParser.cs
+++ b/Assets/Scripts/Xml/XmlParser.cs
@@ -1163,19 +1163,37 @@ namespace XMLTool
switch (type)
{
case "ObjClick":
- var act = new DictionaryCondition();
+ {
+ var act = new DictionaryCondition();
- XAttribute deviceName = action.Attribute("deviceName");
- if (deviceName != null)
- {
- act.args.Add("deviceName", deviceName.Value);
+ XAttribute deviceName = action.Attribute("deviceName");
+ if (deviceName != null)
+ {
+ act.args.Add("deviceName", deviceName.Value);
+ }
+ XAttribute isRight = action.Attribute("isRight");
+ if (isRight != null)
+ {
+ act.args.Add("isRight", isRight.Value);
+ }
+ newAction = act;
}
- XAttribute isRight = action.Attribute("isRight");
- if (isRight != null)
+ break;
+ case "ObjClickLong":
{
- act.args.Add("isRight", isRight.Value);
+ var act = new DictionaryCondition();
+ XAttribute deviceName = action.Attribute("deviceName");
+ if (deviceName != null)
+ {
+ act.args.Add("deviceName", deviceName.Value);
+ }
+ XAttribute time = action.Attribute("time");
+ if (time != null)
+ {
+ act.args.Add("time", time.Value);
+ }
+ newAction = act;
}
- newAction = act;
break;
default:
newAction = new Condition();
diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml
index ddcb472a..03d6ae63 100644
--- a/Doc/Xml配置文档.xml
+++ b/Doc/Xml配置文档.xml
@@ -104,8 +104,11 @@
-
-
+
+
+
+
+
From 3c1a9f564b96a53971516ce6b059db88e27fc006 Mon Sep 17 00:00:00 2001
From: shenjianxing <”315615051@qq.com“>
Date: Thu, 6 Feb 2025 16:26:44 +0800
Subject: [PATCH 04/11] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=97=AA=E7=83=81?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Assets/Scripts/Actions/ActionHelper.cs | 5 +
Assets/Scripts/Actions/HighLightAction.cs | 5 +
.../Scripts/Actions/HighLightFlashAction.cs | 149 ++++++++++++++++++
.../Actions/HighLightFlashAction.cs.meta | 11 ++
Assets/Scripts/Item/HighLightFlashItem.cs | 44 ++++++
.../Scripts/Item/HighLightFlashItem.cs.meta | 11 ++
Assets/Scripts/Xml/XmlParser.cs | 43 ++++-
Doc/Xml配置文档.xml | 6 +
8 files changed, 273 insertions(+), 1 deletion(-)
create mode 100644 Assets/Scripts/Actions/HighLightFlashAction.cs
create mode 100644 Assets/Scripts/Actions/HighLightFlashAction.cs.meta
create mode 100644 Assets/Scripts/Item/HighLightFlashItem.cs
create mode 100644 Assets/Scripts/Item/HighLightFlashItem.cs.meta
diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs
index ef39f9a8..49894bdf 100644
--- a/Assets/Scripts/Actions/ActionHelper.cs
+++ b/Assets/Scripts/Actions/ActionHelper.cs
@@ -173,6 +173,11 @@ public class ActionHelper
var strAction = (XMLTool.DictionaryAction)act;
return HighLightAction.Allocate(act.Value, strAction.args);
}
+ case "HighLightFlash":
+ {
+ var strAction = (XMLTool.DictionaryAction)act;
+ return HighLightFlashAction.Allocate(act.Value, strAction.args);
+ }
case "LoadRes":
{
var dictAction = (XMLTool.DictionaryAction)act;
diff --git a/Assets/Scripts/Actions/HighLightAction.cs b/Assets/Scripts/Actions/HighLightAction.cs
index c8da574f..24d390d5 100644
--- a/Assets/Scripts/Actions/HighLightAction.cs
+++ b/Assets/Scripts/Actions/HighLightAction.cs
@@ -93,6 +93,11 @@ namespace QFramework
{
effect.highlighted = false;
}
+ var flash = obj.GetComponent();
+ if (flash)
+ {
+ flash.Stop();
+ }
}
}
diff --git a/Assets/Scripts/Actions/HighLightFlashAction.cs b/Assets/Scripts/Actions/HighLightFlashAction.cs
new file mode 100644
index 00000000..4746f384
--- /dev/null
+++ b/Assets/Scripts/Actions/HighLightFlashAction.cs
@@ -0,0 +1,149 @@
+using HighlightPlus;
+using System;
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEngine;
+
+namespace QFramework
+{
+ internal class HighLightFlashAction : IAction
+ {
+
+
+ public System.Action OnFinished { get; set; }
+
+
+ private HighLightFlashAction()
+ {
+ }
+
+ private static readonly SimpleObjectPool mPool =
+ new SimpleObjectPool(() => new HighLightFlashAction(), null, 10);
+
+ string path;
+ Color color = Color.green;
+ bool isHigh = true;
+ string deviceName = string.Empty;
+ string isIndependent;
+ string count;
+ string time;
+ string finishedEvent;
+ public static HighLightFlashAction Allocate(string path, Dictionary datas, System.Action OnFinished = null)
+ {
+ var retNode = mPool.Allocate();
+ retNode.ActionID = ActionKit.ID_GENERATOR++;
+ retNode.Deinited = false;
+ retNode.Reset();
+ retNode.path = path;
+
+ if (datas.ContainsKey("color"))
+ {
+
+ retNode.color = Utility.ToColor(datas["color"]);
+
+ }
+ if (datas.ContainsKey("isHigh"))
+ {
+ bool.TryParse(datas["isHigh"], out retNode.isHigh);
+ }
+ retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty;
+ retNode.isIndependent = datas.ContainsKey("isIndependent") ? datas["isIndependent"] : string.Empty;
+ retNode.count = datas.ContainsKey("count") ? datas["count"] : string.Empty;
+ retNode.time = datas.ContainsKey("time") ? datas["time"] : string.Empty;
+ retNode.finishedEvent = datas.ContainsKey("finishedEvent") ? datas["finishedEvent"] : string.Empty;
+ retNode.OnFinished = OnFinished;
+ return retNode;
+ }
+
+
+ public ulong ActionID { get; set; }
+ public ActionStatus Status { get; set; }
+
+ public void OnStart()
+ {
+ GameObject obj = null;
+ if (string.IsNullOrEmpty(deviceName) == false)
+ {
+ obj = DeviceController.Instance.GetDeviceObj(deviceName);
+ }
+ else
+ {
+ obj = Utility.FindObj(path);
+ }
+
+ if (obj != null)
+ {
+ var flash = obj.GetOrAddComponent();
+ if (isHigh)
+ {
+ var effect = obj.GetOrAddComponent();
+ effect.outlineColor = color;
+ effect.highlighted = true;
+ obj.GetOrAddComponent();
+ if (string.IsNullOrEmpty(isIndependent) == false)
+ {
+ switch (isIndependent)
+ {
+ case "true":
+ effect.outlineIndependent = true;
+ break;
+ case "false":
+ effect.outlineIndependent = false;
+ break;
+ }
+ }
+ float time = 1;
+ int count = -1;
+ float.TryParse(this.time, out time);
+ int.TryParse(this.count, out count);
+ flash.Init(time, count, finishedEvent);
+ }
+ else
+ {
+ var effect = obj.GetComponent();
+ if (effect)
+ {
+ effect.highlighted = false;
+ }
+ if (flash)
+ {
+ flash.Stop();
+ }
+
+ }
+ }
+ }
+
+ 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; }
+ }
+
+
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Actions/HighLightFlashAction.cs.meta b/Assets/Scripts/Actions/HighLightFlashAction.cs.meta
new file mode 100644
index 00000000..7a9e45dc
--- /dev/null
+++ b/Assets/Scripts/Actions/HighLightFlashAction.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 96e63ca598764cf4abec4ed34f827731
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Item/HighLightFlashItem.cs b/Assets/Scripts/Item/HighLightFlashItem.cs
new file mode 100644
index 00000000..fb9f89d4
--- /dev/null
+++ b/Assets/Scripts/Item/HighLightFlashItem.cs
@@ -0,0 +1,44 @@
+using DG.Tweening;
+using DG.Tweening.Core;
+using DG.Tweening.Plugins.Options;
+using HighlightPlus;
+using QFramework;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class HighLightFlashItem : MonoBehaviour
+{
+
+ HighlightEffect high;
+ TweenerCore dotw;
+ private void Awake()
+ {
+ high = GetComponent();
+ }
+
+ public void Init(float time, int count = -1, string finishedEvent = null)
+ {
+ high.outline = 0;
+ dotw = DOTween.To(() => high.outline, (v) => high.outline = v, 1, time).SetEase(Ease.OutFlash).SetLoops(count, LoopType.Yoyo).OnComplete(() =>
+ {
+ if (string.IsNullOrEmpty(finishedEvent)==false)
+ {
+ StringEventSystem.Global.Send(finishedEvent);
+ }
+ this.Stop();
+ });
+ }
+
+ public void Stop()
+ {
+ if (dotw != null)
+ {
+ dotw.Kill();
+ dotw = null;
+ }
+ high.highlighted = false;
+ }
+
+
+}
diff --git a/Assets/Scripts/Item/HighLightFlashItem.cs.meta b/Assets/Scripts/Item/HighLightFlashItem.cs.meta
new file mode 100644
index 00000000..5eebf192
--- /dev/null
+++ b/Assets/Scripts/Item/HighLightFlashItem.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a2f23e7e41ba93044ab80cdc6be2e101
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs
index ce2a5804..6b56db69 100644
--- a/Assets/Scripts/Xml/XmlParser.cs
+++ b/Assets/Scripts/Xml/XmlParser.cs
@@ -789,7 +789,48 @@ namespace XMLTool
}
newAction = act;
}
-
+ break;
+ case "HighLightFlash":
+ {
+ var act = new DictionaryAction();
+ XAttribute isHigh = action.Attribute("isHigh");
+ if (isHigh != null)
+ {
+ act.args.Add("isHigh", isHigh.Value);
+ }
+ XAttribute color = action.Attribute("color");
+ if (color != null)
+ {
+ act.args.Add("color", color.Value);
+ }
+ XAttribute deviceName = action.Attribute("deviceName");
+ if (deviceName != null)
+ {
+ act.args.Add("deviceName", deviceName.Value);
+ }
+ newAction = act;
+ XAttribute isIndependent = action.Attribute("isIndependent");
+ if (isIndependent != null)
+ {
+ act.args.Add("isIndependent", isIndependent.Value);
+ }
+ XAttribute time = action.Attribute("time");
+ if (time != null)
+ {
+ act.args.Add("time", time.Value);
+ }
+ XAttribute count = action.Attribute("count");
+ if (count != null)
+ {
+ act.args.Add("count", count.Value);
+ }
+ XAttribute finishedEvent = action.Attribute("finishedEvent");
+ if (finishedEvent != null)
+ {
+ act.args.Add("finishedEvent", finishedEvent.Value);
+ }
+ newAction = act;
+ }
break;
case "LoadRes":
{
diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml
index 03d6ae63..dd234ef5 100644
--- a/Doc/Xml配置文档.xml
+++ b/Doc/Xml配置文档.xml
@@ -91,6 +91,12 @@
+
+
-
-
+
+
-
+