浏览代码

Merge pull request #3 from laurenth-unity/additions

Additional Actions / Logic / Events
/main
GitHub 5 年前
当前提交
9648f9bb
共有 11 个文件被更改,包括 275 次插入0 次删除
  1. 1
      Runtime/LevelScripting/Events/OnTriggerEvent.cs
  2. 74
      Runtime/LevelScripting/Actions/RigidbodyAction.cs
  3. 11
      Runtime/LevelScripting/Actions/RigidbodyAction.cs.meta
  4. 55
      Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs
  5. 11
      Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs.meta
  6. 43
      Runtime/LevelScripting/Events/OnColliderEvent.cs
  7. 11
      Runtime/LevelScripting/Events/OnColliderEvent.cs.meta
  8. 17
      Runtime/LevelScripting/Events/OnJointBreakEvent.cs
  9. 11
      Runtime/LevelScripting/Events/OnJointBreakEvent.cs.meta
  10. 30
      Runtime/LevelScripting/Logic/FlipFlopLogic.cs
  11. 11
      Runtime/LevelScripting/Logic/FlipFlopLogic.cs.meta

1
Runtime/LevelScripting/Events/OnTriggerEvent.cs


public Callable[] onTriggerExit;
public bool OnlyInteractWithTag = true;
[EnableIf("OnlyInteractWithTag")]
public string Tag = "Player";
private void OnTriggerEnter(Collider other)

74
Runtime/LevelScripting/Actions/RigidbodyAction.cs


using NaughtyAttributes;
using UnityEngine;
namespace GameplayIngredients.Actions
{
public enum RigidbodyActionType { Force, Torque, ExplosionForce, Sleep };
public enum ActionSpace { Local, World };
[ExecuteAlways]
public class RigidbodyAction : ActionBase
{
public Rigidbody m_Rigidbody;
[OnValueChanged("OnParameterTypeChanged")]
public RigidbodyActionType actionType;
bool force = true;
bool explosion;
[ShowIf("force")]
public ActionSpace actionSpace;
[ShowIf("force")]
public ForceMode forceMode;
[ShowIf("force")]
public Vector3 direction;
[ShowIf("explosion")]
public float explosionForce;
[ShowIf("explosion")]
public Vector3 explositonPosition;
[ShowIf("explosion")]
public float explosionRadius;
public override void Execute(GameObject instigator = null)
{
if (m_Rigidbody == null)
return;
switch (actionType)
{
case RigidbodyActionType.Force:
if(actionSpace == ActionSpace.World)
{
m_Rigidbody.AddForce(direction, forceMode);
}
if(actionSpace == ActionSpace.Local)
{
m_Rigidbody.AddRelativeForce(direction, forceMode);
}
break;
case RigidbodyActionType.Torque:
if (actionSpace == ActionSpace.World)
{
m_Rigidbody.AddTorque(direction, forceMode);
}
if (actionSpace == ActionSpace.Local)
{
m_Rigidbody.AddRelativeTorque(direction, forceMode);
}
break;
case RigidbodyActionType.ExplosionForce:
m_Rigidbody.AddExplosionForce(explosionForce, explositonPosition, explosionRadius, 0, forceMode);
break;
case RigidbodyActionType.Sleep:
m_Rigidbody.Sleep();
break;
}
}
private void OnParameterTypeChanged()
{
force = (actionType == RigidbodyActionType.Force || RigidbodyActionType.Torque);
explosion = (actionType == RigidbodyActionType.ExplosionForce);
}
}
}

11
Runtime/LevelScripting/Actions/RigidbodyAction.cs.meta


fileFormatVersion: 2
guid: d3490d67f14565045b8de2af2380b379
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

55
Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs


using UnityEngine;
using NaughtyAttributes;
namespace GameplayIngredients.Actions
{
public enum AnimatorParameterType { Bool, Float, Int, Trigger };
public class SetAnimatorParameterAction : ActionBase
{
public Animator animator;
public string parameterName;
[OnValueChanged("OnParameterTypeChanged")]
public AnimatorParameterType parameterType = AnimatorParameterType.Bool;
bool showFloat;
bool showInt;
bool showBool = true;
[ShowIf("showFloat")]
public float floatValue;
[ShowIf("showInt")]
public int intValue;
[ShowIf("showBool")]
public bool boolValue;
public override void Execute(GameObject instigator = null)
{
if (animator == null)
return;
switch (parameterType)
{
case AnimatorParameterType.Bool:
animator.SetBool(parameterName, boolValue);
break;
case AnimatorParameterType.Float:
animator.SetFloat(parameterName, floatValue);
break;
case AnimatorParameterType.Int:
animator.SetInteger(parameterName, intValue);
break;
case AnimatorParameterType.Trigger:
animator.SetTrigger(parameterName);
break;
}
}
private void OnParameterTypeChanged()
{
showBool = (parameterType == AnimatorParameterType.Bool);
showFloat = (parameterType == AnimatorParameterType.Float);
showInt = (parameterType == AnimatorParameterType.Int);
}
}
}

11
Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs.meta


fileFormatVersion: 2
guid: e5f9a6ca2faa0514095c2a061d47807e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

43
Runtime/LevelScripting/Events/OnColliderEvent.cs


using NaughtyAttributes;
using UnityEngine;
namespace GameplayIngredients.Events
{
[RequireComponent(typeof(Collider))]
public class OnColliderEvent : EventBase
{
[ReorderableList]
public Callable[] onCollisionEnter;
[ReorderableList]
public Callable[] onCollisionExit;
public bool OnlyInteractWithTag = false;
[EnableIf("OnlyInteractWithTag")]
public string Tag = "Player";
private void OnCollisionEnter(Collision other)
{
if (OnlyInteractWithTag && other.collider.tag == Tag)
{
Callable.Call(onCollisionEnter, other.collider.gameObject);
}
if (!OnlyInteractWithTag)
{
Callable.Call(onCollisionEnter, other.collider.gameObject);
}
}
private void OnCollisionExit(Collision other)
{
if (OnlyInteractWithTag && other.collider.tag == Tag)
{
Callable.Call(onCollisionExit, other.collider.gameObject);
}
if (!OnlyInteractWithTag)
{
Callable.Call(onCollisionExit, other.collider.gameObject);
}
}
}
}

11
Runtime/LevelScripting/Events/OnColliderEvent.cs.meta


fileFormatVersion: 2
guid: 086b61f209a45d64aa1dae4267461fc5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

17
Runtime/LevelScripting/Events/OnJointBreakEvent.cs


using NaughtyAttributes;
using UnityEngine;
namespace GameplayIngredients.Events
{
[RequireComponent(typeof(Joint))]
public class OnJointBreakEvent : EventBase
{
[ReorderableList]
public Callable[] onJointBreak;
private void OnJointBreak(float breakForce)
{
Callable.Call(onJointBreak, gameObject);
}
}
}

11
Runtime/LevelScripting/Events/OnJointBreakEvent.cs.meta


fileFormatVersion: 2
guid: 86d3be9dd9f73fa4a9a9e0576d5c7cf0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

30
Runtime/LevelScripting/Logic/FlipFlopLogic.cs


using UnityEngine;
using NaughtyAttributes;
namespace GameplayIngredients.Logic
{
public class FlipFlopLogic : LogicBase
{
[ReorderableList]
public Callable[] OnFlip;
[ReorderableList]
public Callable[] OnFlop;
private bool condition = true;
public override void Execute(GameObject instigator = null)
{
if (condition)
{
Callable.Call(OnFlip, instigator);
condition = false;
}
else
{
Callable.Call(OnFlop, instigator);
condition = true;
}
}
}
}

11
Runtime/LevelScripting/Logic/FlipFlopLogic.cs.meta


fileFormatVersion: 2
guid: 6331218ad8cbbe64cb1230f96dac5ffe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存