diff --git a/Assets/Scripts/Actions/ActionBase.cs b/Assets/Scripts/Actions/ActionBase.cs index dd46b2ba..dc832519 100644 --- a/Assets/Scripts/Actions/ActionBase.cs +++ b/Assets/Scripts/Actions/ActionBase.cs @@ -24,6 +24,9 @@ namespace XMLTool } - + public class DictionaryCondition : Condition + { + public Dictionary args = new Dictionary(); + } } diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index c6a99514..029a5ec5 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -237,7 +237,8 @@ public class ActionHelper case "UIClick": return UIClickCondition.Allocate(condition.Value); case "ObjClick": - return ObjClickCondition.Allocate(condition.Value); + var dict = (XMLTool.DictionaryCondition)condition; + return ObjClickCondition.Allocate(dict.Value, dict.args); case "Input": return InputCondition.Allocate(condition.Value); case "Var": diff --git a/Assets/Scripts/Conditions/ObjClickCondition.cs b/Assets/Scripts/Conditions/ObjClickCondition.cs index dd1b43d5..2bcfdad4 100644 --- a/Assets/Scripts/Conditions/ObjClickCondition.cs +++ b/Assets/Scripts/Conditions/ObjClickCondition.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.EventSystems; @@ -14,20 +15,29 @@ namespace QFramework private ObjClickCondition() { } public GameObject obj = null; string path; - public static ObjClickCondition Allocate(string path) + string deviceName; + public static ObjClickCondition 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; return conditionAction; } public bool Check() { if (obj == null) { - obj = Utility.FindObj(path); + if (string.IsNullOrEmpty(deviceName)) + { + obj = Utility.FindObj(path); + } + else + { + obj = DeviceController.Instance.GetDeviceObj(deviceName); + } } if (obj != null && Input.GetMouseButtonUp(0)) { @@ -79,11 +89,11 @@ namespace QFramework } } - public static class ObjClickConditionExtension - { - public static ISequence ObjClickCondition(this ISequence self, string uipath) - { - return self.Append(QFramework.ObjClickCondition.Allocate(uipath)); - } - } + //public static class ObjClickConditionExtension + //{ + // public static ISequence ObjClickCondition(this ISequence self, string uipath) + // { + // return self.Append(QFramework.ObjClickCondition.Allocate(uipath)); + // } + //} } \ No newline at end of file diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index 51db6872..5e112adf 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -1040,13 +1040,29 @@ namespace XMLTool public static Condition ParseCondition(XElement action) { - Condition newAction = new Condition + Condition newAction = null; + string type = action.Attribute("type")?.Value; + switch (type) { - Type = action.Attribute("type")?.Value, - Name = action.Attribute("name")?.Value, - Value = action.Attribute("value")?.Value, - SubActions = ParseActions(action) - }; + case "ObjClick": + var act = new DictionaryCondition(); + + XAttribute deviceName = action.Attribute("deviceName"); + if (deviceName != null) + { + act.args.Add("deviceName", deviceName.Value); + } + newAction = act; + break; + default: + newAction = new Condition(); + break; + } + newAction.Type = type; + newAction.Name = action.Attribute("name")?.Value; + newAction.Value = action.Attribute("value")?.Value; + newAction.SubActions = ParseActions(action); + return newAction; } diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 79bdef6d..03669536 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -72,8 +72,8 @@ - - + +