GitHub
5 年前
当前提交
9648f9bb
共有 11 个文件被更改,包括 275 次插入 和 0 次删除
-
1Runtime/LevelScripting/Events/OnTriggerEvent.cs
-
74Runtime/LevelScripting/Actions/RigidbodyAction.cs
-
11Runtime/LevelScripting/Actions/RigidbodyAction.cs.meta
-
55Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs
-
11Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs.meta
-
43Runtime/LevelScripting/Events/OnColliderEvent.cs
-
11Runtime/LevelScripting/Events/OnColliderEvent.cs.meta
-
17Runtime/LevelScripting/Events/OnJointBreakEvent.cs
-
11Runtime/LevelScripting/Events/OnJointBreakEvent.cs.meta
-
30Runtime/LevelScripting/Logic/FlipFlopLogic.cs
-
11Runtime/LevelScripting/Logic/FlipFlopLogic.cs.meta
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d3490d67f14565045b8de2af2380b379 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e5f9a6ca2faa0514095c2a061d47807e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 086b61f209a45d64aa1dae4267461fc5 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 86d3be9dd9f73fa4a9a9e0576d5c7cf0 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6331218ad8cbbe64cb1230f96dac5ffe |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue