Compare commits
3 Commits
ca264c4e70
...
783579741b
| Author | SHA1 | Date | |
|---|---|---|---|
| 783579741b | |||
|
|
1a10ee747d | ||
|
|
1fca93283a |
@ -337,6 +337,16 @@ 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);
|
||||||
|
}
|
||||||
|
case "Distance":
|
||||||
|
{
|
||||||
|
var dict = (XMLTool.DictionaryCondition)condition;
|
||||||
|
return DistanceCondition.Allocate(condition.Value, dict.args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
95
Assets/Scripts/Conditions/DistanceCondition.cs
Normal file
95
Assets/Scripts/Conditions/DistanceCondition.cs
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
namespace QFramework
|
||||||
|
{
|
||||||
|
public class DistanceCondition : ICondition
|
||||||
|
{
|
||||||
|
|
||||||
|
private static SimpleObjectPool<DistanceCondition> mSimpleObjectPool =
|
||||||
|
new SimpleObjectPool<DistanceCondition>(() => new DistanceCondition(), null, 10);
|
||||||
|
|
||||||
|
private DistanceCondition() { }
|
||||||
|
public GameObject obj = null;
|
||||||
|
float value = 0;
|
||||||
|
Vector3 targetPos = Vector3.zero;
|
||||||
|
bool ignoreY = false;
|
||||||
|
public static DistanceCondition Allocate(string value, Dictionary<string, string> datas)
|
||||||
|
{
|
||||||
|
var conditionAction = mSimpleObjectPool.Allocate();
|
||||||
|
conditionAction.ActionID = ActionKit.ID_GENERATOR++;
|
||||||
|
conditionAction.Deinited = false;
|
||||||
|
conditionAction.Reset();
|
||||||
|
float.TryParse(value, out conditionAction.value);
|
||||||
|
if (datas.ContainsKey("targetPos"))
|
||||||
|
{
|
||||||
|
conditionAction.targetPos = Utility.GetVector3FromStrArray(datas["targetPos"]);
|
||||||
|
}
|
||||||
|
if (datas.ContainsKey("ignoreY"))
|
||||||
|
{
|
||||||
|
if (bool.TryParse(datas["ignoreY"], out conditionAction.ignoreY) == false)
|
||||||
|
{
|
||||||
|
conditionAction.ignoreY = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return conditionAction;
|
||||||
|
}
|
||||||
|
public bool Check()
|
||||||
|
{
|
||||||
|
|
||||||
|
Vector3 self = FreeCameraController.instance.transform.position;
|
||||||
|
if (ignoreY)
|
||||||
|
{
|
||||||
|
self.y = targetPos.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Vector3.Distance(self, targetPos) <= value;
|
||||||
|
}
|
||||||
|
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 DistanceConditionExtension
|
||||||
|
{
|
||||||
|
public static ISequence DistanceCondition(this ISequence self, string value,Dictionary<string,string> datas)
|
||||||
|
{
|
||||||
|
return self.Append(QFramework.DistanceCondition.Allocate(value, datas));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Conditions/DistanceCondition.cs.meta
Normal file
11
Assets/Scripts/Conditions/DistanceCondition.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c8bdcde7925b9534494a18a7b803043e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
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,38 @@ 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;
|
||||||
|
case "Distance":
|
||||||
|
{
|
||||||
|
var act = new DictionaryCondition();
|
||||||
|
XAttribute targetPos = action.Attribute("targetPos");
|
||||||
|
if (targetPos != null)
|
||||||
|
{
|
||||||
|
act.args.Add("targetPos", targetPos.Value);
|
||||||
|
}
|
||||||
|
XAttribute ignoreY = action.Attribute("ignoreY");
|
||||||
|
if (ignoreY != null)
|
||||||
|
{
|
||||||
|
act.args.Add("ignoreY", ignoreY.Value);
|
||||||
|
}
|
||||||
|
newAction = act;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
newAction = new Condition();
|
newAction = new Condition();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -173,6 +173,14 @@
|
|||||||
<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>
|
||||||
|
|
||||||
|
<!--判断是否距离某个点 在某个范围内 ignoreY 是否忽略Y方向的距离-->
|
||||||
|
<Condition type="Distance" value="10" targetPos="0,0,0" ignoreY="false"></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