diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index 8be1bf3d..0229c169 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -287,7 +287,7 @@ public class ActionHelper case "ImageSelectMap": { var dictAction = (XMLTool.ImageSelectMapAction)act; - return QFramework.ImageSelectMapAction.Allocate(dictAction.args,dictAction.items); + return QFramework.ImageSelectMapAction.Allocate(dictAction.args, dictAction.items); } default: Debug.LogError($"没有找到此Action的类型{act.Type}"); @@ -337,6 +337,11 @@ public class ActionHelper return VarCondition.Allocate(condition.Name, condition.Value); case "StrEvent": return StrEventCondition.Allocate(condition.Value); + case "HasDevice": + { + var dict = (XMLTool.DictionaryCondition)condition; + return HasDeviceCondition.Allocate(dict.args); + } } } return null; diff --git a/Assets/Scripts/Conditions/HasDeviceCondition.cs b/Assets/Scripts/Conditions/HasDeviceCondition.cs new file mode 100644 index 00000000..1af42c4b --- /dev/null +++ b/Assets/Scripts/Conditions/HasDeviceCondition.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Xml.Linq; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace QFramework +{ + public class HasDeviceCondition : ICondition + { + + private static SimpleObjectPool mSimpleObjectPool = + new SimpleObjectPool(() => new HasDeviceCondition(), null, 10); + + private HasDeviceCondition() { } + public GameObject obj = null; + string name; + int count = 1; + public static HasDeviceCondition Allocate(Dictionary datas) + { + var conditionAction = mSimpleObjectPool.Allocate(); + conditionAction.ActionID = ActionKit.ID_GENERATOR++; + conditionAction.Deinited = false; + conditionAction.Reset(); + conditionAction.name = datas.ContainsKey("deviceName") ? datas["deviceName"] : ""; + if (datas.ContainsKey("count")) + { + if (int.TryParse(datas["count"], out conditionAction.count) == false) + { + conditionAction.count = 1; + } + } + return conditionAction; + } + public bool Check() + { + if (string.IsNullOrEmpty(name) == false) + { + var device = PlayerController.Instance.HasDevice(name); + if (device != null && device.count >= count) + { + return true; + } + } + return 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; + mSimpleObjectPool.Recycle(this); + } + } + + public void Reset() + { + Paused = false; + Status = ActionStatus.NotStart; + } + } + + public static class HasDeviceConditionExtension + { + public static ISequence HasDeviceCondition(this ISequence self, Dictionary datas) + { + return self.Append(QFramework.HasDeviceCondition.Allocate(datas)); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Conditions/HasDeviceCondition.cs.meta b/Assets/Scripts/Conditions/HasDeviceCondition.cs.meta new file mode 100644 index 00000000..16e2d8b9 --- /dev/null +++ b/Assets/Scripts/Conditions/HasDeviceCondition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 353fda108db04804b9576966f8d0e854 +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 45f11ecf..32370328 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -1803,6 +1803,22 @@ namespace XMLTool newAction = act; } break; + case "HasDevice": + { + var act = new DictionaryCondition(); + XAttribute deviceName = action.Attribute("deviceName"); + if (deviceName != null) + { + act.args.Add("deviceName", deviceName.Value); + } + XAttribute count = action.Attribute("count"); + if (count != null) + { + act.args.Add("count", count.Value); + } + newAction = act; + } + break; default: newAction = new Condition(); break; diff --git a/Data/App.xml b/Data/App.xml index 33623862..7aee75bc 100644 --- a/Data/App.xml +++ b/Data/App.xml @@ -13,17 +13,38 @@ + + Qiu + + Ren/Tou/ShenJing/3 + Qiu + + + - + - + + + + + + + + + + + + + + diff --git a/Doc/Xml閰嶇疆鏂囨。.xml b/Doc/Xml閰嶇疆鏂囨。.xml index d55e5328..2b5ee592 100644 --- a/Doc/Xml閰嶇疆鏂囨。.xml +++ b/Doc/Xml閰嶇疆鏂囨。.xml @@ -173,6 +173,9 @@ + + +