增加 HasDevice判断条件
This commit is contained in:
parent
17d6a14e13
commit
1fca93283a
@ -287,7 +287,7 @@ public class ActionHelper
|
|||||||
case "ImageSelectMap":
|
case "ImageSelectMap":
|
||||||
{
|
{
|
||||||
var dictAction = (XMLTool.ImageSelectMapAction)act;
|
var dictAction = (XMLTool.ImageSelectMapAction)act;
|
||||||
return QFramework.ImageSelectMapAction.Allocate(dictAction.args,dictAction.items);
|
return QFramework.ImageSelectMapAction.Allocate(dictAction.args, dictAction.items);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Debug.LogError($"ûÓÐÕÒµ½´ËActionµÄÀàÐÍ{act.Type}");
|
Debug.LogError($"ûÓÐÕÒµ½´ËActionµÄÀàÐÍ{act.Type}");
|
||||||
@ -337,6 +337,11 @@ public class ActionHelper
|
|||||||
return VarCondition.Allocate(condition.Name, condition.Value);
|
return VarCondition.Allocate(condition.Name, condition.Value);
|
||||||
case "StrEvent":
|
case "StrEvent":
|
||||||
return StrEventCondition.Allocate(condition.Value);
|
return StrEventCondition.Allocate(condition.Value);
|
||||||
|
case "HasDevice":
|
||||||
|
{
|
||||||
|
var dict = (XMLTool.DictionaryCondition)condition;
|
||||||
|
return HasDeviceCondition.Allocate(dict.args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
92
Assets/Scripts/Conditions/HasDeviceCondition.cs
Normal file
92
Assets/Scripts/Conditions/HasDeviceCondition.cs
Normal file
@ -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<HasDeviceCondition> mSimpleObjectPool =
|
||||||
|
new SimpleObjectPool<HasDeviceCondition>(() => new HasDeviceCondition(), null, 10);
|
||||||
|
|
||||||
|
private HasDeviceCondition() { }
|
||||||
|
public GameObject obj = null;
|
||||||
|
string name;
|
||||||
|
int count = 1;
|
||||||
|
public static HasDeviceCondition Allocate(Dictionary<string, string> 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<string, string> datas)
|
||||||
|
{
|
||||||
|
return self.Append(QFramework.HasDeviceCondition.Allocate(datas));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Conditions/HasDeviceCondition.cs.meta
Normal file
11
Assets/Scripts/Conditions/HasDeviceCondition.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 353fda108db04804b9576966f8d0e854
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1803,6 +1803,22 @@ namespace XMLTool
|
|||||||
newAction = act;
|
newAction = act;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
newAction = new Condition();
|
newAction = new Condition();
|
||||||
break;
|
break;
|
||||||
|
|||||||
23
Data/App.xml
23
Data/App.xml
@ -13,17 +13,38 @@
|
|||||||
<MeshCollider/>
|
<MeshCollider/>
|
||||||
<RightMenu values="拾取,丢弃,观察"/>
|
<RightMenu values="拾取,丢弃,观察"/>
|
||||||
</Device>
|
</Device>
|
||||||
|
<Device>
|
||||||
|
<Name>Qiu</Name>
|
||||||
|
<HighLight color="255,255,255"/>
|
||||||
|
<Path>Ren/Tou/ShenJing/3</Path>
|
||||||
|
<Tip>Qiu</Tip>
|
||||||
|
<MeshCollider/>
|
||||||
|
<RightMenu values="拾取,丢弃,观察"/>
|
||||||
|
</Device>
|
||||||
|
|
||||||
|
|
||||||
<!--状态机-->
|
<!--状态机-->
|
||||||
<FSM name="初始化状态机">
|
<FSM name="初始化状态机">
|
||||||
<State name="状态2">
|
<State name="状态1">
|
||||||
<Enter>
|
<Enter>
|
||||||
<Action type="Sequence">
|
<Action type="Sequence">
|
||||||
<Action type="UIShow" value="UIBackPack"></Action>
|
<Action type="UIShow" value="UIBackPack"></Action>
|
||||||
</Action>
|
</Action>
|
||||||
</Enter>
|
</Enter>
|
||||||
</State>
|
</State>
|
||||||
|
<State name="状态2">
|
||||||
|
<Enter>
|
||||||
|
<Action type="Sequence">
|
||||||
|
<!--<Action type="Log" value="11111"></Action>-->
|
||||||
|
</Action>
|
||||||
|
</Enter>
|
||||||
|
</State>
|
||||||
|
<Transision from="状态1" to="状态2">
|
||||||
|
<Condition type="And">
|
||||||
|
<Condition type="HasDevice" deviceName="LeiGu" count="1"></Condition>
|
||||||
|
<Condition type="HasDevice" deviceName="Qiu" count="1"></Condition>
|
||||||
|
</Condition>
|
||||||
|
</Transision>
|
||||||
</FSM>
|
</FSM>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -173,6 +173,9 @@
|
|||||||
<Condition type="Var" name="变量名" value="1"></Condition>
|
<Condition type="Var" name="变量名" value="1"></Condition>
|
||||||
<!--字符串类型的事件监听 UI中的事件监听都 也可以自定义事件监听-->
|
<!--字符串类型的事件监听 UI中的事件监听都 也可以自定义事件监听-->
|
||||||
<Condition type="StrEvent" value="器械选择通过"></Condition>
|
<Condition type="StrEvent" value="器械选择通过"></Condition>
|
||||||
|
|
||||||
|
<!--身上是否存有某个道具 count默认为1 可以判断数量 如:身上有某个道具20个-->
|
||||||
|
<Condition type="HasDevice" deviceName="道具名" count="1"></Condition>
|
||||||
<!--画线 途径点使用|分割 lineScale 可以调整x轴向和y轴线上的线的粗细-->
|
<!--画线 途径点使用|分割 lineScale 可以调整x轴向和y轴线上的线的粗细-->
|
||||||
<Action type="Line" name="红线" value="-4.030808,2.689521,-1.768913|-3.759371,2.694512,-1.247592" color="255,0,0,255" width="0.05" lineScale="10,0.5"></Action>
|
<Action type="Line" name="红线" value="-4.030808,2.689521,-1.768913|-3.759371,2.694512,-1.247592" color="255,0,0,255" width="0.05" lineScale="10,0.5"></Action>
|
||||||
<!--相机锁定 是否可以移动 isMove 是否可以旋转镜头 isRotate-->
|
<!--相机锁定 是否可以移动 isMove 是否可以旋转镜头 isRotate-->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user