diff --git a/Assembly-CSharp-Editor.csproj b/Assembly-CSharp-Editor.csproj index 4bc8e2f..3757ab9 100644 --- a/Assembly-CSharp-Editor.csproj +++ b/Assembly-CSharp-Editor.csproj @@ -46,6 +46,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/Advertisements/Editor/UnityEditor.Advertisements.dll @@ -70,6 +109,51 @@ /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/TreeEditor/Editor/UnityEditor.TreeEditor.dll + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/ConditionalExpression.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/ConditionalExpressionEditor.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/PlayMakerEditor.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/PlayMakerEditorResources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/de/PlayMakerEditor.de.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/es-ES/PlayMakerEditor.es-ES.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/fr/PlayMakerEditor.fr.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/it/PlayMakerEditor.it.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/ja/PlayMakerEditor.ja.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/nl/PlayMakerEditor.nl.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/pt-BR/PlayMakerEditor.pt-BR.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/sv-SE/PlayMakerEditor.sv-SE.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/zh-CN/PlayMakerEditor.zh-CN.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/Editor/zh-TW/PlayMakerEditor.zh-TW.resources.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/Plugins/PlayMaker/PlayMaker.dll + /Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEditor.Graphs.dll diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index 8280821..1ab5030 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -65,12 +65,607 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll + + /Users/matov/Programming/Projects/unityiso/Assets/PlayMaker/ConditionalExpression.dll + + + /Users/matov/Programming/Projects/unityiso/Assets/Plugins/PlayMaker/PlayMaker.dll + /Applications/Unity/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll diff --git a/Assets/Gizmos.meta b/Assets/Gizmos.meta new file mode 100644 index 0000000..603aa85 --- /dev/null +++ b/Assets/Gizmos.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 45bec39a4e05f45bb9a90acbe91399b0 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Gizmos/PlayMakerFSM Icon.tiff b/Assets/Gizmos/PlayMakerFSM Icon.tiff new file mode 100755 index 0000000..f037c5c Binary files /dev/null and b/Assets/Gizmos/PlayMakerFSM Icon.tiff differ diff --git a/Assets/Gizmos/PlayMakerFSM Icon.tiff.meta b/Assets/Gizmos/PlayMakerFSM Icon.tiff.meta new file mode 100755 index 0000000..e70c9df --- /dev/null +++ b/Assets/Gizmos/PlayMakerFSM Icon.tiff.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: f728493f9ebb2324d94581b928975c04 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/Gizmos/PlayMakerGUI Icon.tiff b/Assets/Gizmos/PlayMakerGUI Icon.tiff new file mode 100755 index 0000000..f037c5c Binary files /dev/null and b/Assets/Gizmos/PlayMakerGUI Icon.tiff differ diff --git a/Assets/Gizmos/PlayMakerGUI Icon.tiff.meta b/Assets/Gizmos/PlayMakerGUI Icon.tiff.meta new file mode 100755 index 0000000..7196777 --- /dev/null +++ b/Assets/Gizmos/PlayMakerGUI Icon.tiff.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 7390251e5bc320f4abea3501d907f3e3 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/Gizmos/PlayMakerGlobals Icon.tiff b/Assets/Gizmos/PlayMakerGlobals Icon.tiff new file mode 100755 index 0000000..f037c5c Binary files /dev/null and b/Assets/Gizmos/PlayMakerGlobals Icon.tiff differ diff --git a/Assets/Gizmos/PlayMakerGlobals Icon.tiff.meta b/Assets/Gizmos/PlayMakerGlobals Icon.tiff.meta new file mode 100755 index 0000000..21cc56e --- /dev/null +++ b/Assets/Gizmos/PlayMakerGlobals Icon.tiff.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 846171814b98d1d48afa7805037eb0bc +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/Gizmos/PlayMakerPrefs Icon.tiff b/Assets/Gizmos/PlayMakerPrefs Icon.tiff new file mode 100755 index 0000000..f037c5c Binary files /dev/null and b/Assets/Gizmos/PlayMakerPrefs Icon.tiff differ diff --git a/Assets/Gizmos/PlayMakerPrefs Icon.tiff.meta b/Assets/Gizmos/PlayMakerPrefs Icon.tiff.meta new file mode 100755 index 0000000..38091a7 --- /dev/null +++ b/Assets/Gizmos/PlayMakerPrefs Icon.tiff.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 4681a9805673831459ed595c2dc402d6 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/Gizmos/PlaymakerIcon.tiff b/Assets/Gizmos/PlaymakerIcon.tiff new file mode 100755 index 0000000..6b96f58 Binary files /dev/null and b/Assets/Gizmos/PlaymakerIcon.tiff differ diff --git a/Assets/Gizmos/PlaymakerIcon.tiff.meta b/Assets/Gizmos/PlaymakerIcon.tiff.meta new file mode 100755 index 0000000..7557fd7 --- /dev/null +++ b/Assets/Gizmos/PlaymakerIcon.tiff.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: dd021173169ae0c45840a63894bc27c0 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker.meta b/Assets/PlayMaker.meta new file mode 100644 index 0000000..2cecb93 --- /dev/null +++ b/Assets/PlayMaker.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9e856374850964c5b87f19b12572d635 +folderAsset: yes +timeCreated: 1449957738 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions.meta b/Assets/PlayMaker/Actions.meta new file mode 100644 index 0000000..78218af --- /dev/null +++ b/Assets/PlayMaker/Actions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 93a4fa665e56e446bacfaa603a05b17e +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions/ActivateGameObject.cs b/Assets/PlayMaker/Actions/ActivateGameObject.cs new file mode 100755 index 0000000..f5c989a --- /dev/null +++ b/Assets/PlayMaker/Actions/ActivateGameObject.cs @@ -0,0 +1,132 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Activates/deactivates a Game Object. Use this to hide/show areas, or enable/disable many Behaviours at once.")] + public class ActivateGameObject : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to activate/deactivate.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("Check to activate, uncheck to deactivate Game Object.")] + public FsmBool activate; + + [Tooltip("Recursively activate/deactivate all children.")] + public FsmBool recursive; + + [Tooltip("Reset the game objects when exiting this state. Useful if you want an object to be active only while this state is active.\nNote: Only applies to the last Game Object activated/deactivated (won't work if Game Object changes).")] + public bool resetOnExit; + + [Tooltip("Repeat this action every frame. Useful if Activate changes over time.")] + public bool everyFrame; + + // store the game object that we activated on enter + // so we can de-activate it on exit. + GameObject activatedGameObject; + + public override void Reset() + { + gameObject = null; + activate = true; + recursive = true; + resetOnExit = false; + everyFrame = false; + } + + public override void OnEnter() + { + DoActivateGameObject(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoActivateGameObject(); + } + + public override void OnExit() + { + // the stored game object might be invalid now + if (activatedGameObject == null) + { + return; + } + + if (resetOnExit) + { + if (recursive.Value) + { +#if UNITY_3_5 || UNITY_3_4 + activatedGameObject.SetActiveRecursively(!activate.Value); +#else + SetActiveRecursively(activatedGameObject, !activate.Value); +#endif + } + else + { +#if UNITY_3_5 || UNITY_3_4 + activatedGameObject.active = !activate.Value; +#else + activatedGameObject.SetActive(!activate.Value); +#endif + } + } + } + + void DoActivateGameObject() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + + if (go == null) + { + return; + } + + if (recursive.Value) + { +#if UNITY_3_5 || UNITY_3_4 + go.SetActiveRecursively(activate.Value); +#else + SetActiveRecursively(go, activate.Value); +#endif + } + else + { +#if UNITY_3_5 || UNITY_3_4 + go.active = activate.Value; +#else + go.SetActive(activate.Value); +#endif + } + + activatedGameObject = go; + } + +#if !(UNITY_3_5 || UNITY_3_4) + public void SetActiveRecursively(GameObject go, bool state) + { + go.SetActive(state); + foreach (Transform child in go.transform) + { + SetActiveRecursively(child.gameObject, state); + } + } +#endif + +#if UNITY_EDITOR + public override string AutoName() + { + return (activate.Value ? "Activate " : "Deactivate ") + ActionHelpers.GetValueLabel(Fsm, gameObject); + } +#endif + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ActivateGameObject.cs.meta b/Assets/PlayMaker/Actions/ActivateGameObject.cs.meta new file mode 100755 index 0000000..ecedd47 --- /dev/null +++ b/Assets/PlayMaker/Actions/ActivateGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc0e3ebc3fd22c6458e70283786cf795 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AddAnimationClip.cs b/Assets/PlayMaker/Actions/AddAnimationClip.cs new file mode 100755 index 0000000..3e0ded3 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddAnimationClip.cs @@ -0,0 +1,76 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Adds a named Animation Clip to a Game Object. Optionally trims the Animation.")] + public class AddAnimationClip : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("The GameObject to add the Animation Clip to.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [ObjectType(typeof(AnimationClip))] + [Tooltip("The animation clip to add. NOTE: Make sure the clip is compatible with the object's hierarchy.")] + public FsmObject animationClip; + + [RequiredField] + [Tooltip("Name the animation. Used by other actions to reference this animation.")] + public FsmString animationName; + + [Tooltip("Optionally trim the animation by specifying a first and last frame.")] + public FsmInt firstFrame; + + [Tooltip("Optionally trim the animation by specifying a first and last frame.")] + public FsmInt lastFrame; + + [Tooltip("Add an extra looping frame that matches the first frame.")] + public FsmBool addLoopFrame; + + public override void Reset() + { + gameObject = null; + animationClip = null; + animationName = ""; + firstFrame = 0; + lastFrame = 0; + addLoopFrame = false; + } + + public override void OnEnter() + { + DoAddAnimationClip(); + Finish(); + } + + void DoAddAnimationClip() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var animClip = animationClip.Value as AnimationClip; + if (animClip == null) + { + return; + } + + var animation = go.GetComponent(); + + if (firstFrame.Value == 0 && lastFrame.Value == 0) + { + animation.AddClip(animClip, animationName.Value); + } + else + { + animation.AddClip(animClip, animationName.Value, firstFrame.Value, lastFrame.Value, addLoopFrame.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AddAnimationClip.cs.meta b/Assets/PlayMaker/Actions/AddAnimationClip.cs.meta new file mode 100755 index 0000000..b149d15 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddAnimationClip.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8b9bc61aa3cfd0e43818e823d44ac217 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AddComponent.cs b/Assets/PlayMaker/Actions/AddComponent.cs new file mode 100755 index 0000000..b47d211 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddComponent.cs @@ -0,0 +1,67 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Adds a Component to a Game Object. Use this to change the behaviour of objects on the fly. Optionally remove the Component on exiting the state.")] + public class AddComponent : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to add the Component to.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.ScriptComponent)] + [Title("Component Type"), Tooltip("The type of Component to add to the Game Object.")] + public FsmString component; + + [UIHint(UIHint.Variable)] + [ObjectType(typeof(Component))] + [Tooltip("Store the component in an Object variable. E.g., to use with Set Property.")] + public FsmObject storeComponent; + + [Tooltip("Remove the Component when this State is exited.")] + public FsmBool removeOnExit; + + Component addedComponent; + + public override void Reset() + { + gameObject = null; + component = null; + storeComponent = null; + } + + public override void OnEnter() + { + DoAddComponent(); + + Finish(); + } + + public override void OnExit() + { + if (removeOnExit.Value && addedComponent != null) + { + Object.Destroy(addedComponent); + } + } + + void DoAddComponent() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + addedComponent = go.AddComponent(ReflectionUtils.GetGlobalType(component.Value)); + + storeComponent.Value = addedComponent; + + if (addedComponent == null) + { + LogError("Can't add component: " + component.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AddComponent.cs.meta b/Assets/PlayMaker/Actions/AddComponent.cs.meta new file mode 100755 index 0000000..1932de5 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3a349bb54b28fb44899ea4c1539a9192 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AddExplosionForce.cs b/Assets/PlayMaker/Actions/AddExplosionForce.cs new file mode 100755 index 0000000..bec2ee7 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddExplosionForce.cs @@ -0,0 +1,77 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Applies a force to a Game Object that simulates explosion effects. The explosion force will fall off linearly with distance. Hint: Use the Explosion Action instead to apply an explosion force to all objects in a blast radius.")] + public class AddExplosionForce : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + [Tooltip("The GameObject to add the explosion force to.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The center of the explosion. Hint: this is often the position returned from a GetCollisionInfo action.")] + public FsmVector3 center; + + [RequiredField] + [Tooltip("The strength of the explosion.")] + public FsmFloat force; + + [RequiredField] + [Tooltip("The radius of the explosion. Force falls off linearly with distance.")] + public FsmFloat radius; + + [Tooltip("Applies the force as if it was applied from beneath the object. This is useful since explosions that throw things up instead of pushing things to the side look cooler. A value of 2 will apply a force as if it is applied from 2 meters below while not changing the actual explosion position.")] + public FsmFloat upwardsModifier; + + [Tooltip("The type of force to apply. See Unity Physics docs.")] + public ForceMode forceMode; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + center = new FsmVector3 { UseVariable = true }; + upwardsModifier = 0f; + forceMode = ForceMode.Force; + everyFrame = false; + } + + public override void OnPreprocess() + { + Fsm.HandleFixedUpdate = true; + } + + public override void OnEnter() + { + DoAddExplosionForce(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnFixedUpdate() + { + DoAddExplosionForce(); + } + + void DoAddExplosionForce() + { + var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; + if (center == null || !UpdateCache(go)) + { + return; + } + + rigidbody.AddExplosionForce(force.Value, center.Value, radius.Value, upwardsModifier.Value, forceMode); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AddExplosionForce.cs.meta b/Assets/PlayMaker/Actions/AddExplosionForce.cs.meta new file mode 100755 index 0000000..7166956 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddExplosionForce.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4646286250465e744b99a313370fda17 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AddForce.cs b/Assets/PlayMaker/Actions/AddForce.cs new file mode 100755 index 0000000..172094e --- /dev/null +++ b/Assets/PlayMaker/Actions/AddForce.cs @@ -0,0 +1,111 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Adds a force to a Game Object. Use Vector3 variable and/or Float variables for each axis.")] + public class AddForce : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + [Tooltip("The GameObject to apply the force to.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [Tooltip("Optionally apply the force at a position on the object. This will also add some torque. The position is often returned from MousePick or GetCollisionInfo actions.")] + public FsmVector3 atPosition; + + [UIHint(UIHint.Variable)] + [Tooltip("A Vector3 force to add. Optionally override any axis with the X, Y, Z parameters.")] + public FsmVector3 vector; + + [Tooltip("Force along the X axis. To leave unchanged, set to 'None'.")] + public FsmFloat x; + + [Tooltip("Force along the Y axis. To leave unchanged, set to 'None'.")] + public FsmFloat y; + + [Tooltip("Force along the Z axis. To leave unchanged, set to 'None'.")] + public FsmFloat z; + + [Tooltip("Apply the force in world or local space.")] + public Space space; + + [Tooltip("The type of force to apply. See Unity Physics docs.")] + public ForceMode forceMode; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + atPosition = new FsmVector3 { UseVariable = true }; + vector = null; + // default axis to variable dropdown with None selected. + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + z = new FsmFloat { UseVariable = true }; + space = Space.World; + forceMode = ForceMode.Force; + everyFrame = false; + } + + public override void OnPreprocess() + { + Fsm.HandleFixedUpdate = true; + } + + public override void OnEnter() + { + DoAddForce(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnFixedUpdate() + { + DoAddForce(); + } + + void DoAddForce() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + var force = vector.IsNone ? new Vector3() : vector.Value; + + // override any axis + + if (!x.IsNone) force.x = x.Value; + if (!y.IsNone) force.y = y.Value; + if (!z.IsNone) force.z = z.Value; + + // apply force + + if (space == Space.World) + { + if (!atPosition.IsNone) + { + rigidbody.AddForceAtPosition(force, atPosition.Value, forceMode); + } + else + { + rigidbody.AddForce(force, forceMode); + } + } + else + { + rigidbody.AddRelativeForce(force,forceMode); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AddForce.cs.meta b/Assets/PlayMaker/Actions/AddForce.cs.meta new file mode 100755 index 0000000..0340bf1 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddForce.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 58ff055ba918aaa48b2f142ed5b7a00e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AddMixingTransform.cs b/Assets/PlayMaker/Actions/AddMixingTransform.cs new file mode 100755 index 0000000..0dea52e --- /dev/null +++ b/Assets/PlayMaker/Actions/AddMixingTransform.cs @@ -0,0 +1,66 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Play an animation on a subset of the hierarchy. E.g., A waving animation on the upper body.")] + public class AddMixingTransform : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("The GameObject playing the animation.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The name of the animation to mix. NOTE: The animation should already be added to the Animation Component on the GameObject.")] + public FsmString animationName; + + [RequiredField] + [Tooltip("The mixing transform. E.g., root/upper_body/left_shoulder")] + public FsmString transform; + + [Tooltip("If recursive is true all children of the mix transform will also be animated.")] + public FsmBool recursive; + + public override void Reset() + { + gameObject = null; + animationName = ""; + transform = ""; + recursive = true; + } + + public override void OnEnter() + { + DoAddMixingTransform(); + + Finish(); + } + + void DoAddMixingTransform() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var animation = go.GetComponent(); + if (animation == null) + { + return; + } + + var animClip = animation[animationName.Value]; + if (animClip == null) + { + return; + } + + var mixingTransform = go.transform.Find(transform.Value); + animClip.AddMixingTransform(mixingTransform, recursive.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AddMixingTransform.cs.meta b/Assets/PlayMaker/Actions/AddMixingTransform.cs.meta new file mode 100755 index 0000000..b81d3b9 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddMixingTransform.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6cff7a6b1eb9d840aac5db6552a2780 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AddScript.cs b/Assets/PlayMaker/Actions/AddScript.cs new file mode 100755 index 0000000..8c28aca --- /dev/null +++ b/Assets/PlayMaker/Actions/AddScript.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.ScriptControl)] + [Tooltip("Adds a Script to a Game Object. Use this to change the behaviour of objects on the fly. Optionally remove the Script on exiting the state.")] + public class AddScript : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to add the script to.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The Script to add to the GameObject.")] + [UIHint(UIHint.ScriptComponent)] + public FsmString script; + + [Tooltip("Remove the script from the GameObject when this State is exited.")] + public FsmBool removeOnExit; + + Component addedComponent; + + public override void Reset() + { + gameObject = null; + script = null; + } + + public override void OnEnter() + { + DoAddComponent(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + + Finish(); + } + + public override void OnExit() + { + if (removeOnExit.Value) + { + if (addedComponent != null) + { + Object.Destroy(addedComponent); + } + } + } + + void DoAddComponent(GameObject go) + { + addedComponent = go.AddComponent(ReflectionUtils.GetGlobalType(script.Value)); + + if (addedComponent == null) + { + LogError("Can't add script: " + script.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AddScript.cs.meta b/Assets/PlayMaker/Actions/AddScript.cs.meta new file mode 100755 index 0000000..f10e4dc --- /dev/null +++ b/Assets/PlayMaker/Actions/AddScript.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3963d96ed74c6f647897199a48079bfa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AddTorque.cs b/Assets/PlayMaker/Actions/AddTorque.cs new file mode 100755 index 0000000..077493d --- /dev/null +++ b/Assets/PlayMaker/Actions/AddTorque.cs @@ -0,0 +1,100 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Adds torque (rotational force) to a Game Object.")] + public class AddTorque : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + [Tooltip("The GameObject to add torque to.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [Tooltip("A Vector3 torque. Optionally override any axis with the X, Y, Z parameters.")] + public FsmVector3 vector; + + [Tooltip("Torque around the X axis. To leave unchanged, set to 'None'.")] + public FsmFloat x; + + [Tooltip("Torque around the Y axis. To leave unchanged, set to 'None'.")] + public FsmFloat y; + + [Tooltip("Torque around the Z axis. To leave unchanged, set to 'None'.")] + public FsmFloat z; + + [Tooltip("Apply the force in world or local space.")] + public Space space; + + [Tooltip("The type of force to apply. See Unity Physics docs.")] + public ForceMode forceMode; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + // default axis to variable dropdown with None selected. + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + z = new FsmFloat { UseVariable = true }; + space = Space.World; + forceMode = ForceMode.Force; + everyFrame = false; + } + + public override void OnPreprocess() + { + Fsm.HandleFixedUpdate = true; + } + + public override void OnEnter() + { + DoAddTorque(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnFixedUpdate() + { + DoAddTorque(); + } + + void DoAddTorque() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + var torque = vector.IsNone ? new Vector3(x.Value, y.Value, z.Value) : vector.Value; + + // override any axis + + if (!x.IsNone) torque.x = x.Value; + if (!y.IsNone) torque.y = y.Value; + if (!z.IsNone) torque.z = z.Value; + + // apply + + if (space == Space.World) + { + rigidbody.AddTorque(torque, forceMode); + } + else + { + rigidbody.AddRelativeTorque(torque, forceMode); + } + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AddTorque.cs.meta b/Assets/PlayMaker/Actions/AddTorque.cs.meta new file mode 100755 index 0000000..9190d74 --- /dev/null +++ b/Assets/PlayMaker/Actions/AddTorque.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d610dcc6fcb188943808607777423c4f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateFloat.cs b/Assets/PlayMaker/Actions/AnimateFloat.cs new file mode 100755 index 0000000..a2474c0 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateFloat.cs @@ -0,0 +1,94 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.AnimateVariables)] + [Tooltip("Animates the value of a Float Variable using an Animation Curve.")] + public class AnimateFloat : FsmStateAction + { + [RequiredField] + [Tooltip("The animation curve to use.")] + public FsmAnimationCurve animCurve; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The float variable to set.")] + public FsmFloat floatVariable; + + [Tooltip("Optionally send an Event when the animation finishes.")] + public FsmEvent finishEvent; + + [Tooltip("Ignore TimeScale. Useful if the game is paused.")] + public bool realTime; + + private float startTime; + private float currentTime; + private float endTime; + private bool looping; + + public override void Reset() + { + animCurve = null; + floatVariable = null; + finishEvent = null; + realTime = false; + } + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + currentTime = 0f; + + if (animCurve != null && animCurve.curve != null && animCurve.curve.keys.Length > 0) + { + endTime = animCurve.curve.keys[animCurve.curve.length-1].time; + looping = ActionHelpers.IsLoopingWrapMode(animCurve.curve.postWrapMode); + } + else + { + Finish(); + return; + } + + floatVariable.Value = animCurve.curve.Evaluate(0); + } + + public override void OnUpdate() + { + // update time + + if (realTime) + { + currentTime = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + currentTime += Time.deltaTime; + } + + // update animation + + if (animCurve != null && animCurve.curve != null && floatVariable != null) + { + floatVariable.Value = animCurve.curve.Evaluate(currentTime); + } + + // send finish event + + if (currentTime >= endTime) + { + if (!looping) + { + Finish(); + } + + if (finishEvent != null) + { + Fsm.Event(finishEvent); + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateFloat.cs.meta b/Assets/PlayMaker/Actions/AnimateFloat.cs.meta new file mode 100755 index 0000000..54694ff --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5e775993337e0034e97e098d6575306c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables.meta b/Assets/PlayMaker/Actions/AnimateVariables.meta new file mode 100644 index 0000000..f5446d3 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 29c6cffa3711b4662b2d07f21c708ed0 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateColor.cs b/Assets/PlayMaker/Actions/AnimateVariables/AnimateColor.cs new file mode 100755 index 0000000..3bdff0b --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateColor.cs @@ -0,0 +1,112 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.AnimateVariables)] + [Tooltip("Animates the value of a Color Variable using an Animation Curve.")] + public class AnimateColor : AnimateFsmAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmColor colorVariable; + + [RequiredField] + public FsmAnimationCurve curveR; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to colorVariable.r.")] + public Calculation calculationR; + + [RequiredField] + public FsmAnimationCurve curveG; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to colorVariable.g.")] + public Calculation calculationG; + + [RequiredField] + public FsmAnimationCurve curveB; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to colorVariable.b.")] + public Calculation calculationB; + + [RequiredField] + public FsmAnimationCurve curveA; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to colorVariable.a.")] + public Calculation calculationA; + + private bool finishInNextStep; + + public override void Reset() + { + base.Reset(); + colorVariable = new FsmColor{UseVariable=true}; + } + + public override void OnEnter() + { + base.OnEnter(); + + finishInNextStep = false; + resultFloats = new float[4]; + fromFloats = new float[4]; + fromFloats[0] = colorVariable.IsNone ? 0f : colorVariable.Value.r; + fromFloats[1] = colorVariable.IsNone ? 0f : colorVariable.Value.g; + fromFloats[2] = colorVariable.IsNone ? 0f : colorVariable.Value.b; + fromFloats[3] = colorVariable.IsNone ? 0f : colorVariable.Value.a; + curves = new AnimationCurve[4]; + curves[0] = curveR.curve; + curves[1] = curveG.curve; + curves[2] = curveB.curve; + curves[3] = curveA.curve; + calculations = new Calculation[4]; + calculations[0] = calculationR; + calculations[1] = calculationG; + calculations[2] = calculationB; + calculations[3] = calculationA; + + Init(); + + // Set initial value + if (Math.Abs(delay.Value) < 0.01f) + { + UpdateVariableValue(); + } + } + + private void UpdateVariableValue() + { + if (!colorVariable.IsNone) + { + colorVariable.Value = new Color(resultFloats[0], resultFloats[1], resultFloats[2], resultFloats[3]); + } + } + + public override void OnUpdate() + { + base.OnUpdate(); + + if(isRunning) + { + UpdateVariableValue(); + } + + if(finishInNextStep) + { + if(!looping) + { + Finish(); + Fsm.Event(finishEvent); + } + } + + if(finishAction && !finishInNextStep) + { + UpdateVariableValue(); + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateColor.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/AnimateColor.cs.meta new file mode 100755 index 0000000..805bdae --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 586d3af17311b5c46ab9ac5d3796b7f8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateFloatV2.cs b/Assets/PlayMaker/Actions/AnimateVariables/AnimateFloatV2.cs new file mode 100755 index 0000000..247f15a --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateFloatV2.cs @@ -0,0 +1,71 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.AnimateVariables)] + [Tooltip("Animates the value of a Float Variable using an Animation Curve.")] + public class AnimateFloatV2: AnimateFsmAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat floatVariable; + [RequiredField] + public FsmAnimationCurve animCurve; + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to floatVariable")] + public Calculation calculation; + + + private bool finishInNextStep = false; + + public override void Reset() + { + base.Reset(); + floatVariable = new FsmFloat{UseVariable=true}; + } + + public override void OnEnter() + { + base.OnEnter(); + finishInNextStep = false; + resultFloats = new float[1]; + fromFloats = new float[1]; + fromFloats[0] = floatVariable.IsNone ? 0f : floatVariable.Value; + calculations = new Calculation[1]; + calculations[0] = calculation; + curves = new AnimationCurve[1]; + curves[0] = animCurve.curve; + //call Init after you have initialized curves array + Init(); + } + + public override void OnExit() + { + + } + + public override void OnUpdate() + { + base.OnUpdate(); + if(!floatVariable.IsNone && isRunning){ + floatVariable.Value = resultFloats[0]; + } + + if(finishInNextStep){ + if(!looping) { + Finish(); + if(finishEvent != null) Fsm.Event(finishEvent); + } + + } + + if(finishAction && !finishInNextStep){ + if(!floatVariable.IsNone){ + floatVariable.Value = resultFloats[0]; + } + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateFloatV2.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/AnimateFloatV2.cs.meta new file mode 100755 index 0000000..fb34574 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateFloatV2.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 746a13fb4786bc247a7248536b9a3890 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateFsmAction.cs b/Assets/PlayMaker/Actions/AnimateVariables/AnimateFsmAction.cs new file mode 100755 index 0000000..982a6da --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateFsmAction.cs @@ -0,0 +1,282 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + /// + /// Base action for AnimateXXX actions + /// + public abstract class AnimateFsmAction : FsmStateAction + { + [Tooltip("Define time to use your curve scaled to be stretched or shrinked.")] + public FsmFloat time; + + [Tooltip("If you define speed, your animation will be speeded up or slowed down.")] + public FsmFloat speed; + + [Tooltip("Delayed animimation start.")] + public FsmFloat delay; + + [Tooltip("Animation curve start from any time. If IgnoreCurveOffset is true the animation starts right after the state become entered.")] + public FsmBool ignoreCurveOffset; + + [Tooltip("Optionally send an Event when the animation finishes.")] + public FsmEvent finishEvent; + + [Tooltip("Ignore TimeScale. Useful if the game is paused.")] + public bool realTime; + + private float startTime; + private float currentTime; + private float[] endTimes; + + private float lastTime; + private float deltaTime; + private float delayTime; + private float[] keyOffsets; + + protected AnimationCurve[] curves; + protected Calculation[] calculations; + + protected float[] resultFloats; + protected float[] fromFloats; + protected float[] toFloats; + + protected bool finishAction = false; + protected bool isRunning; + protected bool looping; + private bool start = false; + private float largestEndTime = 0f; + + public enum Calculation{ + None, + SetValue, + AddToValue, + SubtractFromValue, + SubtractValueFromCurve, + MultiplyValue, + DivideValue, + DivideCurveByValue, + } + + public override void Reset() + { + finishEvent = null; + realTime = false; + time = new FsmFloat { UseVariable = true }; + speed = new FsmFloat { UseVariable = true }; + delay = new FsmFloat { UseVariable = true }; + ignoreCurveOffset = new FsmBool{ Value = true}; + resultFloats = new float[0]; + fromFloats = new float[0]; + toFloats = new float[0]; + endTimes = new float[0]; + keyOffsets = new float[0]; + curves = new AnimationCurve[0]; + finishAction = false; + start = false; + } + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + deltaTime = 0f; + currentTime = 0f; + isRunning = false; + finishAction = false; + looping = false; + delayTime = delay.IsNone ? 0f : delayTime = delay.Value; + start = true; + } + + protected void Init() + { + endTimes = new float[curves.Length]; + keyOffsets = new float[curves.Length]; + largestEndTime = 0f; + for(int i = 0; i 0) + { + keyOffsets[i] = curves[i].keys.Length > 0 ? (time.IsNone ? curves[i].keys[0].time : (time.Value/curves[i].keys[curves[i].length-1].time)*curves[i].keys[0].time) : 0f; + currentTime = ignoreCurveOffset.IsNone ? 0f : (ignoreCurveOffset.Value ? keyOffsets[i] : 0f); + if(!time.IsNone) endTimes[i] = time.Value; + else endTimes[i] = curves[i].keys[curves[i].length-1].time; + if(largestEndTime < endTimes[i]) largestEndTime = endTimes[i]; + if(!looping) looping = ActionHelpers.IsLoopingWrapMode(curves[i].postWrapMode); + } + else + { + endTimes[i] = -1f; + } + } + for(int i = 0; i 0f && endTimes[i] == -1f) endTimes[i] = largestEndTime; + else { + if(largestEndTime == 0f && endTimes[i] == -1f) + { + if(time.IsNone) endTimes[i] = 1f; + else endTimes[i] = time.Value; + } + } + } + + // set initial result value + UpdateAnimation(); + } + + public override void OnUpdate() + { + CheckStart(); + + if(isRunning) + { + UpdateTime(); + UpdateAnimation(); + CheckFinished(); + } + } + + private void CheckStart() + { + if (!isRunning && start) + { + if (delayTime >= 0) + { + if (realTime) + { + deltaTime = (FsmTime.RealtimeSinceStartup - startTime) - lastTime; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + delayTime -= deltaTime; + } + else + { + delayTime -= Time.deltaTime; + } + } + else + { + isRunning = true; + start = false; + } + } + } + + private void UpdateTime() + { + if (realTime) + { + deltaTime = (FsmTime.RealtimeSinceStartup - startTime) - lastTime; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + + if (!speed.IsNone) currentTime += deltaTime*speed.Value; + else currentTime += deltaTime; + } + else + { + if (!speed.IsNone) currentTime += Time.deltaTime*speed.Value; + else currentTime += Time.deltaTime; + } + } + + public void UpdateAnimation() + { + for (var k = 0; k < curves.Length; k++) + { + if (curves[k] != null && curves[k].keys.Length > 0) + { + if (calculations[k] != AnimateFsmAction.Calculation.None) + { + switch (calculations[k]) + { + case Calculation.SetValue: + if (!time.IsNone) + resultFloats[k] = + curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length - 1].time); + else resultFloats[k] = curves[k].Evaluate(currentTime); + break; + case Calculation.AddToValue: + if (!time.IsNone) + resultFloats[k] = fromFloats[k] + + curves[k].Evaluate((currentTime/time.Value)* + curves[k].keys[curves[k].length - 1].time); + else resultFloats[k] = fromFloats[k] + curves[k].Evaluate(currentTime); + break; + case Calculation.SubtractFromValue: + if (!time.IsNone) + resultFloats[k] = fromFloats[k] - + curves[k].Evaluate((currentTime/time.Value)* + curves[k].keys[curves[k].length - 1].time); + else resultFloats[k] = fromFloats[k] - curves[k].Evaluate(currentTime); + break; + case Calculation.SubtractValueFromCurve: + if (!time.IsNone) + resultFloats[k] = + curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length - 1].time) - + fromFloats[k]; + else resultFloats[k] = curves[k].Evaluate(currentTime) - fromFloats[k]; + break; + case Calculation.MultiplyValue: + if (!time.IsNone) + resultFloats[k] = + curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length - 1].time)* + fromFloats[k]; + else resultFloats[k] = curves[k].Evaluate(currentTime)*fromFloats[k]; + break; + case Calculation.DivideValue: + if (!time.IsNone) + resultFloats[k] = + curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length - 1].time) != + 0f + ? fromFloats[k]/ + curves[k].Evaluate((currentTime/time.Value)* + curves[k].keys[curves[k].length - 1].time) + : float.MaxValue; + else + resultFloats[k] = curves[k].Evaluate(currentTime) != 0 + ? fromFloats[k]/curves[k].Evaluate(currentTime) + : float.MaxValue; + break; + case Calculation.DivideCurveByValue: + if (!time.IsNone) + resultFloats[k] = fromFloats[k] != 0f + ? curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length - 1].time)/ + fromFloats[k] + : float.MaxValue; + else + resultFloats[k] = fromFloats[k] != 0 + ? curves[k].Evaluate(currentTime)/fromFloats[k] + : float.MaxValue; + break; + } + } + else + { + resultFloats[k] = fromFloats[k]; + } + } + else + { + resultFloats[k] = fromFloats[k]; + } + } + } + + private void CheckFinished() + { + if (isRunning && !looping) + { + finishAction = true; + for (int i = 0; i < endTimes.Length; i++) + { + //Debug.Log(i.ToString() + "| " +endTimes[i].ToString() + " " + currentTime.ToString()); + if (currentTime < endTimes[i]) finishAction = false; + } + isRunning = !finishAction; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateFsmAction.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/AnimateFsmAction.cs.meta new file mode 100755 index 0000000..fd32fda --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateFsmAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b94df5cd261931745bcc35e1aa451330 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateRect.cs b/Assets/PlayMaker/Actions/AnimateVariables/AnimateRect.cs new file mode 100755 index 0000000..aca9e61 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateRect.cs @@ -0,0 +1,114 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("AnimateVariables")] + [Tooltip("Animates the value of a Rect Variable using an Animation Curve.")] + public class AnimateRect : AnimateFsmAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmRect rectVariable; + + [RequiredField] + public FsmAnimationCurve curveX; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to rectVariable.x.")] + public Calculation calculationX; + + [RequiredField] + public FsmAnimationCurve curveY; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to rectVariable.y.")] + public Calculation calculationY; + + [RequiredField] + public FsmAnimationCurve curveW; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to rectVariable.width.")] + public Calculation calculationW; + + [RequiredField] + public FsmAnimationCurve curveH; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to rectVariable.height.")] + public Calculation calculationH; + + private bool finishInNextStep; + + public override void Reset() + { + base.Reset(); + + rectVariable = new FsmRect{UseVariable=true}; + } + + public override void OnEnter() + { + base.OnEnter(); + + finishInNextStep = false; + resultFloats = new float[4]; + fromFloats = new float[4]; + fromFloats[0] = rectVariable.IsNone ? 0f : rectVariable.Value.x; + fromFloats[1] = rectVariable.IsNone ? 0f : rectVariable.Value.y; + fromFloats[2] = rectVariable.IsNone ? 0f : rectVariable.Value.width; + fromFloats[3] = rectVariable.IsNone ? 0f : rectVariable.Value.height; + curves = new AnimationCurve[4]; + curves[0] = curveX.curve; + curves[1] = curveY.curve; + curves[2] = curveW.curve; + curves[3] = curveH.curve; + calculations = new Calculation[4]; + calculations[0] = calculationX; + calculations[1] = calculationY; + calculations[2] = calculationW; + calculations[3] = calculationH; + + Init(); + + if (Math.Abs(delay.Value) < 0.01f) + { + UpdateVariableValue(); + } + + } + + private void UpdateVariableValue() + { + if (!rectVariable.IsNone) + { + rectVariable.Value = new Rect(resultFloats[0], resultFloats[1], resultFloats[2], resultFloats[3]); + } + } + + public override void OnUpdate() + { + base.OnUpdate(); + + if (isRunning) + { + UpdateVariableValue(); + } + + + if (finishInNextStep) + { + if(!looping) + { + Finish(); + Fsm.Event(finishEvent); + } + } + + if(finishAction && !finishInNextStep) + { + UpdateVariableValue(); + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateRect.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/AnimateRect.cs.meta new file mode 100755 index 0000000..a56808e --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateRect.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4683a6d913750504f830330947fddac8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateVector3.cs b/Assets/PlayMaker/Actions/AnimateVariables/AnimateVector3.cs new file mode 100755 index 0000000..4ecfed0 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateVector3.cs @@ -0,0 +1,104 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.AnimateVariables)] + [Tooltip("Animates the value of a Vector3 Variable using an Animation Curve.")] + public class AnimateVector3 : AnimateFsmAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vectorVariable; + + [RequiredField] + public FsmAnimationCurve curveX; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to vectorVariable.x.")] + public Calculation calculationX; + + [RequiredField] + public FsmAnimationCurve curveY; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to vectorVariable.y.")] + public Calculation calculationY; + + [RequiredField] + public FsmAnimationCurve curveZ; + + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to vectorVariable.z.")] + public Calculation calculationZ; + + private bool finishInNextStep; + + public override void Reset() + { + base.Reset(); + vectorVariable = new FsmVector3{UseVariable=true}; + } + + public override void OnEnter() + { + base.OnEnter(); + + finishInNextStep = false; + resultFloats = new float[3]; + fromFloats = new float[3]; + fromFloats[0] = vectorVariable.IsNone ? 0f : vectorVariable.Value.x; + fromFloats[1] = vectorVariable.IsNone ? 0f : vectorVariable.Value.y; + fromFloats[2] = vectorVariable.IsNone ? 0f : vectorVariable.Value.z; + curves = new AnimationCurve[3]; + curves[0] = curveX.curve; + curves[1] = curveY.curve; + curves[2] = curveZ.curve; + calculations = new Calculation[3]; + calculations[0] = calculationX; + calculations[1] = calculationY; + calculations[2] = calculationZ; + + Init(); + + // Set initial value + if (Math.Abs(delay.Value) < 0.01f) + { + UpdateVariableValue(); + } + } + + private void UpdateVariableValue() + { + if (!vectorVariable.IsNone) + { + vectorVariable.Value = new Vector3(resultFloats[0], resultFloats[1], resultFloats[2]); + } + } + + public override void OnUpdate() + { + base.OnUpdate(); + + if(isRunning) + { + UpdateVariableValue(); + } + + if(finishInNextStep) + { + if(!looping) + { + Finish(); + Fsm.Event(finishEvent); + } + + } + + if(finishAction && !finishInNextStep) + { + UpdateVariableValue(); + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/AnimateVector3.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/AnimateVector3.cs.meta new file mode 100755 index 0000000..bbc30f9 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/AnimateVector3.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 096d312d970839340bb0b73993a5217e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/CurveColor.cs b/Assets/PlayMaker/Actions/AnimateVariables/CurveColor.cs new file mode 100755 index 0000000..57a594b --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/CurveColor.cs @@ -0,0 +1,109 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.AnimateVariables)] + [Tooltip("Animates the value of a Color Variable FROM-TO with assistance of Deformation Curves.")] + public class CurveColor: CurveFsmAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmColor colorVariable; + [RequiredField] + public FsmColor fromValue; + [RequiredField] + public FsmColor toValue; + [RequiredField] + public FsmAnimationCurve curveR; + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to otherwise linear move between fromValue.Red and toValue.Rec.")] + public Calculation calculationR; + [RequiredField] + public FsmAnimationCurve curveG; + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to otherwise linear move between fromValue.Green and toValue.Green.")] + public Calculation calculationG; + [RequiredField] + public FsmAnimationCurve curveB; + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to otherwise linear move between fromValue.Blue and toValue.Blue.")] + public Calculation calculationB; + [RequiredField] + public FsmAnimationCurve curveA; + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to otherwise linear move between fromValue.Alpha and toValue.Alpha.")] + public Calculation calculationA; + + + Color clr; + + private bool finishInNextStep = false; + + public override void Reset() + { + base.Reset(); + + colorVariable = new FsmColor{UseVariable=true}; + toValue = new FsmColor{UseVariable=true}; + fromValue = new FsmColor{UseVariable=true}; + } + + public override void OnEnter() + { + base.OnEnter(); + finishInNextStep = false; + resultFloats = new float[4]; + fromFloats = new float[4]; + fromFloats[0] = fromValue.IsNone ? 0f : fromValue.Value.r; + fromFloats[1] = fromValue.IsNone ? 0f : fromValue.Value.g; + fromFloats[2] = fromValue.IsNone ? 0f : fromValue.Value.b; + fromFloats[3] = fromValue.IsNone ? 0f : fromValue.Value.a; + toFloats = new float[4]; + toFloats[0] = toValue.IsNone ? 0f : toValue.Value.r; + toFloats[1] = toValue.IsNone ? 0f : toValue.Value.g; + toFloats[2] = toValue.IsNone ? 0f : toValue.Value.b; + toFloats[3] = toValue.IsNone ? 0f : toValue.Value.a; + + curves = new AnimationCurve[4]; + curves[0] = curveR.curve; + curves[1] = curveG.curve; + curves[2] = curveB.curve; + curves[3] = curveA.curve; + calculations = new Calculation[4]; + calculations[0] = calculationR; + calculations[1] = calculationG; + calculations[2] = calculationB; + calculations[3] = calculationA; + //call Init after you have initialized curves array + Init(); + } + + public override void OnExit() + { + + } + + public override void OnUpdate() + { + base.OnUpdate(); + if(!colorVariable.IsNone && isRunning){ + clr = new Color(resultFloats[0], resultFloats[1], resultFloats[2], resultFloats[3]); + colorVariable.Value = clr; + } + + if(finishInNextStep){ + if(!looping) { + Finish(); + if(finishEvent != null) Fsm.Event(finishEvent); + } + + } + + if(finishAction && !finishInNextStep){ + if(!colorVariable.IsNone){ + clr = new Color(resultFloats[0], resultFloats[1], resultFloats[2], resultFloats[3]); + colorVariable.Value = clr; + } + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/CurveColor.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/CurveColor.cs.meta new file mode 100755 index 0000000..70d0192 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/CurveColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2b5ecf704915e1c47a236d3a9e13e1d8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/CurveFloat.cs b/Assets/PlayMaker/Actions/AnimateVariables/CurveFloat.cs new file mode 100755 index 0000000..91f4d99 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/CurveFloat.cs @@ -0,0 +1,79 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.AnimateVariables)] + [Tooltip("Animates the value of a Float Variable FROM-TO with assistance of Deformation Curve.")] + public class CurveFloat: CurveFsmAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat floatVariable; + [RequiredField] + public FsmFloat fromValue; + [RequiredField] + public FsmFloat toValue; + [RequiredField] + public FsmAnimationCurve animCurve; + [Tooltip("Calculation lets you set a type of curve deformation that will be applied to otherwise linear move between fromValue and toValue.")] + public Calculation calculation; + + + private bool finishInNextStep = false; + + public override void Reset() + { + base.Reset(); + floatVariable = new FsmFloat{UseVariable=true}; + toValue = new FsmFloat{UseVariable=true}; + fromValue = new FsmFloat{UseVariable=true}; + } + + public override void OnEnter() + { + base.OnEnter(); + finishInNextStep = false; + resultFloats = new float[1]; + fromFloats = new float[1]; + fromFloats[0] = fromValue.IsNone ? 0f : fromValue.Value; + toFloats = new float[1]; + toFloats[0] = toValue.IsNone ? 0f : toValue.Value; + calculations = new Calculation[1]; + calculations[0] = calculation; + curves = new AnimationCurve[1]; + curves[0] = animCurve.curve; + //call Init after you have initialized curves array + Init(); + } + + public override void OnExit() + { + + } + + public override void OnUpdate() + { + base.OnUpdate(); + if(!floatVariable.IsNone && isRunning){ + floatVariable.Value = resultFloats[0]; + } + + if(finishInNextStep){ + if(!looping) { + Finish(); + if(finishEvent != null) Fsm.Event(finishEvent); + } + + } + + if(finishAction && !finishInNextStep){ + if(!floatVariable.IsNone){ + floatVariable.Value = resultFloats[0]; + } + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/CurveFloat.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/CurveFloat.cs.meta new file mode 100755 index 0000000..f1306a6 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/CurveFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8df028d2f13f5914482be2a14d98f4b6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/CurveFsmAction.cs b/Assets/PlayMaker/Actions/AnimateVariables/CurveFsmAction.cs new file mode 100755 index 0000000..16b86db --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/CurveFsmAction.cs @@ -0,0 +1,220 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + + [Tooltip("Animate base action - DON'T USE IT!")] + public abstract class CurveFsmAction : FsmStateAction + { + [Tooltip("Define time to use your curve scaled to be stretched or shrinked.")] + public FsmFloat time; + [Tooltip("If you define speed, your animation will be speeded up or slowed down.")] + public FsmFloat speed; + [Tooltip("Delayed animimation start.")] + public FsmFloat delay; + [Tooltip("Animation curve start from any time. If IgnoreCurveOffset is true the animation starts right after the state become entered.")] + public FsmBool ignoreCurveOffset; + [Tooltip("Optionally send an Event when the animation finishes.")] + public FsmEvent finishEvent; + [Tooltip("Ignore TimeScale. Useful if the game is paused.")] + public bool realTime; + + private float startTime; + private float currentTime; + private float[] endTimes; + + private float lastTime; + private float deltaTime; + private float delayTime; + private float[] keyOffsets; + + protected AnimationCurve[] curves; + protected Calculation[] calculations; + + protected float[] resultFloats; + protected float[] fromFloats; + protected float[] toFloats; + private float[] distances; + + protected bool finishAction = false; + protected bool isRunning; + protected bool looping; + private bool start = false; + private float largestEndTime = 0f; + + public enum Calculation{ + None, + AddToValue, + SubtractFromValue, + SubtractValueFromCurve, + MultiplyValue, + DivideValue, + DivideCurveByValue, + } + + public override void Reset() + { + finishEvent = null; + realTime = false; + time = new FsmFloat { UseVariable = true }; + speed = new FsmFloat { UseVariable = true }; + delay = new FsmFloat { UseVariable = true }; + ignoreCurveOffset = new FsmBool{ Value = true}; + resultFloats = new float[0]; + fromFloats = new float[0]; + toFloats = new float[0]; + distances = new float[0]; + endTimes = new float[0]; + keyOffsets = new float[0]; + curves = new AnimationCurve[0]; + finishAction = false; + start = false; + } + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + deltaTime = 0f; + currentTime = 0f; + isRunning = false; + finishAction = false; + looping = false; + delayTime = delay.IsNone ? 0f : delayTime = delay.Value; + start = true; + } + + protected void Init(){ + endTimes = new float[curves.Length]; + keyOffsets = new float[curves.Length]; + largestEndTime = 0f; + for(int i = 0; i 0) + { + keyOffsets[i] = curves[i].keys.Length > 0 ? (time.IsNone ? curves[i].keys[0].time : (time.Value/curves[i].keys[curves[i].length-1].time)*curves[i].keys[0].time) : 0f; + currentTime = ignoreCurveOffset.IsNone ? 0f : (ignoreCurveOffset.Value ? keyOffsets[i] : 0f); + if(!time.IsNone) endTimes[i] = time.Value; + else endTimes[i] = curves[i].keys[curves[i].length-1].time; + if(largestEndTime < endTimes[i]) largestEndTime = endTimes[i]; + if(!looping) looping = ActionHelpers.IsLoopingWrapMode(curves[i].postWrapMode); + } else { + endTimes[i] = -1f; + } + } + for(int i = 0; i 0f && endTimes[i] == -1f) endTimes[i] = largestEndTime; + else { + if(largestEndTime == 0f && endTimes[i] == -1f) { + if(time.IsNone) endTimes[i] = 1f; + else endTimes[i] = time.Value; + } + } + } + distances = new float[fromFloats.Length]; + for(int i = 0; i= 0) { + if(realTime){ + deltaTime = (FsmTime.RealtimeSinceStartup - startTime) - lastTime; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + delayTime -= deltaTime; + } else { + delayTime -= Time.deltaTime; + } + } else { + isRunning = true; + start = false; + startTime = FsmTime.RealtimeSinceStartup; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + } + } + + if(isRunning && !finishAction){ + if (realTime) + { + deltaTime = (FsmTime.RealtimeSinceStartup - startTime) - lastTime; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + + if(!speed.IsNone) currentTime += deltaTime*speed.Value; + else currentTime += deltaTime; + } + else + { + if(!speed.IsNone) currentTime += Time.deltaTime*speed.Value; + else currentTime += Time.deltaTime; + } + + // update animation + for(var k = 0; k 0) + { + if(calculations[k] != CurveFsmAction.Calculation.None){ + switch(calculations[k]){ + case Calculation.AddToValue: + if(!time.IsNone) resultFloats[k] = fromFloats[k] + (distances[k]*(currentTime/time.Value) + curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length-1].time)); + else resultFloats[k] = fromFloats[k] + (distances[k]*(currentTime/endTimes[k]) + curves[k].Evaluate(currentTime)); + break; + case Calculation.SubtractFromValue: + if(!time.IsNone) resultFloats[k] = fromFloats[k] + (distances[k]*(currentTime/time.Value) - curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length-1].time)); + else resultFloats[k] = fromFloats[k] + (distances[k]*(currentTime/endTimes[k]) - curves[k].Evaluate(currentTime)); + break; + case Calculation.SubtractValueFromCurve: + if(!time.IsNone) resultFloats[k] = (curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length-1].time) - distances[k]*(currentTime/time.Value)) + fromFloats[k]; + else resultFloats[k] = (curves[k].Evaluate(currentTime) - distances[k]*(currentTime/endTimes[k])) + fromFloats[k]; + break; + case Calculation.MultiplyValue: + if(!time.IsNone) resultFloats[k] = (curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length-1].time) * distances[k]*(currentTime/time.Value)) + fromFloats[k]; + else resultFloats[k] = (curves[k].Evaluate(currentTime) * distances[k]*(currentTime/endTimes[k])) + fromFloats[k]; + break; + case Calculation.DivideValue : + if(!time.IsNone) resultFloats[k] = curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length-1].time) != 0f + ? fromFloats[k]+ (distances[k]*(currentTime/time.Value))/curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length-1].time) : float.MaxValue; + else resultFloats[k] = curves[k].Evaluate(currentTime) != 0 + ? fromFloats[k] + (distances[k]*(currentTime/endTimes[k]))/curves[k].Evaluate(currentTime) : float.MaxValue; + break; + case Calculation.DivideCurveByValue : + if(!time.IsNone) resultFloats[k] = fromFloats[k] != 0f + ? curves[k].Evaluate((currentTime/time.Value)*curves[k].keys[curves[k].length-1].time)/(distances[k]*(currentTime/time.Value)) + fromFloats[k] : float.MaxValue; + else resultFloats[k] = fromFloats[k] != 0 + ? curves[k].Evaluate(currentTime)/(distances[k]*(currentTime/endTimes[k])) + fromFloats[k] : float.MaxValue; + break; + } + } else { + //Linear interpolation between color components + if(!time.IsNone) resultFloats[k] = (fromFloats[k] + distances[k]*(currentTime/time.Value)); + else resultFloats[k] = (fromFloats[k] + distances[k]*(currentTime/endTimes[k])); + } + } else { + if(!time.IsNone) resultFloats[k] = (fromFloats[k] + distances[k]*(currentTime/time.Value)); + else { + if(largestEndTime == 0f){ + resultFloats[k] = (fromFloats[k] + distances[k]*(currentTime/1f)); + } else { + resultFloats[k] = (fromFloats[k] + distances[k]*(currentTime/largestEndTime)); + } + + } + } + } + + if(isRunning) { + finishAction = true; + for(int i = 0; i= 0) { + if(realTime){ + deltaTime = (FsmTime.RealtimeSinceStartup - startTime) - lastTime; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + delayTime -= deltaTime; + } else { + delayTime -= Time.deltaTime; + } + } else { + isRunning = true; + start= false; + startTime = FsmTime.RealtimeSinceStartup; + lastTime = FsmTime.RealtimeSinceStartup - startTime; + } + } + + if(isRunning && !finished){ + if(!(reverse.IsNone ? false : reverse.Value)){ + UpdatePercentage(); + if(percentage<1f){ + for(int i=0; i0f){ + for(int i=0; i half){ + diff = -((max - end) + start) * value; + retval = start + diff; + }else retval = start + (end - start) * value; + return retval; + } + + protected float spring(float start, float end, float value){ + value = Mathf.Clamp01(value); + value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value))); + return start + (end - start) * value; + } + + protected float easeInQuad(float start, float end, float value){ + end -= start; + return end * value * value + start; + } + + protected float easeOutQuad(float start, float end, float value){ + end -= start; + return -end * value * (value - 2) + start; + } + + protected float easeInOutQuad(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value + start; + value--; + return -end / 2 * (value * (value - 2) - 1) + start; + } + + protected float easeInCubic(float start, float end, float value){ + end -= start; + return end * value * value * value + start; + } + + protected float easeOutCubic(float start, float end, float value){ + value--; + end -= start; + return end * (value * value * value + 1) + start; + } + + protected float easeInOutCubic(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value + start; + value -= 2; + return end / 2 * (value * value * value + 2) + start; + } + + protected float easeInQuart(float start, float end, float value){ + end -= start; + return end * value * value * value * value + start; + } + + protected float easeOutQuart(float start, float end, float value){ + value--; + end -= start; + return -end * (value * value * value * value - 1) + start; + } + + protected float easeInOutQuart(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value * value + start; + value -= 2; + return -end / 2 * (value * value * value * value - 2) + start; + } + + protected float easeInQuint(float start, float end, float value){ + end -= start; + return end * value * value * value * value * value + start; + } + + protected float easeOutQuint(float start, float end, float value){ + value--; + end -= start; + return end * (value * value * value * value * value + 1) + start; + } + + protected float easeInOutQuint(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value * value * value + start; + value -= 2; + return end / 2 * (value * value * value * value * value + 2) + start; + } + + protected float easeInSine(float start, float end, float value){ + end -= start; + return -end * Mathf.Cos(value / 1 * (Mathf.PI / 2)) + end + start; + } + + protected float easeOutSine(float start, float end, float value){ + end -= start; + return end * Mathf.Sin(value / 1 * (Mathf.PI / 2)) + start; + } + + protected float easeInOutSine(float start, float end, float value){ + end -= start; + return -end / 2 * (Mathf.Cos(Mathf.PI * value / 1) - 1) + start; + } + + protected float easeInExpo(float start, float end, float value){ + end -= start; + return end * Mathf.Pow(2, 10 * (value / 1 - 1)) + start; + } + + protected float easeOutExpo(float start, float end, float value){ + end -= start; + return end * (-Mathf.Pow(2, -10 * value / 1) + 1) + start; + } + + protected float easeInOutExpo(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * Mathf.Pow(2, 10 * (value - 1)) + start; + value--; + return end / 2 * (-Mathf.Pow(2, -10 * value) + 2) + start; + } + + protected float easeInCirc(float start, float end, float value){ + end -= start; + return -end * (Mathf.Sqrt(1 - value * value) - 1) + start; + } + + protected float easeOutCirc(float start, float end, float value){ + value--; + end -= start; + return end * Mathf.Sqrt(1 - value * value) + start; + } + + protected float easeInOutCirc(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return -end / 2 * (Mathf.Sqrt(1 - value * value) - 1) + start; + value -= 2; + return end / 2 * (Mathf.Sqrt(1 - value * value) + 1) + start; + } + + protected float bounce(float start, float end, float value){ + value /= 1f; + end -= start; + if (value < (1 / 2.75f)){ + return end * (7.5625f * value * value) + start; + }else if (value < (2 / 2.75f)){ + value -= (1.5f / 2.75f); + return end * (7.5625f * (value) * value + .75f) + start; + }else if (value < (2.5 / 2.75)){ + value -= (2.25f / 2.75f); + return end * (7.5625f * (value) * value + .9375f) + start; + }else{ + value -= (2.625f / 2.75f); + return end * (7.5625f * (value) * value + .984375f) + start; + } + } + + protected float easeInBack(float start, float end, float value){ + end -= start; + value /= 1; + float s = 1.70158f; + return end * (value) * value * ((s + 1) * value - s) + start; + } + + protected float easeOutBack(float start, float end, float value){ + float s = 1.70158f; + end -= start; + value = (value / 1) - 1; + return end * ((value) * value * ((s + 1) * value + s) + 1) + start; + } + + protected float easeInOutBack(float start, float end, float value){ + float s = 1.70158f; + end -= start; + value /= .5f; + if ((value) < 1){ + s *= (1.525f); + return end / 2 * (value * value * (((s) + 1) * value - s)) + start; + } + value -= 2; + s *= (1.525f); + return end / 2 * ((value) * value * (((s) + 1) * value + s) + 2) + start; + } + + protected float punch(float amplitude, float value){ + float s = 9; + if (value == 0){ + return 0; + } + if (value == 1){ + return 0; + } + float period = 1 * 0.3f; + s = period / (2 * Mathf.PI) * Mathf.Asin(0); + return (amplitude * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * 1 - s) * (2 * Mathf.PI) / period)); + } + + protected float elastic(float start, float end, float value){ + //Thank you to rafael.marteleto for fixing this as a port over from Pedro's UnityTween + end -= start; + + float d = 1f; + float p = d * .3f; + float s = 0; + float a = 0; + + if (value == 0) return start; + + if ((value /= d) == 1) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4; + }else{ + s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); + } + + return (a * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) + end + start); + } + + #endregion + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/EaseFsmAction.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/EaseFsmAction.cs.meta new file mode 100755 index 0000000..4324a61 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/EaseFsmAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 652d636e5afe3ee4ebe97f2b8a6db58f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/EaseRect.cs b/Assets/PlayMaker/Actions/AnimateVariables/EaseRect.cs new file mode 100755 index 0000000..fc341df --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/EaseRect.cs @@ -0,0 +1,75 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("AnimateVariables")] + [Tooltip("Easing Animation - Rect.")] + public class EaseRect : EaseFsmAction + { + [RequiredField] + public FsmRect fromValue; + [RequiredField] + public FsmRect toValue; + [UIHint(UIHint.Variable)] + public FsmRect rectVariable; + + private bool finishInNextStep = false; + + public override void Reset (){ + base.Reset(); + rectVariable = null; + fromValue = null; + toValue = null; + finishInNextStep = false; + } + + + public override void OnEnter () + { + base.OnEnter(); + fromFloats = new float[4]; + fromFloats[0] = fromValue.Value.x; + fromFloats[1] = fromValue.Value.y; + fromFloats[2] = fromValue.Value.width; + fromFloats[3] = fromValue.Value.height; + toFloats = new float[4]; + toFloats[0] = toValue.Value.x; + toFloats[1] = toValue.Value.y; + toFloats[2] = toValue.Value.width; + toFloats[3] = toValue.Value.height; + resultFloats = new float[4]; + finishInNextStep = false; + rectVariable.Value = fromValue.Value; + } + + public override void OnExit (){ + base.OnExit(); + } + + public override void OnUpdate(){ + base.OnUpdate(); + if(!rectVariable.IsNone && isRunning){ + rectVariable.Value = new Rect(resultFloats[0],resultFloats[1],resultFloats[2], resultFloats[3]); + } + + if(finishInNextStep){ + Finish(); + if(finishEvent != null) Fsm.Event(finishEvent); + } + + if(finishAction && !finishInNextStep){ + if(!rectVariable.IsNone){ + rectVariable.Value = new Rect(reverse.IsNone ? toValue.Value.x : reverse.Value ? fromValue.Value.x : toValue.Value.x, + reverse.IsNone ? toValue.Value.y : reverse.Value ? fromValue.Value.y : toValue.Value.y, + reverse.IsNone ? toValue.Value.width : reverse.Value ? fromValue.Value.width : toValue.Value.width, + reverse.IsNone ? toValue.Value.height : reverse.Value ? fromValue.Value.height : toValue.Value.height + ); + } + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/EaseRect.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/EaseRect.cs.meta new file mode 100755 index 0000000..dbc15ee --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/EaseRect.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c7149467973e052458a62dbd4dbc91c1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimateVariables/EaseVector3.cs b/Assets/PlayMaker/Actions/AnimateVariables/EaseVector3.cs new file mode 100755 index 0000000..a7d150a --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/EaseVector3.cs @@ -0,0 +1,72 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.AnimateVariables)] + [Tooltip("Easing Animation - Vector3")] + public class EaseVector3 : EaseFsmAction + { + [RequiredField] + public FsmVector3 fromValue; + [RequiredField] + public FsmVector3 toValue; + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + + private bool finishInNextStep = false; + + public override void Reset (){ + base.Reset(); + vector3Variable = null; + fromValue = null; + toValue = null; + finishInNextStep = false; + } + + + public override void OnEnter () + { + base.OnEnter(); + fromFloats = new float[3]; + fromFloats[0] = fromValue.Value.x; + fromFloats[1] = fromValue.Value.y; + fromFloats[2] = fromValue.Value.z; + toFloats = new float[3]; + toFloats[0] = toValue.Value.x; + toFloats[1] = toValue.Value.y; + toFloats[2] = toValue.Value.z; + resultFloats = new float[3]; + finishInNextStep = false; + vector3Variable.Value = fromValue.Value; + } + + public override void OnExit (){ + base.OnExit(); + } + + public override void OnUpdate(){ + base.OnUpdate(); + if(!vector3Variable.IsNone && isRunning){ + vector3Variable.Value = new Vector3(resultFloats[0],resultFloats[1],resultFloats[2]); + } + + if(finishInNextStep){ + Finish(); + if(finishEvent != null) Fsm.Event(finishEvent); + } + + if(finishAction && !finishInNextStep){ + if(!vector3Variable.IsNone){ + vector3Variable.Value = new Vector3(reverse.IsNone ? toValue.Value.x : reverse.Value ? fromValue.Value.x : toValue.Value.x, + reverse.IsNone ? toValue.Value.y : reverse.Value ? fromValue.Value.y : toValue.Value.y, + reverse.IsNone ? toValue.Value.z : reverse.Value ? fromValue.Value.z : toValue.Value.z + ); + } + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimateVariables/EaseVector3.cs.meta b/Assets/PlayMaker/Actions/AnimateVariables/EaseVector3.cs.meta new file mode 100755 index 0000000..499e9fe --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimateVariables/EaseVector3.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 94f53459012912c41aaa91782fd12bb1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnimationSettings.cs b/Assets/PlayMaker/Actions/AnimationSettings.cs new file mode 100755 index 0000000..81c1a75 --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimationSettings.cs @@ -0,0 +1,88 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Set the Wrap Mode, Blend Mode, Layer and Speed of an Animation.\nNOTE: Settings are applied once, on entering the state, NOT continuously. To dynamically control an animation's settings, use Set Animation Speede etc.")] + public class AnimationSettings : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("A GameObject with an Animation Component.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Animation)] + [Tooltip("The name of the animation.")] + public FsmString animName; + + [Tooltip("The behavior of the animation when it wraps.")] + public WrapMode wrapMode; + + [Tooltip("How the animation is blended with other animations on the Game Object.")] + public AnimationBlendMode blendMode; + + [HasFloatSlider(0f, 5f)] + [Tooltip("The speed of the animation. 1 = normal; 2 = double speed...")] + public FsmFloat speed; + + [Tooltip("The animation layer")] + public FsmInt layer; + + public override void Reset() + { + gameObject = null; + animName = null; + wrapMode = WrapMode.Loop; + blendMode = AnimationBlendMode.Blend; + speed = 1.0f; + layer = 0; + } + + public override void OnEnter() + { + DoAnimationSettings(); + + Finish(); + } + + void DoAnimationSettings() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null || string.IsNullOrEmpty(animName.Value)) + { + return; + } + + var animation = go.GetComponent(); + if (animation == null) + { + LogWarning("Missing animation component: " + go.name); + return; + } + + var anim = animation[animName.Value]; + + if (anim == null) + { + LogWarning("Missing animation: " + animName.Value); + return; + } + + anim.wrapMode = wrapMode; + anim.blendMode = blendMode; + + if (!layer.IsNone) + { + anim.layer = layer.Value; + } + + if (!speed.IsNone) + { + anim.speed = speed.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnimationSettings.cs.meta b/Assets/PlayMaker/Actions/AnimationSettings.cs.meta new file mode 100755 index 0000000..be9e5da --- /dev/null +++ b/Assets/PlayMaker/Actions/AnimationSettings.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6f1da104999d6b144b9e1d7cff19f8e9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AnyKey.cs b/Assets/PlayMaker/Actions/AnyKey.cs new file mode 100755 index 0000000..1a0803d --- /dev/null +++ b/Assets/PlayMaker/Actions/AnyKey.cs @@ -0,0 +1,28 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends an Event when the user hits any Key or Mouse Button.")] + public class AnyKey : FsmStateAction + { + [RequiredField] + [Tooltip("Event to send when any Key or Mouse Button is pressed.")] + public FsmEvent sendEvent; + + public override void Reset() + { + sendEvent = null; + } + + public override void OnUpdate() + { + if (Input.anyKeyDown) + { + Fsm.Event(sendEvent); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AnyKey.cs.meta b/Assets/PlayMaker/Actions/AnyKey.cs.meta new file mode 100755 index 0000000..c6709ab --- /dev/null +++ b/Assets/PlayMaker/Actions/AnyKey.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7e2ceb38715ac154487295adaabfd5df +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ApplicationQuit.cs b/Assets/PlayMaker/Actions/ApplicationQuit.cs new file mode 100755 index 0000000..cbfc961 --- /dev/null +++ b/Assets/PlayMaker/Actions/ApplicationQuit.cs @@ -0,0 +1,22 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Application)] + [Tooltip("Quits the player application.")] + public class ApplicationQuit : FsmStateAction + { + public override void Reset() + { + } + + public override void OnEnter() + { + Application.Quit(); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ApplicationQuit.cs.meta b/Assets/PlayMaker/Actions/ApplicationQuit.cs.meta new file mode 100755 index 0000000..2d7cb96 --- /dev/null +++ b/Assets/PlayMaker/Actions/ApplicationQuit.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ace578551a64364db33bcd3c420797c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ApplicationRunInBackground.cs b/Assets/PlayMaker/Actions/ApplicationRunInBackground.cs new file mode 100755 index 0000000..e81352d --- /dev/null +++ b/Assets/PlayMaker/Actions/ApplicationRunInBackground.cs @@ -0,0 +1,25 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Application)] + [Tooltip("Sets if the Application should play in the background. Useful for servers or testing network games on one machine.")] + public class ApplicationRunInBackground : FsmStateAction + { + public FsmBool runInBackground; + + public override void Reset() + { + runInBackground = true; + } + + public override void OnEnter() + { + Application.runInBackground = runInBackground.Value; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ApplicationRunInBackground.cs.meta b/Assets/PlayMaker/Actions/ApplicationRunInBackground.cs.meta new file mode 100755 index 0000000..530cfe5 --- /dev/null +++ b/Assets/PlayMaker/Actions/ApplicationRunInBackground.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8acf39900e9db9543aa415136960f581 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array.meta b/Assets/PlayMaker/Actions/Array.meta new file mode 100644 index 0000000..37b83cd --- /dev/null +++ b/Assets/PlayMaker/Actions/Array.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 04140375cc92843f89e3418a5e189648 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions/Array/ArrayAdd.cs b/Assets/PlayMaker/Actions/Array/ArrayAdd.cs new file mode 100755 index 0000000..8c13bcb --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayAdd.cs @@ -0,0 +1,43 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Add an item to the end of an Array.")] + public class ArrayAdd : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable to use.")] + public FsmArray array; + + [RequiredField] + [MatchElementType("array")] + [Tooltip("Item to add.")] + public FsmVar value; + + public override void Reset() + { + array = null; + value = null; + } + + public override void OnEnter() + { + DoAddValue(); + Finish(); + } + + private void DoAddValue() + { + array.Resize(array.Length + 1); + value.UpdateValue(); + array.Set(array.Length - 1, value.GetValue()); + } + + } + +} + diff --git a/Assets/PlayMaker/Actions/Array/ArrayAdd.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayAdd.cs.meta new file mode 100755 index 0000000..b1ab0e0 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayAdd.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5cf434aed56dd6b4eb839ed214ff0af5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayAddRange.cs b/Assets/PlayMaker/Actions/Array/ArrayAddRange.cs new file mode 100755 index 0000000..3b4ba59 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayAddRange.cs @@ -0,0 +1,53 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Add values to an array.")] + public class ArrayAddRange : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable to use.")] + public FsmArray array; + + [RequiredField] + [MatchElementType("array")] + [Tooltip("The variables to add.")] + public FsmVar[] variables; + + public override void Reset() + { + array = null; + variables = new FsmVar[2]; + } + + public override void OnEnter() + { + DoAddRange(); + + Finish(); + } + + private void DoAddRange() + { + int count = variables.Length; + + if (count>0) + { + array.Resize(array.Length+count); + + foreach(FsmVar _var in variables) + { + array.Set(array.Length-count,_var.GetValue()); + count--; + } + } + + } + + + } +} diff --git a/Assets/PlayMaker/Actions/Array/ArrayAddRange.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayAddRange.cs.meta new file mode 100755 index 0000000..dde1df6 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayAddRange.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0921aaea4fadc8b498ea50142d26b83e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayClear.cs b/Assets/PlayMaker/Actions/Array/ArrayClear.cs new file mode 100755 index 0000000..3416926 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayClear.cs @@ -0,0 +1,43 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Sets all items in an Array to their default value: 0, empty string, false, or null depending on their type. Optionally defines a reset value to use.")] + public class ArrayClear : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable to clear.")] + public FsmArray array; + + [MatchElementType("array")] + [Tooltip("Optional reset value. Leave as None for default value.")] + public FsmVar resetValue; + + public override void Reset() + { + array = null; + resetValue = new FsmVar() {useVariable = true}; + } + + public override void OnEnter() + { + int count = array.Length; + + array.Reset(); + array.Resize(count); + + if (!resetValue.IsNone) + { + object _val = resetValue.GetValue(); + for (int i = 0; i < count; i++) + { + array.Set(i, _val); + } + } + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Array/ArrayClear.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayClear.cs.meta new file mode 100755 index 0000000..2be0bc6 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayClear.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a7235925ce776e34b88138a187d39dc7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayContains.cs b/Assets/PlayMaker/Actions/Array/ArrayContains.cs new file mode 100755 index 0000000..c0f6d91 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayContains.cs @@ -0,0 +1,77 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Check if an Array contains a value. Optionally get its index.")] + public class ArrayContains : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable to use.")] + public FsmArray array; + + [RequiredField] + [MatchElementType("array")] + [Tooltip("The value to check against in the array.")] + public FsmVar value; + + [ActionSection("Result")] + + [Tooltip("The index of the value in the array.")] + [UIHint(UIHint.Variable)] + public FsmInt index; + + [Tooltip("Store in a bool wether it contains or not that element (described below)")] + [UIHint(UIHint.Variable)] + public FsmBool isContained; + + [Tooltip("Event sent if this arraList contains that element ( described below)")] + [UIHint(UIHint.FsmEvent)] + public FsmEvent isContainedEvent; + + [Tooltip("Event sent if this arraList does not contains that element ( described below)")] + [UIHint(UIHint.FsmEvent)] + public FsmEvent isNotContainedEvent; + + public override void Reset () + { + array = null; + value = null; + + index = null; + + isContained = null; + isContainedEvent = null; + isNotContainedEvent = null; + } + + // Code that runs on entering the state. + public override void OnEnter () + { + DoCheckContainsValue (); + Finish (); + } + + private void DoCheckContainsValue() + { + value.UpdateValue(); + var _id = Array.IndexOf(array.Values, value.GetValue()); + + var _iscontained = _id != -1; + isContained.Value = _iscontained; + index.Value = _id; + if (_iscontained) + { + Fsm.Event(isContainedEvent); + } + else + { + Fsm.Event(isNotContainedEvent); + } + } + } +} diff --git a/Assets/PlayMaker/Actions/Array/ArrayContains.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayContains.cs.meta new file mode 100755 index 0000000..a6cab97 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayContains.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f93a56f20084a2446a06a44bc27e257c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayDeleteAt.cs b/Assets/PlayMaker/Actions/Array/ArrayDeleteAt.cs new file mode 100755 index 0000000..e62a1a6 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayDeleteAt.cs @@ -0,0 +1,71 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Delete the item at an index. Index must be between 0 and the number of items -1. First item is index 0.")] + public class ArrayDeleteAt : FsmStateAction + { + [RequiredField] [UIHint(UIHint.Variable)] [Tooltip("The Array Variable to use.")] public FsmArray array; + + [Tooltip("The index into the array.")] public FsmInt index; + + [ActionSection("Result")] [UIHint(UIHint.FsmEvent)] [Tooltip("The event to trigger if the index is out of range")] public FsmEvent indexOutOfRangeEvent; + + + + public override void Reset() + { + array = null; + index = null; + indexOutOfRangeEvent = null; + } + + + // Code that runs on entering the state. + public override void OnEnter() + { + DoDeleteAt(); + + Finish(); + } + + private void DoDeleteAt() + { + if (index.Value >= 0 && index.Value < array.Length) + { + List _list = new List(array.Values); + _list.RemoveAt(index.Value); + array.Values = _list.ToArray(); + } + else + { + Fsm.Event(indexOutOfRangeEvent); + } + } + + /* Not sure it's a good idea to check range at edit time since it can change at runtime + public override string ErrorCheck() + { + if (array.Length==0) + { + if (index.Value<0) + { + return "Index out of Range. Please select a positive number. First item is index 0."; + } + return ""; + } + + if (index.Value<0 || index.Value >= array.Length) + { + return "Index out of Range. Please select an index between 0 and the number of items -1. First item is index 0."; + } + return ""; + }*/ + + } +} diff --git a/Assets/PlayMaker/Actions/Array/ArrayDeleteAt.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayDeleteAt.cs.meta new file mode 100755 index 0000000..6f30695 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayDeleteAt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc32998bfef18a347a974d0482c14ae9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayForEach.cs b/Assets/PlayMaker/Actions/Array/ArrayForEach.cs new file mode 100755 index 0000000..4828f3c --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayForEach.cs @@ -0,0 +1,138 @@ +using System; +using UnityEngine; +using System.Collections; +using HutongGames.PlayMaker; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Iterate through the items in an Array and run an FSM on each item. NOTE: The FSM has to Finish before being run on the next item.")] + public class ArrayForEach : RunFSMAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Array to iterate through.")] + public FsmArray array; + + [HideTypeFilter] + [MatchElementType("array")] + [UIHint(UIHint.Variable)] + [Tooltip("Store the item in a variable")] + public FsmVar storeItem; + + [ActionSection("Run FSM")] + + public FsmTemplateControl fsmTemplateControl = new FsmTemplateControl(); + + [Tooltip("Event to send after iterating through all items in the Array.")] + public FsmEvent finishEvent; + + private int currentIndex; + + public override void Reset() + { + array = null; + fsmTemplateControl = new FsmTemplateControl(); + runFsm = null; + } + + /// + /// Initialize FSM on awake so it doesn't cause hitches later + /// + public override void Awake() + { + if (array != null && fsmTemplateControl.fsmTemplate != null && Application.isPlaying) + { + runFsm = Fsm.CreateSubFsm(fsmTemplateControl); + } + } + + public override void OnEnter() + { + if (array == null || runFsm == null) + { + Finish(); + return; + } + + currentIndex = 0; + StartFsm(); + } + + public override void OnUpdate() + { + runFsm.Update(); + if (!runFsm.Finished) + { + return; // continue later + } + + StartNextFsm(); + } + + public override void OnFixedUpdate() + { + runFsm.LateUpdate(); + if (!runFsm.Finished) + { + return; // continue later + } + + StartNextFsm(); + } + + public override void OnLateUpdate() + { + runFsm.LateUpdate(); + if (!runFsm.Finished) + { + return; // continue later + } + + StartNextFsm(); + } + + void StartNextFsm() + { + currentIndex++; + StartFsm(); + } + + void StartFsm() + { + while (currentIndex < array.Length) + { + DoStartFsm(); + if (!runFsm.Finished) + { + return; // continue later + } + currentIndex++; + } + + Fsm.Event(finishEvent); + Finish(); + } + + void DoStartFsm() + { + storeItem.SetValue(array.Values[currentIndex]); + + fsmTemplateControl.UpdateValues(); + fsmTemplateControl.ApplyOverrides(runFsm); + + runFsm.OnEnable(); + + if (!runFsm.Started) + { + runFsm.Start(); + } + } + + protected override void CheckIfFinished() + { + } + } + + +} diff --git a/Assets/PlayMaker/Actions/Array/ArrayForEach.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayForEach.cs.meta new file mode 100755 index 0000000..f23582c --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayForEach.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8a2a6d82cdbdad4a8178dd12b02dee0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayGet.cs b/Assets/PlayMaker/Actions/Array/ArrayGet.cs new file mode 100755 index 0000000..1d3fd18 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayGet.cs @@ -0,0 +1,95 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Get a value at an index. Index must be between 0 and the number of items -1. First item is index 0.")] + public class ArrayGet : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable to use.")] + public FsmArray array; + + [Tooltip("The index into the array.")] + public FsmInt index; + + [RequiredField] + [MatchElementType("array")] + [UIHint(UIHint.Variable)] + [Tooltip("Store the value in a variable.")] + public FsmVar storeValue; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + [ActionSection("Events")] + + [UIHint(UIHint.FsmEvent)] + [Tooltip("The event to trigger if the index is out of range")] + public FsmEvent indexOutOfRange; + + public override void Reset() + { + array = null; + index = null; + everyFrame = false; + storeValue = null; + indexOutOfRange = null; + } + + public override void OnEnter() + { + DoGetValue(); + + if (!everyFrame) + { + Finish(); + } + + } + + public override void OnUpdate() + { + DoGetValue(); + + } + + private void DoGetValue() + { + if (array.IsNone || storeValue.IsNone) + { + return; + } + + if (index.Value >= 0 && index.Value < array.Length) + { + storeValue.SetValue(array.Get(index.Value)); + } + else + { + //LogError("Index out of Range: " + index.Value); + Fsm.Event(indexOutOfRange); + } + } + + /* Not sure it's a good idea to range check at edit time since it can change at runtime + public override string ErrorCheck() + { + if (index.Value<0 || index.Value >= array.Length) + { + return "Index out of Range. Please select an index between 0 and the number of items -1. First item is index 0."; + } + return ""; + }*/ + +#if UNITY_EDITOR + public override string AutoName() + { + return ActionHelpers.GetValueLabel(storeValue.NamedVar) + "=" + array.Name + "[" + ActionHelpers.GetValueLabel(index) + "]"; + } +#endif + } +} diff --git a/Assets/PlayMaker/Actions/Array/ArrayGet.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayGet.cs.meta new file mode 100755 index 0000000..dc5c547 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayGet.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bb2087d662074974ba5d95f6f6443889 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayGetNext.cs b/Assets/PlayMaker/Actions/Array/ArrayGetNext.cs new file mode 100755 index 0000000..6848092 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayGetNext.cs @@ -0,0 +1,118 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Each time this action is called it gets the next item from a Array. \n" + + "This lets you quickly loop through all the items of an array to perform actions on them.")] + public class ArrayGetNext : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable to use.")] + public FsmArray array; + + [Tooltip("From where to start iteration, leave as 0 to start from the beginning")] + public FsmInt startIndex; + + [Tooltip("When to end iteration, leave as 0 to iterate until the end")] + public FsmInt endIndex; + + [Tooltip("Event to send to get the next item.")] + public FsmEvent loopEvent; + + [Tooltip("Event to send when there are no more items.")] + public FsmEvent finishedEvent; + + [ActionSection("Result")] + + [MatchElementType("array")] + public FsmVar result; + + [UIHint(UIHint.Variable)] + public FsmInt currentIndex; + + // increment that index as we loop through item + private int nextItemIndex = 0; + + public override void Reset() + { + array = null; + startIndex = null; + endIndex = null; + + currentIndex = null; + + loopEvent = null; + finishedEvent = null; + + result = null; + } + + public override void OnEnter() + { + if (nextItemIndex == 0) + { + if (startIndex.Value>0) + { + nextItemIndex = startIndex.Value; + } + } + + DoGetNextItem(); + + Finish(); + } + + + void DoGetNextItem() + { + // no more children? + // check first to avoid errors. + + if (nextItemIndex >= array.Length) + { + nextItemIndex = 0; + currentIndex.Value = array.Length -1; + Fsm.Event(finishedEvent); + return; + } + + // get next item + + result.SetValue(array.Get(nextItemIndex)); + + // no more items? + // check a second time to avoid process lock and possible infinite loop if the action is called again. + // Practically, this enabled calling again this state and it will start again iterating from the first child. + + if (nextItemIndex >= array.Length) + { + nextItemIndex = 0; + currentIndex.Value = array.Length-1; + Fsm.Event(finishedEvent); + return; + } + + if (endIndex.Value>0 && nextItemIndex>= endIndex.Value) + { + nextItemIndex = 0; + currentIndex.Value = endIndex.Value; + Fsm.Event(finishedEvent); + return; + } + + // iterate the next child + nextItemIndex++; + + currentIndex.Value = nextItemIndex -1 ; + + if (loopEvent != null) + { + Fsm.Event(loopEvent); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Array/ArrayGetNext.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayGetNext.cs.meta new file mode 100755 index 0000000..a79b760 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayGetNext.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7f2c332853b32c743940b57c0a595ed7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayGetRandom.cs b/Assets/PlayMaker/Actions/Array/ArrayGetRandom.cs new file mode 100755 index 0000000..7803d65 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayGetRandom.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Get a Random item from an Array.")] + public class ArrayGetRandom : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array to use.")] + public FsmArray array; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the value in a variable.")] + [MatchElementType("array")] + public FsmVar storeValue; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + array = null; + storeValue =null; + everyFrame = false; + } + + // Code that runs on entering the state. + public override void OnEnter() + { + DoGetRandomValue(); + + if (!everyFrame) + { + Finish(); + } + + } + + public override void OnUpdate() + { + DoGetRandomValue(); + + } + + private void DoGetRandomValue() + { + if (storeValue.IsNone) + { + return; + } + + storeValue.SetValue(array.Get(Random.Range(0,array.Length))); + } + + + } +} + diff --git a/Assets/PlayMaker/Actions/Array/ArrayGetRandom.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayGetRandom.cs.meta new file mode 100755 index 0000000..1fadf24 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayGetRandom.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: df9a5befe0eda4445a018b47d17c2a8b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayLength.cs b/Assets/PlayMaker/Actions/Array/ArrayLength.cs new file mode 100755 index 0000000..c0a0b03 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayLength.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Gets the number of items in an Array.")] + public class ArrayLength : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable.")] + public FsmArray array; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the length in an Int Variable.")] + public FsmInt length; + + [Tooltip("Repeat every frame. Useful if the array is changing and you're waiting for a particular length.")] + public bool everyFrame; + + public override void Reset() + { + array = null; + length = null; + everyFrame = false; + } + + public override void OnEnter() + { + length.Value = array.Length; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + length.Value = array.Length; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Array/ArrayLength.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayLength.cs.meta new file mode 100755 index 0000000..e3abfec --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayLength.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bdba2552ffbbbc74b9d67cb2b54e1324 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayResize.cs b/Assets/PlayMaker/Actions/Array/ArrayResize.cs new file mode 100755 index 0000000..bb32063 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayResize.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Resize an array.")] + public class ArrayResize : FsmStateAction + { + [RequiredField] [UIHint(UIHint.Variable)] [Tooltip("The Array Variable to resize")] public FsmArray array; + + [Tooltip("The new size of the array.")] public FsmInt newSize; + + [UIHint(UIHint.FsmEvent)] [Tooltip("The event to trigger if the new size is out of range")] public FsmEvent + sizeOutOfRangeEvent; + + public override void OnEnter() + { + if (newSize.Value >= 0) + { + array.Resize(newSize.Value); + } + else + { + LogError("Size out of range: " + newSize.Value); + Fsm.Event(sizeOutOfRangeEvent); + } + + Finish(); + } + + /* Should be disallowed by the UI now + public override string ErrorCheck() + { + if (newSize.Value<0) + { + return "newSize must be a positive value."; + } + return ""; + }*/ + + } +} diff --git a/Assets/PlayMaker/Actions/Array/ArrayResize.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayResize.cs.meta new file mode 100755 index 0000000..97b09b0 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayResize.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 68e5e954eb95b7b40b0e00f59b4d1986 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayReverse.cs b/Assets/PlayMaker/Actions/Array/ArrayReverse.cs new file mode 100755 index 0000000..e399f6e --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayReverse.cs @@ -0,0 +1,33 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + + [ActionCategory(ActionCategory.Array)] + [Tooltip("Reverse the order of items in an Array.")] + public class ArrayReverse : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array to reverse.")] + public FsmArray array; + + public override void Reset() + { + array = null; + } + + // Code that runs on entering the state. + public override void OnEnter() + { + var _list = new List(array.Values); + _list.Reverse(); + array.Values = _list.ToArray(); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Array/ArrayReverse.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayReverse.cs.meta new file mode 100755 index 0000000..ef42619 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayReverse.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 41e56ac32e995724a9ea51f5b7b5ebce +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArraySet.cs b/Assets/PlayMaker/Actions/Array/ArraySet.cs new file mode 100755 index 0000000..30fcc63 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArraySet.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Set the value at an index. Index must be between 0 and the number of items -1. First item is index 0.")] + public class ArraySet : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable to use.")] + public FsmArray array; + + [Tooltip("The index into the array.")] + public FsmInt index; + + [RequiredField] + [MatchElementType("array")] + [Tooltip("Set the value of the array at the specified index.")] + public FsmVar value; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + [ActionSection("Events")] + + [UIHint(UIHint.FsmEvent)] + [Tooltip("The event to trigger if the index is out of range")] + public FsmEvent indexOutOfRange; + + public override void Reset() + { + array = null; + index = null; + value = null; + everyFrame = false; + indexOutOfRange = null; + } + + public override void OnEnter() + { + DoGetValue(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetValue(); + } + + private void DoGetValue() + { + if (array.IsNone) + { + return; + } + + if (index.Value >= 0 && index.Value < array.Length) + { + value.UpdateValue(); + array.Set(index.Value, value.GetValue()); + } + else + { + //LogError("Index out of Range: " + index.Value); + Fsm.Event(indexOutOfRange); + } + } + + /* + public override string ErrorCheck() + { + if (index.Value<0 || index.Value >= array.Length) + { + return "Index out of Range. Please select an index between 0 and the number of items -1. First item is index 0."; + } + return ""; + }*/ + + } +} diff --git a/Assets/PlayMaker/Actions/Array/ArraySet.cs.meta b/Assets/PlayMaker/Actions/Array/ArraySet.cs.meta new file mode 100755 index 0000000..00874ae --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArraySet.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de186d86d62e53c4ab432d55800df4f6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayShuffle.cs b/Assets/PlayMaker/Actions/Array/ArrayShuffle.cs new file mode 100755 index 0000000..594710b --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayShuffle.cs @@ -0,0 +1,68 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Shuffle values in an array. Optionally set a start index and range to shuffle only part of the array.")] + public class ArrayShuffle : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array to shuffle.")] + public FsmArray array; + + [Tooltip("Optional start Index for the shuffling. Leave it to none or 0 for no effect")] + public FsmInt startIndex; + + [Tooltip("Optional range for the shuffling, starting at the start index if greater than 0. Leave it to none or 0 for no effect, it will shuffle the whole array")] + public FsmInt shufflingRange; + + public override void Reset() + { + array = null; + startIndex = new FsmInt {UseVariable=true}; + shufflingRange = new FsmInt {UseVariable=true}; + } + + // Code that runs on entering the state. + public override void OnEnter() + { + List _list = new List(array.Values); + + int start = 0; + int end = _list.Count-1; + + if (startIndex.Value>0) + { + start = Mathf.Min(startIndex.Value,end); + } + + if (shufflingRange.Value>0) + { + end = Mathf.Min(_list.Count-1,start + shufflingRange.Value); + + } + + // Knuth-Fisher-Yates algo + + // for (int i = proxy.arrayList.Count - 1; i > 0; i--) + for (int i = end; i > start; i--) + { + // Set swapWithPos a random position such that 0 <= swapWithPos <= i + int swapWithPos = Random.Range(start,i + 1); + + // Swap the value at the "current" position (i) with value at swapWithPos + object tmp = _list[i]; + _list[i] = _list[swapWithPos]; + _list[swapWithPos] = tmp; + } + + array.Values = _list.ToArray(); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Array/ArrayShuffle.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayShuffle.cs.meta new file mode 100755 index 0000000..4f18197 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayShuffle.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ee06ffed02f3bbd4682befa29dfb5ab2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArraySort.cs b/Assets/PlayMaker/Actions/Array/ArraySort.cs new file mode 100755 index 0000000..926203f --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArraySort.cs @@ -0,0 +1,31 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Sort items in an Array.")] + public class ArraySort : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array to sort.")] + public FsmArray array; + + public override void Reset() + { + array = null; + } + + public override void OnEnter() + { + var list = new List(array.Values); + list.Sort(); + array.Values = list.ToArray(); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Array/ArraySort.cs.meta b/Assets/PlayMaker/Actions/Array/ArraySort.cs.meta new file mode 100755 index 0000000..05fcfbc --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArraySort.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f95b31bdddbc8554080295de0a14d835 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/ArrayTransferValue.cs b/Assets/PlayMaker/Actions/Array/ArrayTransferValue.cs new file mode 100755 index 0000000..61237b1 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayTransferValue.cs @@ -0,0 +1,122 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Transfer a value from one array to another, basically a copy/cut paste action on steroids.")] + public class ArrayTransferValue : FsmStateAction + { + public enum ArrayTransferType {Copy,Cut,nullify}; + public enum ArrayPasteType {AsFirstItem,AsLastItem,InsertAtSameIndex,ReplaceAtSameIndex}; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable source.")] + public FsmArray arraySource; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Array Variable target.")] + public FsmArray arrayTarget; + + [MatchFieldType("array")] + [Tooltip("The index to transfer.")] + public FsmInt indexToTransfer; + + [ActionSection("Transfer Options")] + + [ObjectType(typeof(ArrayTransferType))] + public FsmEnum copyType; + + [ObjectType(typeof(ArrayPasteType))] + public FsmEnum pasteType; + + [ActionSection("Result")] + + [Tooltip("Event sent if this array source does not contains that element (described below)")] + [UIHint(UIHint.FsmEvent)] + public FsmEvent indexOutOfRange; + + public override void Reset () + { + arraySource = null; + arrayTarget = null; + + indexToTransfer = null; + + copyType = ArrayTransferType.Copy; + pasteType = ArrayPasteType.AsLastItem; + } + + // Code that runs on entering the state. + public override void OnEnter () + { + DoTransferValue (); + Finish (); + } + + private void DoTransferValue () + { + if (arraySource.IsNone || arrayTarget.IsNone) + { + return; + } + int _index = indexToTransfer.Value; + + if (_index< 0 || _index>=arraySource.Length) + { + Fsm.Event(indexOutOfRange); + return; + } + var _value = arraySource.Values[_index]; + + + + if ((ArrayTransferType)copyType.Value == ArrayTransferType.Cut) + { + List _list = new List(arraySource.Values); + _list.RemoveAt(_index); + arraySource.Values = _list.ToArray(); + }else if ((ArrayTransferType)copyType.Value == ArrayTransferType.nullify) + { + arraySource.Values.SetValue(null,_index); + } + + + if ( (ArrayPasteType)pasteType.Value == ArrayPasteType.AsFirstItem) + { + List _listTarget = new List(arrayTarget.Values); + _listTarget.Insert(0,_value); + arrayTarget.Values = _listTarget.ToArray(); + + }else if( (ArrayPasteType)pasteType.Value == ArrayPasteType.AsLastItem) + { + arrayTarget.Resize(arrayTarget.Length + 1); + arrayTarget.Set(arrayTarget.Length - 1, _value); + + }else if( (ArrayPasteType)pasteType.Value == ArrayPasteType.InsertAtSameIndex) + { + if (_index>=arrayTarget.Length) + { + Fsm.Event(indexOutOfRange); + } + List _listTarget = new List(arrayTarget.Values); + _listTarget.Insert(_index,_value); + arrayTarget.Values = _listTarget.ToArray(); + + }else if( (ArrayPasteType)pasteType.Value == ArrayPasteType.ReplaceAtSameIndex) + { + if (_index>=arrayTarget.Length) + { + Fsm.Event(indexOutOfRange); + }else{ + arrayTarget.Set(_index, _value); + } + } + } + + } +} diff --git a/Assets/PlayMaker/Actions/Array/ArrayTransferValue.cs.meta b/Assets/PlayMaker/Actions/Array/ArrayTransferValue.cs.meta new file mode 100755 index 0000000..f160595 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/ArrayTransferValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 798d1540b1bfc474fb13e89319c3abae +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Array/FsmArraySet.cs b/Assets/PlayMaker/Actions/Array/FsmArraySet.cs new file mode 100755 index 0000000..a46d099 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/FsmArraySet.cs @@ -0,0 +1,95 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Array)] + [Tooltip("Set an item in an Array Variable in another FSM.")] + public class FsmArraySet : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object.")] + public FsmString fsmName; + + [RequiredField] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [Tooltip("Set the value of the variable.")] + public FsmString setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmString(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmString() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (go != goLastFrame) + { + goLastFrame = go; + + // only get the fsm component if go has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmString = fsm.FsmVariables.GetFsmString(variableName.Value); + + if (fsmString != null) + { + fsmString.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmString(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Array/FsmArraySet.cs.meta b/Assets/PlayMaker/Actions/Array/FsmArraySet.cs.meta new file mode 100755 index 0000000..90842a2 --- /dev/null +++ b/Assets/PlayMaker/Actions/Array/FsmArraySet.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 05ff3fe206f2df14a97c72576c1a36f9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AudioMute.cs b/Assets/PlayMaker/Actions/AudioMute.cs new file mode 100755 index 0000000..92ce153 --- /dev/null +++ b/Assets/PlayMaker/Actions/AudioMute.cs @@ -0,0 +1,41 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Mute/unmute the Audio Clip played by an Audio Source component on a Game Object.")] + public class AudioMute : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + [Tooltip("The GameObject with an Audio Source component.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("Check to mute, uncheck to unmute.")] + public FsmBool mute; + + public override void Reset() + { + gameObject = null; + mute = false; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go != null) + { + var audio = go.GetComponent(); + if (audio != null) + { + audio.mute = mute.Value; + } + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AudioMute.cs.meta b/Assets/PlayMaker/Actions/AudioMute.cs.meta new file mode 100755 index 0000000..27c2739 --- /dev/null +++ b/Assets/PlayMaker/Actions/AudioMute.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc715a02422df2b43bf7c11fddf2a78a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AudioPause.cs b/Assets/PlayMaker/Actions/AudioPause.cs new file mode 100755 index 0000000..b055f84 --- /dev/null +++ b/Assets/PlayMaker/Actions/AudioPause.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Pauses playing the Audio Clip played by an Audio Source component on a Game Object.")] + public class AudioPause : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + [Tooltip("The GameObject with an Audio Source component.")] + public FsmOwnerDefault gameObject; + + public override void Reset() + { + gameObject = null; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go != null) + { + var audio = go.GetComponent(); + if (audio != null) + { + audio.Pause(); + } + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AudioPause.cs.meta b/Assets/PlayMaker/Actions/AudioPause.cs.meta new file mode 100755 index 0000000..3f9973d --- /dev/null +++ b/Assets/PlayMaker/Actions/AudioPause.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29d1c16d595d7b64fa15ec3d0569a76d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AudioPlay.cs b/Assets/PlayMaker/Actions/AudioPlay.cs new file mode 100755 index 0000000..662d8e7 --- /dev/null +++ b/Assets/PlayMaker/Actions/AudioPlay.cs @@ -0,0 +1,99 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Plays the Audio Clip set with Set Audio Clip or in the Audio Source inspector on a Game Object. Optionally plays a one shot Audio Clip.")] + public class AudioPlay : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + [Tooltip("The GameObject with an AudioSource component.")] + public FsmOwnerDefault gameObject; + + [HasFloatSlider(0,1)] + [Tooltip("Set the volume.")] + public FsmFloat volume; + + [ObjectType(typeof(AudioClip))] + [Tooltip("Optionally play a 'one shot' AudioClip. NOTE: Volume cannot be adjusted while playing a 'one shot' AudioClip.")] + public FsmObject oneShotClip; + + [Tooltip("Event to send when the AudioClip finishes playing.")] + public FsmEvent finishedEvent; + + private AudioSource audio; + + public override void Reset() + { + gameObject = null; + volume = 1f; + oneShotClip = null; + finishedEvent = null; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go != null) + { + // cache the AudioSource component + + audio = go.GetComponent(); + if (audio != null) + { + var audioClip = oneShotClip.Value as AudioClip; + + if (audioClip == null) + { + audio.Play(); + + if (!volume.IsNone) + { + audio.volume = volume.Value; + } + + return; + } + + if (!volume.IsNone) + { + audio.PlayOneShot(audioClip, volume.Value); + } + else + { + audio.PlayOneShot(audioClip); + } + + return; + } + } + + // Finish if failed to play sound + + Finish(); + } + + public override void OnUpdate () + { + if (audio == null) + { + Finish(); + } + else + { + if (!audio.isPlaying) + { + Fsm.Event(finishedEvent); + Finish(); + } + else if (!volume.IsNone && volume.Value != audio.volume) + { + audio.volume = volume.Value; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AudioPlay.cs.meta b/Assets/PlayMaker/Actions/AudioPlay.cs.meta new file mode 100755 index 0000000..d760448 --- /dev/null +++ b/Assets/PlayMaker/Actions/AudioPlay.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d7faf656b29070442874f5324061b99d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AudioStop.cs b/Assets/PlayMaker/Actions/AudioStop.cs new file mode 100755 index 0000000..22e14a9 --- /dev/null +++ b/Assets/PlayMaker/Actions/AudioStop.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Stops playing the Audio Clip played by an Audio Source component on a Game Object.")] + public class AudioStop : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + [Tooltip("The GameObject with an AudioSource component.")] + public FsmOwnerDefault gameObject; + + public override void Reset() + { + gameObject = null; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go != null) + { + var audio = go.GetComponent(); + if (audio != null) + { + audio.Stop(); + } + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/AudioStop.cs.meta b/Assets/PlayMaker/Actions/AudioStop.cs.meta new file mode 100755 index 0000000..32a7030 --- /dev/null +++ b/Assets/PlayMaker/Actions/AudioStop.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6777341ea924c7428e33a6f47113e7f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/AxisEvent.cs b/Assets/PlayMaker/Actions/AxisEvent.cs new file mode 100755 index 0000000..0c07bed --- /dev/null +++ b/Assets/PlayMaker/Actions/AxisEvent.cs @@ -0,0 +1,112 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends events based on the direction of Input Axis (Left/Right/Up/Down...).")] + public class AxisEvent : FsmStateAction + { + [Tooltip("Horizontal axis as defined in the Input Manager")] + public FsmString horizontalAxis; + + [Tooltip("Vertical axis as defined in the Input Manager")] + public FsmString verticalAxis; + + [Tooltip("Event to send if input is to the left.")] + public FsmEvent leftEvent; + + [Tooltip("Event to send if input is to the right.")] + public FsmEvent rightEvent; + + [Tooltip("Event to send if input is to the up.")] + public FsmEvent upEvent; + + [Tooltip("Event to send if input is to the down.")] + public FsmEvent downEvent; + + [Tooltip("Event to send if input is in any direction.")] + public FsmEvent anyDirection; + + [Tooltip("Event to send if no axis input (centered).")] + public FsmEvent noDirection; + + public override void Reset() + { + horizontalAxis = "Horizontal"; + verticalAxis = "Vertical"; + leftEvent = null; + rightEvent = null; + upEvent = null; + downEvent = null; + anyDirection = null; + noDirection = null; + } + + public override void OnUpdate() + { + // get axes offsets + + var x = horizontalAxis.Value != "" ? Input.GetAxis(horizontalAxis.Value) : 0; + var y = verticalAxis.Value != "" ? Input.GetAxis(verticalAxis.Value) : 0; + + // get squared offset from center + + var offset = (x * x) + (y * y); + + // no offset? + + if (offset.Equals(0)) + { + if (noDirection != null) + { + Fsm.Event(noDirection); + } + return; + } + + // get integer direction sector (4 directions) + // TODO: 8 directions? or new action? + + var angle = (Mathf.Atan2(y, x) * Mathf.Rad2Deg) + 45f; + if (angle < 0f) + { + angle += 360f; + } + + var direction = (int)(angle / 90f); + + // send events bases on direction + + if (direction == 0 && rightEvent != null) + { + Fsm.Event(rightEvent); + //Debug.Log("Right"); + } + else if (direction == 1 && upEvent != null) + { + Fsm.Event(upEvent); + //Debug.Log("Up"); + } + else if (direction == 2 && leftEvent != null) + { + Fsm.Event(leftEvent); + //Debug.Log("Left"); + } + else if (direction == 3 && downEvent != null) + { + Fsm.Event(downEvent); + //Debug.Log("Down"); + } + else if (anyDirection != null) + { + // since we already no offset > 0 + + Fsm.Event(anyDirection); + //Debug.Log("AnyDirection"); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/AxisEvent.cs.meta b/Assets/PlayMaker/Actions/AxisEvent.cs.meta new file mode 100755 index 0000000..efe2499 --- /dev/null +++ b/Assets/PlayMaker/Actions/AxisEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8d4cd11ae3f42fd4e9a59b650d252475 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BaseLogAction.cs b/Assets/PlayMaker/Actions/BaseLogAction.cs new file mode 100755 index 0000000..095502f --- /dev/null +++ b/Assets/PlayMaker/Actions/BaseLogAction.cs @@ -0,0 +1,15 @@ +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + // Base class for logging actions + public abstract class BaseLogAction : FsmStateAction + { + public bool sendToUnityLog; + + public override void Reset() + { + sendToUnityLog = false; + } + } +} diff --git a/Assets/PlayMaker/Actions/BaseLogAction.cs.meta b/Assets/PlayMaker/Actions/BaseLogAction.cs.meta new file mode 100755 index 0000000..c20fdfe --- /dev/null +++ b/Assets/PlayMaker/Actions/BaseLogAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e7bb225a384e052488dbd18116e55f54 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BlendAnimation.cs b/Assets/PlayMaker/Actions/BlendAnimation.cs new file mode 100755 index 0000000..3d8cbb2 --- /dev/null +++ b/Assets/PlayMaker/Actions/BlendAnimation.cs @@ -0,0 +1,98 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Blends an Animation towards a Target Weight over a specified Time.\nOptionally sends an Event when finished.")] + public class BlendAnimation : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("The GameObject to animate.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Animation)] + [Tooltip("The name of the animation to blend.")] + public FsmString animName; + + [RequiredField] + [HasFloatSlider(0f, 1f)] + [Tooltip("Target weight to blend to.")] + public FsmFloat targetWeight; + + [RequiredField] + [HasFloatSlider(0f, 5f)] + [Tooltip("How long should the blend take.")] + public FsmFloat time; + + [Tooltip("Event to send when the blend has finished.")] + public FsmEvent finishEvent; + + // TODO: Delayed event doesn't handle speed changes etc. + // Use Animation isPlaying instead? + DelayedEvent delayedFinishEvent; + + public override void Reset() + { + gameObject = null; + animName = null; + targetWeight = 1f; + time = 0.3f; + finishEvent = null; + } + + public override void OnEnter() + { + DoBlendAnimation(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + } + + public override void OnUpdate() + { + if (DelayedEvent.WasSent(delayedFinishEvent)) + { + Finish(); + } + } + + void DoBlendAnimation(GameObject go) + { + if (go == null) + { + return; + } + + var animation = go.GetComponent(); + if (animation == null) + { + LogWarning("Missing Animation component on GameObject: " + go.name); + Finish(); + return; + } + + var anim = animation[animName.Value]; + + if (anim == null) + { + LogWarning("Missing animation: " + animName.Value); + Finish(); + return; + } + + var timeValue = time.Value; + animation.Blend(animName.Value, targetWeight.Value, timeValue); + + // TODO: doesn't work well with scaled time + if (finishEvent != null) + { + delayedFinishEvent = Fsm.DelayedEvent(finishEvent, anim.length); + } + else + { + Finish(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BlendAnimation.cs.meta b/Assets/PlayMaker/Actions/BlendAnimation.cs.meta new file mode 100755 index 0000000..1e81b5e --- /dev/null +++ b/Assets/PlayMaker/Actions/BlendAnimation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: caaf16a32a7f8eb4fa362e719d2e901f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Blink.cs b/Assets/PlayMaker/Actions/Blink.cs new file mode 100755 index 0000000..331234d --- /dev/null +++ b/Assets/PlayMaker/Actions/Blink.cs @@ -0,0 +1,113 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Effects)] + [Tooltip("Turns a Game Object on/off in a regular repeating pattern.")] + public class Blink : ComponentAction + { + [RequiredField] + [Tooltip("The GameObject to blink on/off.")] + public FsmOwnerDefault gameObject; + + [HasFloatSlider(0, 5)] + [Tooltip("Time to stay off in seconds.")] + public FsmFloat timeOff; + + [HasFloatSlider(0, 5)] + [Tooltip("Time to stay on in seconds.")] + public FsmFloat timeOn; + + [Tooltip("Should the object start in the active/visible state?")] + public FsmBool startOn; + + [Tooltip("Only effect the renderer, keeping other components active.")] + public bool rendererOnly; + + [Tooltip("Ignore TimeScale. Useful if the game is paused.")] + public bool realTime; + + private float startTime; + private float timer; + private bool blinkOn; + + public override void Reset() + { + gameObject = null; + timeOff = 0.5f; + timeOn = 0.5f; + rendererOnly = true; + startOn = false; + realTime = false; + } + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + timer = 0f; + + UpdateBlinkState(startOn.Value); + } + + public override void OnUpdate() + { + // update time + + if (realTime) + { + timer = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + timer += Time.deltaTime; + } + + // update blink + + if (blinkOn && timer > timeOn.Value) + { + UpdateBlinkState(false); + } + + if (blinkOn == false && timer > timeOff.Value) + { + UpdateBlinkState(true); + } + } + + void UpdateBlinkState(bool state) + { + var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; + if (go == null) + { + return; + } + + if (rendererOnly) + { + if(UpdateCache(go)) + { + renderer.enabled = state; + } + } + else + { +#if UNITY_3_5 || UNITY_3_4 + go.active = state; +#else + go.SetActive(state); +#endif + } + + blinkOn = state; + + // reset timer + + startTime = FsmTime.RealtimeSinceStartup; + timer = 0f; + } + } +} + diff --git a/Assets/PlayMaker/Actions/Blink.cs.meta b/Assets/PlayMaker/Actions/Blink.cs.meta new file mode 100755 index 0000000..bcf9e51 --- /dev/null +++ b/Assets/PlayMaker/Actions/Blink.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 367dd11eff47df14cbf7d185b4c4d1fb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BoolAllTrue.cs b/Assets/PlayMaker/Actions/BoolAllTrue.cs new file mode 100755 index 0000000..20c8298 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolAllTrue.cs @@ -0,0 +1,70 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if all the given Bool Variables are True.")] + public class BoolAllTrue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variables to check.")] + public FsmBool[] boolVariables; + + [Tooltip("Event to send if all the Bool variables are True.")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a Bool variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + boolVariables = null; + sendEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoAllTrue(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoAllTrue(); + } + + void DoAllTrue() + { + if (boolVariables.Length == 0) return; + + var allTrue = true; + + for (var i = 0; i < boolVariables.Length; i++) + { + if (!boolVariables[i].Value) + { + allTrue = false; + break; + } + } + + if (allTrue) + { + Fsm.Event(sendEvent); + } + + storeResult.Value = allTrue; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BoolAllTrue.cs.meta b/Assets/PlayMaker/Actions/BoolAllTrue.cs.meta new file mode 100755 index 0000000..07919d8 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolAllTrue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f14889b04b70ede4cb1aa06309f5f89d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BoolAnyTrue.cs b/Assets/PlayMaker/Actions/BoolAnyTrue.cs new file mode 100755 index 0000000..0e111b7 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolAnyTrue.cs @@ -0,0 +1,67 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if any of the given Bool Variables are True.")] + public class BoolAnyTrue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variables to check.")] + public FsmBool[] boolVariables; + + [Tooltip("Event to send if any of the Bool variables are True.")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a Bool variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + boolVariables = null; + sendEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoAnyTrue(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoAnyTrue(); + } + + void DoAnyTrue() + { + if (boolVariables.Length == 0) + { + return; + } + + storeResult.Value = false; + + for (var i = 0; i < boolVariables.Length; i++) + { + if (boolVariables[i].Value) + { + Fsm.Event(sendEvent); + storeResult.Value = true; + return; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BoolAnyTrue.cs.meta b/Assets/PlayMaker/Actions/BoolAnyTrue.cs.meta new file mode 100755 index 0000000..43985cc --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolAnyTrue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 92aa7496b9c7dbe49b0623baa74e7db1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BoolChanged.cs b/Assets/PlayMaker/Actions/BoolChanged.cs new file mode 100755 index 0000000..5472ec2 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolChanged.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if the value of a Bool Variable has changed. Use this to send an event on change, or store a bool that can be used in other operations.")] + public class BoolChanged : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variable to watch for changes.")] + public FsmBool boolVariable; + + [Tooltip("Event to send if the variable changes.")] + public FsmEvent changedEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Set to True if changed.")] + public FsmBool storeResult; + + bool previousValue; + + public override void Reset() + { + boolVariable = null; + changedEvent = null; + storeResult = null; + } + + public override void OnEnter() + { + if (boolVariable.IsNone) + { + Finish(); + return; + } + + previousValue = boolVariable.Value; + } + + public override void OnUpdate() + { + storeResult.Value = false; + + if (boolVariable.Value != previousValue) + { + storeResult.Value = true; + Fsm.Event(changedEvent); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/BoolChanged.cs.meta b/Assets/PlayMaker/Actions/BoolChanged.cs.meta new file mode 100755 index 0000000..ce00ab9 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolChanged.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5d16cd2973206874084f6e5b99aff702 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BoolFlip.cs b/Assets/PlayMaker/Actions/BoolFlip.cs new file mode 100755 index 0000000..2c15de0 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolFlip.cs @@ -0,0 +1,25 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Flips the value of a Bool Variable.")] + public class BoolFlip : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Bool variable to flip.")] + public FsmBool boolVariable; + + public override void Reset() + { + boolVariable = null; + } + + public override void OnEnter() + { + boolVariable.Value = !boolVariable.Value; + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BoolFlip.cs.meta b/Assets/PlayMaker/Actions/BoolFlip.cs.meta new file mode 100755 index 0000000..5021625 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolFlip.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6b06d7bf2a25452478dd3e5d5445a896 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BoolNoneTrue.cs b/Assets/PlayMaker/Actions/BoolNoneTrue.cs new file mode 100755 index 0000000..5b134fa --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolNoneTrue.cs @@ -0,0 +1,70 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if all the Bool Variables are False.\nSend an event or store the result.")] + public class BoolNoneTrue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variables to check.")] + public FsmBool[] boolVariables; + + [Tooltip("Event to send if none of the Bool variables are True.")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a Bool variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + boolVariables = null; + sendEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoNoneTrue(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoNoneTrue(); + } + + void DoNoneTrue() + { + if (boolVariables.Length == 0) return; + + var noneTrue = true; + + for (var i = 0; i < boolVariables.Length; i++) + { + if (boolVariables[i].Value) + { + noneTrue = false; + break; + } + } + + if (noneTrue) + { + Fsm.Event(sendEvent); + } + + storeResult.Value = noneTrue; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BoolNoneTrue.cs.meta b/Assets/PlayMaker/Actions/BoolNoneTrue.cs.meta new file mode 100755 index 0000000..53d0094 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolNoneTrue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b3cd57e7754145e4298aa8bbb8cb0ad4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BoolOperator.cs b/Assets/PlayMaker/Actions/BoolOperator.cs new file mode 100755 index 0000000..7a04f70 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolOperator.cs @@ -0,0 +1,86 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Performs boolean operations on 2 Bool Variables.")] + public class BoolOperator : FsmStateAction + { + public enum Operation + { + AND, + NAND, + OR, + XOR + } + + [RequiredField] + [Tooltip("The first Bool variable.")] + public FsmBool bool1; + + [RequiredField] + [Tooltip("The second Bool variable.")] + public FsmBool bool2; + + [Tooltip("Boolean Operation.")] + public Operation operation; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a Bool Variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + bool1 = false; + bool2 = false; + operation = Operation.AND; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoBoolOperator(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoBoolOperator(); + } + + void DoBoolOperator() + { + var v1 = bool1.Value; + var v2 = bool2.Value; + + switch (operation) + { + case Operation.AND: + storeResult.Value = v1 && v2; + break; + + case Operation.NAND: + storeResult.Value = !(v1 && v2); + break; + + case Operation.OR: + storeResult.Value = v1 || v2; + break; + + case Operation.XOR: + storeResult.Value = v1 ^ v2; + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BoolOperator.cs.meta b/Assets/PlayMaker/Actions/BoolOperator.cs.meta new file mode 100755 index 0000000..68d4b8a --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolOperator.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8d63d0c13fcc1064eb48c4d8eae4a294 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BoolTest.cs b/Assets/PlayMaker/Actions/BoolTest.cs new file mode 100755 index 0000000..e912fb6 --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolTest.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends Events based on the value of a Boolean Variable.")] + public class BoolTest : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variable to test.")] + public FsmBool boolVariable; + + [Tooltip("Event to send if the Bool variable is True.")] + public FsmEvent isTrue; + + [Tooltip("Event to send if the Bool variable is False.")] + public FsmEvent isFalse; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + boolVariable = null; + isTrue = null; + isFalse = null; + everyFrame = false; + } + + public override void OnEnter() + { + Fsm.Event(boolVariable.Value ? isTrue : isFalse); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + Fsm.Event(boolVariable.Value ? isTrue : isFalse); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BoolTest.cs.meta b/Assets/PlayMaker/Actions/BoolTest.cs.meta new file mode 100755 index 0000000..a693d5a --- /dev/null +++ b/Assets/PlayMaker/Actions/BoolTest.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b8ab2667346f94c438747d216c43187b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BroadcastEvent.cs b/Assets/PlayMaker/Actions/BroadcastEvent.cs new file mode 100755 index 0000000..339f605 --- /dev/null +++ b/Assets/PlayMaker/Actions/BroadcastEvent.cs @@ -0,0 +1,92 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [Obsolete("This action is obsolete; use Send Event with Event Target instead.")] + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sends an Event to all FSMs in the scene or to all FSMs on a Game Object.\nNOTE: This action won't work on the very first frame of the game...")] + public class BroadcastEvent : FsmStateAction + { + [RequiredField] + public FsmString broadcastEvent; + [Tooltip("Optionally specify a game object to broadcast the event to all FSMs on that game object.")] + public FsmGameObject gameObject; + [Tooltip("Broadcast to all FSMs on the game object's children.")] + public FsmBool sendToChildren; + public FsmBool excludeSelf; + + public override void Reset() + { + broadcastEvent = null; + gameObject = null; + sendToChildren = false; + excludeSelf = false; + } + + public override void OnEnter() + { + if (!string.IsNullOrEmpty(broadcastEvent.Value)) + { + if (gameObject.Value != null) + { + Fsm.BroadcastEventToGameObject(gameObject.Value, broadcastEvent.Value, sendToChildren.Value, excludeSelf.Value); + //BroadcastToGameObject(gameObject.Value); + } + else + { + Fsm.BroadcastEvent(broadcastEvent.Value, excludeSelf.Value); + //BroadcastToAll(); + } + } + + Finish(); + } +/* + void BroadcastToAll() + { + // copy the list in case broadcast event changes Fsm.FsmList + + var fsmList = new List(Fsm.FsmList); + + //Debug.Log("BroadcastToAll"); + foreach (var fsm in fsmList) + { + if (excludeSelf.Value && fsm == Fsm) + { + continue; + } + + //Debug.Log("to: " + fsm.Name); + fsm.Event(broadcastEvent.Value); + } + } + + void BroadcastToGameObject(GameObject go) + { + if (go == null) return; + + Fsm.BroadcastEventToGameObject(go, broadcastEvent.Value, sendToChildren.Value, excludeSelf.Value); + + if (go == null) return; + + var fsmComponents = go.GetComponents(); + + foreach (var fsmComponent in fsmComponents) + { + fsmComponent.Fsm.Event(broadcastEvent.Value); + } + + if (sendToChildren.Value) + { + for (int i = 0; i < go.transform.childCount; i++) + { + BroadcastToGameObject(go.transform.GetChild(i).gameObject); + } + } + }*/ + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BroadcastEvent.cs.meta b/Assets/PlayMaker/Actions/BroadcastEvent.cs.meta new file mode 100755 index 0000000..64144c8 --- /dev/null +++ b/Assets/PlayMaker/Actions/BroadcastEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20931335db4ccb64db86c9d91dce2617 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/BuildString.cs b/Assets/PlayMaker/Actions/BuildString.cs new file mode 100755 index 0000000..ada7d4d --- /dev/null +++ b/Assets/PlayMaker/Actions/BuildString.cs @@ -0,0 +1,77 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Builds a String from other Strings.")] + public class BuildString : FsmStateAction + { + [RequiredField] + [Tooltip("Array of Strings to combine.")] + public FsmString[] stringParts; + + [Tooltip("Separator to insert between each String. E.g. space character.")] + public FsmString separator; + + [Tooltip("Add Separator to end of built string.")] + public FsmBool addToEnd; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the final String in a variable.")] + public FsmString storeResult; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + private string result; + + public override void Reset() + { + stringParts = new FsmString[3]; + separator = null; + addToEnd = true; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoBuildString(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoBuildString(); + } + + void DoBuildString() + { + if (storeResult == null) return; + + result = ""; + + for (var i = 0; i < stringParts.Length-1; i++) + { + result += stringParts[i]; + result += separator.Value; + } + result += stringParts[stringParts.Length - 1]; + + if (addToEnd.Value) + { + result += separator.Value; + } + + storeResult.Value = result; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/BuildString.cs.meta b/Assets/PlayMaker/Actions/BuildString.cs.meta new file mode 100755 index 0000000..e646cf4 --- /dev/null +++ b/Assets/PlayMaker/Actions/BuildString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7b2ad575559473e4db421da96131de2d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CallMethod.cs b/Assets/PlayMaker/Actions/CallMethod.cs new file mode 100755 index 0000000..2347c65 --- /dev/null +++ b/Assets/PlayMaker/Actions/CallMethod.cs @@ -0,0 +1,268 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using System; +using System.Reflection; +using UnityEngine; +using System.Collections.Generic; +using Object = UnityEngine.Object; +using HutongGames.PlayMaker; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.ScriptControl)] + [Tooltip("Call a method in a behaviour.")] + public class CallMethod : FsmStateAction + { + [ObjectType(typeof(MonoBehaviour))] + [Tooltip("Store the component in an Object variable.\nNOTE: Set theObject variable's Object Type to get a component of that type. E.g., set Object Type to UnityEngine.AudioListener to get the AudioListener component on the camera.")] + public FsmObject behaviour; + + //[UIHint(UIHint.Method)] + [Tooltip("Name of the method to call on the component")] + public FsmString methodName; + + [Tooltip("Method paramters. NOTE: these must match the method's signature!")] + public FsmVar[] parameters; + + [ActionSection("Store Result")] + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result of the method call.")] + public FsmVar storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + private FsmObject cachedBehaviour; + private FsmString cachedMethodName; + private Type cachedType; + private MethodInfo cachedMethodInfo; + private ParameterInfo[] cachedParameterInfo; + private object[] parametersArray; + private string errorString; + + public override void Reset() + { + behaviour = null; + methodName = null; + parameters = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + parametersArray = new object[parameters.Length]; + + DoMethodCall(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoMethodCall(); + } + + private void DoMethodCall() + { + if (behaviour.Value == null) + { + Finish(); + return; + } + + if (NeedToUpdateCache()) + { + if (!DoCache()) + { + Debug.LogError(errorString); + Finish(); + return; + } + } + + object result = null; + if (cachedParameterInfo.Length == 0) + { + result = cachedMethodInfo.Invoke(cachedBehaviour.Value, null); + } + else + { + for (var i = 0; i < parameters.Length; i++) + { + var parameter = parameters[i]; + parameter.UpdateValue(); + parametersArray[i] = parameter.GetValue(); + } + + result = cachedMethodInfo.Invoke(cachedBehaviour.Value, parametersArray); + } + + if (!storeResult.IsNone) + { + storeResult.SetValue(result); + } + } + + // TODO: Move tests to helper function in core + private bool NeedToUpdateCache() + { + return cachedBehaviour == null || cachedMethodName == null || // not cached yet + cachedBehaviour.Value != behaviour.Value || // behavior value changed + cachedBehaviour.Name != behaviour.Name || // behavior variable name changed + cachedMethodName.Value != methodName.Value || // methodName value changed + cachedMethodName.Name != methodName.Name; // methodName variable name changed + } + + private bool DoCache() + { + //Debug.Log("DoCache"); + + errorString = string.Empty; + cachedBehaviour = new FsmObject(behaviour); + cachedMethodName = new FsmString(methodName); + + if (cachedBehaviour.Value == null) + { + if (behaviour.UsesVariable && !Application.isPlaying) + { + // Value might be set at runtime + // Display/Log this info...? + } + else + { + errorString += "Behaviour is invalid!\n"; + } + Finish(); + return false; + } + + cachedType = behaviour.Value.GetType(); + var types = new List(parameters.Length); + foreach (var each in parameters) + { + types.Add(each.RealType); + } + +#if NETFX_CORE + var methods = cachedType.GetTypeInfo().GetDeclaredMethods(methodName.Value); + foreach (var method in methods) + { + if (TestMethodSignature(method, types)) + { + cachedMethodInfo = method; + } + } +#else + cachedMethodInfo = cachedType.GetMethod(methodName.Value, types.ToArray()); +#endif + if (cachedMethodInfo == null) + { + errorString += "Invalid Method Name or Parameters: " + methodName.Value + "\n"; + Finish(); + return false; + } + + cachedParameterInfo = cachedMethodInfo.GetParameters(); + return true; + } + +#if NETFX_CORE + private bool TestMethodSignature(MethodInfo method, List parameterTypes) + { + if (method == null) return false; + var methodParameters = method.GetParameters(); + if (methodParameters.Length != parameterTypes.Count) return false; + for (var i = 0; i < methodParameters.Length; i++) + { + if (!ReferenceEquals(methodParameters[i].ParameterType, parameterTypes[i])) + { + return false; + } + } + return true; + } +#endif + + public override string ErrorCheck() + { + /* We could only error check if when we recache, + * however NeedToUpdateCache() is not super robust + * So for now we just recache every frame in editor + * Need to test editor perf... + if (!NeedToUpdateCache()) + { + return errorString; // last error message + }*/ + + if (Application.isPlaying) + { + return errorString; // last error message + } + + errorString = string.Empty; + if (!DoCache()) + { + return errorString; + } + + if (parameters.Length != cachedParameterInfo.Length) + { + return "Parameter count does not match method.\nMethod has " + cachedParameterInfo.Length + " parameters.\nYou specified " + parameters.Length + " paramaters."; + } + + for (var i = 0; i < parameters.Length; i++) + { + var p = parameters[i]; + var paramType = p.RealType; + var paramInfoType = cachedParameterInfo[i].ParameterType; + if (!ReferenceEquals(paramType, paramInfoType)) + { + return "Parameters do not match method signature.\nParameter " + (i + 1) + " (" + paramType + ") should be of type: " + paramInfoType; + } + } + + if (ReferenceEquals(cachedMethodInfo.ReturnType, typeof(void))) + { + if (!string.IsNullOrEmpty(storeResult.variableName)) + { + return "Method does not have return.\nSpecify 'none' in Store Result."; + } + } + else if (!ReferenceEquals(cachedMethodInfo.ReturnType, storeResult.RealType)) + { + return "Store Result is of the wrong type.\nIt should be of type: " + cachedMethodInfo.ReturnType; + } + + return string.Empty; + } + +#if UNITY_EDITOR + public override string AutoName() + { + var name = methodName + "("; + for (int i = 0; i < parameters.Length; i++) + { + var param = parameters[i]; + name += ActionHelpers.GetValueLabel(param.NamedVar); + if (i < parameters.Length - 1) + { + name += ","; + } + } + name += ")"; + + if (!storeResult.IsNone) + { + name = storeResult.variableName + "=" + name; + } + + return name; + } +#endif + } +} diff --git a/Assets/PlayMaker/Actions/CallMethod.cs.meta b/Assets/PlayMaker/Actions/CallMethod.cs.meta new file mode 100755 index 0000000..0e4af73 --- /dev/null +++ b/Assets/PlayMaker/Actions/CallMethod.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f52c1fad52be1734a9cb9a856fe211af +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CallStaticMethod.cs b/Assets/PlayMaker/Actions/CallStaticMethod.cs new file mode 100755 index 0000000..f7ac58f --- /dev/null +++ b/Assets/PlayMaker/Actions/CallStaticMethod.cs @@ -0,0 +1,169 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using System; +using System.Reflection; +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.ScriptControl)] + [Tooltip("Call a static method in a class.")] + public class CallStaticMethod : FsmStateAction + { + [Tooltip("Full path to the class that contains the static method.")] + public FsmString className; + + [Tooltip("The static method to call.")] + public FsmString methodName; + + [Tooltip("Method paramters. NOTE: these must match the method's signature!")] + public FsmVar[] parameters; + + [ActionSection("Store Result")] + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result of the method call.")] + public FsmVar storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + private Type cachedType; + private string cachedClassName; + private string cachedMethodName; + private MethodInfo cachedMethodInfo; + private ParameterInfo[] cachedParameterInfo; + private object[] parametersArray; + private string errorString; + + public override void OnEnter() + { + parametersArray = new object[parameters.Length]; + + DoMethodCall(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoMethodCall(); + } + + private void DoMethodCall() + { + if (className == null || string.IsNullOrEmpty(className.Value)) + { + Finish(); + return; + } + + if (cachedClassName != className.Value || cachedMethodName != methodName.Value) + { + errorString = string.Empty; + if(!DoCache()) + { + Debug.LogError(errorString); + Finish(); + return; + } + } + + object result = null; + if (cachedParameterInfo.Length == 0) + { + result = cachedMethodInfo.Invoke(null, null); + } + else + { + for (var i = 0; i < parameters.Length; i++) + { + var parameter = parameters[i]; + parameter.UpdateValue(); + parametersArray[i] = parameter.GetValue(); + } + + result = cachedMethodInfo.Invoke(null, parametersArray); + } + storeResult.SetValue(result); + } + + private bool DoCache() + { + cachedType = ReflectionUtils.GetGlobalType(className.Value); + if (cachedType == null) + { + errorString += "Class is invalid: " + className.Value + "\n"; + Finish(); + return false; + } + cachedClassName = className.Value; + +#if NETFX_CORE + cachedMethodInfo = cachedType.GetTypeInfo().GetDeclaredMethod(methodName.Value); +#else + var types = new List( capacity: parameters.Length ); + foreach ( var each in parameters ) { + types.Add( each.RealType ); + } + + cachedMethodInfo = cachedType.GetMethod(methodName.Value, types.ToArray()); +#endif + if (cachedMethodInfo == null) + { + errorString += "Invalid Method Name or Parameters: " + methodName.Value +"\n"; + Finish(); + return false; + } + + cachedMethodName = methodName.Value; + cachedParameterInfo = cachedMethodInfo.GetParameters(); + return true; + } + + public override string ErrorCheck() + { + errorString = string.Empty; + DoCache(); + + if (!string.IsNullOrEmpty(errorString)) + { + return errorString; + } + + if (parameters.Length != cachedParameterInfo.Length) + { + return "Parameter count does not match method.\nMethod has " + cachedParameterInfo.Length + " parameters.\nYou specified " +parameters.Length + " paramaters."; + } + + for (var i = 0; i < parameters.Length; i++) + { + var p = parameters[i]; + var paramType = p.RealType; + var paramInfoType = cachedParameterInfo[i].ParameterType; + if (!ReferenceEquals(paramType, paramInfoType )) + { + return "Parameters do not match method signature.\nParameter " + (i + 1) + " (" + paramType + ") should be of type: " + paramInfoType; + } + } + + if (ReferenceEquals(cachedMethodInfo.ReturnType, typeof(void))) + { + if (!string.IsNullOrEmpty(storeResult.variableName)) + { + return "Method does not have return.\nSpecify 'none' in Store Result."; + } + } + else if (!ReferenceEquals(cachedMethodInfo.ReturnType,storeResult.RealType)) + { + return "Store Result is of the wrong type.\nIt should be of type: " + cachedMethodInfo.ReturnType; + } + + return string.Empty; + } + } +} diff --git a/Assets/PlayMaker/Actions/CallStaticMethod.cs.meta b/Assets/PlayMaker/Actions/CallStaticMethod.cs.meta new file mode 100755 index 0000000..39b854e --- /dev/null +++ b/Assets/PlayMaker/Actions/CallStaticMethod.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0066a44ba6edb0d469cc3ac4d31ba298 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CameraFadeIn.cs b/Assets/PlayMaker/Actions/CameraFadeIn.cs new file mode 100755 index 0000000..9de7806 --- /dev/null +++ b/Assets/PlayMaker/Actions/CameraFadeIn.cs @@ -0,0 +1,78 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Fade from a fullscreen Color. NOTE: Uses OnGUI so requires a PlayMakerGUI component in the scene.")] + public class CameraFadeIn : FsmStateAction + { + [RequiredField] + [Tooltip("Color to fade from. E.g., Fade up from black.")] + public FsmColor color; + + [RequiredField] + [HasFloatSlider(0,10)] + [Tooltip("Fade in time in seconds.")] + public FsmFloat time; + + [Tooltip("Event to send when finished.")] + public FsmEvent finishEvent; + + [Tooltip("Ignore TimeScale. Useful if the game is paused.")] + public bool realTime; + + public override void Reset() + { + color = Color.black; + time = 1.0f; + finishEvent = null; + } + + private float startTime; + private float currentTime; + private Color colorLerp; + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + currentTime = 0f; + colorLerp = color.Value; + } + + public override void OnUpdate() + { + if (realTime) + { + currentTime = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + currentTime += Time.deltaTime; + } + + colorLerp = Color.Lerp(color.Value, Color.clear, currentTime/time.Value); + + if (currentTime > time.Value) + { + if (finishEvent != null) + { + Fsm.Event(finishEvent); + } + + Finish(); + } + } + + public override void OnGUI() + { + var guiColor = GUI.color; + GUI.color = colorLerp; + GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height), ActionHelpers.WhiteTexture); + GUI.color = guiColor; + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/CameraFadeIn.cs.meta b/Assets/PlayMaker/Actions/CameraFadeIn.cs.meta new file mode 100755 index 0000000..c213a02 --- /dev/null +++ b/Assets/PlayMaker/Actions/CameraFadeIn.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7750394c42146cd43aa0c3d72c166c45 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CameraFadeOut.cs b/Assets/PlayMaker/Actions/CameraFadeOut.cs new file mode 100755 index 0000000..2f75161 --- /dev/null +++ b/Assets/PlayMaker/Actions/CameraFadeOut.cs @@ -0,0 +1,77 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Fade to a fullscreen Color. NOTE: Uses OnGUI so requires a PlayMakerGUI component in the scene.")] + public class CameraFadeOut : FsmStateAction + { + [RequiredField] + [Tooltip("Color to fade to. E.g., Fade to black.")] + public FsmColor color; + + [RequiredField] + [HasFloatSlider(0,10)] + [Tooltip("Fade out time in seconds.")] + public FsmFloat time; + + [Tooltip("Event to send when finished.")] + public FsmEvent finishEvent; + + [Tooltip("Ignore TimeScale. Useful if the game is paused.")] + public bool realTime; + + public override void Reset() + { + color = Color.black; + time = 1.0f; + finishEvent = null; + } + + private float startTime; + private float currentTime; + private Color colorLerp; + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + currentTime = 0f; + colorLerp = Color.clear; + } + + public override void OnUpdate() + { + if (realTime) + { + currentTime = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + currentTime += Time.deltaTime; + } + + colorLerp = Color.Lerp(Color.clear, color.Value, currentTime/time.Value); + + if (currentTime > time.Value) + { + if (finishEvent != null) + { + Fsm.Event(finishEvent); + } + + // Don't finish since it will stop drawing the fullscreen color + //Finish(); + } + } + + public override void OnGUI() + { + var guiColor = GUI.color; + GUI.color = colorLerp; + GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height), ActionHelpers.WhiteTexture); + GUI.color = guiColor; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/CameraFadeOut.cs.meta b/Assets/PlayMaker/Actions/CameraFadeOut.cs.meta new file mode 100755 index 0000000..33b604d --- /dev/null +++ b/Assets/PlayMaker/Actions/CameraFadeOut.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1c61240297981ce4da9dff4609b23660 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CapturePoseAsAnimationClip.cs b/Assets/PlayMaker/Actions/CapturePoseAsAnimationClip.cs new file mode 100755 index 0000000..b75dd0f --- /dev/null +++ b/Assets/PlayMaker/Actions/CapturePoseAsAnimationClip.cs @@ -0,0 +1,125 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Captures the current pose of a hierarchy as an animation clip.\n\nUseful to blend from an arbitrary pose (e.g. a ragdoll death) back to a known animation (e.g. idle).")] + public class CapturePoseAsAnimationClip : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("The GameObject root of the hierarchy to capture.")] + public FsmOwnerDefault gameObject; + + [Tooltip("Capture position keys.")] + public FsmBool position; + + [Tooltip("Capture rotation keys.")] + public FsmBool rotation; + + [Tooltip("Capture scale keys.")] + public FsmBool scale; + + [RequiredField] + [UIHint(UIHint.Variable)] + [ObjectType(typeof(AnimationClip))] + [Tooltip("Store the result in an Object variable of type AnimationClip.")] + public FsmObject storeAnimationClip; + + public override void Reset() + { + gameObject = null; + position = false; + rotation = true; + scale = false; + storeAnimationClip = null; + } + + public override void OnEnter() + { + DoCaptureAnimationClip(); + + Finish(); + } + + void DoCaptureAnimationClip() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var animClip = new AnimationClip(); + + foreach (Transform child in go.transform) + { + CaptureTransform(child, "", animClip); + } + + storeAnimationClip.Value = animClip; + } + + void CaptureTransform(Transform transform, string path, AnimationClip clip) + { + path += transform.name; + + //Debug.Log(path); + + if (position.Value) + { + CapturePosition(transform, path, clip); + } + + if (rotation.Value) + { + CaptureRotation(transform, path, clip); + } + + if (scale.Value) + { + CaptureScale(transform, path, clip); + } + + foreach (Transform child in transform) + { + CaptureTransform(child, path + "/", clip); + } + } + + void CapturePosition(Transform transform, string path, AnimationClip clip) + { + SetConstantCurve(clip, path, "localPosition.x", transform.localPosition.x); + SetConstantCurve(clip, path, "localPosition.y", transform.localPosition.y); + SetConstantCurve(clip, path, "localPosition.z", transform.localPosition.z); + } + + void CaptureRotation(Transform transform, string path, AnimationClip clip) + { + SetConstantCurve(clip, path, "localRotation.x", transform.localRotation.x); + SetConstantCurve(clip, path, "localRotation.y", transform.localRotation.y); + SetConstantCurve(clip, path, "localRotation.z", transform.localRotation.z); + SetConstantCurve(clip, path, "localRotation.w", transform.localRotation.w); + } + + void CaptureScale(Transform transform, string path, AnimationClip clip) + { + SetConstantCurve(clip, path, "localScale.x", transform.localScale.x); + SetConstantCurve(clip, path, "localScale.y", transform.localScale.y); + SetConstantCurve(clip, path, "localScale.z", transform.localScale.z); + } + + void SetConstantCurve(AnimationClip clip, string childPath, string propertyPath, float value) + { + var curve = AnimationCurve.Linear(0, value, 100, value); + curve.postWrapMode = WrapMode.Loop; + + clip.SetCurve(childPath, typeof(Transform), propertyPath, curve); + } + + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/CapturePoseAsAnimationClip.cs.meta b/Assets/PlayMaker/Actions/CapturePoseAsAnimationClip.cs.meta new file mode 100755 index 0000000..82f16aa --- /dev/null +++ b/Assets/PlayMaker/Actions/CapturePoseAsAnimationClip.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b879bd09b7eebe94782860779d5cc275 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CollisionEvent.cs b/Assets/PlayMaker/Actions/CollisionEvent.cs new file mode 100755 index 0000000..a3530cd --- /dev/null +++ b/Assets/PlayMaker/Actions/CollisionEvent.cs @@ -0,0 +1,118 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Detect collisions between the Owner of this FSM and other Game Objects that have RigidBody components.\nNOTE: The system events, COLLISION ENTER, COLLISION STAY, and COLLISION EXIT are sent automatically on collisions with any object. Use this action to filter collisions by Tag.")] + public class CollisionEvent : FsmStateAction + { + [Tooltip("The type of collision to detect.")] + public CollisionType collision; + + [UIHint(UIHint.Tag)] + [Tooltip("Filter by Tag.")] + public FsmString collideTag; + + [Tooltip("Event to send if a collision is detected.")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the GameObject that collided with the Owner of this FSM.")] + public FsmGameObject storeCollider; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the force of the collision. NOTE: Use Get Collision Info to get more info about the collision.")] + public FsmFloat storeForce; + + public override void Reset() + { + collision = CollisionType.OnCollisionEnter; + collideTag = "Untagged"; + sendEvent = null; + storeCollider = null; + storeForce = null; + } + + public override void OnPreprocess() + { + switch (collision) + { + case CollisionType.OnCollisionEnter: + Fsm.HandleCollisionEnter = true; + break; + case CollisionType.OnCollisionStay: + Fsm.HandleCollisionStay = true; + break; + case CollisionType.OnCollisionExit: + Fsm.HandleCollisionExit = true; + break; + } + + } + + void StoreCollisionInfo(Collision collisionInfo) + { + storeCollider.Value = collisionInfo.gameObject; + storeForce.Value = collisionInfo.relativeVelocity.magnitude; + } + + public override void DoCollisionEnter(Collision collisionInfo) + { + if (collision == CollisionType.OnCollisionEnter) + { + if (collisionInfo.collider.gameObject.tag == collideTag.Value) + { + StoreCollisionInfo(collisionInfo); + Fsm.Event(sendEvent); + } + } + } + + public override void DoCollisionStay(Collision collisionInfo) + { + if (collision == CollisionType.OnCollisionStay) + { + if (collisionInfo.collider.gameObject.tag == collideTag.Value) + { + StoreCollisionInfo(collisionInfo); + Fsm.Event(sendEvent); + } + } + } + + public override void DoCollisionExit(Collision collisionInfo) + { + if (collision == CollisionType.OnCollisionExit) + { + if (collisionInfo.collider.gameObject.tag == collideTag.Value) + { + StoreCollisionInfo(collisionInfo); + Fsm.Event(sendEvent); + } + } + } + + public override void DoControllerColliderHit(ControllerColliderHit collisionInfo) + { + if (collision == CollisionType.OnControllerColliderHit) + { + if (collisionInfo.collider.gameObject.tag == collideTag.Value) + { + if (storeCollider != null) + storeCollider.Value = collisionInfo.gameObject; + + storeForce.Value = 0f; //TODO: impact force? + Fsm.Event(sendEvent); + } + } + } + + public override string ErrorCheck() + { + return ActionHelpers.CheckOwnerPhysicsSetup(Owner); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/CollisionEvent.cs.meta b/Assets/PlayMaker/Actions/CollisionEvent.cs.meta new file mode 100755 index 0000000..1da3126 --- /dev/null +++ b/Assets/PlayMaker/Actions/CollisionEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6a06ca6d8ec9db846a1d5d88107777cf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ColorInterpolate.cs b/Assets/PlayMaker/Actions/ColorInterpolate.cs new file mode 100755 index 0000000..3ddf001 --- /dev/null +++ b/Assets/PlayMaker/Actions/ColorInterpolate.cs @@ -0,0 +1,122 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Color)] + [Tooltip("Interpolate through an array of Colors over a specified amount of Time.")] + public class ColorInterpolate : FsmStateAction + { + [RequiredField] + [Tooltip("Array of colors to interpolate through.")] + public FsmColor[] colors; + + [RequiredField] + [Tooltip("Interpolation time.")] + public FsmFloat time; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the interpolated color in a Color variable.")] + public FsmColor storeColor; + + [Tooltip("Event to send when the interpolation finishes.")] + public FsmEvent finishEvent; + + [Tooltip("Ignore TimeScale")] + public bool realTime; + + private float startTime; + private float currentTime; + + public override void Reset() + { + colors = new FsmColor[3]; + time = 1.0f; + storeColor = null; + finishEvent = null; + realTime = false; + } + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + currentTime = 0f; + + if (colors.Length < 2) + { + if (colors.Length == 1) + { + storeColor.Value = colors[0].Value; + } + Finish(); + } + else + { + storeColor.Value = colors[0].Value; + } + } + + public override void OnUpdate() + { + // update time + + if (realTime) + { + currentTime = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + currentTime += Time.deltaTime; + } + + // finished? + + if (currentTime > time.Value) + { + Finish(); + + storeColor.Value = colors[colors.Length - 1].Value; + + if (finishEvent != null) + { + Fsm.Event(finishEvent); + } + + return; + } + + // lerp + + Color lerpColor; + var lerpAmount = (colors.Length-1) * currentTime/time.Value; + + if (lerpAmount.Equals(0)) + { + lerpColor = colors[0].Value; + } + + else if (lerpAmount.Equals(colors.Length-1)) + { + lerpColor = colors[colors.Length-1].Value; + } + + else + { + var color1 = colors[Mathf.FloorToInt(lerpAmount)].Value; + var color2 = colors[Mathf.CeilToInt(lerpAmount)].Value; + lerpAmount -= Mathf.Floor(lerpAmount); + + lerpColor = Color.Lerp(color1, color2, lerpAmount); + } + + storeColor.Value = lerpColor; + } + + public override string ErrorCheck () + { + return colors.Length < 2 ? "Define at least 2 colors to make a gradient." : null; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ColorInterpolate.cs.meta b/Assets/PlayMaker/Actions/ColorInterpolate.cs.meta new file mode 100755 index 0000000..7d1f1fb --- /dev/null +++ b/Assets/PlayMaker/Actions/ColorInterpolate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1521b5e737c712a4aaa0130e5bbddd06 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ColorRamp.cs b/Assets/PlayMaker/Actions/ColorRamp.cs new file mode 100755 index 0000000..55361c7 --- /dev/null +++ b/Assets/PlayMaker/Actions/ColorRamp.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Color)] + [Tooltip("Samples a Color on a continuous Colors gradient.")] + public class ColorRamp : FsmStateAction + { + [RequiredField] + [Tooltip("Array of colors to defining the gradient.")] + public FsmColor[] colors; + + [RequiredField] + [Tooltip("Point on the gradient to sample. Should be between 0 and the number of colors in the gradient.")] + public FsmFloat sampleAt; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the sampled color in a Color variable.")] + public FsmColor storeColor; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + colors = new FsmColor[3]; + sampleAt = 0; + storeColor = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoColorRamp(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoColorRamp(); + } + + void DoColorRamp() + { + if (colors == null) return; + if (colors.Length == 0) return; + if (sampleAt == null) return; + if (storeColor == null) return; + + Color lerpColor; + var lerpAmount = Mathf.Clamp(sampleAt.Value, 0, colors.Length-1); + + if (lerpAmount == 0) + { + lerpColor = colors[0].Value; + } + else if (lerpAmount == colors.Length) + { + lerpColor = colors[colors.Length-1].Value; + } + else + { + var color1 = colors[Mathf.FloorToInt(lerpAmount)].Value; + var color2 = colors[Mathf.CeilToInt(lerpAmount)].Value; + lerpAmount -= Mathf.Floor(lerpAmount); + + lerpColor = Color.Lerp(color1, color2, lerpAmount); + } + + storeColor.Value = lerpColor; + } + + public override string ErrorCheck () + { + if (colors.Length < 2) + { + return "Define at least 2 colors to make a gradient."; + } + return null; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ColorRamp.cs.meta b/Assets/PlayMaker/Actions/ColorRamp.cs.meta new file mode 100755 index 0000000..b42302d --- /dev/null +++ b/Assets/PlayMaker/Actions/ColorRamp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3e09d8a9fe0d9244a8d01810500725a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Comment.cs b/Assets/PlayMaker/Actions/Comment.cs new file mode 100755 index 0000000..59497a5 --- /dev/null +++ b/Assets/PlayMaker/Actions/Comment.cs @@ -0,0 +1,22 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Adds a text area to the action list. NOTE: Doesn't do anything, just for notes...")] + public class Comment : FsmStateAction + { + [UIHint(UIHint.Comment)] + public string comment; + + public override void Reset() + { + comment = ""; + } + + public override void OnEnter() + { + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Comment.cs.meta b/Assets/PlayMaker/Actions/Comment.cs.meta new file mode 100755 index 0000000..8240b8b --- /dev/null +++ b/Assets/PlayMaker/Actions/Comment.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6a5b874eadc685146bfc648baec9d751 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ComponentAction.cs b/Assets/PlayMaker/Actions/ComponentAction.cs new file mode 100755 index 0000000..46c1513 --- /dev/null +++ b/Assets/PlayMaker/Actions/ComponentAction.cs @@ -0,0 +1,81 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + // Base class for actions that access a Component on a GameObject. + // Caches the component for performance + public abstract class ComponentAction : FsmStateAction where T : Component + { + private GameObject cachedGameObject; + private T component; + + protected Rigidbody rigidbody + { + get { return component as Rigidbody; } + } + + protected Renderer renderer + { + get { return component as Renderer; } + } + + protected Animation animation + { + get { return component as Animation; } + } + + protected AudioSource audio + { + get { return component as AudioSource; } + } + + protected Camera camera + { + get { return component as Camera; } + } + + protected GUIText guiText + { + get { return component as GUIText; } + } + + protected GUITexture guiTexture + { + get { return component as GUITexture; } + } + + protected Light light + { + get { return component as Light; } + } + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + protected NetworkView networkView + { + get { return component as NetworkView; } + } +#endif + protected bool UpdateCache(GameObject go) + { + if (go == null) + { + return false; + } + + if (component == null || cachedGameObject != go) + { + component = go.GetComponent(); + cachedGameObject = go; + + if (component == null) + { + LogWarning("Missing component: " + typeof(T).FullName + " on: " + go.name); + } + } + + return component != null; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ComponentAction.cs.meta b/Assets/PlayMaker/Actions/ComponentAction.cs.meta new file mode 100755 index 0000000..4d176c2 --- /dev/null +++ b/Assets/PlayMaker/Actions/ComponentAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fe02f53520edc8b419bac5fadc0630fd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ControllerIsGrounded.cs b/Assets/PlayMaker/Actions/ControllerIsGrounded.cs new file mode 100755 index 0000000..a07ea49 --- /dev/null +++ b/Assets/PlayMaker/Actions/ControllerIsGrounded.cs @@ -0,0 +1,79 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Character)] + [Tooltip("Tests if a Character Controller on a Game Object was touching the ground during the last move.")] + public class ControllerIsGrounded : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(CharacterController))] + [Tooltip("The GameObject to check.")] + public FsmOwnerDefault gameObject; + + [Tooltip("Event to send if touching the ground.")] + public FsmEvent trueEvent; + + [Tooltip("Event to send if not touching the ground.")] + public FsmEvent falseEvent; + + [Tooltip("Sore the result in a bool variable.")] + [UIHint(UIHint.Variable)] + public FsmBool storeResult; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + private GameObject previousGo; // remember so we can get new controller only when it changes. + private CharacterController controller; + + public override void Reset() + { + gameObject = null; + trueEvent = null; + falseEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoControllerIsGrounded(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoControllerIsGrounded(); + } + + void DoControllerIsGrounded() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (go != previousGo) + { + controller = go.GetComponent(); + previousGo = go; + } + + if (controller == null) return; + + var isGrounded = controller.isGrounded; + + storeResult.Value = isGrounded; + + Fsm.Event(isGrounded ? trueEvent : falseEvent); + } + } +} diff --git a/Assets/PlayMaker/Actions/ControllerIsGrounded.cs.meta b/Assets/PlayMaker/Actions/ControllerIsGrounded.cs.meta new file mode 100755 index 0000000..b3141e3 --- /dev/null +++ b/Assets/PlayMaker/Actions/ControllerIsGrounded.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: caa9b85a8f718a542b1b01e94b63d2c3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ControllerMove.cs b/Assets/PlayMaker/Actions/ControllerMove.cs new file mode 100755 index 0000000..bc210d0 --- /dev/null +++ b/Assets/PlayMaker/Actions/ControllerMove.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Character)] + [Tooltip("Moves a Game Object with a Character Controller. See also Controller Simple Move. NOTE: It is recommended that you make only one call to Move or SimpleMove per frame.")] + public class ControllerMove : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(CharacterController))] + [Tooltip("The GameObject to move.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The movement vector.")] + public FsmVector3 moveVector; + + [Tooltip("Move in local or word space.")] + public Space space; + + [Tooltip("Movement vector is defined in units per second. Makes movement frame rate independent.")] + public FsmBool perSecond; + + private GameObject previousGo; // remember so we can get new controller only when it changes. + private CharacterController controller; + + public override void Reset() + { + gameObject = null; + moveVector = new FsmVector3 {UseVariable = true}; + space = Space.World; + perSecond = true; + } + + public override void OnUpdate() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + if (go != previousGo) + { + controller = go.GetComponent(); + previousGo = go; + } + + if (controller != null) + { + var move = space == Space.World ? moveVector.Value : go.transform.TransformDirection(moveVector.Value); + + if (perSecond.Value) + { + controller.Move(move * Time.deltaTime); + } + else + { + controller.Move(move); + } + } + } + } +} diff --git a/Assets/PlayMaker/Actions/ControllerMove.cs.meta b/Assets/PlayMaker/Actions/ControllerMove.cs.meta new file mode 100755 index 0000000..ffb2bb5 --- /dev/null +++ b/Assets/PlayMaker/Actions/ControllerMove.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1f380e65a6e5c7043a6414d3721d2197 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ControllerSettings.cs b/Assets/PlayMaker/Actions/ControllerSettings.cs new file mode 100755 index 0000000..9409054 --- /dev/null +++ b/Assets/PlayMaker/Actions/ControllerSettings.cs @@ -0,0 +1,95 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Character)] + [Tooltip("Modify various character controller settings.\n'None' leaves the setting unchanged.")] + public class ControllerSettings : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(CharacterController))] + [Tooltip("The GameObject that owns the CharacterController.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The height of the character's capsule.")] + public FsmFloat height; + + [Tooltip("The radius of the character's capsule.")] + public FsmFloat radius; + + [Tooltip("The character controllers slope limit in degrees.")] + public FsmFloat slopeLimit; + + [Tooltip("The character controllers step offset in meters.")] + public FsmFloat stepOffset; + + [Tooltip("The center of the character's capsule relative to the transform's position")] + public FsmVector3 center; + + [Tooltip("Should other rigidbodies or character controllers collide with this character controller (By default always enabled).")] + public FsmBool detectCollisions; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + // cache so we can get new controller only when it changes. + + GameObject previousGo; + CharacterController controller; + + public override void Reset() + { + gameObject = null; + height = new FsmFloat { UseVariable = true }; + radius = new FsmFloat { UseVariable = true }; + slopeLimit = new FsmFloat { UseVariable = true }; + stepOffset = new FsmFloat { UseVariable = true }; + center = new FsmVector3 { UseVariable = true }; + detectCollisions = new FsmBool { UseVariable = true }; + everyFrame = false; + } + + public override void OnEnter() + { + DoControllerSettings(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoControllerSettings(); + } + + + void DoControllerSettings() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (go != previousGo) + { + controller = go.GetComponent(); + previousGo = go; + } + + if (controller != null) + { + if (!height.IsNone) controller.height = height.Value; + if (!radius.IsNone) controller.radius = radius.Value; + if (!slopeLimit.IsNone) controller.slopeLimit = slopeLimit.Value; + if (!stepOffset.IsNone) controller.stepOffset = stepOffset.Value; + if (!center.IsNone) controller.center = center.Value; + if (!detectCollisions.IsNone) controller.detectCollisions = detectCollisions.Value; + } + } + } +} diff --git a/Assets/PlayMaker/Actions/ControllerSettings.cs.meta b/Assets/PlayMaker/Actions/ControllerSettings.cs.meta new file mode 100755 index 0000000..cde1677 --- /dev/null +++ b/Assets/PlayMaker/Actions/ControllerSettings.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d9ce2594deb14894baeec30cb77ac184 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ControllerSimpleMove.cs b/Assets/PlayMaker/Actions/ControllerSimpleMove.cs new file mode 100755 index 0000000..bf95348 --- /dev/null +++ b/Assets/PlayMaker/Actions/ControllerSimpleMove.cs @@ -0,0 +1,56 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Character)] + [Tooltip("Moves a Game Object with a Character Controller. Velocity along the y-axis is ignored. Speed is in meters/s. Gravity is automatically applied.")] + public class ControllerSimpleMove : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(CharacterController))] + [Tooltip("The GameObject to move.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The movement vector.")] + public FsmVector3 moveVector; + + [Tooltip("Multiply the movement vector by a speed factor.")] + public FsmFloat speed; + + [Tooltip("Move in local or word space.")] + public Space space; + + private GameObject previousGo; // remember so we can get new controller only when it changes. + private CharacterController controller; + + public override void Reset() + { + gameObject = null; + moveVector = new FsmVector3 {UseVariable = true}; + speed = 1; + space = Space.World; + } + + public override void OnUpdate() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + if (go != previousGo) + { + controller = go.GetComponent(); + previousGo = go; + } + + if (controller != null) + { + var move = space == Space.World ? moveVector.Value : go.transform.TransformDirection(moveVector.Value); + + controller.SimpleMove(move * speed.Value); + } + } + } +} diff --git a/Assets/PlayMaker/Actions/ControllerSimpleMove.cs.meta b/Assets/PlayMaker/Actions/ControllerSimpleMove.cs.meta new file mode 100755 index 0000000..01d3665 --- /dev/null +++ b/Assets/PlayMaker/Actions/ControllerSimpleMove.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d335426cd3a656448a4a60cebe7825df +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertBoolToColor.cs b/Assets/PlayMaker/Actions/ConvertBoolToColor.cs new file mode 100755 index 0000000..5fcbe2e --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertBoolToColor.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts a Bool value to a Color.")] + public class ConvertBoolToColor : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variable to test.")] + public FsmBool boolVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Color variable to set based on the bool variable value.")] + public FsmColor colorVariable; + + [Tooltip("Color if Bool variable is false.")] + public FsmColor falseColor; + + [Tooltip("Color if Bool variable is true.")] + public FsmColor trueColor; + + [Tooltip("Repeat every frame. Useful if the Bool variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + boolVariable = null; + colorVariable = null; + falseColor = Color.black; + trueColor = Color.white; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertBoolToColor(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertBoolToColor(); + } + + void DoConvertBoolToColor() + { + colorVariable.Value = boolVariable.Value ? trueColor.Value : falseColor.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertBoolToColor.cs.meta b/Assets/PlayMaker/Actions/ConvertBoolToColor.cs.meta new file mode 100755 index 0000000..4722198 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertBoolToColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: abc72cf566c2db1428c762b4ce9efe21 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertBoolToFloat.cs b/Assets/PlayMaker/Actions/ConvertBoolToFloat.cs new file mode 100755 index 0000000..45f4077 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertBoolToFloat.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts a Bool value to a Float value.")] + public class ConvertBoolToFloat : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variable to test.")] + public FsmBool boolVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Float variable to set based on the Bool variable value.")] + public FsmFloat floatVariable; + + [Tooltip("Float value if Bool variable is false.")] + public FsmFloat falseValue; + + [Tooltip("Float value if Bool variable is true.")] + public FsmFloat trueValue; + + [Tooltip("Repeat every frame. Useful if the Bool variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + boolVariable = null; + floatVariable = null; + falseValue = 0; + trueValue = 1; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertBoolToFloat(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertBoolToFloat(); + } + + void DoConvertBoolToFloat() + { + floatVariable.Value = boolVariable.Value ? trueValue.Value : falseValue.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertBoolToFloat.cs.meta b/Assets/PlayMaker/Actions/ConvertBoolToFloat.cs.meta new file mode 100755 index 0000000..82b156c --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertBoolToFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1785c4b9b31b055489883b6a1492adc6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertBoolToInt.cs b/Assets/PlayMaker/Actions/ConvertBoolToInt.cs new file mode 100755 index 0000000..67cd0cc --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertBoolToInt.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts a Bool value to an Integer value.")] + public class ConvertBoolToInt : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variable to test.")] + public FsmBool boolVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Integer variable to set based on the Bool variable value.")] + public FsmInt intVariable; + + [Tooltip("Integer value if Bool variable is false.")] + public FsmInt falseValue; + + [Tooltip("Integer value if Bool variable is false.")] + public FsmInt trueValue; + + [Tooltip("Repeat every frame. Useful if the Bool variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + boolVariable = null; + intVariable = null; + falseValue = 0; + trueValue = 1; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertBoolToInt(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertBoolToInt(); + } + + void DoConvertBoolToInt() + { + intVariable.Value = boolVariable.Value ? trueValue.Value : falseValue.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertBoolToInt.cs.meta b/Assets/PlayMaker/Actions/ConvertBoolToInt.cs.meta new file mode 100755 index 0000000..f37602f --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertBoolToInt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f28800202f2a2b2488205a83acbf51bf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertBoolToString.cs b/Assets/PlayMaker/Actions/ConvertBoolToString.cs new file mode 100755 index 0000000..34e1d88 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertBoolToString.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts a Bool value to a String value.")] + public class ConvertBoolToString : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variable to test.")] + public FsmBool boolVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The String variable to set based on the Bool variable value.")] + public FsmString stringVariable; + + [Tooltip("String value if Bool variable is false.")] + public FsmString falseString; + + [Tooltip("String value if Bool variable is true.")] + public FsmString trueString; + + [Tooltip("Repeat every frame. Useful if the Bool variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + boolVariable = null; + stringVariable = null; + falseString = "False"; + trueString = "True"; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertBoolToString(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertBoolToString(); + } + + void DoConvertBoolToString() + { + stringVariable.Value = boolVariable.Value ? trueString.Value : falseString.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertBoolToString.cs.meta b/Assets/PlayMaker/Actions/ConvertBoolToString.cs.meta new file mode 100755 index 0000000..773f061 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertBoolToString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3eaa51191417f614ebfbc37a95b81efd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertEnumToString.cs b/Assets/PlayMaker/Actions/ConvertEnumToString.cs new file mode 100755 index 0000000..96194a3 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertEnumToString.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts an Enum value to a String value.")] + public class ConvertEnumToString : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Enum variable to convert.")] + public FsmEnum enumVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The String variable to store the converted value.")] + public FsmString stringVariable; + + [Tooltip("Repeat every frame. Useful if the Enum variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + enumVariable = null; + stringVariable = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertEnumToString(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertEnumToString(); + } + + void DoConvertEnumToString() + { + stringVariable.Value = enumVariable.Value != null ? enumVariable.Value.ToString() : ""; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertEnumToString.cs.meta b/Assets/PlayMaker/Actions/ConvertEnumToString.cs.meta new file mode 100755 index 0000000..20a1171 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertEnumToString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ff4c5b0baaf92be4496c3474ae6ca767 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertFloatToInt.cs b/Assets/PlayMaker/Actions/ConvertFloatToInt.cs new file mode 100755 index 0000000..d714e04 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertFloatToInt.cs @@ -0,0 +1,74 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts a Float value to an Integer value.")] + public class ConvertFloatToInt : FsmStateAction + { + public enum FloatRounding + { + RoundDown, + RoundUp, + Nearest + } + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Float variable to convert to an integer.")] + public FsmFloat floatVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in an Integer variable.")] + public FsmInt intVariable; + + public FloatRounding rounding; + + public bool everyFrame; + + public override void Reset() + { + floatVariable = null; + intVariable = null; + rounding = FloatRounding.Nearest; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertFloatToInt(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertFloatToInt(); + } + + void DoConvertFloatToInt() + { + switch (rounding) + { + + case FloatRounding.Nearest: + intVariable.Value = Mathf.RoundToInt(floatVariable.Value); + break; + + case FloatRounding.RoundDown: + intVariable.Value = Mathf.FloorToInt(floatVariable.Value); + break; + + case FloatRounding.RoundUp: + intVariable.Value = Mathf.CeilToInt(floatVariable.Value); + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertFloatToInt.cs.meta b/Assets/PlayMaker/Actions/ConvertFloatToInt.cs.meta new file mode 100755 index 0000000..5fb5713 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertFloatToInt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fef83905517654a4b86a427636e8a50f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertFloatToString.cs b/Assets/PlayMaker/Actions/ConvertFloatToString.cs new file mode 100755 index 0000000..279bf34 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertFloatToString.cs @@ -0,0 +1,62 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts a Float value to a String value with optional format.")] + public class ConvertFloatToString : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The float variable to convert.")] + public FsmFloat floatVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("A string variable to store the converted value.")] + public FsmString stringVariable; + + [Tooltip("Optional Format, allows for leading zeroes. E.g., 0000")] + public FsmString format; + + [Tooltip("Repeat every frame. Useful if the float variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + floatVariable = null; + stringVariable = null; + everyFrame = false; + format = null; + } + + public override void OnEnter() + { + DoConvertFloatToString(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertFloatToString(); + } + + void DoConvertFloatToString() + { + if (format.IsNone || string.IsNullOrEmpty(format.Value)) + { + stringVariable.Value = floatVariable.Value.ToString(); + } + else + { + stringVariable.Value = floatVariable.Value.ToString(format.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertFloatToString.cs.meta b/Assets/PlayMaker/Actions/ConvertFloatToString.cs.meta new file mode 100755 index 0000000..cdde539 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertFloatToString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 83cb2bebe956b4e41973ba7844cf7905 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertIntToFloat.cs b/Assets/PlayMaker/Actions/ConvertIntToFloat.cs new file mode 100755 index 0000000..4caf7ee --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertIntToFloat.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts an Integer value to a Float value.")] + public class ConvertIntToFloat : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Integer variable to convert to a float.")] + public FsmInt intVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a Float variable.")] + public FsmFloat floatVariable; + + [Tooltip("Repeat every frame. Useful if the Integer variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + intVariable = null; + floatVariable = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertIntToFloat(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoConvertIntToFloat(); + } + + void DoConvertIntToFloat() + { + floatVariable.Value = intVariable.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertIntToFloat.cs.meta b/Assets/PlayMaker/Actions/ConvertIntToFloat.cs.meta new file mode 100755 index 0000000..b1c1037 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertIntToFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a9486bf109dec1d45824da934235f1af +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertIntToString.cs b/Assets/PlayMaker/Actions/ConvertIntToString.cs new file mode 100755 index 0000000..1b7d95f --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertIntToString.cs @@ -0,0 +1,62 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts an Integer value to a String value with an optional format.")] + public class ConvertIntToString : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Int variable to convert.")] + public FsmInt intVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("A String variable to store the converted value.")] + public FsmString stringVariable; + + [Tooltip("Optional Format, allows for leading zeroes. E.g., 0000")] + public FsmString format; + + [Tooltip("Repeat every frame. Useful if the Int variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + intVariable = null; + stringVariable = null; + everyFrame = false; + format = null; + } + + public override void OnEnter() + { + DoConvertIntToString(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertIntToString(); + } + + void DoConvertIntToString() + { + if (format.IsNone || string.IsNullOrEmpty(format.Value)) + { + stringVariable.Value = intVariable.Value.ToString(); + } + else + { + stringVariable.Value = intVariable.Value.ToString(format.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertIntToString.cs.meta b/Assets/PlayMaker/Actions/ConvertIntToString.cs.meta new file mode 100755 index 0000000..8c9a809 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertIntToString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a57adc7ae10e64947af9dfd85a4b0b7b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertMaterialToObject.cs b/Assets/PlayMaker/Actions/ConvertMaterialToObject.cs new file mode 100755 index 0000000..9574978 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertMaterialToObject.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts a Material variable to an Object variable. Useful if you want to use Set Property (which only works on Object variables).")] + public class ConvertMaterialToObject : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Material variable to convert to an Object.")] + public FsmMaterial materialVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in an Object variable.")] + public FsmObject objectVariable; + + [Tooltip("Repeat every frame. Useful if the Material variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + materialVariable = null; + objectVariable = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertMaterialToObject(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertMaterialToObject(); + } + + void DoConvertMaterialToObject() + { + objectVariable.Value = materialVariable.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertMaterialToObject.cs.meta b/Assets/PlayMaker/Actions/ConvertMaterialToObject.cs.meta new file mode 100755 index 0000000..66f17b6 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertMaterialToObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e6d46eac91f9daa499286f795155bfd2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertSecondsToString.cs b/Assets/PlayMaker/Actions/ConvertSecondsToString.cs new file mode 100755 index 0000000..a3d950b --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertSecondsToString.cs @@ -0,0 +1,74 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +using UnityEngine; +using System; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [HelpUrl("http://hutonggames.com/playmakerforum/index.php?topic=1711.0")] + [Tooltip("Converts Seconds to a String value representing the time.")] + public class ConvertSecondsToString : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The seconds variable to convert.")] + public FsmFloat secondsVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("A string variable to store the time value.")] + public FsmString stringVariable; + + [RequiredField] + [Tooltip("Format. 0 for days, 1 is for hours, 2 for minutes, 3 for seconds and 4 for milliseconds. 5 for total days, 6 for total hours, 7 for total minutes, 8 for total seconds, 9 for total milliseconds, 10 for two digits milliseconds. so {2:D2} would just show the seconds of the current time, NOT the grand total number of seconds, the grand total of seconds would be {8:F0}")] + public FsmString format; + + [Tooltip("Repeat every frame. Useful if the seconds variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + secondsVariable = null; + stringVariable = null; + everyFrame = false; + format = "{1:D2}h:{2:D2}m:{3:D2}s:{10}ms"; + } + + public override void OnEnter() + { + DoConvertSecondsToString(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoConvertSecondsToString(); + } + + void DoConvertSecondsToString() + { + TimeSpan t = TimeSpan.FromSeconds(secondsVariable.Value); + + string milliseconds_2D = t.Milliseconds.ToString("D3").PadLeft(2, '0'); + milliseconds_2D = milliseconds_2D.Substring(0,2); + + stringVariable.Value = string.Format(format.Value, + t.Days, + t.Hours, + t.Minutes, + t.Seconds, + t.Milliseconds, + t.TotalDays, + t.TotalHours, + t.TotalMinutes, + t.TotalSeconds, + t.TotalMilliseconds, + milliseconds_2D); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertSecondsToString.cs.meta b/Assets/PlayMaker/Actions/ConvertSecondsToString.cs.meta new file mode 100755 index 0000000..e536fe1 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertSecondsToString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b3fbd58b6e607dc45be3fb9de999c4b9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ConvertStringToInt.cs b/Assets/PlayMaker/Actions/ConvertStringToInt.cs new file mode 100755 index 0000000..babaf00 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertStringToInt.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Convert)] + [Tooltip("Converts an String value to an Int value.")] + public class ConvertStringToInt : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The String variable to convert to an integer.")] + public FsmString stringVariable; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in an Int variable.")] + public FsmInt intVariable; + + [Tooltip("Repeat every frame. Useful if the String variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + intVariable = null; + stringVariable = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoConvertStringToInt(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoConvertStringToInt(); + } + + void DoConvertStringToInt() + { + intVariable.Value = int.Parse(stringVariable.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ConvertStringToInt.cs.meta b/Assets/PlayMaker/Actions/ConvertStringToInt.cs.meta new file mode 100755 index 0000000..dc2d239 --- /dev/null +++ b/Assets/PlayMaker/Actions/ConvertStringToInt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9fd2d70c3e210c34789e8d8d6baa10b8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CreateEmptyObject.cs b/Assets/PlayMaker/Actions/CreateEmptyObject.cs new file mode 100755 index 0000000..68d1b29 --- /dev/null +++ b/Assets/PlayMaker/Actions/CreateEmptyObject.cs @@ -0,0 +1,77 @@ + +// SLY added if null create empty object + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Creates a Game Object at a spawn point.\nUse a Game Object and/or Position/Rotation for the Spawn Point. If you specify a Game Object, Position is used as a local offset, and Rotation will override the object's rotation.")] + public class CreateEmptyObject : FsmStateAction + { + public FsmGameObject gameObject; + public FsmGameObject spawnPoint; + public FsmVector3 position; + public FsmVector3 rotation; + [UIHint(UIHint.Variable)] + [Tooltip("Optionally store the created object.")] + public FsmGameObject storeObject; + + public override void Reset() + { + gameObject = null; + spawnPoint = null; + position = new FsmVector3 { UseVariable = true }; + rotation = new FsmVector3 { UseVariable = true }; + storeObject = null; + } + + public override void OnEnter() + { + var go = gameObject.Value; + + Vector3 spawnPosition = Vector3.zero; + Vector3 spawnRotation = Vector3.zero; + + if (spawnPoint.Value != null) + { + spawnPosition = spawnPoint.Value.transform.position; + if (!position.IsNone) + spawnPosition += position.Value; + + if (!rotation.IsNone) + spawnRotation = rotation.Value; + else + spawnRotation = spawnPoint.Value.transform.eulerAngles; + } + else + { + if (!position.IsNone) + spawnPosition = position.Value; + + if (!rotation.IsNone) + spawnRotation = rotation.Value; + } + + var newObject = storeObject.Value; + + if (go != null) + { + newObject = (GameObject)Object.Instantiate(go); + storeObject.Value = newObject; + } + else + { + newObject = new GameObject( "EmptyObjectFromNull" ); + storeObject.Value = newObject; + } + if (newObject != null) + { + newObject.transform.position = spawnPosition; + newObject.transform.eulerAngles = spawnRotation; + } + Finish(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/CreateEmptyObject.cs.meta b/Assets/PlayMaker/Actions/CreateEmptyObject.cs.meta new file mode 100755 index 0000000..6ac7251 --- /dev/null +++ b/Assets/PlayMaker/Actions/CreateEmptyObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 00c62e062f0301a40aea02e25c059045 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CreateObject.cs b/Assets/PlayMaker/Actions/CreateObject.cs new file mode 100755 index 0000000..c68ef74 --- /dev/null +++ b/Assets/PlayMaker/Actions/CreateObject.cs @@ -0,0 +1,102 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Creates a Game Object, usually from a Prefab.")] + public class CreateObject : FsmStateAction + { + [RequiredField] + [Tooltip("GameObject to create. Usually a Prefab.")] + public FsmGameObject gameObject; + + [Tooltip("Optional Spawn Point.")] + public FsmGameObject spawnPoint; + + [Tooltip("Position. If a Spawn Point is defined, this is used as a local offset from the Spawn Point position.")] + public FsmVector3 position; + + [Tooltip("Rotation. NOTE: Overrides the rotation of the Spawn Point.")] + public FsmVector3 rotation; + + [UIHint(UIHint.Variable)] + [Tooltip("Optionally store the created object.")] + public FsmGameObject storeObject; + + [Tooltip("Use Network.Instantiate to create a Game Object on all clients in a networked game.")] + public FsmBool networkInstantiate; + + [Tooltip("Usually 0. The group number allows you to group together network messages which allows you to filter them if so desired.")] + public FsmInt networkGroup; + + public override void Reset() + { + gameObject = null; + spawnPoint = null; + position = new FsmVector3 { UseVariable = true }; + rotation = new FsmVector3 { UseVariable = true }; + storeObject = null; + networkInstantiate = false; + networkGroup = 0; + } + + public override void OnEnter() + { + var go = gameObject.Value; + + if (go != null) + { + var spawnPosition = Vector3.zero; + var spawnRotation = Vector3.zero; + + if (spawnPoint.Value != null) + { + spawnPosition = spawnPoint.Value.transform.position; + + if (!position.IsNone) + { + spawnPosition += position.Value; + } + + spawnRotation = !rotation.IsNone ? rotation.Value : spawnPoint.Value.transform.eulerAngles; + } + else + { + if (!position.IsNone) + { + spawnPosition = position.Value; + } + + if (!rotation.IsNone) + { + spawnRotation = rotation.Value; + } + } + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + GameObject newObject; + + if (!networkInstantiate.Value) + { + newObject = (GameObject)Object.Instantiate(go, spawnPosition, Quaternion.Euler(spawnRotation)); + } + else + { + newObject = (GameObject)Network.Instantiate(go, spawnPosition, Quaternion.Euler(spawnRotation), networkGroup.Value); + } +#else + var newObject = (GameObject)Object.Instantiate(go, spawnPosition, Quaternion.Euler(spawnRotation)); +#endif + storeObject.Value = newObject; + + //newObject.transform.position = spawnPosition; + //newObject.transform.eulerAngles = spawnRotation; + } + + Finish(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/CreateObject.cs.meta b/Assets/PlayMaker/Actions/CreateObject.cs.meta new file mode 100755 index 0000000..e598ee9 --- /dev/null +++ b/Assets/PlayMaker/Actions/CreateObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6ac0b5be40cabfc40b923fa4954641aa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/CutToCamera.cs b/Assets/PlayMaker/Actions/CutToCamera.cs new file mode 100755 index 0000000..aa3a5a6 --- /dev/null +++ b/Assets/PlayMaker/Actions/CutToCamera.cs @@ -0,0 +1,64 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Activates a Camera in the scene.")] + public class CutToCamera : FsmStateAction + { + [RequiredField] + public Camera camera; + public bool makeMainCamera; + public bool cutBackOnExit; + + Camera oldCamera; + + public override void Reset() + { + camera = null; + makeMainCamera = true; + cutBackOnExit = false; + } + + public override void OnEnter() + { + if (camera == null) + { + LogError("Missing camera!"); + return; + } + + oldCamera = Camera.main; + + SwitchCamera(Camera.main, camera); + + if (makeMainCamera) + camera.tag = "MainCamera"; + + Finish(); + } + + public override void OnExit() + { + if (cutBackOnExit) + { + SwitchCamera(camera, oldCamera); + } + } + + static void SwitchCamera(Camera camera1, Camera camera2) + { + if (camera1 != null) + { + camera1.enabled = false; + } + + if (camera2 != null) + { + camera2.enabled = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/CutToCamera.cs.meta b/Assets/PlayMaker/Actions/CutToCamera.cs.meta new file mode 100755 index 0000000..20d0ea4 --- /dev/null +++ b/Assets/PlayMaker/Actions/CutToCamera.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 62eb7e2e15da7094383d7bf068082c7d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugBool.cs b/Assets/PlayMaker/Actions/DebugBool.cs new file mode 100755 index 0000000..ad4b8b7 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugBool.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Logs the value of a Bool Variable in the PlayMaker Log Window.")] + public class DebugBool : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [UIHint(UIHint.Variable)] + [Tooltip("The Bool variable to debug.")] + public FsmBool boolVariable; + + public override void Reset() + { + logLevel = LogLevel.Info; + boolVariable = null; + base.Reset(); + } + + public override void OnEnter() + { + var text = "None"; + + if (!boolVariable.IsNone) + { + text = boolVariable.Name + ": " + boolVariable.Value; + } + + ActionHelpers.DebugLog(Fsm, logLevel, text, sendToUnityLog); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DebugBool.cs.meta b/Assets/PlayMaker/Actions/DebugBool.cs.meta new file mode 100755 index 0000000..3ced773 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugBool.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ac3bb315ecd09f54d8ae6732d7dbbd85 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugDrawShape.cs b/Assets/PlayMaker/Actions/DebugDrawShape.cs new file mode 100755 index 0000000..38cf065 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugDrawShape.cs @@ -0,0 +1,63 @@ +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Draw Gizmos in the Scene View.")] + public class DebugDrawShape : FsmStateAction + { + public enum ShapeType { Sphere, Cube, WireSphere, WireCube } + + [RequiredField] + [Tooltip("Draw the Gizmo at a GameObject's position.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The type of Gizmo to draw:\nSphere, Cube, WireSphere, or WireCube.")] + public ShapeType shape; + + [Tooltip("The color to use.")] + public FsmColor color; + + [Tooltip("Use this for sphere gizmos")] + public FsmFloat radius; + + [Tooltip("Use this for cube gizmos")] + public FsmVector3 size; + + public override void Reset() + { + gameObject = null; + shape = ShapeType.Sphere; + color = Color.grey; + radius = 1f; + size = new Vector3(1f, 1f, 1f); + } + + public override void OnDrawActionGizmos() + { + var ownerTransform = Fsm.GetOwnerDefaultTarget(gameObject).transform; + if (ownerTransform == null) + return; + + Gizmos.color = color.Value; + + switch (shape) + { + case ShapeType.Sphere: + Gizmos.DrawSphere(ownerTransform.position, radius.Value); + break; + case ShapeType.WireSphere: + Gizmos.DrawWireSphere(ownerTransform.position, radius.Value); + break; + case ShapeType.Cube: + Gizmos.DrawCube(ownerTransform.position, size.Value); + break; + case ShapeType.WireCube: + Gizmos.DrawWireCube(ownerTransform.position, size.Value); + break; + default: + break; + } + } + } +} diff --git a/Assets/PlayMaker/Actions/DebugDrawShape.cs.meta b/Assets/PlayMaker/Actions/DebugDrawShape.cs.meta new file mode 100755 index 0000000..db3d0f1 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugDrawShape.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8631f4b0c29b45e4ab58995114fa2ad2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugEnum.cs b/Assets/PlayMaker/Actions/DebugEnum.cs new file mode 100755 index 0000000..a8e36ed --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugEnum.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Logs the value of an Enum Variable in the PlayMaker Log Window.")] + public class DebugEnum : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [UIHint(UIHint.Variable)] + [Tooltip("The Enum Variable to debug.")] + public FsmEnum enumVariable; + + public override void Reset() + { + logLevel = LogLevel.Info; + enumVariable = null; + base.Reset(); + } + + public override void OnEnter() + { + var text = "None"; + + if (!enumVariable.IsNone) + { + text = enumVariable.Name + ": " + enumVariable.Value; + } + + ActionHelpers.DebugLog(Fsm, logLevel, text, sendToUnityLog); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DebugEnum.cs.meta b/Assets/PlayMaker/Actions/DebugEnum.cs.meta new file mode 100755 index 0000000..e6b436c --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugEnum.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7d5ef26a6102c0044bc96f9587acb44b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugFloat.cs b/Assets/PlayMaker/Actions/DebugFloat.cs new file mode 100755 index 0000000..9426743 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugFloat.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Logs the value of a Float Variable in the PlayMaker Log Window.")] + public class DebugFloat : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [UIHint(UIHint.Variable)] + [Tooltip("The Float variable to debug.")] + public FsmFloat floatVariable; + + public override void Reset() + { + logLevel = LogLevel.Info; + floatVariable = null; + base.Reset(); + } + + public override void OnEnter() + { + string text = "None"; + + if (!floatVariable.IsNone) + { + text = floatVariable.Name + ": " + floatVariable.Value; + } + + ActionHelpers.DebugLog(Fsm, logLevel, text, sendToUnityLog); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DebugFloat.cs.meta b/Assets/PlayMaker/Actions/DebugFloat.cs.meta new file mode 100755 index 0000000..84f14b0 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f54725291271e644d8931a2b9a127486 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugFsmVariable.cs b/Assets/PlayMaker/Actions/DebugFsmVariable.cs new file mode 100755 index 0000000..dac38e6 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugFsmVariable.cs @@ -0,0 +1,33 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Print the value of any FSM Variable in the PlayMaker Log Window.")] + public class DebugFsmVariable : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [HideTypeFilter] + [UIHint(UIHint.Variable)] + [Tooltip("The variable to debug.")] + public FsmVar variable; + + public override void Reset() + { + logLevel = LogLevel.Info; + variable = null; + base.Reset(); + } + + public override void OnEnter() + { + ActionHelpers.DebugLog(Fsm, logLevel, variable.DebugString(), sendToUnityLog); + + Finish(); + } + } +} diff --git a/Assets/PlayMaker/Actions/DebugFsmVariable.cs.meta b/Assets/PlayMaker/Actions/DebugFsmVariable.cs.meta new file mode 100755 index 0000000..651482e --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugFsmVariable.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6eced6fe7c6fe6f48a18b71bc955e200 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugGameObject.cs b/Assets/PlayMaker/Actions/DebugGameObject.cs new file mode 100755 index 0000000..8ed45d4 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugGameObject.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Logs the value of a Game Object Variable in the PlayMaker Log Window.")] + public class DebugGameObject : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [UIHint(UIHint.Variable)] + [Tooltip("The GameObject variable to debug.")] + public FsmGameObject gameObject; + + public override void Reset() + { + logLevel = LogLevel.Info; + gameObject = null; + base.Reset(); + } + + public override void OnEnter() + { + var text = "None"; + + if (!gameObject.IsNone) + { + text = gameObject.Name + ": " + gameObject; + } + + ActionHelpers.DebugLog(Fsm, logLevel, text, sendToUnityLog); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DebugGameObject.cs.meta b/Assets/PlayMaker/Actions/DebugGameObject.cs.meta new file mode 100755 index 0000000..6fd59e8 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 77dd57ebe3a79ac4f8467131f0f04beb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugInt.cs b/Assets/PlayMaker/Actions/DebugInt.cs new file mode 100755 index 0000000..55baa7b --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugInt.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Logs the value of an Integer Variable in the PlayMaker Log Window.")] + public class DebugInt : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [UIHint(UIHint.Variable)] + [Tooltip("The Int variable to debug.")] + public FsmInt intVariable; + + public override void Reset() + { + logLevel = LogLevel.Info; + intVariable = null; + } + + public override void OnEnter() + { + var text = "None"; + + if (!intVariable.IsNone) + { + text = intVariable.Name + ": " + intVariable.Value; + } + + ActionHelpers.DebugLog(Fsm, logLevel, text, sendToUnityLog); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DebugInt.cs.meta b/Assets/PlayMaker/Actions/DebugInt.cs.meta new file mode 100755 index 0000000..4c174f0 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugInt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dd0da7275cd2ad74b890f9acc2fe1918 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugLog.cs b/Assets/PlayMaker/Actions/DebugLog.cs new file mode 100755 index 0000000..408e223 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugLog.cs @@ -0,0 +1,32 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Sends a log message to the PlayMaker Log Window.")] + public class DebugLog : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [Tooltip("Text to send to the log.")] + public FsmString text; + + public override void Reset() + { + logLevel = LogLevel.Info; + text = ""; + base.Reset(); + } + + public override void OnEnter() + { + if (!string.IsNullOrEmpty(text.Value)) + { + ActionHelpers.DebugLog(Fsm, logLevel, text.Value, sendToUnityLog); + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DebugLog.cs.meta b/Assets/PlayMaker/Actions/DebugLog.cs.meta new file mode 100755 index 0000000..fcfe4e9 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugLog.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a5ede73c5bbf5b4aa6004aebbdf51f7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugObject.cs b/Assets/PlayMaker/Actions/DebugObject.cs new file mode 100755 index 0000000..9e9aab3 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugObject.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Logs the value of an Object Variable in the PlayMaker Log Window.")] + public class DebugObject : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [UIHint(UIHint.Variable)] + [Tooltip("The Object variable to debug.")] + public FsmObject fsmObject; + + public override void Reset() + { + logLevel = LogLevel.Info; + fsmObject = null; + base.Reset(); + } + + public override void OnEnter() + { + var text = "None"; + + if (!fsmObject.IsNone) + { + text = fsmObject.Name + ": " + fsmObject; + } + + ActionHelpers.DebugLog(Fsm, logLevel, text, sendToUnityLog); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DebugObject.cs.meta b/Assets/PlayMaker/Actions/DebugObject.cs.meta new file mode 100755 index 0000000..3f7f473 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2b0f9963f42fa364a8b2ac7110f32fb0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DebugVector3.cs b/Assets/PlayMaker/Actions/DebugVector3.cs new file mode 100755 index 0000000..deabd16 --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugVector3.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Logs the value of a Vector3 Variable in the PlayMaker Log Window.")] + public class DebugVector3 : BaseLogAction + { + [Tooltip("Info, Warning, or Error.")] + public LogLevel logLevel; + + [UIHint(UIHint.Variable)] + [Tooltip("The Vector3 variable to debug.")] + public FsmVector3 vector3Variable; + + public override void Reset() + { + logLevel = LogLevel.Info; + vector3Variable = null; + base.Reset(); + } + + public override void OnEnter() + { + var text = "None"; + + if (!vector3Variable.IsNone) + { + text = vector3Variable.Name + ": " + vector3Variable.Value; + } + + ActionHelpers.DebugLog(Fsm, logLevel, text, sendToUnityLog); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DebugVector3.cs.meta b/Assets/PlayMaker/Actions/DebugVector3.cs.meta new file mode 100755 index 0000000..6bbd17e --- /dev/null +++ b/Assets/PlayMaker/Actions/DebugVector3.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0530dae92ccbb0642a30a1a968da9e28 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DestroyComponent.cs b/Assets/PlayMaker/Actions/DestroyComponent.cs new file mode 100755 index 0000000..c9ad1c4 --- /dev/null +++ b/Assets/PlayMaker/Actions/DestroyComponent.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Destroys a Component of an Object.")] + public class DestroyComponent : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the Component.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.ScriptComponent)] + [Tooltip("The name of the Component to destroy.")] + public FsmString component; + + Component aComponent; + + public override void Reset() + { + aComponent = null; + gameObject = null; + component = null; + } + + public override void OnEnter() + { + DoDestroyComponent(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + + Finish(); + } + + + void DoDestroyComponent(GameObject go) + { + aComponent = go.GetComponent(ReflectionUtils.GetGlobalType(component.Value)); + if (aComponent == null) + { + LogError("No such component: " + component.Value); + } + else + { + Object.Destroy(aComponent); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DestroyComponent.cs.meta b/Assets/PlayMaker/Actions/DestroyComponent.cs.meta new file mode 100755 index 0000000..8e538e6 --- /dev/null +++ b/Assets/PlayMaker/Actions/DestroyComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 40eadc04dfda17149bd90bbd3b1e0abc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DestroyObject.cs b/Assets/PlayMaker/Actions/DestroyObject.cs new file mode 100755 index 0000000..fe83dc8 --- /dev/null +++ b/Assets/PlayMaker/Actions/DestroyObject.cs @@ -0,0 +1,61 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Destroys a Game Object.")] + public class DestroyObject : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to destroy.")] + public FsmGameObject gameObject; + + [HasFloatSlider(0, 5)] + [Tooltip("Optional delay before destroying the Game Object.")] + public FsmFloat delay; + + [Tooltip("Detach children before destroying the Game Object.")] + public FsmBool detachChildren; + //public FsmEvent sendEvent; + + //DelayedEvent delayedEvent; + + public override void Reset() + { + gameObject = null; + delay = 0; + //sendEvent = null; + } + + public override void OnEnter() + { + var go = gameObject.Value; + + if (go != null) + { + if (delay.Value <= 0) + { + Object.Destroy(go); + } + else + { + Object.Destroy(go, delay.Value); + } + + if (detachChildren.Value) + go.transform.DetachChildren(); + } + + Finish(); + //delayedEvent = new DelayedEvent(Fsm, sendEvent, delay.Value); + } + + public override void OnUpdate() + { + //delayedEvent.Update(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DestroyObject.cs.meta b/Assets/PlayMaker/Actions/DestroyObject.cs.meta new file mode 100755 index 0000000..8e9a6a9 --- /dev/null +++ b/Assets/PlayMaker/Actions/DestroyObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e731ab92ba211bd41acccbd77b4e1575 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DestroyObjects.cs b/Assets/PlayMaker/Actions/DestroyObjects.cs new file mode 100755 index 0000000..01049d3 --- /dev/null +++ b/Assets/PlayMaker/Actions/DestroyObjects.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Destroys GameObjects in an array.")] + public class DestroyObjects : FsmStateAction + { + [RequiredField] + [ArrayEditor(VariableType.GameObject)] + [Tooltip("The GameObjects to destroy.")] + public FsmArray gameObjects; + + [HasFloatSlider(0, 5)] + [Tooltip("Optional delay before destroying the Game Objects.")] + public FsmFloat delay; + + [Tooltip("Detach children before destroying the Game Objects.")] + public FsmBool detachChildren; + + public override void Reset() + { + gameObjects = null; + delay = 0; + } + + public override void OnEnter() + { + var goArray = gameObjects.Values as GameObject[]; + if (goArray != null) + { + foreach (var go in goArray) + { + if (go != null) + { + if (delay.Value <= 0) + { + Object.Destroy(go); + } + else + { + Object.Destroy(go, delay.Value); + } + + if (detachChildren.Value) + { + go.transform.DetachChildren(); + } + } + } + + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DestroyObjects.cs.meta b/Assets/PlayMaker/Actions/DestroyObjects.cs.meta new file mode 100755 index 0000000..e1a6302 --- /dev/null +++ b/Assets/PlayMaker/Actions/DestroyObjects.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e160956d4c1e2b4b9f0ba8431afc31a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DestroySelf.cs b/Assets/PlayMaker/Actions/DestroySelf.cs new file mode 100755 index 0000000..c3d63e7 --- /dev/null +++ b/Assets/PlayMaker/Actions/DestroySelf.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System.Collections; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Destroys the Owner of the Fsm! Useful for spawned Prefabs that need to kill themselves, e.g., a projectile that explodes on impact.")] + public class DestroySelf : FsmStateAction + { + [Tooltip("Detach children before destroying the Owner.")] + public FsmBool detachChildren; + + public override void Reset() + { + detachChildren = false; + } + + public override void OnEnter() + { + if (Owner != null) + { + if (detachChildren.Value) + { + Owner.transform.DetachChildren(); + } + + Object.Destroy(Owner); + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DestroySelf.cs.meta b/Assets/PlayMaker/Actions/DestroySelf.cs.meta new file mode 100755 index 0000000..9c651e2 --- /dev/null +++ b/Assets/PlayMaker/Actions/DestroySelf.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 06abfd20bfea39c459e9bed825a93fe8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DetachChildren.cs b/Assets/PlayMaker/Actions/DetachChildren.cs new file mode 100755 index 0000000..cbaa7d5 --- /dev/null +++ b/Assets/PlayMaker/Actions/DetachChildren.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Unparents all children from the Game Object.")] + public class DetachChildren : FsmStateAction + { + [RequiredField] + [Tooltip("GameObject to unparent children from.")] + public FsmOwnerDefault gameObject; + + public override void Reset() + { + gameObject = null; + } + + public override void OnEnter() + { + DoDetachChildren(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + static void DoDetachChildren(GameObject go) + { + if (go != null) + { + go.transform.DetachChildren(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DetachChildren.cs.meta b/Assets/PlayMaker/Actions/DetachChildren.cs.meta new file mode 100755 index 0000000..b4768b1 --- /dev/null +++ b/Assets/PlayMaker/Actions/DetachChildren.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0d294200b68c2f940b889d6def70521a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DetectDeviceOrientation.cs b/Assets/PlayMaker/Actions/DetectDeviceOrientation.cs new file mode 100755 index 0000000..6494a75 --- /dev/null +++ b/Assets/PlayMaker/Actions/DetectDeviceOrientation.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// Depreciated +/* +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.InputDevice)] + [Tooltip("Sends an Event based on the Orientation of the mobile device.")] + public class DetectDeviceOrientation : FsmStateAction + { + [Tooltip("Note: If device is physically situated between discrete positions, as when (for example) rotated diagonally, system will report Unknown orientation.")] + public DeviceOrientation orientation; + [Tooltip("The event to send if the device orientation matches Orientation.")] + public FsmEvent sendEvent; + [Tooltip("Repeat every frame. Useful if you want to wait for the orientation to be true.")] + public bool everyFrame; + + public override void Reset() + { + orientation = DeviceOrientation.Portrait; + sendEvent = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoDetectDeviceOrientation(); + + if (!everyFrame) + Finish(); + } + + + public override void OnUpdate() + { + DoDetectDeviceOrientation(); + } + + void DoDetectDeviceOrientation() + { + if (Input.deviceOrientation == orientation) + Fsm.Event(sendEvent); + } + + } +} +*/ \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DetectDeviceOrientation.cs.meta b/Assets/PlayMaker/Actions/DetectDeviceOrientation.cs.meta new file mode 100755 index 0000000..8b33376 --- /dev/null +++ b/Assets/PlayMaker/Actions/DetectDeviceOrientation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ee9fdab5d94faa74199212719ee63055 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DeviceOrientationEvent.cs b/Assets/PlayMaker/Actions/DeviceOrientationEvent.cs new file mode 100755 index 0000000..3e4686e --- /dev/null +++ b/Assets/PlayMaker/Actions/DeviceOrientationEvent.cs @@ -0,0 +1,52 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Sends an Event based on the Orientation of the mobile device.")] + public class DeviceOrientationEvent : FsmStateAction + { + [Tooltip("Note: If device is physically situated between discrete positions, as when (for example) rotated diagonally, system will report Unknown orientation.")] + public DeviceOrientation orientation; + + [Tooltip("The event to send if the device orientation matches Orientation.")] + public FsmEvent sendEvent; + + [Tooltip("Repeat every frame. Useful if you want to wait for the orientation to be true.")] + public bool everyFrame; + + public override void Reset() + { + orientation = DeviceOrientation.Portrait; + sendEvent = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoDetectDeviceOrientation(); + + if (!everyFrame) + { + Finish(); + } + } + + + public override void OnUpdate() + { + DoDetectDeviceOrientation(); + } + + void DoDetectDeviceOrientation() + { + if (Input.deviceOrientation == orientation) + { + Fsm.Event(sendEvent); + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DeviceOrientationEvent.cs.meta b/Assets/PlayMaker/Actions/DeviceOrientationEvent.cs.meta new file mode 100755 index 0000000..92951d5 --- /dev/null +++ b/Assets/PlayMaker/Actions/DeviceOrientationEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eb3c398f2f2220c44ad7e329f8635c3a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DevicePlayFullScreenMovie.cs b/Assets/PlayMaker/Actions/DevicePlayFullScreenMovie.cs new file mode 100755 index 0000000..8f3373a --- /dev/null +++ b/Assets/PlayMaker/Actions/DevicePlayFullScreenMovie.cs @@ -0,0 +1,43 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if (UNITY_EDITOR || UNITY_IPHONE || UNITY_ANDROID) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Plays a full-screen movie on a handheld device. Please consult the Unity docs for Handheld.PlayFullScreenMovie for proper usage.")] + public class DevicePlayFullScreenMovie : FsmStateAction + { + [RequiredField] + [Tooltip("Note that player will stream movie directly from the iPhone disc, therefore you have to provide movie as a separate files and not as an usual asset.\nYou will have to create a folder named StreamingAssets inside your Unity project (inside your Assets folder). Store your movies inside that folder. Unity will automatically copy contents of that folder into the iPhone application bundle.")] + public FsmString moviePath; + + [RequiredField] + [Tooltip("This action will initiate a transition that fades the screen from your current content to the designated background color of the player. When playback finishes, the player uses another fade effect to transition back to your content.")] + public FsmColor fadeColor; + + [Tooltip("Options for displaying movie playback controls. See Unity docs.")] + public FullScreenMovieControlMode movieControlMode; + + [Tooltip("Scaling modes for displaying movies.. See Unity docs.")] + public FullScreenMovieScalingMode movieScalingMode; + + public override void Reset() + { + moviePath = ""; + fadeColor = Color.black; + + movieControlMode = FullScreenMovieControlMode.Full; + movieScalingMode = FullScreenMovieScalingMode.AspectFit; + } + + public override void OnEnter() + { + Handheld.PlayFullScreenMovie(moviePath.Value, fadeColor.Value, movieControlMode, movieScalingMode); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DevicePlayFullScreenMovie.cs.meta b/Assets/PlayMaker/Actions/DevicePlayFullScreenMovie.cs.meta new file mode 100755 index 0000000..9e2ea17 --- /dev/null +++ b/Assets/PlayMaker/Actions/DevicePlayFullScreenMovie.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a4db7d99a54a59c47863f77a2301a3ed +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DeviceShakeEvent.cs b/Assets/PlayMaker/Actions/DeviceShakeEvent.cs new file mode 100755 index 0000000..76bfbee --- /dev/null +++ b/Assets/PlayMaker/Actions/DeviceShakeEvent.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Sends an Event when the mobile device is shaken.")] + public class DeviceShakeEvent : FsmStateAction + { + [RequiredField] + [Tooltip("Amount of acceleration required to trigger the event. Higher numbers require a harder shake.")] + public FsmFloat shakeThreshold; + + [RequiredField] + [Tooltip("Event to send when Shake Threshold is exceded.")] + public FsmEvent sendEvent; + + public override void Reset() + { + shakeThreshold = 3f; + sendEvent = null; + } + + public override void OnUpdate() + { + var acceleration = Input.acceleration; + + if (acceleration.sqrMagnitude > (shakeThreshold.Value * shakeThreshold.Value)) + { + Fsm.Event(sendEvent); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DeviceShakeEvent.cs.meta b/Assets/PlayMaker/Actions/DeviceShakeEvent.cs.meta new file mode 100755 index 0000000..320cffe --- /dev/null +++ b/Assets/PlayMaker/Actions/DeviceShakeEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a03a10a50ae10254ea6e249ae73479b1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DeviceVibrate.cs b/Assets/PlayMaker/Actions/DeviceVibrate.cs new file mode 100755 index 0000000..e3919d1 --- /dev/null +++ b/Assets/PlayMaker/Actions/DeviceVibrate.cs @@ -0,0 +1,22 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Causes the device to vibrate for half a second.")] + public class DeviceVibrate : FsmStateAction + { + public override void Reset() + {} + + public override void OnEnter() + { +#if (UNITY_IPHONE || UNITY_ANDROID) + Handheld.Vibrate(); +#endif + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DeviceVibrate.cs.meta b/Assets/PlayMaker/Actions/DeviceVibrate.cs.meta new file mode 100755 index 0000000..974da50 --- /dev/null +++ b/Assets/PlayMaker/Actions/DeviceVibrate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7b6b6b9b693bbb449aeaf0fd1257a944 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DontDestroyOnLoad.cs b/Assets/PlayMaker/Actions/DontDestroyOnLoad.cs new file mode 100755 index 0000000..dc949da --- /dev/null +++ b/Assets/PlayMaker/Actions/DontDestroyOnLoad.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System.Collections; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Level)] + [Tooltip("Makes the Game Object not be destroyed automatically when loading a new scene.")] + public class DontDestroyOnLoad : FsmStateAction + { + [RequiredField] + [Tooltip("GameObject to mark as DontDestroyOnLoad.")] + public FsmOwnerDefault gameObject; + + public override void Reset() + { + gameObject = null; + } + + public override void OnEnter() + { + // Have to get the root, since the game object will be destroyed if any of its parents are destroyed. + + Object.DontDestroyOnLoad(Owner.transform.root.gameObject); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DontDestroyOnLoad.cs.meta b/Assets/PlayMaker/Actions/DontDestroyOnLoad.cs.meta new file mode 100755 index 0000000..3b49ded --- /dev/null +++ b/Assets/PlayMaker/Actions/DontDestroyOnLoad.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5b09d34da3db2bb4f866c3eaf15a5a0c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DrawDebugLine.cs b/Assets/PlayMaker/Actions/DrawDebugLine.cs new file mode 100755 index 0000000..8f13fa5 --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawDebugLine.cs @@ -0,0 +1,43 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Draws a line from a Start point to an End point. Specify the points as Game Objects or Vector3 world positions. If both are specified, position is used as a local offset from the Object's position.")] + public class DrawDebugLine : FsmStateAction + { + [Tooltip("Draw line from a GameObject.")] + public FsmGameObject fromObject; + + [Tooltip("Draw line from a world position, or local offset from GameObject if provided.")] + public FsmVector3 fromPosition; + + [Tooltip("Draw line to a GameObject.")] + public FsmGameObject toObject; + + [Tooltip("Draw line to a world position, or local offset from GameObject if provided.")] + public FsmVector3 toPosition; + + [Tooltip("The color of the line.")] + public FsmColor color; + + public override void Reset() + { + fromObject = new FsmGameObject { UseVariable = true} ; + fromPosition = new FsmVector3 { UseVariable = true}; + toObject = new FsmGameObject { UseVariable = true} ; + toPosition = new FsmVector3 { UseVariable = true}; + color = Color.white; + } + + public override void OnUpdate() + { + var startPos = ActionHelpers.GetPosition(fromObject, fromPosition); + var endPos = ActionHelpers.GetPosition(toObject, toPosition); + + Debug.DrawLine(startPos, endPos, color.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DrawDebugLine.cs.meta b/Assets/PlayMaker/Actions/DrawDebugLine.cs.meta new file mode 100755 index 0000000..4200470 --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawDebugLine.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 18bfd2197dc13c44c81ae8f279f87a21 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DrawDebugRay.cs b/Assets/PlayMaker/Actions/DrawDebugRay.cs new file mode 100755 index 0000000..10947f4 --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawDebugRay.cs @@ -0,0 +1,38 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Draws a line from a Start point in a direction. Specify the start point as Game Objects or Vector3 world positions. If both are specified, position is used as a local offset from the Object's position.")] + public class DrawDebugRay : FsmStateAction + { + [Tooltip("Draw ray from a GameObject.")] + public FsmGameObject fromObject; + + [Tooltip("Draw ray from a world position, or local offset from GameObject if provided.")] + public FsmVector3 fromPosition; + + [Tooltip("Direction vector of ray.")] + public FsmVector3 direction; + + [Tooltip("The color of the ray.")] + public FsmColor color; + + public override void Reset() + { + fromObject = new FsmGameObject { UseVariable = true} ; + fromPosition = new FsmVector3 { UseVariable = true}; + direction = new FsmVector3 { UseVariable = true}; + color = Color.white; + } + + public override void OnUpdate() + { + var startPos = ActionHelpers.GetPosition(fromObject, fromPosition); + + Debug.DrawRay(startPos, direction.Value, color.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DrawDebugRay.cs.meta b/Assets/PlayMaker/Actions/DrawDebugRay.cs.meta new file mode 100755 index 0000000..8d099d0 --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawDebugRay.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 408b1150e046afe418a4a54df0f31d2e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DrawFullscreenColor.cs b/Assets/PlayMaker/Actions/DrawFullscreenColor.cs new file mode 100755 index 0000000..cff3e77 --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawFullscreenColor.cs @@ -0,0 +1,28 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Fills the screen with a Color. NOTE: Uses OnGUI so you need a PlayMakerGUI component in the scene.")] + public class DrawFullscreenColor : FsmStateAction + { + [RequiredField] + [Tooltip("Color. NOTE: Uses OnGUI so you need a PlayMakerGUI component in the scene.")] + public FsmColor color; + + public override void Reset() + { + color = Color.white; + } + + public override void OnGUI() + { + var guiColor = GUI.color; + GUI.color = color.Value; + GUI.DrawTexture(new Rect(0,0,Screen.width, Screen.height), ActionHelpers.WhiteTexture); + GUI.color = guiColor; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DrawFullscreenColor.cs.meta b/Assets/PlayMaker/Actions/DrawFullscreenColor.cs.meta new file mode 100755 index 0000000..f96884a --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawFullscreenColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0c7f66d29ff3bd74dae9af37c8e5d50a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DrawStateLabel.cs b/Assets/PlayMaker/Actions/DrawStateLabel.cs new file mode 100755 index 0000000..e7309ee --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawStateLabel.cs @@ -0,0 +1,27 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Debug)] + [Tooltip("Draws a state label for this FSM in the Game View. The label is drawn on the game object that owns the FSM. Use this to override the global setting in the PlayMaker Debug menu.")] + public class DrawStateLabel : FsmStateAction + { + [RequiredField] + [Tooltip("Set to True to show State labels, or Fals to hide them.")] + public FsmBool showLabel; + + public override void Reset() + { + showLabel = true; + } + + public override void OnEnter() + { + Fsm.ShowStateLabel = showLabel.Value; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DrawStateLabel.cs.meta b/Assets/PlayMaker/Actions/DrawStateLabel.cs.meta new file mode 100755 index 0000000..396e8cf --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawStateLabel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fb63ee17456c1d344b3111b2e201aa57 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/DrawTexture.cs b/Assets/PlayMaker/Actions/DrawTexture.cs new file mode 100755 index 0000000..1da79b9 --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawTexture.cs @@ -0,0 +1,85 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Draws a GUI Texture. NOTE: Uses OnGUI so you need a PlayMakerGUI component in the scene.")] + public class DrawTexture : FsmStateAction + { + [RequiredField] + [Tooltip("Texture to draw.")] + public FsmTexture texture; + + [UIHint(UIHint.Variable)] + [Tooltip("Rectangle on the screen to draw the texture within. Alternatively, set or override individual properties below.")] + [Title("Position")] + public FsmRect screenRect; + + [Tooltip("Left screen coordinate.")] + public FsmFloat left; + + [Tooltip("Top screen coordinate.")] + public FsmFloat top; + + [Tooltip("Width of texture on screen.")] + public FsmFloat width; + + [Tooltip("Height of texture on screen.")] + public FsmFloat height; + + [Tooltip("How to scale the image when the aspect ratio of it doesn't fit the aspect ratio to be drawn within.")] + public ScaleMode scaleMode; + + [Tooltip("Whether to alpha blend the image on to the display (the default). If false, the picture is drawn on to the display.")] + public FsmBool alphaBlend; + + [Tooltip("Aspect ratio to use for the source image. If 0 (the default), the aspect ratio from the image is used. Pass in w/h for the desired aspect ratio. This allows the aspect ratio of the source image to be adjusted without changing the pixel width and height.")] + public FsmFloat imageAspect; + + [Tooltip("Use normalized screen coordinates (0-1)")] + public FsmBool normalized; + + private Rect rect; + + public override void Reset() + { + texture = null; + screenRect = null; + left = 0; + top = 0; + width = 1; + height = 1; + scaleMode = ScaleMode.StretchToFill; + alphaBlend = true; + imageAspect = 0; + normalized = true; + } + + public override void OnGUI() + { + if (texture.Value == null) + { + return; + } + + rect = !screenRect.IsNone ? screenRect.Value : new Rect(); + + if (!left.IsNone) rect.x = left.Value; + if (!top.IsNone) rect.y = top.Value; + if (!width.IsNone) rect.width = width.Value; + if (!height.IsNone) rect.height = height.Value; + + if (normalized.Value) + { + rect.x *= Screen.width; + rect.width *= Screen.width; + rect.y *= Screen.height; + rect.height *= Screen.height; + } + + GUI.DrawTexture(rect, texture.Value, scaleMode, alphaBlend.Value, imageAspect.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/DrawTexture.cs.meta b/Assets/PlayMaker/Actions/DrawTexture.cs.meta new file mode 100755 index 0000000..b652b20 --- /dev/null +++ b/Assets/PlayMaker/Actions/DrawTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 24c4ca69322160341bb2712caf79680c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Editor.meta b/Assets/PlayMaker/Actions/Editor.meta new file mode 100644 index 0000000..1bc9c9e --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 55e5e22e2abaa4ae28a1116600fbd1b8 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions/Editor/GetDistanceEditor.cs b/Assets/PlayMaker/Actions/Editor/GetDistanceEditor.cs new file mode 100755 index 0000000..0c4e762 --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor/GetDistanceEditor.cs @@ -0,0 +1,43 @@ +using System.ComponentModel; +using System.Globalization; +using HutongGames.PlayMaker.Actions; +using HutongGames.PlayMakerEditor; +using UnityEditor; +using UnityEngine; +using System.Collections; + +namespace HutongGames.PlayMakerEditor +{ + [CustomActionEditor(typeof (GetDistance))] + public class GetDistanceEditor : CustomActionEditor + { + public override bool OnGUI() + { + return DrawDefaultInspector(); + } + + [Localizable(false)] + public override void OnSceneGUI() + { + var action = (GetDistance) target; + + var fromObject = action.Fsm.GetOwnerDefaultTarget(action.gameObject); + var toObject = action.target; + + if (fromObject == null || toObject.IsNone || toObject.Value == null) + { + return; + } + + var fromPos = fromObject.transform.position; + var toPos = toObject.Value.transform.position; + var distance = Vector3.Distance(fromPos, toPos); + var label = string.Format("Get Distance:\n{0}", string.Format("{0:0.000}", distance)); + + + Handles.color = new Color(1, 1, 1, 0.5f); + Handles.DrawLine(fromPos, toPos); + Handles.Label((fromPos + toPos)*0.5f, label); + } + } +} diff --git a/Assets/PlayMaker/Actions/Editor/GetDistanceEditor.cs.meta b/Assets/PlayMaker/Actions/Editor/GetDistanceEditor.cs.meta new file mode 100755 index 0000000..ad21d49 --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor/GetDistanceEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 74cbac50b46d39d418eaf951dfc12b55 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Editor/LookAtActionEditor.cs b/Assets/PlayMaker/Actions/Editor/LookAtActionEditor.cs new file mode 100755 index 0000000..bcf08a0 --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor/LookAtActionEditor.cs @@ -0,0 +1,92 @@ +using HutongGames.PlayMaker.Actions; +using HutongGames.PlayMakerEditor; +using UnityEditor; +using UnityEngine; +using System.Collections; + +namespace HutongGames.PlayMakerEditor +{ + [CustomActionEditor(typeof (LookAt))] + public class LookAtActionEditor : CustomActionEditor + { + public override bool OnGUI() + { + return DrawDefaultInspector(); + } + + public override void OnSceneGUI() + { + var lookAtAction = (LookAt) target; + + if (lookAtAction.UpdateLookAtPosition()) + { + var go = target.Fsm.GetOwnerDefaultTarget(lookAtAction.gameObject); + var goTransform = go.transform; + var goPosition = goTransform.position; + + var lookAtPosition = lookAtAction.GetLookAtPosition(); + var lookAtVector = lookAtPosition - goPosition; + var lookAtRotation = Quaternion.LookRotation(lookAtVector); + var lookAtAngle = Vector3.Angle(goTransform.forward, lookAtVector); + var lookAtNormal = Vector3.Cross(goTransform.forward, lookAtVector); + + var handleSize = HandleUtility.GetHandleSize(goPosition); + var arrowSize = handleSize*0.2f; + var distance = (lookAtPosition - goPosition).magnitude; + + var goTarget = lookAtAction.targetObject.Value; + + // Position handles + + if (!lookAtAction.targetPosition.IsNone) + { + if (goTarget != null) + { + // Edit local offset from target object + + var goTargetTransform = goTarget.transform; + var worldTargetPos = goTargetTransform.TransformPoint(lookAtAction.targetPosition.Value); + + lookAtAction.targetPosition.Value = goTargetTransform.InverseTransformPoint(Handles.PositionHandle(worldTargetPos, goTarget.transform.rotation)); + Handles.color = new Color(1, 1, 1, 0.2f); + Handles.DrawLine(goTargetTransform.position, lookAtAction.GetLookAtPositionWithVertical()); + } + else + { + // Edit world position + + lookAtAction.targetPosition.Value = Handles.PositionHandle(lookAtAction.targetPosition.Value, Quaternion.identity); + } + } + + // Forward vector + + Handles.color = Color.blue; + Handles.DrawLine(goPosition, goPosition + goTransform.forward*handleSize); + + // Lookat vector + + Handles.DrawLine(goPosition, lookAtPosition); + Handles.ConeCap(0, goPosition + lookAtVector.normalized * (distance - arrowSize * 0.7f) , lookAtRotation, arrowSize); // fudge factor to position cap correctly + + // Arc between vectors + + Handles.color = new Color(1, 1, 1, 0.2f); + Handles.DrawSolidArc(goPosition, lookAtNormal, goTransform.forward, lookAtAngle, handleSize); + + // Show vertical offset + + if (lookAtAction.keepVertical.Value) + { + Handles.DrawLine(lookAtPosition, lookAtAction.GetLookAtPositionWithVertical()); + } + + if (GUI.changed) + { + FsmEditor.EditingActions(); + FsmEditor.Repaint(true); + } + } + } + } +} diff --git a/Assets/PlayMaker/Actions/Editor/LookAtActionEditor.cs.meta b/Assets/PlayMaker/Actions/Editor/LookAtActionEditor.cs.meta new file mode 100755 index 0000000..8813861 --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor/LookAtActionEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8f2a69e5a6699e64ca61a6e6effee186 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Editor/MoveTowardsActionEditor.cs b/Assets/PlayMaker/Actions/Editor/MoveTowardsActionEditor.cs new file mode 100755 index 0000000..7be0b3e --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor/MoveTowardsActionEditor.cs @@ -0,0 +1,81 @@ +using HutongGames.PlayMaker.Actions; +using HutongGames.PlayMakerEditor; +using UnityEditor; +using UnityEngine; +using System.Collections; + +namespace HutongGames.PlayMakerEditor +{ + [CustomActionEditor(typeof (MoveTowards))] + public class MoveTowardsActionEditor : CustomActionEditor + { + public override bool OnGUI() + { + return DrawDefaultInspector(); + } + + public override void OnSceneGUI() + { + var moveTowardsAction = (MoveTowards) target; + + if (moveTowardsAction.UpdateTargetPos()) + { + var go = target.Fsm.GetOwnerDefaultTarget(moveTowardsAction.gameObject); + var goTransform = go.transform; + var goPosition = goTransform.position; + + var lookAtPosition = moveTowardsAction.GetTargetPos(); + var lookAtVector = lookAtPosition - goPosition; + if (lookAtVector == Vector3.zero) return; + var lookAtRotation = Quaternion.LookRotation(lookAtVector); + + var handleSize = HandleUtility.GetHandleSize(goPosition); + var arrowSize = handleSize*0.2f; + var distance = (lookAtPosition - goPosition).magnitude; + + var goTarget = moveTowardsAction.targetObject.Value; + + // Position handles + + if (!moveTowardsAction.targetPosition.IsNone) + { + if (goTarget != null) + { + // Edit local offset from target object + + var goTargetTransform = goTarget.transform; + var worldTargetPos = goTargetTransform.TransformPoint(moveTowardsAction.targetPosition.Value); + + moveTowardsAction.targetPosition.Value = goTargetTransform.InverseTransformPoint(Handles.PositionHandle(worldTargetPos, goTarget.transform.rotation)); + Handles.color = new Color(1, 1, 1, 0.2f); + Handles.DrawLine(goTargetTransform.position, moveTowardsAction.GetTargetPosWithVertical()); + } + else + { + // Edit world position + + moveTowardsAction.targetPosition.Value = Handles.PositionHandle(moveTowardsAction.targetPosition.Value, Quaternion.identity); + } + } + + // Target vector + + Handles.DrawLine(goPosition, lookAtPosition); + Handles.ConeCap(0, goPosition + lookAtVector.normalized * (distance - arrowSize * 0.7f), lookAtRotation, arrowSize); // fudge factor to position cap correctly + + // Show vertical offset + + if (moveTowardsAction.ignoreVertical.Value) + { + Handles.DrawLine(lookAtPosition, moveTowardsAction.GetTargetPosWithVertical()); + } + + if (GUI.changed) + { + FsmEditor.EditingActions(); + FsmEditor.Repaint(true); + } + } + } + } +} diff --git a/Assets/PlayMaker/Actions/Editor/MoveTowardsActionEditor.cs.meta b/Assets/PlayMaker/Actions/Editor/MoveTowardsActionEditor.cs.meta new file mode 100755 index 0000000..e117a2e --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor/MoveTowardsActionEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45c59c6d5dd951b4f9ff008c28d50fc4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Editor/SetCameraFOVActionEditor.cs b/Assets/PlayMaker/Actions/Editor/SetCameraFOVActionEditor.cs new file mode 100755 index 0000000..38694df --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor/SetCameraFOVActionEditor.cs @@ -0,0 +1,52 @@ +using HutongGames.PlayMaker.Actions; +using HutongGames.PlayMakerEditor; +using UnityEditor; +using UnityEngine; +using System.Collections; + +namespace HutongGames.PlayMakerEditor +{ + [CustomActionEditor(typeof (SetCameraFOV))] + public class SetCameraFOVActionEditor : CustomActionEditor + { + private GameObject cachedGameObject; + private Camera camera; + + public override bool OnGUI() + { + return DrawDefaultInspector(); + } + + public override void OnSceneGUI() + { + var setCameraFOVAction = (SetCameraFOV) target; + if (setCameraFOVAction.fieldOfView.IsNone) + { + return; + } + + var go = setCameraFOVAction.Fsm.GetOwnerDefaultTarget(setCameraFOVAction.gameObject); + var fov = setCameraFOVAction.fieldOfView.Value; + + if (go != null && fov > 0) + { + if (go != cachedGameObject || camera == null) + { + camera = go.GetComponent(); + cachedGameObject = go; + } + + if (camera != null) + { + var originalFOV = camera.fieldOfView; + camera.fieldOfView = setCameraFOVAction.fieldOfView.Value; + + Handles.color = new Color(1, 1, 0, .5f); + SceneGUI.DrawCameraFrustrum(camera); + + camera.fieldOfView = originalFOV; + } + } + } + } +} diff --git a/Assets/PlayMaker/Actions/Editor/SetCameraFOVActionEditor.cs.meta b/Assets/PlayMaker/Actions/Editor/SetCameraFOVActionEditor.cs.meta new file mode 100755 index 0000000..89ff300 --- /dev/null +++ b/Assets/PlayMaker/Actions/Editor/SetCameraFOVActionEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1de4730ee5d36b74193bf451063a5b9e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/EnableAnimation.cs b/Assets/PlayMaker/Actions/EnableAnimation.cs new file mode 100755 index 0000000..1c44f0f --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableAnimation.cs @@ -0,0 +1,75 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Enables/Disables an Animation on a GameObject.\nAnimation time is paused while disabled. Animation must also have a non zero weight to play.")] + public class EnableAnimation : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("The GameObject playing the animation.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Animation)] + [Tooltip("The name of the animation to enable/disable.")] + public FsmString animName; + + [RequiredField] + [Tooltip("Set to True to enable, False to disable.")] + public FsmBool enable; + + [Tooltip("Reset the initial enabled state when exiting the state.")] + public FsmBool resetOnExit; + + private AnimationState anim; + + public override void Reset() + { + gameObject = null; + animName = null; + enable = true; + resetOnExit = false; + } + + public override void OnEnter() + { + DoEnableAnimation(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + void DoEnableAnimation(GameObject go) + { + if (go == null) + { + return; + } + + var animation = go.GetComponent(); + if (animation == null) + { + LogError("Missing animation component!"); + return; + } + + anim = animation[animName.Value]; + + if (anim != null) + { + anim.enabled = enable.Value; + } + } + + public override void OnExit() + { + if (resetOnExit.Value && anim != null) + { + anim.enabled = !enable.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/EnableAnimation.cs.meta b/Assets/PlayMaker/Actions/EnableAnimation.cs.meta new file mode 100755 index 0000000..e8a6153 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableAnimation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4e18e42fb3afda04aa50874569cb30f1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/EnableBehaviour.cs b/Assets/PlayMaker/Actions/EnableBehaviour.cs new file mode 100755 index 0000000..0aebeb2 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableBehaviour.cs @@ -0,0 +1,97 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.ScriptControl)] + [Tooltip("Enables/Disables a Behaviour on a GameObject. Optionally reset the Behaviour on exit - useful if you want the Behaviour to be active only while this state is active.")] + public class EnableBehaviour : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the Behaviour.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Behaviour)] + [Tooltip("The name of the Behaviour to enable/disable.")] + public FsmString behaviour; + + [Tooltip("Optionally drag a component directly into this field (behavior name will be ignored).")] + public Component component; + + [RequiredField] + [Tooltip("Set to True to enable, False to disable.")] + public FsmBool enable; + + public FsmBool resetOnExit; + + public override void Reset() + { + gameObject = null; + behaviour = null; + component = null; + enable = true; + resetOnExit = true; + } + + Behaviour componentTarget; + + public override void OnEnter() + { + DoEnableBehaviour(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + void DoEnableBehaviour(GameObject go) + { + if (go == null) + { + return; + } + + if (component != null) + { + componentTarget = component as Behaviour; + } + else + { + componentTarget = go.GetComponent(ReflectionUtils.GetGlobalType(behaviour.Value)) as Behaviour; + } + + if (componentTarget == null) + { + LogWarning(" " + go.name + " missing behaviour: " + behaviour.Value); + return; + } + + componentTarget.enabled = enable.Value; + } + + public override void OnExit() + { + if (componentTarget == null) + { + return; + } + + if (resetOnExit.Value) + { + componentTarget.enabled = !enable.Value; + } + } + + public override string ErrorCheck() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + + if (go == null || component != null || behaviour.IsNone || string.IsNullOrEmpty(behaviour.Value)) + { + return null; + } + + var comp = go.GetComponent(ReflectionUtils.GetGlobalType(behaviour.Value)) as Behaviour; + return comp != null ? null : "Behaviour missing"; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/EnableBehaviour.cs.meta b/Assets/PlayMaker/Actions/EnableBehaviour.cs.meta new file mode 100755 index 0000000..d4c662b --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableBehaviour.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d6231766398559749b2481761a8f485d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/EnableFSM.cs b/Assets/PlayMaker/Actions/EnableFSM.cs new file mode 100755 index 0000000..093a1c4 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableFSM.cs @@ -0,0 +1,90 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Enables/Disables an FSM component on a GameObject.")] + public class EnableFSM : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM component.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on GameObject. Useful if you have more than one FSM on a GameObject.")] + public FsmString fsmName; + + [Tooltip("Set to True to enable, False to disable.")] + public FsmBool enable; + + [Tooltip("Reset the initial enabled state when exiting the state.")] + public FsmBool resetOnExit; + + private PlayMakerFSM fsmComponent; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + enable = true; + resetOnExit = true; + } + + public override void OnEnter() + { + DoEnableFSM(); + + Finish(); + } + + void DoEnableFSM() + { + GameObject go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; + + if (go == null) return; + + if (!string.IsNullOrEmpty(fsmName.Value)) + { + // find by FSM component name + + var fsmComponents = go.GetComponents(); + foreach (var component in fsmComponents) + { + if (component.FsmName == fsmName.Value) + { + fsmComponent = component; + break; + } + } + } + else + { + // get first FSM component + + fsmComponent = go.GetComponent(); + } + + if (fsmComponent == null) + { + // TODO: Not sure if this is an error condition... + LogError("Missing FsmComponent!"); + return; + } + + fsmComponent.enabled = enable.Value; + } + + public override void OnExit() + { + if (fsmComponent == null) return; + + if (resetOnExit.Value) + { + fsmComponent.enabled = !enable.Value; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/EnableFSM.cs.meta b/Assets/PlayMaker/Actions/EnableFSM.cs.meta new file mode 100755 index 0000000..befc1f6 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableFSM.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bff36e3d590ced345ab5630c02bde143 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/EnableFog.cs b/Assets/PlayMaker/Actions/EnableFog.cs new file mode 100755 index 0000000..404a4a4 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableFog.cs @@ -0,0 +1,38 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.RenderSettings)] + [Tooltip("Enables/Disables Fog in the scene.")] + public class EnableFog : FsmStateAction + { + [Tooltip("Set to True to enable, False to disable.")] + public FsmBool enableFog; + + [Tooltip("Repeat every frame. Useful if the Enable Fog setting is changing.")] + public bool everyFrame; + + public override void Reset() + { + enableFog = true; + everyFrame = false; + } + + public override void OnEnter() + { + RenderSettings.fog = enableFog.Value; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + RenderSettings.fog = enableFog.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/EnableFog.cs.meta b/Assets/PlayMaker/Actions/EnableFog.cs.meta new file mode 100755 index 0000000..1ac945b --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableFog.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d36d3bc3048b4bc4c88d96241817350f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/EnableGUI.cs b/Assets/PlayMaker/Actions/EnableGUI.cs new file mode 100755 index 0000000..f1303b0 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableGUI.cs @@ -0,0 +1,25 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Enables/Disables the PlayMakerGUI component in the scene. Note, you need a PlayMakerGUI component in the scene to see OnGUI actions. However, OnGUI can be very expensive on mobile devices. This action lets you turn OnGUI on/off (e.g., turn it on for a menu, and off during gameplay).")] + public class EnableGUI : FsmStateAction + { + [Tooltip("Set to True to enable, False to disable.")] + public FsmBool enableGUI; + + public override void Reset() + { + enableGUI = true; + } + + public override void OnEnter() + { + PlayMakerGUI.Instance.enabled = enableGUI.Value; + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/EnableGUI.cs.meta b/Assets/PlayMaker/Actions/EnableGUI.cs.meta new file mode 100755 index 0000000..4ef59b8 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnableGUI.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bb0d4058950c33b4da60d866130e6300 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/EnumCompare.cs b/Assets/PlayMaker/Actions/EnumCompare.cs new file mode 100755 index 0000000..3bd9e3f --- /dev/null +++ b/Assets/PlayMaker/Actions/EnumCompare.cs @@ -0,0 +1,77 @@ +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Compares 2 Enum values and sends Events based on the result.")] + public class EnumCompare : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmEnum enumVariable; + + [MatchFieldType("enumVariable")] + public FsmEnum compareTo; + + public FsmEvent equalEvent; + + public FsmEvent notEqualEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the true/false result in a bool variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame. Useful if the enum is changing over time.")] + public bool everyFrame; + + public override void Reset() + { + enumVariable = null; + compareTo = null; + equalEvent = null; + notEqualEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoEnumCompare(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoEnumCompare(); + } + + void DoEnumCompare() + { + if (enumVariable == null || compareTo == null) return; + + var equal = Equals(enumVariable.Value, compareTo.Value); + + if (storeResult != null) + { + storeResult.Value = equal; + } + + if (equal && equalEvent != null) + { + Fsm.Event(equalEvent); + return; + } + + if (!equal && notEqualEvent != null) + { + Fsm.Event(notEqualEvent); + } + + } + + } +} diff --git a/Assets/PlayMaker/Actions/EnumCompare.cs.meta b/Assets/PlayMaker/Actions/EnumCompare.cs.meta new file mode 100755 index 0000000..e217221 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnumCompare.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 36c0a8c05ee8cc345962a8441340fb6e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/EnumSwitch.cs b/Assets/PlayMaker/Actions/EnumSwitch.cs new file mode 100755 index 0000000..5fa2808 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnumSwitch.cs @@ -0,0 +1,58 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends an Event based on the value of an Enum Variable.")] + public class EnumSwitch : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmEnum enumVariable; + + [CompoundArray("Enum Switches", "Compare Enum Values", "Send")] + [MatchFieldType("enumVariable")] + public FsmEnum[] compareTo; + public FsmEvent[] sendEvent; + + public bool everyFrame; + + public override void Reset() + { + enumVariable = null; + compareTo = new FsmEnum[0]; + sendEvent = new FsmEvent[0]; + everyFrame = false; + } + + public override void OnEnter() + { + DoEnumSwitch(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoEnumSwitch(); + } + + private void DoEnumSwitch() + { + if (enumVariable.IsNone) + return; + + for (int i = 0; i < compareTo.Length; i++) + { + if (Equals(enumVariable.Value, compareTo[i].Value)) + { + Fsm.Event(sendEvent[i]); + return; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/EnumSwitch.cs.meta b/Assets/PlayMaker/Actions/EnumSwitch.cs.meta new file mode 100755 index 0000000..f7e0d51 --- /dev/null +++ b/Assets/PlayMaker/Actions/EnumSwitch.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3dfa083daff6b6e459f0385a956eb962 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Explosion.cs b/Assets/PlayMaker/Actions/Explosion.cs new file mode 100755 index 0000000..03ca0da --- /dev/null +++ b/Assets/PlayMaker/Actions/Explosion.cs @@ -0,0 +1,91 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Applies an explosion Force to all Game Objects with a Rigid Body inside a Radius.")] + public class Explosion : FsmStateAction + { + [RequiredField] + [Tooltip("The world position of the center of the explosion.")] + public FsmVector3 center; + + [RequiredField] + [Tooltip("The strength of the explosion.")] + public FsmFloat force; + + [RequiredField] + [Tooltip("The radius of the explosion. Force falls of linearly with distance.")] + public FsmFloat radius; + + [Tooltip("Applies the force as if it was applied from beneath the object. This is useful since explosions that throw things up instead of pushing things to the side look cooler. A value of 2 will apply a force as if it is applied from 2 meters below while not changing the actual explosion position.")] + public FsmFloat upwardsModifier; + + [Tooltip("The type of force to apply.")] + public ForceMode forceMode; + + [UIHint(UIHint.Layer)] + public FsmInt layer; + + [UIHint(UIHint.Layer)] + [Tooltip("Layers to effect.")] + public FsmInt[] layerMask; + + [Tooltip("Invert the mask, so you effect all layers except those defined above.")] + public FsmBool invertMask; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + center = null; + upwardsModifier = 0f; + forceMode = ForceMode.Force; + everyFrame = false; + } + + public override void OnPreprocess() + { + Fsm.HandleFixedUpdate = true; + } + + public override void OnEnter() + { + DoExplosion(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnFixedUpdate() + { + DoExplosion(); + } + + void DoExplosion() + { + var colliders = Physics.OverlapSphere(center.Value, radius.Value); + + foreach (var hit in colliders) + { + var rigidBody = hit.gameObject.GetComponent(); + if (rigidBody != null && ShouldApplyForce(hit.gameObject)) + { + rigidBody.AddExplosionForce(force.Value, center.Value, radius.Value, upwardsModifier.Value, forceMode); + } + } + } + + bool ShouldApplyForce(GameObject go) + { + var mask = ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value); + + return ((1 << go.layer) & mask) > 0; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Explosion.cs.meta b/Assets/PlayMaker/Actions/Explosion.cs.meta new file mode 100755 index 0000000..7861cba --- /dev/null +++ b/Assets/PlayMaker/Actions/Explosion.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1c95111a2f820ea4db52a880cefdf3d4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FindChild.cs b/Assets/PlayMaker/Actions/FindChild.cs new file mode 100755 index 0000000..a6c1758 --- /dev/null +++ b/Assets/PlayMaker/Actions/FindChild.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Finds the Child of a GameObject by Name.\nNote, you can specify a path to the child, e.g., LeftShoulder/Arm/Hand/Finger. If you need to specify a tag, use GetChild.")] + public class FindChild : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to search.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The name of the child. Note, you can specify a path to the child, e.g., LeftShoulder/Arm/Hand/Finger")] + public FsmString childName; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the child in a GameObject variable.")] + public FsmGameObject storeResult; + + public override void Reset() + { + gameObject = null; + childName = ""; + storeResult = null; + } + + public override void OnEnter() + { + DoFindChild(); + + Finish(); + } + + void DoFindChild() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var transform = go.transform.FindChild(childName.Value); + storeResult.Value = transform != null ? transform.gameObject : null; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FindChild.cs.meta b/Assets/PlayMaker/Actions/FindChild.cs.meta new file mode 100755 index 0000000..c36ec94 --- /dev/null +++ b/Assets/PlayMaker/Actions/FindChild.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a752fb4c33b1a064ea8dbeb01d36c7fb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FindClosest.cs b/Assets/PlayMaker/Actions/FindClosest.cs new file mode 100755 index 0000000..bce8e42 --- /dev/null +++ b/Assets/PlayMaker/Actions/FindClosest.cs @@ -0,0 +1,111 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// Added Ignore Owner option. Thanks Nueral Echo: http://hutonggames.com/playmakerforum/index.php?topic=71.0 + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Finds the closest object to the specified Game Object.\nOptionally filter by Tag and Visibility.")] + public class FindClosest : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to measure from.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Tag)] + [Tooltip("Only consider objects with this Tag. NOTE: It's generally a lot quicker to find objects with a Tag!")] + public FsmString withTag; + + [Tooltip("If checked, ignores the object that owns this FSM.")] + public FsmBool ignoreOwner; + + [Tooltip("Only consider objects visible to the camera.")] + public FsmBool mustBeVisible; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the closest object.")] + public FsmGameObject storeObject; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the distance to the closest object.")] + public FsmFloat storeDistance; + + [Tooltip("Repeat every frame")] + public bool everyFrame; + + + public override void Reset() + { + gameObject = null; + withTag = "Untagged"; + ignoreOwner = true; + mustBeVisible = false; + storeObject = null; + storeDistance = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoFindClosest(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFindClosest(); + } + + void DoFindClosest() + { + var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; + + GameObject[] objects; // objects to consider + + if (string.IsNullOrEmpty(withTag.Value) || withTag.Value == "Untagged") + { + objects = (GameObject[])GameObject.FindObjectsOfType(typeof(GameObject)); + } + else + { + objects = GameObject.FindGameObjectsWithTag(withTag.Value); + } + + GameObject closestObj = null; + var closestDist = Mathf.Infinity; + + foreach (var obj in objects) + { + if (ignoreOwner.Value && obj == Owner) + { + continue; + } + + if (mustBeVisible.Value && !ActionHelpers.IsVisible(obj)) + { + continue; + } + + var dist = (go.transform.position - obj.transform.position).sqrMagnitude; + if (dist < closestDist) + { + closestDist = dist; + closestObj = obj; + } + } + + storeObject.Value = closestObj; + + if (!storeDistance.IsNone) + { + storeDistance.Value = Mathf.Sqrt(closestDist); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FindClosest.cs.meta b/Assets/PlayMaker/Actions/FindClosest.cs.meta new file mode 100755 index 0000000..cb15842 --- /dev/null +++ b/Assets/PlayMaker/Actions/FindClosest.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1ca68d6b093046a4b9ad84fa898eb1cc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FindGameObject.cs b/Assets/PlayMaker/Actions/FindGameObject.cs new file mode 100755 index 0000000..423b2db --- /dev/null +++ b/Assets/PlayMaker/Actions/FindGameObject.cs @@ -0,0 +1,80 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Finds a Game Object by Name and/or Tag.")] + public class FindGameObject : FsmStateAction + { + [Tooltip("The name of the GameObject to find. You can leave this empty if you specify a Tag.")] + public FsmString objectName; + + [UIHint(UIHint.Tag)] + [Tooltip("Find a GameObject with this tag. If Object Name is specified then both name and Tag must match.")] + public FsmString withTag; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a GameObject variable.")] + public FsmGameObject store; + + public override void Reset() + { + objectName = ""; + withTag = "Untagged"; + store = null; + } + + public override void OnEnter() + { + Find(); + Finish(); + } + + void Find() + { + + + if (withTag.Value != "Untagged") + { + if (!string.IsNullOrEmpty(objectName.Value)) + { + var possibleGameObjects = GameObject.FindGameObjectsWithTag(withTag.Value); + + foreach (var go in possibleGameObjects) + { + if (go.name == objectName.Value) + { + store.Value = go; + return; + } + } + + store.Value = null; + return; + } + + store.Value = GameObject.FindGameObjectWithTag(withTag.Value); + return; + } + + store.Value = GameObject.Find(objectName.Value); + + + + } + + public override string ErrorCheck() + { + if (string.IsNullOrEmpty(objectName.Value) && string.IsNullOrEmpty(withTag.Value)) + { + return "Specify Name, Tag, or both."; + } + + return null; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FindGameObject.cs.meta b/Assets/PlayMaker/Actions/FindGameObject.cs.meta new file mode 100755 index 0000000..1429710 --- /dev/null +++ b/Assets/PlayMaker/Actions/FindGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 06d9a34c5ce73ee499c15dc7f3e381ff +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FinishFSM.cs b/Assets/PlayMaker/Actions/FinishFSM.cs new file mode 100755 index 0000000..a694b3f --- /dev/null +++ b/Assets/PlayMaker/Actions/FinishFSM.cs @@ -0,0 +1,17 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Note("Stop this FSM. If this FSM was launched by a Run FSM action, it will trigger a Finish event in that state.")] + [Tooltip("Stop this FSM. If this FSM was launched by a Run FSM action, it will trigger a Finish event in that state.")] + public class FinishFSM : FsmStateAction + { + public override void OnEnter() + { + Fsm.Stop(); + } + } +} diff --git a/Assets/PlayMaker/Actions/FinishFSM.cs.meta b/Assets/PlayMaker/Actions/FinishFSM.cs.meta new file mode 100755 index 0000000..2a314ed --- /dev/null +++ b/Assets/PlayMaker/Actions/FinishFSM.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 42de3c028956f4445a0afbc09ec326ae +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Flicker.cs b/Assets/PlayMaker/Actions/Flicker.cs new file mode 100755 index 0000000..f3b17df --- /dev/null +++ b/Assets/PlayMaker/Actions/Flicker.cs @@ -0,0 +1,100 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Effects)] + [Tooltip("Randomly flickers a Game Object on/off.")] + public class Flicker : ComponentAction + { + [RequiredField] + [Tooltip("The GameObject to flicker.")] + public FsmOwnerDefault gameObject; + + [HasFloatSlider(0, 1)] + [Tooltip("The frequency of the flicker in seconds.")] + public FsmFloat frequency; + + [HasFloatSlider(0, 1)] + [Tooltip("Amount of time flicker is On (0-1). E.g. Use 0.95 for an occasional flicker.")] + public FsmFloat amountOn; + + [Tooltip("Only effect the renderer, leaving other components active.")] + public bool rendererOnly; + + [Tooltip("Ignore time scale. Useful if flickering UI when the game is paused.")] + public bool realTime; + + private float startTime; + private float timer; + + public override void Reset() + { + gameObject = null; + frequency = 0.1f; + amountOn = 0.5f; + rendererOnly = true; + realTime = false; + } + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + timer = 0f; + } + + public override void OnUpdate() + { + // get target + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // update time + + if (realTime) + { + timer = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + timer += Time.deltaTime; + } + + if (timer > frequency.Value) + { + var on = Random.Range(0f,1f) < amountOn.Value; + + // do flicker + + if (rendererOnly) + { + if (UpdateCache(go)) + { + renderer.enabled = on; + } + } + else + { +#if UNITY_3_5 || UNITY_3_4 + go.active = on; +#else + go.SetActive(on); +#endif + } + + // reset timer + + startTime = timer; + timer = 0; + } + } + + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Flicker.cs.meta b/Assets/PlayMaker/Actions/Flicker.cs.meta new file mode 100755 index 0000000..d03675d --- /dev/null +++ b/Assets/PlayMaker/Actions/Flicker.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e15058fb95219274db6d7f289f12181c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatAbs.cs b/Assets/PlayMaker/Actions/FloatAbs.cs new file mode 100755 index 0000000..6259152 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatAbs.cs @@ -0,0 +1,45 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Sets a Float variable to its absolute value.")] + public class FloatAbs : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Float variable.")] + public FsmFloat floatVariable; + + [Tooltip("Repeat every frame. Useful if the Float variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + floatVariable = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoFloatAbs(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFloatAbs(); + } + + void DoFloatAbs() + { + floatVariable.Value = Mathf.Abs(floatVariable.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatAbs.cs.meta b/Assets/PlayMaker/Actions/FloatAbs.cs.meta new file mode 100755 index 0000000..13a9f56 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatAbs.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 86b3f8142ff1f964f9217d989dc943ea +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatAdd.cs b/Assets/PlayMaker/Actions/FloatAdd.cs new file mode 100755 index 0000000..e8ed91a --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatAdd.cs @@ -0,0 +1,61 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Adds a value to a Float Variable.")] + public class FloatAdd : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Float variable to add to.")] + public FsmFloat floatVariable; + + [RequiredField] + [Tooltip("Amount to add.")] + public FsmFloat add; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + [Tooltip("Used with Every Frame. Adds the value over one second to make the operation frame rate independent.")] + public bool perSecond; + + public override void Reset() + { + floatVariable = null; + add = null; + everyFrame = false; + perSecond = false; + } + + public override void OnEnter() + { + DoFloatAdd(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFloatAdd(); + } + + void DoFloatAdd() + { + if (!perSecond) + { + floatVariable.Value += add.Value; + } + else + { + floatVariable.Value += add.Value * Time.deltaTime; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatAdd.cs.meta b/Assets/PlayMaker/Actions/FloatAdd.cs.meta new file mode 100755 index 0000000..b7f68a3 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatAdd.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a0ffdc9f499e2c84fa4d1fb276692d35 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatAddMultiple.cs b/Assets/PlayMaker/Actions/FloatAddMultiple.cs new file mode 100755 index 0000000..3dccdf0 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatAddMultiple.cs @@ -0,0 +1,53 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Adds multipe float variables to float variable.")] + public class FloatAddMultiple : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("The float variables to add.")] + public FsmFloat[] floatVariables; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Add to this variable.")] + public FsmFloat addTo; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + public override void Reset() + { + floatVariables = null; + addTo = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoFloatAdd(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFloatAdd(); + } + + void DoFloatAdd() + { + for (var i = 0; i < floatVariables.Length; i++) + { + addTo.Value += floatVariables[i].Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatAddMultiple.cs.meta b/Assets/PlayMaker/Actions/FloatAddMultiple.cs.meta new file mode 100755 index 0000000..7bf2b3d --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatAddMultiple.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30f480222cbd14e46a7dfdb3ec00fb35 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatChanged.cs b/Assets/PlayMaker/Actions/FloatChanged.cs new file mode 100755 index 0000000..0f56fbe --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatChanged.cs @@ -0,0 +1,56 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if the value of a Float variable changed. Use this to send an event on change, or store a bool that can be used in other operations.")] + public class FloatChanged : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Float variable to watch for a change.")] + public FsmFloat floatVariable; + + [Tooltip("Event to send if the float variable changes.")] + public FsmEvent changedEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Set to True if the float variable changes.")] + public FsmBool storeResult; + + float previousValue; + + public override void Reset() + { + floatVariable = null; + changedEvent = null; + storeResult = null; + } + + public override void OnEnter() + { + if (floatVariable.IsNone) + { + Finish(); + return; + } + + previousValue = floatVariable.Value; + } + + public override void OnUpdate() + { + storeResult.Value = false; + + if (floatVariable.Value != previousValue) + { + previousValue = floatVariable.Value; + storeResult.Value = true; + Fsm.Event(changedEvent); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/FloatChanged.cs.meta b/Assets/PlayMaker/Actions/FloatChanged.cs.meta new file mode 100755 index 0000000..75d83e7 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatChanged.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 739cb6d4280e5c143ae53b1678d6ca11 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatClamp.cs b/Assets/PlayMaker/Actions/FloatClamp.cs new file mode 100755 index 0000000..64452e5 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatClamp.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Clamps the value of Float Variable to a Min/Max range.")] + public class FloatClamp : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Float variable to clamp.")] + public FsmFloat floatVariable; + + [RequiredField] + [Tooltip("The minimum value.")] + public FsmFloat minValue; + + [RequiredField] + [Tooltip("The maximum value.")] + public FsmFloat maxValue; + + [Tooltip("Repeate every frame. Useful if the float variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + floatVariable = null; + minValue = null; + maxValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoClamp(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoClamp(); + } + + void DoClamp() + { + floatVariable.Value = Mathf.Clamp(floatVariable.Value, minValue.Value, maxValue.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatClamp.cs.meta b/Assets/PlayMaker/Actions/FloatClamp.cs.meta new file mode 100755 index 0000000..eebfa94 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatClamp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2f5ef85fe3e4c3a43afe1812481a2438 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatCompare.cs b/Assets/PlayMaker/Actions/FloatCompare.cs new file mode 100755 index 0000000..84e1656 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatCompare.cs @@ -0,0 +1,92 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends Events based on the comparison of 2 Floats.")] + public class FloatCompare : FsmStateAction + { + [RequiredField] + [Tooltip("The first float variable.")] + public FsmFloat float1; + + [RequiredField] + [Tooltip("The second float variable.")] + public FsmFloat float2; + + [RequiredField] + [Tooltip("Tolerance for the Equal test (almost equal).\nNOTE: Floats that look the same are often not exactly the same, so you often need to use a small tolerance.")] + public FsmFloat tolerance; + + [Tooltip("Event sent if Float 1 equals Float 2 (within Tolerance)")] + public FsmEvent equal; + + [Tooltip("Event sent if Float 1 is less than Float 2")] + public FsmEvent lessThan; + + [Tooltip("Event sent if Float 1 is greater than Float 2")] + public FsmEvent greaterThan; + + [Tooltip("Repeat every frame. Useful if the variables are changing and you're waiting for a particular result.")] + public bool everyFrame; + + public override void Reset() + { + float1 = 0f; + float2 = 0f; + tolerance = 0f; + equal = null; + lessThan = null; + greaterThan = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoCompare(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoCompare(); + } + + void DoCompare() + { + + if (Mathf.Abs(float1.Value - float2.Value) <= tolerance.Value) + { + Fsm.Event(equal); + return; + } + + if (float1.Value < float2.Value) + { + Fsm.Event(lessThan); + return; + } + + if (float1.Value > float2.Value) + { + Fsm.Event(greaterThan); + } + + } + + public override string ErrorCheck() + { + if (FsmEvent.IsNullOrEmpty(equal) && + FsmEvent.IsNullOrEmpty(lessThan) && + FsmEvent.IsNullOrEmpty(greaterThan)) + return "Action sends no events!"; + return ""; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatCompare.cs.meta b/Assets/PlayMaker/Actions/FloatCompare.cs.meta new file mode 100755 index 0000000..90dfb36 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatCompare.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84990667b104c414f974e0135e674032 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatDivide.cs b/Assets/PlayMaker/Actions/FloatDivide.cs new file mode 100755 index 0000000..1e72fc1 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatDivide.cs @@ -0,0 +1,45 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Divides one Float by another.")] + public class FloatDivide : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The float variable to divide.")] + public FsmFloat floatVariable; + + [RequiredField] + [Tooltip("Divide the float variable by this value.")] + public FsmFloat divideBy; + + [Tooltip("Repeate every frame. Useful if the variables are changing.")] + public bool everyFrame; + + public override void Reset() + { + floatVariable = null; + divideBy = null; + everyFrame = false; + } + + public override void OnEnter() + { + floatVariable.Value /= divideBy.Value; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + floatVariable.Value /= divideBy.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatDivide.cs.meta b/Assets/PlayMaker/Actions/FloatDivide.cs.meta new file mode 100755 index 0000000..6dc6be9 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatDivide.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e496791d0542b1f44a5b37d81d2822f8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatInterpolate.cs b/Assets/PlayMaker/Actions/FloatInterpolate.cs new file mode 100755 index 0000000..5ec21ca --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatInterpolate.cs @@ -0,0 +1,108 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Interpolates between 2 Float values over a specified Time.")] + public class FloatInterpolate : FsmStateAction + { + [Tooltip("Interpolation mode: Linear or EaseInOut.")] + public InterpolationType mode; + + [RequiredField] + [Tooltip("Interpolate from this value.")] + public FsmFloat fromFloat; + + [RequiredField] + [Tooltip("Interpolate to this value.")] + public FsmFloat toFloat; + + [RequiredField] + [Tooltip("Interpolate over this amount of time in seconds.")] + public FsmFloat time; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the current value in a float variable.")] + public FsmFloat storeResult; + + [Tooltip("Event to send when the interpolation is finished.")] + public FsmEvent finishEvent; + + [Tooltip("Ignore TimeScale. Useful if the game is paused (Time scaled to 0).")] + public bool realTime; + + private float startTime; + private float currentTime; + + public override void Reset() + { + mode = InterpolationType.Linear; + fromFloat = null; + toFloat = null; + time = 1.0f; + storeResult = null; + finishEvent = null; + realTime = false; + } + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + currentTime = 0f; + + if (storeResult == null) + { + Finish(); + } + else + { + storeResult.Value = fromFloat.Value; + } + } + + public override void OnUpdate() + { + // update time + + if (realTime) + { + currentTime = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + currentTime += Time.deltaTime; + } + + var lerpTime = currentTime/time.Value; + + switch (mode) { + + case InterpolationType.Linear: + + storeResult.Value = Mathf.Lerp(fromFloat.Value, toFloat.Value, lerpTime); + + break; + + case InterpolationType.EaseInOut: + + storeResult.Value = Mathf.SmoothStep(fromFloat.Value, toFloat.Value, lerpTime); + + break; + } + + if (lerpTime > 1) + { + if (finishEvent != null) + { + Fsm.Event(finishEvent); + } + + Finish(); + } + + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatInterpolate.cs.meta b/Assets/PlayMaker/Actions/FloatInterpolate.cs.meta new file mode 100755 index 0000000..ac70b52 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatInterpolate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: da7a2fec57b3dc14c9acf45e26522b9f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatMultiply.cs b/Assets/PlayMaker/Actions/FloatMultiply.cs new file mode 100755 index 0000000..e5ad738 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatMultiply.cs @@ -0,0 +1,45 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Multiplies one Float by another.")] + public class FloatMultiply : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The float variable to multiply.")] + public FsmFloat floatVariable; + + [RequiredField] + [Tooltip("Multiply the float variable by this value.")] + public FsmFloat multiplyBy; + + [Tooltip("Repeat every frame. Useful if the variables are changing.")] + public bool everyFrame; + + public override void Reset() + { + floatVariable = null; + multiplyBy = null; + everyFrame = false; + } + + public override void OnEnter() + { + floatVariable.Value *= multiplyBy.Value; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + floatVariable.Value *= multiplyBy.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatMultiply.cs.meta b/Assets/PlayMaker/Actions/FloatMultiply.cs.meta new file mode 100755 index 0000000..9bbc2d2 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatMultiply.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4e9857c05ad00264d90da0f1c9568695 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatOperator.cs b/Assets/PlayMaker/Actions/FloatOperator.cs new file mode 100755 index 0000000..84a6183 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatOperator.cs @@ -0,0 +1,97 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Performs math operations on 2 Floats: Add, Subtract, Multiply, Divide, Min, Max.")] + public class FloatOperator : FsmStateAction + { + public enum Operation + { + Add, + Subtract, + Multiply, + Divide, + Min, + Max + } + + [RequiredField] + [Tooltip("The first float.")] + public FsmFloat float1; + + [RequiredField] + [Tooltip("The second float.")] + public FsmFloat float2; + + [Tooltip("The math operation to perform on the floats.")] + public Operation operation = Operation.Add; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result of the operation in a float variable.")] + public FsmFloat storeResult; + + [Tooltip("Repeat every frame. Useful if the variables are changing.")] + public bool everyFrame; + + public override void Reset() + { + float1 = null; + float2 = null; + operation = Operation.Add; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoFloatOperator(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFloatOperator(); + } + + void DoFloatOperator() + { + var v1 = float1.Value; + var v2 = float2.Value; + + switch (operation) + { + case Operation.Add: + storeResult.Value = v1 + v2; + break; + + case Operation.Subtract: + storeResult.Value = v1 - v2; + break; + + case Operation.Multiply: + storeResult.Value = v1 * v2; + break; + + case Operation.Divide: + storeResult.Value = v1 / v2; + break; + + case Operation.Min: + storeResult.Value = Mathf.Min(v1, v2); + break; + + case Operation.Max: + storeResult.Value = Mathf.Max(v1, v2); + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatOperator.cs.meta b/Assets/PlayMaker/Actions/FloatOperator.cs.meta new file mode 100755 index 0000000..07d4260 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatOperator.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ce19b54bb8fac84f887039b47e758ec +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatSignTest.cs b/Assets/PlayMaker/Actions/FloatSignTest.cs new file mode 100755 index 0000000..7c6a4fb --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatSignTest.cs @@ -0,0 +1,66 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends Events based on the sign of a Float.")] + public class FloatSignTest : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The float variable to test.")] + public FsmFloat floatValue; + + [Tooltip("Event to send if the float variable is positive.")] + public FsmEvent isPositive; + + [Tooltip("Event to send if the float variable is negative.")] + public FsmEvent isNegative; + + [Tooltip("Repeat every frame. Useful if the variable is changing and you're waiting for a particular result.")] + public bool everyFrame; + + public override void Reset() + { + floatValue = 0f; + isPositive = null; + isNegative = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSignTest(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSignTest(); + } + + void DoSignTest() + { + if (floatValue == null) + { + return; + } + + Fsm.Event(floatValue.Value < 0 ? isNegative : isPositive); + } + + public override string ErrorCheck() + { + if (FsmEvent.IsNullOrEmpty(isPositive) && + FsmEvent.IsNullOrEmpty(isNegative)) + return "Action sends no events!"; + return ""; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatSignTest.cs.meta b/Assets/PlayMaker/Actions/FloatSignTest.cs.meta new file mode 100755 index 0000000..45ad173 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatSignTest.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a118f82c78538f14ea2ac55ab786b09a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatSubtract.cs b/Assets/PlayMaker/Actions/FloatSubtract.cs new file mode 100755 index 0000000..10cea09 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatSubtract.cs @@ -0,0 +1,62 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// Simple custom action by Tobbe Olsson - www.tobbeo.net + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Subtracts a value from a Float Variable.")] + public class FloatSubtract : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The float variable to subtract from.")] + public FsmFloat floatVariable; + + [RequiredField] + [Tooltip("Value to subtract from the float variable.")] + public FsmFloat subtract; + + [Tooltip("Repeat every frame while the state is active.")] + public bool everyFrame; + + [Tooltip("Used with Every Frame. Adds the value over one second to make the operation frame rate independent.")] + public bool perSecond; + + public override void Reset() + { + floatVariable = null; + subtract = null; + everyFrame = false; + perSecond = false; + } + + public override void OnEnter() + { + DoFloatSubtract(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFloatSubtract(); + } + + void DoFloatSubtract() + { + if (!perSecond) + { + floatVariable.Value -= subtract.Value; + } + else + { + floatVariable.Value -= subtract.Value * Time.deltaTime; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatSubtract.cs.meta b/Assets/PlayMaker/Actions/FloatSubtract.cs.meta new file mode 100755 index 0000000..42cf33d --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatSubtract.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e8d5cba22795e2f45b0248bf64ecc255 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FloatSwitch.cs b/Assets/PlayMaker/Actions/FloatSwitch.cs new file mode 100755 index 0000000..7c83a36 --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatSwitch.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends an Event based on the value of a Float Variable. The float could represent distance, angle to a target, health left... The array sets up float ranges that correspond to Events.")] + public class FloatSwitch : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The float variable to test.")] + public FsmFloat floatVariable; + + [CompoundArray("Float Switches", "Less Than", "Send Event")] + public FsmFloat[] lessThan; + public FsmEvent[] sendEvent; + + [Tooltip("Repeat every frame. Useful if the variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + floatVariable = null; + lessThan = new FsmFloat[1]; + sendEvent = new FsmEvent[1]; + everyFrame = false; + } + + public override void OnEnter() + { + DoFloatSwitch(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFloatSwitch(); + } + + void DoFloatSwitch() + { + if (floatVariable.IsNone) + { + return; + } + + for (var i = 0; i < lessThan.Length; i++) + { + if (floatVariable.Value < lessThan[i].Value) + { + Fsm.Event(sendEvent[i]); + return; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FloatSwitch.cs.meta b/Assets/PlayMaker/Actions/FloatSwitch.cs.meta new file mode 100755 index 0000000..8f873ee --- /dev/null +++ b/Assets/PlayMaker/Actions/FloatSwitch.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 17170bfcb9493ec4080569d2b67dd82f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FormatString.cs b/Assets/PlayMaker/Actions/FormatString.cs new file mode 100755 index 0000000..f63e1be --- /dev/null +++ b/Assets/PlayMaker/Actions/FormatString.cs @@ -0,0 +1,73 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Replaces each format item in a specified string with the text equivalent of variable's value. Stores the result in a string variable.")] + public class FormatString : FsmStateAction + { + [RequiredField] + [Tooltip("E.g. Hello {0} and {1}\nWith 2 variables that replace {0} and {1}\nSee C# string.Format docs.")] + public FsmString format; + + [Tooltip("Variables to use for each formatting item.")] + public FsmVar[] variables; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the formatted result in a string variable.")] + public FsmString storeResult; + + [Tooltip("Repeat every frame. This is useful if the variables are changing.")] + public bool everyFrame; + + private object[] objectArray; + + public override void Reset() + { + format = null; + variables = null; + storeResult = null; + everyFrame = false; + } + + // Code that runs on entering the state. + public override void OnEnter() + { + objectArray = new object[variables.Length]; + + DoFormatString(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFormatString(); + } + + void DoFormatString() + { + for (var i = 0; i < variables.Length; i++) + { + variables[i].UpdateValue(); + objectArray[i] = variables[i].GetValue(); + } + + try + { + storeResult.Value = string.Format(format.Value, objectArray); + } + catch (System.FormatException e) + { + LogError(e.Message); + Finish(); + } + } + } +} diff --git a/Assets/PlayMaker/Actions/FormatString.cs.meta b/Assets/PlayMaker/Actions/FormatString.cs.meta new file mode 100755 index 0000000..439d506 --- /dev/null +++ b/Assets/PlayMaker/Actions/FormatString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 521dc12fea783ee43b6f00b9cc079b53 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ForwardAllEvents.cs b/Assets/PlayMaker/Actions/ForwardAllEvents.cs new file mode 100755 index 0000000..7f3f851 --- /dev/null +++ b/Assets/PlayMaker/Actions/ForwardAllEvents.cs @@ -0,0 +1,48 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Forwards all event recieved by this FSM to another target. Optionally specify a list of events to ignore.")] + public class ForwardAllEvents : FsmStateAction + { + [Tooltip("Forward to this target.")] + public FsmEventTarget forwardTo; + + [Tooltip("Don't forward these events.")] + public FsmEvent[] exceptThese; + + [Tooltip("Should this action eat the events or pass them on.")] + public bool eatEvents; + + public override void Reset() + { + forwardTo = new FsmEventTarget {target = FsmEventTarget.EventTarget.FSMComponent}; + exceptThese = new[] {FsmEvent.Finished}; + eatEvents = true; + } + + /// + /// Return true to eat the event + /// + public override bool Event(FsmEvent fsmEvent) + { + if (exceptThese != null) + { + foreach (var e in exceptThese) + { + if (e == fsmEvent) + { + return false; + } + } + } + + Fsm.Event(forwardTo, fsmEvent); + + return eatEvents; + } + } +} diff --git a/Assets/PlayMaker/Actions/ForwardAllEvents.cs.meta b/Assets/PlayMaker/Actions/ForwardAllEvents.cs.meta new file mode 100755 index 0000000..c28b7d5 --- /dev/null +++ b/Assets/PlayMaker/Actions/ForwardAllEvents.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c7d6f71ad43da148ad8e1a61f15041b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ForwardEvent.cs b/Assets/PlayMaker/Actions/ForwardEvent.cs new file mode 100755 index 0000000..aa8ffb6 --- /dev/null +++ b/Assets/PlayMaker/Actions/ForwardEvent.cs @@ -0,0 +1,48 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Forward an event recieved by this FSM to another target.")] + public class ForwardEvent : FsmStateAction + { + [Tooltip("Forward to this target.")] + public FsmEventTarget forwardTo; + + [Tooltip("The events to forward.")] + public FsmEvent[] eventsToForward; + + [Tooltip("Should this action eat the events or pass them on.")] + public bool eatEvents; + + public override void Reset() + { + forwardTo = new FsmEventTarget { target = FsmEventTarget.EventTarget.FSMComponent }; + eventsToForward = null; + eatEvents = true; + } + + /// + /// Return true to eat the event + /// + public override bool Event(FsmEvent fsmEvent) + { + if (eventsToForward != null) + { + foreach (var e in eventsToForward) + { + if (e == fsmEvent) + { + Fsm.Event(forwardTo, fsmEvent); + + return eatEvents; + } + } + } + + return false; + } + } +} diff --git a/Assets/PlayMaker/Actions/ForwardEvent.cs.meta b/Assets/PlayMaker/Actions/ForwardEvent.cs.meta new file mode 100755 index 0000000..7858efa --- /dev/null +++ b/Assets/PlayMaker/Actions/ForwardEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 51bb8177791b89b4cbafaa8ba6e67eec +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FsmEventOptions.cs b/Assets/PlayMaker/Actions/FsmEventOptions.cs new file mode 100755 index 0000000..aa7728d --- /dev/null +++ b/Assets/PlayMaker/Actions/FsmEventOptions.cs @@ -0,0 +1,31 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sets how subsequent events sent in this state are handled.")] + public class FsmEventOptions : FsmStateAction + { + public PlayMakerFSM sendToFsmComponent; + public FsmGameObject sendToGameObject; + public FsmString fsmName; + public FsmBool sendToChildren; + public FsmBool broadcastToAll; + + public override void Reset() + { + sendToFsmComponent = null; + sendToGameObject = null; + fsmName = ""; + sendToChildren = false; + broadcastToAll = false; + } + + public override void OnUpdate() + { + + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FsmEventOptions.cs.meta b/Assets/PlayMaker/Actions/FsmEventOptions.cs.meta new file mode 100755 index 0000000..13a0b95 --- /dev/null +++ b/Assets/PlayMaker/Actions/FsmEventOptions.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f288f12d4899683459f7a260c1f1a0fd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FsmStateSwitch.cs b/Assets/PlayMaker/Actions/FsmStateSwitch.cs new file mode 100755 index 0000000..ad5aad8 --- /dev/null +++ b/Assets/PlayMaker/Actions/FsmStateSwitch.cs @@ -0,0 +1,88 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends Events based on the current State of an FSM.")] + public class FsmStateSwitch : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmGameObject gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of Fsm on GameObject. Useful if there is more than one FSM on the GameObject.")] + public FsmString fsmName; + + [CompoundArray("State Switches", "Compare State", "Send Event")] + public FsmString[] compareTo; + public FsmEvent[] sendEvent; + + [Tooltip("Repeat every frame. Useful if you're waiting for a particular result.")] + public bool everyFrame; + + // store game object last frame so we know when it's changed + // and have to cache a new fsm + private GameObject previousGo; + + // cach the fsm component since that's an expensive operation + private PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = null; + compareTo = new FsmString[1]; + sendEvent = new FsmEvent[1]; + everyFrame = false; + } + + public override void OnEnter() + { + DoFsmStateSwitch(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFsmStateSwitch(); + } + + void DoFsmStateSwitch() + { + var go = gameObject.Value; + if (go == null) + { + return; + } + + if (go != previousGo) + { + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + previousGo = go; + } + + if (fsm == null) + { + return; + } + + var activeStateName = fsm.ActiveStateName; + + for (var i = 0; i < compareTo.Length; i++) + { + if (activeStateName == compareTo[i].Value) + { + Fsm.Event(sendEvent[i]); + return; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FsmStateSwitch.cs.meta b/Assets/PlayMaker/Actions/FsmStateSwitch.cs.meta new file mode 100755 index 0000000..d48f51f --- /dev/null +++ b/Assets/PlayMaker/Actions/FsmStateSwitch.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20cdf56e450bf394ea813472c630dab2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/FsmStateTest.cs b/Assets/PlayMaker/Actions/FsmStateTest.cs new file mode 100755 index 0000000..5dd6f8b --- /dev/null +++ b/Assets/PlayMaker/Actions/FsmStateTest.cs @@ -0,0 +1,102 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if an FSM is in the specified State.")] + public class FsmStateTest : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmGameObject gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of Fsm on Game Object. Useful if there is more than one FSM on the GameObject.")] + public FsmString fsmName; + + [RequiredField] + [Tooltip("Check to see if the FSM is in this state.")] + public FsmString stateName; + + [Tooltip("Event to send if the FSM is in the specified state.")] + public FsmEvent trueEvent; + + [Tooltip("Event to send if the FSM is NOT in the specified state.")] + public FsmEvent falseEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result of this test in a bool variable. Useful if other actions depend on this test.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame. Useful if you're waiting for a particular state.")] + public bool everyFrame; + + // store game object last frame so we know when it's changed + // and have to cache a new fsm + private GameObject previousGo; + + // cach the fsm component since that's an expensive operation + private PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = null; + stateName = null; + trueEvent = null; + falseEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoFsmStateTest(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoFsmStateTest(); + } + + void DoFsmStateTest() + { + var go = gameObject.Value; + if (go == null) return; + + if (go != previousGo) + { + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + previousGo = go; + } + + if (fsm == null) + { + return; + } + + var isState = false; + + if (fsm.ActiveStateName == stateName.Value) + { + Fsm.Event(trueEvent); + isState = true; + } + else + { + Fsm.Event(falseEvent); + } + + storeResult.Value = isState; + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/FsmStateTest.cs.meta b/Assets/PlayMaker/Actions/FsmStateTest.cs.meta new file mode 100755 index 0000000..60d9af8 --- /dev/null +++ b/Assets/PlayMaker/Actions/FsmStateTest.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 92923df3aa9dbbe488cc031a06cbc36e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUIAction.cs b/Assets/PlayMaker/Actions/GUIAction.cs new file mode 100755 index 0000000..55117aa --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIAction.cs @@ -0,0 +1,53 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + // base type for GUI actions that need a Rect + [Tooltip("GUI base action - don't use!")] + public abstract class GUIAction : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmRect screenRect; + + public FsmFloat left; + public FsmFloat top; + public FsmFloat width; + public FsmFloat height; + + [RequiredField] + public FsmBool normalized; + + internal Rect rect; + + public override void Reset() + { + screenRect = null; + left = 0; + top = 0; + width = 1; + height = 1; + normalized = true; + } + + public override void OnGUI() + { + rect = !screenRect.IsNone ? screenRect.Value : new Rect(); + + if (!left.IsNone) rect.x = left.Value; + if (!top.IsNone) rect.y = top.Value; + if (!width.IsNone) rect.width = width.Value; + if (!height.IsNone) rect.height = height.Value; + + if (normalized.Value) + { + rect.x *= Screen.width; + rect.width *= Screen.width; + rect.y *= Screen.height; + rect.height *= Screen.height; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUIAction.cs.meta b/Assets/PlayMaker/Actions/GUIAction.cs.meta new file mode 100755 index 0000000..c6b98f4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 17bcb6282e16aed468545082cfb6095e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUIBox.cs b/Assets/PlayMaker/Actions/GUIBox.cs new file mode 100755 index 0000000..9cee6f3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIBox.cs @@ -0,0 +1,26 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("GUI Box.")] + public class GUIBox : GUIContentAction + { + public override void OnGUI() + { + base.OnGUI(); + + if (string.IsNullOrEmpty(style.Value)) + { + GUI.Box(rect, content); + } + else + { + GUI.Box(rect, content, style.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUIBox.cs.meta b/Assets/PlayMaker/Actions/GUIBox.cs.meta new file mode 100755 index 0000000..d52e244 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIBox.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bbd85c2831eb4ee48a8fc6b22f51fbd6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUIButton.cs b/Assets/PlayMaker/Actions/GUIButton.cs new file mode 100755 index 0000000..d0605fc --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIButton.cs @@ -0,0 +1,42 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("GUI button. Sends an Event when pressed. Optionally store the button state in a Bool Variable.")] + public class GUIButton : GUIContentAction + { + public FsmEvent sendEvent; + [UIHint(UIHint.Variable)] + public FsmBool storeButtonState; + + public override void Reset() + { + base.Reset(); + sendEvent = null; + storeButtonState = null; + style = "Button"; + } + + public override void OnGUI() + { + base.OnGUI(); + + bool pressed = false; + + if (GUI.Button(rect, content, style.Value)) + { + Fsm.Event(sendEvent); + pressed = true; + } + + if (storeButtonState != null) + { + storeButtonState.Value = pressed; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUIButton.cs.meta b/Assets/PlayMaker/Actions/GUIButton.cs.meta new file mode 100755 index 0000000..600f0d3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIButton.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 35d4d21f5f6d121469d2889bc4c68247 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUIContentAction.cs b/Assets/PlayMaker/Actions/GUIContentAction.cs new file mode 100755 index 0000000..1bde0a8 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIContentAction.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + // base type for GUI actions with GUIContent parameters + + [Tooltip("GUI base action - don't use!")] + public abstract class GUIContentAction : GUIAction + { + public FsmTexture image; + public FsmString text; + public FsmString tooltip; + public FsmString style; + + internal GUIContent content; + + public override void Reset() + { + base.Reset(); + image = null; + text = ""; + tooltip = ""; + style = ""; + } + + public override void OnGUI() + { + base.OnGUI(); + + content = new GUIContent(text.Value, image.Value, tooltip.Value); + } + } +} diff --git a/Assets/PlayMaker/Actions/GUIContentAction.cs.meta b/Assets/PlayMaker/Actions/GUIContentAction.cs.meta new file mode 100755 index 0000000..dd04eb1 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIContentAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 06e1ed2f413640042aecee9d1cf2a6fa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUIElementHitTest.cs b/Assets/PlayMaker/Actions/GUIElementHitTest.cs new file mode 100755 index 0000000..28b5ba4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIElementHitTest.cs @@ -0,0 +1,122 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUIElement)] + [Tooltip("Performs a Hit Test on a Game Object with a GUITexture or GUIText component.")] + public class GUIElementHitTest : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(GUIElement))] + [Tooltip("The GameObject that has a GUITexture or GUIText component.")] + public FsmOwnerDefault gameObject; + [Tooltip("Specify camera or use MainCamera as default.")] + public Camera camera; + [Tooltip("A vector position on screen. Usually stored by actions like GetTouchInfo, or World To Screen Point.")] + public FsmVector3 screenPoint; + [Tooltip("Specify screen X coordinate.")] + public FsmFloat screenX; + [Tooltip("Specify screen Y coordinate.")] + public FsmFloat screenY; + [Tooltip("Whether the specified screen coordinates are normalized (0-1).")] + public FsmBool normalized; + [Tooltip("Event to send if the Hit Test is true.")] + public FsmEvent hitEvent; + [UIHint(UIHint.Variable)] + [Tooltip("Store the result of the Hit Test in a bool variable (true/false).")] + public FsmBool storeResult; + [Tooltip("Repeat every frame. Useful if you want to wait for the hit test to return true.")] + public FsmBool everyFrame; + + // cache component + private GUIElement guiElement; + + // remember game object cached, so we can re-cache component if it changes + private GameObject gameObjectCached; + + public override void Reset() + { + gameObject = null; + camera = null; + screenPoint = new FsmVector3 { UseVariable = true}; + screenX = new FsmFloat { UseVariable = true}; + screenY = new FsmFloat { UseVariable = true }; + normalized = true; + hitEvent = null; + everyFrame = true; + } + + public override void OnEnter() + { + DoHitTest(); + + if (!everyFrame.Value) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoHitTest(); + } + + void DoHitTest() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // cache GUIElement component + + if (go != gameObjectCached) + { + guiElement = go.GetComponent() ?? (GUIElement) go.GetComponent(); + gameObjectCached = go; + } + + if (guiElement == null) + { + Finish(); + return; + } + + // get screen point to test + + var testPoint = screenPoint.IsNone ? new Vector3(0, 0) : screenPoint.Value; + + if (!screenX.IsNone) + { + testPoint.x = screenX.Value; + } + + if (!screenY.IsNone) + { + testPoint.y = screenY.Value; + } + + if (normalized.Value) + { + testPoint.x *= Screen.width; + testPoint.y *= Screen.height; + } + + // perform hit test + + if (guiElement.HitTest(testPoint, camera)) + { + storeResult.Value = true; + Fsm.Event(hitEvent); + } + else + { + storeResult.Value = false; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUIElementHitTest.cs.meta b/Assets/PlayMaker/Actions/GUIElementHitTest.cs.meta new file mode 100755 index 0000000..02acabc --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIElementHitTest.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 245d4ced7ea5e644caa802866b4057b1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUIHorizontalSlider.cs b/Assets/PlayMaker/Actions/GUIHorizontalSlider.cs new file mode 100755 index 0000000..c600a04 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIHorizontalSlider.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("GUI Horizontal Slider connected to a Float Variable.")] + public class GUIHorizontalSlider : GUIAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat floatVariable; + [RequiredField] + public FsmFloat leftValue; + [RequiredField] + public FsmFloat rightValue; + public FsmString sliderStyle; + public FsmString thumbStyle; + + public override void Reset() + { + base.Reset(); + floatVariable = null; + leftValue = 0f; + rightValue = 100f; + sliderStyle = "horizontalslider"; + thumbStyle = "horizontalsliderthumb"; + } + + public override void OnGUI() + { + base.OnGUI(); + + if(floatVariable != null) + { + floatVariable.Value = GUI.HorizontalSlider(rect, floatVariable.Value, leftValue.Value, rightValue.Value, + sliderStyle.Value != "" ? sliderStyle.Value : "horizontalslider", + thumbStyle.Value != "" ? thumbStyle.Value : "horizontalsliderthumb"); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUIHorizontalSlider.cs.meta b/Assets/PlayMaker/Actions/GUIHorizontalSlider.cs.meta new file mode 100755 index 0000000..7361b1e --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIHorizontalSlider.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 25a46b5ed1cd97e439e3450484cea7af +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILabel.cs b/Assets/PlayMaker/Actions/GUILabel.cs new file mode 100755 index 0000000..d4e789e --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILabel.cs @@ -0,0 +1,26 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("GUI Label.")] + public class GUILabel : GUIContentAction + { + public override void OnGUI() + { + base.OnGUI(); + + if (string.IsNullOrEmpty(style.Value)) + { + GUI.Label(rect, content); + } + else + { + GUI.Label(rect, content, style.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILabel.cs.meta b/Assets/PlayMaker/Actions/GUILabel.cs.meta new file mode 100755 index 0000000..0e90ecd --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILabel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f6f9a724c3a042e459fdd042677426b1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutAction.cs b/Assets/PlayMaker/Actions/GUILayoutAction.cs new file mode 100755 index 0000000..27362ff --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutAction.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [Tooltip("GUILayout base action - don't use!")] + public abstract class GUILayoutAction : FsmStateAction + { + public LayoutOption[] layoutOptions; + + GUILayoutOption[] options; + + public GUILayoutOption[] LayoutOptions + { + get + { + if (options == null) + { + options = new GUILayoutOption[layoutOptions.Length]; + for (int i = 0; i < layoutOptions.Length; i++) + options[i] = layoutOptions[i].GetGUILayoutOption(); + } + + return options; + } + } + + public override void Reset() + { + layoutOptions = new LayoutOption[0]; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutAction.cs.meta b/Assets/PlayMaker/Actions/GUILayoutAction.cs.meta new file mode 100755 index 0000000..ee48d00 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cf00ee48784570f4ebf959a52d160ae4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginArea.cs b/Assets/PlayMaker/Actions/GUILayoutBeginArea.cs new file mode 100755 index 0000000..d33de06 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginArea.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Begin a GUILayout block of GUI controls in a fixed screen area. NOTE: Block must end with a corresponding GUILayoutEndArea.")] + public class GUILayoutBeginArea : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmRect screenRect; + public FsmFloat left; + public FsmFloat top; + public FsmFloat width; + public FsmFloat height; + public FsmBool normalized; + public FsmString style; + + private Rect rect; + + public override void Reset() + { + screenRect = null; + left = 0; + top = 0; + width = 1; + height = 1; + normalized = true; + style = ""; + } + + public override void OnGUI() + { + rect = !screenRect.IsNone ? screenRect.Value : new Rect(); + + if (!left.IsNone) rect.x = left.Value; + if (!top.IsNone) rect.y = top.Value; + if (!width.IsNone) rect.width = width.Value; + if (!height.IsNone) rect.height = height.Value; + + if (normalized.Value) + { + rect.x *= Screen.width; + rect.width *= Screen.width; + rect.y *= Screen.height; + rect.height *= Screen.height; + } + + // if no GUIContent is given, then the signature is misunderstood as BeginAreay(Rect,String) + GUILayout.BeginArea(rect, GUIContent.none, style.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginArea.cs.meta b/Assets/PlayMaker/Actions/GUILayoutBeginArea.cs.meta new file mode 100755 index 0000000..cc51d5e --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginArea.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30c94f2ef05504344a6ef1667d4a9fd8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginAreaFollowObject.cs b/Assets/PlayMaker/Actions/GUILayoutBeginAreaFollowObject.cs new file mode 100755 index 0000000..089d576 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginAreaFollowObject.cs @@ -0,0 +1,93 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Begin a GUILayout area that follows the specified game object. Useful for overlays (e.g., playerName). NOTE: Block must end with a corresponding GUILayoutEndArea.")] + public class GUILayoutBeginAreaFollowObject : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to follow.")] + public FsmGameObject gameObject; + + [RequiredField] + public FsmFloat offsetLeft; + + [RequiredField] + public FsmFloat offsetTop; + + [RequiredField] + public FsmFloat width; + + [RequiredField] + public FsmFloat height; + + [Tooltip("Use normalized screen coordinates (0-1).")] + public FsmBool normalized; + + [Tooltip("Optional named style in the current GUISkin")] + public FsmString style; + + public override void Reset() + { + gameObject = null; + offsetLeft = 0f; + offsetTop = 0f; + width = 1f; + height = 1f; + normalized = true; + style = ""; + } + + public override void OnGUI() + { + var go = gameObject.Value; + + if (go == null || Camera.main == null) + { + DummyBeginArea(); + return; + } + + // get go position in camera space + + var worldPosition = go.transform.position; + var positionInCameraSpace = Camera.main.transform.InverseTransformPoint(worldPosition); + if (positionInCameraSpace.z < 0) + { + // behind camera, but still need to BeginArea() + // TODO option to keep onscreen + DummyBeginArea(); + return; + } + + // get screen position + + Vector2 screenPos = Camera.main.WorldToScreenPoint(worldPosition); + + var left = screenPos.x + (normalized.Value ? offsetLeft.Value * Screen.width : offsetLeft.Value); + var top = screenPos.y + (normalized.Value ? offsetTop.Value * Screen.width : offsetTop.Value); + + var rect = new Rect(left, top, width.Value, height.Value); + + if (normalized.Value) + { + rect.width *= Screen.width; + rect.height *= Screen.height; + } + + // convert screen coordinates + rect.y = Screen.height - rect.y; + + GUILayout.BeginArea(rect, style.Value); + } + + static void DummyBeginArea() + { + GUILayout.BeginArea(new Rect()); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginAreaFollowObject.cs.meta b/Assets/PlayMaker/Actions/GUILayoutBeginAreaFollowObject.cs.meta new file mode 100755 index 0000000..2441519 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginAreaFollowObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f950adc018606d4c8bab36697f6732c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginCentered.cs b/Assets/PlayMaker/Actions/GUILayoutBeginCentered.cs new file mode 100755 index 0000000..c3a271d --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginCentered.cs @@ -0,0 +1,25 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Begin a centered GUILayout block. The block is centered inside a parent GUILayout Area. So to place the block in the center of the screen, first use a GULayout Area the size of the whole screen (the default setting). NOTE: Block must end with a corresponding GUILayoutEndCentered.")] + public class GUILayoutBeginCentered : FsmStateAction + { + public override void Reset() + { + } + + public override void OnGUI() + { + GUILayout.BeginVertical(); + GUILayout.FlexibleSpace(); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.BeginVertical(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginCentered.cs.meta b/Assets/PlayMaker/Actions/GUILayoutBeginCentered.cs.meta new file mode 100755 index 0000000..d275a63 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginCentered.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6230eb3c4a60d944cbcdd5c911ff378c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginHorizontal.cs b/Assets/PlayMaker/Actions/GUILayoutBeginHorizontal.cs new file mode 100755 index 0000000..75877b3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginHorizontal.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout BeginHorizontal.")] + public class GUILayoutBeginHorizontal : GUILayoutAction + { + public FsmTexture image; + public FsmString text; + public FsmString tooltip; + public FsmString style; + + public override void Reset() + { + base.Reset(); + text = ""; + image = null; + tooltip = ""; + style = ""; + } + + public override void OnGUI() + { + GUILayout.BeginHorizontal(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginHorizontal.cs.meta b/Assets/PlayMaker/Actions/GUILayoutBeginHorizontal.cs.meta new file mode 100755 index 0000000..ace747d --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginHorizontal.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 27cd4a9db3650944583f7a4c89dba5e1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginScrollView.cs b/Assets/PlayMaker/Actions/GUILayoutBeginScrollView.cs new file mode 100755 index 0000000..b7768db --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginScrollView.cs @@ -0,0 +1,58 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Begins a ScrollView. Use GUILayoutEndScrollView at the end of the block.")] + public class GUILayoutBeginScrollView : GUILayoutAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Assign a Vector2 variable to store the scroll position of this view.")] + public FsmVector2 scrollPosition; + + [Tooltip("Always show the horizontal scrollbars.")] + public FsmBool horizontalScrollbar; + + [Tooltip("Always show the vertical scrollbars.")] + public FsmBool verticalScrollbar; + + [Tooltip("Define custom styles below. NOTE: You have to define all the styles if you check this option.")] + public FsmBool useCustomStyle; + + [Tooltip("Named style in the active GUISkin for the horizontal scrollbars.")] + public FsmString horizontalStyle; + + [Tooltip("Named style in the active GUISkin for the vertical scrollbars.")] + public FsmString verticalStyle; + + [Tooltip("Named style in the active GUISkin for the background.")] + public FsmString backgroundStyle; + + public override void Reset() + { + base.Reset(); + scrollPosition = null; + horizontalScrollbar = null; + verticalScrollbar = null; + useCustomStyle = null; + horizontalStyle = null; + verticalStyle = null; + backgroundStyle = null; + } + + public override void OnGUI() + { + if (useCustomStyle.Value) + { + scrollPosition.Value = GUILayout.BeginScrollView(scrollPosition.Value, horizontalScrollbar.Value, verticalScrollbar.Value, horizontalStyle.Value, verticalStyle.Value, backgroundStyle.Value, LayoutOptions); + } + else + { + scrollPosition.Value = GUILayout.BeginScrollView(scrollPosition.Value, horizontalScrollbar.Value, verticalScrollbar.Value, LayoutOptions); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginScrollView.cs.meta b/Assets/PlayMaker/Actions/GUILayoutBeginScrollView.cs.meta new file mode 100755 index 0000000..b2cc5fa --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginScrollView.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46d1d0e6718068d4183523024920c532 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginVertical.cs b/Assets/PlayMaker/Actions/GUILayoutBeginVertical.cs new file mode 100755 index 0000000..27f1aba --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginVertical.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Begins a vertical control group. The group must be closed with GUILayoutEndVertical action.")] + public class GUILayoutBeginVertical : GUILayoutAction + { + public FsmTexture image; + public FsmString text; + public FsmString tooltip; + public FsmString style; + + public override void Reset() + { + base.Reset(); + text = ""; + image = null; + tooltip = ""; + style = ""; + } + + public override void OnGUI() + { + GUILayout.BeginVertical(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutBeginVertical.cs.meta b/Assets/PlayMaker/Actions/GUILayoutBeginVertical.cs.meta new file mode 100755 index 0000000..c2825c6 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBeginVertical.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 58a06762632d10f42a3cf2003a1584b1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutBox.cs b/Assets/PlayMaker/Actions/GUILayoutBox.cs new file mode 100755 index 0000000..fcbf9d4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBox.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Box.")] + public class GUILayoutBox : GUILayoutAction + { + [Tooltip("Image to display in the Box.")] + public FsmTexture image; + + [Tooltip("Text to display in the Box.")] + public FsmString text; + + [Tooltip("Optional Tooltip string.")] + public FsmString tooltip; + + [Tooltip("Optional GUIStyle in the active GUISkin.")] + public FsmString style; + + public override void Reset() + { + base.Reset(); + text = ""; + image = null; + tooltip = ""; + style = ""; + } + + public override void OnGUI() + { + if (string.IsNullOrEmpty(style.Value)) + { + GUILayout.Box(new GUIContent(text.Value, image.Value, tooltip.Value), LayoutOptions); + } + else + { + GUILayout.Box(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutBox.cs.meta b/Assets/PlayMaker/Actions/GUILayoutBox.cs.meta new file mode 100755 index 0000000..821dde8 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutBox.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 10aedf67ed01d084d9f7ca62ebe92533 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutButton.cs b/Assets/PlayMaker/Actions/GUILayoutButton.cs new file mode 100755 index 0000000..cbe8a5b --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutButton.cs @@ -0,0 +1,54 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Button. Sends an Event when pressed. Optionally stores the button state in a Bool Variable.")] + public class GUILayoutButton : GUILayoutAction + { + public FsmEvent sendEvent; + [UIHint(UIHint.Variable)] + public FsmBool storeButtonState; + public FsmTexture image; + public FsmString text; + public FsmString tooltip; + public FsmString style; + + public override void Reset() + { + base.Reset(); + sendEvent = null; + storeButtonState = null; + text = ""; + image = null; + tooltip = ""; + style = ""; + } + + public override void OnGUI() + { + bool buttonPressed; + + if (string.IsNullOrEmpty(style.Value)) + { + buttonPressed = GUILayout.Button(new GUIContent(text.Value, image.Value, tooltip.Value), LayoutOptions); + } + else + { + buttonPressed = GUILayout.Button(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions); + } + + if (buttonPressed) + { + Fsm.Event(sendEvent); + } + + if (storeButtonState != null) + { + storeButtonState.Value = buttonPressed; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutButton.cs.meta b/Assets/PlayMaker/Actions/GUILayoutButton.cs.meta new file mode 100755 index 0000000..bcf6f0a --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutButton.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e7f20b3c86dfaf346b29850e99187a6d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutConfirmPasswordField.cs b/Assets/PlayMaker/Actions/GUILayoutConfirmPasswordField.cs new file mode 100755 index 0000000..bd897c1 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutConfirmPasswordField.cs @@ -0,0 +1,50 @@ +using UnityEngine; +using System.Collections; + + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Password Field. Optionally send an event if the text has been edited.")] + public class GUILayoutConfirmPasswordField : GUILayoutAction { + + [UIHint(UIHint.Variable)] + public FsmString text; + public FsmInt maxLength; + public FsmString style; + public FsmEvent changedEvent; + public FsmString mask; + public FsmBool confirm; + public FsmString password; + + public override void Reset() + { + text = null; + maxLength = 25; + style = "TextField"; + mask = "*"; + changedEvent = null; + confirm = false; + password = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + text.Value = GUILayout.PasswordField(text.Value, mask.Value[0], style.Value, LayoutOptions); + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/GUILayoutConfirmPasswordField.cs.meta b/Assets/PlayMaker/Actions/GUILayoutConfirmPasswordField.cs.meta new file mode 100755 index 0000000..651cdb4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutConfirmPasswordField.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 26f5f741942744e468b2cd0fd24c75a3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutEmailField.cs b/Assets/PlayMaker/Actions/GUILayoutEmailField.cs new file mode 100755 index 0000000..6ae6f83 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEmailField.cs @@ -0,0 +1,44 @@ +using UnityEngine; +using System.Collections; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Password Field. Optionally send an event if the text has been edited.")] + public class GUILayoutEmailField : GUILayoutAction { + + [UIHint(UIHint.Variable)] + public FsmString text; + public FsmInt maxLength; + public FsmString style; + public FsmEvent changedEvent; + public FsmBool valid; + + public override void Reset() + { + text = null; + maxLength = 25; + style = "TextField"; + valid = true; + changedEvent = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + text.Value = GUILayout.TextField(text.Value, style.Value, LayoutOptions); + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} diff --git a/Assets/PlayMaker/Actions/GUILayoutEmailField.cs.meta b/Assets/PlayMaker/Actions/GUILayoutEmailField.cs.meta new file mode 100755 index 0000000..97c667f --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEmailField.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c911af626aab7184eb71f56bf16b4bc2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutEndArea.cs b/Assets/PlayMaker/Actions/GUILayoutEndArea.cs new file mode 100755 index 0000000..ec2abc9 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndArea.cs @@ -0,0 +1,21 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Close a GUILayout group started with BeginArea.")] + public class GUILayoutEndArea : FsmStateAction + { + public override void Reset() + { + } + + public override void OnGUI() + { + GUILayout.EndArea(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutEndArea.cs.meta b/Assets/PlayMaker/Actions/GUILayoutEndArea.cs.meta new file mode 100755 index 0000000..3e3e832 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndArea.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f41e103f41cd8fd489822cc2e7694a19 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutEndCentered.cs b/Assets/PlayMaker/Actions/GUILayoutEndCentered.cs new file mode 100755 index 0000000..58c37d1 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndCentered.cs @@ -0,0 +1,25 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("End a centered GUILayout block started with GUILayoutBeginCentered.")] + public class GUILayoutEndCentered : FsmStateAction + { + public override void Reset() + { + } + + public override void OnGUI() + { + GUILayout.EndVertical(); + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutEndCentered.cs.meta b/Assets/PlayMaker/Actions/GUILayoutEndCentered.cs.meta new file mode 100755 index 0000000..818c727 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndCentered.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 89536a71cb2d5d646b6848e75bd3462f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutEndHorizontal.cs b/Assets/PlayMaker/Actions/GUILayoutEndHorizontal.cs new file mode 100755 index 0000000..fd2ade9 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndHorizontal.cs @@ -0,0 +1,21 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Close a group started with BeginHorizontal.")] + public class GUILayoutEndHorizontal : FsmStateAction + { + public override void Reset() + { + } + + public override void OnGUI() + { + GUILayout.EndHorizontal(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutEndHorizontal.cs.meta b/Assets/PlayMaker/Actions/GUILayoutEndHorizontal.cs.meta new file mode 100755 index 0000000..53fb849 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndHorizontal.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e2da75bd5e127349a81f1645b16996a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutEndScrollView.cs b/Assets/PlayMaker/Actions/GUILayoutEndScrollView.cs new file mode 100755 index 0000000..448d0be --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndScrollView.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Close a group started with GUILayout Begin ScrollView.")] + public class GUILayoutEndScrollView : FsmStateAction + { + public override void OnGUI() + { + GUILayout.EndScrollView(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutEndScrollView.cs.meta b/Assets/PlayMaker/Actions/GUILayoutEndScrollView.cs.meta new file mode 100755 index 0000000..b4761af --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndScrollView.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4e9ea6bfde86b2e4b9bee487684216f4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutEndVertical.cs b/Assets/PlayMaker/Actions/GUILayoutEndVertical.cs new file mode 100755 index 0000000..20a2770 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndVertical.cs @@ -0,0 +1,21 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Close a group started with BeginVertical.")] + public class GUILayoutEndVertical : FsmStateAction + { + public override void Reset() + { + } + + public override void OnGUI() + { + GUILayout.EndVertical(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutEndVertical.cs.meta b/Assets/PlayMaker/Actions/GUILayoutEndVertical.cs.meta new file mode 100755 index 0000000..2f0ee18 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutEndVertical.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cfb813ec7fa31c24fb0a710e1d1906ac +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutFlexibleSpace.cs b/Assets/PlayMaker/Actions/GUILayoutFlexibleSpace.cs new file mode 100755 index 0000000..0ae4adb --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutFlexibleSpace.cs @@ -0,0 +1,21 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Inserts a flexible space element.")] + public class GUILayoutFlexibleSpace : FsmStateAction + { + public override void Reset() + { + } + + public override void OnGUI() + { + GUILayout.FlexibleSpace(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutFlexibleSpace.cs.meta b/Assets/PlayMaker/Actions/GUILayoutFlexibleSpace.cs.meta new file mode 100755 index 0000000..0e59c67 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutFlexibleSpace.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a405bebdd5bfcb240afa2a953a244314 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutFloatField.cs b/Assets/PlayMaker/Actions/GUILayoutFloatField.cs new file mode 100755 index 0000000..97efbfe --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutFloatField.cs @@ -0,0 +1,54 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Text Field to edit a Float Variable. Optionally send an event if the text has been edited.")] + public class GUILayoutFloatField : GUILayoutAction + { + [UIHint(UIHint.Variable)] + [Tooltip("Float Variable to show in the edit field.")] + public FsmFloat floatVariable; + + [Tooltip("Optional GUIStyle in the active GUISKin.")] + public FsmString style; + + [Tooltip("Optional event to send when the value changes.")] + public FsmEvent changedEvent; + + public override void Reset() + { + base.Reset(); + floatVariable = null; + style = ""; + changedEvent = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + if (!string.IsNullOrEmpty(style.Value)) + { + floatVariable.Value = float.Parse(GUILayout.TextField(floatVariable.Value.ToString(), style.Value, LayoutOptions)); + } + else + { + floatVariable.Value = float.Parse(GUILayout.TextField(floatVariable.Value.ToString(), LayoutOptions)); + } + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutFloatField.cs.meta b/Assets/PlayMaker/Actions/GUILayoutFloatField.cs.meta new file mode 100755 index 0000000..721aef3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutFloatField.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ff0e259b09945248bd95ee5892ac218 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutFloatLabel.cs b/Assets/PlayMaker/Actions/GUILayoutFloatLabel.cs new file mode 100755 index 0000000..5ee4360 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutFloatLabel.cs @@ -0,0 +1,42 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Label for a Float Variable.")] + public class GUILayoutFloatLabel : GUILayoutAction + { + [Tooltip("Text to put before the float variable.")] + public FsmString prefix; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Float variable to display.")] + public FsmFloat floatVariable; + + [Tooltip("Optional GUIStyle in the active GUISKin.")] + public FsmString style; + + public override void Reset() + { + base.Reset(); + prefix = ""; + style = ""; + floatVariable = null; + } + + public override void OnGUI() + { + if (string.IsNullOrEmpty(style.Value)) + { + GUILayout.Label(new GUIContent(prefix.Value + floatVariable.Value), LayoutOptions); + } + else + { + GUILayout.Label(new GUIContent(prefix.Value + floatVariable.Value), style.Value, LayoutOptions); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutFloatLabel.cs.meta b/Assets/PlayMaker/Actions/GUILayoutFloatLabel.cs.meta new file mode 100755 index 0000000..89796b5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutFloatLabel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c77202432ac19af46a106033a35e138c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutHorizontalSlider.cs b/Assets/PlayMaker/Actions/GUILayoutHorizontalSlider.cs new file mode 100755 index 0000000..0179bd9 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutHorizontalSlider.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("A Horizontal Slider linked to a Float Variable.")] + public class GUILayoutHorizontalSlider : GUILayoutAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat floatVariable; + [RequiredField] + public FsmFloat leftValue; + [RequiredField] + public FsmFloat rightValue; + public FsmEvent changedEvent; + + public override void Reset() + { + base.Reset(); + floatVariable = null; + leftValue = 0; + rightValue = 100; + changedEvent = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + if(floatVariable != null) + { + floatVariable.Value = GUILayout.HorizontalSlider(floatVariable.Value, leftValue.Value, rightValue.Value, LayoutOptions); + } + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutHorizontalSlider.cs.meta b/Assets/PlayMaker/Actions/GUILayoutHorizontalSlider.cs.meta new file mode 100755 index 0000000..1f386cb --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutHorizontalSlider.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4be705bd84f718e448a0471f4adca4a0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutIntField.cs b/Assets/PlayMaker/Actions/GUILayoutIntField.cs new file mode 100755 index 0000000..0372a03 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutIntField.cs @@ -0,0 +1,54 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Text Field to edit an Int Variable. Optionally send an event if the text has been edited.")] + public class GUILayoutIntField : GUILayoutAction + { + [UIHint(UIHint.Variable)] + [Tooltip("Int Variable to show in the edit field.")] + public FsmInt intVariable; + + [Tooltip("Optional GUIStyle in the active GUISKin.")] + public FsmString style; + + [Tooltip("Optional event to send when the value changes.")] + public FsmEvent changedEvent; + + public override void Reset() + { + base.Reset(); + intVariable = null; + style = ""; + changedEvent = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + if (!string.IsNullOrEmpty(style.Value)) + { + intVariable.Value = int.Parse(GUILayout.TextField(intVariable.Value.ToString(), style.Value, LayoutOptions)); + } + else + { + intVariable.Value = int.Parse(GUILayout.TextField(intVariable.Value.ToString(), LayoutOptions)); + } + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutIntField.cs.meta b/Assets/PlayMaker/Actions/GUILayoutIntField.cs.meta new file mode 100755 index 0000000..a3c0318 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutIntField.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d29fefa855ea4bd48a9e06b7391153ee +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutIntLabel.cs b/Assets/PlayMaker/Actions/GUILayoutIntLabel.cs new file mode 100755 index 0000000..9b0e266 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutIntLabel.cs @@ -0,0 +1,42 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Label for an Int Variable.")] + public class GUILayoutIntLabel : GUILayoutAction + { + [Tooltip("Text to put before the int variable.")] + public FsmString prefix; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Int variable to display.")] + public FsmInt intVariable; + + [Tooltip("Optional GUIStyle in the active GUISKin.")] + public FsmString style; + + public override void Reset() + { + base.Reset(); + prefix = ""; + style = ""; + intVariable = null; + } + + public override void OnGUI() + { + if (string.IsNullOrEmpty(style.Value)) + { + GUILayout.Label(new GUIContent(prefix.Value + intVariable.Value), LayoutOptions); + } + else + { + GUILayout.Label(new GUIContent(prefix.Value + intVariable.Value), style.Value, LayoutOptions); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutIntLabel.cs.meta b/Assets/PlayMaker/Actions/GUILayoutIntLabel.cs.meta new file mode 100755 index 0000000..266eb31 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutIntLabel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: efa7dd743542ef948835fe37027787c0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutLabel.cs b/Assets/PlayMaker/Actions/GUILayoutLabel.cs new file mode 100755 index 0000000..717e4f5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutLabel.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Label.")] + public class GUILayoutLabel : GUILayoutAction + { + public FsmTexture image; + public FsmString text; + public FsmString tooltip; + public FsmString style; + + public override void Reset() + { + base.Reset(); + text = ""; + image = null; + tooltip = ""; + style = ""; + } + + public override void OnGUI() + { + if (string.IsNullOrEmpty(style.Value)) + { + GUILayout.Label(new GUIContent(text.Value, image.Value, tooltip.Value), LayoutOptions); + } + else + { + GUILayout.Label(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutLabel.cs.meta b/Assets/PlayMaker/Actions/GUILayoutLabel.cs.meta new file mode 100755 index 0000000..e87a8b4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutLabel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 04c8d5fb24524c8448204a0732529090 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutPasswordField.cs b/Assets/PlayMaker/Actions/GUILayoutPasswordField.cs new file mode 100755 index 0000000..d531c60 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutPasswordField.cs @@ -0,0 +1,44 @@ +using UnityEngine; +using System.Collections; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Password Field. Optionally send an event if the text has been edited.")] + public class GUILayoutPasswordField : GUILayoutAction { + + [UIHint(UIHint.Variable)] + public FsmString text; + public FsmInt maxLength; + public FsmString style; + public FsmEvent changedEvent; + public FsmString mask; + + public override void Reset() + { + text = null; + maxLength = 25; + style = "TextField"; + mask = "*"; + changedEvent = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + text.Value = GUILayout.PasswordField(text.Value, mask.Value[0], style.Value, LayoutOptions); + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} diff --git a/Assets/PlayMaker/Actions/GUILayoutPasswordField.cs.meta b/Assets/PlayMaker/Actions/GUILayoutPasswordField.cs.meta new file mode 100755 index 0000000..a07d854 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutPasswordField.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aec5b40288ceef042a20a6b9362313dd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutRepeatButton.cs b/Assets/PlayMaker/Actions/GUILayoutRepeatButton.cs new file mode 100755 index 0000000..a133728 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutRepeatButton.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Repeat Button. Sends an Event while pressed. Optionally store the button state in a Bool Variable.")] + public class GUILayoutRepeatButton : GUILayoutAction + { + public FsmEvent sendEvent; + [UIHint(UIHint.Variable)] + public FsmBool storeButtonState; + public FsmTexture image; + public FsmString text; + public FsmString tooltip; + public FsmString style; + + public override void Reset() + { + base.Reset(); + sendEvent = null; + storeButtonState = null; + text = ""; + image = null; + tooltip = ""; + style = ""; + } + + public override void OnGUI() + { + bool buttonPressed; + + if (string.IsNullOrEmpty(style.Value)) + { + buttonPressed = GUILayout.RepeatButton(new GUIContent(text.Value, image.Value, tooltip.Value), LayoutOptions); + } + else + { + buttonPressed = GUILayout.RepeatButton(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions); + } + + if (buttonPressed) + { + Fsm.Event(sendEvent); + } + + storeButtonState.Value = buttonPressed; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutRepeatButton.cs.meta b/Assets/PlayMaker/Actions/GUILayoutRepeatButton.cs.meta new file mode 100755 index 0000000..6ab243d --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutRepeatButton.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0aa9bb6fb5a38c44fb12d1c8bce8108d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutSelectionGrid.cs b/Assets/PlayMaker/Actions/GUILayoutSelectionGrid.cs new file mode 100755 index 0000000..9934469 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutSelectionGrid.cs @@ -0,0 +1,19 @@ +/*using UnityEngine; +using System.Collections; + +public class GUILayoutSelectionGrid : MonoBehaviour +{ + + // Use this for initialization + void Start () + { + + } + + // Update is called once per frame + void Update () + { + + } +}*/ + diff --git a/Assets/PlayMaker/Actions/GUILayoutSelectionGrid.cs.meta b/Assets/PlayMaker/Actions/GUILayoutSelectionGrid.cs.meta new file mode 100755 index 0000000..005407c --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutSelectionGrid.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cb2a3347525f41a489603abd9d5b51c8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutSpace.cs b/Assets/PlayMaker/Actions/GUILayoutSpace.cs new file mode 100755 index 0000000..6f6aae9 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutSpace.cs @@ -0,0 +1,24 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Inserts a space in the current layout group.")] + public class GUILayoutSpace : FsmStateAction + { + public FsmFloat space; + + public override void Reset() + { + space = 10; + } + + public override void OnGUI() + { + GUILayout.Space(space.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutSpace.cs.meta b/Assets/PlayMaker/Actions/GUILayoutSpace.cs.meta new file mode 100755 index 0000000..3a89d7a --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutSpace.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cf27a70ac1ccdde4c974c9247dd005e8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutTextField.cs b/Assets/PlayMaker/Actions/GUILayoutTextField.cs new file mode 100755 index 0000000..986cf1d --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutTextField.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Text Field. Optionally send an event if the text has been edited.")] + public class GUILayoutTextField : GUILayoutAction + { + [UIHint(UIHint.Variable)] + public FsmString text; + public FsmInt maxLength; + public FsmString style; + public FsmEvent changedEvent; + + public override void Reset() + { + base.Reset(); + text = null; + maxLength = 25; + style = "TextField"; + changedEvent = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + text.Value = GUILayout.TextField(text.Value, maxLength.Value, style.Value, LayoutOptions); + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutTextField.cs.meta b/Assets/PlayMaker/Actions/GUILayoutTextField.cs.meta new file mode 100755 index 0000000..93baafc --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutTextField.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d10183de2e7f04c479c30ee6b98678aa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutTextLabel.cs b/Assets/PlayMaker/Actions/GUILayoutTextLabel.cs new file mode 100755 index 0000000..a29fb92 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutTextLabel.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Label for simple text.")] + public class GUILayoutTextLabel : GUILayoutAction + { + [Tooltip("Text to display.")] + public FsmString text; + + [Tooltip("Optional GUIStyle in the active GUISkin.")] + public FsmString style; + + public override void Reset() + { + base.Reset(); + text = ""; + style = ""; + } + + public override void OnGUI() + { + if (string.IsNullOrEmpty(style.Value)) + { + GUILayout.Label(new GUIContent(text.Value), LayoutOptions); + } + else + { + GUILayout.Label(new GUIContent(text.Value), style.Value, LayoutOptions); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutTextLabel.cs.meta b/Assets/PlayMaker/Actions/GUILayoutTextLabel.cs.meta new file mode 100755 index 0000000..0460b59 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutTextLabel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c4ce0c89f6af5a6409cb7b0a80d27ceb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutToggle.cs b/Assets/PlayMaker/Actions/GUILayoutToggle.cs new file mode 100755 index 0000000..f3961fd --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutToggle.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Makes an on/off Toggle Button and stores the button state in a Bool Variable.")] + public class GUILayoutToggle : GUILayoutAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmBool storeButtonState; + public FsmTexture image; + public FsmString text; + public FsmString tooltip; + public FsmString style; + public FsmEvent changedEvent; + + public override void Reset() + { + base.Reset(); + storeButtonState = null; + text = ""; + image = null; + tooltip = ""; + style = "Toggle"; + changedEvent = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + storeButtonState.Value = GUILayout.Toggle(storeButtonState.Value, new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions); + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutToggle.cs.meta b/Assets/PlayMaker/Actions/GUILayoutToggle.cs.meta new file mode 100755 index 0000000..9eeb33e --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutToggle.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 208746a6e3e2cff4ca7694ad623a36e6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutToolbar.cs b/Assets/PlayMaker/Actions/GUILayoutToolbar.cs new file mode 100755 index 0000000..edfaf80 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutToolbar.cs @@ -0,0 +1,104 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("GUILayout Toolbar. NOTE: Arrays must be the same length as NumButtons or empty.")] + public class GUILayoutToolbar : GUILayoutAction + { + public FsmInt numButtons; + [UIHint(UIHint.Variable)] + public FsmInt selectedButton; + public FsmEvent[] buttonEventsArray; + public FsmTexture[] imagesArray; + public FsmString[] textsArray; + public FsmString[] tooltipsArray; + public FsmString style; + + GUIContent[] contents; + + public GUIContent[] Contents + { + get + { + if (contents == null) + { + contents = new GUIContent[numButtons.Value]; + for (int i = 0; i < numButtons.Value; i++) + contents[i] = new GUIContent(); + + for (int i = 0; i < imagesArray.Length; i++) + contents[i].image = imagesArray[i].Value; + + for (int i = 0; i < textsArray.Length; i++) + contents[i].text = textsArray[i].Value; + + for (int i = 0; i < tooltipsArray.Length; i++) + contents[i].tooltip = tooltipsArray[i].Value; + } + + return contents; + } + } + + public override void Reset() + { + base.Reset(); + numButtons = 0; + selectedButton = null; + buttonEventsArray = new FsmEvent[0]; + imagesArray = new FsmTexture[0]; + tooltipsArray = new FsmString[0]; + style = "Button"; + } + + public override void OnEnter() + { + string error = ErrorCheck(); + + if (!string.IsNullOrEmpty(error)) + { + LogError(error); + Finish(); + } + + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + selectedButton.Value = GUILayout.Toolbar(selectedButton.Value, Contents, style.Value, LayoutOptions); + + if (GUI.changed) + { + if (selectedButton.Value < buttonEventsArray.Length) + { + Fsm.Event(buttonEventsArray[selectedButton.Value]); + GUIUtility.ExitGUI(); + } + } + else + { + GUI.changed = guiChanged; + } + } + + public override string ErrorCheck () + { + string error = ""; + + if (imagesArray.Length > 0 && imagesArray.Length != numButtons.Value) + error += "Images array doesn't match NumButtons.\n"; + if (textsArray.Length > 0 && textsArray.Length != numButtons.Value) + error += "Texts array doesn't match NumButtons.\n"; + if (tooltipsArray.Length > 0 && tooltipsArray.Length != numButtons.Value) + error += "Tooltips array doesn't match NumButtons.\n"; + + return error; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutToolbar.cs.meta b/Assets/PlayMaker/Actions/GUILayoutToolbar.cs.meta new file mode 100755 index 0000000..13af789 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutToolbar.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bd581a34e06b296429e81366c0b07b68 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUILayoutVerticalSlider.cs b/Assets/PlayMaker/Actions/GUILayoutVerticalSlider.cs new file mode 100755 index 0000000..15d9c77 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutVerticalSlider.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("A Vertical Slider linked to a Float Variable.")] + public class GUILayoutVerticalSlider : GUILayoutAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat floatVariable; + [RequiredField] + public FsmFloat topValue; + [RequiredField] + public FsmFloat bottomValue; + public FsmEvent changedEvent; + + public override void Reset() + { + base.Reset(); + floatVariable = null; + topValue = 100; + bottomValue = 0; + changedEvent = null; + } + + public override void OnGUI() + { + var guiChanged = GUI.changed; + GUI.changed = false; + + if(floatVariable != null) + { + floatVariable.Value = GUILayout.VerticalSlider(floatVariable.Value, topValue.Value, bottomValue.Value, LayoutOptions); + } + + if (GUI.changed) + { + Fsm.Event(changedEvent); + GUIUtility.ExitGUI(); + } + else + { + GUI.changed = guiChanged; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUILayoutVerticalSlider.cs.meta b/Assets/PlayMaker/Actions/GUILayoutVerticalSlider.cs.meta new file mode 100755 index 0000000..751f342 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUILayoutVerticalSlider.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 168b3347511283149a9f6295254dd123 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUITooltip.cs b/Assets/PlayMaker/Actions/GUITooltip.cs new file mode 100755 index 0000000..dde9013 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUITooltip.cs @@ -0,0 +1,25 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Gets the Tooltip of the control the mouse is currently over and store it in a String Variable.")] + public class GUITooltip : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmString storeTooltip; + + public override void Reset() + { + storeTooltip = null; + } + + public override void OnGUI() + { + storeTooltip.Value = GUI.tooltip; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUITooltip.cs.meta b/Assets/PlayMaker/Actions/GUITooltip.cs.meta new file mode 100755 index 0000000..3e32c9d --- /dev/null +++ b/Assets/PlayMaker/Actions/GUITooltip.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9d0e2091200eed44689cbb414dd73395 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GUIVerticalSlider.cs b/Assets/PlayMaker/Actions/GUIVerticalSlider.cs new file mode 100755 index 0000000..f695923 --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIVerticalSlider.cs @@ -0,0 +1,45 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("GUI Vertical Slider connected to a Float Variable.")] + public class GUIVerticalSlider : GUIAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat floatVariable; + [RequiredField] + public FsmFloat topValue; + [RequiredField] + public FsmFloat bottomValue; + public FsmString sliderStyle; + public FsmString thumbStyle; + + public override void Reset() + { + base.Reset(); + floatVariable = null; + topValue = 100f; + bottomValue = 0f; + sliderStyle = "verticalslider"; + thumbStyle = "verticalsliderthumb"; + width = 0.1f; + } + + public override void OnGUI() + { + base.OnGUI(); + + if(floatVariable != null) + { + floatVariable.Value = GUI.VerticalSlider(rect, floatVariable.Value, topValue.Value, bottomValue.Value, + sliderStyle.Value != "" ? sliderStyle.Value : "verticalslider", + thumbStyle.Value != "" ? thumbStyle.Value : "verticalsliderthumb"); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GUIVerticalSlider.cs.meta b/Assets/PlayMaker/Actions/GUIVerticalSlider.cs.meta new file mode 100755 index 0000000..bc6c70d --- /dev/null +++ b/Assets/PlayMaker/Actions/GUIVerticalSlider.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7236a76ba89533945a2f8847dbd362a2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GameObjectChanged.cs b/Assets/PlayMaker/Actions/GameObjectChanged.cs new file mode 100755 index 0000000..8e40a26 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectChanged.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if the value of a GameObject variable changed. Use this to send an event on change, or store a bool that can be used in other operations.")] + public class GameObjectChanged : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The GameObject variable to watch for a change.")] + public FsmGameObject gameObjectVariable; + + [Tooltip("Event to send if the variable changes.")] + public FsmEvent changedEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Set to True if the variable changes.")] + public FsmBool storeResult; + + private GameObject previousValue; + + public override void Reset() + { + gameObjectVariable = null; + changedEvent = null; + storeResult = null; + } + + public override void OnEnter() + { + if (gameObjectVariable.IsNone) + { + Finish(); + return; + } + + previousValue = gameObjectVariable.Value; + } + + public override void OnUpdate() + { + storeResult.Value = false; + + if (gameObjectVariable.Value != previousValue) + { + storeResult.Value = true; + Fsm.Event(changedEvent); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/GameObjectChanged.cs.meta b/Assets/PlayMaker/Actions/GameObjectChanged.cs.meta new file mode 100755 index 0000000..9dbc037 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectChanged.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c00c48530d8d5c44eaf36d86978c60ff +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GameObjectCompare.cs b/Assets/PlayMaker/Actions/GameObjectCompare.cs new file mode 100755 index 0000000..427270d --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectCompare.cs @@ -0,0 +1,77 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Compares 2 Game Objects and sends Events based on the result.")] + public class GameObjectCompare : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Title("Game Object")] + [Tooltip("A Game Object variable to compare.")] + public FsmOwnerDefault gameObjectVariable; + + [RequiredField] + [Tooltip("Compare the variable with this Game Object")] + public FsmGameObject compareTo; + + [Tooltip("Send this event if Game Objects are equal")] + public FsmEvent equalEvent; + + [Tooltip("Send this event if Game Objects are not equal")] + public FsmEvent notEqualEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result of the check in a Bool Variable. (True if equal, false if not equal).")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame. Useful if you're waiting for a true or false result.")] + public bool everyFrame; + + public override void Reset() + { + gameObjectVariable = null; + compareTo = null; + equalEvent = null; + notEqualEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGameObjectCompare(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGameObjectCompare(); + } + + void DoGameObjectCompare() + { + var equal = Fsm.GetOwnerDefaultTarget(gameObjectVariable) == compareTo.Value; + + storeResult.Value = equal; + + if (equal && equalEvent != null) + { + Fsm.Event(equalEvent); + } + else if (!equal && notEqualEvent != null) + { + Fsm.Event(notEqualEvent); + } + + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GameObjectCompare.cs.meta b/Assets/PlayMaker/Actions/GameObjectCompare.cs.meta new file mode 100755 index 0000000..d946429 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectCompare.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8d4a3389d8a0c344faf105a37e5e990b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GameObjectCompareTag.cs b/Assets/PlayMaker/Actions/GameObjectCompareTag.cs new file mode 100755 index 0000000..0ae62b8 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectCompareTag.cs @@ -0,0 +1,70 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if a Game Object has a tag.")] + public class GameObjectCompareTag : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to test.")] + public FsmGameObject gameObject; + + [RequiredField] + [UIHint(UIHint.Tag)] + [Tooltip("The Tag to check for.")] + public FsmString tag; + + [Tooltip("Event to send if the GameObject has the Tag.")] + public FsmEvent trueEvent; + + [Tooltip("Event to send if the GameObject does not have the Tag.")] + public FsmEvent falseEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a Bool variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + tag = "Untagged"; + trueEvent = null; + falseEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoCompareTag(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoCompareTag(); + } + + void DoCompareTag() + { + var hasTag = false; + + if (gameObject.Value != null) + { + hasTag = gameObject.Value.CompareTag(tag.Value); + } + + storeResult.Value = hasTag; + + Fsm.Event(hasTag ? trueEvent : falseEvent); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GameObjectCompareTag.cs.meta b/Assets/PlayMaker/Actions/GameObjectCompareTag.cs.meta new file mode 100755 index 0000000..834d4ac --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectCompareTag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ad53193224edfbf48b46c3e5cabcec93 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GameObjectHasChildren.cs b/Assets/PlayMaker/Actions/GameObjectHasChildren.cs new file mode 100755 index 0000000..54b3918 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectHasChildren.cs @@ -0,0 +1,67 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if a GameObject has children.")] + public class GameObjectHasChildren : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to test.")] + public FsmOwnerDefault gameObject; + + [Tooltip("Event to send if the GameObject has children.")] + public FsmEvent trueEvent; + + [Tooltip("Event to send if the GameObject does not have children.")] + public FsmEvent falseEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a bool variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + trueEvent = null; + falseEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoHasChildren(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoHasChildren(); + } + + void DoHasChildren() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var hasChildren = go.transform.childCount > 0; + + storeResult.Value = hasChildren; + + Fsm.Event(hasChildren ? trueEvent : falseEvent); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GameObjectHasChildren.cs.meta b/Assets/PlayMaker/Actions/GameObjectHasChildren.cs.meta new file mode 100755 index 0000000..407266e --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectHasChildren.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 002d4d76d73b72447a3f0f535181ed23 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GameObjectIsChildOf.cs b/Assets/PlayMaker/Actions/GameObjectIsChildOf.cs new file mode 100755 index 0000000..f6e0a9a --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectIsChildOf.cs @@ -0,0 +1,60 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if a GameObject is a Child of another GameObject.")] + public class GameObjectIsChildOf : FsmStateAction + { + [RequiredField] + [Tooltip("GameObject to test.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("Is it a child of this GameObject?")] + public FsmGameObject isChildOf; + + [Tooltip("Event to send if GameObject is a child.")] + public FsmEvent trueEvent; + + [Tooltip("Event to send if GameObject is NOT a child.")] + public FsmEvent falseEvent; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store result in a bool variable")] + public FsmBool storeResult; + + public override void Reset() + { + gameObject = null; + isChildOf = null; + trueEvent = null; + falseEvent = null; + storeResult = null; + } + + public override void OnEnter() + { + DoIsChildOf(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + void DoIsChildOf(GameObject go) + { + if (go == null || isChildOf == null) + { + return; + } + + var isChild = go.transform.IsChildOf(isChildOf.Value.transform); + + storeResult.Value = isChild; + + Fsm.Event(isChild ? trueEvent : falseEvent); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GameObjectIsChildOf.cs.meta b/Assets/PlayMaker/Actions/GameObjectIsChildOf.cs.meta new file mode 100755 index 0000000..91095c4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectIsChildOf.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9cd05436dc89657409bb2199a60b8e0d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GameObjectIsNull.cs b/Assets/PlayMaker/Actions/GameObjectIsNull.cs new file mode 100755 index 0000000..4d3cf91 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectIsNull.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if a GameObject Variable has a null value. E.g., If the FindGameObject action failed to find an object.")] + public class GameObjectIsNull : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The GameObject variable to test.")] + public FsmGameObject gameObject; + + [Tooltip("Event to send if the GamObject is null.")] + public FsmEvent isNull; + + [Tooltip("Event to send if the GamObject is NOT null.")] + public FsmEvent isNotNull; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a bool variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + isNull = null; + isNotNull = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoIsGameObjectNull(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoIsGameObjectNull(); + } + + void DoIsGameObjectNull() + { + var goIsNull = gameObject.Value == null; + + if (storeResult != null) + { + storeResult.Value = goIsNull; + } + + Fsm.Event(goIsNull ? isNull : isNotNull); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GameObjectIsNull.cs.meta b/Assets/PlayMaker/Actions/GameObjectIsNull.cs.meta new file mode 100755 index 0000000..3a835c1 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectIsNull.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46ec54b167425fb49af68d433df15d74 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GameObjectIsVisible.cs b/Assets/PlayMaker/Actions/GameObjectIsVisible.cs new file mode 100755 index 0000000..7f3bbd6 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectIsVisible.cs @@ -0,0 +1,65 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if a Game Object is visible.")] + public class GameObjectIsVisible : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Renderer))] + [Tooltip("The GameObject to test.")] + public FsmOwnerDefault gameObject; + + [Tooltip("Event to send if the GameObject is visible.")] + public FsmEvent trueEvent; + + [Tooltip("Event to send if the GameObject is NOT visible.")] + public FsmEvent falseEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a bool variable.")] + public FsmBool storeResult; + + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + trueEvent = null; + falseEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoIsVisible(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoIsVisible(); + } + + void DoIsVisible() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + var isVisible = renderer.isVisible; + storeResult.Value = isVisible; + Fsm.Event(isVisible ? trueEvent : falseEvent); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/GameObjectIsVisible.cs.meta b/Assets/PlayMaker/Actions/GameObjectIsVisible.cs.meta new file mode 100755 index 0000000..b62b6bf --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectIsVisible.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3dfbe4a6cf9612c458b56236e4da4893 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GameObjectTagSwitch.cs b/Assets/PlayMaker/Actions/GameObjectTagSwitch.cs new file mode 100755 index 0000000..6d19f14 --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectTagSwitch.cs @@ -0,0 +1,65 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends an Event based on a Game Object's Tag.")] + public class GameObjectTagSwitch : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The GameObject to test.")] + public FsmGameObject gameObject; + + [CompoundArray("Tag Switches", "Compare Tag", "Send Event")] + [UIHint(UIHint.Tag)] + public FsmString[] compareTo; + public FsmEvent[] sendEvent; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + compareTo = new FsmString[1]; + sendEvent = new FsmEvent[1]; + everyFrame = false; + } + + public override void OnEnter() + { + DoTagSwitch(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoTagSwitch(); + } + + void DoTagSwitch() + { + var go = gameObject.Value; + if (go == null) + { + return; + } + + for (var i = 0; i < compareTo.Length; i++) + { + if (go.tag == compareTo[i].Value) + { + Fsm.Event(sendEvent[i]); + return; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GameObjectTagSwitch.cs.meta b/Assets/PlayMaker/Actions/GameObjectTagSwitch.cs.meta new file mode 100755 index 0000000..9da9ece --- /dev/null +++ b/Assets/PlayMaker/Actions/GameObjectTagSwitch.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 59478a071e6d32d45aa0b076e9cd9017 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetAngleToTarget.cs b/Assets/PlayMaker/Actions/GetAngleToTarget.cs new file mode 100755 index 0000000..c8b301a --- /dev/null +++ b/Assets/PlayMaker/Actions/GetAngleToTarget.cs @@ -0,0 +1,89 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Gets the Angle between a GameObject's forward axis and a Target. The Target can be defined as a GameObject or a world Position. If you specify both, then the Position will be used as a local offset from the Target Object's position.")] + public class GetAngleToTarget : FsmStateAction + { + [RequiredField] + [Tooltip("The game object whose forward axis we measure from. If the target is dead ahead the angle will be 0.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The target object to measure the angle to. Or use target position.")] + public FsmGameObject targetObject; + + [Tooltip("The world position to measure an angle to. If Target Object is also specified, this vector is used as an offset from that object's position.")] + public FsmVector3 targetPosition; + + [Tooltip("Ignore height differences when calculating the angle.")] + public FsmBool ignoreHeight; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the angle in a float variable.")] + public FsmFloat storeAngle; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + targetObject = null; + targetPosition = new FsmVector3 { UseVariable = true}; + ignoreHeight = true; + storeAngle = null; + everyFrame = false; + } + + public override void OnLateUpdate() + { + DoGetAngleToTarget(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoGetAngleToTarget() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var goTarget = targetObject.Value; + if (goTarget == null && targetPosition.IsNone) + { + return; + } + + Vector3 targetPos; + if (goTarget != null) + { + targetPos = !targetPosition.IsNone ? + goTarget.transform.TransformPoint(targetPosition.Value) : + goTarget.transform.position; + } + else + { + targetPos = targetPosition.Value; + } + + if (ignoreHeight.Value) + { + targetPos.y = go.transform.position.y; + } + + var targetDir = targetPos - go.transform.position; + + storeAngle.Value = Vector3.Angle(targetDir, go.transform.forward); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetAngleToTarget.cs.meta b/Assets/PlayMaker/Actions/GetAngleToTarget.cs.meta new file mode 100755 index 0000000..b9cabb4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetAngleToTarget.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30feefdfd82d7554f972fcdc8e444987 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetAxis.cs b/Assets/PlayMaker/Actions/GetAxis.cs new file mode 100755 index 0000000..e31ea8d --- /dev/null +++ b/Assets/PlayMaker/Actions/GetAxis.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Gets the value of the specified Input Axis and stores it in a Float Variable. See Unity Input Manager docs.")] + public class GetAxis : FsmStateAction + { + [RequiredField] + [Tooltip("The name of the axis. Set in the Unity Input Manager.")] + public FsmString axisName; + + [Tooltip("Axis values are in the range -1 to 1. Use the multiplier to set a larger range.")] + public FsmFloat multiplier; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a float variable.")] + public FsmFloat store; + + [Tooltip("Repeat every frame. Typically this would be set to True.")] + public bool everyFrame; + + public override void Reset() + { + axisName = ""; + multiplier = 1.0f; + store = null; + everyFrame = true; + } + + public override void OnEnter() + { + DoGetAxis(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetAxis(); + } + + void DoGetAxis() + { + var axisValue = Input.GetAxis(axisName.Value); + + // if variable set to none, assume multiplier of 1 + if (!multiplier.IsNone) + { + axisValue *= multiplier.Value; + } + + store.Value = axisValue; + } + } +} + diff --git a/Assets/PlayMaker/Actions/GetAxis.cs.meta b/Assets/PlayMaker/Actions/GetAxis.cs.meta new file mode 100755 index 0000000..1a6c92b --- /dev/null +++ b/Assets/PlayMaker/Actions/GetAxis.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46dfe4d824cf8b14593e4e9d57327b96 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetAxisVector.cs b/Assets/PlayMaker/Actions/GetAxisVector.cs new file mode 100755 index 0000000..aeb0812 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetAxisVector.cs @@ -0,0 +1,126 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Gets a world direction Vector from 2 Input Axis. Typically used for a third person controller with Relative To set to the camera.")] + public class GetAxisVector : FsmStateAction + { + public enum AxisPlane + { + XZ, + XY, + YZ + } + + [Tooltip("The name of the horizontal input axis. See Unity Input Manager.")] + public FsmString horizontalAxis; + + [Tooltip("The name of the vertical input axis. See Unity Input Manager.")] + public FsmString verticalAxis; + + [Tooltip("Input axis are reported in the range -1 to 1, this multiplier lets you set a new range.")] + public FsmFloat multiplier; + + [RequiredField] + [Tooltip("The world plane to map the 2d input onto.")] + public AxisPlane mapToPlane; + + [Tooltip("Make the result relative to a GameObject, typically the main camera.")] + public FsmGameObject relativeTo; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the direction vector.")] + public FsmVector3 storeVector; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the length of the direction vector.")] + public FsmFloat storeMagnitude; + + public override void Reset() + { + horizontalAxis = "Horizontal"; + verticalAxis = "Vertical"; + multiplier = 1.0f; + mapToPlane = AxisPlane.XZ; + storeVector = null; + storeMagnitude = null; + } + + public override void OnUpdate() + { + var forward = new Vector3(); + var right = new Vector3(); + + if (relativeTo.Value == null) + { + switch (mapToPlane) + { + case AxisPlane.XZ: + forward = Vector3.forward; + right = Vector3.right; + break; + + case AxisPlane.XY: + forward = Vector3.up; + right = Vector3.right; + break; + + case AxisPlane.YZ: + forward = Vector3.up; + right = Vector3.forward; + break; + } + } + else + { + var transform = relativeTo.Value.transform; + + switch (mapToPlane) + { + case AxisPlane.XZ: + forward = transform.TransformDirection(Vector3.forward); + forward.y = 0; + forward = forward.normalized; + right = new Vector3(forward.z, 0, -forward.x); + break; + + case AxisPlane.XY: + case AxisPlane.YZ: + // NOTE: in relative mode XY ans YZ are the same! + forward = Vector3.up; + forward.z = 0; + forward = forward.normalized; + right = transform.TransformDirection(Vector3.right); + break; + } + + // Right vector relative to the object + // Always orthogonal to the forward vector + + } + + // get individual axis + // leaving an axis blank or set to None sets it to 0 + + var h = (horizontalAxis.IsNone || string.IsNullOrEmpty(horizontalAxis.Value)) ? 0f : Input.GetAxis(horizontalAxis.Value); + var v = (verticalAxis.IsNone || string.IsNullOrEmpty(verticalAxis.Value)) ? 0f : Input.GetAxis(verticalAxis.Value); + + // calculate resulting direction vector + + var direction = h * right + v * forward; + direction *= multiplier.Value; + + storeVector.Value = direction; + + if (!storeMagnitude.IsNone) + { + storeMagnitude.Value = direction.magnitude; + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/GetAxisVector.cs.meta b/Assets/PlayMaker/Actions/GetAxisVector.cs.meta new file mode 100755 index 0000000..dd6ec11 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetAxisVector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 792beefc57adc2547bdff316107dbb3d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetButton.cs b/Assets/PlayMaker/Actions/GetButton.cs new file mode 100755 index 0000000..72a57fd --- /dev/null +++ b/Assets/PlayMaker/Actions/GetButton.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Gets the pressed state of the specified Button and stores it in a Bool Variable. See Unity Input Manager docs.")] + public class GetButton : FsmStateAction + { + [RequiredField] + [Tooltip("The name of the button. Set in the Unity Input Manager.")] + public FsmString buttonName; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a bool variable.")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + buttonName = "Fire1"; + storeResult = null; + everyFrame = true; + } + + public override void OnEnter() + { + DoGetButton(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetButton(); + } + + void DoGetButton() + { + storeResult.Value = Input.GetButton(buttonName.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/GetButton.cs.meta b/Assets/PlayMaker/Actions/GetButton.cs.meta new file mode 100755 index 0000000..e1a865e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetButton.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84793dec0f7bc3c4aa18e798f4418028 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetButtonDown.cs b/Assets/PlayMaker/Actions/GetButtonDown.cs new file mode 100755 index 0000000..cf9b85e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetButtonDown.cs @@ -0,0 +1,41 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends an Event when a Button is pressed.")] + public class GetButtonDown : FsmStateAction + { + [RequiredField] + [Tooltip("The name of the button. Set in the Unity Input Manager.")] + public FsmString buttonName; + + [Tooltip("Event to send if the button is pressed.")] + public FsmEvent sendEvent; + + [Tooltip("Set to True if the button is pressed.")] + [UIHint(UIHint.Variable)] + public FsmBool storeResult; + + public override void Reset() + { + buttonName = "Fire1"; + sendEvent = null; + storeResult = null; + } + + public override void OnUpdate() + { + var buttonDown = Input.GetButtonDown(buttonName.Value); + + if (buttonDown) + { + Fsm.Event(sendEvent); + } + + storeResult.Value = buttonDown; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetButtonDown.cs.meta b/Assets/PlayMaker/Actions/GetButtonDown.cs.meta new file mode 100755 index 0000000..fd75186 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetButtonDown.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e27b07f69defd0148ace6783eb8fbeeb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetButtonUp.cs b/Assets/PlayMaker/Actions/GetButtonUp.cs new file mode 100755 index 0000000..28ae979 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetButtonUp.cs @@ -0,0 +1,41 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends an Event when a Button is released.")] + public class GetButtonUp : FsmStateAction + { + [RequiredField] + [Tooltip("The name of the button. Set in the Unity Input Manager.")] + public FsmString buttonName; + + [Tooltip("Event to send if the button is released.")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Set to True if the button is released.")] + public FsmBool storeResult; + + public override void Reset() + { + buttonName = "Fire1"; + sendEvent = null; + storeResult = null; + } + + public override void OnUpdate() + { + var buttonUp = Input.GetButtonUp(buttonName.Value); + + if (buttonUp) + { + Fsm.Event(sendEvent); + } + + storeResult.Value = buttonUp; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetButtonUp.cs.meta b/Assets/PlayMaker/Actions/GetButtonUp.cs.meta new file mode 100755 index 0000000..251e183 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetButtonUp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8fdb363c300e2ae4e8bad177b18c1eee +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetChild.cs b/Assets/PlayMaker/Actions/GetChild.cs new file mode 100755 index 0000000..9cf12c3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetChild.cs @@ -0,0 +1,98 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Finds the Child of a GameObject by Name and/or Tag. Use this to find attach points etc. NOTE: This action will search recursively through all children and return the first match; To find a specific child use Find Child.")] + public class GetChild : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to search.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The name of the child to search for.")] + public FsmString childName; + + [UIHint(UIHint.Tag)] + [Tooltip("The Tag to search for. If Child Name is set, both name and Tag need to match.")] + public FsmString withTag; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a GameObject variable.")] + public FsmGameObject storeResult; + + public override void Reset() + { + gameObject = null; + childName = ""; + withTag = "Untagged"; + storeResult = null; + } + + public override void OnEnter() + { + storeResult.Value = DoGetChildByName(Fsm.GetOwnerDefaultTarget(gameObject), childName.Value, withTag.Value); + + Finish(); + } + + static GameObject DoGetChildByName(GameObject root, string name, string tag) + { + if (root == null) + { + return null; + } + + foreach (Transform child in root.transform) + { + if (!string.IsNullOrEmpty(name)) + { + if (child.name == name) + { + if (!string.IsNullOrEmpty(tag)) + { + if (child.tag.Equals(tag)) + { + return child.gameObject; + } + } + else + { + return child.gameObject; + } + } + } + else if (!string.IsNullOrEmpty((tag))) + { + if (child.tag == tag) + { + return child.gameObject; + } + } + + // search recursively + + var returnObject = DoGetChildByName(child.gameObject, name, tag); + if(returnObject != null) + { + return returnObject; + } + } + + return null; + } + + public override string ErrorCheck() + { + if (string.IsNullOrEmpty(childName.Value) && string.IsNullOrEmpty(withTag.Value)) + { + return "Specify Child Name, Tag, or both."; + } + return null; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetChild.cs.meta b/Assets/PlayMaker/Actions/GetChild.cs.meta new file mode 100755 index 0000000..d5537e6 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetChild.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f4adf55e2c4dc5418731b9b9a8dc780 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetChildCount.cs b/Assets/PlayMaker/Actions/GetChildCount.cs new file mode 100755 index 0000000..d564545 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetChildCount.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets the number of children that a GameObject has.")] + public class GetChildCount : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to test.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the number of children in an int variable.")] + public FsmInt storeResult; + + public override void Reset() + { + gameObject = null; + storeResult = null; + } + + public override void OnEnter() + { + DoGetChildCount(); + + Finish(); + } + + void DoGetChildCount() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + storeResult.Value = go.transform.childCount; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetChildCount.cs.meta b/Assets/PlayMaker/Actions/GetChildCount.cs.meta new file mode 100755 index 0000000..df0a195 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetChildCount.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8efed92cdcc759c4f94d26420dd73d87 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetChildNum.cs b/Assets/PlayMaker/Actions/GetChildNum.cs new file mode 100755 index 0000000..54cba64 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetChildNum.cs @@ -0,0 +1,43 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets the Child of a GameObject by Index.\nE.g., O to get the first child. HINT: Use this with an integer variable to iterate through children.")] + public class GetChildNum : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to search.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The index of the child to find.")] + public FsmInt childIndex; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the child in a GameObject variable.")] + public FsmGameObject store; + + public override void Reset() + { + gameObject = null; + childIndex = 0; + store = null; + } + + public override void OnEnter() + { + store.Value = DoGetChildNum(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + GameObject DoGetChildNum(GameObject go) + { + return go == null ? null : go.transform.GetChild(childIndex.Value % go.transform.childCount).gameObject; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetChildNum.cs.meta b/Assets/PlayMaker/Actions/GetChildNum.cs.meta new file mode 100755 index 0000000..02dc33a --- /dev/null +++ b/Assets/PlayMaker/Actions/GetChildNum.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3ad9fe5da426834eae997733367641c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetCollisionInfo.cs b/Assets/PlayMaker/Actions/GetCollisionInfo.cs new file mode 100755 index 0000000..10e07ef --- /dev/null +++ b/Assets/PlayMaker/Actions/GetCollisionInfo.cs @@ -0,0 +1,71 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Gets info on the last collision event and store in variables. See Unity Physics docs.")] + public class GetCollisionInfo : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("Get the GameObject hit.")] + public FsmGameObject gameObjectHit; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the relative velocity of the collision.")] + public FsmVector3 relativeVelocity; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the relative speed of the collision. Useful for controlling reactions. E.g., selecting an appropriate sound fx.")] + public FsmFloat relativeSpeed; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the world position of the collision contact. Useful for spawning effects etc.")] + public FsmVector3 contactPoint; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the collision normal vector. Useful for aligning spawned effects etc.")] + public FsmVector3 contactNormal; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the name of the physics material of the colliding GameObject. Useful for triggering different effects. Audio, particles...")] + public FsmString physicsMaterialName; + + public override void Reset() + { + gameObjectHit = null; + relativeVelocity = null; + relativeSpeed = null; + contactPoint = null; + contactNormal = null; + physicsMaterialName = null; + } + + void StoreCollisionInfo() + { + if (Fsm.CollisionInfo == null) + { + return; + } + + gameObjectHit.Value = Fsm.CollisionInfo.gameObject; + relativeSpeed.Value = Fsm.CollisionInfo.relativeVelocity.magnitude; + relativeVelocity.Value = Fsm.CollisionInfo.relativeVelocity; + physicsMaterialName.Value = Fsm.CollisionInfo.collider.material.name; + + if (Fsm.CollisionInfo.contacts != null && Fsm.CollisionInfo.contacts.Length > 0) + { + contactPoint.Value = Fsm.CollisionInfo.contacts[0].point; + contactNormal.Value = Fsm.CollisionInfo.contacts[0].normal; + } + } + + public override void OnEnter() + { + StoreCollisionInfo(); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetCollisionInfo.cs.meta b/Assets/PlayMaker/Actions/GetCollisionInfo.cs.meta new file mode 100755 index 0000000..139cbb8 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetCollisionInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8241c7f0706b3bc41a7e3a8155be2824 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetColorRGBA.cs b/Assets/PlayMaker/Actions/GetColorRGBA.cs new file mode 100755 index 0000000..1389dfe --- /dev/null +++ b/Assets/PlayMaker/Actions/GetColorRGBA.cs @@ -0,0 +1,73 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Color)] + [Tooltip("Get the RGBA channels of a Color Variable and store them in Float Variables.")] + public class GetColorRGBA : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The Color variable.")] + public FsmColor color; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the red channel in a float variable.")] + public FsmFloat storeRed; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the green channel in a float variable.")] + public FsmFloat storeGreen; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the blue channel in a float variable.")] + public FsmFloat storeBlue; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the alpha channel in a float variable.")] + public FsmFloat storeAlpha; + + [Tooltip("Repeat every frame. Useful if the color variable is changing.")] + public bool everyFrame; + + public override void Reset() + { + color = null; + storeRed = null; + storeGreen = null; + storeBlue = null; + storeAlpha = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetColorRGBA(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate () + { + DoGetColorRGBA(); + } + + void DoGetColorRGBA() + { + if (color.IsNone) + { + return; + } + + storeRed.Value = color.Value.r; + storeGreen.Value = color.Value.g; + storeBlue.Value = color.Value.b; + storeAlpha.Value = color.Value.a; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetColorRGBA.cs.meta b/Assets/PlayMaker/Actions/GetColorRGBA.cs.meta new file mode 100755 index 0000000..dba5401 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetColorRGBA.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20a1bfe0231a3d447af9ee3bfab360f9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetComponent.cs b/Assets/PlayMaker/Actions/GetComponent.cs new file mode 100755 index 0000000..7a53eb5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetComponent.cs @@ -0,0 +1,66 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.UnityObject)] + [Tooltip("Gets a Component attached to a GameObject and stores it in an Object variable. NOTE: Set the Object variable's Object Type to get a component of that type. E.g., set Object Type to UnityEngine.AudioListener to get the AudioListener component on the camera.")] + public class GetComponent : FsmStateAction + { + [Tooltip("The GameObject that owns the component.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [RequiredField] + [Tooltip("Store the component in an Object variable.\nNOTE: Set theObject variable's Object Type to get a component of that type. E.g., set Object Type to UnityEngine.AudioListener to get the AudioListener component on the camera.")] + public FsmObject storeComponent; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + storeComponent = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetComponent(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetComponent(); + } + + void DoGetComponent() + { + if (storeComponent == null) + { + return; + } + + var targetObject = Fsm.GetOwnerDefaultTarget(gameObject); + + if (targetObject == null) + { + return; + } + + if (storeComponent.IsNone) + { + return; + } + + storeComponent.Value = targetObject.GetComponent(storeComponent.ObjectType); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetComponent.cs.meta b/Assets/PlayMaker/Actions/GetComponent.cs.meta new file mode 100755 index 0000000..1c4ea09 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a2adcd42dd6bfa74cad7166cf5410f03 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetControllerCollisionFlags.cs b/Assets/PlayMaker/Actions/GetControllerCollisionFlags.cs new file mode 100755 index 0000000..d6f2659 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetControllerCollisionFlags.cs @@ -0,0 +1,74 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Character)] + [Tooltip("Gets the Collision Flags from a Character Controller on a Game Object. Collision flags give you a broad overview of where the character collided with any other object.")] + public class GetControllerCollisionFlags : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(CharacterController))] + [Tooltip("The GameObject with a Character Controller component.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [Tooltip("True if the Character Controller capsule is on the ground")] + public FsmBool isGrounded; + + [UIHint(UIHint.Variable)] + [Tooltip("True if no collisions in last move.")] + public FsmBool none; + + [UIHint(UIHint.Variable)] + [Tooltip("True if the Character Controller capsule was hit on the sides.")] + public FsmBool sides; + + [UIHint(UIHint.Variable)] + [Tooltip("True if the Character Controller capsule was hit from above.")] + public FsmBool above; + + [UIHint(UIHint.Variable)] + [Tooltip("True if the Character Controller capsule was hit from below.")] + public FsmBool below; + + private GameObject previousGo; // remember so we can get new controller only when it changes. + private CharacterController controller; + + public override void Reset() + { + gameObject = null; + isGrounded = null; + none = null; + sides = null; + above = null; + below = null; + } + + public override void OnUpdate() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (go != previousGo) + { + controller = go.GetComponent(); + previousGo = go; + } + + if (controller != null) + { + isGrounded.Value = controller.isGrounded; + none.Value = (controller.collisionFlags & CollisionFlags.None) != 0; + sides.Value = (controller.collisionFlags & CollisionFlags.Sides) != 0; + above.Value = (controller.collisionFlags & CollisionFlags.Above) != 0; + below.Value = (controller.collisionFlags & CollisionFlags.Below) != 0; + } + + } + } +} diff --git a/Assets/PlayMaker/Actions/GetControllerCollisionFlags.cs.meta b/Assets/PlayMaker/Actions/GetControllerCollisionFlags.cs.meta new file mode 100755 index 0000000..278ef1e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetControllerCollisionFlags.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5fef0e8a9af622c4f962fa8bed423d24 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetControllerHitInfo.cs b/Assets/PlayMaker/Actions/GetControllerHitInfo.cs new file mode 100755 index 0000000..610808f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetControllerHitInfo.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Character)] + [Tooltip("Gets info on the last Character Controller collision and store in variables.")] + public class GetControllerHitInfo : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmGameObject gameObjectHit; + [UIHint(UIHint.Variable)] + public FsmVector3 contactPoint; + [UIHint(UIHint.Variable)] + public FsmVector3 contactNormal; + [UIHint(UIHint.Variable)] + public FsmVector3 moveDirection; + [UIHint(UIHint.Variable)] + public FsmFloat moveLength; + [UIHint(UIHint.Variable)] + [Tooltip("Useful for triggering different effects. Audio, particles...")] + public FsmString physicsMaterialName; + + public override void Reset() + { + gameObjectHit = null; + contactPoint = null; + contactNormal = null; + moveDirection = null; + moveLength = null; + physicsMaterialName = null; + } + + void StoreTriggerInfo() + { + if (Fsm.ControllerCollider == null) return; + + gameObjectHit.Value = Fsm.ControllerCollider.gameObject; + contactPoint.Value = Fsm.ControllerCollider.point; + contactNormal.Value = Fsm.ControllerCollider.normal; + moveDirection.Value = Fsm.ControllerCollider.moveDirection; + moveLength.Value = Fsm.ControllerCollider.moveLength; + physicsMaterialName.Value = Fsm.ControllerCollider.collider.material.name; + } + + public override void OnEnter() + { + StoreTriggerInfo(); + + Finish(); + } + + public override string ErrorCheck() + { + return ActionHelpers.CheckOwnerPhysicsSetup(Owner); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetControllerHitInfo.cs.meta b/Assets/PlayMaker/Actions/GetControllerHitInfo.cs.meta new file mode 100755 index 0000000..e70f347 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetControllerHitInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4df4faf7dc9040d44bb6f8ef649c9111 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetDeviceAcceleration.cs b/Assets/PlayMaker/Actions/GetDeviceAcceleration.cs new file mode 100755 index 0000000..cececc2 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetDeviceAcceleration.cs @@ -0,0 +1,92 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Gets the last measured linear acceleration of a device and stores it in a Vector3 Variable.")] + public class GetDeviceAcceleration : FsmStateAction + { + // TODO: Figure out some nice mapping options for common use cases. +/* public enum MappingOptions + { + Flat, + Vertical + } + + [Tooltip("Flat is god for marble rolling games, vertical is good for Doodle Jump type games.")] + public MappingOptions mappingOptions; +*/ + + [UIHint(UIHint.Variable)] + public FsmVector3 storeVector; + [UIHint(UIHint.Variable)] + public FsmFloat storeX; + [UIHint(UIHint.Variable)] + public FsmFloat storeY; + [UIHint(UIHint.Variable)] + public FsmFloat storeZ; + public FsmFloat multiplier; + public bool everyFrame; + + public override void Reset() + { + storeVector = null; + storeX = null; + storeY = null; + storeZ = null; + multiplier = 1; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetDeviceAcceleration(); + + if (!everyFrame) + Finish(); + } + + + public override void OnUpdate() + { + DoGetDeviceAcceleration(); + } + + void DoGetDeviceAcceleration() + { +/* var dir = Vector3.zero; + + switch (mappingOptions) + { + case MappingOptions.Flat: + + dir.x = Input.acceleration.x; + dir.y = Input.acceleration.z; + dir.z = Input.acceleration.y; + break; + + + case MappingOptions.Vertical: + dir.x = Input.acceleration.x; + dir.y = Input.acceleration.y; + dir.z = Input.acceleration.x; + break; + } +*/ + var dir = new Vector3(Input.acceleration.x, Input.acceleration.y, Input.acceleration.z); + + if (!multiplier.IsNone) + { + dir *= multiplier.Value; + } + + storeVector.Value = dir; + storeX.Value = dir.x; + storeY.Value = dir.y; + storeZ.Value = dir.z; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetDeviceAcceleration.cs.meta b/Assets/PlayMaker/Actions/GetDeviceAcceleration.cs.meta new file mode 100755 index 0000000..d171a7f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetDeviceAcceleration.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c9dcc17af4114204f800d38a9aaf19ac +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetDeviceRoll.cs b/Assets/PlayMaker/Actions/GetDeviceRoll.cs new file mode 100755 index 0000000..87aac48 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetDeviceRoll.cs @@ -0,0 +1,86 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Gets the rotation of the device around its z axis (into the screen). For example when you steer with the iPhone in a driving game.")] + public class GetDeviceRoll : FsmStateAction + { + public enum BaseOrientation + { + Portrait, + LandscapeLeft, + LandscapeRight + } + + [Tooltip("How the user is expected to hold the device (where angle will be zero).")] + public BaseOrientation baseOrientation; + [UIHint(UIHint.Variable)] + public FsmFloat storeAngle; + public FsmFloat limitAngle; + public FsmFloat smoothing; + public bool everyFrame; + + private float lastZAngle; + + public override void Reset() + { + baseOrientation = BaseOrientation.LandscapeLeft; + storeAngle = null; + limitAngle = new FsmFloat { UseVariable = true }; + smoothing = 5f; + everyFrame = true; + } + + public override void OnEnter() + { + DoGetDeviceRoll(); + + if (!everyFrame) + Finish(); + } + + + public override void OnUpdate() + { + DoGetDeviceRoll(); + } + + void DoGetDeviceRoll() + { + float x = Input.acceleration.x; + float y = Input.acceleration.y; + float zAngle = 0; + + switch (baseOrientation) + { + case BaseOrientation.Portrait: + zAngle = -Mathf.Atan2(x, -y); + break; + case BaseOrientation.LandscapeLeft: + zAngle = Mathf.Atan2(y, -x); + break; + case BaseOrientation.LandscapeRight: + zAngle = -Mathf.Atan2(y, x); + break; + } + + if (!limitAngle.IsNone) + { + zAngle = Mathf.Clamp(Mathf.Rad2Deg * zAngle, -limitAngle.Value, limitAngle.Value); + } + + if (smoothing.Value > 0) + { + zAngle = Mathf.LerpAngle(lastZAngle, zAngle, smoothing.Value * Time.deltaTime); + } + + lastZAngle = zAngle; + + storeAngle.Value = zAngle; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetDeviceRoll.cs.meta b/Assets/PlayMaker/Actions/GetDeviceRoll.cs.meta new file mode 100755 index 0000000..c0cbb3a --- /dev/null +++ b/Assets/PlayMaker/Actions/GetDeviceRoll.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 92027fbdffd3cea4ca2ceb09a13add18 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetDistance.cs b/Assets/PlayMaker/Actions/GetDistance.cs new file mode 100755 index 0000000..46c7af9 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetDistance.cs @@ -0,0 +1,61 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Measures the Distance betweens 2 Game Objects and stores the result in a Float Variable.")] + public class GetDistance : FsmStateAction + { + [RequiredField] + [Tooltip("Measure distance from this GameObject.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("Target GameObject.")] + public FsmGameObject target; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the distance in a float variable.")] + public FsmFloat storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + target = null; + storeResult = null; + everyFrame = true; + } + + public override void OnEnter() + { + DoGetDistance(); + + if (!everyFrame) + { + Finish(); + } + } + public override void OnUpdate() + { + DoGetDistance(); + } + + void DoGetDistance() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null || target.Value == null || storeResult == null) + { + return; + } + + storeResult.Value = Vector3.Distance(go.transform.position, target.Value.transform.position); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetDistance.cs.meta b/Assets/PlayMaker/Actions/GetDistance.cs.meta new file mode 100755 index 0000000..fdfe83e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetDistance.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 428f92bb9c2f69b43a99266fa4930745 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetEventInfo.cs b/Assets/PlayMaker/Actions/GetEventInfo.cs new file mode 100755 index 0000000..851be3c --- /dev/null +++ b/Assets/PlayMaker/Actions/GetEventInfo.cs @@ -0,0 +1,91 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Gets info on the last event that caused a state change. See also Set Event Data action.")] + public class GetEventInfo : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmGameObject sentByGameObject; + [UIHint(UIHint.Variable)] + public FsmString fsmName; + [UIHint(UIHint.Variable)] + public FsmBool getBoolData; + [UIHint(UIHint.Variable)] + public FsmInt getIntData; + [UIHint(UIHint.Variable)] + public FsmFloat getFloatData; + [UIHint(UIHint.Variable)] + public FsmVector2 getVector2Data; + [UIHint(UIHint.Variable)] + public FsmVector3 getVector3Data; + [UIHint(UIHint.Variable)] + public FsmString getStringData; + [UIHint(UIHint.Variable)] + public FsmGameObject getGameObjectData; + [UIHint(UIHint.Variable)] + public FsmRect getRectData; + [UIHint(UIHint.Variable)] + public FsmQuaternion getQuaternionData; + [UIHint(UIHint.Variable)] + public FsmMaterial getMaterialData; + [UIHint(UIHint.Variable)] + public FsmTexture getTextureData; + [UIHint(UIHint.Variable)] + public FsmColor getColorData; + [UIHint(UIHint.Variable)] + public FsmObject getObjectData; + + public override void Reset() + { + sentByGameObject = null; + fsmName = null; + getBoolData = null; + getIntData = null; + getFloatData = null; + getVector2Data = null; + getVector3Data = null; + getStringData = null; + getGameObjectData = null; + getRectData = null; + getQuaternionData = null; + getMaterialData = null; + getTextureData = null; + getColorData = null; + getObjectData = null; + } + + public override void OnEnter() + { + if (Fsm.EventData.SentByFsm != null) + { + sentByGameObject.Value = Fsm.EventData.SentByFsm.GameObject; + fsmName.Value = Fsm.EventData.SentByFsm.Name; + } + else + { + sentByGameObject.Value = null; + fsmName.Value = ""; + } + + getBoolData.Value = Fsm.EventData.BoolData; + getIntData.Value = Fsm.EventData.IntData; + getFloatData.Value = Fsm.EventData.FloatData; + getVector2Data.Value = Fsm.EventData.Vector2Data; + getVector3Data.Value = Fsm.EventData.Vector3Data; + getStringData.Value = Fsm.EventData.StringData; + getGameObjectData.Value = Fsm.EventData.GameObjectData; + getRectData.Value = Fsm.EventData.RectData; + getQuaternionData.Value = Fsm.EventData.QuaternionData; + getMaterialData.Value = Fsm.EventData.MaterialData; + getTextureData.Value = Fsm.EventData.TextureData; + getColorData.Value = Fsm.EventData.ColorData; + getObjectData.Value = Fsm.EventData.ObjectData; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetEventInfo.cs.meta b/Assets/PlayMaker/Actions/GetEventInfo.cs.meta new file mode 100755 index 0000000..5a8004d --- /dev/null +++ b/Assets/PlayMaker/Actions/GetEventInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bdeeb47490bb9e94ca4fcbe9b6be9a75 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmBool.cs b/Assets/PlayMaker/Actions/GetFsmBool.cs new file mode 100755 index 0000000..b6c5b86 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmBool.cs @@ -0,0 +1,72 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Bool Variable from another FSM.")] + public class GetFsmBool : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmBool)] + public FsmString variableName; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmBool storeValue; + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmBool(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetFsmBool(); + } + + void DoGetFsmBool() + { + if (storeValue == null) return; + + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) return; + + FsmBool fsmBool = fsm.FsmVariables.GetFsmBool(variableName.Value); + + if (fsmBool == null) return; + + storeValue.Value = fsmBool.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmBool.cs.meta b/Assets/PlayMaker/Actions/GetFsmBool.cs.meta new file mode 100755 index 0000000..8e9503e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmBool.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd9621abe3cb4f14a975ab66a1d89703 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmColor.cs b/Assets/PlayMaker/Actions/GetFsmColor.cs new file mode 100755 index 0000000..859efd1 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmColor.cs @@ -0,0 +1,72 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Color Variable from another FSM.")] + public class GetFsmColor : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmColor)] + public FsmString variableName; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmColor storeValue; + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmColor(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetFsmColor(); + } + + void DoGetFsmColor() + { + if (storeValue == null) return; + + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) return; + + FsmColor fsmColor = fsm.FsmVariables.GetFsmColor(variableName.Value); + + if (fsmColor == null) return; + + storeValue.Value = fsmColor.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmColor.cs.meta b/Assets/PlayMaker/Actions/GetFsmColor.cs.meta new file mode 100755 index 0000000..c2a6ecc --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1dce27cb44453b74380717775cbf4bcf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmEnum.cs b/Assets/PlayMaker/Actions/GetFsmEnum.cs new file mode 100755 index 0000000..b9da8e3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmEnum.cs @@ -0,0 +1,79 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of an Enum Variable from another FSM.")] + public class GetFsmEnum : FsmStateAction + { + [RequiredField] + [Tooltip("The target FSM")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmBool)] + public FsmString variableName; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmEnum storeValue; + + [Tooltip("Repeat every frame")] + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmEnum(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmEnum(); + } + + void DoGetFsmEnum() + { + if (storeValue == null) return; + + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) return; + + var fsmEnum = fsm.FsmVariables.GetFsmEnum(variableName.Value); + if (fsmEnum == null) return; + + storeValue.Value = fsmEnum.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmEnum.cs.meta b/Assets/PlayMaker/Actions/GetFsmEnum.cs.meta new file mode 100755 index 0000000..4b98790 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmEnum.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c87a739e8b72e6e4e99aa78a2427fd03 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmFloat.cs b/Assets/PlayMaker/Actions/GetFsmFloat.cs new file mode 100755 index 0000000..ad6af26 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmFloat.cs @@ -0,0 +1,72 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Float Variable from another FSM.")] + public class GetFsmFloat : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmFloat)] + public FsmString variableName; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeValue; + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmFloat(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetFsmFloat(); + } + + void DoGetFsmFloat() + { + if (storeValue.IsNone) return; + + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + goLastFrame = go; + } + + if (fsm == null) return; + + FsmFloat fsmFloat = fsm.FsmVariables.GetFsmFloat(variableName.Value); + + if (fsmFloat == null) return; + + storeValue.Value = fsmFloat.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmFloat.cs.meta b/Assets/PlayMaker/Actions/GetFsmFloat.cs.meta new file mode 100755 index 0000000..98f86d5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0e5e91cfed7b66c44b7f5bde1f59fe30 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmGameObject.cs b/Assets/PlayMaker/Actions/GetFsmGameObject.cs new file mode 100755 index 0000000..aa1a214 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmGameObject.cs @@ -0,0 +1,74 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Game Object Variable from another FSM.")] + public class GetFsmGameObject : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmGameObject)] + public FsmString variableName; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmGameObject storeValue; + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmGameObject(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetFsmGameObject(); + } + + void DoGetFsmGameObject() + { + if (storeValue == null) return; + + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) return; + + FsmGameObject fsmGameObject = fsm.FsmVariables.GetFsmGameObject(variableName.Value); + + if (fsmGameObject == null) return; + + storeValue.Value = fsmGameObject.Value; + } + + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmGameObject.cs.meta b/Assets/PlayMaker/Actions/GetFsmGameObject.cs.meta new file mode 100755 index 0000000..4134156 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 97e6a2e52290e6b4f93900fe4ad21449 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmInt.cs b/Assets/PlayMaker/Actions/GetFsmInt.cs new file mode 100755 index 0000000..45edff0 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmInt.cs @@ -0,0 +1,72 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of an Integer Variable from another FSM.")] + public class GetFsmInt : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmInt)] + public FsmString variableName; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt storeValue; + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmInt(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetFsmInt(); + } + + void DoGetFsmInt() + { + if (storeValue == null) return; + + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) return; + + FsmInt fsmInt = fsm.FsmVariables.GetFsmInt(variableName.Value); + + if (fsmInt == null) return; + + storeValue.Value = fsmInt.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmInt.cs.meta b/Assets/PlayMaker/Actions/GetFsmInt.cs.meta new file mode 100755 index 0000000..90b1579 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmInt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2d9f76bd8ba211b488b98b673121384c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmMaterial.cs b/Assets/PlayMaker/Actions/GetFsmMaterial.cs new file mode 100755 index 0000000..4ee9a4f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmMaterial.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Material Variable from another FSM.")] + public class GetFsmMaterial : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmMaterial)] + public FsmString variableName; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmMaterial storeValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + GameObject goLastFrame; + protected PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + storeValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetFsmVariable(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmVariable(); + } + + void DoGetFsmVariable() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null || storeValue == null) + { + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmMaterial(variableName.Value); + + if (fsmVar != null) + { + storeValue.Value = fsmVar.Value; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmMaterial.cs.meta b/Assets/PlayMaker/Actions/GetFsmMaterial.cs.meta new file mode 100755 index 0000000..f2755a6 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmMaterial.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6b1ca2bc76bd8cc48bc89bd3b995d3a9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmObject.cs b/Assets/PlayMaker/Actions/GetFsmObject.cs new file mode 100755 index 0000000..e65e729 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmObject.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of an Object Variable from another FSM.")] + public class GetFsmObject : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmObject)] + public FsmString variableName; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmObject storeValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + GameObject goLastFrame; + protected PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + storeValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetFsmVariable(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmVariable(); + } + + void DoGetFsmVariable() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null || storeValue == null) + { + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmObject(variableName.Value); + + if (fsmVar != null) + { + storeValue.Value = fsmVar.Value; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmObject.cs.meta b/Assets/PlayMaker/Actions/GetFsmObject.cs.meta new file mode 100755 index 0000000..fb72def --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0cbb971dcad5dfe41ba207cf8ddf10e8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmQuaternion.cs b/Assets/PlayMaker/Actions/GetFsmQuaternion.cs new file mode 100755 index 0000000..6522b1c --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmQuaternion.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Quaternion Variable from another FSM.")] + public class GetFsmQuaternion : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmQuaternion)] + public FsmString variableName; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmQuaternion storeValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + GameObject goLastFrame; + protected PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + storeValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetFsmVariable(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmVariable(); + } + + void DoGetFsmVariable() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null || storeValue == null) + { + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmQuaternion(variableName.Value); + + if (fsmVar != null) + { + storeValue.Value = fsmVar.Value; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmQuaternion.cs.meta b/Assets/PlayMaker/Actions/GetFsmQuaternion.cs.meta new file mode 100755 index 0000000..bb3b2c9 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmQuaternion.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d079cd4867c36e54faf57b52c0c7e4ee +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmRect.cs b/Assets/PlayMaker/Actions/GetFsmRect.cs new file mode 100755 index 0000000..2474d11 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmRect.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Rect Variable from another FSM.")] + public class GetFsmRect : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmRect)] + public FsmString variableName; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmRect storeValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + GameObject goLastFrame; + protected PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + storeValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetFsmVariable(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmVariable(); + } + + void DoGetFsmVariable() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null || storeValue == null) + { + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmRect(variableName.Value); + + if (fsmVar != null) + { + storeValue.Value = fsmVar.Value; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmRect.cs.meta b/Assets/PlayMaker/Actions/GetFsmRect.cs.meta new file mode 100755 index 0000000..e7ed119 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmRect.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 10a898a9e2d37ee469ec06b5db381052 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmState.cs b/Assets/PlayMaker/Actions/GetFsmState.cs new file mode 100755 index 0000000..22aa19f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmState.cs @@ -0,0 +1,83 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Gets the name of the specified FSMs current state. Either reference the fsm component directly, or find it on a game object.")] + public class GetFsmState : FsmStateAction + { + [Tooltip("Drag a PlayMakerFSM component here.")] + public PlayMakerFSM fsmComponent; + + [Tooltip("If not specifyng the component above, specify the GameObject that owns the FSM")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of Fsm on Game Object. If left blank it will find the first PlayMakerFSM on the GameObject.")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the state name in a string variable.")] + public FsmString storeResult; + + [Tooltip("Repeat every frame. E.g., useful if you're waiting for the state to change.")] + public bool everyFrame; + + private PlayMakerFSM fsm; + + public override void Reset() + { + fsmComponent = null; + gameObject = null; + fsmName = ""; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetFsmState(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmState(); + } + + void DoGetFsmState() + { + if (fsm == null) + { + if (fsmComponent != null) + { + fsm = fsmComponent; + } + else + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go != null) + { + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + } + + if (fsm == null) + { + storeResult.Value = ""; + return; + } + } + + storeResult.Value = fsm.ActiveStateName; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmState.cs.meta b/Assets/PlayMaker/Actions/GetFsmState.cs.meta new file mode 100755 index 0000000..2930cea --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmState.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fd5aac683074ad74dbc7b5f19fe2ee26 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmString.cs b/Assets/PlayMaker/Actions/GetFsmString.cs new file mode 100755 index 0000000..aa2dad2 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmString.cs @@ -0,0 +1,72 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a String Variable from another FSM.")] + public class GetFsmString : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmString)] + public FsmString variableName; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString storeValue; + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmString(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetFsmString(); + } + + void DoGetFsmString() + { + if (storeValue == null) return; + + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) return; + + FsmString fsmString = fsm.FsmVariables.GetFsmString(variableName.Value); + + if (fsmString == null) return; + + storeValue.Value = fsmString.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmString.cs.meta b/Assets/PlayMaker/Actions/GetFsmString.cs.meta new file mode 100755 index 0000000..379380a --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fdd74848050c6b44eab573991ac7e31d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmTexture.cs b/Assets/PlayMaker/Actions/GetFsmTexture.cs new file mode 100755 index 0000000..bcbf297 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmTexture.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Texture Variable from another FSM.")] + public class GetFsmTexture : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmTexture)] + public FsmString variableName; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmTexture storeValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + GameObject goLastFrame; + protected PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + storeValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetFsmVariable(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmVariable(); + } + + void DoGetFsmVariable() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null || storeValue == null) + { + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmTexture(variableName.Value); + + if (fsmVar != null) + { + storeValue.Value = fsmVar.Value; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmTexture.cs.meta b/Assets/PlayMaker/Actions/GetFsmTexture.cs.meta new file mode 100755 index 0000000..b3be188 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a8b2a265ff450ee418db802c965b15a8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmVariable.cs b/Assets/PlayMaker/Actions/GetFsmVariable.cs new file mode 100755 index 0000000..6dc40be --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmVariable.cs @@ -0,0 +1,99 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a variable in another FSM and store it in a variable of the same name in this FSM.")] + public class GetFsmVariable : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [HideTypeFilter] + [UIHint(UIHint.Variable)] + public FsmVar storeValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + private GameObject cachedGO; + private PlayMakerFSM sourceFsm; + private INamedVariable sourceVariable; + private NamedVariable targetVariable; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = new FsmVar(); + } + + public override void OnEnter() + { + InitFsmVar(); + + DoGetFsmVariable(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmVariable(); + } + + void InitFsmVar() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (go != cachedGO) + { + sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + sourceVariable = sourceFsm.FsmVariables.GetVariable(storeValue.variableName); + targetVariable = Fsm.Variables.GetVariable(storeValue.variableName); + storeValue.Type = targetVariable.VariableType; + + if (!string.IsNullOrEmpty(storeValue.variableName) && sourceVariable == null) + { + LogWarning("Missing Variable: " + storeValue.variableName); + } + + cachedGO = go; + } + } + + void DoGetFsmVariable() + { + if (storeValue.IsNone) + { + return; + } + + InitFsmVar(); + storeValue.GetValueFrom(sourceVariable); + storeValue.ApplyValueTo(targetVariable); + } + +#if UNITY_EDITOR + public override string AutoName() + { + return ("Get FSM Variable: " + ActionHelpers.GetValueLabel(storeValue.NamedVar)); + } +#endif + } +} diff --git a/Assets/PlayMaker/Actions/GetFsmVariable.cs.meta b/Assets/PlayMaker/Actions/GetFsmVariable.cs.meta new file mode 100755 index 0000000..a585d94 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmVariable.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 36fdfdb437289ec489dd5b1133deec80 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmVariables.cs b/Assets/PlayMaker/Actions/GetFsmVariables.cs new file mode 100755 index 0000000..f82bc41 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmVariables.cs @@ -0,0 +1,98 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the values of multiple variables in another FSM and store in variables of the same name in this FSM.")] + public class GetFsmVariables : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [HideTypeFilter] + [UIHint(UIHint.Variable)] + public FsmVar[] getVariables; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + private GameObject cachedGO; + private PlayMakerFSM sourceFsm; + private INamedVariable[] sourceVariables; + private NamedVariable[] targetVariables; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + getVariables = null; + } + + void InitFsmVars() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (go != cachedGO) + { + sourceVariables = new INamedVariable[getVariables.Length]; + targetVariables = new NamedVariable[getVariables.Length]; + + for (var i = 0; i < getVariables.Length; i++) + { + var variableName = getVariables[i].variableName; + sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + sourceVariables[i] = sourceFsm.FsmVariables.GetVariable(variableName); + targetVariables[i] = Fsm.Variables.GetVariable(variableName); + getVariables[i].Type = targetVariables[i].VariableType; + + if (!string.IsNullOrEmpty(variableName) && sourceVariables[i] == null) + { + LogWarning("Missing Variable: " + variableName); + } + + cachedGO = go; + } + } + } + + public override void OnEnter() + { + InitFsmVars(); + + DoGetFsmVariables(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetFsmVariables(); + } + + void DoGetFsmVariables() + { + InitFsmVars(); + + for (var i = 0; i < getVariables.Length; i++) + { + getVariables[i].GetValueFrom(sourceVariables[i]); + getVariables[i].ApplyValueTo(targetVariables[i]); + } + } + } +} diff --git a/Assets/PlayMaker/Actions/GetFsmVariables.cs.meta b/Assets/PlayMaker/Actions/GetFsmVariables.cs.meta new file mode 100755 index 0000000..391709d --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmVariables.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46663c0db282f7045807d75af544b7f6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmVector2.cs b/Assets/PlayMaker/Actions/GetFsmVector2.cs new file mode 100755 index 0000000..8b440da --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmVector2.cs @@ -0,0 +1,85 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Vector2 Variable from another FSM.")] + public class GetFsmVector2 : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmVector2)] + public FsmString variableName; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector2 storeValue; + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmVector2(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetFsmVector2(); + } + + void DoGetFsmVector2() + { + if (storeValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + + if (go == null) + { + return; + } + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + return; + } + + var fsmVector2 = fsm.FsmVariables.GetFsmVector2(variableName.Value); + + if (fsmVector2 == null) + { + return; + } + + storeValue.Value = fsmVector2.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmVector2.cs.meta b/Assets/PlayMaker/Actions/GetFsmVector2.cs.meta new file mode 100755 index 0000000..9677264 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmVector2.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a755290c09b78ed44bd915310300b42c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetFsmVector3.cs b/Assets/PlayMaker/Actions/GetFsmVector3.cs new file mode 100755 index 0000000..6fd9764 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmVector3.cs @@ -0,0 +1,72 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Get the value of a Vector3 Variable from another FSM.")] + public class GetFsmVector3 : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmVector3)] + public FsmString variableName; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 storeValue; + public bool everyFrame; + + GameObject goLastFrame; + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + storeValue = null; + } + + public override void OnEnter() + { + DoGetFsmVector3(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetFsmVector3(); + } + + void DoGetFsmVector3() + { + if (storeValue == null) return; + + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // only get the fsm component if go has changed + + if (go != goLastFrame) + { + goLastFrame = go; + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) return; + + FsmVector3 fsmVector3 = fsm.FsmVariables.GetFsmVector3(variableName.Value); + + if (fsmVector3 == null) return; + + storeValue.Value = fsmVector3.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetFsmVector3.cs.meta b/Assets/PlayMaker/Actions/GetFsmVector3.cs.meta new file mode 100755 index 0000000..486c6a4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetFsmVector3.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46c8c8bb1397d144d9adb770445ab086 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetIPhoneSettings.cs b/Assets/PlayMaker/Actions/GetIPhoneSettings.cs new file mode 100755 index 0000000..d1822ee --- /dev/null +++ b/Assets/PlayMaker/Actions/GetIPhoneSettings.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Get various iPhone settings.")] + public class GetIPhoneSettings : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("Allows device to fall into 'sleep' state with screen being dim if no touches occurred. Default value is true.")] + public FsmBool getScreenCanDarken; + + [UIHint(UIHint.Variable)] + [Tooltip("A unique device identifier string. It is guaranteed to be unique for every device (Read Only).")] + public FsmString getUniqueIdentifier; + + [UIHint(UIHint.Variable)] + [Tooltip("The user defined name of the device (Read Only).")] + public FsmString getName; + + [UIHint(UIHint.Variable)] + [Tooltip("The model of the device (Read Only).")] + public FsmString getModel; + + [UIHint(UIHint.Variable)] + [Tooltip("The name of the operating system running on the device (Read Only).")] + public FsmString getSystemName; + + [UIHint(UIHint.Variable)] + [Tooltip("The generation of the device (Read Only).")] + public FsmString getGeneration; + + public override void Reset() + { + getScreenCanDarken = null; + getUniqueIdentifier = null; + getName = null; + getModel = null; + getSystemName = null; + getGeneration = null; + } + + public override void OnEnter() + { +#if UNITY_IPHONE + + getScreenCanDarken.Value = Screen.sleepTimeout > 0f; //iPhoneSettings.screenCanDarken; + getUniqueIdentifier.Value = SystemInfo.deviceUniqueIdentifier; //iPhoneSettings.uniqueIdentifier; + getName.Value = SystemInfo.deviceName; //iPhoneSettings.name; + getModel.Value = SystemInfo.deviceModel; //iPhoneSettings.model; + getSystemName.Value = SystemInfo.operatingSystem; //iPhoneSettings.systemName; +#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6 + getGeneration.Value = iPhone.generation.ToString(); +#else + getGeneration.Value = UnityEngine.iOS.Device.generation.ToString(); +#endif +#endif + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetIPhoneSettings.cs.meta b/Assets/PlayMaker/Actions/GetIPhoneSettings.cs.meta new file mode 100755 index 0000000..eb79555 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetIPhoneSettings.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 75228a05fe3d0d04080e899b8b2704ad +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetKey.cs b/Assets/PlayMaker/Actions/GetKey.cs new file mode 100755 index 0000000..70f9511 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetKey.cs @@ -0,0 +1,52 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Gets the pressed state of a Key.")] + public class GetKey : FsmStateAction + { + [RequiredField] + [Tooltip("The key to test.")] + public KeyCode key; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store if the key is down (True) or up (False).")] + public FsmBool storeResult; + + [Tooltip("Repeat every frame. Useful if you're waiting for a key press/release.")] + public bool everyFrame; + + public override void Reset() + { + key = KeyCode.None; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetKey(); + + if (!everyFrame) + { + Finish(); + } + } + + + public override void OnUpdate() + { + DoGetKey(); + } + + void DoGetKey() + { + storeResult.Value = Input.GetKey(key); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetKey.cs.meta b/Assets/PlayMaker/Actions/GetKey.cs.meta new file mode 100755 index 0000000..6299d1e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetKey.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 09e09d95b123250499060078cf57b480 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetKeyDown.cs b/Assets/PlayMaker/Actions/GetKeyDown.cs new file mode 100755 index 0000000..b9a2bb7 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetKeyDown.cs @@ -0,0 +1,34 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends an Event when a Key is pressed.")] + public class GetKeyDown : FsmStateAction + { + [RequiredField] + public KeyCode key; + public FsmEvent sendEvent; + [UIHint(UIHint.Variable)] + public FsmBool storeResult; + + public override void Reset() + { + sendEvent = null; + key = KeyCode.None; + storeResult = null; + } + + public override void OnUpdate() + { + bool keyDown = Input.GetKeyDown(key); + + if (keyDown) + Fsm.Event(sendEvent); + + storeResult.Value = keyDown; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetKeyDown.cs.meta b/Assets/PlayMaker/Actions/GetKeyDown.cs.meta new file mode 100755 index 0000000..7d430e8 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetKeyDown.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dc977968122a76d48b8ab23de94e7018 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetKeyUp.cs b/Assets/PlayMaker/Actions/GetKeyUp.cs new file mode 100755 index 0000000..f8f3bb3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetKeyUp.cs @@ -0,0 +1,34 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends an Event when a Key is released.")] + public class GetKeyUp : FsmStateAction + { + [RequiredField] + public KeyCode key; + public FsmEvent sendEvent; + [UIHint(UIHint.Variable)] + public FsmBool storeResult; + + public override void Reset() + { + sendEvent = null; + key = KeyCode.None; + storeResult = null; + } + + public override void OnUpdate() + { + bool keyUp = Input.GetKeyUp(key); + + if (keyUp) + Fsm.Event(sendEvent); + + storeResult.Value = keyUp; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetKeyUp.cs.meta b/Assets/PlayMaker/Actions/GetKeyUp.cs.meta new file mode 100755 index 0000000..5d6a155 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetKeyUp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b6f54ffcea7679849b1fc474dab578c7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetLastEvent.cs b/Assets/PlayMaker/Actions/GetLastEvent.cs new file mode 100755 index 0000000..0186ea9 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetLastEvent.cs @@ -0,0 +1,26 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Gets the event that caused the transition to the current state, and stores it in a String Variable.")] + public class GetLastEvent : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmString storeEvent; + + public override void Reset() + { + storeEvent = null; + } + + public override void OnEnter() + { + storeEvent.Value = Fsm.LastTransition == null ? "START" : Fsm.LastTransition.EventName; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetLastEvent.cs.meta b/Assets/PlayMaker/Actions/GetLastEvent.cs.meta new file mode 100755 index 0000000..54949cd --- /dev/null +++ b/Assets/PlayMaker/Actions/GetLastEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7f812896d24109f44959a5f3cb41bb5f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetLayer.cs b/Assets/PlayMaker/Actions/GetLayer.cs new file mode 100755 index 0000000..0ae2286 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetLayer.cs @@ -0,0 +1,45 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets a Game Object's Layer and stores it in an Int Variable.")] + public class GetLayer : FsmStateAction + { + [RequiredField] + public FsmGameObject gameObject; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt storeResult; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetLayer(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetLayer(); + } + + void DoGetLayer() + { + if (gameObject.Value == null) return; + + storeResult.Value = gameObject.Value.layer; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetLayer.cs.meta b/Assets/PlayMaker/Actions/GetLayer.cs.meta new file mode 100755 index 0000000..72fd769 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetLayer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 130ab1592e3e4084ba6076940d13d2cd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetLocationInfo.cs b/Assets/PlayMaker/Actions/GetLocationInfo.cs new file mode 100755 index 0000000..8a0191b --- /dev/null +++ b/Assets/PlayMaker/Actions/GetLocationInfo.cs @@ -0,0 +1,75 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Gets Location Info from a mobile device. NOTE: Use StartLocationService before trying to get location info.")] + public class GetLocationInfo : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmVector3 vectorPosition; + [UIHint(UIHint.Variable)] + public FsmFloat longitude; + [UIHint(UIHint.Variable)] + public FsmFloat latitude; + [UIHint(UIHint.Variable)] + public FsmFloat altitude; + [UIHint(UIHint.Variable)] + public FsmFloat horizontalAccuracy; + [UIHint(UIHint.Variable)] + public FsmFloat verticalAccuracy; + // TODO: figure out useful way to expose timeStamp + // maybe how old is the location...? + //[UIHint(UIHint.Variable)] + //[Tooltip("Timestamp (in seconds since the game started) when location was last updated.")] + //public FsmFloat timeStamp; + [Tooltip("Event to send if the location cannot be queried.")] + public FsmEvent errorEvent; + + public override void Reset() + { + longitude = null; + latitude = null; + altitude = null; + horizontalAccuracy = null; + verticalAccuracy = null; + //timeStamp = null; + errorEvent = null; + } + + public override void OnEnter() + { + DoGetLocationInfo(); + + Finish(); + } + + void DoGetLocationInfo() + { +#if UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WP8 + + if (Input.location.status != LocationServiceStatus.Running) + { + Fsm.Event(errorEvent); + return; + } + + float x = Input.location.lastData.longitude; + float y = Input.location.lastData.latitude; + float z = Input.location.lastData.altitude; + + vectorPosition.Value = new Vector3(x,y,z); + + longitude.Value = x; + latitude.Value = y; + altitude.Value = z; + + horizontalAccuracy.Value = Input.location.lastData.horizontalAccuracy; + verticalAccuracy.Value = Input.location.lastData.verticalAccuracy; + +#endif + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetLocationInfo.cs.meta b/Assets/PlayMaker/Actions/GetLocationInfo.cs.meta new file mode 100755 index 0000000..8209c47 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetLocationInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 083716b1d12bae54db4cfe69d822cccf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMainCamera.cs b/Assets/PlayMaker/Actions/GetMainCamera.cs new file mode 100755 index 0000000..82a0993 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMainCamera.cs @@ -0,0 +1,29 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// Thanks to James Murchison for the original version of this script. + +using UnityEngine; +using HutongGames.PlayMaker; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Gets the camera tagged MainCamera from the scene")] + public class GetMainCamera : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmGameObject storeGameObject; + + public override void Reset () + { + storeGameObject = null; + } + + public override void OnEnter () + { + storeGameObject.Value = Camera.main != null ? Camera.main.gameObject : null; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetMainCamera.cs.meta b/Assets/PlayMaker/Actions/GetMainCamera.cs.meta new file mode 100755 index 0000000..c0dcb25 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMainCamera.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c85da2b6adfa49441ad3f64fb7ecbc3b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMass.cs b/Assets/PlayMaker/Actions/GetMass.cs new file mode 100755 index 0000000..b8e8321 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMass.cs @@ -0,0 +1,43 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Gets the Mass of a Game Object's Rigid Body.")] + public class GetMass : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + [Tooltip("The GameObject that owns the Rigidbody")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the mass in a float variable.")] + public FsmFloat storeResult; + + public override void Reset() + { + gameObject = null; + storeResult = null; + } + + public override void OnEnter() + { + DoGetMass(); + + Finish(); + } + + void DoGetMass() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + storeResult.Value = rigidbody.mass; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetMass.cs.meta b/Assets/PlayMaker/Actions/GetMass.cs.meta new file mode 100755 index 0000000..c6ffa2f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ffabb4161e65b10469326724e680a136 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMaterial.cs b/Assets/PlayMaker/Actions/GetMaterial.cs new file mode 100755 index 0000000..d5ea214 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMaterial.cs @@ -0,0 +1,76 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// Thanks to: Giyomu +// http://hutonggames.com/playmakerforum/index.php?topic=400.0 + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Get a material at index on a gameObject and store it in a variable")] + public class GetMaterial : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Renderer))] + [Tooltip("The GameObject the Material is applied to.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The index of the Material in the Materials array.")] + public FsmInt materialIndex; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the material in a variable.")] + public FsmMaterial material; + + [Tooltip("Get the shared material of this object. NOTE: Modifying the shared material will change the appearance of all objects using this material, and change material settings that are stored in the project too.")] + public bool getSharedMaterial; + + public override void Reset() + { + gameObject = null; + material = null; + materialIndex = 0; + getSharedMaterial = false; + } + + public override void OnEnter () + { + DoGetMaterial(); + Finish(); + } + + void DoGetMaterial() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (materialIndex.Value == 0 && !getSharedMaterial) + { + material.Value = renderer.material; + } + + else if(materialIndex.Value == 0 && getSharedMaterial) + { + material.Value = renderer.sharedMaterial; + } + + else if (renderer.materials.Length > materialIndex.Value && !getSharedMaterial) + { + var materials = renderer.materials; + material.Value = materials[materialIndex.Value]; + renderer.materials = materials; + } + + else if (renderer.materials.Length > materialIndex.Value && getSharedMaterial) + { + var materials = renderer.sharedMaterials; + material.Value = materials[materialIndex.Value]; + renderer.sharedMaterials = materials; + } + } + } +} diff --git a/Assets/PlayMaker/Actions/GetMaterial.cs.meta b/Assets/PlayMaker/Actions/GetMaterial.cs.meta new file mode 100755 index 0000000..6a1d779 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMaterial.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 77990142c9a8a824a895f46131a474f7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMaterialTexture.cs b/Assets/PlayMaker/Actions/GetMaterialTexture.cs new file mode 100755 index 0000000..ebe814f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMaterialTexture.cs @@ -0,0 +1,88 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// Thanks to: Giyomu +// http://hutonggames.com/playmakerforum/index.php?topic=401.0 + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Get a texture from a material on a GameObject")] + public class GetMaterialTexture : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Renderer))] + [Tooltip("The GameObject the Material is applied to.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The index of the Material in the Materials array.")] + public FsmInt materialIndex; + + [UIHint(UIHint.NamedTexture)] + [Tooltip("The texture to get. See Unity Shader docs for names.")] + public FsmString namedTexture; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Title("StoreTexture")] // fix parameter name + [Tooltip("Store the texture in a variable.")] + public FsmTexture storedTexture; + + [Tooltip("Get the shared version of the texture.")] + public bool getFromSharedMaterial; + + public override void Reset() + { + gameObject = null; + materialIndex = 0; + namedTexture = "_MainTex"; + storedTexture = null; + getFromSharedMaterial = false; + } + + public override void OnEnter() + { + DoGetMaterialTexture(); + Finish(); + } + + void DoGetMaterialTexture() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + var namedTex = namedTexture.Value; + if (namedTex == "") + { + namedTex = "_MainTex"; + } + + if (materialIndex.Value == 0 && !getFromSharedMaterial) + { + storedTexture.Value = renderer.material.GetTexture(namedTex); + } + + else if (materialIndex.Value == 0 && getFromSharedMaterial) + { + storedTexture.Value = renderer.sharedMaterial.GetTexture(namedTex); + } + + else if (renderer.materials.Length > materialIndex.Value && !getFromSharedMaterial) + { + var materials = renderer.materials; + storedTexture.Value = renderer.materials[materialIndex.Value].GetTexture(namedTex); + renderer.materials = materials; + } + + else if (renderer.materials.Length > materialIndex.Value && getFromSharedMaterial) + { + var materials = renderer.sharedMaterials; + storedTexture.Value = renderer.sharedMaterials[materialIndex.Value].GetTexture(namedTex); + renderer.materials = materials; + } + } + } +} diff --git a/Assets/PlayMaker/Actions/GetMaterialTexture.cs.meta b/Assets/PlayMaker/Actions/GetMaterialTexture.cs.meta new file mode 100755 index 0000000..c38727d --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMaterialTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f52eb48d413c85b46bccfe0d6e75098b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMouseButton.cs b/Assets/PlayMaker/Actions/GetMouseButton.cs new file mode 100755 index 0000000..77d86d2 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseButton.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Gets the pressed state of the specified Mouse Button and stores it in a Bool Variable. See Unity Input Manager doc.")] + public class GetMouseButton : FsmStateAction + { + [RequiredField] + [Tooltip("The mouse button to test.")] + public MouseButton button; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the pressed state in a Bool Variable.")] + public FsmBool storeResult; + + public override void Reset() + { + button = MouseButton.Left; + storeResult = null; + } + + public override void OnEnter() + { + storeResult.Value = Input.GetMouseButton((int)button); + } + + public override void OnUpdate() + { + storeResult.Value = Input.GetMouseButton((int)button); + } + } +} + diff --git a/Assets/PlayMaker/Actions/GetMouseButton.cs.meta b/Assets/PlayMaker/Actions/GetMouseButton.cs.meta new file mode 100755 index 0000000..adc099d --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseButton.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 890d733aad46f3e4c98f7731b61caa97 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMouseButtonDown.cs b/Assets/PlayMaker/Actions/GetMouseButtonDown.cs new file mode 100755 index 0000000..d230172 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseButtonDown.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends an Event when the specified Mouse Button is pressed. Optionally store the button state in a bool variable.")] + public class GetMouseButtonDown : FsmStateAction + { + [RequiredField] + [Tooltip("The mouse button to test.")] + public MouseButton button; + + [Tooltip("Event to send if the mouse button is down.")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the button state in a Bool Variable.")] + public FsmBool storeResult; + + public override void Reset() + { + button = MouseButton.Left; + sendEvent = null; + storeResult = null; + } + + public override void OnEnter() + { + DoGetMouseButtonDown(); + } + + public override void OnUpdate() + { + DoGetMouseButtonDown(); + } + + void DoGetMouseButtonDown() + { + bool buttonDown = Input.GetMouseButtonDown((int)button); + if (buttonDown) + { + Fsm.Event(sendEvent); + } + + storeResult.Value = buttonDown; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetMouseButtonDown.cs.meta b/Assets/PlayMaker/Actions/GetMouseButtonDown.cs.meta new file mode 100755 index 0000000..8d4781d --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseButtonDown.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8fe8065692b58344582d703e5912c698 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMouseButtonUp.cs b/Assets/PlayMaker/Actions/GetMouseButtonUp.cs new file mode 100755 index 0000000..1b3def5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseButtonUp.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends an Event when the specified Mouse Button is released. Optionally store the button state in a bool variable.")] + public class GetMouseButtonUp : FsmStateAction + { + [RequiredField] + [Tooltip("The mouse button to test.")] + public MouseButton button; + + [Tooltip("Event to send if the mouse button is down.")] + public FsmEvent sendEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the pressed state in a Bool Variable.")] + public FsmBool storeResult; + + public override void Reset() + { + button = MouseButton.Left; + sendEvent = null; + storeResult = null; + } + + public override void OnEnter() + { + DoGetMouseButtonUp(); + } + + public override void OnUpdate() + { + DoGetMouseButtonUp(); + } + + public void DoGetMouseButtonUp() + { + bool buttonUp = Input.GetMouseButtonUp((int)button); + if (buttonUp) + { + Fsm.Event(sendEvent); + } + + storeResult.Value = buttonUp; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetMouseButtonUp.cs.meta b/Assets/PlayMaker/Actions/GetMouseButtonUp.cs.meta new file mode 100755 index 0000000..777b455 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseButtonUp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f7b489fa5d69534a86005b52bc02998 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMouseX.cs b/Assets/PlayMaker/Actions/GetMouseX.cs new file mode 100755 index 0000000..8414eb5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseX.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Gets the X Position of the mouse and stores it in a Float Variable.")] + public class GetMouseX : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeResult; + public bool normalize; + + public override void Reset() + { + storeResult = null; + normalize = true; + } + + public override void OnEnter() + { + DoGetMouseX(); + } + + public override void OnUpdate() + { + DoGetMouseX(); + } + + void DoGetMouseX() + { + if (storeResult != null) + { + float xpos = Input.mousePosition.x; + + if (normalize) + xpos /= Screen.width; + + storeResult.Value = xpos; + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/GetMouseX.cs.meta b/Assets/PlayMaker/Actions/GetMouseX.cs.meta new file mode 100755 index 0000000..2a223da --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseX.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e948dfb9aecf7247b31e68381d364f4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetMouseY.cs b/Assets/PlayMaker/Actions/GetMouseY.cs new file mode 100755 index 0000000..b9123a3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseY.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Gets the Y Position of the mouse and stores it in a Float Variable.")] + public class GetMouseY : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeResult; + public bool normalize; + + public override void Reset() + { + storeResult = null; + normalize = true; + } + + public override void OnEnter() + { + DoGetMouseY(); + } + + public override void OnUpdate() + { + DoGetMouseY(); + } + + void DoGetMouseY() + { + if (storeResult != null) + { + float ypos = Input.mousePosition.y; + + if (normalize) + ypos /= Screen.height; + + storeResult.Value = ypos; + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/GetMouseY.cs.meta b/Assets/PlayMaker/Actions/GetMouseY.cs.meta new file mode 100755 index 0000000..21adeaa --- /dev/null +++ b/Assets/PlayMaker/Actions/GetMouseY.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f6b2db7fd3dcefa41b738bd147447ae9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetName.cs b/Assets/PlayMaker/Actions/GetName.cs new file mode 100755 index 0000000..5b2fa9d --- /dev/null +++ b/Assets/PlayMaker/Actions/GetName.cs @@ -0,0 +1,47 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets the name of a Game Object and stores it in a String Variable.")] + public class GetName : FsmStateAction + { + [RequiredField] + public FsmGameObject gameObject; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString storeName; + + public bool everyFrame; + + public override void Reset() + { + gameObject = new FsmGameObject { UseVariable = true}; + storeName = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetGameObjectName(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetGameObjectName(); + } + + void DoGetGameObjectName() + { + var go = gameObject.Value; + + storeName.Value = go != null ? go.name : ""; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetName.cs.meta b/Assets/PlayMaker/Actions/GetName.cs.meta new file mode 100755 index 0000000..3b863a8 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetName.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 045ff2653e06dc348a164ea75e133264 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetNextChild.cs b/Assets/PlayMaker/Actions/GetNextChild.cs new file mode 100755 index 0000000..615182e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetNextChild.cs @@ -0,0 +1,98 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Each time this action is called it gets the next child of a GameObject. This lets you quickly loop through all the children of an object to perform actions on them. NOTE: To find a specific child use Find Child.")] + public class GetNextChild : FsmStateAction + { + [RequiredField] + [Tooltip("The parent GameObject. Note, if GameObject changes, this action will reset and start again at the first child.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the next child in a GameObject variable.")] + public FsmGameObject storeNextChild; + + [Tooltip("Event to send to get the next child.")] + public FsmEvent loopEvent; + + [Tooltip("Event to send when there are no more children.")] + public FsmEvent finishedEvent; + + public override void Reset() + { + gameObject = null; + storeNextChild = null; + loopEvent = null; + finishedEvent = null; + } + + // cache the gameObject so we no if it changes + private GameObject go; + + // increment a child index as we loop through children + private int nextChildIndex; + + public override void OnEnter() + { + + DoGetNextChild(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + void DoGetNextChild(GameObject parent) + { + if (parent == null) + { + return; + } + + // reset? + + if (go != parent) + { + go = parent; + nextChildIndex = 0; + } + + // no more children? + // check first to avoid errors. + + if (nextChildIndex >= go.transform.childCount) + { + nextChildIndex = 0; + Fsm.Event(finishedEvent); + return; + } + + // get next child + + storeNextChild.Value = parent.transform.GetChild(nextChildIndex).gameObject; + + + // no more children? + // check a second time to avoid process lock and possible infinite loop if the action is called again. + // Practically, this enabled calling again this state and it will start again iterating from the first child. + + if (nextChildIndex >= go.transform.childCount) + { + nextChildIndex = 0; + Fsm.Event(finishedEvent); + return; + } + + // iterate the next child + nextChildIndex++; + + if (loopEvent != null) + { + Fsm.Event(loopEvent); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetNextChild.cs.meta b/Assets/PlayMaker/Actions/GetNextChild.cs.meta new file mode 100755 index 0000000..6f368fd --- /dev/null +++ b/Assets/PlayMaker/Actions/GetNextChild.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2750bf7d1d5757341ac1d3b3934ba848 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetOwner.cs b/Assets/PlayMaker/Actions/GetOwner.cs new file mode 100755 index 0000000..9a51a28 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetOwner.cs @@ -0,0 +1,27 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets the Game Object that owns the FSM and stores it in a game object variable.")] + public class GetOwner : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmGameObject storeGameObject; + + public override void Reset() + { + storeGameObject = null; + } + + public override void OnEnter() + { + storeGameObject.Value = Owner; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetOwner.cs.meta b/Assets/PlayMaker/Actions/GetOwner.cs.meta new file mode 100755 index 0000000..776def2 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetOwner.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a09fbbee2ff3ced47847530415f04af0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetParent.cs b/Assets/PlayMaker/Actions/GetParent.cs new file mode 100755 index 0000000..e6a473e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetParent.cs @@ -0,0 +1,31 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets the Parent of a Game Object.")] + public class GetParent : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.Variable)] + public FsmGameObject storeResult; + + public override void Reset() + { + gameObject = null; + storeResult = null; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go != null) + storeResult.Value = go.transform.parent == null ? null : go.transform.parent.gameObject; + else + storeResult.Value = null; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetParent.cs.meta b/Assets/PlayMaker/Actions/GetParent.cs.meta new file mode 100755 index 0000000..74f0d0c --- /dev/null +++ b/Assets/PlayMaker/Actions/GetParent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1ebc1e55f53789442b767369a58c2427 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetPosition.cs b/Assets/PlayMaker/Actions/GetPosition.cs new file mode 100755 index 0000000..1967c4a --- /dev/null +++ b/Assets/PlayMaker/Actions/GetPosition.cs @@ -0,0 +1,74 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Gets the Position of a Game Object and stores it in a Vector3 Variable or each Axis in a Float Variable")] + public class GetPosition : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + public FsmVector3 vector; + + [UIHint(UIHint.Variable)] + public FsmFloat x; + + [UIHint(UIHint.Variable)] + public FsmFloat y; + + [UIHint(UIHint.Variable)] + public FsmFloat z; + + public Space space; + + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + vector = null; + x = null; + y = null; + z = null; + space = Space.World; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetPosition(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetPosition(); + } + + void DoGetPosition() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var position = space == Space.World ? go.transform.position : go.transform.localPosition; + + vector.Value = position; + x.Value = position.x; + y.Value = position.y; + z.Value = position.z; + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetPosition.cs.meta b/Assets/PlayMaker/Actions/GetPosition.cs.meta new file mode 100755 index 0000000..4faaa89 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30b9e49bd10ad084f9de50bd465c7311 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetPreviousStateName.cs b/Assets/PlayMaker/Actions/GetPreviousStateName.cs new file mode 100755 index 0000000..69753b4 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetPreviousStateName.cs @@ -0,0 +1,26 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Gets the name of the previously active state and stores it in a String Variable.")] + public class GetPreviousStateName : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmString storeName; + + public override void Reset() + { + storeName = null; + } + + public override void OnEnter() + { + storeName.Value = Fsm.PreviousActiveState == null ? null : Fsm.PreviousActiveState.Name; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetPreviousStateName.cs.meta b/Assets/PlayMaker/Actions/GetPreviousStateName.cs.meta new file mode 100755 index 0000000..c9fe2b1 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetPreviousStateName.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c36954e78645b0b48ae925a44d2de0f9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetProperty.cs b/Assets/PlayMaker/Actions/GetProperty.cs new file mode 100755 index 0000000..edef775 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetProperty.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !UNITY_FLASH + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.UnityObject)] + [Tooltip("Gets the value of any public property or field on the targeted Unity Object and stores it in a variable. E.g., Drag and drop any component attached to a Game Object to access its properties.")] + public class GetProperty : FsmStateAction + { + public FsmProperty targetProperty; + public bool everyFrame; + + public override void Reset() + { + targetProperty = new FsmProperty { setProperty = false }; + everyFrame = false; + } + + public override void OnEnter() + { + targetProperty.GetValue(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + targetProperty.GetValue(); + } + +#if UNITY_EDITOR + public override string AutoName() + { + var name = string.IsNullOrEmpty(targetProperty.PropertyName) ? "[none]" : targetProperty.PropertyName; + return "Get Property: "+ name; + //var value = ActionHelpers.GetValueLabel(targetProperty.GetVariable()); + //return string.Format("Get {0} to {1}", name, value); + } +#endif + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetProperty.cs.meta b/Assets/PlayMaker/Actions/GetProperty.cs.meta new file mode 100755 index 0000000..60131b2 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetProperty.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a018ddc252a3fd3439d9948293ffe120 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetRandomChild.cs b/Assets/PlayMaker/Actions/GetRandomChild.cs new file mode 100755 index 0000000..6101568 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRandomChild.cs @@ -0,0 +1,40 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets a Random Child of a Game Object.")] + public class GetRandomChild : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmGameObject storeResult; + + public override void Reset() + { + gameObject = null; + storeResult = null; + } + + public override void OnEnter() + { + DoGetRandomChild(); + Finish(); + } + + void DoGetRandomChild() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + int childCount = go.transform.childCount; + if (childCount == 0) return; + + storeResult.Value = go.transform.GetChild(Random.Range(0, childCount)).gameObject; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetRandomChild.cs.meta b/Assets/PlayMaker/Actions/GetRandomChild.cs.meta new file mode 100755 index 0000000..e5a245b --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRandomChild.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ef5bde52908514f4c897adef304536ca +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetRandomObject.cs b/Assets/PlayMaker/Actions/GetRandomObject.cs new file mode 100755 index 0000000..9c2cd6e --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRandomObject.cs @@ -0,0 +1,65 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets a Random Game Object from the scene.\nOptionally filter by Tag.")] + public class GetRandomObject : FsmStateAction + { + [UIHint(UIHint.Tag)] + public FsmString withTag; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmGameObject storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + withTag = "Untagged"; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetRandomObject(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetRandomObject(); + } + + void DoGetRandomObject() + { + GameObject[] gameObjects; + + if (withTag.Value != "Untagged") + { + gameObjects = GameObject.FindGameObjectsWithTag(withTag.Value); + } + else + { + gameObjects = (GameObject[])Object.FindObjectsOfType(typeof(GameObject)); + } + + if (gameObjects.Length > 0) + { + storeResult.Value = gameObjects[Random.Range(0, gameObjects.Length)]; + return; + } + + storeResult.Value = null; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetRandomObject.cs.meta b/Assets/PlayMaker/Actions/GetRandomObject.cs.meta new file mode 100755 index 0000000..91ab31a --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRandomObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c4b3907e0f8f9c46b4fdb54b3c73164 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetRaycastHitInfo.cs b/Assets/PlayMaker/Actions/GetRaycastHitInfo.cs new file mode 100755 index 0000000..9ad5652 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRaycastHitInfo.cs @@ -0,0 +1,66 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Gets info on the last Raycast and store in variables.")] + public class GetRaycastHitInfo : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("Get the GameObject hit by the last Raycast and store it in a variable.")] + public FsmGameObject gameObjectHit; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the world position of the ray hit point and store it in a variable.")] + [Title("Hit Point")] + public FsmVector3 point; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the normal at the hit point and store it in a variable.")] + public FsmVector3 normal; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the distance along the ray to the hit point and store it in a variable.")] + public FsmFloat distance; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObjectHit = null; + point = null; + normal = null; + distance = null; + everyFrame = false; + } + + void StoreRaycastInfo() + { + if (Fsm.RaycastHitInfo.collider != null) + { + gameObjectHit.Value = Fsm.RaycastHitInfo.collider.gameObject; + point.Value = Fsm.RaycastHitInfo.point; + normal.Value = Fsm.RaycastHitInfo.normal; + distance.Value = Fsm.RaycastHitInfo.distance; + } + } + + public override void OnEnter() + { + StoreRaycastInfo(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + StoreRaycastInfo(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetRaycastHitInfo.cs.meta b/Assets/PlayMaker/Actions/GetRaycastHitInfo.cs.meta new file mode 100755 index 0000000..53b93ca --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRaycastHitInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c5e7185b5f18b7548800c0ab7d5c3cae +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetRectFields.cs b/Assets/PlayMaker/Actions/GetRectFields.cs new file mode 100755 index 0000000..10ae85f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRectFields.cs @@ -0,0 +1,67 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Rect)] + [Tooltip("Get the individual fields of a Rect Variable and store them in Float Variables.")] + public class GetRectFields : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmRect rectVariable; + + [UIHint(UIHint.Variable)] + public FsmFloat storeX; + + [UIHint(UIHint.Variable)] + public FsmFloat storeY; + + [UIHint(UIHint.Variable)] + public FsmFloat storeWidth; + + [UIHint(UIHint.Variable)] + public FsmFloat storeHeight; + + public bool everyFrame; + + public override void Reset() + { + rectVariable = null; + storeX = null; + storeY = null; + storeWidth = null; + storeHeight = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetRectFields(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetRectFields(); + } + + void DoGetRectFields() + { + if (rectVariable.IsNone) + { + return; + } + + storeX.Value = rectVariable.Value.x; + storeY.Value = rectVariable.Value.y; + storeWidth.Value = rectVariable.Value.width; + storeHeight.Value = rectVariable.Value.height; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetRectFields.cs.meta b/Assets/PlayMaker/Actions/GetRectFields.cs.meta new file mode 100755 index 0000000..b74df87 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRectFields.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6d1407ee3c78d9f46b206f60ca49806a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetRoot.cs b/Assets/PlayMaker/Actions/GetRoot.cs new file mode 100755 index 0000000..02e4c59 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRoot.cs @@ -0,0 +1,38 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets the top most parent of the Game Object.\nIf the game object has no parent, returns itself.")] + public class GetRoot : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmGameObject storeRoot; + + public override void Reset() + { + gameObject = null; + storeRoot = null; + } + + public override void OnEnter() + { + DoGetRoot(); + + Finish(); + } + + void DoGetRoot() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + storeRoot.Value = go.transform.root.gameObject; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetRoot.cs.meta b/Assets/PlayMaker/Actions/GetRoot.cs.meta new file mode 100755 index 0000000..925846a --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRoot.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 46d883c3dd43f0044ba8b4133f3a7b5a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetRotation.cs b/Assets/PlayMaker/Actions/GetRotation.cs new file mode 100755 index 0000000..afd3fa5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRotation.cs @@ -0,0 +1,88 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Gets the Rotation of a Game Object and stores it in a Vector3 Variable or each Axis in a Float Variable")] + public class GetRotation : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.Variable)] + public FsmQuaternion quaternion; + [UIHint(UIHint.Variable)] + [Title("Euler Angles")] + public FsmVector3 vector; + [UIHint(UIHint.Variable)] + public FsmFloat xAngle; + [UIHint(UIHint.Variable)] + public FsmFloat yAngle; + [UIHint(UIHint.Variable)] + public FsmFloat zAngle; + public Space space; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + quaternion = null; + vector = null; + xAngle = null; + yAngle = null; + zAngle = null; + space = Space.World; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetRotation(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetRotation(); + } + + void DoGetRotation() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (space == Space.World) + { + quaternion.Value = go.transform.rotation; + + var rotation = go.transform.eulerAngles; + + vector.Value = rotation; + xAngle.Value = rotation.x; + yAngle.Value = rotation.y; + zAngle.Value = rotation.z; + } + else + { + var rotation = go.transform.localEulerAngles; + + quaternion.Value = Quaternion.Euler(rotation); + + vector.Value = rotation; + xAngle.Value = rotation.x; + yAngle.Value = rotation.y; + zAngle.Value = rotation.z; + } + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetRotation.cs.meta b/Assets/PlayMaker/Actions/GetRotation.cs.meta new file mode 100755 index 0000000..c878096 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 11568980f96e6354cb11a621656a449c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetScale.cs b/Assets/PlayMaker/Actions/GetScale.cs new file mode 100755 index 0000000..55975fe --- /dev/null +++ b/Assets/PlayMaker/Actions/GetScale.cs @@ -0,0 +1,76 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// http://hutonggames.com/playmakerforum/index.php?topic=63.0 +// Thanks: MaDDoX + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Gets the Scale of a Game Object and stores it in a Vector3 Variable or each Axis in a Float Variable")] + public class GetScale : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + public FsmVector3 vector; + + [UIHint(UIHint.Variable)] + public FsmFloat xScale; + + [UIHint(UIHint.Variable)] + public FsmFloat yScale; + + [UIHint(UIHint.Variable)] + public FsmFloat zScale; + + public Space space; + + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + vector = null; + xScale = null; + yScale = null; + zScale = null; + space = Space.World; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetScale(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetScale(); + } + + void DoGetScale() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var scale = space == Space.World ? go.transform.lossyScale : go.transform.localScale; + + vector.Value = scale; + xScale.Value = scale.x; + yScale.Value = scale.y; + zScale.Value = scale.z; + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetScale.cs.meta b/Assets/PlayMaker/Actions/GetScale.cs.meta new file mode 100755 index 0000000..3f579ad --- /dev/null +++ b/Assets/PlayMaker/Actions/GetScale.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc555f986aa1bc7498bc9cf99b97a38d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetScreenHeight.cs b/Assets/PlayMaker/Actions/GetScreenHeight.cs new file mode 100755 index 0000000..b9350ce --- /dev/null +++ b/Assets/PlayMaker/Actions/GetScreenHeight.cs @@ -0,0 +1,27 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Application)] + [Tooltip("Gets the Height of the Screen in pixels.")] + public class GetScreenHeight : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeScreenHeight; + + public override void Reset() + { + storeScreenHeight = null; + } + + public override void OnEnter() + { + storeScreenHeight.Value = Screen.height; + Finish(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetScreenHeight.cs.meta b/Assets/PlayMaker/Actions/GetScreenHeight.cs.meta new file mode 100755 index 0000000..0feead5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetScreenHeight.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 83ea24d8e26cdaf4f940fda23c29ecb7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetScreenWidth.cs b/Assets/PlayMaker/Actions/GetScreenWidth.cs new file mode 100755 index 0000000..acf9b95 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetScreenWidth.cs @@ -0,0 +1,27 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Application)] + [Tooltip("Gets the Width of the Screen in pixels.")] + public class GetScreenWidth : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeScreenWidth; + + public override void Reset() + { + storeScreenWidth = null; + } + + public override void OnEnter() + { + storeScreenWidth.Value = Screen.width; + Finish(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetScreenWidth.cs.meta b/Assets/PlayMaker/Actions/GetScreenWidth.cs.meta new file mode 100755 index 0000000..3395e34 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetScreenWidth.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc3418538b8c2cb4d93436a08a94d849 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetSpeed.cs b/Assets/PlayMaker/Actions/GetSpeed.cs new file mode 100755 index 0000000..28cbb2f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetSpeed.cs @@ -0,0 +1,61 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Gets the Speed of a Game Object and stores it in a Float Variable. NOTE: The Game Object must have a rigid body.")] + public class GetSpeed : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + [Tooltip("The GameObject with a Rigidbody.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the speed in a float variable.")] + public FsmFloat storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetSpeed(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetSpeed(); + } + + void DoGetSpeed() + { + if (storeResult == null) + { + return; + } + + var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; + if (UpdateCache(go)) + { + var velocity = rigidbody.velocity; + storeResult.Value = velocity.magnitude; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetSpeed.cs.meta b/Assets/PlayMaker/Actions/GetSpeed.cs.meta new file mode 100755 index 0000000..9d38125 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetSpeed.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8c8f62156b62b7c42953ef79868fc3a2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetStringLeft.cs b/Assets/PlayMaker/Actions/GetStringLeft.cs new file mode 100755 index 0000000..417d025 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetStringLeft.cs @@ -0,0 +1,57 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Gets the Left n characters from a String Variable.")] + public class GetStringLeft : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + + [Tooltip("Number of characters to get.")] + public FsmInt charCount; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + charCount = 0; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetStringLeft(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetStringLeft(); + } + + void DoGetStringLeft() + { + if (stringVariable.IsNone) return; + if (storeResult.IsNone) return; + + storeResult.Value = stringVariable.Value.Substring(0, Mathf.Clamp(charCount.Value, 0, stringVariable.Value.Length)); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetStringLeft.cs.meta b/Assets/PlayMaker/Actions/GetStringLeft.cs.meta new file mode 100755 index 0000000..16f9a13 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetStringLeft.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 199c773473d95214b8c31de51d14dbd0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetStringLength.cs b/Assets/PlayMaker/Actions/GetStringLength.cs new file mode 100755 index 0000000..fe04477 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetStringLength.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Gets the Length of a String.")] + public class GetStringLength : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt storeResult; + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetStringLength(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetStringLength(); + } + + void DoGetStringLength() + { + if (stringVariable == null) return; + if (storeResult == null) return; + + storeResult.Value = stringVariable.Value.Length; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetStringLength.cs.meta b/Assets/PlayMaker/Actions/GetStringLength.cs.meta new file mode 100755 index 0000000..899c014 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetStringLength.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0f06dd4128a98404dbbd0c144563f449 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetStringRight.cs b/Assets/PlayMaker/Actions/GetStringRight.cs new file mode 100755 index 0000000..b141125 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetStringRight.cs @@ -0,0 +1,57 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Gets the Right n characters from a String.")] + public class GetStringRight : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + + [Tooltip("Number of characters to get.")] + public FsmInt charCount; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString storeResult; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + charCount = 0; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetStringRight(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetStringRight(); + } + + void DoGetStringRight() + { + if (stringVariable.IsNone) return; + if (storeResult.IsNone) return; + + var text = stringVariable.Value; + var count = Mathf.Clamp(charCount.Value, 0, text.Length); + storeResult.Value = text.Substring(text.Length - count, count); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetStringRight.cs.meta b/Assets/PlayMaker/Actions/GetStringRight.cs.meta new file mode 100755 index 0000000..3ae95f5 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetStringRight.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 58939666c2ca9cc449f67a55d54d9a88 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetSubstring.cs b/Assets/PlayMaker/Actions/GetSubstring.cs new file mode 100755 index 0000000..419e3ae --- /dev/null +++ b/Assets/PlayMaker/Actions/GetSubstring.cs @@ -0,0 +1,54 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Gets a sub-string from a String Variable.")] + public class GetSubstring : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + [RequiredField] + public FsmInt startIndex; + [RequiredField] + public FsmInt length; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString storeResult; + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + startIndex = 0; + length = 1; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetSubstring(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetSubstring(); + } + + void DoGetSubstring() + { + if (stringVariable == null) return; + if (storeResult == null) return; + + storeResult.Value = stringVariable.Value.Substring(startIndex.Value, length.Value); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetSubstring.cs.meta b/Assets/PlayMaker/Actions/GetSubstring.cs.meta new file mode 100755 index 0000000..344422b --- /dev/null +++ b/Assets/PlayMaker/Actions/GetSubstring.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8997ded4a827f0b44b95a5537a0e8dbf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetSystemDateTime.cs b/Assets/PlayMaker/Actions/GetSystemDateTime.cs new file mode 100755 index 0000000..1f27fbc --- /dev/null +++ b/Assets/PlayMaker/Actions/GetSystemDateTime.cs @@ -0,0 +1,43 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Time)] + [Tooltip("Gets system date and time info and stores it in a string variable. An optional format string gives you a lot of control over the formatting (see online docs for format syntax).")] + public class GetSystemDateTime : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("Store System DateTime as a string.")] + public FsmString storeString; + + [Tooltip("Optional format string. E.g., MM/dd/yyyy HH:mm")] + public FsmString format; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + storeString = null; + format = "MM/dd/yyyy HH:mm"; + } + + public override void OnEnter() + { + storeString.Value = DateTime.Now.ToString(format.Value); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + storeString.Value = DateTime.Now.ToString(format.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/GetSystemDateTime.cs.meta b/Assets/PlayMaker/Actions/GetSystemDateTime.cs.meta new file mode 100755 index 0000000..22378ed --- /dev/null +++ b/Assets/PlayMaker/Actions/GetSystemDateTime.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1e02d3f4a1dc5364babb74da3ffd080b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetTag.cs b/Assets/PlayMaker/Actions/GetTag.cs new file mode 100755 index 0000000..6dc3ab3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTag.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets a Game Object's Tag and stores it in a String Variable.")] + public class GetTag : FsmStateAction + { + [RequiredField] + public FsmGameObject gameObject; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString storeResult; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetTag(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetTag(); + } + + void DoGetTag() + { + if (gameObject.Value == null) return; + + storeResult.Value = gameObject.Value.tag; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetTag.cs.meta b/Assets/PlayMaker/Actions/GetTag.cs.meta new file mode 100755 index 0000000..8a5804b --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fa39124361c39bb41851e998ff9993fc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetTagCount.cs b/Assets/PlayMaker/Actions/GetTagCount.cs new file mode 100755 index 0000000..8c6f06f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTagCount.cs @@ -0,0 +1,33 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets the number of Game Objects in the scene with the specified Tag.")] + public class GetTagCount : FsmStateAction + { + [UIHint(UIHint.Tag)] + public FsmString tag; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt storeResult; + + public override void Reset() + { + tag = "Untagged"; + storeResult = null; + } + + public override void OnEnter() + { + GameObject[] gos = GameObject.FindGameObjectsWithTag(tag.Value); + + if (storeResult != null) + storeResult.Value = gos != null ? gos.Length : 0; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetTagCount.cs.meta b/Assets/PlayMaker/Actions/GetTagCount.cs.meta new file mode 100755 index 0000000..5b49bb6 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTagCount.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a012ac3cd51e9c84f82af32e1ab135cd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetTimeInfo.cs b/Assets/PlayMaker/Actions/GetTimeInfo.cs new file mode 100755 index 0000000..4308bd2 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTimeInfo.cs @@ -0,0 +1,96 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Time)] + [Tooltip("Gets various useful Time measurements.")] + public class GetTimeInfo : FsmStateAction + { + public enum TimeInfo + { + DeltaTime, + TimeScale, + SmoothDeltaTime, + TimeInCurrentState, + TimeSinceStartup, + TimeSinceLevelLoad, + RealTimeSinceStartup, + RealTimeInCurrentState + } + + public TimeInfo getInfo; + + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeValue; + + public bool everyFrame; + + public override void Reset() + { + getInfo = TimeInfo.TimeSinceLevelLoad; + storeValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetTimeInfo(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetTimeInfo(); + } + + void DoGetTimeInfo() + { + switch (getInfo) + { + + case TimeInfo.DeltaTime: + storeValue.Value = Time.deltaTime; + break; + + case TimeInfo.TimeScale: + storeValue.Value = Time.timeScale; + break; + + case TimeInfo.SmoothDeltaTime: + storeValue.Value = Time.smoothDeltaTime; + break; + + case TimeInfo.TimeInCurrentState: + storeValue.Value = State.StateTime; + break; + + case TimeInfo.TimeSinceStartup: + storeValue.Value = Time.time; + break; + + case TimeInfo.TimeSinceLevelLoad: + storeValue.Value = Time.timeSinceLevelLoad; + break; + + case TimeInfo.RealTimeSinceStartup: + storeValue.Value = FsmTime.RealtimeSinceStartup; + break; + + case TimeInfo.RealTimeInCurrentState: + storeValue.Value = FsmTime.RealtimeSinceStartup - State.RealStartTime; + break; + + default: + storeValue.Value = 0f; + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetTimeInfo.cs.meta b/Assets/PlayMaker/Actions/GetTimeInfo.cs.meta new file mode 100755 index 0000000..3deba12 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTimeInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8e3db02fb7991d64d85d8cb4e2faf252 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetTouchCount.cs b/Assets/PlayMaker/Actions/GetTouchCount.cs new file mode 100755 index 0000000..c0601f2 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTouchCount.cs @@ -0,0 +1,41 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Gets the number of Touches.")] + public class GetTouchCount : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt storeCount; + public bool everyFrame; + + public override void Reset() + { + storeCount = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetTouchCount(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoGetTouchCount(); + } + + void DoGetTouchCount() + { + storeCount.Value = Input.touchCount; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetTouchCount.cs.meta b/Assets/PlayMaker/Actions/GetTouchCount.cs.meta new file mode 100755 index 0000000..fd3cc34 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTouchCount.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b64c8446f7450a44ba67b31d3853ca79 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetTouchInfo.cs b/Assets/PlayMaker/Actions/GetTouchInfo.cs new file mode 100755 index 0000000..b2a7372 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTouchInfo.cs @@ -0,0 +1,105 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Gets info on a touch event.")] + public class GetTouchInfo : FsmStateAction + { + [Tooltip("Filter by a Finger ID. You can store a Finger ID in other Touch actions, e.g., Touch Event.")] + public FsmInt fingerId; + [Tooltip("If true, all screen coordinates are returned normalized (0-1), otherwise in pixels.")] + public FsmBool normalize; + [UIHint(UIHint.Variable)] + public FsmVector3 storePosition; + [UIHint(UIHint.Variable)] + public FsmFloat storeX; + [UIHint(UIHint.Variable)] + public FsmFloat storeY; + [UIHint(UIHint.Variable)] + public FsmVector3 storeDeltaPosition; + [UIHint(UIHint.Variable)] + public FsmFloat storeDeltaX; + [UIHint(UIHint.Variable)] + public FsmFloat storeDeltaY; + [UIHint(UIHint.Variable)] + public FsmFloat storeDeltaTime; + [UIHint(UIHint.Variable)] + public FsmInt storeTapCount; + + public bool everyFrame = true; + + float screenWidth; + float screenHeight; + + public override void Reset() + { + fingerId = new FsmInt { UseVariable = true }; + normalize = true; + storePosition = null; + storeDeltaPosition = null; + storeDeltaTime = null; + storeTapCount = null; + everyFrame = true; + } + + public override void OnEnter() + { + screenWidth = Screen.width; + screenHeight = Screen.height; + + DoGetTouchInfo(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetTouchInfo(); + } + + void DoGetTouchInfo() + { + if (Input.touchCount > 0) + { + foreach (var touch in Input.touches) + { + if (fingerId.IsNone || touch.fingerId == fingerId.Value) + { + float x = normalize.Value == false ? touch.position.x : touch.position.x / screenWidth; + float y = normalize.Value == false ? touch.position.y : touch.position.y / screenHeight; + + if (!storePosition.IsNone) + { + storePosition.Value = new Vector3(x, y, 0); + } + + storeX.Value = x; + storeY.Value = y; + + float deltax = normalize.Value == false ? touch.deltaPosition.x : touch.deltaPosition.x / screenWidth; + float deltay = normalize.Value == false ? touch.deltaPosition.y : touch.deltaPosition.y / screenHeight; + + if (!storeDeltaPosition.IsNone) + { + storeDeltaPosition.Value = new Vector3(deltax, deltay, 0); + } + + storeDeltaX.Value = deltax; + storeDeltaY.Value = deltay; + + storeDeltaTime.Value = touch.deltaTime; + storeTapCount.Value = touch.tapCount; + } + } + } + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetTouchInfo.cs.meta b/Assets/PlayMaker/Actions/GetTouchInfo.cs.meta new file mode 100755 index 0000000..f50bc28 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTouchInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f1f2c212c98dba40b9321d85fac7d83 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetTransform.cs b/Assets/PlayMaker/Actions/GetTransform.cs new file mode 100755 index 0000000..7a5f0a6 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTransform.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Gets a Game Object's Transform and stores it in an Object Variable.")] + public class GetTransform : FsmStateAction + { + [RequiredField] + public FsmGameObject gameObject; + + [RequiredField] + [UIHint(UIHint.Variable)] + [ObjectType(typeof(Transform))] + public FsmObject storeTransform; + + public bool everyFrame; + + public override void Reset() + { + gameObject = new FsmGameObject { UseVariable = true}; + storeTransform = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetGameObjectName(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetGameObjectName(); + } + + void DoGetGameObjectName() + { + var go = gameObject.Value; + + storeTransform.Value = go != null ? go.transform : null; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetTransform.cs.meta b/Assets/PlayMaker/Actions/GetTransform.cs.meta new file mode 100755 index 0000000..39aceb9 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTransform.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c43a7be7c6a41434d834172485aa1c72 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetTriggerInfo.cs b/Assets/PlayMaker/Actions/GetTriggerInfo.cs new file mode 100755 index 0000000..764a783 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTriggerInfo.cs @@ -0,0 +1,38 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Gets info on the last Trigger event and store in variables.")] + public class GetTriggerInfo : FsmStateAction + { + [UIHint(UIHint.Variable)] + public FsmGameObject gameObjectHit; + [UIHint(UIHint.Variable)] + [Tooltip("Useful for triggering different effects. Audio, particles...")] + public FsmString physicsMaterialName; + + public override void Reset() + { + gameObjectHit = null; + physicsMaterialName = null; + } + + void StoreTriggerInfo() + { + if (Fsm.TriggerCollider == null) return; + + gameObjectHit.Value = Fsm.TriggerCollider.gameObject; + physicsMaterialName.Value = Fsm.TriggerCollider.material.name; + } + + public override void OnEnter() + { + StoreTriggerInfo(); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetTriggerInfo.cs.meta b/Assets/PlayMaker/Actions/GetTriggerInfo.cs.meta new file mode 100755 index 0000000..d8b788c --- /dev/null +++ b/Assets/PlayMaker/Actions/GetTriggerInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c04fdb2a67228ba4283a7e3d6f2c6707 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetVector3XYZ.cs b/Assets/PlayMaker/Actions/GetVector3XYZ.cs new file mode 100755 index 0000000..eb86b33 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVector3XYZ.cs @@ -0,0 +1,58 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Get the XYZ channels of a Vector3 Variable and store them in Float Variables.")] + public class GetVector3XYZ : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + [UIHint(UIHint.Variable)] + public FsmFloat storeX; + [UIHint(UIHint.Variable)] + public FsmFloat storeY; + [UIHint(UIHint.Variable)] + public FsmFloat storeZ; + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + storeX = null; + storeY = null; + storeZ = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetVector3XYZ(); + + if(!everyFrame) + Finish(); + } + + public override void OnUpdate () + { + DoGetVector3XYZ(); + } + + void DoGetVector3XYZ() + { + if (vector3Variable == null) return; + + if (storeX != null) + storeX.Value = vector3Variable.Value.x; + + if (storeY != null) + storeY.Value = vector3Variable.Value.y; + + if (storeZ != null) + storeZ.Value = vector3Variable.Value.z; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetVector3XYZ.cs.meta b/Assets/PlayMaker/Actions/GetVector3XYZ.cs.meta new file mode 100755 index 0000000..f17012f --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVector3XYZ.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: beeb2aa4d6f866441815d87a22143bd6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetVectorLength.cs b/Assets/PlayMaker/Actions/GetVectorLength.cs new file mode 100755 index 0000000..e57c8d3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVectorLength.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Get Vector3 Length.")] + public class GetVectorLength : FsmStateAction + { + public FsmVector3 vector3; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeLength; + + public override void Reset() + { + vector3 = null; + storeLength = null; + } + + public override void OnEnter() + { + DoVectorLength(); + Finish(); + } + + void DoVectorLength() + { + if (vector3 == null) return; + if (storeLength == null) return; + storeLength.Value = vector3.Value.magnitude; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetVectorLength.cs.meta b/Assets/PlayMaker/Actions/GetVectorLength.cs.meta new file mode 100755 index 0000000..4be9982 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVectorLength.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b0aa280b551a53342be23052e8e3953e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetVelocity.cs b/Assets/PlayMaker/Actions/GetVelocity.cs new file mode 100755 index 0000000..2c709d3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVelocity.cs @@ -0,0 +1,73 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Gets the Velocity of a Game Object and stores it in a Vector3 Variable or each Axis in a Float Variable. NOTE: The Game Object must have a Rigid Body.")] + public class GetVelocity : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.Variable)] + public FsmVector3 vector; + [UIHint(UIHint.Variable)] + public FsmFloat x; + [UIHint(UIHint.Variable)] + public FsmFloat y; + [UIHint(UIHint.Variable)] + public FsmFloat z; + public Space space; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + vector = null; + x = null; + y = null; + z = null; + space = Space.World; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetVelocity(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetVelocity(); + } + + void DoGetVelocity() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + var velocity = rigidbody.velocity; + if (space == Space.Self) + { + velocity = go.transform.InverseTransformDirection(velocity); + } + + vector.Value = velocity; + x.Value = velocity.x; + y.Value = velocity.y; + z.Value = velocity.z; + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetVelocity.cs.meta b/Assets/PlayMaker/Actions/GetVelocity.cs.meta new file mode 100755 index 0000000..56a5d02 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6e1a910972bc068458cecb4dfbfd02c1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetVertexCount.cs b/Assets/PlayMaker/Actions/GetVertexCount.cs new file mode 100755 index 0000000..953b2b3 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVertexCount.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("Mesh")] + [Tooltip("Gets the number of vertices in a GameObject's mesh. Useful in conjunction with GetVertexPosition.")] + public class GetVertexCount : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(MeshFilter))] + [Tooltip("The GameObject to check.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the vertex count in a variable.")] + public FsmInt storeCount; + + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + storeCount = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetVertexCount(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetVertexCount(); + } + + void DoGetVertexCount() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + + if (go != null) + { + var meshFilter = go.GetComponent(); + + if (meshFilter == null) + { + LogError("Missing MeshFilter!"); + return; + } + + storeCount.Value = meshFilter.mesh.vertexCount; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetVertexCount.cs.meta b/Assets/PlayMaker/Actions/GetVertexCount.cs.meta new file mode 100755 index 0000000..f70fd31 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVertexCount.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fecfe57495f66e0459a41b4f8b76048e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GetVertexPosition.cs b/Assets/PlayMaker/Actions/GetVertexPosition.cs new file mode 100755 index 0000000..f594313 --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVertexPosition.cs @@ -0,0 +1,82 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("Mesh")] + [Tooltip("Gets the position of a vertex in a GameObject's mesh. Hint: Use GetVertexCount to get the number of vertices in a mesh.")] + public class GetVertexPosition : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(MeshFilter))] + [Tooltip("The GameObject to check.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The index of the vertex.")] + public FsmInt vertexIndex; + + [Tooltip("Coordinate system to use.")] + public Space space; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the vertex position in a variable.")] + public FsmVector3 storePosition; + + [Tooltip("Repeat every frame. Useful if the mesh is animated.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + space = Space.World; + storePosition = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoGetVertexPosition(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGetVertexPosition(); + } + + void DoGetVertexPosition() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + + if (go != null) + { + var meshFilter = go.GetComponent(); + + if (meshFilter == null) + { + LogError("Missing MeshFilter!"); + return; + } + + switch (space) + { + case Space.World: + var position = meshFilter.mesh.vertices[vertexIndex.Value]; + storePosition.Value = go.transform.TransformPoint(position); + break; + + case Space.Self: + storePosition.Value = meshFilter.mesh.vertices[vertexIndex.Value]; + break; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GetVertexPosition.cs.meta b/Assets/PlayMaker/Actions/GetVertexPosition.cs.meta new file mode 100755 index 0000000..9383c5b --- /dev/null +++ b/Assets/PlayMaker/Actions/GetVertexPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b45c4d3e58758da40900db1acddb5dd0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/GotoPreviousState.cs b/Assets/PlayMaker/Actions/GotoPreviousState.cs new file mode 100755 index 0000000..372dcf2 --- /dev/null +++ b/Assets/PlayMaker/Actions/GotoPreviousState.cs @@ -0,0 +1,27 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Immediately return to the previously active state.")] + public class GotoPreviousState : FsmStateAction + { + public override void Reset() + { + } + + public override void OnEnter() + { + if (Fsm.PreviousActiveState != null) + { + Log("Goto Previous State: " + Fsm.PreviousActiveState.Name); + + Fsm.GotoPreviousState(); + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/GotoPreviousState.cs.meta b/Assets/PlayMaker/Actions/GotoPreviousState.cs.meta new file mode 100755 index 0000000..3995fb0 --- /dev/null +++ b/Assets/PlayMaker/Actions/GotoPreviousState.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bfc61e41661b780488c6babd4d1de9a5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/HasComponent.cs b/Assets/PlayMaker/Actions/HasComponent.cs new file mode 100755 index 0000000..47dcc9b --- /dev/null +++ b/Assets/PlayMaker/Actions/HasComponent.cs @@ -0,0 +1,67 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using HutongGames.PlayMaker; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Checks if an Object has a Component. Optionally remove the Component on exiting the state.")] + public class HasComponent : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + [UIHint(UIHint.ScriptComponent)] + public FsmString component; + public FsmBool removeOnExit; + public FsmEvent trueEvent; + public FsmEvent falseEvent; + [UIHint(UIHint.Variable)] + public FsmBool store; + public bool everyFrame; + + Component aComponent; + + public override void Reset() + { + aComponent = null; + gameObject = null; + trueEvent = null; + falseEvent = null; + component = null; + store = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoHasComponent(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoHasComponent(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + } + + public override void OnExit() + { + if (removeOnExit.Value && aComponent != null) + { + Object.Destroy(aComponent); + } + } + + void DoHasComponent(GameObject go) + { + aComponent = go.GetComponent(ReflectionUtils.GetGlobalType(component.Value)); + + Fsm.Event(aComponent != null ? trueEvent : falseEvent); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/HasComponent.cs.meta b/Assets/PlayMaker/Actions/HasComponent.cs.meta new file mode 100755 index 0000000..ac80ca9 --- /dev/null +++ b/Assets/PlayMaker/Actions/HasComponent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a93e9c264d049b54f9e05bfd694ae14d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IncrementRenderQueue.cs b/Assets/PlayMaker/Actions/IncrementRenderQueue.cs new file mode 100755 index 0000000..5d3eb3c --- /dev/null +++ b/Assets/PlayMaker/Actions/IncrementRenderQueue.cs @@ -0,0 +1,19 @@ +using UnityEngine; +using System.Collections; + +public class IncrementRenderQueue : MonoBehaviour +{ + + // Use this for initialization + void Start () + { + + } + + // Update is called once per frame + void Update () + { + + } +} + diff --git a/Assets/PlayMaker/Actions/IncrementRenderQueue.cs.meta b/Assets/PlayMaker/Actions/IncrementRenderQueue.cs.meta new file mode 100755 index 0000000..09c7af4 --- /dev/null +++ b/Assets/PlayMaker/Actions/IncrementRenderQueue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de75474885f65654fbd5b9a0fbc58250 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IntAdd.cs b/Assets/PlayMaker/Actions/IntAdd.cs new file mode 100755 index 0000000..e0122c3 --- /dev/null +++ b/Assets/PlayMaker/Actions/IntAdd.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Adds a value to an Integer Variable.")] + public class IntAdd : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt intVariable; + [RequiredField] + public FsmInt add; + public bool everyFrame; + + public override void Reset() + { + intVariable = null; + add = null; + everyFrame = false; + } + + public override void OnEnter() + { + intVariable.Value += add.Value; + + if (!everyFrame) + Finish(); + } + + // NOTE: very frame rate dependent! + public override void OnUpdate() + { + intVariable.Value += add.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/IntAdd.cs.meta b/Assets/PlayMaker/Actions/IntAdd.cs.meta new file mode 100755 index 0000000..acca9d4 --- /dev/null +++ b/Assets/PlayMaker/Actions/IntAdd.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1fda73f7935c7864c8ac48592bafa1af +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IntChanged.cs b/Assets/PlayMaker/Actions/IntChanged.cs new file mode 100755 index 0000000..86a006e --- /dev/null +++ b/Assets/PlayMaker/Actions/IntChanged.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if the value of an integer variable changed. Use this to send an event on change, or store a bool that can be used in other operations.")] + public class IntChanged : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt intVariable; + public FsmEvent changedEvent; + [UIHint(UIHint.Variable)] + public FsmBool storeResult; + + int previousValue; + + public override void Reset() + { + intVariable = null; + changedEvent = null; + storeResult = null; + } + + public override void OnEnter() + { + if (intVariable.IsNone) + { + Finish(); + return; + } + + previousValue = intVariable.Value; + } + + public override void OnUpdate() + { + storeResult.Value = false; + + if (intVariable.Value != previousValue) + { + previousValue = intVariable.Value; + storeResult.Value = true; + Fsm.Event(changedEvent); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/IntChanged.cs.meta b/Assets/PlayMaker/Actions/IntChanged.cs.meta new file mode 100755 index 0000000..c224a1b --- /dev/null +++ b/Assets/PlayMaker/Actions/IntChanged.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 71aefaa33e74c7b4399c6232b0828066 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IntClamp.cs b/Assets/PlayMaker/Actions/IntClamp.cs new file mode 100755 index 0000000..cd861d0 --- /dev/null +++ b/Assets/PlayMaker/Actions/IntClamp.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Clamp the value of an Integer Variable to a Min/Max range.")] + public class IntClamp : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt intVariable; + [RequiredField] + public FsmInt minValue; + [RequiredField] + public FsmInt maxValue; + public bool everyFrame; + + public override void Reset() + { + intVariable = null; + minValue = null; + maxValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoClamp(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoClamp(); + } + + void DoClamp() + { + intVariable.Value = Mathf.Clamp(intVariable.Value, minValue.Value, maxValue.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/IntClamp.cs.meta b/Assets/PlayMaker/Actions/IntClamp.cs.meta new file mode 100755 index 0000000..5e2a794 --- /dev/null +++ b/Assets/PlayMaker/Actions/IntClamp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0f29dfbf16228f64d8c404892dc184f1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IntCompare.cs b/Assets/PlayMaker/Actions/IntCompare.cs new file mode 100755 index 0000000..1fae105 --- /dev/null +++ b/Assets/PlayMaker/Actions/IntCompare.cs @@ -0,0 +1,74 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends Events based on the comparison of 2 Integers.")] + public class IntCompare : FsmStateAction + { + [RequiredField] + public FsmInt integer1; + [RequiredField] + public FsmInt integer2; + [Tooltip("Event sent if Int 1 equals Int 2")] + public FsmEvent equal; + [Tooltip("Event sent if Int 1 is less than Int 2")] + public FsmEvent lessThan; + [Tooltip("Event sent if Int 1 is greater than Int 2")] + public FsmEvent greaterThan; + public bool everyFrame; + + public override void Reset() + { + integer1 = 0; + integer2 = 0; + equal = null; + lessThan = null; + greaterThan = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoIntCompare(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoIntCompare(); + } + + void DoIntCompare() + { + if (integer1.Value == integer2.Value) + { + Fsm.Event(equal); + return; + } + + if (integer1.Value < integer2.Value) + { + Fsm.Event(lessThan); + return; + } + + if (integer1.Value > integer2.Value) + { + Fsm.Event(greaterThan); + } + + } + + public override string ErrorCheck() + { + if (FsmEvent.IsNullOrEmpty(equal) && + FsmEvent.IsNullOrEmpty(lessThan) && + FsmEvent.IsNullOrEmpty(greaterThan)) + return "Action sends no events!"; + return ""; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/IntCompare.cs.meta b/Assets/PlayMaker/Actions/IntCompare.cs.meta new file mode 100755 index 0000000..4d4c2e6 --- /dev/null +++ b/Assets/PlayMaker/Actions/IntCompare.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7fdc11c4458365e4397a1423b5c5d7aa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IntOperator.cs b/Assets/PlayMaker/Actions/IntOperator.cs new file mode 100755 index 0000000..615faea --- /dev/null +++ b/Assets/PlayMaker/Actions/IntOperator.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Performs math operation on 2 Integers: Add, Subtract, Multiply, Divide, Min, Max.")] + public class IntOperator : FsmStateAction + { + public enum Operation + { + Add, + Subtract, + Multiply, + Divide, + Min, + Max + } + + [RequiredField] + public FsmInt integer1; + [RequiredField] + public FsmInt integer2; + public Operation operation = Operation.Add; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt storeResult; + public bool everyFrame; + + public override void Reset() + { + integer1 = null; + integer2 = null; + operation = Operation.Add; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoIntOperator(); + + if (!everyFrame) + Finish(); + } + + // NOTE: very frame rate dependent! + public override void OnUpdate() + { + DoIntOperator(); + } + + void DoIntOperator() + { + int v1 = integer1.Value; + int v2 = integer2.Value; + + switch (operation) + { + case Operation.Add: + storeResult.Value = v1 + v2; + break; + + case Operation.Subtract: + storeResult.Value = v1 - v2; + break; + + case Operation.Multiply: + storeResult.Value = v1 * v2; + break; + + case Operation.Divide: + storeResult.Value = v1 / v2; + break; + + case Operation.Min: + storeResult.Value = Mathf.Min(v1, v2); + break; + + case Operation.Max: + storeResult.Value = Mathf.Max(v1, v2); + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/IntOperator.cs.meta b/Assets/PlayMaker/Actions/IntOperator.cs.meta new file mode 100755 index 0000000..3ef415a --- /dev/null +++ b/Assets/PlayMaker/Actions/IntOperator.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 704e5a23542193949a1a4ac4eb074e2e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IntSwitch.cs b/Assets/PlayMaker/Actions/IntSwitch.cs new file mode 100755 index 0000000..0e1f435 --- /dev/null +++ b/Assets/PlayMaker/Actions/IntSwitch.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends an Event based on the value of an Integer Variable.")] + public class IntSwitch : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt intVariable; + [CompoundArray("Int Switches", "Compare Int", "Send Event")] + public FsmInt[] compareTo; + public FsmEvent[] sendEvent; + public bool everyFrame; + + public override void Reset() + { + intVariable = null; + compareTo = new FsmInt[1]; + sendEvent = new FsmEvent[1]; + everyFrame = false; + } + + public override void OnEnter() + { + DoIntSwitch(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoIntSwitch(); + } + + void DoIntSwitch() + { + if (intVariable.IsNone) + return; + + for (int i = 0; i < compareTo.Length; i++) + { + if (intVariable.Value == compareTo[i].Value) + { + Fsm.Event(sendEvent[i]); + return; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/IntSwitch.cs.meta b/Assets/PlayMaker/Actions/IntSwitch.cs.meta new file mode 100755 index 0000000..6996db6 --- /dev/null +++ b/Assets/PlayMaker/Actions/IntSwitch.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6f26ba808ee8a9940bee07634362da78 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/InterpolateTransform.cs b/Assets/PlayMaker/Actions/InterpolateTransform.cs new file mode 100755 index 0000000..22da4eb --- /dev/null +++ b/Assets/PlayMaker/Actions/InterpolateTransform.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +/* +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Interpolates a Game Objects Transform (Position/Rotation/Scale). You can specify the Transform using a Game Object, or individual Position, Rotation, Scale vectors.")] + public class InterpolateTransform : FsmStateAction + { + public InterpolationType mode; + [RequiredField] + [Tooltip("The Game Object to move.")] + public FsmOwnerDefault gameObject; + public FsmGameObject fromObject; + public FsmVector3 fromPosition; + public FsmVector3 fromRotation; + public FsmVector3 fromScale; + public FsmGameObject fromObject; + public FsmVector3 fromPosition; + public FsmVector3 fromRotation; + public FsmVector3 fromScale; + + public override void Reset() + { + sendEvent = null; + } + + public override void OnUpdate() + { + if (Input.anyKeyDown) + Fsm.Event(sendEvent); + } + } +} +*/ \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/InterpolateTransform.cs.meta b/Assets/PlayMaker/Actions/InterpolateTransform.cs.meta new file mode 100755 index 0000000..b7f7093 --- /dev/null +++ b/Assets/PlayMaker/Actions/InterpolateTransform.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 064418e2a5f2cb3498b53d022a12c17c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/InverseTransformDirection.cs b/Assets/PlayMaker/Actions/InverseTransformDirection.cs new file mode 100755 index 0000000..9e8d690 --- /dev/null +++ b/Assets/PlayMaker/Actions/InverseTransformDirection.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Transforms a Direction from world space to a Game Object's local space. The opposite of TransformDirection.")] + public class InverseTransformDirection : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmVector3 worldDirection; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 storeResult; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + worldDirection = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoInverseTransformDirection(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoInverseTransformDirection(); + } + + void DoInverseTransformDirection() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if(go == null) return; + + storeResult.Value = go.transform.InverseTransformDirection(worldDirection.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/InverseTransformDirection.cs.meta b/Assets/PlayMaker/Actions/InverseTransformDirection.cs.meta new file mode 100755 index 0000000..adf6654 --- /dev/null +++ b/Assets/PlayMaker/Actions/InverseTransformDirection.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 34aef6d301ba9f640a3e9de22acb6f69 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/InverseTransformPoint.cs b/Assets/PlayMaker/Actions/InverseTransformPoint.cs new file mode 100755 index 0000000..759cf24 --- /dev/null +++ b/Assets/PlayMaker/Actions/InverseTransformPoint.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Transforms position from world space to a Game Object's local space. The opposite of TransformPoint.")] + public class InverseTransformPoint : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmVector3 worldPosition; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 storeResult; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + worldPosition = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoInverseTransformPoint(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoInverseTransformPoint(); + } + + void DoInverseTransformPoint() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if(go == null) return; + + storeResult.Value = go.transform.InverseTransformPoint(worldPosition.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/InverseTransformPoint.cs.meta b/Assets/PlayMaker/Actions/InverseTransformPoint.cs.meta new file mode 100755 index 0000000..e035b03 --- /dev/null +++ b/Assets/PlayMaker/Actions/InverseTransformPoint.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e492b8fba7bde334ca5ef87bdad035c1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/InvokeMethod.cs b/Assets/PlayMaker/Actions/InvokeMethod.cs new file mode 100755 index 0000000..992c4a7 --- /dev/null +++ b/Assets/PlayMaker/Actions/InvokeMethod.cs @@ -0,0 +1,147 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if UNITY_EDITOR +using System; +using System.Linq; +using System.Collections.Generic; +using System.Reflection; +#endif + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.ScriptControl)] + [Tooltip("Invokes a Method in a Behaviour attached to a Game Object. See Unity InvokeMethod docs.")] + public class InvokeMethod : FsmStateAction + { + [RequiredField] + [Tooltip("The game object that owns the behaviour.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Script)] + [Tooltip("The behaviour that contains the method.")] + public FsmString behaviour; + + [RequiredField] + [UIHint(UIHint.Method)] + [Tooltip("The name of the method to invoke.")] + public FsmString methodName; + + [HasFloatSlider(0, 10)] + [Tooltip("Optional time delay in seconds.")] + public FsmFloat delay; + + [Tooltip("Call the method repeatedly.")] + public FsmBool repeating; + + [HasFloatSlider(0, 10)] + [Tooltip("Delay between repeated calls in seconds.")] + public FsmFloat repeatDelay; + + [Tooltip("Stop calling the method when the state is exited.")] + public FsmBool cancelOnExit; + +#if UNITY_EDITOR + + private Type cachedType; + private List methodNames; + +#endif + + public override void Reset() + { + gameObject = null; + behaviour = null; + methodName = ""; + delay = null; + repeating = false; + repeatDelay = 1; + cancelOnExit = false; + } + + MonoBehaviour component; + + public override void OnEnter() + { + DoInvokeMethod(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + void DoInvokeMethod(GameObject go) + { + if (go == null) + { + return; + } + + component = go.GetComponent(ReflectionUtils.GetGlobalType(behaviour.Value)) as MonoBehaviour; + + if (component == null) + { + LogWarning("InvokeMethod: " + go.name + " missing behaviour: " + behaviour.Value); + return; + } + + if (repeating.Value) + { + component.InvokeRepeating(methodName.Value, delay.Value, repeatDelay.Value); + } + else + { + component.Invoke(methodName.Value, delay.Value); + } + } + + public override void OnExit() + { + if (component == null) + { + return; + } + + if (cancelOnExit.Value) + { + component.CancelInvoke(methodName.Value); + } + } + +#if UNITY_EDITOR + + + public override string ErrorCheck() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null || string.IsNullOrEmpty(behaviour.Value)) + { + return string.Empty; + } + + var type = ReflectionUtils.GetGlobalType(behaviour.Value); + if (type == null) + { + return "Missing Behaviour: " + behaviour.Value; + } + + if (cachedType != type) + { + cachedType = type; + methodNames = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Select(m => m.Name).ToList(); + } + + if (!string.IsNullOrEmpty(methodName.Value)) + { + if (!methodNames.Contains(methodName.Value)) + { + return "Missing Method: " + methodName.Value; + } + } + return string.Empty; + } + +#endif + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/InvokeMethod.cs.meta b/Assets/PlayMaker/Actions/InvokeMethod.cs.meta new file mode 100755 index 0000000..f606ece --- /dev/null +++ b/Assets/PlayMaker/Actions/InvokeMethod.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3a2bdf72fb05ced4294cdb1c5f847fbb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IsKinematic.cs b/Assets/PlayMaker/Actions/IsKinematic.cs new file mode 100755 index 0000000..3466cba --- /dev/null +++ b/Assets/PlayMaker/Actions/IsKinematic.cs @@ -0,0 +1,61 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Tests if a Game Object's Rigid Body is Kinematic.")] + public class IsKinematic : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + + public FsmEvent trueEvent; + + public FsmEvent falseEvent; + + [UIHint(UIHint.Variable)] + public FsmBool store; + + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + trueEvent = null; + falseEvent = null; + store = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoIsKinematic(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoIsKinematic(); + } + + void DoIsKinematic() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + var isKinematic = rigidbody.isKinematic; + store.Value = isKinematic; + Fsm.Event(isKinematic ? trueEvent : falseEvent); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/IsKinematic.cs.meta b/Assets/PlayMaker/Actions/IsKinematic.cs.meta new file mode 100755 index 0000000..82c20a3 --- /dev/null +++ b/Assets/PlayMaker/Actions/IsKinematic.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3cb26a81ea0a0ba4aad053f9de8bd150 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/IsSleeping.cs b/Assets/PlayMaker/Actions/IsSleeping.cs new file mode 100755 index 0000000..b433687 --- /dev/null +++ b/Assets/PlayMaker/Actions/IsSleeping.cs @@ -0,0 +1,61 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Tests if a Game Object's Rigid Body is sleeping.")] + public class IsSleeping : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + + public FsmEvent trueEvent; + + public FsmEvent falseEvent; + + [UIHint(UIHint.Variable)] + public FsmBool store; + + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + trueEvent = null; + falseEvent = null; + store = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoIsSleeping(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoIsSleeping(); + } + + void DoIsSleeping() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + var isSleeping = rigidbody.IsSleeping(); + store.Value = isSleeping; + Fsm.Event(isSleeping ? trueEvent : falseEvent); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/IsSleeping.cs.meta b/Assets/PlayMaker/Actions/IsSleeping.cs.meta new file mode 100755 index 0000000..891fae3 --- /dev/null +++ b/Assets/PlayMaker/Actions/IsSleeping.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0cf2655596bafec45b50c15fe3785020 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/KillDelayedEvents.cs b/Assets/PlayMaker/Actions/KillDelayedEvents.cs new file mode 100755 index 0000000..e3292a5 --- /dev/null +++ b/Assets/PlayMaker/Actions/KillDelayedEvents.cs @@ -0,0 +1,20 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using System; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Note("Kill all queued delayed events.")] + [Tooltip("Kill all queued delayed events. Delayed events are 'fire and forget', but sometimes this can cause problems.")] + [Obsolete("This action is obsolete as of 1.8.0. Delayed events are now cleared when a state exits.")] + public class KillDelayedEvents : FsmStateAction + { + public override void OnEnter() + { + Fsm.KillDelayedEvents(); + + Finish(); + } + } +} diff --git a/Assets/PlayMaker/Actions/KillDelayedEvents.cs.meta b/Assets/PlayMaker/Actions/KillDelayedEvents.cs.meta new file mode 100755 index 0000000..c262169 --- /dev/null +++ b/Assets/PlayMaker/Actions/KillDelayedEvents.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d3c6c502091d64544804c8b322959c48 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/LoadLevel.cs b/Assets/PlayMaker/Actions/LoadLevel.cs new file mode 100755 index 0000000..90ac402 --- /dev/null +++ b/Assets/PlayMaker/Actions/LoadLevel.cs @@ -0,0 +1,116 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if (UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2) +#define UNITY_PRE_5_3 +#endif + +using UnityEngine; +#if !UNITY_PRE_5_3 +using UnityEngine.SceneManagement; +#endif + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Level)] + [Tooltip("Loads a Level by Name. NOTE: Before you can load a level, you have to add it to the list of levels defined in File->Build Settings...")] + public class LoadLevel : FsmStateAction + { + [RequiredField] + [Tooltip("The name of the level to load. NOTE: Must be in the list of levels defined in File->Build Settings... ")] + public FsmString levelName; + + [Tooltip("Load the level additively, keeping the current scene.")] + public bool additive; + + [Tooltip("Load the level asynchronously in the background.")] + public bool async; + + [Tooltip("Event to send when the level has loaded. NOTE: This only makes sense if the FSM is still in the scene!")] + public FsmEvent loadedEvent; + + [Tooltip("Keep this GameObject in the new level. NOTE: The GameObject and components is disabled then enabled on load; uncheck Reset On Disable to keep the active state.")] + public FsmBool dontDestroyOnLoad; + + private AsyncOperation asyncOperation; + + public override void Reset() + { + levelName = ""; + additive = false; + async = false; + loadedEvent = null; + dontDestroyOnLoad = false; + } + + public override void OnEnter() + { + if (dontDestroyOnLoad.Value) + { + // Have to get the root, since this FSM will be destroyed if a parent is destroyed. + + var root = Owner.transform.root; + + Object.DontDestroyOnLoad(root.gameObject); + } + + if (additive) + { + if (async) + { +#if UNITY_PRE_5_3 + asyncOperation = Application.LoadLevelAdditiveAsync(levelName.Value); +#else + asyncOperation = SceneManager.LoadSceneAsync(levelName.Value); +#endif + + Debug.Log("LoadLevelAdditiveAsyc: " + levelName.Value); + + return; // Don't Finish() + } + +#if UNITY_PRE_5_3 + Application.LoadLevelAdditive(levelName.Value); +#else + SceneManager.LoadScene(levelName.Value, LoadSceneMode.Additive); +#endif + + Debug.Log("LoadLevelAdditive: " + levelName.Value); + } + else + if (async) + { +#if UNITY_PRE_5_3 + asyncOperation = Application.LoadLevelAsync(levelName.Value); +#else + asyncOperation = SceneManager.LoadSceneAsync(levelName.Value); +#endif + Debug.Log("LoadLevelAsync: " + levelName.Value); + + return; // Don't Finish() + } + else + { +#if UNITY_PRE_5_3 + Application.LoadLevel(levelName.Value); +#else + SceneManager.LoadScene(levelName.Value); +#endif + Debug.Log("LoadLevel: " + levelName.Value); + } + + Log("LOAD COMPLETE"); + + Fsm.Event(loadedEvent); + Finish(); + } + + public override void OnUpdate() + { + if (asyncOperation.isDone) + { + Fsm.Event(loadedEvent); + Finish(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/LoadLevel.cs.meta b/Assets/PlayMaker/Actions/LoadLevel.cs.meta new file mode 100755 index 0000000..eec30f7 --- /dev/null +++ b/Assets/PlayMaker/Actions/LoadLevel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 30fcd7ba76646434b8562f5b8d7b10d6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/LoadLevelNum.cs b/Assets/PlayMaker/Actions/LoadLevelNum.cs new file mode 100755 index 0000000..214e928 --- /dev/null +++ b/Assets/PlayMaker/Actions/LoadLevelNum.cs @@ -0,0 +1,71 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if (UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2) +#define UNITY_PRE_5_3 +#endif + +using UnityEngine; +#if !UNITY_PRE_5_3 +using UnityEngine.SceneManagement; +#endif + + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Level)] + [Tooltip("Loads a Level by Index number. Before you can load a level, you have to add it to the list of levels defined in File->Build Settings...")] + public class LoadLevelNum : FsmStateAction + { + [RequiredField] + [Tooltip("The level index in File->Build Settings")] + public FsmInt levelIndex; + + [Tooltip("Load the level additively, keeping the current scene.")] + public bool additive; + + [Tooltip("Event to send after the level is loaded.")] + public FsmEvent loadedEvent; + + [Tooltip("Keep this GameObject in the new level. NOTE: The GameObject and components is disabled then enabled on load; uncheck Reset On Disable to keep the active state.")] + public FsmBool dontDestroyOnLoad; + + public override void Reset() + { + levelIndex = null; + additive = false; + loadedEvent = null; + dontDestroyOnLoad = false; + } + + public override void OnEnter() + { + if (dontDestroyOnLoad.Value) + { + // Have to get the root, since this FSM will be destroyed if a parent is destroyed. + + var root = Owner.transform.root; + Object.DontDestroyOnLoad(root.gameObject); + } + + if (additive) + { +#if UNITY_PRE_5_3 + Application.LoadLevelAdditive(levelIndex.Value); +#else + SceneManager.LoadScene(levelIndex.Value, LoadSceneMode.Additive); +#endif + } + else + { +#if UNITY_PRE_5_3 + Application.LoadLevel(levelIndex.Value); +#else + SceneManager.LoadScene(levelIndex.Value); +#endif + } + + Fsm.Event(loadedEvent); + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/LoadLevelNum.cs.meta b/Assets/PlayMaker/Actions/LoadLevelNum.cs.meta new file mode 100755 index 0000000..361864e --- /dev/null +++ b/Assets/PlayMaker/Actions/LoadLevelNum.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4639facb079d91c45afd211dc4427bc7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/LookAt.cs b/Assets/PlayMaker/Actions/LookAt.cs new file mode 100755 index 0000000..161c83a --- /dev/null +++ b/Assets/PlayMaker/Actions/LookAt.cs @@ -0,0 +1,132 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Rotates a Game Object so its forward vector points at a Target. The Target can be specified as a GameObject or a world Position. If you specify both, then Position specifies a local offset from the target object's Position.")] + public class LookAt : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to rotate.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The GameObject to Look At.")] + public FsmGameObject targetObject; + + [Tooltip("World position to look at, or local offset from Target Object if specified.")] + public FsmVector3 targetPosition; + + [Tooltip("Rotate the GameObject to point its up direction vector in the direction hinted at by the Up Vector. See Unity Look At docs for more details.")] + public FsmVector3 upVector; + + [Tooltip("Don't rotate vertically.")] + public FsmBool keepVertical; + + [Title("Draw Debug Line")] + [Tooltip("Draw a debug line from the GameObject to the Target.")] + public FsmBool debug; + + [Tooltip("Color to use for the debug line.")] + public FsmColor debugLineColor; + + [Tooltip("Repeat every frame.")] + public bool everyFrame = true; + + private GameObject go; + private GameObject goTarget; + private Vector3 lookAtPos; + private Vector3 lookAtPosWithVertical; + + public override void Reset() + { + gameObject = null; + targetObject = null; + targetPosition = new FsmVector3 { UseVariable = true}; + upVector = new FsmVector3 { UseVariable = true}; + keepVertical = true; + debug = false; + debugLineColor = Color.yellow; + everyFrame = true; + } + + public override void OnEnter() + { + DoLookAt(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnLateUpdate() + { + DoLookAt(); + } + + void DoLookAt() + { + if (!UpdateLookAtPosition()) + { + return; + } + + go.transform.LookAt(lookAtPos, upVector.IsNone ? Vector3.up : upVector.Value); + + if (debug.Value) + { + Debug.DrawLine(go.transform.position, lookAtPos, debugLineColor.Value); + } + } + + public bool UpdateLookAtPosition() + { + if (Fsm == null) + { + return false; + } + + go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return false; + } + + goTarget = targetObject.Value; + if (goTarget == null && targetPosition.IsNone) + { + return false; + } + + if (goTarget != null) + { + lookAtPos = !targetPosition.IsNone ? goTarget.transform.TransformPoint(targetPosition.Value) : goTarget.transform.position; + } + else + { + lookAtPos = targetPosition.Value; + } + + lookAtPosWithVertical = lookAtPos; + + if (keepVertical.Value) + { + lookAtPos.y = go.transform.position.y; + } + + return true; + } + + public Vector3 GetLookAtPosition() + { + return lookAtPos; + } + + public Vector3 GetLookAtPositionWithVertical() + { + return lookAtPosWithVertical; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/LookAt.cs.meta b/Assets/PlayMaker/Actions/LookAt.cs.meta new file mode 100755 index 0000000..1d423dd --- /dev/null +++ b/Assets/PlayMaker/Actions/LookAt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 15ccc54ff644b4f4482b71efaefc8782 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/MouseLook.cs b/Assets/PlayMaker/Actions/MouseLook.cs new file mode 100755 index 0000000..9a45130 --- /dev/null +++ b/Assets/PlayMaker/Actions/MouseLook.cs @@ -0,0 +1,159 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + /// + /// Action version of Unity's builtin MouseLook behaviour. + /// TODO: Expose invert Y option. + /// + [ActionCategory(ActionCategory.Input)] + [Tooltip("Rotates a GameObject based on mouse movement. Minimum and Maximum values can be used to constrain the rotation.")] + public class MouseLook : FsmStateAction + { + public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 } + + [RequiredField] + [Tooltip("The GameObject to rotate.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The axes to rotate around.")] + public RotationAxes axes = RotationAxes.MouseXAndY; + + [RequiredField] + public FsmFloat sensitivityX; + + [RequiredField] + public FsmFloat sensitivityY; + + [HasFloatSlider(-360,360)] + [Tooltip("Clamp rotation around X axis. Set to None for no clamping.")] + public FsmFloat minimumX; + + [HasFloatSlider(-360, 360)] + [Tooltip("Clamp rotation around X axis. Set to None for no clamping.")] + public FsmFloat maximumX; + + [HasFloatSlider(-360, 360)] + [Tooltip("Clamp rotation around Y axis. Set to None for no clamping.")] + public FsmFloat minimumY; + + [HasFloatSlider(-360, 360)] + [Tooltip("Clamp rotation around Y axis. Set to None for no clamping.")] + public FsmFloat maximumY; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + float rotationX; + float rotationY; + + public override void Reset() + { + gameObject = null; + axes = RotationAxes.MouseXAndY; + sensitivityX = 15f; + sensitivityY = 15f; + minimumX = new FsmFloat {UseVariable = true}; + maximumX = new FsmFloat { UseVariable = true }; + minimumY = -60f; + maximumY = 60f; + everyFrame = true; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + Finish(); + return; + } + + // Make the rigid body not change rotation + // TODO: Original Unity script had this. Expose as option? + var rigidbody = go.GetComponent(); + if (rigidbody != null) + { + rigidbody.freezeRotation = true; + } + + // initialize rotation + + rotationX = go.transform.localRotation.eulerAngles.y; + rotationY = go.transform.localRotation.eulerAngles.x; + + DoMouseLook(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoMouseLook(); + } + + void DoMouseLook() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var transform = go.transform; + + switch (axes) + { + case RotationAxes.MouseXAndY: + + transform.localEulerAngles = new Vector3(GetYRotation(), GetXRotation(), 0); + break; + + case RotationAxes.MouseX: + + transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, GetXRotation(), 0); + break; + + case RotationAxes.MouseY: + + transform.localEulerAngles = new Vector3(-GetYRotation(), transform.localEulerAngles.y, 0); + break; + } + } + + float GetXRotation() + { + rotationX += Input.GetAxis("Mouse X") * sensitivityX.Value; + rotationX = ClampAngle(rotationX, minimumX, maximumX); + return rotationX; + } + + float GetYRotation() + { + rotationY += Input.GetAxis("Mouse Y") * sensitivityY.Value; + rotationY = ClampAngle(rotationY, minimumY, maximumY); + return rotationY; + } + + // Clamp function that respects IsNone + static float ClampAngle(float angle, FsmFloat min, FsmFloat max) + { + if (!min.IsNone && angle < min.Value) + { + angle = min.Value; + } + + if (!max.IsNone && angle > max.Value) + { + angle = max.Value; + } + + return angle; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/MouseLook.cs.meta b/Assets/PlayMaker/Actions/MouseLook.cs.meta new file mode 100755 index 0000000..26d03b9 --- /dev/null +++ b/Assets/PlayMaker/Actions/MouseLook.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9cb5ef034cae1a047b7cc81407619144 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/MouseLook2.cs b/Assets/PlayMaker/Actions/MouseLook2.cs new file mode 100755 index 0000000..342a1ae --- /dev/null +++ b/Assets/PlayMaker/Actions/MouseLook2.cs @@ -0,0 +1,156 @@ +// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + /// + /// Action version of Unity's builtin MouseLook behaviour. + /// TODO: Expose invert Y option. + /// + [ActionCategory(ActionCategory.Input)] + [Tooltip("Rotates a GameObject based on mouse movement. Minimum and Maximum values can be used to constrain the rotation.")] + public class MouseLook2 : ComponentAction + { + public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 } + + [RequiredField] + [Tooltip("The GameObject to rotate.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The axes to rotate around.")] + public RotationAxes axes = RotationAxes.MouseXAndY; + + [RequiredField] + public FsmFloat sensitivityX; + + [RequiredField] + public FsmFloat sensitivityY; + + [RequiredField] + [HasFloatSlider(-360,360)] + public FsmFloat minimumX; + + [RequiredField] + [HasFloatSlider(-360, 360)] + public FsmFloat maximumX; + + [RequiredField] + [HasFloatSlider(-360, 360)] + public FsmFloat minimumY; + + [RequiredField] + [HasFloatSlider(-360, 360)] + public FsmFloat maximumY; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + float rotationX; + float rotationY; + + public override void Reset() + { + gameObject = null; + axes = RotationAxes.MouseXAndY; + sensitivityX = 15f; + sensitivityY = 15f; + minimumX = -360f; + maximumX = 360f; + minimumY = -60f; + maximumY = 60f; + everyFrame = true; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + Finish(); + return; + } + + // Make the rigid body not change rotation + // TODO: Original Unity script had this. Expose as option? + if (!UpdateCache(go)) + { + if (rigidbody) + { + rigidbody.freezeRotation = true; + } + } + + DoMouseLook(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoMouseLook(); + } + + void DoMouseLook() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var transform = go.transform; + + switch (axes) + { + case RotationAxes.MouseXAndY: + + transform.localEulerAngles = new Vector3(GetYRotation(), GetXRotation(), 0); + break; + + case RotationAxes.MouseX: + + transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, GetXRotation(), 0); + break; + + case RotationAxes.MouseY: + + transform.localEulerAngles = new Vector3(-GetYRotation(), transform.localEulerAngles.y, 0); + break; + } + } + + float GetXRotation() + { + rotationX += Input.GetAxis("Mouse X") * sensitivityX.Value; + rotationX = ClampAngle(rotationX, minimumX, maximumX); + return rotationX; + } + + float GetYRotation() + { + rotationY += Input.GetAxis("Mouse Y") * sensitivityY.Value; + rotationY = ClampAngle(rotationY, minimumY, maximumY); + return rotationY; + } + + // Clamp function that respects IsNone + static float ClampAngle(float angle, FsmFloat min, FsmFloat max) + { + if (!min.IsNone && angle < min.Value) + { + angle = min.Value; + } + + if (!max.IsNone && angle > max.Value) + { + angle = max.Value; + } + + return angle; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/MouseLook2.cs.meta b/Assets/PlayMaker/Actions/MouseLook2.cs.meta new file mode 100755 index 0000000..e384b48 --- /dev/null +++ b/Assets/PlayMaker/Actions/MouseLook2.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 917ad6be8c2f4ef4ba0cdda783e0a581 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/MousePick.cs b/Assets/PlayMaker/Actions/MousePick.cs new file mode 100755 index 0000000..a84d868 --- /dev/null +++ b/Assets/PlayMaker/Actions/MousePick.cs @@ -0,0 +1,81 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Perform a Mouse Pick on the scene and stores the results. Use Ray Distance to set how close the camera must be to pick the object.")] + public class MousePick : FsmStateAction + { + [RequiredField] + public FsmFloat rayDistance = 100f; + [UIHint(UIHint.Variable)] + public FsmBool storeDidPickObject; + [UIHint(UIHint.Variable)] + public FsmGameObject storeGameObject; + [UIHint(UIHint.Variable)] + public FsmVector3 storePoint; + [UIHint(UIHint.Variable)] + public FsmVector3 storeNormal; + [UIHint(UIHint.Variable)] + public FsmFloat storeDistance; + [UIHint(UIHint.Layer)] + [Tooltip("Pick only from these layers.")] + public FsmInt[] layerMask; + [Tooltip("Invert the mask, so you pick from all layers except those defined above.")] + public FsmBool invertMask; + public bool everyFrame; + + public override void Reset() + { + rayDistance = 100f; + storeDidPickObject = null; + storeGameObject = null; + storePoint = null; + storeNormal = null; + storeDistance = null; + layerMask = new FsmInt[0]; + invertMask = false; + everyFrame = false; + } + + public override void OnEnter() + { + DoMousePick(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoMousePick(); + } + + void DoMousePick() + { + RaycastHit hitInfo = ActionHelpers.MousePick(rayDistance.Value, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value)); + + bool didPick = hitInfo.collider != null; + storeDidPickObject.Value = didPick; + + if (didPick) + { + storeGameObject.Value = hitInfo.collider.gameObject; + storeDistance.Value = hitInfo.distance; + storePoint.Value = hitInfo.point; + storeNormal.Value = hitInfo.normal; + } + else + { + // TODO: not sure if this is the right strategy... + storeGameObject.Value = null; + storeDistance.Value = Mathf.Infinity; + storePoint.Value = Vector3.zero; + storeNormal.Value = Vector3.zero; + } + + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/MousePick.cs.meta b/Assets/PlayMaker/Actions/MousePick.cs.meta new file mode 100755 index 0000000..dc743aa --- /dev/null +++ b/Assets/PlayMaker/Actions/MousePick.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a1a621564b617384ab7a2070baf811e4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/MousePickEvent.cs b/Assets/PlayMaker/Actions/MousePickEvent.cs new file mode 100755 index 0000000..0e7f3bc --- /dev/null +++ b/Assets/PlayMaker/Actions/MousePickEvent.cs @@ -0,0 +1,124 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Sends Events based on mouse interactions with a Game Object: MouseOver, MouseDown, MouseUp, MouseOff. Use Ray Distance to set how close the camera must be to pick the object.")] + public class MousePickEvent : FsmStateAction + { + [CheckForComponent(typeof(Collider))] + public FsmOwnerDefault GameObject; + + [Tooltip("Length of the ray to cast from the camera.")] + public FsmFloat rayDistance = 100f; + + [Tooltip("Event to send when the mouse is over the GameObject.")] + public FsmEvent mouseOver; + + [Tooltip("Event to send when the mouse is pressed while over the GameObject.")] + public FsmEvent mouseDown; + + [Tooltip("Event to send when the mouse is released while over the GameObject.")] + public FsmEvent mouseUp; + + [Tooltip("Event to send when the mouse moves off the GameObject.")] + public FsmEvent mouseOff; + + [Tooltip("Pick only from these layers.")] + [UIHint(UIHint.Layer)] + public FsmInt[] layerMask; + + [Tooltip("Invert the mask, so you pick from all layers except those defined above.")] + public FsmBool invertMask; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + GameObject = null; + rayDistance = 100f; + mouseOver = null; + mouseDown = null; + mouseUp = null; + mouseOff = null; + layerMask = new FsmInt[0]; + invertMask = false; + everyFrame = true; + } + + public override void OnEnter() + { + DoMousePickEvent(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoMousePickEvent(); + } + + void DoMousePickEvent() + { + // Do the raycast + + bool isMouseOver = DoRaycast(); + + // Store mouse pick info so it can be seen by Get Raycast Hit Info action + + Fsm.RaycastHitInfo = ActionHelpers.mousePickInfo; + + // Send events based on the raycast and mouse buttons + + if (isMouseOver) + { + if (mouseDown != null && Input.GetMouseButtonDown(0)) + { + Fsm.Event(mouseDown); + } + + if (mouseOver != null) + { + Fsm.Event(mouseOver); + } + + if (mouseUp != null &&Input.GetMouseButtonUp(0)) + { + Fsm.Event(mouseUp); + } + } + else + { + if (mouseOff != null) + { + Fsm.Event(mouseOff); + } + } + } + + bool DoRaycast() + { + var testObject = GameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : GameObject.GameObject.Value; + + // ActionHelpers uses a cache to try and minimize Raycasts + + return ActionHelpers.IsMouseOver(testObject, rayDistance.Value, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value)); + } + + public override string ErrorCheck() + { + string errorString = ""; + + errorString += ActionHelpers.CheckRayDistance(rayDistance.Value); + errorString += ActionHelpers.CheckPhysicsSetup(GameObject); + + return errorString; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/MousePickEvent.cs.meta b/Assets/PlayMaker/Actions/MousePickEvent.cs.meta new file mode 100755 index 0000000..1f14f98 --- /dev/null +++ b/Assets/PlayMaker/Actions/MousePickEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f57b13daeba15d04a866bba900f88858 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/MoveObject.cs b/Assets/PlayMaker/Actions/MoveObject.cs new file mode 100755 index 0000000..2486ede --- /dev/null +++ b/Assets/PlayMaker/Actions/MoveObject.cs @@ -0,0 +1,77 @@ +// Thanks to A3DStudio + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [HelpUrl("http://hutonggames.com/playmakerforum/index.php?topic=4758.0")] + [Tooltip("Move a GameObject to another GameObject. Works like iTween Move To, but with better performance.")] + public class MoveObject: EaseFsmAction + { + [RequiredField] + public FsmOwnerDefault objectToMove; + [RequiredField] + public FsmGameObject destination; + + private FsmVector3 fromValue; + private FsmVector3 toVector; + private FsmVector3 fromVector; + + private bool finishInNextStep; + + public override void Reset () + { + fromValue = null; + toVector = null; + finishInNextStep = false; + fromVector = null; + } + + + public override void OnEnter () + { + var go = Fsm.GetOwnerDefaultTarget(objectToMove); + fromVector = go.transform.position; + toVector = destination.Value.transform.position; + + fromFloats = new float[3]; + fromFloats[0] = fromVector.Value.x; + fromFloats[1] = fromVector.Value.y; + fromFloats[2] = fromVector.Value.z; + + toFloats = new float[3]; + toFloats[0] = toVector.Value.x; + toFloats[1] = toVector.Value.y; + toFloats[2] = toVector.Value.z; + resultFloats = new float[3]; + + resultFloats[0] = fromVector.Value.x; + resultFloats[1] = fromVector.Value.y; + resultFloats[2] = fromVector.Value.z; + + finishInNextStep = false; + } + + public override void OnUpdate() + { + var go = Fsm.GetOwnerDefaultTarget(objectToMove); + go.transform.position = new Vector3(resultFloats[0],resultFloats[1],resultFloats[2]); + + if(finishInNextStep){ + Finish(); + if(finishEvent != null) Fsm.Event(finishEvent); + } + + if(finishAction && !finishInNextStep) + { + go.transform.position = new Vector3(reverse.IsNone ? toVector.Value.x : reverse.Value ? fromValue.Value.x : toVector.Value.x, + reverse.IsNone ? toVector.Value.y : reverse.Value ? fromValue.Value.y : toVector.Value.y, + reverse.IsNone ? toVector.Value.z : reverse.Value ? fromValue.Value.z : toVector.Value.z + ); + finishInNextStep = true; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/MoveObject.cs.meta b/Assets/PlayMaker/Actions/MoveObject.cs.meta new file mode 100755 index 0000000..1f13403 --- /dev/null +++ b/Assets/PlayMaker/Actions/MoveObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 87d639c82dbaec8468ab9dbe7f92ebb3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/MovePosition.cs b/Assets/PlayMaker/Actions/MovePosition.cs new file mode 100755 index 0000000..661804c --- /dev/null +++ b/Assets/PlayMaker/Actions/MovePosition.cs @@ -0,0 +1,92 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +/* +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Moves a Game Object's Rigid Body to a new position. To leave any axis unchanged, set variable to 'None'.")] + public class MovePosition : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.Variable)] + public FsmVector3 vector; + public FsmFloat x; + public FsmFloat y; + public FsmFloat z; + public Space space; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + vector = null; + // default axis to variable dropdown with None selected. + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + z = new FsmFloat { UseVariable = true }; + space = Space.Self; + everyFrame = false; + } + + /* Transform scale doesn't stick in OnEnter + * TODO: figure out why... + public override void OnEnter() + { + DoSetPosition(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoMovePosition(); + + if (!everyFrame) + Finish(); + } + + void DoMovePosition() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + if (go.rigidbody == null) return; + + // init position + + Vector3 position; + + if (vector.IsNone) + { + if (space == Space.World) + position = go.rigidbody.position; + else + position = go.transform.TransformPoint(go.rigidbody.position); + } + else + { + position = vector.Value; + } + + // override any axis + + if (!x.IsNone) position.x = x.Value; + if (!y.IsNone) position.y = y.Value; + if (!z.IsNone) position.z = z.Value; + + // apply + + if (space == Space.World) + go.rigidbody.MovePosition(position); + else + go.rigidbody.MovePosition(go.transform.InverseTransformPoint(position)) + } + + + } +} +*/ \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/MovePosition.cs.meta b/Assets/PlayMaker/Actions/MovePosition.cs.meta new file mode 100755 index 0000000..6a266cc --- /dev/null +++ b/Assets/PlayMaker/Actions/MovePosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5bb25ceaaf938934abd268a5414376f3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/MoveTowards.cs b/Assets/PlayMaker/Actions/MoveTowards.cs new file mode 100755 index 0000000..353c7b2 --- /dev/null +++ b/Assets/PlayMaker/Actions/MoveTowards.cs @@ -0,0 +1,116 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Moves a Game Object towards a Target. Optionally sends an event when successful. The Target can be specified as a Game Object or a world Position. If you specify both, then the Position is used as a local offset from the Object's Position.")] + public class MoveTowards : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to Move")] + public FsmOwnerDefault gameObject; + + [Tooltip("A target GameObject to move towards. Or use a world Target Position below.")] + public FsmGameObject targetObject; + + [Tooltip("A world position if no Target Object. Otherwise used as a local offset from the Target Object.")] + public FsmVector3 targetPosition; + + [Tooltip("Ignore any height difference in the target.")] + public FsmBool ignoreVertical; + + [HasFloatSlider(0, 20)] + [Tooltip("The maximum movement speed. HINT: You can make this a variable to change it over time.")] + public FsmFloat maxSpeed; + + [HasFloatSlider(0, 5)] + [Tooltip("Distance at which the move is considered finished, and the Finish Event is sent.")] + public FsmFloat finishDistance; + + [Tooltip("Event to send when the Finish Distance is reached.")] + public FsmEvent finishEvent; + + private GameObject go; + private GameObject goTarget; + private Vector3 targetPos; + private Vector3 targetPosWithVertical; + + public override void Reset() + { + gameObject = null; + targetObject = null; + maxSpeed = 10f; + finishDistance = 1f; + finishEvent = null; + } + + public override void OnUpdate() + { + DoMoveTowards(); + } + + void DoMoveTowards() + { + if (!UpdateTargetPos()) + { + return; + } + + go.transform.position = Vector3.MoveTowards(go.transform.position, targetPos, maxSpeed.Value * Time.deltaTime); + + var distance = (go.transform.position - targetPos).magnitude; + if (distance < finishDistance.Value) + { + Fsm.Event(finishEvent); + Finish(); + } + } + + public bool UpdateTargetPos() + { + go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return false; + } + + goTarget = targetObject.Value; + if (goTarget == null && targetPosition.IsNone) + { + return false; + } + + if (goTarget != null) + { + targetPos = !targetPosition.IsNone ? + goTarget.transform.TransformPoint(targetPosition.Value) : + goTarget.transform.position; + } + else + { + targetPos = targetPosition.Value; + } + + targetPosWithVertical = targetPos; + + if (ignoreVertical.Value) + { + targetPos.y = go.transform.position.y; + } + + return true; + } + + public Vector3 GetTargetPos() + { + return targetPos; + } + + public Vector3 GetTargetPosWithVertical() + { + return targetPosWithVertical; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/MoveTowards.cs.meta b/Assets/PlayMaker/Actions/MoveTowards.cs.meta new file mode 100755 index 0000000..127008f --- /dev/null +++ b/Assets/PlayMaker/Actions/MoveTowards.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2fa8dc1498e42734f9ce0ef695e29697 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/MovieTextureAudioSettings.cs b/Assets/PlayMaker/Actions/MovieTextureAudioSettings.cs new file mode 100755 index 0000000..2ca7e9e --- /dev/null +++ b/Assets/PlayMaker/Actions/MovieTextureAudioSettings.cs @@ -0,0 +1,53 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_FLASH || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE || UNITY_BLACKBERRY || UNITY_WP8 || UNITY_PSM || UNITY_WEBGL) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Movie)] + [Tooltip("Sets the Game Object as the Audio Source associated with the Movie Texture. The Game Object must have an AudioSource Component.")] + public class MovieTextureAudioSettings : FsmStateAction + { + [RequiredField] + [ObjectType(typeof(MovieTexture))] + public FsmObject movieTexture; + + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + public FsmGameObject gameObject; + + // this gets overridden by AudioPlay... + //public FsmFloat volume; + + public override void Reset() + { + movieTexture = null; + gameObject = null; + //volume = 1; + } + + public override void OnEnter() + { + var movie = movieTexture.Value as MovieTexture; + + if (movie != null && gameObject.Value != null) + { + var audio = gameObject.Value.GetComponent(); + if (audio != null) + { + audio.clip = movie.audioClip; + + //if (!volume.IsNone) + // audio.volume = volume.Value; + } + } + + Finish(); + } + } +} + +#endif + diff --git a/Assets/PlayMaker/Actions/MovieTextureAudioSettings.cs.meta b/Assets/PlayMaker/Actions/MovieTextureAudioSettings.cs.meta new file mode 100755 index 0000000..7309dba --- /dev/null +++ b/Assets/PlayMaker/Actions/MovieTextureAudioSettings.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7aa1526fff0dd6849a045425bad3900f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network.meta b/Assets/PlayMaker/Actions/Network.meta new file mode 100644 index 0000000..bc4a6e2 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0bbd22fe5a0f0466ea9a6d94d826c3dc +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerClearHostList.cs b/Assets/PlayMaker/Actions/Network/MasterServerClearHostList.cs new file mode 100755 index 0000000..019f559 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerClearHostList.cs @@ -0,0 +1,24 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Clear the host list which was received by MasterServer Request Host List")] + public class MasterServerClearHostList : FsmStateAction + { + + public override void OnEnter() + { + MasterServer.ClearHostList(); + + Finish(); + + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerClearHostList.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerClearHostList.cs.meta new file mode 100755 index 0000000..cd79acc --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerClearHostList.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 11a86ba96bae55f4b92e8367d045dafc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerGetHostCount.cs b/Assets/PlayMaker/Actions/Network/MasterServerGetHostCount.cs new file mode 100755 index 0000000..8d87077 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerGetHostCount.cs @@ -0,0 +1,27 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the number of hosts on the master server.\n\nUse MasterServer Get Host Data to get host data at a specific index.")] + public class MasterServerGetHostCount : FsmStateAction + { + [RequiredField] + [Tooltip("The number of hosts on the MasterServer.")] + [UIHint(UIHint.Variable)] + public FsmInt count; + + public override void OnEnter() + { + count.Value = MasterServer.PollHostList().Length; + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerGetHostCount.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerGetHostCount.cs.meta new file mode 100755 index 0000000..e642b36 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerGetHostCount.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 57f7710982e566c4ebfb19c4a3971b59 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerGetHostData.cs b/Assets/PlayMaker/Actions/Network/MasterServerGetHostData.cs new file mode 100755 index 0000000..1858e08 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerGetHostData.cs @@ -0,0 +1,115 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get host data from the master server.")] + public class MasterServerGetHostData : FsmStateAction + { + [RequiredField] + [Tooltip("The index into the MasterServer Host List")] + public FsmInt hostIndex; + + //[ActionSection("Result")] + + [Tooltip("Does this server require NAT punchthrough?")] + [UIHint(UIHint.Variable)] + public FsmBool useNat; + + [Tooltip("The type of the game (e.g., 'MyUniqueGameType')")] + [UIHint(UIHint.Variable)] + public FsmString gameType; + + [Tooltip("The name of the game (e.g., 'John Does's Game')")] + [UIHint(UIHint.Variable)] + public FsmString gameName; + + [Tooltip("Currently connected players")] + [UIHint(UIHint.Variable)] + public FsmInt connectedPlayers; + + [Tooltip("Maximum players limit")] + [UIHint(UIHint.Variable)] + public FsmInt playerLimit; + + [Tooltip("Server IP address.")] + [UIHint(UIHint.Variable)] + public FsmString ipAddress; + + [Tooltip("Server port")] + [UIHint(UIHint.Variable)] + public FsmInt port; + + [Tooltip("Does the server require a password?")] + [UIHint(UIHint.Variable)] + public FsmBool passwordProtected; + + [Tooltip("A miscellaneous comment (can hold data)")] + [UIHint(UIHint.Variable)] + public FsmString comment; + + [Tooltip("The GUID of the host, needed when connecting with NAT punchthrough.")] + [UIHint(UIHint.Variable)] + public FsmString guid; + + public override void Reset() + { + hostIndex = null; + useNat = null; + gameType = null; + gameName = null; + connectedPlayers = null; + playerLimit = null; + ipAddress = null; + port = null; + passwordProtected = null; + comment = null; + guid = null; + } + + public override void OnEnter() + { + GetHostData(); + + Finish(); + } + + void GetHostData() + { + int _count = MasterServer.PollHostList().Length; + + int _index = hostIndex.Value; + + if (_index<0 || _index>=_count) + { + LogError("MasterServer Host index out of range!"); + return; + } + + HostData _hostData = MasterServer.PollHostList()[_index]; + + if (_hostData == null) + { + LogError("MasterServer HostData could not found at index "+_index); + return; + } + + useNat.Value = _hostData.useNat; + gameType.Value = _hostData.gameType; + gameName.Value = _hostData.gameName; + connectedPlayers.Value = _hostData.connectedPlayers; + playerLimit.Value = _hostData.playerLimit; + ipAddress.Value = _hostData.ip[0]; + port.Value = _hostData.port; + passwordProtected.Value = _hostData.passwordProtected; + comment.Value = _hostData.comment; + guid.Value = _hostData.guid; + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerGetHostData.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerGetHostData.cs.meta new file mode 100755 index 0000000..3b2fe9e --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerGetHostData.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 95dc0a3d8ed6fe74d8ec33dfb13773ae +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerGetNextHostData.cs b/Assets/PlayMaker/Actions/Network/MasterServerGetNextHostData.cs new file mode 100755 index 0000000..eceb92a --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerGetNextHostData.cs @@ -0,0 +1,146 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the next host data from the master server. \nEach time this action is called it gets the next connected host." + + "This lets you quickly loop through all the connected hosts to get information on each one.")] + public class MasterServerGetNextHostData : FsmStateAction + { + + [ActionSection("Set up")] + + [Tooltip("Event to send for looping.")] + public FsmEvent loopEvent; + + [Tooltip("Event to send when there are no more hosts.")] + public FsmEvent finishedEvent; + + [ActionSection("Result")] + + [Tooltip("The index into the MasterServer Host List")] + [UIHint(UIHint.Variable)] + public FsmInt index; + + [Tooltip("Does this server require NAT punchthrough?")] + [UIHint(UIHint.Variable)] + public FsmBool useNat; + + [Tooltip("The type of the game (e.g., 'MyUniqueGameType')")] + [UIHint(UIHint.Variable)] + public FsmString gameType; + + [Tooltip("The name of the game (e.g., 'John Does's Game')")] + [UIHint(UIHint.Variable)] + public FsmString gameName; + + [Tooltip("Currently connected players")] + [UIHint(UIHint.Variable)] + public FsmInt connectedPlayers; + + [Tooltip("Maximum players limit")] + [UIHint(UIHint.Variable)] + public FsmInt playerLimit; + + [Tooltip("Server IP address.")] + [UIHint(UIHint.Variable)] + public FsmString ipAddress; + + [Tooltip("Server port")] + [UIHint(UIHint.Variable)] + public FsmInt port; + + [Tooltip("Does the server require a password?")] + [UIHint(UIHint.Variable)] + public FsmBool passwordProtected; + + [Tooltip("A miscellaneous comment (can hold data)")] + [UIHint(UIHint.Variable)] + public FsmString comment; + + [Tooltip("The GUID of the host, needed when connecting with NAT punchthrough.")] + [UIHint(UIHint.Variable)] + public FsmString guid; + + // increment a child index as we loop through children + private int nextItemIndex; + + // are we there yet? + private bool noMoreItems; + + public override void Reset() + { + finishedEvent = null; + loopEvent = null; + + index = null; + useNat = null; + gameType = null; + gameName = null; + connectedPlayers = null; + playerLimit = null; + ipAddress = null; + port = null; + passwordProtected = null; + comment = null; + guid = null; + } + + public override void OnEnter() + { + + DoGetNextHostData(); + + Finish(); + } + + void DoGetNextHostData() + { + // no more items? + + if (nextItemIndex >= MasterServer.PollHostList().Length) + { + nextItemIndex = 0; + Fsm.Event(finishedEvent); + return; + } + + // get next item + HostData _hostData = MasterServer.PollHostList()[nextItemIndex]; + + index.Value = nextItemIndex; + useNat.Value = _hostData.useNat; + gameType.Value = _hostData.gameType; + gameName.Value = _hostData.gameName; + connectedPlayers.Value = _hostData.connectedPlayers; + playerLimit.Value = _hostData.playerLimit; + ipAddress.Value = _hostData.ip[0]; + port.Value = _hostData.port; + passwordProtected.Value = _hostData.passwordProtected; + comment.Value = _hostData.comment; + guid.Value = _hostData.guid; + + // no more items? + + if (nextItemIndex >= MasterServer.PollHostList().Length) + { + Fsm.Event(finishedEvent); + nextItemIndex = 0; + return; + } + + // iterate to next + nextItemIndex++; + + if (loopEvent!=null){ + Fsm.Event(loopEvent); + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerGetNextHostData.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerGetNextHostData.cs.meta new file mode 100755 index 0000000..878ba80 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerGetNextHostData.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cca3e75f9ca1b7441816825153864b32 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerGetProperties.cs b/Assets/PlayMaker/Actions/Network/MasterServerGetProperties.cs new file mode 100755 index 0000000..b5d9dd5 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerGetProperties.cs @@ -0,0 +1,76 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the IP address, port, update rate and dedicated server flag of the master server and store in variables.")] + public class MasterServerGetProperties : FsmStateAction + { + + [Tooltip("The IP address of the master server.")] + [UIHint(UIHint.Variable)] + public FsmString ipAddress; + + [Tooltip("The connection port of the master server.")] + [UIHint(UIHint.Variable)] + public FsmInt port; + + [Tooltip("The minimum update rate for master server host information update. Default is 60 seconds")] + [UIHint(UIHint.Variable)] + public FsmInt updateRate; + + [Tooltip("Flag to report if this machine is a dedicated server.")] + [UIHint(UIHint.Variable)] + public FsmBool dedicatedServer; + + [Tooltip("Event sent if this machine is a dedicated server")] + public FsmEvent isDedicatedServerEvent; + + [Tooltip("Event sent if this machine is not a dedicated server")] + public FsmEvent isNotDedicatedServerEvent; + + public override void Reset() + { + ipAddress = null; + port = null; + updateRate = null; + dedicatedServer = null; + isDedicatedServerEvent = null; + isNotDedicatedServerEvent = null; + } + + public override void OnEnter() + { + GetMasterServerProperties(); + + Finish(); + } + + void GetMasterServerProperties() + { + ipAddress.Value = MasterServer.ipAddress; + port.Value = MasterServer.port; + updateRate.Value = MasterServer.updateRate; + + bool _dedicated = MasterServer.dedicatedServer; + + dedicatedServer.Value = _dedicated; + + if (_dedicated && isDedicatedServerEvent != null) + { + Fsm.Event(isDedicatedServerEvent); + } + + if (!_dedicated && isNotDedicatedServerEvent !=null) + { + Fsm.Event(isNotDedicatedServerEvent); + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerGetProperties.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerGetProperties.cs.meta new file mode 100755 index 0000000..9e8a01a --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerGetProperties.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 33d3417b8cff8864d82ca7b3de9ce2b4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerRegisterHost.cs b/Assets/PlayMaker/Actions/Network/MasterServerRegisterHost.cs new file mode 100755 index 0000000..676e1d8 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerRegisterHost.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Register this server on the master server.\n\n" + + "If the master server address information has not been changed the default Unity master server will be used.")] + public class MasterServerRegisterHost : FsmStateAction + { + [RequiredField] + [Tooltip("The unique game type name.")] + public FsmString gameTypeName; + + [RequiredField] + [Tooltip("The game name.")] + public FsmString gameName; + + [Tooltip("Optional comment")] + public FsmString comment; + + public override void Reset() + { + gameTypeName = null; + gameName = null; + comment = null; + } + + public override void OnEnter() + { + DoMasterServerRegisterHost(); + + Finish(); + } + + void DoMasterServerRegisterHost() + { + MasterServer.RegisterHost(gameTypeName.Value,gameName.Value,comment.Value); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerRegisterHost.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerRegisterHost.cs.meta new file mode 100755 index 0000000..cb19f4d --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerRegisterHost.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3470941e93c737446b4c1d5b61b12b10 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerRequestHostList.cs b/Assets/PlayMaker/Actions/Network/MasterServerRequestHostList.cs new file mode 100755 index 0000000..5fbe731 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerRequestHostList.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Request a host list from the master server.\n\n" + + "Use MasterServer Get Host Data to get info on each host in the host list.")] + public class MasterServerRequestHostList : FsmStateAction + { + [RequiredField] + [Tooltip("The unique game type name.")] + public FsmString gameTypeName; + + [Tooltip("Event sent when the host list has arrived. NOTE: The action will not Finish until the host list arrives.")] + public FsmEvent HostListArrivedEvent; + + public override void Reset() + { + gameTypeName = null; + HostListArrivedEvent = null; + } + + public override void OnEnter() + { + DoMasterServerRequestHost(); + } + + public override void OnUpdate() + { + WatchServerRequestHost(); + } + + void DoMasterServerRequestHost() + { + MasterServer.ClearHostList(); + + MasterServer.RequestHostList(gameTypeName.Value); + } + + void WatchServerRequestHost() + { + if (MasterServer.PollHostList().Length != 0) + { + Fsm.Event(HostListArrivedEvent); + Finish(); + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerRequestHostList.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerRequestHostList.cs.meta new file mode 100755 index 0000000..6e8ebeb --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerRequestHostList.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c8d24af52987882458fde8bb145f3db0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerSetProperties.cs b/Assets/PlayMaker/Actions/Network/MasterServerSetProperties.cs new file mode 100755 index 0000000..1ac19ec --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerSetProperties.cs @@ -0,0 +1,53 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Set the IP address, port, update rate and dedicated server flag of the master server.")] + public class MasterServerSetProperties : FsmStateAction + { + [Tooltip("Set the IP address of the master server.")] + public FsmString ipAddress; + + [Tooltip("Set the connection port of the master server.")] + public FsmInt port; + + [Tooltip("Set the minimum update rate for master server host information update. Default is 60 seconds.")] + public FsmInt updateRate; + + [Tooltip("Set if this machine is a dedicated server.")] + public FsmBool dedicatedServer; + + public override void Reset() + { + ipAddress = "127.0.0.1"; + port = 10002; + updateRate = 60; + dedicatedServer = false; + } + + public override void OnEnter() + { + SetMasterServerProperties(); + + Finish(); + } + + void SetMasterServerProperties() + { + MasterServer.ipAddress = ipAddress.Value; + + MasterServer.port = port.Value; + + MasterServer.updateRate = updateRate.Value; + + MasterServer.dedicatedServer = dedicatedServer.Value; + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerSetProperties.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerSetProperties.cs.meta new file mode 100755 index 0000000..bdbb12b --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerSetProperties.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dcf0aa2e1a8928243aee63e8957a0430 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/MasterServerUnregisterHost.cs b/Assets/PlayMaker/Actions/Network/MasterServerUnregisterHost.cs new file mode 100755 index 0000000..6117b92 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerUnregisterHost.cs @@ -0,0 +1,23 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Unregister this server from the master server.\n\n" + + "Does nothing if the server is not registered or has already unregistered.")] + public class MasterServerUnregisterHost : FsmStateAction + { + public override void OnEnter() + { + MasterServer.UnregisterHost(); + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/MasterServerUnregisterHost.cs.meta b/Assets/PlayMaker/Actions/Network/MasterServerUnregisterHost.cs.meta new file mode 100755 index 0000000..d1e6cde --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/MasterServerUnregisterHost.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 370d3fe4eb2acb9478d3ede8245f7919 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkCloseConnection.cs b/Assets/PlayMaker/Actions/Network/NetworkCloseConnection.cs new file mode 100755 index 0000000..b52399f --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkCloseConnection.cs @@ -0,0 +1,91 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Close the connection to another system.\n\nConnection index defines which system to close the connection to (from the Network connections array).\n" + + "Can define connection to close via Guid if index is unknown. \n" + + "If we are a client the only possible connection to close is the server connection, if we are a server the target player will be kicked off. \n\n" + + "Send Disconnection Notification enables or disables notifications being sent to the other end. " + + "If disabled the connection is dropped, if not a disconnect notification is reliably sent to the remote party and there after the connection is dropped.")] + public class NetworkCloseConnection : FsmStateAction + { + + [Tooltip("Connection index to close")] + [UIHint(UIHint.Variable)] + public FsmInt connectionIndex; + + [Tooltip("Connection GUID to close. Used If Index is not set.")] + [UIHint(UIHint.Variable)] + public FsmString connectionGUID; + + [Tooltip("If True, send Disconnection Notification")] + public bool sendDisconnectionNotification; + + public override void Reset() + { + connectionIndex = 0; + connectionGUID = null; + + sendDisconnectionNotification = true; + } + + public override void OnEnter() + { + + + int index = 0; + + if (!connectionIndex.IsNone) + { + index = connectionIndex.Value; + + }else if (!connectionGUID.IsNone){ + + //find the index of this guid. + int guidIndex; + + if ( getIndexFromGUID(connectionGUID.Value,out guidIndex) ) + { + index = guidIndex; + } + + + } + + if (index < 0 || index > Network.connections.Length) + { + LogError("Connection index out of range: " +index); + } + else + { + Network.CloseConnection(Network.connections[index], sendDisconnectionNotification); + } + + Finish(); + } + + bool getIndexFromGUID(string guid,out int guidIndex) + { + + for(int i=0;i + { + [RequiredField] + [CheckForComponent(typeof(NetworkView))] + [Tooltip("The Game Object to destroy.\nNOTE: The Game Object must have a NetworkView attached.")] + public FsmOwnerDefault gameObject; + + [Tooltip("Remove all RPC calls associated with the Game Object.")] + public FsmBool removeRPCs; + + public override void Reset() + { + gameObject = null; + removeRPCs = true; + } + + public override void OnEnter() + { + DoDestroy(); + + Finish(); + } + + void DoDestroy() + { + // get the target + var targetGo = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(targetGo)) + { + return; + } + + if (removeRPCs.Value) + { + Network.RemoveRPCs(networkView.owner); + } + Network.DestroyPlayerObjects(networkView.owner); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkDestroy.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkDestroy.cs.meta new file mode 100755 index 0000000..4f5e810 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkDestroy.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 60d777b76f74a034684c8dfcb2e565d8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkDisconnect.cs b/Assets/PlayMaker/Actions/Network/NetworkDisconnect.cs new file mode 100755 index 0000000..ec89780 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkDisconnect.cs @@ -0,0 +1,23 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Disconnect from the server.")] + public class NetworkDisconnect : FsmStateAction + { + + public override void OnEnter() + { + Network.Disconnect(); + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkDisconnect.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkDisconnect.cs.meta new file mode 100755 index 0000000..404fb29 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkDisconnect.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b1654a5bf4a568d4f9c6f276e678ea36 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetAveragePing.cs b/Assets/PlayMaker/Actions/Network/NetworkGetAveragePing.cs new file mode 100755 index 0000000..a8b8589 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetAveragePing.cs @@ -0,0 +1,100 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the last average ping time to the given player in milliseconds. \n" + + "If the player can't be found -1 will be returned. Pings are automatically sent out every couple of seconds.")] + public class NetworkGetPlayerPing : FsmStateAction + { + [ActionSection("Setup")] + + [RequiredField] + [Tooltip("The Index of the player in the network connections list.")] + [UIHint(UIHint.Variable)] + public FsmInt playerIndex; + + [Tooltip("The player reference is cached, that is if the connections list changes, the player reference remains.")] + public bool cachePlayerReference = true; + + public bool everyFrame; + + [ActionSection("Result")] + + [RequiredField] + [Tooltip("Get the last average ping time to the given player in milliseconds.")] + [UIHint(UIHint.Variable)] + public FsmInt averagePing; + + [Tooltip("Event to send if the player can't be found. Average Ping is set to -1.")] + public FsmEvent PlayerNotFoundEvent; + + [Tooltip("Event to send if the player is found (pings back).")] + public FsmEvent PlayerFoundEvent; + + + private NetworkPlayer _player; + + public override void Reset() + { + playerIndex = null; + averagePing = null; + PlayerNotFoundEvent = null; + PlayerFoundEvent = null; + cachePlayerReference = true; + everyFrame = false; + } + + public override void OnEnter() + { + if (cachePlayerReference) + { + _player = Network.connections[playerIndex.Value]; + } + + GetAveragePing(); + + if(!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + GetAveragePing(); + } + + void GetAveragePing() + { + + if (!cachePlayerReference) + { + _player = Network.connections[playerIndex.Value]; + } + + int _averagePing = Network.GetAveragePing(_player); + if (!averagePing.IsNone) + { + averagePing.Value = _averagePing; + } + + if (_averagePing ==-1 && PlayerNotFoundEvent != null) + { + Fsm.Event(PlayerNotFoundEvent); + } + + if (_averagePing!=-1 && PlayerFoundEvent !=null) + { + Fsm.Event(PlayerFoundEvent); + } + + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetAveragePing.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetAveragePing.cs.meta new file mode 100755 index 0000000..72becf7 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetAveragePing.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bbaa6614b626de048b7bb628e5115e6b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetConnectedPlayerProperties.cs b/Assets/PlayMaker/Actions/Network/NetworkGetConnectedPlayerProperties.cs new file mode 100755 index 0000000..9a6817b --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetConnectedPlayerProperties.cs @@ -0,0 +1,82 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get connected player properties.")] + public class NetworkGetConnectedPlayerProperties : FsmStateAction + { + [RequiredField] + [Tooltip("The player connection index.")] + public FsmInt index; + + [ActionSection("Result")] + + [Tooltip("Get the IP address of this player.")] + [UIHint(UIHint.Variable)] + public FsmString IpAddress; + + [Tooltip("Get the port of this player.")] + [UIHint(UIHint.Variable)] + public FsmInt port; + + [Tooltip("Get the GUID for this player, used when connecting with NAT punchthrough.")] + [UIHint(UIHint.Variable)] + public FsmString guid; + + [Tooltip("Get the external IP address of the network interface. This will only be populated after some external connection has been made.")] + [UIHint(UIHint.Variable)] + public FsmString externalIPAddress; + + [Tooltip("Get the external port of the network interface. This will only be populated after some external connection has been made.")] + [UIHint(UIHint.Variable)] + public FsmInt externalPort; + + public override void Reset() + { + index = null; + IpAddress = null; + port = null; + guid = null; + externalIPAddress = null; + externalPort = null; + } + + public override void OnEnter() + { + getPlayerProperties(); + + Finish(); + } + + void getPlayerProperties() + { + int _index = index.Value; + + if (_index<0 || _index>= Network.connections.Length) + { + LogError("Player index out of range"); + return; + } + + NetworkPlayer _player = Network.connections[_index]; +/* if (_player==null) + { + LogError("player not found"); + return; + }*/ + + IpAddress.Value = _player.ipAddress; + port.Value = _player.port; + guid.Value = _player.guid; + externalIPAddress.Value = _player.externalIP; + externalPort.Value = _player.externalPort; + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetConnectedPlayerProperties.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetConnectedPlayerProperties.cs.meta new file mode 100755 index 0000000..4c548d6 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetConnectedPlayerProperties.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4abd35d754b34f14f83bda4a88cc6722 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetConnectionsCount.cs b/Assets/PlayMaker/Actions/Network/NetworkGetConnectionsCount.cs new file mode 100755 index 0000000..f73952d --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetConnectionsCount.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the number of connected players.\n\nOn a client this returns 1 (the server).")] + public class NetworkGetConnectionsCount : FsmStateAction + { + [Tooltip("Number of connected players.")] + [UIHint(UIHint.Variable)] + public FsmInt connectionsCount; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + connectionsCount = null; + everyFrame = true; + } + + public override void OnEnter() + { + connectionsCount.Value = Network.connections.Length; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + connectionsCount.Value = Network.connections.Length; + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetConnectionsCount.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetConnectionsCount.cs.meta new file mode 100755 index 0000000..ec32473 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetConnectionsCount.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6a65ab3838ff94a7d8e407ffc48a7b1b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetIsMessageQueueRunning.cs b/Assets/PlayMaker/Actions/Network/NetworkGetIsMessageQueueRunning.cs new file mode 100755 index 0000000..a9c9b77 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetIsMessageQueueRunning.cs @@ -0,0 +1,31 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get if network messages are enabled or disabled.\n\nIf disabled no RPC call execution or network view synchronization takes place")] + public class NetworkGetIsMessageQueueRunning : FsmStateAction + { + [Tooltip("Is Message Queue Running. If this is disabled no RPC call execution or network view synchronization takes place")] + [UIHint(UIHint.Variable)] + public FsmBool result; + + public override void Reset() + { + result = null; + } + + public override void OnEnter() + { + result.Value = Network.isMessageQueueRunning; + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetIsMessageQueueRunning.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetIsMessageQueueRunning.cs.meta new file mode 100755 index 0000000..8c6f8d8 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetIsMessageQueueRunning.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b9955dccc83ef6743b8152151bed2ac5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetLastPing.cs b/Assets/PlayMaker/Actions/Network/NetworkGetLastPing.cs new file mode 100755 index 0000000..3c2d1c9 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetLastPing.cs @@ -0,0 +1,96 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the last ping time to the given player in milliseconds. \n" + + "If the player can't be found -1 will be returned. Pings are automatically sent out every couple of seconds.")] + public class NetworkGetLastPing : FsmStateAction + { + [ActionSection("Setup")] + + [RequiredField] + [Tooltip("The Index of the player in the network connections list.")] + [UIHint(UIHint.Variable)] + public FsmInt playerIndex; + + [Tooltip("The player reference is cached, that is if the connections list changes, the player reference remains.")] + public bool cachePlayerReference = true; + + public bool everyFrame; + + [ActionSection("Result")] + + [RequiredField] + [Tooltip("Get the last ping time to the given player in milliseconds.")] + [UIHint(UIHint.Variable)] + public FsmInt lastPing; + + [Tooltip("Event to send if the player can't be found. Average Ping is set to -1.")] + public FsmEvent PlayerNotFoundEvent; + + [Tooltip("Event to send if the player is found (pings back).")] + public FsmEvent PlayerFoundEvent; + + + private NetworkPlayer _player; + + public override void Reset() + { + playerIndex = null; + lastPing = null; + PlayerNotFoundEvent = null; + PlayerFoundEvent = null; + cachePlayerReference = true; + everyFrame = false; + } + + public override void OnEnter() + { + if (cachePlayerReference){ + _player = Network.connections[playerIndex.Value]; + } + + GetLastPing(); + + if(!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + GetLastPing(); + } + + void GetLastPing() + { + + if (!cachePlayerReference){ + + _player = Network.connections[playerIndex.Value]; + } + + int _lastPing = Network.GetLastPing(_player); + lastPing.Value = _lastPing; + + if (_lastPing ==-1 && PlayerNotFoundEvent != null){ + Fsm.Event(PlayerNotFoundEvent); + } + + if (_lastPing!=-1 && PlayerFoundEvent !=null) + { + Fsm.Event(PlayerFoundEvent); + } + + + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetLastPing.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetLastPing.cs.meta new file mode 100755 index 0000000..a5dc61b --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetLastPing.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 467c990ba4eed2a4cbe8f9948cdfbace +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetLocalPlayerProperties.cs b/Assets/PlayMaker/Actions/Network/NetworkGetLocalPlayerProperties.cs new file mode 100755 index 0000000..d03a295 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetLocalPlayerProperties.cs @@ -0,0 +1,56 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the local network player properties")] + public class NetworkGetLocalPlayerProperties : FsmStateAction + { + [Tooltip("The IP address of this player.")] + [UIHint(UIHint.Variable)] + public FsmString IpAddress; + + [Tooltip("The port of this player.")] + [UIHint(UIHint.Variable)] + public FsmInt port; + + [Tooltip("The GUID for this player, used when connecting with NAT punchthrough.")] + [UIHint(UIHint.Variable)] + public FsmString guid; + + [Tooltip("The external IP address of the network interface. This will only be populated after some external connection has been made.")] + [UIHint(UIHint.Variable)] + public FsmString externalIPAddress; + + [Tooltip("Returns the external port of the network interface. This will only be populated after some external connection has been made.")] + [UIHint(UIHint.Variable)] + public FsmInt externalPort; + + public override void Reset() + { + IpAddress = null; + port = null; + guid = null; + externalIPAddress = null; + externalPort = null; + } + + public override void OnEnter() + { + IpAddress.Value = Network.player.ipAddress; + port.Value = Network.player.port; + guid.Value = Network.player.guid; + externalIPAddress.Value = Network.player.externalIP; + externalPort.Value = Network.player.externalPort; + + Finish(); + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetLocalPlayerProperties.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetLocalPlayerProperties.cs.meta new file mode 100755 index 0000000..4fe956d --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetLocalPlayerProperties.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 532c763936e5ea548a622de415887b6a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetMaximumConnections.cs b/Assets/PlayMaker/Actions/Network/NetworkGetMaximumConnections.cs new file mode 100755 index 0000000..8fecfa9 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetMaximumConnections.cs @@ -0,0 +1,32 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the maximum amount of connections/players allowed.")] + public class NetworkGetMaximumConnections : FsmStateAction + { + [Tooltip("Get the maximum amount of connections/players allowed.")] + [UIHint(UIHint.Variable)] + public FsmInt result; + + public override void Reset() + { + result = null; + } + + public override void OnEnter() + { + result.Value = Network.maxConnections; + + Finish(); + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetMaximumConnections.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetMaximumConnections.cs.meta new file mode 100755 index 0000000..3403005 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetMaximumConnections.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd3016037ca0b6f4a82be53ed71782f7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetMessagePlayerProperties.cs b/Assets/PlayMaker/Actions/Network/NetworkGetMessagePlayerProperties.cs new file mode 100755 index 0000000..00ebe97 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetMessagePlayerProperties.cs @@ -0,0 +1,69 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the network OnPlayerConnected or OnPlayerDisConnected message player info.")] + public class NetworkGetMessagePlayerProperties : FsmStateAction + { + + [Tooltip("Get the IP address of this connected player.")] + [UIHint(UIHint.Variable)] + public FsmString IpAddress; + + [Tooltip("Get the port of this connected player.")] + [UIHint(UIHint.Variable)] + public FsmInt port; + + [Tooltip("Get the GUID for this connected player, used when connecting with NAT punchthrough.")] + [UIHint(UIHint.Variable)] + public FsmString guid; + + [Tooltip("Get the external IP address of the network interface. This will only be populated after some external connection has been made.")] + [UIHint(UIHint.Variable)] + public FsmString externalIPAddress; + + [Tooltip("Get the external port of the network interface. This will only be populated after some external connection has been made.")] + [UIHint(UIHint.Variable)] + public FsmInt externalPort; + + + public override void Reset() + { + IpAddress = null; + port = null; + guid = null; + externalIPAddress = null; + externalPort = null; + } + + + public override void OnEnter() + { + doGetOnPLayerConnectedProperties(); + Finish(); + } + + void doGetOnPLayerConnectedProperties() + { + NetworkPlayer _player = Fsm.EventData.Player; + Debug.Log("hello "+_player.ipAddress); + + + IpAddress.Value = _player.ipAddress; + port.Value = _player.port; + guid.Value = _player.guid; + externalIPAddress.Value = _player.externalIP; + externalPort.Value = _player.externalPort; + + Finish(); + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetMessagePlayerProperties.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetMessagePlayerProperties.cs.meta new file mode 100755 index 0000000..4851b34 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetMessagePlayerProperties.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 76a2f1afb754faf429a13c17796d72bf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetMinimumAllocatableViewIDs.cs b/Assets/PlayMaker/Actions/Network/NetworkGetMinimumAllocatableViewIDs.cs new file mode 100755 index 0000000..6d41c67 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetMinimumAllocatableViewIDs.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the minimum number of ViewID numbers in the ViewID pool given to clients by the server. The default value is 100.\n\n" + + "The ViewID pools are given to each player as he connects and are refreshed with new numbers if the player runs out. " + + "The server and clients should be in sync regarding this value.\n\n" + + "Setting this higher only on the server has the effect that he sends more view ID numbers to clients, than they really want.\n\n" + + "Setting this higher only on clients means they request more view IDs more often, for example twice in a row, as the pools received from the server don't contain enough numbers. ")] + public class NetworkGetMinimumAllocatableViewIDs : FsmStateAction + { + [Tooltip("Get the minimum number of ViewID numbers in the ViewID pool given to clients by the server. The default value is 100.")] + [UIHint(UIHint.Variable)] + public FsmInt result; + + public override void Reset() + { + result = null; + } + + public override void OnEnter() + { + result.Value = Network.minimumAllocatableViewIDs; + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetMinimumAllocatableViewIDs.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetMinimumAllocatableViewIDs.cs.meta new file mode 100755 index 0000000..bb35c30 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetMinimumAllocatableViewIDs.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1340ba9a13b142c488eb10788673d4be +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetNetworkDisconnectionInfo.cs b/Assets/PlayMaker/Actions/Network/NetworkGetNetworkDisconnectionInfo.cs new file mode 100755 index 0000000..14f3480 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetNetworkDisconnectionInfo.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the network OnDisconnectedFromServer.")] + public class NetworkGetNetworkDisconnectionInfos : FsmStateAction + { + + [Tooltip("Disconnection label")] + [UIHint(UIHint.Variable)] + public FsmString disconnectionLabel; + + [Tooltip("The connection to the system has been lost, no reliable packets could be delivered.")] + public FsmEvent lostConnectionEvent; + [Tooltip("The connection to the system has been closed.")] + public FsmEvent disConnectedEvent; + + + public override void Reset () + { + disconnectionLabel = null; + lostConnectionEvent = null; + disConnectedEvent = null; + + } + + + public override void OnEnter () + { + doGetNetworkDisconnectionInfo(); + + Finish(); + } + + void doGetNetworkDisconnectionInfo() + { + NetworkDisconnection _networkDisconnectionInfo = Fsm.EventData.DisconnectionInfo; + + disconnectionLabel.Value = _networkDisconnectionInfo.ToString(); + + switch (_networkDisconnectionInfo) { + case NetworkDisconnection.Disconnected: + if (disConnectedEvent != null) { + Fsm.Event (disConnectedEvent); + } + break; + case NetworkDisconnection.LostConnection: + if (lostConnectionEvent != null) { + Fsm.Event (lostConnectionEvent); + } + break; + } + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetNetworkDisconnectionInfo.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetNetworkDisconnectionInfo.cs.meta new file mode 100755 index 0000000..576c975 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetNetworkDisconnectionInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3e54cdeeca98525418636bf939e139c5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetNetworkErrorInfo.cs b/Assets/PlayMaker/Actions/Network/NetworkGetNetworkErrorInfo.cs new file mode 100755 index 0000000..9051a4c --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetNetworkErrorInfo.cs @@ -0,0 +1,174 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the network OnFailedToConnect or MasterServer OnFailedToConnectToMasterServer connection error message.")] + public class NetworkGetOnFailedToConnectProperties : FsmStateAction + { + + + [Tooltip("Error label")] + [UIHint(UIHint.Variable)] + public FsmString errorLabel; + + [Tooltip("No error occurred.")] + public FsmEvent NoErrorEvent; + [Tooltip("We presented an RSA public key which does not match what the system we connected to is using.")] + public FsmEvent RSAPublicKeyMismatchEvent; + [Tooltip("The server is using a password and has refused our connection because we did not set the correct password.")] + public FsmEvent InvalidPasswordEvent; + [Tooltip("onnection attempt failed, possibly because of internal connectivity problems.")] + public FsmEvent ConnectionFailedEvent; + [Tooltip("The server is at full capacity, failed to connect.")] + public FsmEvent TooManyConnectedPlayersEvent; + [Tooltip("We are banned from the system we attempted to connect to (likely temporarily).")] + public FsmEvent ConnectionBannedEvent; + [Tooltip("We are already connected to this particular server (can happen after fast disconnect/reconnect).")] + public FsmEvent AlreadyConnectedToServerEvent; + [Tooltip("Cannot connect to two servers at once. Close the connection before connecting again.")] + public FsmEvent AlreadyConnectedToAnotherServerEvent; + [Tooltip("Internal error while attempting to initialize network interface. Socket possibly already in use.")] + public FsmEvent CreateSocketOrThreadFailureEvent; + [Tooltip("Incorrect parameters given to Connect function.")] + public FsmEvent IncorrectParametersEvent; + [Tooltip("No host target given in Connect.")] + public FsmEvent EmptyConnectTargetEvent; + [Tooltip("Client could not connect internally to same network NAT enabled server.")] + public FsmEvent InternalDirectConnectFailedEvent; + [Tooltip("The NAT target we are trying to connect to is not connected to the facilitator server.")] + public FsmEvent NATTargetNotConnectedEvent; + [Tooltip("Connection lost while attempting to connect to NAT target.")] + public FsmEvent NATTargetConnectionLostEvent; + [Tooltip("NAT punchthrough attempt has failed. The cause could be a too restrictive NAT implementation on either endpoints.")] + public FsmEvent NATPunchthroughFailedEvent; + + + public override void Reset () + { + errorLabel = null; + NoErrorEvent = null; + RSAPublicKeyMismatchEvent = null; + InvalidPasswordEvent = null; + ConnectionFailedEvent = null; + TooManyConnectedPlayersEvent = null; + ConnectionBannedEvent = null; + AlreadyConnectedToServerEvent = null; + AlreadyConnectedToAnotherServerEvent = null; + CreateSocketOrThreadFailureEvent = null; + IncorrectParametersEvent = null; + EmptyConnectTargetEvent = null; + InternalDirectConnectFailedEvent = null; + NATTargetNotConnectedEvent = null; + NATTargetConnectionLostEvent = null; + NATPunchthroughFailedEvent = null; + } + + + public override void OnEnter () + { + doGetNetworkErrorInfo(); + + Finish(); + } + + void doGetNetworkErrorInfo() + { + NetworkConnectionError _networkConnectionError = Fsm.EventData.ConnectionError; + /* How do you check that Fsm.EventData.ConnectionError is indeed set, since it's an enum? + if (_networkConnectionError == null) { + LogError ("NetworkConnectionError data is null"); + return; + } + */ + errorLabel.Value = _networkConnectionError.ToString(); + + switch (_networkConnectionError) { + case NetworkConnectionError.NoError: + if (NoErrorEvent != null) { + Fsm.Event (NoErrorEvent); + } + break; + case NetworkConnectionError.RSAPublicKeyMismatch: + if (RSAPublicKeyMismatchEvent != null) { + Fsm.Event (RSAPublicKeyMismatchEvent); + } + break; + case NetworkConnectionError.InvalidPassword: + if (InvalidPasswordEvent != null) { + Fsm.Event (InvalidPasswordEvent); + } + break; + case NetworkConnectionError.ConnectionFailed: + if (ConnectionFailedEvent != null) { + Fsm.Event (ConnectionFailedEvent); + } + break; + case NetworkConnectionError.TooManyConnectedPlayers: + if (TooManyConnectedPlayersEvent != null) { + Fsm.Event (TooManyConnectedPlayersEvent); + } + break; + case NetworkConnectionError.ConnectionBanned: + if (ConnectionBannedEvent != null) { + Fsm.Event (ConnectionBannedEvent); + } + break; + case NetworkConnectionError.AlreadyConnectedToServer: + if (AlreadyConnectedToServerEvent != null) { + Fsm.Event (AlreadyConnectedToServerEvent); + } + break; + case NetworkConnectionError.AlreadyConnectedToAnotherServer: + if (AlreadyConnectedToAnotherServerEvent != null) { + Fsm.Event (AlreadyConnectedToAnotherServerEvent); + } + break; + case NetworkConnectionError.CreateSocketOrThreadFailure: + if (CreateSocketOrThreadFailureEvent != null) { + Fsm.Event (CreateSocketOrThreadFailureEvent); + } + break; + case NetworkConnectionError.IncorrectParameters: + if (IncorrectParametersEvent != null) { + Fsm.Event (IncorrectParametersEvent); + } + break; + case NetworkConnectionError.EmptyConnectTarget: + if (EmptyConnectTargetEvent != null) { + Fsm.Event (EmptyConnectTargetEvent); + } + break; + case NetworkConnectionError.InternalDirectConnectFailed: + if (InternalDirectConnectFailedEvent != null) { + Fsm.Event (InternalDirectConnectFailedEvent); + } + break; + case NetworkConnectionError.NATTargetNotConnected: + if (NATTargetNotConnectedEvent != null) { + Fsm.Event (NATTargetNotConnectedEvent); + } + break; + case NetworkConnectionError.NATTargetConnectionLost: + if (NATTargetConnectionLostEvent != null) { + Fsm.Event (NATTargetConnectionLostEvent); + } + break; + case NetworkConnectionError.NATPunchthroughFailed: + if (NATPunchthroughFailedEvent != null) { + Fsm.Event (NoErrorEvent); + } + break; + + } + + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetNetworkErrorInfo.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetNetworkErrorInfo.cs.meta new file mode 100755 index 0000000..6827478 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetNetworkErrorInfo.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2fd86eb11ae95534694396c6b61dada6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetNextConnectedPlayerProperties.cs b/Assets/PlayMaker/Actions/Network/NetworkGetNextConnectedPlayerProperties.cs new file mode 100755 index 0000000..028847e --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetNextConnectedPlayerProperties.cs @@ -0,0 +1,121 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the next connected player properties. \nEach time this action is called it gets the next child of a GameObject." + + "This lets you quickly loop through all the connected player to perform actions on them.")] + public class NetworkGetNextConnectedPlayerProperties : FsmStateAction + { + + [ActionSection("Set up")] + + [Tooltip("Event to send for looping.")] + public FsmEvent loopEvent; + + [Tooltip("Event to send when there are no more children.")] + public FsmEvent finishedEvent; + + [ActionSection("Result")] + + [Tooltip("The player connection index.")] + [UIHint(UIHint.Variable)] + public FsmInt index; + + [Tooltip("Get the IP address of this player.")] + [UIHint(UIHint.Variable)] + public FsmString IpAddress; + + [Tooltip("Get the port of this player.")] + [UIHint(UIHint.Variable)] + public FsmInt port; + + [Tooltip("Get the GUID for this player, used when connecting with NAT punchthrough.")] + [UIHint(UIHint.Variable)] + public FsmString guid; + + [Tooltip("Get the external IP address of the network interface. This will only be populated after some external connection has been made.")] + [UIHint(UIHint.Variable)] + public FsmString externalIPAddress; + + [Tooltip("Get the external port of the network interface. This will only be populated after some external connection has been made.")] + [UIHint(UIHint.Variable)] + public FsmInt externalPort; + + + // increment a child index as we loop through children + private int nextItemIndex; + + public override void Reset() + { + finishedEvent = null; + loopEvent = null; + + index = null; + IpAddress = null; + port = null; + guid = null; + externalIPAddress = null; + externalPort = null; + } + + + public override void OnEnter() + { + DoGetNextPlayerProperties(); + + Finish(); + } + + void DoGetNextPlayerProperties() + { + + // no more items? + + if (nextItemIndex >= Network.connections.Length) + { + // Debug.Log("no more players to loop: "+ nextItemIndex + " total "+Network.connections.Length); + Fsm.Event(finishedEvent); + nextItemIndex = 0; + return; + } + + // get next item + NetworkPlayer _player = Network.connections[nextItemIndex]; + + index.Value = nextItemIndex; + + IpAddress.Value = _player.ipAddress; + port.Value = _player.port; + guid.Value = _player.guid; + externalIPAddress.Value = _player.externalIP; + externalPort.Value = _player.externalPort; + + + + // check again if we reached the end of the list. + if (nextItemIndex >= Network.connections.Length) + { + //Debug.Log("no more players to loop: "+ nextItemIndex + " total "+Network.connections.Length); + Fsm.Event(finishedEvent); + nextItemIndex = 0; + return; + } + + // iterate to next + nextItemIndex++; + + if (loopEvent!=null){ + Fsm.Event(loopEvent); + } + + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetNextConnectedPlayerProperties.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetNextConnectedPlayerProperties.cs.meta new file mode 100755 index 0000000..5afe4ed --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetNextConnectedPlayerProperties.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8b57f566b7009224da4ef3917ec21be6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetSendRate.cs b/Assets/PlayMaker/Actions/Network/NetworkGetSendRate.cs new file mode 100755 index 0000000..1efbfd7 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetSendRate.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Store the current send rate for all NetworkViews")] + public class NetworkGetSendRate : FsmStateAction + { + [RequiredField] + [Tooltip("Store the current send rate for NetworkViews")] + [UIHint(UIHint.Variable)] + public FsmFloat sendRate; + + public override void Reset() + { + sendRate = null; + } + + public override void OnEnter() + { + DoGetSendRate(); + + Finish(); + } + + void DoGetSendRate() + { + sendRate.Value = Network.sendRate; + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetSendRate.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetSendRate.cs.meta new file mode 100755 index 0000000..4e8b37b --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetSendRate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1ace0486dfa857046a30044c34bf0975 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetTime.cs b/Assets/PlayMaker/Actions/Network/NetworkGetTime.cs new file mode 100755 index 0000000..d5a677b --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetTime.cs @@ -0,0 +1,33 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the current network time (seconds).")] + public class NetworkGetTime : FsmStateAction + { + [Tooltip("The network time.")] + [UIHint(UIHint.Variable)] + public FsmFloat time; + + public override void Reset() + { + time = null; + } + + public override void OnEnter() + { + // TODO: support double somehow because this can not work properly. + time.Value = (float)Network.time; + + Finish(); + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkGetTime.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkGetTime.cs.meta new file mode 100755 index 0000000..b189b86 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkGetTime.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c03a87c41499e244da9056809da3b122 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkHavePublicIpAddress.cs b/Assets/PlayMaker/Actions/Network/NetworkHavePublicIpAddress.cs new file mode 100755 index 0000000..c6f94aa --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkHavePublicIpAddress.cs @@ -0,0 +1,52 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Check if this machine has a public IP address.")] + public class NetworkHavePublicIpAddress : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("True if this machine has a public IP address")] + public FsmBool havePublicIpAddress; + + [Tooltip("Event to send if this machine has a public IP address")] + public FsmEvent publicIpAddressFoundEvent; + + [Tooltip("Event to send if this machine has no public IP address")] + public FsmEvent publicIpAddressNotFoundEvent; + + public override void Reset() + { + havePublicIpAddress = null; + publicIpAddressFoundEvent = null; + publicIpAddressNotFoundEvent =null; + } + + public override void OnEnter() + { + + bool _publicIpAddress = Network.HavePublicAddress(); + + havePublicIpAddress.Value = _publicIpAddress; + + if (_publicIpAddress && publicIpAddressFoundEvent != null) + { + Fsm.Event(publicIpAddressFoundEvent); + } + else if (!_publicIpAddress && publicIpAddressNotFoundEvent != null) + { + Fsm.Event(publicIpAddressNotFoundEvent); + } + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkHavePublicIpAddress.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkHavePublicIpAddress.cs.meta new file mode 100755 index 0000000..ce7f656 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkHavePublicIpAddress.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 14d82bc7a83c3ac4b9812cb637bf0c8d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkInitializeServer.cs b/Assets/PlayMaker/Actions/Network/NetworkInitializeServer.cs new file mode 100755 index 0000000..935bf36 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkInitializeServer.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Launch a server.")] + public class NetworkInitializeServer : FsmStateAction + { + [RequiredField] + [Tooltip("The number of allowed incoming connections/number of players allowed in the game.")] + public FsmInt connections; + + [RequiredField] + [Tooltip("The port number we want to listen to.")] + public FsmInt listenPort; + + [Tooltip("Sets the password for the server. This must be matched in the NetworkConnect action.")] + public FsmString incomingPassword; + + [Tooltip("Sets the NAT punchthrough functionality.")] + public FsmBool useNAT; + + [Tooltip("Unity handles the network layer by providing secure connections if you wish to use them. \n" + + "Most games will want to use secure connections. " + + "However, they add up to 15 bytes per packet and take time to compute so you may wish to limit usage to deployed games only.")] + public FsmBool useSecurityLayer; + + [Tooltip("Run the server in the background, even if it doesn't have focus.")] + public FsmBool runInBackground; + + [ActionSection("Errors")] + + [Tooltip("Event to send in case of an error creating the server.")] + public FsmEvent errorEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the error string in a variable.")] + public FsmString errorString; + + public override void Reset() + { + connections = 32; + listenPort = 25001; + incomingPassword = ""; + errorEvent = null; + errorString = null; + useNAT = false; + useSecurityLayer = false; + runInBackground = true; + } + + public override void OnEnter() + { + //var useNAT = !Network.HavePublicAddress(); + + Network.incomingPassword = incomingPassword.Value; + + if (useSecurityLayer.Value) + { + Network.InitializeSecurity(); + } + + if (runInBackground.Value) + { + Application.runInBackground = true; + } + + var error = Network.InitializeServer(connections.Value, listenPort.Value, useNAT.Value); + + if (error != NetworkConnectionError.NoError) + { + errorString.Value = error.ToString(); + LogError(errorString.Value); + Fsm.Event(errorEvent); + } + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkInitializeServer.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkInitializeServer.cs.meta new file mode 100755 index 0000000..db58e12 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkInitializeServer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f0f0e3824249a3441a5e8d40c8b91966 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkInstantiate.cs b/Assets/PlayMaker/Actions/Network/NetworkInstantiate.cs new file mode 100755 index 0000000..0ca9d7e --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkInstantiate.cs @@ -0,0 +1,90 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Creates a Game Object on all clients in a network game.")] + public class NetworkInstantiate : FsmStateAction + { + [RequiredField] + [Tooltip("The prefab will be instanted on all clients in the game.")] + public FsmGameObject prefab; + + [Tooltip("Optional Spawn Point.")] + public FsmGameObject spawnPoint; + + [Tooltip("Spawn Position. If a Spawn Point is defined, this is used as a local offset from the Spawn Point position.")] + public FsmVector3 position; + + [Tooltip("Spawn Rotation. NOTE: Overrides the rotation of the Spawn Point.")] + public FsmVector3 rotation; + + [UIHint(UIHint.Variable)] + [Tooltip("Optionally store the created object.")] + public FsmGameObject storeObject; + + [Tooltip("Usually 0. The group number allows you to group together network messages which allows you to filter them if so desired.")] + public FsmInt networkGroup; + + public override void Reset() + { + prefab = null; + spawnPoint = null; + position = new FsmVector3 { UseVariable = true }; + rotation = new FsmVector3 { UseVariable = true }; + storeObject = null; + networkGroup = 0; + } + + public override void OnEnter() + { + var go = prefab.Value; + + if (go != null) + { + var spawnPosition = Vector3.zero; + var spawnRotation = Vector3.up; + + if (spawnPoint.Value != null) + { + spawnPosition = spawnPoint.Value.transform.position; + + if (!position.IsNone) + { + spawnPosition += position.Value; + } + + spawnRotation = !rotation.IsNone ? rotation.Value : spawnPoint.Value.transform.eulerAngles; + } + else + { + if (!position.IsNone) + { + spawnPosition = position.Value; + } + + if (!rotation.IsNone) + { + spawnRotation = rotation.Value; + } + } + + var newObject = (GameObject)Network.Instantiate(go, spawnPosition, Quaternion.Euler(spawnRotation), networkGroup.Value); + + storeObject.Value = newObject; + + //newObject.transform.position = spawnPosition; + //newObject.transform.eulerAngles = spawnRotation; + } + + Finish(); + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkInstantiate.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkInstantiate.cs.meta new file mode 100755 index 0000000..c687e40 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkInstantiate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ad17eafb0b67eb442a4ebedacfbb6378 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkIsClient.cs b/Assets/PlayMaker/Actions/Network/NetworkIsClient.cs new file mode 100755 index 0000000..f231152 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkIsClient.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Test if your peer type is client.")] + public class NetworkIsClient : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("True if running as client.")] + public FsmBool isClient; + + [Tooltip("Event to send if running as client.")] + public FsmEvent isClientEvent; + + [Tooltip("Event to send if not running as client.")] + public FsmEvent isNotClientEvent; + + public override void Reset() + { + isClient = null; + } + + public override void OnEnter() + { + DoCheckIsClient(); + + Finish(); + } + + void DoCheckIsClient() + { + isClient.Value = Network.isClient; + + if (Network.isClient && isClientEvent != null) + { + Fsm.Event(isClientEvent); + } + else if (!Network.isClient && isNotClientEvent != null) + { + Fsm.Event(isNotClientEvent); + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkIsClient.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkIsClient.cs.meta new file mode 100755 index 0000000..afede87 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkIsClient.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f7767eb07df59ad4fae6f458dd7259a4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkIsServer.cs b/Assets/PlayMaker/Actions/Network/NetworkIsServer.cs new file mode 100755 index 0000000..66d0dc2 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkIsServer.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Test if your peer type is server.")] + public class NetworkIsServer : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("True if running as server.")] + public FsmBool isServer; + + [Tooltip("Event to send if running as server.")] + public FsmEvent isServerEvent; + + [Tooltip("Event to send if not running as server.")] + public FsmEvent isNotServerEvent; + + public override void Reset() + { + isServer = null; + } + + public override void OnEnter() + { + DoCheckIsServer(); + + Finish(); + } + + void DoCheckIsServer() + { + isServer.Value = Network.isServer; + + if (Network.isServer && isServerEvent != null) + { + Fsm.Event(isServerEvent); + } + else if (!Network.isServer && isNotServerEvent != null) + { + Fsm.Event(isNotServerEvent); + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkIsServer.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkIsServer.cs.meta new file mode 100755 index 0000000..633ba93 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkIsServer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 186cdfe7253d69d419f5c82826b467d2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkPeerTypeSwitch.cs b/Assets/PlayMaker/Actions/Network/NetworkPeerTypeSwitch.cs new file mode 100755 index 0000000..70fbc0c --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkPeerTypeSwitch.cs @@ -0,0 +1,84 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Send Events based on the status of the network interface peer type: Disconneced, Server, Client, Connecting.")] + public class NetworkPeerTypeSwitch : FsmStateAction + { + [Tooltip("Event to send if no client connection running. Server not initialized.")] + public FsmEvent isDisconnected; + + [Tooltip("Event to send if running as server.")] + public FsmEvent isServer; + + [Tooltip("Event to send if running as client.")] + public FsmEvent isClient; + + [Tooltip("Event to send attempting to connect to a server.")] + public FsmEvent isConnecting; + + //[Tooltip("Only send the event when the peer type changes. NOTE: Event always sent the first time the state is entered.")] + //public bool OnlyOnChange; + + [Tooltip("Repeat every frame. Useful if you're waiting for a particular network state.")] + public bool everyFrame; + + public override void Reset() + { + isDisconnected = null; + isServer = null; + isClient = null; + isConnecting = null; + //OnlyOnChange = true; + everyFrame = false; + } + + public override void OnEnter() + { + DoNetworkPeerTypeSwitch(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoNetworkPeerTypeSwitch(); + } + + void DoNetworkPeerTypeSwitch() + { + switch (Network.peerType) + { + case NetworkPeerType.Disconnected: + + Fsm.Event(isDisconnected); + break; + + case NetworkPeerType.Server: + + Fsm.Event(isServer); + break; + + case NetworkPeerType.Client: + + Fsm.Event(isClient); + break; + + case NetworkPeerType.Connecting: + + Fsm.Event(isConnecting); + break; + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkPeerTypeSwitch.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkPeerTypeSwitch.cs.meta new file mode 100755 index 0000000..b0b2a98 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkPeerTypeSwitch.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b7f8f353377c382478a7ad73361f48af +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetIsMessageQueueRunning.cs b/Assets/PlayMaker/Actions/Network/NetworkSetIsMessageQueueRunning.cs new file mode 100755 index 0000000..346558b --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetIsMessageQueueRunning.cs @@ -0,0 +1,31 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Enable or disable the processing of network messages.\n\nIf this is disabled no RPC call execution or network view synchronization takes place.")] + public class NetworkSetIsMessageQueueRunning : FsmStateAction + { + [Tooltip("Is Message Queue Running. If this is disabled no RPC call execution or network view synchronization takes place")] + public FsmBool isMessageQueueRunning; + + public override void Reset() + { + isMessageQueueRunning = null; + } + + public override void OnEnter() + { + Network.isMessageQueueRunning = isMessageQueueRunning.Value; + + Finish(); + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetIsMessageQueueRunning.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkSetIsMessageQueueRunning.cs.meta new file mode 100755 index 0000000..b7e8e18 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetIsMessageQueueRunning.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a18a3309f03aa44fbeda9b48f7e4867 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetLevelPrefix.cs b/Assets/PlayMaker/Actions/Network/NetworkSetLevelPrefix.cs new file mode 100755 index 0000000..75afdec --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetLevelPrefix.cs @@ -0,0 +1,41 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Set the level prefix which will then be prefixed to all network ViewID numbers.\n\n" + + "This prevents old network updates from straying into a new level from the previous level.\n\n" + + "This can be set to any number and then incremented with each new level load. " + + "This doesn't add overhead to network traffic but just diminishes the pool of network ViewID numbers a little bit.")] + public class NetworkSetLevelPrefix : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The level prefix which will then be prefixed to all network ViewID numbers.")] + public FsmInt levelPrefix; + + public override void Reset() + { + levelPrefix = null; + } + + public override void OnEnter() + { + if (levelPrefix.IsNone) + { + LogError("Network LevelPrefix not set"); + return; + } + + Network.SetLevelPrefix(levelPrefix.Value); + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetLevelPrefix.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkSetLevelPrefix.cs.meta new file mode 100755 index 0000000..21a1f5c --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetLevelPrefix.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cb0d9358a782c5c488c43c4ccdb18d86 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetLogLevel.cs b/Assets/PlayMaker/Actions/Network/NetworkSetLogLevel.cs new file mode 100755 index 0000000..6b0f86d --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetLogLevel.cs @@ -0,0 +1,33 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Set the log level for network messages. Default is Off.\n\nOff: Only report errors, otherwise silent.\n\nInformational: Report informational messages like connectivity events.\n\nFull: Full debug level logging down to each individual message being reported.")] + public class NetworkSetLogLevel : FsmStateAction + { + [Tooltip("The log level")] + public NetworkLogLevel logLevel; + + + public override void Reset() + { + logLevel = NetworkLogLevel.Off; + + } + + public override void OnEnter() + { + Network.logLevel = logLevel; + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetLogLevel.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkSetLogLevel.cs.meta new file mode 100755 index 0000000..fd4b597 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetLogLevel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ed5ebf769ea04b4fad80afc030dbf24 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetMaxConnections.cs b/Assets/PlayMaker/Actions/Network/NetworkSetMaxConnections.cs new file mode 100755 index 0000000..5e4aa51 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetMaxConnections.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Set the maximum amount of connections/players allowed.\n\n" + + "This cannot be set higher than the connection count given in Launch Server.\n\n" + + "Setting it to 0 means no new connections can be made but the existing ones stay connected.\n\n" + + "Setting it to -1 means the maximum connections count is set to the same number of current open connections. " + + "In that case, if a players drops then the slot is still open for him.")] + public class NetworkSetMaximumConnections : FsmStateAction + { + [Tooltip("The maximum amount of connections/players allowed.")] + public FsmInt maximumConnections; + + public override void Reset() + { + maximumConnections = 32; + } + + public override void OnEnter() + { + if (maximumConnections.Value <-1) + { + LogWarning("Network Maximum connections can not be less than -1"); + maximumConnections.Value = -1; + } + + Network.maxConnections = maximumConnections.Value; + + Finish(); + } + + public override string ErrorCheck() + { + if (maximumConnections.Value <-1) + { + return "Network Maximum connections can not be less than -1"; + } + + return ""; + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetMaxConnections.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkSetMaxConnections.cs.meta new file mode 100755 index 0000000..976eef9 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetMaxConnections.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 18f98afe6e8d13546bc1d0acd678e5a2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetMinimumAllocatableViewIDs.cs b/Assets/PlayMaker/Actions/Network/NetworkSetMinimumAllocatableViewIDs.cs new file mode 100755 index 0000000..d9a80f1 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetMinimumAllocatableViewIDs.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Set the minimum number of ViewID numbers in the ViewID pool given to clients by the server. The default value is 100.\n\n" + + "The ViewID pools are given to each player as he connects and are refreshed with new numbers if the player runs out. " + + "The server and clients should be in sync regarding this value.\n\n" + + "Setting this higher only on the server has the effect that he sends more view ID numbers to clients, than they really want.\n\n" + + "Setting this higher only on clients means they request more view IDs more often, for example twice in a row, as the pools received from the server don't contain enough numbers. ")] + public class NetworkSetMinimumAllocatableViewIDs : FsmStateAction + { + [Tooltip("The minimum number of ViewID numbers in the ViewID pool given to clients by the server. The default value is 100.")] + public FsmInt minimumViewIDs; + + public override void Reset() + { + minimumViewIDs = 100; + } + + public override void OnEnter() + { + Network.minimumAllocatableViewIDs = minimumViewIDs.Value; + + Finish(); + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetMinimumAllocatableViewIDs.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkSetMinimumAllocatableViewIDs.cs.meta new file mode 100755 index 0000000..01102ee --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetMinimumAllocatableViewIDs.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f9260da2878bdcc4c96b58d6b3127b7c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetSendRate.cs b/Assets/PlayMaker/Actions/Network/NetworkSetSendRate.cs new file mode 100755 index 0000000..31c6cd2 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetSendRate.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Set the send rate for all networkViews. Default is 15")] + public class NetworkSetSendRate : FsmStateAction + { + [RequiredField] + [Tooltip("The send rate for all networkViews")] + public FsmFloat sendRate; + + public override void Reset() + { + sendRate = 15f; + } + + public override void OnEnter() + { + DoSetSendRate(); + + Finish(); + } + + void DoSetSendRate() + { + Network.sendRate = sendRate.Value; + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkSetSendRate.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkSetSendRate.cs.meta new file mode 100755 index 0000000..f2c1d13 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkSetSendRate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: db4963a1ff4022c458766dcc56d81b6d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkViewGetIsMine.cs b/Assets/PlayMaker/Actions/Network/NetworkViewGetIsMine.cs new file mode 100755 index 0000000..425aaa6 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkViewGetIsMine.cs @@ -0,0 +1,84 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Test if the Network View is controlled by a GameObject.")] + public class NetworkViewIsMine : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(NetworkView))] + [Tooltip("The Game Object with the NetworkView attached.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [Tooltip("True if the network view is controlled by this object.")] + public FsmBool isMine; + + [Tooltip("Send this event if the network view controlled by this object.")] + public FsmEvent isMineEvent; + + [Tooltip("Send this event if the network view is NOT controlled by this object.")] + public FsmEvent isNotMineEvent; + + private NetworkView _networkView; + + private void _getNetworkView() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + _networkView = go.GetComponent(); + } + + public override void Reset() + { + gameObject = null; + isMine = null; + isMineEvent = null; + isNotMineEvent = null; + } + + public override void OnEnter() + { + _getNetworkView(); + + checkIsMine(); + + Finish(); + } + + void checkIsMine() + { + if (_networkView ==null) + { + return; + } + + bool _isMine = _networkView.isMine; + isMine.Value = _isMine; + + if (_isMine ) + { + if (isMineEvent!=null) + { + Fsm.Event(isMineEvent); + } + } + else if (isNotMineEvent!=null) + { + Fsm.Event(isNotMineEvent); + } + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkViewGetIsMine.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkViewGetIsMine.cs.meta new file mode 100755 index 0000000..b800411 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkViewGetIsMine.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7ec6fcd52a438a243a641914a4bf6e93 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkViewGetViewId.cs b/Assets/PlayMaker/Actions/Network/NetworkViewGetViewId.cs new file mode 100755 index 0000000..b955970 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkViewGetViewId.cs @@ -0,0 +1,60 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. +/* +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Get the ViewId of a NetworkView.\n\nNOTE: The GameObject must have a NetworkView attached.")] + public class NetworkViewGetViewID : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(NetworkView))] + [Tooltip("The GameObject.\nNOTE: The Game Object must have a NetworkView attached.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The view Id")] + [UIHint(UIHint.Variable)] + public FsmInt viewID; + + private NetworkView _networkView; + + private void _getNetworkView() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + _networkView = go.GetComponent(); + } + + public override void Reset() + { + gameObject = null; + viewID = null; + } + + public override void OnEnter() + { + _getNetworkView(); + + getViewId(); + + Finish(); + } + + void getViewId() + { + if (_networkView ==null) + { + return; + } + + viewID.Value = _networkView.viewID; + } + + } +} +*/ \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkViewGetViewId.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkViewGetViewId.cs.meta new file mode 100755 index 0000000..1da3ef4 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkViewGetViewId.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f813a58f6f2ca864d833a8f5cccfd60d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/NetworkViewRemoveRPCs.cs b/Assets/PlayMaker/Actions/Network/NetworkViewRemoveRPCs.cs new file mode 100755 index 0000000..466c3e9 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkViewRemoveRPCs.cs @@ -0,0 +1,41 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Remove the RPC function calls accociated with a Game Object.\n\nNOTE: The Game Object must have a NetworkView component attached.")] + public class NetworkViewRemoveRPCs : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(NetworkView))] + [Tooltip("Remove the RPC function calls accociated with this Game Object.\n\nNOTE: The GameObject must have a NetworkView component attached.")] + public FsmOwnerDefault gameObject; + + public override void Reset() + { + gameObject = null; + } + + public override void OnEnter() + { + DoRemoveRPCsFromViewID(); + + Finish(); + } + + void DoRemoveRPCsFromViewID() + { + var targetGo = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(targetGo)) + { + Network.RemoveRPCs(networkView.viewID); + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/NetworkViewRemoveRPCs.cs.meta b/Assets/PlayMaker/Actions/Network/NetworkViewRemoveRPCs.cs.meta new file mode 100755 index 0000000..84dd0a1 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/NetworkViewRemoveRPCs.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a65704793b3c84148b34218d5e6b46ac +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/PlayMakerRPCProxy.cs b/Assets/PlayMaker/Actions/Network/PlayMakerRPCProxy.cs new file mode 100755 index 0000000..39cc1cf --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/PlayMakerRPCProxy.cs @@ -0,0 +1,35 @@ +// Unity 5.1 introduced a new networking library. +// Unless we define PLAYMAKER_LEGACY_NETWORK old network actions are disabled +#if !(UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || PLAYMAKER_LEGACY_NETWORK) +#define UNITY_NEW_NETWORK +#endif + +// Some platforms do not support networking (at least the old network library) +#if (UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) +#define PLATFORM_NOT_SUPPORTED +#endif + +using UnityEngine; +using System.Collections; + + +public class PlayMakerRPCProxy : MonoBehaviour +{ + public PlayMakerFSM[] fsms; + + public void Reset() + { + fsms = GetComponents(); + } + +#if !(PLATFORM_NOT_SUPPORTED || UNITY_NEW_NETWORK || PLAYMAKER_NO_NETWORK) + [RPC] +#endif + public void ForwardEvent(string eventName) + { + foreach (var fsm in fsms) + { + fsm.SendEvent(eventName); + } + } +} diff --git a/Assets/PlayMaker/Actions/Network/PlayMakerRPCProxy.cs.meta b/Assets/PlayMaker/Actions/Network/PlayMakerRPCProxy.cs.meta new file mode 100755 index 0000000..39d588c --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/PlayMakerRPCProxy.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8efea186b2a04264e8c8e31adac078e4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/SendRemoteEvent.cs b/Assets/PlayMaker/Actions/Network/SendRemoteEvent.cs new file mode 100755 index 0000000..8d39ed8 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/SendRemoteEvent.cs @@ -0,0 +1,75 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +// Unity 5.1 introduced a new networking library. +// Unless we define PLAYMAKER_LEGACY_NETWORK old network actions are disabled +#if !(UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || PLAYMAKER_LEGACY_NETWORK) +#define UNITY_NEW_NETWORK +#endif + +// Some platforms do not support networking (at least the old network library) +#if (UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) +#define PLATFORM_NOT_SUPPORTED +#endif + +#if !(PLATFORM_NOT_SUPPORTED || UNITY_NEW_NETWORK || PLAYMAKER_NO_NETWORK) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Send an Fsm Event on a remote machine. Uses Unity RPC functions.")] + public class SendRemoteEvent : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(NetworkView))] + [Tooltip("The game object that sends the event.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The event you want to send.")] + public FsmEvent remoteEvent; + + [Tooltip("Optional string data. Use 'Get Event Info' action to retrieve it.")] + public FsmString stringData; + + [Tooltip("Option for who will receive an RPC.")] + public RPCMode mode; + + public override void Reset() + { + gameObject = null; + remoteEvent = null; + mode = RPCMode.All; + stringData = null; + mode = RPCMode.All; + } + + public override void OnEnter() + { + DoRemoteEvent(); + + Finish(); + } + + void DoRemoteEvent() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (!stringData.IsNone && stringData.Value != "") + { + networkView.RPC("SendRemoteFsmEventWithData", mode, remoteEvent.Name,stringData.Value); + } + else + { + networkView.RPC("SendRemoteFsmEvent", mode, remoteEvent.Name); + } + } + } +} + +#endif diff --git a/Assets/PlayMaker/Actions/Network/SendRemoteEvent.cs.meta b/Assets/PlayMaker/Actions/Network/SendRemoteEvent.cs.meta new file mode 100755 index 0000000..f50c619 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/SendRemoteEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e8b98ab9798f2f84ea3c60d69612f974 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/SendRemoteEventByProxy.cs b/Assets/PlayMaker/Actions/Network/SendRemoteEventByProxy.cs new file mode 100755 index 0000000..1d0bbe4 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/SendRemoteEventByProxy.cs @@ -0,0 +1,76 @@ +// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved. + +// Unity 5.1 introduced a new networking library. +// Unless we define PLAYMAKER_LEGACY_NETWORK old network actions are disabled +#if !(UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || PLAYMAKER_LEGACY_NETWORK) +#define UNITY_NEW_NETWORK +#endif + +// Some platforms do not support networking (at least the old network library) +#if (UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) +#define PLATFORM_NOT_SUPPORTED +#endif + +#if !(PLATFORM_NOT_SUPPORTED || UNITY_NEW_NETWORK || PLAYMAKER_NO_NETWORK) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Send an Fsm Event on a remote machine. Uses Unity RPC functions. Use this instead of SendRemoteEvent if you have multiple PlayMakerFSM components on the GameObject that you want to recieve the event.")] + public class SendRemoteEventByProxy : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(NetworkView), typeof(PlayMakerRPCProxy))] + [Tooltip("The game object that sends the event.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The event you want to send.")] + public FsmEvent remoteEvent; + + [Tooltip("Optional string data. Use 'Get Event Info' action to retrieve it.")] + public FsmString stringData; + + [Tooltip("Option for who will receive an RPC.")] + public RPCMode mode; + + public override void Reset() + { + gameObject = null; + remoteEvent = null; + mode = RPCMode.All; + stringData = null; + mode = RPCMode.All; + } + + public override void OnEnter() + { + DoRPC(); + + Finish(); + } + + void DoRPC() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (!stringData.IsNone && stringData.Value != "") + { + networkView.RPC("ForwardEvent", mode, remoteEvent.Name, stringData.Value); + } + else + { + networkView.RPC("ForwardEvent", mode, remoteEvent.Name); + } + + } + } +} + +#endif diff --git a/Assets/PlayMaker/Actions/Network/SendRemoteEventByProxy.cs.meta b/Assets/PlayMaker/Actions/Network/SendRemoteEventByProxy.cs.meta new file mode 100755 index 0000000..a3d9375 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/SendRemoteEventByProxy.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e9c486a43efc4b44da9429e5bef42cb7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Network/StartServer.cs b/Assets/PlayMaker/Actions/Network/StartServer.cs new file mode 100755 index 0000000..934007f --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/StartServer.cs @@ -0,0 +1,86 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WIIU || UNITY_PSM || UNITY_WEBGL || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE) + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Network)] + [Tooltip("Start a server.")] + public class StartServer : FsmStateAction + { + [RequiredField] + [Tooltip("The number of allowed incoming connections/number of players allowed in the game.")] + public FsmInt connections; + + [RequiredField] + [Tooltip("The port number we want to listen to.")] + public FsmInt listenPort; + + [Tooltip("Sets the password for the server. This must be matched in the NetworkConnect action.")] + public FsmString incomingPassword; + + [Tooltip("Sets the NAT punchthrough functionality.")] + public FsmBool useNAT; + + [Tooltip("Unity handles the network layer by providing secure connections if you wish to use them. \n" + + "Most games will want to use secure connections. " + + "However, they add up to 15 bytes per packet and take time to compute so you may wish to limit usage to deployed games only.")] + public FsmBool useSecurityLayer; + + [Tooltip("Run the server in the background, even if it doesn't have focus.")] + public FsmBool runInBackground; + + [ActionSection("Errors")] + + [Tooltip("Event to send in case of an error creating the server.")] + public FsmEvent errorEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the error string in a variable.")] + public FsmString errorString; + + public override void Reset() + { + connections = 32; + listenPort = 25001; + incomingPassword = ""; + errorEvent = null; + errorString = null; + useNAT = false; + useSecurityLayer = false; + runInBackground = true; + } + + public override void OnEnter() + { + //var useNAT = !Network.HavePublicAddress(); + + Network.incomingPassword = incomingPassword.Value; + + if (useSecurityLayer.Value){ + Network.InitializeSecurity(); + } + + if (runInBackground.Value) + { + Application.runInBackground = true; + } + + var error = Network.InitializeServer(connections.Value, listenPort.Value, useNAT.Value); + + if (error != NetworkConnectionError.NoError) + { + errorString.Value = error.ToString(); + LogError(errorString.Value); + Fsm.Event(errorEvent); + } + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Network/StartServer.cs.meta b/Assets/PlayMaker/Actions/Network/StartServer.cs.meta new file mode 100755 index 0000000..b302fd1 --- /dev/null +++ b/Assets/PlayMaker/Actions/Network/StartServer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e1e987b217f3d89458a7de778948a78a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/NextFrameEvent.cs b/Assets/PlayMaker/Actions/NextFrameEvent.cs new file mode 100755 index 0000000..7dfea5d --- /dev/null +++ b/Assets/PlayMaker/Actions/NextFrameEvent.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sends an Event in the next frame. Useful if you want to loop states every frame.")] + public class NextFrameEvent : FsmStateAction + { + [RequiredField] + public FsmEvent sendEvent; + + public override void Reset() + { + sendEvent = null; + } + + public override void OnEnter() + { + } + + public override void OnUpdate() + { + Finish(); + + Fsm.Event(sendEvent); + } + + +#if UNITY_EDITOR + public override string AutoName() + { + return "Next Frame Event: " + sendEvent.Name; + } +#endif + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/NextFrameEvent.cs.meta b/Assets/PlayMaker/Actions/NextFrameEvent.cs.meta new file mode 100755 index 0000000..81c3427 --- /dev/null +++ b/Assets/PlayMaker/Actions/NextFrameEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f7d49062dd8a28443badc6155f4a1c1c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ObjectCompare.cs b/Assets/PlayMaker/Actions/ObjectCompare.cs new file mode 100755 index 0000000..d2da6c4 --- /dev/null +++ b/Assets/PlayMaker/Actions/ObjectCompare.cs @@ -0,0 +1,67 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Compare 2 Object Variables and send events based on the result.")] + public class ObjectCompare : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmObject objectVariable; + + [RequiredField] + public FsmObject compareTo; + + //[ActionSection("")] + + [Tooltip("Event to send if the 2 object values are equal.")] + public FsmEvent equalEvent; + + [Tooltip("Event to send if the 2 object values are not equal.")] + public FsmEvent notEqualEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a variable.")] + public FsmBool storeResult; + + //[ActionSection("")] + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + objectVariable = null; + compareTo = null; + storeResult = null; + equalEvent = null; + notEqualEvent = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoObjectCompare(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoObjectCompare(); + } + + void DoObjectCompare() + { + var result = objectVariable.Value == compareTo.Value; + + storeResult.Value = result; + + Fsm.Event(result ? equalEvent : notEqualEvent); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ObjectCompare.cs.meta b/Assets/PlayMaker/Actions/ObjectCompare.cs.meta new file mode 100755 index 0000000..7e2cc88 --- /dev/null +++ b/Assets/PlayMaker/Actions/ObjectCompare.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d4f8559eb0834134795f61474b7610ef +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PauseMovieTexture.cs b/Assets/PlayMaker/Actions/PauseMovieTexture.cs new file mode 100755 index 0000000..dd091df --- /dev/null +++ b/Assets/PlayMaker/Actions/PauseMovieTexture.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_FLASH || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE || UNITY_BLACKBERRY || UNITY_METRO || UNITY_WP8 || UNITY_PSM || UNITY_WEBGL) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Movie)] + [Tooltip("Pauses a Movie Texture.")] + public class PauseMovieTexture : FsmStateAction + { + [RequiredField] + [ObjectType(typeof(MovieTexture))] + public FsmObject movieTexture; + + public override void Reset() + { + movieTexture = null; + } + + public override void OnEnter() + { + var movie = movieTexture.Value as MovieTexture; + + if (movie != null) + { + movie.Pause(); + } + + Finish(); + } + } +} + +#endif diff --git a/Assets/PlayMaker/Actions/PauseMovieTexture.cs.meta b/Assets/PlayMaker/Actions/PauseMovieTexture.cs.meta new file mode 100755 index 0000000..0bdcfd4 --- /dev/null +++ b/Assets/PlayMaker/Actions/PauseMovieTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8695e994d952a1c408bd5df7a7dcfd76 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PerSecond.cs b/Assets/PlayMaker/Actions/PerSecond.cs new file mode 100755 index 0000000..f03c39e --- /dev/null +++ b/Assets/PlayMaker/Actions/PerSecond.cs @@ -0,0 +1,45 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Time)] + [Tooltip("Multiplies a Float by Time.deltaTime to use in frame-rate independent operations. E.g., 10 becomes 10 units per second.")] + public class PerSecond : FsmStateAction + { + [RequiredField] + public FsmFloat floatValue; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeResult; + public bool everyFrame; + + public override void Reset() + { + floatValue = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoPerSecond(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoPerSecond(); + } + + void DoPerSecond() + { + if (storeResult == null) return; + + storeResult.Value = floatValue.Value * Time.deltaTime; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/PerSecond.cs.meta b/Assets/PlayMaker/Actions/PerSecond.cs.meta new file mode 100755 index 0000000..5f71c6a --- /dev/null +++ b/Assets/PlayMaker/Actions/PerSecond.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4fb529b5c7a29a045973d621e6d2daaa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PlayAnimation.cs b/Assets/PlayMaker/Actions/PlayAnimation.cs new file mode 100755 index 0000000..c5fea8d --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayAnimation.cs @@ -0,0 +1,130 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Plays an Animation on a Game Object. You can add named animation clips to the object in the Unity editor, or with the Add Animation Clip action.")] + public class PlayAnimation : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("Game Object to play the animation on.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Animation)] + [Tooltip("The name of the animation to play.")] + public FsmString animName; + + [Tooltip("How to treat previously playing animations.")] + public PlayMode playMode; + + [HasFloatSlider(0f, 5f)] + [Tooltip("Time taken to blend to this animation.")] + public FsmFloat blendTime; + + [Tooltip("Event to send when the animation is finished playing. NOTE: Not sent with Loop or PingPong wrap modes!")] + public FsmEvent finishEvent; + + [Tooltip("Event to send when the animation loops. If you want to send this event to another FSM use Set Event Target. NOTE: This event is only sent with Loop and PingPong wrap modes.")] + public FsmEvent loopEvent; + + [Tooltip("Stop playing the animation when this state is exited.")] + public bool stopOnExit; + + private AnimationState anim; + private float prevAnimtTime; + + public override void Reset() + { + gameObject = null; + animName = null; + playMode = PlayMode.StopAll; + blendTime = 0.3f; + finishEvent = null; + loopEvent = null; + stopOnExit = false; + } + + public override void OnEnter() + { + DoPlayAnimation(); + } + + void DoPlayAnimation() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + Finish(); + return; + } + + if (string.IsNullOrEmpty(animName.Value)) + { + LogWarning("Missing animName!"); + Finish(); + return; + } + + anim = animation[animName.Value]; + + if (anim == null) + { + LogWarning("Missing animation: " + animName.Value); + Finish(); + return; + } + + var time = blendTime.Value; + if (time < 0.001f) + { + animation.Play(animName.Value, playMode); + } + else + { + animation.CrossFade(animName.Value, time, playMode); + } + + prevAnimtTime = anim.time; + } + + public override void OnUpdate() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null || anim == null) + { + return; + } + + if (!anim.enabled || (anim.wrapMode == WrapMode.ClampForever && anim.time > anim.length)) + { + Fsm.Event(finishEvent); + Finish(); + } + + if (anim.wrapMode != WrapMode.ClampForever && anim.time > anim.length && prevAnimtTime < anim.length) + { + Fsm.Event(loopEvent); + } + } + + public override void OnExit() + { + if (stopOnExit) + { + StopAnimation(); + } + } + + void StopAnimation() + { + if (animation != null) + { + animation.Stop(animName.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/PlayAnimation.cs.meta b/Assets/PlayMaker/Actions/PlayAnimation.cs.meta new file mode 100755 index 0000000..c11ddef --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayAnimation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a91b4f48a88067f46b95d5a5ff738443 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PlayMovieTexture.cs b/Assets/PlayMaker/Actions/PlayMovieTexture.cs new file mode 100755 index 0000000..2882174 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayMovieTexture.cs @@ -0,0 +1,40 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_FLASH || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE || UNITY_BLACKBERRY || UNITY_METRO || UNITY_WP8 || UNITY_PSM || UNITY_WEBGL) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Movie)] + [Tooltip("Plays a Movie Texture. Use the Movie Texture in a Material, or in the GUI.")] + public class PlayMovieTexture : FsmStateAction + { + [RequiredField] + [ObjectType(typeof(MovieTexture))] + public FsmObject movieTexture; + + public FsmBool loop; + + public override void Reset() + { + movieTexture = null; + loop = false; + } + + public override void OnEnter() + { + var movie = movieTexture.Value as MovieTexture; + + if (movie != null) + { + movie.loop = loop.Value; + movie.Play(); + } + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/PlayMovieTexture.cs.meta b/Assets/PlayMaker/Actions/PlayMovieTexture.cs.meta new file mode 100755 index 0000000..1c567b4 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayMovieTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bfac80dc19eabec408d1d615352c1209 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PlayRandomAnimation.cs b/Assets/PlayMaker/Actions/PlayRandomAnimation.cs new file mode 100755 index 0000000..9ebb409 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayRandomAnimation.cs @@ -0,0 +1,149 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System.Collections.Generic; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Plays a Random Animation on a Game Object. You can set the relative weight of each animation to control how often they are selected.")] + public class PlayRandomAnimation : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("Game Object to play the animation on.")] + public FsmOwnerDefault gameObject; + + [CompoundArray("Animations", "Animation", "Weight")] + + [UIHint(UIHint.Animation)] + public FsmString[] animations; + + [HasFloatSlider(0, 1)] + public FsmFloat[] weights; + + [Tooltip("How to treat previously playing animations.")] + public PlayMode playMode; + + [HasFloatSlider(0f, 5f)] + [Tooltip("Time taken to blend to this animation.")] + public FsmFloat blendTime; + + [Tooltip("Event to send when the animation is finished playing. NOTE: Not sent with Loop or PingPong wrap modes!")] + public FsmEvent finishEvent; + + [Tooltip("Event to send when the animation loops. If you want to send this event to another FSM use Set Event Target. NOTE: This event is only sent with Loop and PingPong wrap modes.")] + public FsmEvent loopEvent; + + [Tooltip("Stop playing the animation when this state is exited.")] + public bool stopOnExit; + + private AnimationState anim; + private float prevAnimtTime; + + public override void Reset() + { + gameObject = null; + animations = new FsmString[0]; + weights = new FsmFloat[0]; + playMode = PlayMode.StopAll; + blendTime = 0.3f; + finishEvent = null; + loopEvent = null; + stopOnExit = false; + } + + public override void OnEnter() + { + DoPlayRandomAnimation(); + } + + void DoPlayRandomAnimation() + { + if (animations.Length > 0) + { + var randomIndex = ActionHelpers.GetRandomWeightedIndex(weights); + + if (randomIndex != -1) + { + DoPlayAnimation(animations[randomIndex].Value); + } + } + } + + void DoPlayAnimation(string animName) + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + Finish(); + return; + } + + if (string.IsNullOrEmpty(animName)) + { + LogWarning("Missing animName!"); + Finish(); + return; + } + + anim = animation[animName]; + + if (anim == null) + { + LogWarning("Missing animation: " + animName); + Finish(); + return; + } + + var time = blendTime.Value; + if (time < 0.001f) + { + animation.Play(animName, playMode); + } + else + { + animation.CrossFade(animName, time, playMode); + } + + prevAnimtTime = anim.time; + } + + public override void OnUpdate() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null || anim == null) + { + return; + } + + if (!anim.enabled || (anim.wrapMode == WrapMode.ClampForever && anim.time > anim.length)) + { + Fsm.Event(finishEvent); + Finish(); + } + + if (anim.wrapMode != WrapMode.ClampForever && anim.time > anim.length && prevAnimtTime < anim.length) + { + Fsm.Event(loopEvent); + } + } + + public override void OnExit() + { + if (stopOnExit) + { + StopAnimation(); + } + } + + void StopAnimation() + { + if (animation != null) + { + animation.Stop(anim.name); + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/PlayRandomAnimation.cs.meta b/Assets/PlayMaker/Actions/PlayRandomAnimation.cs.meta new file mode 100755 index 0000000..bb20a36 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayRandomAnimation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c17b3e1c679e6aa4589c924799fb14fa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PlayRandomSound.cs b/Assets/PlayMaker/Actions/PlayRandomSound.cs new file mode 100755 index 0000000..ea36008 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayRandomSound.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System.Collections.Generic; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Plays a Random Audio Clip at a position defined by a Game Object or a Vector3. If a position is defined, it takes priority over the game object. You can set the relative weight of the clips to control how often they are selected.")] + public class PlayRandomSound : FsmStateAction + { + public FsmOwnerDefault gameObject; + public FsmVector3 position; + [CompoundArray("Audio Clips", "Audio Clip", "Weight")] + public AudioClip[] audioClips; + [HasFloatSlider(0, 1)] + public FsmFloat[] weights; + [HasFloatSlider(0, 1)] + public FsmFloat volume = 1f; + + public override void Reset() + { + gameObject = null; + position = new FsmVector3 { UseVariable = true }; + audioClips = new AudioClip[3]; + weights = new FsmFloat[] {1,1,1}; + volume = 1; + } + + public override void OnEnter() + { + DoPlayRandomClip(); + + Finish(); + } + + void DoPlayRandomClip() + { + if (audioClips.Length == 0) return; + + int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights); + + if (randomIndex != -1) + { + AudioClip clip = audioClips[randomIndex]; + if (clip != null) + { + if (!position.IsNone) + { + AudioSource.PlayClipAtPoint(clip, position.Value, volume.Value); + } + else + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + AudioSource.PlayClipAtPoint(clip, go.transform.position, volume.Value); + } + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/PlayRandomSound.cs.meta b/Assets/PlayMaker/Actions/PlayRandomSound.cs.meta new file mode 100755 index 0000000..4ca8992 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayRandomSound.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3b74a4cd320a6e43a7fa4a99b4b6d8c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PlaySound.cs b/Assets/PlayMaker/Actions/PlaySound.cs new file mode 100755 index 0000000..327dc0d --- /dev/null +++ b/Assets/PlayMaker/Actions/PlaySound.cs @@ -0,0 +1,66 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Plays an Audio Clip at a position defined by a Game Object or Vector3. If a position is defined, it takes priority over the game object. This action doesn't require an Audio Source component, but offers less control than Audio actions.")] + public class PlaySound : FsmStateAction + { + public FsmOwnerDefault gameObject; + + public FsmVector3 position; + + [RequiredField] + [Title("Audio Clip")] + [ObjectType(typeof(AudioClip))] + public FsmObject clip; + + [HasFloatSlider(0, 1)] + public FsmFloat volume = 1f; + + public override void Reset() + { + gameObject = null; + position = new FsmVector3 { UseVariable = true }; + clip = null; + volume = 1; + } + + public override void OnEnter() + { + DoPlaySound(); + Finish(); + } + + + void DoPlaySound() + { + var audioClip = clip.Value as AudioClip; + + if (audioClip == null) + { + LogWarning("Missing Audio Clip!"); + return; + } + + if (!position.IsNone) + { + AudioSource.PlayClipAtPoint(audioClip, position.Value, volume.Value); + } + else + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + AudioSource.PlayClipAtPoint(audioClip, go.transform.position, volume.Value); + } + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/PlaySound.cs.meta b/Assets/PlayMaker/Actions/PlaySound.cs.meta new file mode 100755 index 0000000..c462ee4 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlaySound.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 61417d8946e6d0f4db90854a047e6d2f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PlayerPrefs.meta b/Assets/PlayMaker/Actions/PlayerPrefs.meta new file mode 100644 index 0000000..0f9e404 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayerPrefs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 114763f8ef1de4f9e99dbec1672b71fd +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteAll.cs b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteAll.cs new file mode 100755 index 0000000..20f490b --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteAll.cs @@ -0,0 +1,21 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("PlayerPrefs")] + [Tooltip("Removes all keys and values from the preferences. Use with caution.")] + public class PlayerPrefsDeleteAll : FsmStateAction + { + public override void Reset() + { + } + + public override void OnEnter() + { + PlayerPrefs.DeleteAll(); + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteAll.cs.meta b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteAll.cs.meta new file mode 100755 index 0000000..f8d88b5 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteAll.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5501f7a70d7cf49629369f172e27da15 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteKey.cs b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteKey.cs new file mode 100755 index 0000000..f7750ba --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteKey.cs @@ -0,0 +1,24 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("PlayerPrefs")] + [Tooltip("Removes key and its corresponding value from the preferences.")] + public class PlayerPrefsDeleteKey : FsmStateAction + { + public FsmString key; + + public override void Reset() + { + key = ""; + } + + public override void OnEnter() + { + if(!key.IsNone && !key.Value.Equals("")) PlayerPrefs.DeleteKey(key.Value); + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteKey.cs.meta b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteKey.cs.meta new file mode 100755 index 0000000..7a96ed4 --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsDeleteKey.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 127b0deba2e8e4726be24dafbcf9a6d5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsGetFloat.cs b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsGetFloat.cs new file mode 100755 index 0000000..10a227d --- /dev/null +++ b/Assets/PlayMaker/Actions/PlayerPrefs/PlayerPrefsGetFloat.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +using UnityEngine; +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("PlayerPrefs")] + [Tooltip("Returns the value corresponding to key in the preference file if it exists.")] + public class PlayerPrefsGetFloat : FsmStateAction + { + [CompoundArray("Count", "Key", "Variable")] + [Tooltip("Case sensitive key.")] + public FsmString[] keys; + [UIHint(UIHint.Variable)] + public FsmFloat[] variables; + + public override void Reset() + { + keys = new FsmString[1]; + variables = new FsmFloat[1]; + } + + public override void OnEnter() + { + for(int i = 0; i 1 && randomEventIndex == lastEventIndex); + + lastEventIndex = randomEventIndex; + + return State.Transitions[randomEventIndex].FsmEvent; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RandomEvent.cs.meta b/Assets/PlayMaker/Actions/RandomEvent.cs.meta new file mode 100755 index 0000000..635d959 --- /dev/null +++ b/Assets/PlayMaker/Actions/RandomEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 44d48efcf6f18084996147a88a4ffb12 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RandomFloat.cs b/Assets/PlayMaker/Actions/RandomFloat.cs new file mode 100755 index 0000000..6ee5cd6 --- /dev/null +++ b/Assets/PlayMaker/Actions/RandomFloat.cs @@ -0,0 +1,33 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Sets a Float Variable to a random value between Min/Max.")] + public class RandomFloat : FsmStateAction + { + [RequiredField] + public FsmFloat min; + [RequiredField] + public FsmFloat max; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeResult; + + public override void Reset() + { + min = 0f; + max = 1f; + storeResult = null; + } + + public override void OnEnter() + { + storeResult.Value = Random.Range(min.Value, max.Value); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RandomFloat.cs.meta b/Assets/PlayMaker/Actions/RandomFloat.cs.meta new file mode 100755 index 0000000..9b7f5ee --- /dev/null +++ b/Assets/PlayMaker/Actions/RandomFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f0884723e2cedce4e96387c846f324fb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RandomInt.cs b/Assets/PlayMaker/Actions/RandomInt.cs new file mode 100755 index 0000000..3ec4769 --- /dev/null +++ b/Assets/PlayMaker/Actions/RandomInt.cs @@ -0,0 +1,40 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// 'inclusiveMax' option added by MaDDoX (@brenoazevedo) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Sets an Integer Variable to a random value between Min/Max.")] + public class RandomInt : FsmStateAction + { + [RequiredField] + public FsmInt min; + [RequiredField] + public FsmInt max; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt storeResult; + [Tooltip("Should the Max value be included in the possible results?")] + public bool inclusiveMax; + + public override void Reset() + { + min = 0; + max = 100; + storeResult = null; + // make default false to not break old behavior. + inclusiveMax = false; + } + + public override void OnEnter() + { + storeResult.Value = (inclusiveMax) ? + Random.Range(min.Value, max.Value + 1) : + Random.Range(min.Value, max.Value); + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RandomInt.cs.meta b/Assets/PlayMaker/Actions/RandomInt.cs.meta new file mode 100755 index 0000000..c7a5471 --- /dev/null +++ b/Assets/PlayMaker/Actions/RandomInt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f75a76cb3f87b8847b792a044ff76217 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RandomWait.cs b/Assets/PlayMaker/Actions/RandomWait.cs new file mode 100755 index 0000000..325f598 --- /dev/null +++ b/Assets/PlayMaker/Actions/RandomWait.cs @@ -0,0 +1,80 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// Thanks derkoi: +// http://hutonggames.com/playmakerforum/index.php?topic=4700.0 + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Time)] + [Tooltip("Delays a State from finishing by a random time. NOTE: Other actions continue, but FINISHED can't happen before Time.")] + public class RandomWait : FsmStateAction + { + + [RequiredField] + [Tooltip("Minimum amount of time to wait.")] + public FsmFloat min; + + [RequiredField] + [Tooltip("Maximum amount of time to wait.")] + public FsmFloat max; + + [Tooltip("Event to send when timer is finished.")] + public FsmEvent finishEvent; + + [Tooltip("Ignore time scale.")] + public bool realTime; + + + private float startTime; + private float timer; + private float time; + + public override void Reset() + { + min = 0f; + max = 1f; + finishEvent = null; + realTime = false; + } + + public override void OnEnter() + { + time = Random.Range(min.Value, max.Value); + + if (time <= 0) + { + Fsm.Event(finishEvent); + Finish(); + return; + } + + startTime = FsmTime.RealtimeSinceStartup; + timer = 0f; + } + + public override void OnUpdate() + { + // update time + + if (realTime) + { + timer = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + timer += Time.deltaTime; + } + + if (timer >= time) + { + Finish(); + if (finishEvent != null) + { + Fsm.Event(finishEvent); + } + } + } + + } +} diff --git a/Assets/PlayMaker/Actions/RandomWait.cs.meta b/Assets/PlayMaker/Actions/RandomWait.cs.meta new file mode 100755 index 0000000..0a766d0 --- /dev/null +++ b/Assets/PlayMaker/Actions/RandomWait.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 37507b4af45ecfc42a3231ce7c64377d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Raycast.cs b/Assets/PlayMaker/Actions/Raycast.cs new file mode 100755 index 0000000..f59fc52 --- /dev/null +++ b/Assets/PlayMaker/Actions/Raycast.cs @@ -0,0 +1,167 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Casts a Ray against all Colliders in the scene. Use either a Game Object or Vector3 world position as the origin of the ray. Use GetRaycastInfo to get more detailed info.")] + public class Raycast : FsmStateAction + { + //[ActionSection("Setup Raycast")] + + [Tooltip("Start ray at game object position. \nOr use From Position parameter.")] + public FsmOwnerDefault fromGameObject; + + [Tooltip("Start ray at a vector3 world position. \nOr use Game Object parameter.")] + public FsmVector3 fromPosition; + + [Tooltip("A vector3 direction vector")] + public FsmVector3 direction; + + [Tooltip("Cast the ray in world or local space. Note if no Game Object is specfied, the direction is in world space.")] + public Space space; + + [Tooltip("The length of the ray. Set to -1 for infinity.")] + public FsmFloat distance; + + [ActionSection("Result")] + + [Tooltip("Event to send if the ray hits an object.")] + [UIHint(UIHint.Variable)] + public FsmEvent hitEvent; + + [Tooltip("Set a bool variable to true if hit something, otherwise false.")] + [UIHint(UIHint.Variable)] + public FsmBool storeDidHit; + + [Tooltip("Store the game object hit in a variable.")] + [UIHint(UIHint.Variable)] + public FsmGameObject storeHitObject; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the world position of the ray hit point and store it in a variable.")] + public FsmVector3 storeHitPoint; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the normal at the hit point and store it in a variable.")] + public FsmVector3 storeHitNormal; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the distance along the ray to the hit point and store it in a variable.")] + public FsmFloat storeHitDistance; + + [ActionSection("Filter")] + + [Tooltip("Set how often to cast a ray. 0 = once, don't repeat; 1 = everyFrame; 2 = every other frame... \nSince raycasts can get expensive use the highest repeat interval you can get away with.")] + public FsmInt repeatInterval; + + [UIHint(UIHint.Layer)] + [Tooltip("Pick only from these layers.")] + public FsmInt[] layerMask; + + [Tooltip("Invert the mask, so you pick from all layers except those defined above.")] + public FsmBool invertMask; + + [ActionSection("Debug")] + + [Tooltip("The color to use for the debug line.")] + public FsmColor debugColor; + + [Tooltip("Draw a debug line. Note: Check Gizmos in the Game View to see it in game.")] + public FsmBool debug; + + int repeat; + + public override void Reset() + { + fromGameObject = null; + fromPosition = new FsmVector3 { UseVariable = true }; + direction = new FsmVector3 { UseVariable = true }; + space = Space.Self; + distance = 100; + hitEvent = null; + storeDidHit = null; + storeHitObject = null; + storeHitPoint = null; + storeHitNormal = null; + storeHitDistance = null; + repeatInterval = 1; + layerMask = new FsmInt[0]; + invertMask = false; + debugColor = Color.yellow; + debug = false; + } + + public override void OnEnter() + { + DoRaycast(); + + if (repeatInterval.Value == 0) + { + Finish(); + } + } + + public override void OnUpdate() + { + repeat--; + + if (repeat == 0) + { + DoRaycast(); + } + } + + void DoRaycast() + { + repeat = repeatInterval.Value; + + if (distance.Value == 0) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(fromGameObject); + + var originPos = go != null ? go.transform.position : fromPosition.Value; + + var rayLength = Mathf.Infinity; + if (distance.Value > 0 ) + { + rayLength = distance.Value; + } + + var dirVector = direction.Value; + if(go != null && space == Space.Self) + { + dirVector = go.transform.TransformDirection(direction.Value); + } + + RaycastHit hitInfo; + Physics.Raycast(originPos, dirVector, out hitInfo, rayLength, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value)); + + Fsm.RaycastHitInfo = hitInfo; + + var didHit = hitInfo.collider != null; + + storeDidHit.Value = didHit; + + if (didHit) + { + storeHitObject.Value = hitInfo.collider.gameObject; + storeHitPoint.Value = Fsm.RaycastHitInfo.point; + storeHitNormal.Value = Fsm.RaycastHitInfo.normal; + storeHitDistance.Value = Fsm.RaycastHitInfo.distance; + Fsm.Event(hitEvent); + } + + if (debug.Value) + { + var debugRayLength = Mathf.Min(rayLength, 1000); + Debug.DrawLine(originPos, originPos + dirVector * debugRayLength, debugColor.Value); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/Raycast.cs.meta b/Assets/PlayMaker/Actions/Raycast.cs.meta new file mode 100755 index 0000000..5bd91ab --- /dev/null +++ b/Assets/PlayMaker/Actions/Raycast.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b2f50df742f99db41ac598460ff5e062 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RaycastAll.cs b/Assets/PlayMaker/Actions/RaycastAll.cs new file mode 100755 index 0000000..61f941d --- /dev/null +++ b/Assets/PlayMaker/Actions/RaycastAll.cs @@ -0,0 +1,173 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Casts a Ray against all Colliders in the scene. Use either a GameObject or Vector3 world position as the origin of the ray. Use GetRaycastAllInfo to get more detailed info.")] + public class RaycastAll : FsmStateAction + { + public static RaycastHit[] RaycastAllHitInfo; + + //[ActionSection("Setup Raycast")] + + [Tooltip("Start ray at game object position. \nOr use From Position parameter.")] + public FsmOwnerDefault fromGameObject; + + [Tooltip("Start ray at a vector3 world position. \nOr use Game Object parameter.")] + public FsmVector3 fromPosition; + + [Tooltip("A vector3 direction vector")] + public FsmVector3 direction; + + [Tooltip("Cast the ray in world or local space. Note if no Game Object is specfied, the direction is in world space.")] + public Space space; + + [Tooltip("The length of the ray. Set to -1 for infinity.")] + public FsmFloat distance; + + [ActionSection("Result")] + + [Tooltip("Event to send if the ray hits an object.")] + [UIHint(UIHint.Variable)] + public FsmEvent hitEvent; + + [Tooltip("Set a bool variable to true if hit something, otherwise false.")] + [UIHint(UIHint.Variable)] + public FsmBool storeDidHit; + + [Tooltip("Store the GameObjects hit in an array variable.")] + [UIHint(UIHint.Variable)] + [ArrayEditor(VariableType.GameObject)] + public FsmArray storeHitObjects; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the world position of the ray hit point and store it in a variable.")] + public FsmVector3 storeHitPoint; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the normal at the hit point and store it in a variable.")] + public FsmVector3 storeHitNormal; + + [UIHint(UIHint.Variable)] + [Tooltip("Get the distance along the ray to the hit point and store it in a variable.")] + public FsmFloat storeHitDistance; + + [ActionSection("Filter")] + + [Tooltip("Set how often to cast a ray. 0 = once, don't repeat; 1 = everyFrame; 2 = every other frame... \nSince raycasts can get expensive use the highest repeat interval you can get away with.")] + public FsmInt repeatInterval; + + [UIHint(UIHint.Layer)] + [Tooltip("Pick only from these layers.")] + public FsmInt[] layerMask; + + [Tooltip("Invert the mask, so you pick from all layers except those defined above.")] + public FsmBool invertMask; + + [ActionSection("Debug")] + + [Tooltip("The color to use for the debug line.")] + public FsmColor debugColor; + + [Tooltip("Draw a debug line. Note: Check Gizmos in the Game View to see it in game.")] + public FsmBool debug; + + int repeat; + + public override void Reset() + { + fromGameObject = null; + fromPosition = new FsmVector3 { UseVariable = true }; + direction = new FsmVector3 { UseVariable = true }; + space = Space.Self; + distance = 100; + hitEvent = null; + storeDidHit = null; + storeHitObjects = null; + storeHitPoint = null; + storeHitNormal = null; + storeHitDistance = null; + repeatInterval = 1; + layerMask = new FsmInt[0]; + invertMask = false; + debugColor = Color.yellow; + debug = false; + } + + public override void OnEnter() + { + DoRaycast(); + + if (repeatInterval.Value == 0) + { + Finish(); + } + } + + public override void OnUpdate() + { + repeat--; + + if (repeat == 0) + { + DoRaycast(); + } + } + + void DoRaycast() + { + repeat = repeatInterval.Value; + + if (distance.Value == 0) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(fromGameObject); + + var originPos = go != null ? go.transform.position : fromPosition.Value; + + var rayLength = Mathf.Infinity; + if (distance.Value > 0 ) + { + rayLength = distance.Value; + } + + var dirVector = direction.Value; + if(go != null && space == Space.Self) + { + dirVector = go.transform.TransformDirection(direction.Value); + } + + RaycastAllHitInfo = Physics.RaycastAll(originPos, dirVector, rayLength, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value)); + + var didHit = RaycastAllHitInfo.Length > 0; + storeDidHit.Value = didHit; + + if (didHit) + { + var gameObjectsHit = new GameObject[RaycastAllHitInfo.Length]; + for (int i = 0; i < RaycastAllHitInfo.Length; i++) + { + var hit = RaycastAllHitInfo[i]; + gameObjectsHit[i] = hit.collider.gameObject; + } + + storeHitObjects.Values = gameObjectsHit; + storeHitPoint.Value = Fsm.RaycastHitInfo.point; + storeHitNormal.Value = Fsm.RaycastHitInfo.normal; + storeHitDistance.Value = Fsm.RaycastHitInfo.distance; + Fsm.Event(hitEvent); + } + + if (debug.Value) + { + var debugRayLength = Mathf.Min(rayLength, 1000); + Debug.DrawLine(originPos, originPos + dirVector * debugRayLength, debugColor.Value); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/RaycastAll.cs.meta b/Assets/PlayMaker/Actions/RaycastAll.cs.meta new file mode 100755 index 0000000..b74d0a6 --- /dev/null +++ b/Assets/PlayMaker/Actions/RaycastAll.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eb7dfc6b98090c944b4795e08c211a16 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RectContains.cs b/Assets/PlayMaker/Actions/RectContains.cs new file mode 100755 index 0000000..eeb3d5d --- /dev/null +++ b/Assets/PlayMaker/Actions/RectContains.cs @@ -0,0 +1,98 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Rect)] + [Tooltip("Tests if a point is inside a rectangle.")] + public class RectContains : FsmStateAction + { + [RequiredField] + [Tooltip("Rectangle to test.")] + public FsmRect rectangle; + + [Tooltip("Point to test.")] + public FsmVector3 point; + + [Tooltip("Specify/override X value.")] + public FsmFloat x; + + [Tooltip("Specify/override Y value.")] + public FsmFloat y; + + //[ActionSection("")] + + [Tooltip("Event to send if the Point is inside the Rectangle.")] + public FsmEvent trueEvent; + + [Tooltip("Event to send if the Point is outside the Rectangle.")] + public FsmEvent falseEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a variable.")] + public FsmBool storeResult; + + //[ActionSection("")] + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + rectangle = new FsmRect { UseVariable = true }; + point = new FsmVector3 { UseVariable = true }; + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + storeResult = null; + trueEvent = null; + falseEvent = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoRectContains(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoRectContains(); + } + + void DoRectContains() + { + if (rectangle.IsNone) + { + return; + } + + // get point to test from inputs + + var testPoint = point.Value; + + if (!x.IsNone) + { + testPoint.x = x.Value; + } + + if (!y.IsNone) + { + testPoint.y = y.Value; + } + + // do results + + var contained = rectangle.Value.Contains(testPoint); + + storeResult.Value = contained; + + Fsm.Event(contained ? trueEvent : falseEvent); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RectContains.cs.meta b/Assets/PlayMaker/Actions/RectContains.cs.meta new file mode 100755 index 0000000..6bb708f --- /dev/null +++ b/Assets/PlayMaker/Actions/RectContains.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3879258ccc484f541aa411a7b6a16cc3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RectOverlaps.cs b/Assets/PlayMaker/Actions/RectOverlaps.cs new file mode 100755 index 0000000..5f72b38 --- /dev/null +++ b/Assets/PlayMaker/Actions/RectOverlaps.cs @@ -0,0 +1,90 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Rect)] + [Tooltip("Tests if 2 Rects overlap.")] + public class RectOverlaps : FsmStateAction + { + [RequiredField] + [Tooltip("First Rectangle.")] + public FsmRect rect1; + + [RequiredField] + [Tooltip("Second Rectangle.")] + public FsmRect rect2; + + [Tooltip("Event to send if the Rects overlap.")] + public FsmEvent trueEvent; + + [Tooltip("Event to send if the Rects do not overlap.")] + public FsmEvent falseEvent; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in a variable.")] + public FsmBool storeResult; + + //[ActionSection("")] + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + rect1 = new FsmRect { UseVariable = true }; + rect2 = new FsmRect { UseVariable = true }; + storeResult = null; + trueEvent = null; + falseEvent = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoRectOverlap(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoRectOverlap(); + } + + void DoRectOverlap() + { + if (rect1.IsNone || rect2.IsNone) + { + return; + } + + var overlapping = Intersect(rect1.Value, rect2.Value); + storeResult.Value = overlapping; + Fsm.Event(overlapping ? trueEvent : falseEvent); + } + + public static bool Intersect(Rect a, Rect b) + { + FlipNegative(ref a); + FlipNegative(ref b); + bool c1 = a.xMin < b.xMax; + bool c2 = a.xMax > b.xMin; + bool c3 = a.yMin < b.yMax; + bool c4 = a.yMax > b.yMin; + return c1 && c2 && c3 && c4; + } + + public static void FlipNegative(ref Rect r) + { + if (r.width < 0) + r.x -= (r.width *= -1); + if (r.height < 0) + r.y -= (r.height *= -1); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RectOverlaps.cs.meta b/Assets/PlayMaker/Actions/RectOverlaps.cs.meta new file mode 100755 index 0000000..63cc6ca --- /dev/null +++ b/Assets/PlayMaker/Actions/RectOverlaps.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 28b208024f55972479e3c39902c27282 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RemoveMixingTransform.cs b/Assets/PlayMaker/Actions/RemoveMixingTransform.cs new file mode 100755 index 0000000..1740e1a --- /dev/null +++ b/Assets/PlayMaker/Actions/RemoveMixingTransform.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Removes a mixing transform previously added with Add Mixing Transform. If transform has been added as recursive, then it will be removed as recursive. Once you remove all mixing transforms added to animation state all curves become animated again.")] + public class RemoveMixingTransform : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + [Tooltip("The GameObject playing the animation.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The name of the animation.")] + public FsmString animationName; + [RequiredField] + + [Tooltip("The mixing transform to remove. E.g., root/upper_body/left_shoulder")] + public FsmString transfrom; + + public override void Reset() + { + gameObject = null; + animationName = ""; + } + + public override void OnEnter() + { + DoRemoveMixingTransform(); + + Finish(); + } + + void DoRemoveMixingTransform() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + var animClip = animation[animationName.Value]; + if (animClip == null) + { + return; + } + + var mixingTransform = go.transform.Find(transfrom.Value); + animClip.AddMixingTransform(mixingTransform); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RemoveMixingTransform.cs.meta b/Assets/PlayMaker/Actions/RemoveMixingTransform.cs.meta new file mode 100755 index 0000000..cc1af65 --- /dev/null +++ b/Assets/PlayMaker/Actions/RemoveMixingTransform.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e312a237c7efd4f41b1cf3391f9aac98 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ResetGUIMatrix.cs b/Assets/PlayMaker/Actions/ResetGUIMatrix.cs new file mode 100755 index 0000000..a2efcc3 --- /dev/null +++ b/Assets/PlayMaker/Actions/ResetGUIMatrix.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Resets the GUI matrix. Useful if you've rotated or scaled the GUI and now want to reset it.")] + public class ResetGUIMatrix : FsmStateAction + { + public override void OnGUI() + { + PlayMakerGUI.GUIMatrix = GUI.matrix = Matrix4x4.identity; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ResetGUIMatrix.cs.meta b/Assets/PlayMaker/Actions/ResetGUIMatrix.cs.meta new file mode 100755 index 0000000..4db8f92 --- /dev/null +++ b/Assets/PlayMaker/Actions/ResetGUIMatrix.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 02176d2a0e0c28b47ab11859676fafb6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ResetInputAxes.cs b/Assets/PlayMaker/Actions/ResetInputAxes.cs new file mode 100755 index 0000000..1cc0e7b --- /dev/null +++ b/Assets/PlayMaker/Actions/ResetInputAxes.cs @@ -0,0 +1,19 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Resets all Input. After ResetInputAxes all axes return to 0 and all buttons return to 0 for one frame")] + public class ResetInputAxes : FsmStateAction + { + public override void Reset(){} + + public override void OnEnter() + { + Input.ResetInputAxes(); + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ResetInputAxes.cs.meta b/Assets/PlayMaker/Actions/ResetInputAxes.cs.meta new file mode 100755 index 0000000..18133ac --- /dev/null +++ b/Assets/PlayMaker/Actions/ResetInputAxes.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 28036865b5d7931449427b86f2f979db +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RestartLevel.cs b/Assets/PlayMaker/Actions/RestartLevel.cs new file mode 100755 index 0000000..ea4d38b --- /dev/null +++ b/Assets/PlayMaker/Actions/RestartLevel.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// micro script by Andrew Raphael Lukasik + +#if (UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2) +#define UNITY_PRE_5_3 +#endif + +using UnityEngine; +#if !UNITY_PRE_5_3 +using UnityEngine.SceneManagement; +#endif + + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Level)] + [Tooltip("Restarts current level.")] + public class RestartLevel : FsmStateAction + { + public override void OnEnter() + { +#if UNITY_PRE_5_3 + Application.LoadLevel(Application.loadedLevelName); +#else + SceneManager.LoadScene(SceneManager.GetActiveScene().name); +#endif + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RestartLevel.cs.meta b/Assets/PlayMaker/Actions/RestartLevel.cs.meta new file mode 100755 index 0000000..fcfd3cc --- /dev/null +++ b/Assets/PlayMaker/Actions/RestartLevel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c06952405da47b24a98a90cb4677b23f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RewindAnimation.cs b/Assets/PlayMaker/Actions/RewindAnimation.cs new file mode 100755 index 0000000..e754774 --- /dev/null +++ b/Assets/PlayMaker/Actions/RewindAnimation.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Rewinds the named animation.")] + public class RewindAnimation : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.Animation)] + public FsmString animName; + + public override void Reset() + { + gameObject = null; + animName = null; + } + + public override void OnEnter() + { + DoRewindAnimation(); + + Finish(); + } + + void DoRewindAnimation() + { + if (string.IsNullOrEmpty(animName.Value)) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + animation.Rewind(animName.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RewindAnimation.cs.meta b/Assets/PlayMaker/Actions/RewindAnimation.cs.meta new file mode 100755 index 0000000..60d69f9 --- /dev/null +++ b/Assets/PlayMaker/Actions/RewindAnimation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: df5af008ae532374aa35afd9bfd06177 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Rotate.cs b/Assets/PlayMaker/Actions/Rotate.cs new file mode 100755 index 0000000..be7cdd4 --- /dev/null +++ b/Assets/PlayMaker/Actions/Rotate.cs @@ -0,0 +1,137 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Rotates a Game Object around each Axis. Use a Vector3 Variable and/or XYZ components. To leave any axis unchanged, set variable to 'None'.")] + public class Rotate : FsmStateAction + { + [RequiredField] + [Tooltip("The game object to rotate.")] + public FsmOwnerDefault gameObject; + + [Tooltip("A rotation vector. NOTE: You can override individual axis below.")] + [UIHint(UIHint.Variable)] + public FsmVector3 vector; + + [Tooltip("Rotation around x axis.")] + public FsmFloat xAngle; + + [Tooltip("Rotation around y axis.")] + public FsmFloat yAngle; + + [Tooltip("Rotation around z axis.")] + public FsmFloat zAngle; + + [Tooltip("Rotate in local or world space.")] + public Space space; + + [Tooltip("Rotate over one second")] + public bool perSecond; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + [Tooltip("Perform the rotation in LateUpdate. This is useful if you want to override the rotation of objects that are animated or otherwise rotated in Update.")] + public bool lateUpdate; + + [Tooltip("Perform the rotation in FixedUpdate. This is useful when working with rigid bodies and physics.")] + public bool fixedUpdate; + + public override void Reset() + { + gameObject = null; + vector = null; + // default axis to variable dropdown with None selected. + xAngle = new FsmFloat { UseVariable = true }; + yAngle = new FsmFloat { UseVariable = true }; + zAngle = new FsmFloat { UseVariable = true }; + space = Space.Self; + perSecond = false; + everyFrame = true; + lateUpdate = false; + fixedUpdate = false; + } + + public override void OnPreprocess() + { + Fsm.HandleFixedUpdate = true; + } + + public override void OnEnter() + { + if(!everyFrame && !lateUpdate && !fixedUpdate) + { + DoRotate(); + Finish(); + } + } + + public override void OnUpdate() + { + if (!lateUpdate && !fixedUpdate) + { + DoRotate(); + } + } + + public override void OnLateUpdate() + { + if (lateUpdate) + { + DoRotate(); + } + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnFixedUpdate() + { + if (fixedUpdate) + { + DoRotate(); + } + + if (!everyFrame) + { + Finish(); + } + } + + void DoRotate() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // Use vector if specified + + var rotate = vector.IsNone ? new Vector3(xAngle.Value, yAngle.Value, zAngle.Value) : vector.Value; + + // override any axis + + if (!xAngle.IsNone) rotate.x = xAngle.Value; + if (!yAngle.IsNone) rotate.y = yAngle.Value; + if (!zAngle.IsNone) rotate.z = zAngle.Value; + + // apply + + if (!perSecond) + { + go.transform.Rotate(rotate, space); + } + else + { + go.transform.Rotate(rotate * Time.deltaTime, space); + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Rotate.cs.meta b/Assets/PlayMaker/Actions/Rotate.cs.meta new file mode 100755 index 0000000..ea31ffd --- /dev/null +++ b/Assets/PlayMaker/Actions/Rotate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: afc1c6ea49cb9eb4cb8211e23db57545 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RotateGUI.cs b/Assets/PlayMaker/Actions/RotateGUI.cs new file mode 100755 index 0000000..d699d08 --- /dev/null +++ b/Assets/PlayMaker/Actions/RotateGUI.cs @@ -0,0 +1,60 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Rotates the GUI around a pivot point. By default only effects GUI rendered by this FSM, check Apply Globally to effect all GUI controls.")] + public class RotateGUI : FsmStateAction + { + [RequiredField] + public FsmFloat angle; + [RequiredField] + public FsmFloat pivotX; + [RequiredField] + public FsmFloat pivotY; + public bool normalized; + public bool applyGlobally; + + bool applied; + + public override void Reset() + { + angle = 0; + pivotX = 0.5f; + pivotY = 0.5f; + normalized = true; + applyGlobally = false; + } + + public override void OnGUI() + { + if (applied) + { + return; + } + + var pivotPoint = new Vector2(pivotX.Value, pivotY.Value); + + if (normalized) + { + pivotPoint.x *= Screen.width; + pivotPoint.y *= Screen.height; + } + + GUIUtility.RotateAroundPivot(angle.Value, pivotPoint); + + if (applyGlobally) + { + PlayMakerGUI.GUIMatrix = GUI.matrix; + applied = true; + } + } + + public override void OnUpdate() + { + applied = false; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/RotateGUI.cs.meta b/Assets/PlayMaker/Actions/RotateGUI.cs.meta new file mode 100755 index 0000000..c38dc3d --- /dev/null +++ b/Assets/PlayMaker/Actions/RotateGUI.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3eee34a1e1638a438487dcbdb4616ef +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RunFSM.cs b/Assets/PlayMaker/Actions/RunFSM.cs new file mode 100755 index 0000000..1be0f5b --- /dev/null +++ b/Assets/PlayMaker/Actions/RunFSM.cs @@ -0,0 +1,74 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Creates an FSM from a saved FSM Template.")] + public class RunFSM : RunFSMAction + { + public FsmTemplateControl fsmTemplateControl = new FsmTemplateControl(); + + [UIHint(UIHint.Variable)] + public FsmInt storeID; + + [Tooltip("Event to send when the FSM has finished (usually because it ran a Finish FSM action).")] + public FsmEvent finishEvent; + + public override void Reset() + { + fsmTemplateControl = new FsmTemplateControl(); + storeID = null; + runFsm = null; + } + + /// + /// Initialize FSM on awake so it doesn't cause hitches later + /// + public override void Awake() + { + if (fsmTemplateControl.fsmTemplate != null && Application.isPlaying) + { + runFsm = Fsm.CreateSubFsm(fsmTemplateControl); + } + } + + /// + /// Start the FSM on entering the state + /// + public override void OnEnter() + { + if (runFsm == null) + { + Finish(); + return; + } + + fsmTemplateControl.UpdateValues(); + fsmTemplateControl.ApplyOverrides(runFsm); + + runFsm.OnEnable(); + + if (!runFsm.Started) + { + runFsm.Start(); + } + + storeID.Value = fsmTemplateControl.ID; + + CheckIfFinished(); + } + + // Other functionality covered in RunFSMAction base class + + protected override void CheckIfFinished() + { + if (runFsm == null || runFsm.Finished) + { + Finish(); + Fsm.Event(finishEvent); + } + } + } +} diff --git a/Assets/PlayMaker/Actions/RunFSM.cs.meta b/Assets/PlayMaker/Actions/RunFSM.cs.meta new file mode 100755 index 0000000..382ddba --- /dev/null +++ b/Assets/PlayMaker/Actions/RunFSM.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4d7b4c7e53243804f8ddd98b1f317bfb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/RunFSMAction.cs b/Assets/PlayMaker/Actions/RunFSMAction.cs new file mode 100755 index 0000000..fd15fba --- /dev/null +++ b/Assets/PlayMaker/Actions/RunFSMAction.cs @@ -0,0 +1,170 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [Tooltip("Base class for actions that want to run a sub FSM.")] + public abstract class RunFSMAction : FsmStateAction + { + protected Fsm runFsm; + + public override void Reset() + { + runFsm = null; + } + + /// + /// Forward global events to the sub FSM + /// + public override bool Event(FsmEvent fsmEvent) + { + if (runFsm != null && (fsmEvent.IsGlobal || fsmEvent.IsSystemEvent)) + { + runFsm.Event(fsmEvent); + } + + return false; + } + + /// + /// Start the FSM on entering the state + /// + public override void OnEnter() + { + if (runFsm == null) + { + Finish(); + return; + } + + runFsm.OnEnable(); + + if (!runFsm.Started) + { + runFsm.Start(); + } + + CheckIfFinished(); + } + + public override void OnUpdate() + { + if (runFsm != null) + { + runFsm.Update(); + CheckIfFinished(); + } + else + { + Finish(); + } + } + + public override void OnFixedUpdate() + { + if (runFsm != null) + { + runFsm.FixedUpdate(); + CheckIfFinished(); + } + else + { + Finish(); + } + } + + public override void OnLateUpdate() + { + if (runFsm != null) + { + runFsm.LateUpdate(); + CheckIfFinished(); + } + else + { + Finish(); + } + } + + public override void DoTriggerEnter(Collider other) + { + if (runFsm.HandleTriggerEnter) + { + runFsm.OnTriggerEnter(other); + } + } + + public override void DoTriggerStay(Collider other) + { + if (runFsm.HandleTriggerStay) + { + runFsm.OnTriggerStay(other); + } + } + + public override void DoTriggerExit(Collider other) + { + if (runFsm.HandleTriggerExit) + { + runFsm.OnTriggerExit(other); + } + } + + public override void DoCollisionEnter(Collision collisionInfo) + { + if (runFsm.HandleCollisionEnter) + { + runFsm.OnCollisionEnter(collisionInfo); + } + } + + public override void DoCollisionStay(Collision collisionInfo) + { + if (runFsm.HandleCollisionStay) + { + runFsm.OnCollisionStay(collisionInfo); + } + } + + public override void DoCollisionExit(Collision collisionInfo) + { + if (runFsm.HandleCollisionExit) + { + runFsm.OnCollisionExit(collisionInfo); + } + } + + public override void DoControllerColliderHit(ControllerColliderHit collisionInfo) + { + runFsm.OnControllerColliderHit(collisionInfo); + } + + public override void OnGUI() + { + if (runFsm != null && runFsm.HandleOnGUI) + { + runFsm.OnGUI(); + } + } + + /// + /// Stop the FSM on exiting the state + /// + public override void OnExit() + { + if (runFsm != null) + { + runFsm.Stop(); + } + } + + protected virtual void CheckIfFinished() + { + if (runFsm == null || runFsm.Finished) + { + Finish(); + } + } + } +} diff --git a/Assets/PlayMaker/Actions/RunFSMAction.cs.meta b/Assets/PlayMaker/Actions/RunFSMAction.cs.meta new file mode 100755 index 0000000..61918b3 --- /dev/null +++ b/Assets/PlayMaker/Actions/RunFSMAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a000d7d498ec6a841a828fc0a90a84c4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SampleCurve.cs b/Assets/PlayMaker/Actions/SampleCurve.cs new file mode 100755 index 0000000..3d06672 --- /dev/null +++ b/Assets/PlayMaker/Actions/SampleCurve.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Gets the value of a curve at a given time and stores it in a Float Variable. NOTE: This can be used for more than just animation! It's a general way to transform an input number into an output number using a curve (e.g., linear input -> bell curve).")] + public class SampleCurve : FsmStateAction + { + [RequiredField] + public FsmAnimationCurve curve; + [RequiredField] + public FsmFloat sampleAt; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat storeValue; + public bool everyFrame; + + public override void Reset() + { + curve = null; + sampleAt = null; + storeValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSampleCurve(); + + if(!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSampleCurve(); + } + + void DoSampleCurve() + { + if (curve == null || curve.curve == null || storeValue == null) + return; + + storeValue.Value = curve.curve.Evaluate(sampleAt.Value); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SampleCurve.cs.meta b/Assets/PlayMaker/Actions/SampleCurve.cs.meta new file mode 100755 index 0000000..988d1a0 --- /dev/null +++ b/Assets/PlayMaker/Actions/SampleCurve.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ff6ea1c567e6324418af3ce38d21ad15 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ScaleGUI.cs b/Assets/PlayMaker/Actions/ScaleGUI.cs new file mode 100755 index 0000000..7ea7825 --- /dev/null +++ b/Assets/PlayMaker/Actions/ScaleGUI.cs @@ -0,0 +1,80 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !UNITY_FLASH + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Scales the GUI around a pivot point. By default only effects GUI rendered by this FSM, check Apply Globally to effect all GUI controls.")] + public class ScaleGUI : FsmStateAction + { + [RequiredField] + public FsmFloat scaleX; + + [RequiredField] + public FsmFloat scaleY; + + [RequiredField] + public FsmFloat pivotX; + + [RequiredField] + public FsmFloat pivotY; + + [Tooltip("Pivot point uses normalized coordinates. E.g. 0.5 is the center of the screen.")] + public bool normalized; + + public bool applyGlobally; + + bool applied; + + public override void Reset() + { + scaleX = 1f; + scaleY = 1f; + pivotX = 0.5f; + pivotY = 0.5f; + normalized = true; + applyGlobally = false; + } + + public override void OnGUI() + { + if (applied) + { + return; + } + + var scale = new Vector2(scaleX.Value, scaleY.Value); + + // Not allowed to scale to 0 - it breaks the GUI matrix + + if (Equals(scale.x, 0)) scale.x = 0.0001f; + if (Equals(scale.y, 0)) scale.x = 0.0001f; + + var pivotPoint = new Vector2(pivotX.Value, pivotY.Value); + + if (normalized) + { + pivotPoint.x *= Screen.width; + pivotPoint.y *= Screen.height; + } + + GUIUtility.ScaleAroundPivot(scale, pivotPoint); + + if (applyGlobally) + { + PlayMakerGUI.GUIMatrix = GUI.matrix; + applied = true; + } + } + + public override void OnUpdate() + { + applied = false; + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ScaleGUI.cs.meta b/Assets/PlayMaker/Actions/ScaleGUI.cs.meta new file mode 100755 index 0000000..6ed8772 --- /dev/null +++ b/Assets/PlayMaker/Actions/ScaleGUI.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7cb056ea1f15c1b44913c9d39244208b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ScaleTime.cs b/Assets/PlayMaker/Actions/ScaleTime.cs new file mode 100755 index 0000000..1c1db6c --- /dev/null +++ b/Assets/PlayMaker/Actions/ScaleTime.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Time)] + [Tooltip("Scales time: 1 = normal, 0.5 = half speed, 2 = double speed.")] + public class ScaleTime : FsmStateAction + { + [RequiredField] + [HasFloatSlider(0,4)] + [Tooltip("Scales time: 1 = normal, 0.5 = half speed, 2 = double speed.")] + public FsmFloat timeScale; + + [Tooltip("Adjust the fixed physics time step to match the time scale.")] + public FsmBool adjustFixedDeltaTime; + + [Tooltip("Repeat every frame. Useful when animating the value.")] + public bool everyFrame; + + public override void Reset() + { + timeScale = 1.0f; + adjustFixedDeltaTime = true; + everyFrame = false; + } + + public override void OnEnter() + { + DoTimeScale(); + + if (!everyFrame) + { + Finish(); + } + } + public override void OnUpdate() + { + DoTimeScale(); + } + + void DoTimeScale() + { + Time.timeScale = timeScale.Value; + + //TODO: how to get the user set default value? + Time.fixedDeltaTime = 0.02f * Time.timeScale; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ScaleTime.cs.meta b/Assets/PlayMaker/Actions/ScaleTime.cs.meta new file mode 100755 index 0000000..c0a9820 --- /dev/null +++ b/Assets/PlayMaker/Actions/ScaleTime.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a0898764ced5b174ca723ffbfce99ac3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ScreenPick.cs b/Assets/PlayMaker/Actions/ScreenPick.cs new file mode 100755 index 0000000..7a611b0 --- /dev/null +++ b/Assets/PlayMaker/Actions/ScreenPick.cs @@ -0,0 +1,116 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Perform a raycast into the scene using screen coordinates and stores the results. Use Ray Distance to set how close the camera must be to pick the object. NOTE: Uses the MainCamera!")] + public class ScreenPick : FsmStateAction + { + [Tooltip("A Vector3 screen position. Commonly stored by other actions.")] + public FsmVector3 screenVector; + [Tooltip ("X position on screen.")] + public FsmFloat screenX; + [Tooltip ("Y position on screen.")] + public FsmFloat screenY; + [Tooltip("Are the supplied screen coordinates normalized (0-1), or in pixels.")] + public FsmBool normalized; + [RequiredField] + public FsmFloat rayDistance = 100f; + [UIHint(UIHint.Variable)] + public FsmBool storeDidPickObject; + [UIHint(UIHint.Variable)] + public FsmGameObject storeGameObject; + [UIHint(UIHint.Variable)] + public FsmVector3 storePoint; + [UIHint(UIHint.Variable)] + public FsmVector3 storeNormal; + [UIHint(UIHint.Variable)] + public FsmFloat storeDistance; + [UIHint(UIHint.Layer)] + [Tooltip("Pick only from these layers.")] + public FsmInt[] layerMask; + [Tooltip("Invert the mask, so you pick from all layers except those defined above.")] + public FsmBool invertMask; + public bool everyFrame; + + public override void Reset() + { + screenVector = new FsmVector3 { UseVariable = true }; + screenX = new FsmFloat { UseVariable = true }; + screenY = new FsmFloat { UseVariable = true }; + normalized = false; + rayDistance = 100f; + storeDidPickObject = null; + storeGameObject = null; + storePoint = null; + storeNormal = null; + storeDistance = null; + layerMask = new FsmInt[0]; + invertMask = false; + everyFrame = false; + } + + public override void OnEnter() + { + DoScreenPick(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoScreenPick(); + } + + void DoScreenPick() + { + if (Camera.main == null) + { + LogError("No MainCamera defined!"); + Finish(); + return; + } + + var rayStart = Vector3.zero; + + if (!screenVector.IsNone) rayStart = screenVector.Value; + if (!screenX.IsNone) rayStart.x = screenX.Value; + if (!screenY.IsNone) rayStart.y = screenY.Value; + + if (normalized.Value) + { + rayStart.x *= Screen.width; + rayStart.y *= Screen.height; + } + + RaycastHit hitInfo; + var ray = Camera.main.ScreenPointToRay(rayStart); + Physics.Raycast(ray, out hitInfo, rayDistance.Value, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value)); + + var didPick = hitInfo.collider != null; + storeDidPickObject.Value = didPick; + + if (didPick) + { + storeGameObject.Value = hitInfo.collider.gameObject; + storeDistance.Value = hitInfo.distance; + storePoint.Value = hitInfo.point; + storeNormal.Value = hitInfo.normal; + } + else + { + // TODO: not sure if this is the right strategy... + storeGameObject.Value = null; + storeDistance = Mathf.Infinity; + storePoint.Value = Vector3.zero; + storeNormal.Value = Vector3.zero; + } + + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ScreenPick.cs.meta b/Assets/PlayMaker/Actions/ScreenPick.cs.meta new file mode 100755 index 0000000..e6093ca --- /dev/null +++ b/Assets/PlayMaker/Actions/ScreenPick.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0a151663ce2809d40911820353904e71 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/ScreenToWorldPoint.cs b/Assets/PlayMaker/Actions/ScreenToWorldPoint.cs new file mode 100755 index 0000000..88234ec --- /dev/null +++ b/Assets/PlayMaker/Actions/ScreenToWorldPoint.cs @@ -0,0 +1,100 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Transforms position from screen space into world space. NOTE: Uses the MainCamera!")] + public class ScreenToWorldPoint : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("Screen position as a vector.")] + public FsmVector3 screenVector; + [Tooltip("Screen X position in pixels or normalized. See Normalized.")] + public FsmFloat screenX; + [Tooltip("Screen X position in pixels or normalized. See Normalized.")] + public FsmFloat screenY; + [Tooltip("Distance into the screen in world units.")] + public FsmFloat screenZ; + [Tooltip("If true, X/Y coordinates are considered normalized (0-1), otherwise they are expected to be in pixels")] + public FsmBool normalized; + [UIHint(UIHint.Variable)] + [Tooltip("Store the world position in a vector3 variable.")] + public FsmVector3 storeWorldVector; + [UIHint(UIHint.Variable)] + [Tooltip("Store the world X position in a float variable.")] + public FsmFloat storeWorldX; + [UIHint(UIHint.Variable)] + [Tooltip("Store the world Y position in a float variable.")] + public FsmFloat storeWorldY; + [UIHint(UIHint.Variable)] + [Tooltip("Store the world Z position in a float variable.")] + public FsmFloat storeWorldZ; + [Tooltip("Repeat every frame")] + public bool everyFrame; + + public override void Reset() + { + screenVector = null; + // default axis to variable dropdown with None selected. + screenX = new FsmFloat { UseVariable = true }; + screenY = new FsmFloat { UseVariable = true }; + screenZ = 1; + normalized = false; + storeWorldVector = null; + storeWorldX = null; + storeWorldY = null; + storeWorldZ = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoScreenToWorldPoint(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoScreenToWorldPoint(); + } + + void DoScreenToWorldPoint() + { + if (Camera.main == null) + { + LogError("No MainCamera defined!"); + Finish(); + return; + } + + var position = Vector3.zero; + + if(!screenVector.IsNone) position = screenVector.Value; + + if (!screenX.IsNone) position.x = screenX.Value; + if (!screenY.IsNone) position.y = screenY.Value; + if (!screenZ.IsNone) position.z = screenZ.Value; + + if (normalized.Value) + { + position.x *= Screen.width; + position.y *= Screen.height; + } + + position = Camera.main.ScreenToWorldPoint(position); + + storeWorldVector.Value = position; + storeWorldX.Value = position.x; + storeWorldY.Value = position.y; + storeWorldZ.Value = position.z; + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/ScreenToWorldPoint.cs.meta b/Assets/PlayMaker/Actions/ScreenToWorldPoint.cs.meta new file mode 100755 index 0000000..57b828e --- /dev/null +++ b/Assets/PlayMaker/Actions/ScreenToWorldPoint.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cfa47c7459382454cbe1605d8c2a67d9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SelectRandomColor.cs b/Assets/PlayMaker/Actions/SelectRandomColor.cs new file mode 100755 index 0000000..b3f1641 --- /dev/null +++ b/Assets/PlayMaker/Actions/SelectRandomColor.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Color)] + [Tooltip("Select a random Color from an array of Colors.")] + public class SelectRandomColor : FsmStateAction + { + [CompoundArray("Colors", "Color", "Weight")] + public FsmColor[] colors; + [HasFloatSlider(0, 1)] + public FsmFloat[] weights; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmColor storeColor; + + public override void Reset() + { + colors = new FsmColor[3]; + weights = new FsmFloat[] {1,1,1}; + storeColor = null; + } + + public override void OnEnter() + { + DoSelectRandomColor(); + Finish(); + } + + void DoSelectRandomColor() + { + if (colors == null) return; + if (colors.Length == 0) return; + if (storeColor == null) return; + + int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights); + + if (randomIndex != -1) + { + storeColor.Value = colors[randomIndex].Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SelectRandomColor.cs.meta b/Assets/PlayMaker/Actions/SelectRandomColor.cs.meta new file mode 100755 index 0000000..d7a9c2e --- /dev/null +++ b/Assets/PlayMaker/Actions/SelectRandomColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a110ab751cd9f4c42a6ae9a6ce254280 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SelectRandomGameObject.cs b/Assets/PlayMaker/Actions/SelectRandomGameObject.cs new file mode 100755 index 0000000..e131dbb --- /dev/null +++ b/Assets/PlayMaker/Actions/SelectRandomGameObject.cs @@ -0,0 +1,47 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Selects a Random Game Object from an array of Game Objects.")] + public class SelectRandomGameObject : FsmStateAction + { + [CompoundArray("Game Objects", "Game Object", "Weight")] + public FsmGameObject[] gameObjects; + [HasFloatSlider(0, 1)] + public FsmFloat[] weights; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmGameObject storeGameObject; + + public override void Reset () + { + gameObjects = new FsmGameObject[3]; + weights = new FsmFloat[] {1,1,1}; + storeGameObject = null; + } + + public override void OnEnter () + { + DoSelectRandomGameObject(); + Finish(); + } + + void DoSelectRandomGameObject() + { + if (gameObjects == null) return; + if (gameObjects.Length == 0) return; + if (storeGameObject == null) return; + + int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights); + + if (randomIndex != -1) + { + storeGameObject.Value = gameObjects[randomIndex].Value; + } + + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SelectRandomGameObject.cs.meta b/Assets/PlayMaker/Actions/SelectRandomGameObject.cs.meta new file mode 100755 index 0000000..dac01d5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SelectRandomGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 132d207d2906f2742b8aa09313847d1a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SelectRandomString.cs b/Assets/PlayMaker/Actions/SelectRandomString.cs new file mode 100755 index 0000000..e7fa35a --- /dev/null +++ b/Assets/PlayMaker/Actions/SelectRandomString.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Select a Random String from an array of Strings.")] + public class SelectRandomString : FsmStateAction + { + [CompoundArray("Strings", "String", "Weight")] + public FsmString[] strings; + [HasFloatSlider(0, 1)] + public FsmFloat[] weights; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString storeString; + + public override void Reset() + { + strings = new FsmString[3]; + weights = new FsmFloat[] {1,1,1}; + storeString = null; + } + + public override void OnEnter() + { + DoSelectRandomString(); + Finish(); + } + + void DoSelectRandomString() + { + if (strings == null) return; + if (strings.Length == 0) return; + if (storeString == null) return; + + int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights); + + if (randomIndex != -1) + { + storeString.Value = strings[randomIndex].Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SelectRandomString.cs.meta b/Assets/PlayMaker/Actions/SelectRandomString.cs.meta new file mode 100755 index 0000000..140d964 --- /dev/null +++ b/Assets/PlayMaker/Actions/SelectRandomString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2aa2969464467894fadeaa9c413e447f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SelectRandomVector3.cs b/Assets/PlayMaker/Actions/SelectRandomVector3.cs new file mode 100755 index 0000000..704ec2a --- /dev/null +++ b/Assets/PlayMaker/Actions/SelectRandomVector3.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Select a Random Vector3 from a Vector3 array.")] + public class SelectRandomVector3 : FsmStateAction + { + [CompoundArray("Vectors", "Vector", "Weight")] + public FsmVector3[] vector3Array; + [HasFloatSlider(0, 1)] + public FsmFloat[] weights; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 storeVector3; + + public override void Reset() + { + vector3Array = new FsmVector3[3]; + weights = new FsmFloat[] {1,1,1}; + storeVector3 = null; + } + + public override void OnEnter() + { + DoSelectRandomColor(); + Finish(); + } + + void DoSelectRandomColor() + { + if (vector3Array == null) return; + if (vector3Array.Length == 0) return; + if (storeVector3 == null) return; + + int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights); + + if (randomIndex != -1) + { + storeVector3.Value = vector3Array[randomIndex].Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SelectRandomVector3.cs.meta b/Assets/PlayMaker/Actions/SelectRandomVector3.cs.meta new file mode 100755 index 0000000..8682902 --- /dev/null +++ b/Assets/PlayMaker/Actions/SelectRandomVector3.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 38259eedc3e82dc489a816d1c12936d8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SendEvent.cs b/Assets/PlayMaker/Actions/SendEvent.cs new file mode 100755 index 0000000..1d8c916 --- /dev/null +++ b/Assets/PlayMaker/Actions/SendEvent.cs @@ -0,0 +1,66 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sends an Event after an optional delay. NOTE: To send events between FSMs they must be marked as Global in the Events Browser.")] + public class SendEvent : FsmStateAction + { + [Tooltip("Where to send the event.")] + public FsmEventTarget eventTarget; + + [RequiredField] + [Tooltip("The event to send. NOTE: Events must be marked Global to send between FSMs.")] + public FsmEvent sendEvent; + + [HasFloatSlider(0, 10)] + [Tooltip("Optional delay in seconds.")] + public FsmFloat delay; + + [Tooltip("Repeat every frame. Rarely needed, but can be useful when sending events to other FSMs.")] + public bool everyFrame; + + private DelayedEvent delayedEvent; + + public override void Reset() + { + eventTarget = null; + sendEvent = null; + delay = null; + everyFrame = false; + } + + public override void OnEnter() + { + if (delay.Value < 0.001f) + { + Fsm.Event(eventTarget, sendEvent); + if (!everyFrame) + { + Finish(); + } + } + else + { + delayedEvent = Fsm.DelayedEvent(eventTarget, sendEvent, delay.Value); + } + } + + public override void OnUpdate() + { + if (!everyFrame) + { + if (DelayedEvent.WasSent(delayedEvent)) + { + Finish(); + } + } + else + { + Fsm.Event(eventTarget, sendEvent); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SendEvent.cs.meta b/Assets/PlayMaker/Actions/SendEvent.cs.meta new file mode 100755 index 0000000..27aaf35 --- /dev/null +++ b/Assets/PlayMaker/Actions/SendEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2d17db40edbce4c41be55264595c0af8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SendEventByName.cs b/Assets/PlayMaker/Actions/SendEventByName.cs new file mode 100755 index 0000000..630d16c --- /dev/null +++ b/Assets/PlayMaker/Actions/SendEventByName.cs @@ -0,0 +1,64 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sends an Event by name after an optional delay. NOTE: Use this over Send Event if you store events as string variables.")] + public class SendEventByName : FsmStateAction + { + [Tooltip("Where to send the event.")] + public FsmEventTarget eventTarget; + + [RequiredField] + [Tooltip("The event to send. NOTE: Events must be marked Global to send between FSMs.")] + public FsmString sendEvent; + + [HasFloatSlider(0, 10)] + [Tooltip("Optional delay in seconds.")] + public FsmFloat delay; + + [Tooltip("Repeat every frame. Rarely needed, but can be useful when sending events to other FSMs.")] + public bool everyFrame; + + DelayedEvent delayedEvent; + + public override void Reset() + { + eventTarget = null; + sendEvent = null; + delay = null; + everyFrame = false; + } + + public override void OnEnter() + { + if (delay.Value < 0.001f) + { + Fsm.Event(eventTarget, sendEvent.Value); + if (!everyFrame) + { + Finish(); + } + } + else + { + delayedEvent = Fsm.DelayedEvent(eventTarget, FsmEvent.GetFsmEvent(sendEvent.Value), delay.Value); + } + } + + public override void OnUpdate() + { + if (!everyFrame) + { + if (DelayedEvent.WasSent(delayedEvent)) + { + Finish(); + } + } + else + { + Fsm.Event(eventTarget, sendEvent.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SendEventByName.cs.meta b/Assets/PlayMaker/Actions/SendEventByName.cs.meta new file mode 100755 index 0000000..fd58b82 --- /dev/null +++ b/Assets/PlayMaker/Actions/SendEventByName.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5e9e10e15541c9d4598f27322fe43a95 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SendEventToFsm.cs b/Assets/PlayMaker/Actions/SendEventToFsm.cs new file mode 100755 index 0000000..f871e1d --- /dev/null +++ b/Assets/PlayMaker/Actions/SendEventToFsm.cs @@ -0,0 +1,78 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [Obsolete("This action is obsolete; use Send Event with Event Target instead.")] + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sends an Event to another Fsm after an optional delay. Specify an Fsm Name or use the first Fsm on the object.")] + public class SendEventToFsm : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of Fsm on Game Object")] + public FsmString fsmName; + [RequiredField] + [UIHint(UIHint.FsmEvent)] + public FsmString sendEvent; + [HasFloatSlider(0, 10)] + public FsmFloat delay; + bool requireReceiver; + + private GameObject go; + private DelayedEvent delayedEvent; + + public override void Reset() + { + gameObject = null; + fsmName = null; + sendEvent = null; + delay = null; + requireReceiver = false; + } + + public override void OnEnter() + { + go = Fsm.GetOwnerDefaultTarget(gameObject); + + if (go == null) + { + Finish(); + return; + } + + var sendToFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + + if (sendToFsm == null) + { + if (requireReceiver) + { + LogError("GameObject doesn't have FsmComponent: " + go.name + " " + fsmName.Value); + } + + return; + } + + if (delay.Value < 0.001) + { + sendToFsm.Fsm.Event(sendEvent.Value); + Finish(); + } + else + { + delayedEvent = sendToFsm.Fsm.DelayedEvent(FsmEvent.GetFsmEvent(sendEvent.Value), delay.Value); + } + } + + public override void OnUpdate() + { + if (DelayedEvent.WasSent(delayedEvent)) + { + Finish(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SendEventToFsm.cs.meta b/Assets/PlayMaker/Actions/SendEventToFsm.cs.meta new file mode 100755 index 0000000..4caceb1 --- /dev/null +++ b/Assets/PlayMaker/Actions/SendEventToFsm.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e67332eeb4ef833489b089d1d65e041f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SendMessage.cs b/Assets/PlayMaker/Actions/SendMessage.cs new file mode 100755 index 0000000..e2515e5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SendMessage.cs @@ -0,0 +1,142 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.ScriptControl)] + [Tooltip("Sends a Message to a Game Object. See Unity docs for SendMessage.")] + public class SendMessage : FsmStateAction + { + public enum MessageType + { + SendMessage, + SendMessageUpwards, + BroadcastMessage + } + + [RequiredField] + [Tooltip("GameObject that sends the message.")] + public FsmOwnerDefault gameObject; + + [Tooltip("Where to send the message.\nSee Unity docs.")] + public MessageType delivery; + + [Tooltip("Send options.\nSee Unity docs.")] + public SendMessageOptions options; + + [RequiredField] + public FunctionCall functionCall; + + public override void Reset() + { + gameObject = null; + delivery = MessageType.SendMessage; + options = SendMessageOptions.DontRequireReceiver; + functionCall = null; + } + + public override void OnEnter() + { + DoSendMessage(); + + Finish(); + } + + void DoSendMessage() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + object parameter = null; + + switch (functionCall.ParameterType) + { + case "None": + break; + + case "bool": + parameter = functionCall.BoolParameter.Value; + break; + + case "int": + parameter = functionCall.IntParameter.Value; + break; + + case "float": + parameter = functionCall.FloatParameter.Value; + break; + + case "string": + parameter = functionCall.StringParameter.Value; + break; + + case "Vector2": + parameter = functionCall.Vector2Parameter.Value; + break; + + case "Vector3": + parameter = functionCall.Vector3Parameter.Value; + break; + + case "Rect": + parameter = functionCall.RectParamater.Value; + break; + + case "GameObject": + parameter = functionCall.GameObjectParameter.Value; + break; + + case "Material": + parameter = functionCall.MaterialParameter.Value; + break; + + case "Texture": + parameter = functionCall.TextureParameter.Value; + break; + + case "Color": + parameter = functionCall.ColorParameter.Value; + break; + + case "Quaternion": + parameter = functionCall.QuaternionParameter.Value; + break; + + case "Object": + parameter = functionCall.ObjectParameter.Value; + break; + + case "Enum": + parameter = functionCall.EnumParameter.Value; + break; + + case "Array": + parameter = functionCall.ArrayParameter.Values; + break; + } + + switch (delivery) + { + case MessageType.SendMessage: + + go.SendMessage(functionCall.FunctionName, parameter, options); + return; + + case MessageType.SendMessageUpwards: + + go.SendMessageUpwards(functionCall.FunctionName, parameter, options); + return; + + case MessageType.BroadcastMessage: + + go.BroadcastMessage(functionCall.FunctionName, parameter, options); + return; + + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SendMessage.cs.meta b/Assets/PlayMaker/Actions/SendMessage.cs.meta new file mode 100755 index 0000000..13a3475 --- /dev/null +++ b/Assets/PlayMaker/Actions/SendMessage.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 669e0b354c0fba34fac778911cc907b6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SendRandomEvent.cs b/Assets/PlayMaker/Actions/SendRandomEvent.cs new file mode 100755 index 0000000..60c08dc --- /dev/null +++ b/Assets/PlayMaker/Actions/SendRandomEvent.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sends a Random Event picked from an array of Events. Optionally set the relative weight of each event.")] + public class SendRandomEvent : FsmStateAction + { + [CompoundArray("Events", "Event", "Weight")] + public FsmEvent[] events; + [HasFloatSlider(0, 1)] + public FsmFloat[] weights; + public FsmFloat delay; + + DelayedEvent delayedEvent; + + public override void Reset() + { + events = new FsmEvent[3]; + weights = new FsmFloat[] {1,1,1}; + delay = null; + } + + public override void OnEnter() + { + if (events.Length > 0) + { + int randomIndex = ActionHelpers.GetRandomWeightedIndex(weights); + + if (randomIndex != -1) + { + if (delay.Value < 0.001f) + { + Fsm.Event(events[randomIndex]); + Finish(); + } + else + { + delayedEvent = Fsm.DelayedEvent(events[randomIndex], delay.Value); + } + + return; + } + } + + Finish(); + } + + public override void OnUpdate() + { + if (DelayedEvent.WasSent(delayedEvent)) + { + Finish(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SendRandomEvent.cs.meta b/Assets/PlayMaker/Actions/SendRandomEvent.cs.meta new file mode 100755 index 0000000..6113a6f --- /dev/null +++ b/Assets/PlayMaker/Actions/SendRandomEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c1ba25b9548a936458186692e85f3259 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SequenceEvent.cs b/Assets/PlayMaker/Actions/SequenceEvent.cs new file mode 100755 index 0000000..38054a0 --- /dev/null +++ b/Assets/PlayMaker/Actions/SequenceEvent.cs @@ -0,0 +1,54 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sends the next event on the state each time the state is entered.")] + public class SequenceEvent : FsmStateAction + { + [HasFloatSlider(0, 10)] + public FsmFloat delay; + + DelayedEvent delayedEvent; + int eventIndex; + + public override void Reset() + { + delay = null; + } + + public override void OnEnter() + { + var eventCount = State.Transitions.Length; + + if (eventCount > 0) + { + var fsmEvent = State.Transitions[eventIndex].FsmEvent; + + if (delay.Value < 0.001f) + { + Fsm.Event(fsmEvent); + Finish(); + } + else + { + delayedEvent = Fsm.DelayedEvent(fsmEvent, delay.Value); + } + + eventIndex++; + if (eventIndex == eventCount) + { + eventIndex = 0; + } + } + } + + public override void OnUpdate() + { + if (DelayedEvent.WasSent(delayedEvent)) + { + Finish(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SequenceEvent.cs.meta b/Assets/PlayMaker/Actions/SequenceEvent.cs.meta new file mode 100755 index 0000000..37c3df6 --- /dev/null +++ b/Assets/PlayMaker/Actions/SequenceEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 36cebf3c20367d04ab464546dbfe2267 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAllFsmGameObject.cs b/Assets/PlayMaker/Actions/SetAllFsmGameObject.cs new file mode 100755 index 0000000..092b553 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAllFsmGameObject.cs @@ -0,0 +1,86 @@ +// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved. +// JeanFabre: This version allow setting the variable to null. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Game Object Variable in another All FSM. Accept null reference")] + public class SetAllFsmGameObject : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + //[UIHint(UIHint.FsmName)] + //[Tooltip("Optional name of FSM on Game Object")] + //public FsmString fsmName; + //[RequiredField] + //[UIHint(UIHint.FsmGameObject)] + //public FsmString variableName; + //public FsmGameObject setValue; + public bool everyFrame; + + //GameObject goLastFrame; + //PlayMakerFSM[] fsms; + + public override void Reset() + { + //gameObject = null; + //fsmName = ""; + //setValue = null; + + //goLastFrame = null ; + //fsms = null ; + } + + public override void OnEnter() + { + //fsms = null ; + + //DoSetFsmGameObject(); + + if (!everyFrame) + Finish(); + } + + void DoSetFsmGameObject() + { + //GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + //if (go == null) return; + + //if (go != goLastFrame) + //{ + // goLastFrame = go; + + //fsms = go.GetComponents() ; + // only get the fsm component if go has changed + + //fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + //} + + //if (fsms == null) return; + + //for( int i = 0 ; i < fsms.Length ; i ++ ) + //{ + /*FsmGameObject fsmGameObject = fsms[i].FsmVariables.GetFsmGameObject(variableName.Value); + + if (fsmGameObject == null) continue; + + if (setValue == null) + { + fsmGameObject.Value = null; + } + else + { + fsmGameObject.Value = setValue.Value; + }*/ + //} + } + + //public override void OnUpdate() + //{ + //DoSetFsmGameObject(); + //} + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAllFsmGameObject.cs.meta b/Assets/PlayMaker/Actions/SetAllFsmGameObject.cs.meta new file mode 100755 index 0000000..549531b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAllFsmGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 20f45c85164d76b4e83ed2d0dc9f0335 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAmbientLight.cs b/Assets/PlayMaker/Actions/SetAmbientLight.cs new file mode 100755 index 0000000..2f1d6e0 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAmbientLight.cs @@ -0,0 +1,39 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.RenderSettings)] + [Tooltip("Sets the Ambient Light Color for the scene.")] + public class SetAmbientLight : FsmStateAction + { + [RequiredField] + public FsmColor ambientColor; + public bool everyFrame; + + public override void Reset() + { + ambientColor = Color.gray; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetAmbientColor(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetAmbientColor(); + } + + void DoSetAmbientColor() + { + RenderSettings.ambientLight = ambientColor.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAmbientLight.cs.meta b/Assets/PlayMaker/Actions/SetAmbientLight.cs.meta new file mode 100755 index 0000000..0d921d1 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAmbientLight.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 79e8a1aed82f7364eb7f2e89cb0a1b30 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAnimationSpeed.cs b/Assets/PlayMaker/Actions/SetAnimationSpeed.cs new file mode 100755 index 0000000..34edc4e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAnimationSpeed.cs @@ -0,0 +1,64 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Sets the Speed of an Animation. Check Every Frame to update the animation time continuosly, e.g., if you're manipulating a variable that controls animation speed.")] + public class SetAnimationSpeed : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + public FsmOwnerDefault gameObject; + [RequiredField] + [UIHint(UIHint.Animation)] + public FsmString animName; + public FsmFloat speed = 1f; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + animName = null; + speed = 1f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetAnimationSpeed(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetAnimationSpeed(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + } + + void DoSetAnimationSpeed(GameObject go) + { + if (!UpdateCache(go)) + { + return; + } + + var anim = animation[animName.Value]; + if (anim == null) + { + LogWarning("Missing animation: " + animName.Value); + return; + } + + anim.speed = speed.Value; + } + + /* + public override string ErrorCheck() + { + return ErrorCheckHelpers.CheckAnimationSetup(gameObject.value); + }*/ + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAnimationSpeed.cs.meta b/Assets/PlayMaker/Actions/SetAnimationSpeed.cs.meta new file mode 100755 index 0000000..24a5dd4 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAnimationSpeed.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 791ecdf3435dea248bf2ec0fa7577adf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAnimationTime.cs b/Assets/PlayMaker/Actions/SetAnimationTime.cs new file mode 100755 index 0000000..b75f106 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAnimationTime.cs @@ -0,0 +1,76 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Sets the current Time of an Animation, Normalize time means 0 (start) to 1 (end); useful if you don't care about the exact time. Check Every Frame to update the time continuosly.")] + public class SetAnimationTime : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + public FsmOwnerDefault gameObject; + [RequiredField] + [UIHint(UIHint.Animation)] + public FsmString animName; + public FsmFloat time; + public bool normalized; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + animName = null; + time = null; + normalized = false; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetAnimationTime(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetAnimationTime(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + } + + void DoSetAnimationTime(GameObject go) + { + if (!UpdateCache(go)) + { + return; + } + + animation.Play(animName.Value); + + var anim = animation[animName.Value]; + if (anim == null) + { + LogWarning("Missing animation: " + animName.Value); + return; + } + + if (normalized) + { + anim.normalizedTime = time.Value; + } + else + { + anim.time = time.Value; + } + + // TODO: need to do this? + if (everyFrame) + { + anim.speed = 0; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAnimationTime.cs.meta b/Assets/PlayMaker/Actions/SetAnimationTime.cs.meta new file mode 100755 index 0000000..731358d --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAnimationTime.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84994d0c340d30744be8e62b88889675 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAnimationWeight.cs b/Assets/PlayMaker/Actions/SetAnimationWeight.cs new file mode 100755 index 0000000..8bad87a --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAnimationWeight.cs @@ -0,0 +1,60 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Sets the Blend Weight of an Animation. Check Every Frame to update the weight continuosly, e.g., if you're manipulating a variable that controls the weight.")] + public class SetAnimationWeight : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + public FsmOwnerDefault gameObject; + [RequiredField] + [UIHint(UIHint.Animation)] + public FsmString animName; + public FsmFloat weight = 1f; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + animName = null; + weight = 1f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetAnimationWeight(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetAnimationWeight(gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value); + } + + void DoSetAnimationWeight(GameObject go) + { + if (!UpdateCache(go)) + { + return; + } + + var anim = animation[animName.Value]; + if (anim == null) + { + LogWarning("Missing animation: " + animName.Value); + return; + } + + anim.weight = weight.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAnimationWeight.cs.meta b/Assets/PlayMaker/Actions/SetAnimationWeight.cs.meta new file mode 100755 index 0000000..77d70d4 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAnimationWeight.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2800e1c371ad41e42a66b39fcf5baf43 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAudioClip.cs b/Assets/PlayMaker/Actions/SetAudioClip.cs new file mode 100755 index 0000000..17c2106 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAudioClip.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Sets the Audio Clip played by the AudioSource component on a Game Object.")] + public class SetAudioClip : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + [Tooltip("The GameObject with the AudioSource component.")] + public FsmOwnerDefault gameObject; + + [ObjectType(typeof(AudioClip))] + [Tooltip("The AudioClip to set.")] + public FsmObject audioClip; + + public override void Reset() + { + gameObject = null; + audioClip = null; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + audio.clip = audioClip.Value as AudioClip; + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAudioClip.cs.meta b/Assets/PlayMaker/Actions/SetAudioClip.cs.meta new file mode 100755 index 0000000..5f144d5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAudioClip.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 43e053420a1a7764e9b7bfce0dc7c229 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAudioLoop.cs b/Assets/PlayMaker/Actions/SetAudioLoop.cs new file mode 100755 index 0000000..a77a02f --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAudioLoop.cs @@ -0,0 +1,33 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Sets looping on the AudioSource component on a Game Object.")] + public class SetAudioLoop : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + public FsmOwnerDefault gameObject; + public FsmBool loop; + + public override void Reset() + { + gameObject = null; + loop = false; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + audio.loop = loop.Value; + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAudioLoop.cs.meta b/Assets/PlayMaker/Actions/SetAudioLoop.cs.meta new file mode 100755 index 0000000..3216ac4 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAudioLoop.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96e3a3f60d1f3a84f813e1ca3d19cfa9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAudioPitch.cs b/Assets/PlayMaker/Actions/SetAudioPitch.cs new file mode 100755 index 0000000..6b6e3b5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAudioPitch.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Sets the Pitch of the Audio Clip played by the AudioSource component on a Game Object.")] + public class SetAudioPitch : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + public FsmOwnerDefault gameObject; + public FsmFloat pitch; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + pitch = 1; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetAudioPitch(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate () + { + DoSetAudioPitch(); + } + + void DoSetAudioPitch() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + if (!pitch.IsNone) + { + audio.pitch = pitch.Value; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAudioPitch.cs.meta b/Assets/PlayMaker/Actions/SetAudioPitch.cs.meta new file mode 100755 index 0000000..0b52eca --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAudioPitch.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bcee416ff0c12e34f94c8f3552122e6c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetAudioVolume.cs b/Assets/PlayMaker/Actions/SetAudioVolume.cs new file mode 100755 index 0000000..2411c34 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAudioVolume.cs @@ -0,0 +1,52 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Sets the Volume of the Audio Clip played by the AudioSource component on a Game Object.")] + public class SetAudioVolume : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(AudioSource))] + public FsmOwnerDefault gameObject; + [HasFloatSlider(0,1)] + public FsmFloat volume; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + volume = 1; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetAudioVolume(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate () + { + DoSetAudioVolume(); + } + + void DoSetAudioVolume() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + if (!volume.IsNone) + { + audio.volume = volume.Value; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetAudioVolume.cs.meta b/Assets/PlayMaker/Actions/SetAudioVolume.cs.meta new file mode 100755 index 0000000..cc5bcd2 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetAudioVolume.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b790d68bb38d2c848a163e04516c2812 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetBackgroundColor.cs b/Assets/PlayMaker/Actions/SetBackgroundColor.cs new file mode 100755 index 0000000..2470fa8 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetBackgroundColor.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Sets the Background Color used by the Camera.")] + public class SetBackgroundColor : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Camera))] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmColor backgroundColor; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + backgroundColor = Color.black; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetBackgroundColor(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetBackgroundColor(); + } + + void DoSetBackgroundColor() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + camera.backgroundColor = backgroundColor.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetBackgroundColor.cs.meta b/Assets/PlayMaker/Actions/SetBackgroundColor.cs.meta new file mode 100755 index 0000000..83fc4a9 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetBackgroundColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2580741b9cad41d4ebcb5fe081a342c1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetBoolValue.cs b/Assets/PlayMaker/Actions/SetBoolValue.cs new file mode 100755 index 0000000..d80771e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetBoolValue.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Sets the value of a Bool Variable.")] + public class SetBoolValue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmBool boolVariable; + [RequiredField] + public FsmBool boolValue; + public bool everyFrame; + + public override void Reset() + { + boolVariable = null; + boolValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + boolVariable.Value = boolValue.Value; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + boolVariable.Value = boolValue.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetBoolValue.cs.meta b/Assets/PlayMaker/Actions/SetBoolValue.cs.meta new file mode 100755 index 0000000..4c48094 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetBoolValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 00be43d651f0337439b458939d103490 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetCameraCullingMask.cs b/Assets/PlayMaker/Actions/SetCameraCullingMask.cs new file mode 100755 index 0000000..c6ef4af --- /dev/null +++ b/Assets/PlayMaker/Actions/SetCameraCullingMask.cs @@ -0,0 +1,56 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Sets the Culling Mask used by the Camera.")] + public class SetCameraCullingMask : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Camera))] + public FsmOwnerDefault gameObject; + + [Tooltip("Cull these layers.")] + [UIHint(UIHint.Layer)] + public FsmInt[] cullingMask; + + [Tooltip("Invert the mask, so you cull all layers except those defined above.")] + public FsmBool invertMask; + + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + cullingMask = new FsmInt[0]; + invertMask = false; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetCameraCullingMask(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetCameraCullingMask(); + } + + void DoSetCameraCullingMask() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + camera.cullingMask = ActionHelpers.LayerArrayToLayerMask(cullingMask, invertMask.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetCameraCullingMask.cs.meta b/Assets/PlayMaker/Actions/SetCameraCullingMask.cs.meta new file mode 100755 index 0000000..44c87aa --- /dev/null +++ b/Assets/PlayMaker/Actions/SetCameraCullingMask.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ddaf2de42b757fd4bbab76cba3e66c1f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetCameraFOV.cs b/Assets/PlayMaker/Actions/SetCameraFOV.cs new file mode 100755 index 0000000..779359d --- /dev/null +++ b/Assets/PlayMaker/Actions/SetCameraFOV.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Sets Field of View used by the Camera.")] + public class SetCameraFOV : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Camera))] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmFloat fieldOfView; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + fieldOfView = 50f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetCameraFOV(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetCameraFOV(); + } + + void DoSetCameraFOV() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + camera.fieldOfView = fieldOfView.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetCameraFOV.cs.meta b/Assets/PlayMaker/Actions/SetCameraFOV.cs.meta new file mode 100755 index 0000000..e25b1b5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetCameraFOV.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b064faf20b4b8814c9bc8ed1f043f6e1 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetColorRGBA.cs b/Assets/PlayMaker/Actions/SetColorRGBA.cs new file mode 100755 index 0000000..a0f9f68 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetColorRGBA.cs @@ -0,0 +1,85 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Color)] + [Tooltip("Sets the RGBA channels of a Color Variable. To leave any channel unchanged, set variable to 'None'.")] + public class SetColorRGBA : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmColor colorVariable; + + [HasFloatSlider(0,1)] + public FsmFloat red; + + [HasFloatSlider(0,1)] + public FsmFloat green; + + [HasFloatSlider(0,1)] + public FsmFloat blue; + + [HasFloatSlider(0,1)] + public FsmFloat alpha; + + public bool everyFrame; + + public override void Reset() + { + colorVariable = null; + + // default to variable dropdown with None selected. + + red = 0; + green = 0; + blue = 0; + alpha = 1; + + everyFrame = false; + } + + public override void OnEnter() + { + DoSetColorRGBA(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetColorRGBA(); + } + + void DoSetColorRGBA() + { + if (colorVariable == null) return; + + var newColor = colorVariable.Value; + + if (!red.IsNone) + { + newColor.r = red.Value; + } + + if (!green.IsNone) + { + newColor.g = green.Value; + } + + if (!blue.IsNone) + { + newColor.b = blue.Value; + } + + if (!alpha.IsNone) + { + newColor.a = alpha.Value; + } + + colorVariable.Value = newColor; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetColorRGBA.cs.meta b/Assets/PlayMaker/Actions/SetColorRGBA.cs.meta new file mode 100755 index 0000000..0122588 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetColorRGBA.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f7dfba8043adee4e8b44fe39ff17bf8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetColorValue.cs b/Assets/PlayMaker/Actions/SetColorValue.cs new file mode 100755 index 0000000..46cc84c --- /dev/null +++ b/Assets/PlayMaker/Actions/SetColorValue.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Color)] + [Tooltip("Sets the value of a Color Variable.")] + public class SetColorValue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmColor colorVariable; + [RequiredField] + public FsmColor color; + public bool everyFrame; + + public override void Reset() + { + colorVariable = null; + color = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetColorValue(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetColorValue(); + } + + void DoSetColorValue() + { + if (colorVariable != null) + colorVariable.Value = color.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetColorValue.cs.meta b/Assets/PlayMaker/Actions/SetColorValue.cs.meta new file mode 100755 index 0000000..7484ca3 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetColorValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9d987edef72027a408b133b1a138d8fd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetDrag.cs b/Assets/PlayMaker/Actions/SetDrag.cs new file mode 100755 index 0000000..61eaea9 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetDrag.cs @@ -0,0 +1,54 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// Thanks Lane + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [HelpUrl("http://hutonggames.com/playmakerforum/index.php?topic=4734.0")] + [Tooltip("Sets the Drag of a Game Object's Rigid Body.")] + public class SetDrag : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + + [RequiredField] + [HasFloatSlider(0.0f,10f)] + public FsmFloat drag; + + [Tooltip("Repeat every frame. Typically this would be set to True.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + drag = 1; + } + + public override void OnEnter() + { + DoSetDrag(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetDrag(); + } + + void DoSetDrag() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + rigidbody.drag = drag.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetDrag.cs.meta b/Assets/PlayMaker/Actions/SetDrag.cs.meta new file mode 100755 index 0000000..e1b8d2a --- /dev/null +++ b/Assets/PlayMaker/Actions/SetDrag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 03b227b3a99567c42913b4110ea8a32f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetEnumValue.cs b/Assets/PlayMaker/Actions/SetEnumValue.cs new file mode 100755 index 0000000..37cc9ee --- /dev/null +++ b/Assets/PlayMaker/Actions/SetEnumValue.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Enum)] + [Tooltip("Sets the value of an Enum Variable.")] + public class SetEnumValue : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("The Enum Variable to set.")] + public FsmEnum enumVariable; + + [MatchFieldType("enumVariable")] + [Tooltip("The Enum value to set the variable to.")] + public FsmEnum enumValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + enumVariable = null; + enumValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetEnumValue(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetEnumValue(); + } + + void DoSetEnumValue() + { + enumVariable.Value = enumValue.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetEnumValue.cs.meta b/Assets/PlayMaker/Actions/SetEnumValue.cs.meta new file mode 100755 index 0000000..b2c7eb6 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetEnumValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 15318b589c6f0bc4ab84c9c13d9dece5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetEventData.cs b/Assets/PlayMaker/Actions/SetEventData.cs new file mode 100755 index 0000000..abe7833 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetEventData.cs @@ -0,0 +1,61 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sets Event Data before sending an event. Get the Event Data, along with sender information, using Get Event Info action.")] + public class SetEventData : FsmStateAction + { + public FsmGameObject setGameObjectData; + public FsmInt setIntData; + public FsmFloat setFloatData; + public FsmString setStringData; + public FsmBool setBoolData; + public FsmVector2 setVector2Data; + public FsmVector3 setVector3Data; + public FsmRect setRectData; + public FsmQuaternion setQuaternionData; + public FsmColor setColorData; + public FsmMaterial setMaterialData; + public FsmTexture setTextureData; + public FsmObject setObjectData; + + public override void Reset() + { + setGameObjectData = new FsmGameObject{UseVariable = true}; + setIntData = new FsmInt { UseVariable = true }; + setFloatData = new FsmFloat { UseVariable = true }; + setStringData = new FsmString { UseVariable = true }; + setBoolData = new FsmBool { UseVariable = true }; + setVector2Data = new FsmVector2 { UseVariable = true }; + setVector3Data = new FsmVector3 { UseVariable = true }; + setRectData = new FsmRect { UseVariable = true }; + setQuaternionData = new FsmQuaternion { UseVariable = true }; + setColorData = new FsmColor { UseVariable = true }; + setMaterialData = new FsmMaterial { UseVariable = true }; + setTextureData = new FsmTexture { UseVariable = true }; + setObjectData = new FsmObject { UseVariable = true }; + } + + public override void OnEnter() + { + Fsm.EventData.BoolData = setBoolData.Value; + Fsm.EventData.IntData = setIntData.Value; + Fsm.EventData.FloatData = setFloatData.Value; + Fsm.EventData.Vector2Data = setVector2Data.Value; + Fsm.EventData.Vector3Data = setVector3Data.Value; + Fsm.EventData.StringData = setStringData.Value; + Fsm.EventData.GameObjectData = setGameObjectData.Value; + Fsm.EventData.RectData = setRectData.Value; + Fsm.EventData.QuaternionData = setQuaternionData.Value; + Fsm.EventData.ColorData = setColorData.Value; + Fsm.EventData.MaterialData = setMaterialData.Value; + Fsm.EventData.TextureData = setTextureData.Value; + Fsm.EventData.ObjectData = setObjectData.Value; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetEventData.cs.meta b/Assets/PlayMaker/Actions/SetEventData.cs.meta new file mode 100755 index 0000000..f2f0e60 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetEventData.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 90eeb02be41916f41825bd8f70a06555 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetEventTarget.cs b/Assets/PlayMaker/Actions/SetEventTarget.cs new file mode 100755 index 0000000..12c4eed --- /dev/null +++ b/Assets/PlayMaker/Actions/SetEventTarget.cs @@ -0,0 +1,23 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Sets the target FSM for all subsequent events sent by this state. The default 'Self' sends events to this FSM.")] + public class SetEventTarget : FsmStateAction + { + public FsmEventTarget eventTarget; + + public override void Reset() + { + } + + public override void OnEnter() + { + Fsm.EventTarget = eventTarget; + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetEventTarget.cs.meta b/Assets/PlayMaker/Actions/SetEventTarget.cs.meta new file mode 100755 index 0000000..1a00774 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetEventTarget.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6bc63b6801428444ebc7f2a4bb63529a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFlareStrength.cs b/Assets/PlayMaker/Actions/SetFlareStrength.cs new file mode 100755 index 0000000..8885a41 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFlareStrength.cs @@ -0,0 +1,39 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.RenderSettings)] + [Tooltip("Sets the intensity of all Flares in the scene.")] + public class SetFlareStrength : FsmStateAction + { + [RequiredField] + public FsmFloat flareStrength; + public bool everyFrame; + + public override void Reset() + { + flareStrength = 0.2f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFlareStrength(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetFlareStrength(); + } + + void DoSetFlareStrength() + { + RenderSettings.flareStrength = flareStrength.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFlareStrength.cs.meta b/Assets/PlayMaker/Actions/SetFlareStrength.cs.meta new file mode 100755 index 0000000..d26e4d6 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFlareStrength.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 735bc38edeae5794887f61622d0fb8f3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFloatValue.cs b/Assets/PlayMaker/Actions/SetFloatValue.cs new file mode 100755 index 0000000..d3e1a9b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFloatValue.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Sets the value of a Float Variable.")] + public class SetFloatValue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmFloat floatVariable; + [RequiredField] + public FsmFloat floatValue; + public bool everyFrame; + + public override void Reset() + { + floatVariable = null; + floatValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + floatVariable.Value = floatValue.Value; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + floatVariable.Value = floatValue.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFloatValue.cs.meta b/Assets/PlayMaker/Actions/SetFloatValue.cs.meta new file mode 100755 index 0000000..4bd134c --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFloatValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d61549e2ee237ae4e9aa9e73d547c3fc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFogColor.cs b/Assets/PlayMaker/Actions/SetFogColor.cs new file mode 100755 index 0000000..11c850d --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFogColor.cs @@ -0,0 +1,39 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.RenderSettings)] + [Tooltip("Sets the color of the Fog in the scene.")] + public class SetFogColor : FsmStateAction + { + [RequiredField] + public FsmColor fogColor; + public bool everyFrame; + + public override void Reset() + { + fogColor = Color.white; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFogColor(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetFogColor(); + } + + void DoSetFogColor() + { + RenderSettings.fogColor = fogColor.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFogColor.cs.meta b/Assets/PlayMaker/Actions/SetFogColor.cs.meta new file mode 100755 index 0000000..7784afb --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFogColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c42fbae9cb61ffa4bbcc4725b19e802e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFogDensity.cs b/Assets/PlayMaker/Actions/SetFogDensity.cs new file mode 100755 index 0000000..2c5a118 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFogDensity.cs @@ -0,0 +1,39 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.RenderSettings)] + [Tooltip("Sets the density of the Fog in the scene.")] + public class SetFogDensity : FsmStateAction + { + [RequiredField] + public FsmFloat fogDensity; + public bool everyFrame; + + public override void Reset() + { + fogDensity = 0.5f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFogDensity(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetFogDensity(); + } + + void DoSetFogDensity() + { + RenderSettings.fogDensity = fogDensity.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFogDensity.cs.meta b/Assets/PlayMaker/Actions/SetFogDensity.cs.meta new file mode 100755 index 0000000..22d3881 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFogDensity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 732d8e7e400e6d04eb7d25a443e6bb1a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmBool.cs b/Assets/PlayMaker/Actions/SetFsmBool.cs new file mode 100755 index 0000000..e2ce117 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmBool.cs @@ -0,0 +1,100 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Bool Variable in another FSM.")] + public class SetFsmBool : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmBool)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmBool setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmBool(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmBool() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmBool = fsm.FsmVariables.FindFsmBool(variableName.Value); + + if (fsmBool != null) + { + fsmBool.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmBool(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmBool.cs.meta b/Assets/PlayMaker/Actions/SetFsmBool.cs.meta new file mode 100755 index 0000000..94b4d2a --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmBool.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cf09b613f0b23504ebb8e5a237f3d7ec +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmColor.cs b/Assets/PlayMaker/Actions/SetFsmColor.cs new file mode 100755 index 0000000..4a61587 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmColor.cs @@ -0,0 +1,100 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Color Variable in another FSM.")] + public class SetFsmColor : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmColor)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmColor setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmColor(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmColor() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmColor = fsm.FsmVariables.GetFsmColor(variableName.Value); + + if (fsmColor != null) + { + fsmColor.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmColor(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmColor.cs.meta b/Assets/PlayMaker/Actions/SetFsmColor.cs.meta new file mode 100755 index 0000000..40979af --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 93521bb024ec50d46974db698c20b312 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmEnum.cs b/Assets/PlayMaker/Actions/SetFsmEnum.cs new file mode 100755 index 0000000..880d4a4 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmEnum.cs @@ -0,0 +1,97 @@ +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a String Variable in another FSM.")] + public class SetFsmEnum : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object.")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmEnum)] + [Tooltip("Enum variable name needs to match the FSM variable name on Game Object.")] + public FsmString variableName; + + [RequiredField] + //[MatchFieldType("variableName")] + public FsmEnum setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmEnum(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmEnum() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmEnum = fsm.FsmVariables.GetFsmEnum(variableName.Value); + if (fsmEnum != null) + { + fsmEnum.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmEnum(); + } + + } +} diff --git a/Assets/PlayMaker/Actions/SetFsmEnum.cs.meta b/Assets/PlayMaker/Actions/SetFsmEnum.cs.meta new file mode 100755 index 0000000..331e3e6 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmEnum.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1eb2758e9be6bbd47ada1ddd76754b04 +timeCreated: 1432431915 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions/SetFsmFloat.cs b/Assets/PlayMaker/Actions/SetFsmFloat.cs new file mode 100755 index 0000000..5fdad45 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmFloat.cs @@ -0,0 +1,101 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Float Variable in another FSM.")] + public class SetFsmFloat : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmFloat)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmFloat setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmFloat(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmFloat() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmFloat = fsm.FsmVariables.GetFsmFloat(variableName.Value); + + if (fsmFloat != null) + { + fsmFloat.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmFloat(); + } + + } +} + diff --git a/Assets/PlayMaker/Actions/SetFsmFloat.cs.meta b/Assets/PlayMaker/Actions/SetFsmFloat.cs.meta new file mode 100755 index 0000000..42c2461 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5ecdd691c2c7b38478ad552d728ba1e0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmGameObject.cs b/Assets/PlayMaker/Actions/SetFsmGameObject.cs new file mode 100755 index 0000000..90b0145 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmGameObject.cs @@ -0,0 +1,95 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// JeanFabre: This version allow setting the variable to null. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Game Object Variable in another FSM. Accept null reference")] + public class SetFsmGameObject : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmGameObject)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [Tooltip("Set the value of the variable.")] + public FsmGameObject setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + private GameObject goLastFrame; + string fsmNameLastFrame; + + private PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFsmGameObject(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmGameObject() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + return; + } + + var fsmGameObject = fsm.FsmVariables.FindFsmGameObject(variableName.Value); + + if (fsmGameObject != null) + { + fsmGameObject.Value = setValue == null ? null : setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmGameObject(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmGameObject.cs.meta b/Assets/PlayMaker/Actions/SetFsmGameObject.cs.meta new file mode 100755 index 0000000..2372f58 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b6d0c7a75d6bb9c429ce70d9a21f4614 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmInt.cs b/Assets/PlayMaker/Actions/SetFsmInt.cs new file mode 100755 index 0000000..1c65648 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmInt.cs @@ -0,0 +1,97 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of an Integer Variable in another FSM.")] + public class SetFsmInt : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmInt)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmInt setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmInt(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmInt() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmInt = fsm.FsmVariables.GetFsmInt(variableName.Value); + + if (fsmInt != null) + { + fsmInt.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmInt(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmInt.cs.meta b/Assets/PlayMaker/Actions/SetFsmInt.cs.meta new file mode 100755 index 0000000..8d3c41a --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmInt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6b4b8dc15c1d3b44093eb43bfdbd7b50 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmMaterial.cs b/Assets/PlayMaker/Actions/SetFsmMaterial.cs new file mode 100755 index 0000000..0212269 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmMaterial.cs @@ -0,0 +1,102 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Material Variable in another FSM.")] + public class SetFsmMaterial : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmMaterial)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmMaterial setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + setValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFsmBool(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmBool() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmMaterial(variableName.Value); + + if (fsmVar != null) + { + fsmVar.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmBool(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmMaterial.cs.meta b/Assets/PlayMaker/Actions/SetFsmMaterial.cs.meta new file mode 100755 index 0000000..63bf443 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmMaterial.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d58ffb639647c654b8eaa37758c2b71e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmObject.cs b/Assets/PlayMaker/Actions/SetFsmObject.cs new file mode 100755 index 0000000..3189533 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmObject.cs @@ -0,0 +1,101 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of an Object Variable in another FSM.")] + public class SetFsmObject : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmObject)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [Tooltip("Set the value of the variable.")] + public FsmObject setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + setValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFsmBool(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmBool() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmObject(variableName.Value); + + if (fsmVar != null) + { + fsmVar.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmBool(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmObject.cs.meta b/Assets/PlayMaker/Actions/SetFsmObject.cs.meta new file mode 100755 index 0000000..7b089a0 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a4d93d75d9f35b48966dadfa9dccfaa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmQuaternion.cs b/Assets/PlayMaker/Actions/SetFsmQuaternion.cs new file mode 100755 index 0000000..1e053f2 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmQuaternion.cs @@ -0,0 +1,102 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Quaternion Variable in another FSM.")] + public class SetFsmQuaternion : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmQuaternion)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmQuaternion setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + setValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFsmQuaternion(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmQuaternion() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmQuaternion(variableName.Value); + + if (fsmVar != null) + { + fsmVar.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmQuaternion(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmQuaternion.cs.meta b/Assets/PlayMaker/Actions/SetFsmQuaternion.cs.meta new file mode 100755 index 0000000..9020ab3 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmQuaternion.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3ba17874b9ce798418d40af656f0630a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmRect.cs b/Assets/PlayMaker/Actions/SetFsmRect.cs new file mode 100755 index 0000000..7109ab6 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmRect.cs @@ -0,0 +1,102 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Rect Variable in another FSM.")] + public class SetFsmRect : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmRect)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmRect setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + setValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFsmBool(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmBool() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmVar = fsm.FsmVariables.GetFsmRect(variableName.Value); + + if (fsmVar != null) + { + fsmVar.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmBool(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmRect.cs.meta b/Assets/PlayMaker/Actions/SetFsmRect.cs.meta new file mode 100755 index 0000000..8bad5da --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmRect.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 85801822a8a25b64aa5ef26f7f4c869f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmString.cs b/Assets/PlayMaker/Actions/SetFsmString.cs new file mode 100755 index 0000000..07bf34b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmString.cs @@ -0,0 +1,99 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a String Variable in another FSM.")] + public class SetFsmString : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object.")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmString)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [Tooltip("Set the value of the variable.")] + public FsmString setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmString(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmString() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmString = fsm.FsmVariables.GetFsmString(variableName.Value); + + if (fsmString != null) + { + fsmString.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmString(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmString.cs.meta b/Assets/PlayMaker/Actions/SetFsmString.cs.meta new file mode 100755 index 0000000..36ac259 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmString.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e883d7ab08b86d5498f97ef94fe72d4a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmTexture.cs b/Assets/PlayMaker/Actions/SetFsmTexture.cs new file mode 100755 index 0000000..f0e30a0 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmTexture.cs @@ -0,0 +1,101 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Texture Variable in another FSM.")] + public class SetFsmTexture : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmTexture)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [Tooltip("Set the value of the variable.")] + public FsmTexture setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + variableName = ""; + setValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetFsmBool(); + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetFsmBool() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmVar = fsm.FsmVariables.FindFsmTexture(variableName.Value); + + if (fsmVar != null) + { + fsmVar.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmBool(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmTexture.cs.meta b/Assets/PlayMaker/Actions/SetFsmTexture.cs.meta new file mode 100755 index 0000000..04d6cf0 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7b8be3bbc1612a4449a2b06af4ad8710 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmVariable.cs b/Assets/PlayMaker/Actions/SetFsmVariable.cs new file mode 100755 index 0000000..6d3c129 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmVariable.cs @@ -0,0 +1,104 @@ +// (c) copyright Hutong Games, LLC 2010-2012. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a variable in another FSM.")] + public class SetFsmVariable : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [Tooltip("The name of the variable in the target FSM.")] + public FsmString variableName; + + [RequiredField] + public FsmVar setValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + private PlayMakerFSM targetFsm; + private NamedVariable targetVariable; + private INamedVariable sourceVariable; + + private GameObject cachedGameObject; + private string cachedFsmName; + private string cachedVariableName; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = new FsmVar(); + } + + public override void OnEnter() + { + DoSetFsmVariable(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetFsmVariable(); + } + + private void DoSetFsmVariable() + { + if (setValue.IsNone || string.IsNullOrEmpty(variableName.Value)) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (go != cachedGameObject || fsmName.Value != cachedFsmName) + { + targetFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + if (targetFsm == null) + { + return; + } + cachedGameObject = go; + cachedFsmName = fsmName.Value; + } + + if (variableName.Value != cachedVariableName) + { + targetVariable = targetFsm.FsmVariables.FindVariable(setValue.Type, variableName.Value); + cachedVariableName = variableName.Value; + } + + if (targetVariable == null) + { + LogWarning("Missing Variable: " + variableName.Value); + return; + } + + setValue.ApplyValueTo(targetVariable); + } + +#if UNITY_EDITOR + public override string AutoName() + { + return ("Set FSM Variable: " + ActionHelpers.GetValueLabel(variableName)); + } +#endif + } +} diff --git a/Assets/PlayMaker/Actions/SetFsmVariable.cs.meta b/Assets/PlayMaker/Actions/SetFsmVariable.cs.meta new file mode 100755 index 0000000..42c3545 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmVariable.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7b5899629abf3214a96d3f139a9db4d0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmVector2.cs b/Assets/PlayMaker/Actions/SetFsmVector2.cs new file mode 100755 index 0000000..2fe75b4 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmVector2.cs @@ -0,0 +1,99 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Vector2 Variable in another FSM.")] + public class SetFsmVector2 : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmVector2)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmVector2 setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmVector2(); + + if (!everyFrame) + Finish(); + } + + void DoSetFsmVector2() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmVector2 = fsm.FsmVariables.GetFsmVector2(variableName.Value); + + if (fsmVector2 != null) + { + fsmVector2.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + + } + + public override void OnUpdate() + { + DoSetFsmVector2(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmVector2.cs.meta b/Assets/PlayMaker/Actions/SetFsmVector2.cs.meta new file mode 100755 index 0000000..a2ce0e1 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmVector2.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8fd65fb1221e17743af069372ff874d6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetFsmVector3.cs b/Assets/PlayMaker/Actions/SetFsmVector3.cs new file mode 100755 index 0000000..ffbd125 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmVector3.cs @@ -0,0 +1,98 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.StateMachine)] + [Tooltip("Set the value of a Vector3 Variable in another FSM.")] + public class SetFsmVector3 : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject that owns the FSM.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.FsmName)] + [Tooltip("Optional name of FSM on Game Object")] + public FsmString fsmName; + + [RequiredField] + [UIHint(UIHint.FsmVector3)] + [Tooltip("The name of the FSM variable.")] + public FsmString variableName; + + [RequiredField] + [Tooltip("Set the value of the variable.")] + public FsmVector3 setValue; + + [Tooltip("Repeat every frame. Useful if the value is changing.")] + public bool everyFrame; + + GameObject goLastFrame; + string fsmNameLastFrame; + + PlayMakerFSM fsm; + + public override void Reset() + { + gameObject = null; + fsmName = ""; + setValue = null; + } + + public override void OnEnter() + { + DoSetFsmVector3(); + + if (!everyFrame) + Finish(); + } + + void DoSetFsmVector3() + { + if (setValue == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // FIX: must check as well that the fsm name is different. + if (go != goLastFrame || fsmName.Value != fsmNameLastFrame) + { + goLastFrame = go; + fsmNameLastFrame = fsmName.Value; + // only get the fsm component if go or fsm name has changed + + fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); + } + + if (fsm == null) + { + LogWarning("Could not find FSM: " + fsmName.Value); + return; + } + + var fsmVector3 = fsm.FsmVariables.GetFsmVector3(variableName.Value); + + if (fsmVector3 != null) + { + fsmVector3.Value = setValue.Value; + } + else + { + LogWarning("Could not find variable: " + variableName.Value); + } + } + + public override void OnUpdate() + { + DoSetFsmVector3(); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetFsmVector3.cs.meta b/Assets/PlayMaker/Actions/SetFsmVector3.cs.meta new file mode 100755 index 0000000..4fd08c1 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetFsmVector3.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 77bd9dda890c0614eba326161995290c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUIAlpha.cs b/Assets/PlayMaker/Actions/SetGUIAlpha.cs new file mode 100755 index 0000000..a8e839a --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIAlpha.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Sets the global Alpha for the GUI. Useful for fading GUI up/down. By default only effects GUI rendered by this FSM, check Apply Globally to effect all GUI controls.")] + public class SetGUIAlpha : FsmStateAction + { + [RequiredField] + public FsmFloat alpha; + public FsmBool applyGlobally; + + public override void Reset() + { + alpha = 1f; + } + + public override void OnGUI() + { + GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, alpha.Value); + + if (applyGlobally.Value) + { + PlayMakerGUI.GUIColor = GUI.color; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUIAlpha.cs.meta b/Assets/PlayMaker/Actions/SetGUIAlpha.cs.meta new file mode 100755 index 0000000..90a43d8 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIAlpha.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 681d64666aa35bd429b24d6c5693760f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUIBackgroundColor.cs b/Assets/PlayMaker/Actions/SetGUIBackgroundColor.cs new file mode 100755 index 0000000..af2fcc9 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIBackgroundColor.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Sets the Tinting Color for all background elements rendered by the GUI. By default only effects GUI rendered by this FSM, check Apply Globally to effect all GUI controls.")] + public class SetGUIBackgroundColor : FsmStateAction + { + [RequiredField] + public FsmColor backgroundColor; + public FsmBool applyGlobally; + + public override void Reset() + { + backgroundColor = Color.white; + } + + public override void OnGUI() + { + GUI.backgroundColor = backgroundColor.Value; + + if (applyGlobally.Value) + { + PlayMakerGUI.GUIBackgroundColor = GUI.backgroundColor; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUIBackgroundColor.cs.meta b/Assets/PlayMaker/Actions/SetGUIBackgroundColor.cs.meta new file mode 100755 index 0000000..659da4e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIBackgroundColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45f2aaf8ee4849f4180653917eac92ad +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUIColor.cs b/Assets/PlayMaker/Actions/SetGUIColor.cs new file mode 100755 index 0000000..b44770c --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIColor.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Sets the Tinting Color for the GUI. By default only effects GUI rendered by this FSM, check Apply Globally to effect all GUI controls.")] + public class SetGUIColor : FsmStateAction + { + [RequiredField] + public FsmColor color; + public FsmBool applyGlobally; + + public override void Reset() + { + color = Color.white; + } + + public override void OnGUI() + { + GUI.color = color.Value; + + if (applyGlobally.Value) + { + PlayMakerGUI.GUIColor = GUI.color; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUIColor.cs.meta b/Assets/PlayMaker/Actions/SetGUIColor.cs.meta new file mode 100755 index 0000000..e86f755 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 31b0ef84843dda14eb74bc1bfecdc167 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUIContentColor.cs b/Assets/PlayMaker/Actions/SetGUIContentColor.cs new file mode 100755 index 0000000..11da1f5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIContentColor.cs @@ -0,0 +1,30 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Sets the Tinting Color for all text rendered by the GUI. By default only effects GUI rendered by this FSM, check Apply Globally to effect all GUI controls.")] + public class SetGUIContentColor : FsmStateAction + { + [RequiredField] + public FsmColor contentColor; + public FsmBool applyGlobally; + + public override void Reset() + { + contentColor = Color.white; + } + + public override void OnGUI() + { + GUI.contentColor = contentColor.Value; + + if (applyGlobally.Value) + { + PlayMakerGUI.GUIContentColor = GUI.contentColor; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUIContentColor.cs.meta b/Assets/PlayMaker/Actions/SetGUIContentColor.cs.meta new file mode 100755 index 0000000..56f96ed --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIContentColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 249bd3a217fcef24f8d8841f7cfcd510 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUIDepth.cs b/Assets/PlayMaker/Actions/SetGUIDepth.cs new file mode 100755 index 0000000..4845616 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIDepth.cs @@ -0,0 +1,29 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Sets the sorting depth of subsequent GUI elements.")] + public class SetGUIDepth : FsmStateAction + { + [RequiredField] + public FsmInt depth; + + public override void Reset() + { + depth = 0; + } + + public override void OnPreprocess() + { + Fsm.HandleOnGUI = true; + } + + public override void OnGUI() + { + GUI.depth = depth.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUIDepth.cs.meta b/Assets/PlayMaker/Actions/SetGUIDepth.cs.meta new file mode 100755 index 0000000..d6e43c1 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIDepth.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 60696b5a384803a449ea3ad476738f41 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUISkin.cs b/Assets/PlayMaker/Actions/SetGUISkin.cs new file mode 100755 index 0000000..0162b85 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUISkin.cs @@ -0,0 +1,33 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Sets the GUISkin used by GUI elements.")] + public class SetGUISkin : FsmStateAction + { + [RequiredField] + public GUISkin skin; + public FsmBool applyGlobally; + + public override void Reset() + { + skin = null; + applyGlobally = true; + } + + public override void OnGUI() + { + if (skin != null) + GUI.skin = skin; + + if (applyGlobally.Value) + { + PlayMakerGUI.GUISkin = skin; + Finish(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUISkin.cs.meta b/Assets/PlayMaker/Actions/SetGUISkin.cs.meta new file mode 100755 index 0000000..f3461c6 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUISkin.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3151ca2da34e926439df38bcc05eb495 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUIText.cs b/Assets/PlayMaker/Actions/SetGUIText.cs new file mode 100755 index 0000000..4f2253e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIText.cs @@ -0,0 +1,47 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUIElement)] + [Tooltip("Sets the Text used by the GUIText Component attached to a Game Object.")] + public class SetGUIText : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(GUIText))] + public FsmOwnerDefault gameObject; + public FsmString text; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + text = ""; + } + + public override void OnEnter() + { + DoSetGUIText(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetGUIText(); + } + + void DoSetGUIText() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + guiText.text = text.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUIText.cs.meta b/Assets/PlayMaker/Actions/SetGUIText.cs.meta new file mode 100755 index 0000000..b3a4a3a --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUIText.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: df24cbf936769a341b29239c83db2386 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUITexture.cs b/Assets/PlayMaker/Actions/SetGUITexture.cs new file mode 100755 index 0000000..093d568 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUITexture.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUIElement)] + [Tooltip("Sets the Texture used by the GUITexture attached to a Game Object.")] + public class SetGUITexture : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(GUITexture))] + [Tooltip("The GameObject that owns the GUITexture.")] + public FsmOwnerDefault gameObject; + + [Tooltip("Texture to apply.")] + public FsmTexture texture; + + public override void Reset() + { + gameObject = null; + texture = null; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + guiTexture.texture = texture.Value; + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUITexture.cs.meta b/Assets/PlayMaker/Actions/SetGUITexture.cs.meta new file mode 100755 index 0000000..e00a9cc --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUITexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 983d4f76436f46b4bbff9fd836a5f482 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUITextureAlpha.cs b/Assets/PlayMaker/Actions/SetGUITextureAlpha.cs new file mode 100755 index 0000000..e22b91f --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUITextureAlpha.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUIElement)] + [Tooltip("Sets the Alpha of the GUITexture attached to a Game Object. Useful for fading GUI elements in/out.")] + public class SetGUITextureAlpha : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(GUITexture))] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmFloat alpha; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + alpha = 1.0f; + everyFrame = false; + } + + public override void OnEnter() + { + DoGUITextureAlpha(); + + if(!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoGUITextureAlpha(); + } + + void DoGUITextureAlpha() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + var color = guiTexture.color; + guiTexture.color = new Color(color.r, color.g, color.b, alpha.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUITextureAlpha.cs.meta b/Assets/PlayMaker/Actions/SetGUITextureAlpha.cs.meta new file mode 100755 index 0000000..ebb21a8 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUITextureAlpha.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 08b78615a290fed42985e1549b225a17 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGUITextureColor.cs b/Assets/PlayMaker/Actions/SetGUITextureColor.cs new file mode 100755 index 0000000..6072eb9 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUITextureColor.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUIElement)] + [Tooltip("Sets the Color of the GUITexture attached to a Game Object.")] + public class SetGUITextureColor : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(GUITexture))] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmColor color; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + color = Color.white; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetGUITextureColor(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetGUITextureColor(); + } + + void DoSetGUITextureColor() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + guiTexture.color = color.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGUITextureColor.cs.meta b/Assets/PlayMaker/Actions/SetGUITextureColor.cs.meta new file mode 100755 index 0000000..9997f48 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGUITextureColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 814f5df03eb9286489090e2a8a7c5254 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGameObject.cs b/Assets/PlayMaker/Actions/SetGameObject.cs new file mode 100755 index 0000000..2596813 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGameObject.cs @@ -0,0 +1,39 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Sets the value of a Game Object Variable.")] + public class SetGameObject : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmGameObject variable; + public FsmGameObject gameObject; + public bool everyFrame; + + public override void Reset() + { + variable = null; + gameObject = null; + everyFrame = false; + } + + public override void OnEnter() + { + variable.Value = gameObject.Value; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + variable.Value = gameObject.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGameObject.cs.meta b/Assets/PlayMaker/Actions/SetGameObject.cs.meta new file mode 100755 index 0000000..5b11776 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGameObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aa903464829c70f419f286cef321f421 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGameVolume.cs b/Assets/PlayMaker/Actions/SetGameVolume.cs new file mode 100755 index 0000000..38e5cd5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGameVolume.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Audio)] + [Tooltip("Sets the global sound volume.")] + public class SetGameVolume : FsmStateAction + { + [RequiredField] + [HasFloatSlider(0,1)] + public FsmFloat volume; + public bool everyFrame; + + public override void Reset() + { + volume = 1.0f; + everyFrame = false; + } + + public override void OnEnter() + { + AudioListener.volume = volume.Value; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + AudioListener.volume = volume.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGameVolume.cs.meta b/Assets/PlayMaker/Actions/SetGameVolume.cs.meta new file mode 100755 index 0000000..acac0e2 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGameVolume.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 67448731f4f757c40b2f67019f99c2fa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetGravity.cs b/Assets/PlayMaker/Actions/SetGravity.cs new file mode 100755 index 0000000..9bab665 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGravity.cs @@ -0,0 +1,53 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Sets the gravity vector, or individual axis.")] + public class SetGravity : FsmStateAction + { + public FsmVector3 vector; + public FsmFloat x; + public FsmFloat y; + public FsmFloat z; + public bool everyFrame; + + public override void Reset() + { + vector = null; + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + z = new FsmFloat { UseVariable = true }; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetGravity(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetGravity(); + } + + void DoSetGravity() + { + Vector3 gravity = vector.Value; + + if (!x.IsNone) + gravity.x = x.Value; + if (!y.IsNone) + gravity.y = y.Value; + if (!z.IsNone) + gravity.z = z.Value; + + Physics.gravity = gravity; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetGravity.cs.meta b/Assets/PlayMaker/Actions/SetGravity.cs.meta new file mode 100755 index 0000000..e9c945c --- /dev/null +++ b/Assets/PlayMaker/Actions/SetGravity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca0c224d55f487d43903c2fa2652b48e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetHaloStrength.cs b/Assets/PlayMaker/Actions/SetHaloStrength.cs new file mode 100755 index 0000000..9bad22e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetHaloStrength.cs @@ -0,0 +1,39 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.RenderSettings)] + [Tooltip("Sets the size of light halos.")] + public class SetHaloStrength : FsmStateAction + { + [RequiredField] + public FsmFloat haloStrength; + public bool everyFrame; + + public override void Reset() + { + haloStrength = 0.5f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetHaloStrength(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetHaloStrength(); + } + + void DoSetHaloStrength() + { + RenderSettings.haloStrength = haloStrength.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetHaloStrength.cs.meta b/Assets/PlayMaker/Actions/SetHaloStrength.cs.meta new file mode 100755 index 0000000..b147c93 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetHaloStrength.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dfa3230224ccfea46b26c5cba7cbea76 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetIntFromFloat.cs b/Assets/PlayMaker/Actions/SetIntFromFloat.cs new file mode 100755 index 0000000..e658aea --- /dev/null +++ b/Assets/PlayMaker/Actions/SetIntFromFloat.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Sets the value of an integer variable using a float value.")] + public class SetIntFromFloat : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt intVariable; + public FsmFloat floatValue; + public bool everyFrame; + + public override void Reset() + { + intVariable = null; + floatValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + intVariable.Value = (int)floatValue.Value; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + intVariable.Value = (int)floatValue.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetIntFromFloat.cs.meta b/Assets/PlayMaker/Actions/SetIntFromFloat.cs.meta new file mode 100755 index 0000000..5d9703f --- /dev/null +++ b/Assets/PlayMaker/Actions/SetIntFromFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 45ae843950627624cac9f7ca42305c34 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetIntValue.cs b/Assets/PlayMaker/Actions/SetIntValue.cs new file mode 100755 index 0000000..c104b08 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetIntValue.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Math)] + [Tooltip("Sets the value of an Integer Variable.")] + public class SetIntValue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmInt intVariable; + [RequiredField] + public FsmInt intValue; + public bool everyFrame; + + public override void Reset() + { + intVariable = null; + intValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + intVariable.Value = intValue.Value; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + intVariable.Value = intValue.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetIntValue.cs.meta b/Assets/PlayMaker/Actions/SetIntValue.cs.meta new file mode 100755 index 0000000..eea5477 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetIntValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 71d9b78292d7cb84d9dc9013fd4b9fb9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetIsKinematic.cs b/Assets/PlayMaker/Actions/SetIsKinematic.cs new file mode 100755 index 0000000..c2b4bc7 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetIsKinematic.cs @@ -0,0 +1,39 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Controls whether physics affects the Game Object.")] + public class SetIsKinematic : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmBool isKinematic; + + public override void Reset() + { + gameObject = null; + isKinematic = false; + } + + public override void OnEnter() + { + DoSetIsKinematic(); + Finish(); + } + + void DoSetIsKinematic() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + rigidbody.isKinematic = isKinematic.Value; + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/SetIsKinematic.cs.meta b/Assets/PlayMaker/Actions/SetIsKinematic.cs.meta new file mode 100755 index 0000000..b23ef3b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetIsKinematic.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6f45b23344dd264e83751bb05e0d8b0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetJointConnectedBody.cs b/Assets/PlayMaker/Actions/SetJointConnectedBody.cs new file mode 100755 index 0000000..84bc10b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetJointConnectedBody.cs @@ -0,0 +1,42 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Connect a joint to a game object.")] + public class SetJointConnectedBody : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Joint))] + [Tooltip("The joint to connect. Requires a Joint component.")] + public FsmOwnerDefault joint; + + [CheckForComponent(typeof (Rigidbody))] + [Tooltip("The game object to connect to the Joint. Set to none to connect the Joint to the world.")] + public FsmGameObject rigidBody; + + public override void Reset() + { + joint = null; + rigidBody = null; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(joint); + if (go != null) + { + var jointComponent = go.GetComponent(); + + if (jointComponent != null) + { + jointComponent.connectedBody = rigidBody.Value == null ? null : rigidBody.Value.GetComponent(); + } + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetJointConnectedBody.cs.meta b/Assets/PlayMaker/Actions/SetJointConnectedBody.cs.meta new file mode 100755 index 0000000..8b208c3 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetJointConnectedBody.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 054c73a768a9deb4d9d225f0dd1b6f34 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetLayer.cs b/Assets/PlayMaker/Actions/SetLayer.cs new file mode 100755 index 0000000..a6c2748 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLayer.cs @@ -0,0 +1,38 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Sets a Game Object's Layer.")] + public class SetLayer : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [UIHint(UIHint.Layer)] + public int layer; + + public override void Reset() + { + gameObject = null; + layer = 0; + } + + public override void OnEnter() + { + DoSetLayer(); + + Finish(); + } + + void DoSetLayer() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + go.layer = layer; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetLayer.cs.meta b/Assets/PlayMaker/Actions/SetLayer.cs.meta new file mode 100755 index 0000000..6137de1 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLayer.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 77f4f9c354a59684296f1a852f59796e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetLightColor.cs b/Assets/PlayMaker/Actions/SetLightColor.cs new file mode 100755 index 0000000..91c956d --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightColor.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Lights)] + [Tooltip("Sets the Color of a Light.")] + public class SetLightColor : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Light))] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmColor lightColor; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + lightColor = Color.white; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetLightColor(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetLightColor(); + } + + void DoSetLightColor() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + light.color = lightColor.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetLightColor.cs.meta b/Assets/PlayMaker/Actions/SetLightColor.cs.meta new file mode 100755 index 0000000..b02ceeb --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 035e007c3fa59054d828b36ce43cfe6b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetLightCookie.cs b/Assets/PlayMaker/Actions/SetLightCookie.cs new file mode 100755 index 0000000..5c41a9f --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightCookie.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Lights)] + [Tooltip("Sets the Texture projected by a Light.")] + public class SetLightCookie : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Light))] + public FsmOwnerDefault gameObject; + public FsmTexture lightCookie; + + public override void Reset() + { + gameObject = null; + lightCookie = null; + } + + public override void OnEnter() + { + DoSetLightCookie(); + Finish(); + } + + void DoSetLightCookie() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + light.cookie = lightCookie.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetLightCookie.cs.meta b/Assets/PlayMaker/Actions/SetLightCookie.cs.meta new file mode 100755 index 0000000..ee1ed10 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightCookie.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3a524ebe8e5d26c42ac34e159293ec45 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetLightFlare.cs b/Assets/PlayMaker/Actions/SetLightFlare.cs new file mode 100755 index 0000000..3191b2d --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightFlare.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Lights)] + [Tooltip("Sets the Flare effect used by a Light.")] + public class SetLightFlare : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Light))] + public FsmOwnerDefault gameObject; + public Flare lightFlare; + + public override void Reset() + { + gameObject = null; + lightFlare = null; + } + + public override void OnEnter() + { + DoSetLightRange(); + Finish(); + } + + void DoSetLightRange() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + light.flare = lightFlare; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetLightFlare.cs.meta b/Assets/PlayMaker/Actions/SetLightFlare.cs.meta new file mode 100755 index 0000000..e5091ff --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightFlare.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: df69e1a8bc949e44da6851cbaa2f8a8c +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetLightIntensity.cs b/Assets/PlayMaker/Actions/SetLightIntensity.cs new file mode 100755 index 0000000..f94a8a7 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightIntensity.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Lights)] + [Tooltip("Sets the Intensity of a Light.")] + public class SetLightIntensity : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Light))] + public FsmOwnerDefault gameObject; + public FsmFloat lightIntensity; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + lightIntensity = 1f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetLightIntensity(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetLightIntensity(); + } + + void DoSetLightIntensity() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + light.intensity = lightIntensity.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetLightIntensity.cs.meta b/Assets/PlayMaker/Actions/SetLightIntensity.cs.meta new file mode 100755 index 0000000..dd6919b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightIntensity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4a55f9d629330ab418370b0e5228b3d9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetLightRange.cs b/Assets/PlayMaker/Actions/SetLightRange.cs new file mode 100755 index 0000000..06eb80b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightRange.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Lights)] + [Tooltip("Sets the Range of a Light.")] + public class SetLightRange : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Light))] + public FsmOwnerDefault gameObject; + public FsmFloat lightRange; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + lightRange = 20f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetLightRange(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetLightRange(); + } + + void DoSetLightRange() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + light.range = lightRange.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetLightRange.cs.meta b/Assets/PlayMaker/Actions/SetLightRange.cs.meta new file mode 100755 index 0000000..5616c79 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightRange.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca7c4594a8181f247b6d7d6862ca6345 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetLightSpotAngle.cs b/Assets/PlayMaker/Actions/SetLightSpotAngle.cs new file mode 100755 index 0000000..9861555 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightSpotAngle.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Lights)] + [Tooltip("Sets the Spot Angle of a Light.")] + public class SetLightSpotAngle : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Light))] + public FsmOwnerDefault gameObject; + public FsmFloat lightSpotAngle; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + lightSpotAngle = 20f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetLightRange(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetLightRange(); + } + + void DoSetLightRange() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + light.spotAngle = lightSpotAngle.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetLightSpotAngle.cs.meta b/Assets/PlayMaker/Actions/SetLightSpotAngle.cs.meta new file mode 100755 index 0000000..e1a2c5d --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightSpotAngle.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a9a288b3e31b1ce478ed64d294fb6cc6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetLightType.cs b/Assets/PlayMaker/Actions/SetLightType.cs new file mode 100755 index 0000000..b6ee9f1 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightType.cs @@ -0,0 +1,39 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Lights)] + [Tooltip("Set Spot, Directional, or Point Light type.")] + public class SetLightType : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Light))] + public FsmOwnerDefault gameObject; + + [ObjectType(typeof(LightType))] + public FsmEnum lightType; + + public override void Reset() + { + gameObject = null; + lightType = LightType.Point; + } + + public override void OnEnter() + { + DoSetLightType(); + Finish(); + } + + void DoSetLightType() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + light.type = (LightType)lightType.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetLightType.cs.meta b/Assets/PlayMaker/Actions/SetLightType.cs.meta new file mode 100755 index 0000000..500d151 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetLightType.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd567235dfdc08d4ba995b3fe196c186 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetMainCamera.cs b/Assets/PlayMaker/Actions/SetMainCamera.cs new file mode 100755 index 0000000..97e1eb5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMainCamera.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using HutongGames.PlayMaker; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Sets the Main Camera.")] + public class SetMainCamera : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Camera))] + [Tooltip("The GameObject to set as the main camera (should have a Camera component).")] + public FsmGameObject gameObject; + + public override void Reset() + { + gameObject = null; + } + + public override void OnEnter() + { + if (gameObject.Value != null) + { + if (Camera.main != null) + { + Camera.main.gameObject.tag = "Untagged"; + } + + gameObject.Value.tag = "MainCamera"; + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetMainCamera.cs.meta b/Assets/PlayMaker/Actions/SetMainCamera.cs.meta new file mode 100755 index 0000000..367d673 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMainCamera.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2815aae2ab050a04188ffd013d0ebd0b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetMass.cs b/Assets/PlayMaker/Actions/SetMass.cs new file mode 100755 index 0000000..9781a76 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMass.cs @@ -0,0 +1,40 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Sets the Mass of a Game Object's Rigid Body.")] + public class SetMass : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + [RequiredField] + [HasFloatSlider(0.1f,10f)] + public FsmFloat mass; + + public override void Reset() + { + gameObject = null; + mass = 1; + } + + public override void OnEnter() + { + DoSetMass(); + + Finish(); + } + + void DoSetMass() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + rigidbody.mass = mass.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetMass.cs.meta b/Assets/PlayMaker/Actions/SetMass.cs.meta new file mode 100755 index 0000000..751a530 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMass.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 50a58cb3b1615c64b9adc636459d5099 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetMaterial.cs b/Assets/PlayMaker/Actions/SetMaterial.cs new file mode 100755 index 0000000..698ffec --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterial.cs @@ -0,0 +1,52 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets the material on a game object.")] + public class SetMaterial : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + public FsmInt materialIndex; + [RequiredField] + public FsmMaterial material; + + public override void Reset() + { + gameObject = null; + material = null; + materialIndex = 0; + } + + public override void OnEnter() + { + DoSetMaterial(); + + Finish(); + } + + void DoSetMaterial() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (materialIndex.Value == 0) + { + renderer.material = material.Value; + } + else if (renderer.materials.Length > materialIndex.Value) + { + var materials = renderer.materials; + materials[materialIndex.Value] = material.Value; + renderer.materials = materials; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetMaterial.cs.meta b/Assets/PlayMaker/Actions/SetMaterial.cs.meta new file mode 100755 index 0000000..53d77c0 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterial.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2123b532aa5869945839a781ff8b14e4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetMaterialColor.cs b/Assets/PlayMaker/Actions/SetMaterialColor.cs new file mode 100755 index 0000000..4312386 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterialColor.cs @@ -0,0 +1,95 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets a named color value in a game object's material.")] + public class SetMaterialColor : ComponentAction + { + [Tooltip("The GameObject that the material is applied to.")] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + + [Tooltip("GameObjects can have multiple materials. Specify an index to target a specific material.")] + public FsmInt materialIndex; + + [Tooltip("Alternatively specify a Material instead of a GameObject and Index.")] + public FsmMaterial material; + + [UIHint(UIHint.NamedColor)] + [Tooltip("A named color parameter in the shader.")] + public FsmString namedColor; + + [RequiredField] + [Tooltip("Set the parameter value.")] + public FsmColor color; + + [Tooltip("Repeat every frame. Useful if the value is animated.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + materialIndex = 0; + material = null; + namedColor = "_Color"; + color = Color.black; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetMaterialColor(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetMaterialColor(); + } + + void DoSetMaterialColor() + { + if (color.IsNone) + { + return; + } + + var colorName = namedColor.Value; + if (colorName == "") colorName = "_Color"; + + if (material.Value != null) + { + material.Value.SetColor(colorName, color.Value); + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (renderer.material == null) + { + LogError("Missing Material!"); + return; + } + + if (materialIndex.Value == 0) + { + renderer.material.SetColor(colorName, color.Value); + } + else if (renderer.materials.Length > materialIndex.Value) + { + var materials = renderer.materials; + materials[materialIndex.Value].SetColor(colorName, color.Value); + renderer.materials = materials; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetMaterialColor.cs.meta b/Assets/PlayMaker/Actions/SetMaterialColor.cs.meta new file mode 100755 index 0000000..e10f495 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterialColor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7dce87cf3a14d854785f521c2fb24485 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetMaterialFloat.cs b/Assets/PlayMaker/Actions/SetMaterialFloat.cs new file mode 100755 index 0000000..8778eab --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterialFloat.cs @@ -0,0 +1,89 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets a named float in a game object's material.")] + public class SetMaterialFloat : ComponentAction + { + [Tooltip("The GameObject that the material is applied to.")] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + + [Tooltip("GameObjects can have multiple materials. Specify an index to target a specific material.")] + public FsmInt materialIndex; + + [Tooltip("Alternatively specify a Material instead of a GameObject and Index.")] + public FsmMaterial material; + + [RequiredField] + [Tooltip("A named float parameter in the shader.")] + public FsmString namedFloat; + + [RequiredField] + [Tooltip("Set the parameter value.")] + public FsmFloat floatValue; + + [Tooltip("Repeat every frame. Useful if the value is animated.")] + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + materialIndex = 0; + material = null; + namedFloat = ""; + floatValue = 0f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetMaterialFloat(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate () + { + DoSetMaterialFloat(); + } + + void DoSetMaterialFloat() + { + if (material.Value != null) + { + material.Value.SetFloat(namedFloat.Value, floatValue.Value); + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (renderer.material == null) + { + LogError("Missing Material!"); + return; + } + + if (materialIndex.Value == 0) + { + renderer.material.SetFloat(namedFloat.Value, floatValue.Value); + } + else if (renderer.materials.Length > materialIndex.Value) + { + var materials = renderer.materials; + materials[materialIndex.Value].SetFloat(namedFloat.Value, floatValue.Value); + renderer.materials = materials; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetMaterialFloat.cs.meta b/Assets/PlayMaker/Actions/SetMaterialFloat.cs.meta new file mode 100755 index 0000000..12829ed --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterialFloat.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dc52acf5cae52fa489222cdac12fed77 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetMaterialMovieTexture.cs b/Assets/PlayMaker/Actions/SetMaterialMovieTexture.cs new file mode 100755 index 0000000..837561f --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterialMovieTexture.cs @@ -0,0 +1,85 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_FLASH || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE || UNITY_BLACKBERRY || UNITY_METRO || UNITY_WP8 || UNITY_PSM || UNITY_WEBGL) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets a named texture in a game object's material to a movie texture.")] + public class SetMaterialMovieTexture : ComponentAction + { + [Tooltip("The GameObject that the material is applied to.")] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + + [Tooltip("GameObjects can have multiple materials. Specify an index to target a specific material.")] + public FsmInt materialIndex; + + [Tooltip("Alternatively specify a Material instead of a GameObject and Index.")] + public FsmMaterial material; + + [UIHint(UIHint.NamedTexture)] + [Tooltip("A named texture in the shader.")] + public FsmString namedTexture; + + [RequiredField] + [ObjectType(typeof(MovieTexture))] + public FsmObject movieTexture; + + public override void Reset() + { + gameObject = null; + materialIndex = 0; + material = null; + namedTexture = "_MainTex"; + movieTexture = null; + } + + public override void OnEnter() + { + DoSetMaterialTexture(); + Finish(); + } + + void DoSetMaterialTexture() + { + var movie = movieTexture.Value as MovieTexture; + + var namedTex = namedTexture.Value; + if (namedTex == "") namedTex = "_MainTex"; + + if (material.Value != null) + { + material.Value.SetTexture(namedTex, movie); + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (renderer.material == null) + { + LogError("Missing Material!"); + return; + } + + if (materialIndex.Value == 0) + { + renderer.material.SetTexture(namedTex, movie); + } + else if (renderer.materials.Length > materialIndex.Value) + { + var materials = renderer.materials; + materials[materialIndex.Value].SetTexture(namedTex, movie); + renderer.materials = materials; + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetMaterialMovieTexture.cs.meta b/Assets/PlayMaker/Actions/SetMaterialMovieTexture.cs.meta new file mode 100755 index 0000000..7dd89ec --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterialMovieTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4009754d7567217489725d4c2d5e9255 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetMaterialTexture.cs b/Assets/PlayMaker/Actions/SetMaterialTexture.cs new file mode 100755 index 0000000..c7f9b15 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterialTexture.cs @@ -0,0 +1,77 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets a named texture in a game object's material.")] + public class SetMaterialTexture : ComponentAction + { + [Tooltip("The GameObject that the material is applied to.")] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + + [Tooltip("GameObjects can have multiple materials. Specify an index to target a specific material.")] + public FsmInt materialIndex; + + [Tooltip("Alternatively specify a Material instead of a GameObject and Index.")] + public FsmMaterial material; + + [UIHint(UIHint.NamedTexture)] + [Tooltip("A named parameter in the shader.")] + public FsmString namedTexture; + + public FsmTexture texture; + + public override void Reset() + { + gameObject = null; + materialIndex = 0; + material = null; + namedTexture = "_MainTex"; + texture = null; + } + + public override void OnEnter() + { + DoSetMaterialTexture(); + Finish(); + } + + void DoSetMaterialTexture() + { + var namedTex = namedTexture.Value; + if (namedTex == "") namedTex = "_MainTex"; + + if (material.Value != null) + { + material.Value.SetTexture(namedTex, texture.Value); + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (renderer.material == null) + { + LogError("Missing Material!"); + return; + } + + if (materialIndex.Value == 0) + { + renderer.material.SetTexture(namedTex, texture.Value); + } + else if (renderer.materials.Length > materialIndex.Value) + { + var materials = renderer.materials; + materials[materialIndex.Value].SetTexture(namedTex, texture.Value); + renderer.materials = materials; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetMaterialTexture.cs.meta b/Assets/PlayMaker/Actions/SetMaterialTexture.cs.meta new file mode 100755 index 0000000..b86184c --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMaterialTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 79fb97dbd1751784d9f8e987bca0cbfb +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetMouseCursor.cs b/Assets/PlayMaker/Actions/SetMouseCursor.cs new file mode 100755 index 0000000..1029ebc --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMouseCursor.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUI)] + [Tooltip("Controls the appearance of Mouse Cursor.")] + public class SetMouseCursor : FsmStateAction + { + public FsmTexture cursorTexture; + public FsmBool hideCursor; + public FsmBool lockCursor; + + public override void Reset() + { + cursorTexture = null; + hideCursor = false; + lockCursor = false; + } + + public override void OnEnter() + { + PlayMakerGUI.LockCursor = lockCursor.Value; + PlayMakerGUI.HideCursor = hideCursor.Value; + PlayMakerGUI.MouseCursor = cursorTexture.Value; + + Finish(); + } + +/* + public override void OnUpdate() + { + // not sure if there is a performance impact to setting these ever frame, + // so only do it if it's changed. + + if (Screen.lockCursor != lockCursor.Value) + Screen.lockCursor = lockCursor.Value; + + if (Screen.showCursor == hideCursor.Value) + Screen.showCursor = !hideCursor.Value; + } + + public override void OnGUI() + { + // draw custom cursor + + if (cursorTexture != null) + { + var mousePos = Input.mousePosition; + var pos = new Rect(mousePos.x - cursorTexture.width * 0.5f, + Screen.height - mousePos.y - cursorTexture.height * 0.5f, + cursorTexture.width, cursorTexture.height); + + GUI.DrawTexture(pos, cursorTexture); + } + }*/ + } +} diff --git a/Assets/PlayMaker/Actions/SetMouseCursor.cs.meta b/Assets/PlayMaker/Actions/SetMouseCursor.cs.meta new file mode 100755 index 0000000..8f48035 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetMouseCursor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 878e7650db19ecc48b8a5e21a42f4502 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetName.cs b/Assets/PlayMaker/Actions/SetName.cs new file mode 100755 index 0000000..5269394 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetName.cs @@ -0,0 +1,38 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Sets a Game Object's Name.")] + public class SetName : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmString name; + + public override void Reset() + { + gameObject = null; + name = null; + } + + public override void OnEnter() + { + DoSetLayer(); + + Finish(); + } + + void DoSetLayer() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + go.name = name.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetName.cs.meta b/Assets/PlayMaker/Actions/SetName.cs.meta new file mode 100755 index 0000000..425ce17 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetName.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6ca6839156f0d8742a3b1a1e0727eb04 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetObjectValue.cs b/Assets/PlayMaker/Actions/SetObjectValue.cs new file mode 100755 index 0000000..fde876e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetObjectValue.cs @@ -0,0 +1,41 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.UnityObject)] + [Tooltip("Sets the value of an Object Variable.")] + public class SetObjectValue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmObject objectVariable; + + [RequiredField] + public FsmObject objectValue; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + public override void Reset() + { + objectVariable = null; + objectValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + objectVariable.Value = objectValue.Value; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + objectVariable.Value = objectValue.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetObjectValue.cs.meta b/Assets/PlayMaker/Actions/SetObjectValue.cs.meta new file mode 100755 index 0000000..7fcd8f5 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetObjectValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 54662ceb470b9404990da495672da27b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetParent.cs b/Assets/PlayMaker/Actions/SetParent.cs new file mode 100755 index 0000000..4a16c59 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetParent.cs @@ -0,0 +1,54 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Sets the Parent of a Game Object.")] + public class SetParent : FsmStateAction + { + [RequiredField] + [Tooltip("The Game Object to parent.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The new parent for the Game Object.")] + public FsmGameObject parent; + + [Tooltip("Set the local position to 0,0,0 after parenting.")] + public FsmBool resetLocalPosition; + + [Tooltip("Set the local rotation to 0,0,0 after parenting.")] + public FsmBool resetLocalRotation; + + public override void Reset() + { + gameObject = null; + parent = null; + resetLocalPosition = null; + resetLocalRotation = null; + } + + public override void OnEnter() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + + if (go != null) + { + go.transform.parent = parent.Value == null ? null : parent.Value.transform; + + if (resetLocalPosition.Value) + { + go.transform.localPosition = Vector3.zero; + } + + if (resetLocalRotation.Value) + { + go.transform.localRotation = Quaternion.identity; + } + } + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetParent.cs.meta b/Assets/PlayMaker/Actions/SetParent.cs.meta new file mode 100755 index 0000000..4c62073 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetParent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a58b09bbc7ddda748b3a872a95a37110 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetPosition.cs b/Assets/PlayMaker/Actions/SetPosition.cs new file mode 100755 index 0000000..f1b2e43 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetPosition.cs @@ -0,0 +1,116 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Sets the Position of a Game Object. To leave any axis unchanged, set variable to 'None'.")] + public class SetPosition : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to position.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [Tooltip("Use a stored Vector3 position, and/or set individual axis below.")] + public FsmVector3 vector; + + public FsmFloat x; + public FsmFloat y; + public FsmFloat z; + + [Tooltip("Use local or world space.")] + public Space space; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + [Tooltip("Perform in LateUpdate. This is useful if you want to override the position of objects that are animated or otherwise positioned in Update.")] + public bool lateUpdate; + + public override void Reset() + { + gameObject = null; + vector = null; + // default axis to variable dropdown with None selected. + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + z = new FsmFloat { UseVariable = true }; + space = Space.Self; + everyFrame = false; + lateUpdate = false; + } + + public override void OnEnter() + { + if (!everyFrame && !lateUpdate) + { + DoSetPosition(); + Finish(); + } + } + + public override void OnUpdate() + { + if (!lateUpdate) + { + DoSetPosition(); + } + } + + public override void OnLateUpdate() + { + if (lateUpdate) + { + DoSetPosition(); + } + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetPosition() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // init position + + Vector3 position; + + if (vector.IsNone) + { + position = space == Space.World ? go.transform.position : go.transform.localPosition; + } + else + { + position = vector.Value; + } + + // override any axis + + if (!x.IsNone) position.x = x.Value; + if (!y.IsNone) position.y = y.Value; + if (!z.IsNone) position.z = z.Value; + + // apply + + if (space == Space.World) + { + go.transform.position = position; + } + else + { + go.transform.localPosition = position; + } + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetPosition.cs.meta b/Assets/PlayMaker/Actions/SetPosition.cs.meta new file mode 100755 index 0000000..ce96cb4 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetPosition.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3601e653be2a11b478f2d632c6354ea0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetProperty.cs b/Assets/PlayMaker/Actions/SetProperty.cs new file mode 100755 index 0000000..7996ef6 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetProperty.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !UNITY_FLASH + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.UnityObject)] + [Tooltip("Sets the value of any public property or field on the targeted Unity Object. E.g., Drag and drop any component attached to a Game Object to access its properties.")] + public class SetProperty : FsmStateAction + { + public FsmProperty targetProperty; + public bool everyFrame; + + public override void Reset() + { + targetProperty = new FsmProperty {setProperty = true}; + everyFrame = false; + } + + public override void OnEnter() + { + targetProperty.SetValue(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + targetProperty.SetValue(); + } + +#if UNITY_EDITOR + public override string AutoName() + { + var name = string.IsNullOrEmpty(targetProperty.PropertyName) ? "[none]" : targetProperty.PropertyName; + var value = ActionHelpers.GetValueLabel(targetProperty.GetVariable()); + return string.Format("Set {0} to {1}", name, value); + } +#endif + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetProperty.cs.meta b/Assets/PlayMaker/Actions/SetProperty.cs.meta new file mode 100755 index 0000000..95999bc --- /dev/null +++ b/Assets/PlayMaker/Actions/SetProperty.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: befa8ae3e14b68044aaf1c7ab7a9d974 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetRandomMaterial.cs b/Assets/PlayMaker/Actions/SetRandomMaterial.cs new file mode 100755 index 0000000..eadd88c --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRandomMaterial.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets a Game Object's material randomly from an array of Materials.")] + public class SetRandomMaterial : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + public FsmInt materialIndex; + public FsmMaterial[] materials; + + public override void Reset() + { + gameObject = null; + materialIndex = 0; + materials = new FsmMaterial[3]; + } + + public override void OnEnter() + { + DoSetRandomMaterial(); + Finish(); + } + + void DoSetRandomMaterial() + { + if (materials == null) return; + if (materials.Length == 0) return; + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (renderer.material == null) + { + LogError("Missing Material!"); + return; + } + + if (materialIndex.Value == 0) + { + renderer.material = materials[Random.Range(0, materials.Length)].Value; + } + else if (renderer.materials.Length > materialIndex.Value) + { + var newMaterials = renderer.materials; + newMaterials[materialIndex.Value] = materials[Random.Range(0, materials.Length)].Value; + renderer.materials = newMaterials; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetRandomMaterial.cs.meta b/Assets/PlayMaker/Actions/SetRandomMaterial.cs.meta new file mode 100755 index 0000000..3e7bd1c --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRandomMaterial.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4d27db5568595374abb4629346811b05 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetRandomRotation.cs b/Assets/PlayMaker/Actions/SetRandomRotation.cs new file mode 100755 index 0000000..309e466 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRandomRotation.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Sets Random Rotation for a Game Object. Uncheck an axis to keep its current value.")] + public class SetRandomRotation : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmBool x; + [RequiredField] + public FsmBool y; + [RequiredField] + public FsmBool z; + + public override void Reset() + { + gameObject = null; + x = true; + y = true; + z = true; + } + + public override void OnEnter() + { + DoRandomRotation(); + + Finish(); + } + + void DoRandomRotation() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) return; + + Vector3 rotation = go.transform.localEulerAngles; + + float xAngle = rotation.x; + float yAngle = rotation.y; + float zAngle = rotation.z; + + if (x.Value) xAngle = Random.Range(0,360); + if (y.Value) yAngle = Random.Range(0,360); + if (z.Value) zAngle = Random.Range(0,360); + + go.transform.localEulerAngles = new Vector3(xAngle, yAngle, zAngle); + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetRandomRotation.cs.meta b/Assets/PlayMaker/Actions/SetRandomRotation.cs.meta new file mode 100755 index 0000000..2af7cb8 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRandomRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3953107518a8648409a83e9e9740366b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetRectFields.cs b/Assets/PlayMaker/Actions/SetRectFields.cs new file mode 100755 index 0000000..355392e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRectFields.cs @@ -0,0 +1,77 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Rect)] + [Tooltip("Sets the individual fields of a Rect Variable. To leave any field unchanged, set variable to 'None'.")] + public class SetRectFields : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmRect rectVariable; + + public FsmFloat x; + public FsmFloat y; + public FsmFloat width; + public FsmFloat height; + + public bool everyFrame; + + public override void Reset() + { + rectVariable = null; + x = new FsmFloat {UseVariable = true}; + y = new FsmFloat { UseVariable = true }; + width = new FsmFloat { UseVariable = true }; + height = new FsmFloat { UseVariable = true }; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetRectFields(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetRectFields(); + } + + void DoSetRectFields() + { + if (rectVariable.IsNone) + { + return; + } + + var newRect = rectVariable.Value; + + if (!x.IsNone) + { + newRect.x = x.Value; + } + + if (!y.IsNone) + { + newRect.y = y.Value; + } + + if (!width.IsNone) + { + newRect.width = width.Value; + } + + if (!height.IsNone) + { + newRect.height = height.Value; + } + + rectVariable.Value = newRect; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetRectFields.cs.meta b/Assets/PlayMaker/Actions/SetRectFields.cs.meta new file mode 100755 index 0000000..70ae181 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRectFields.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0d7c17ad7518dfd439fde3f3ea8aaa26 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetRectValue.cs b/Assets/PlayMaker/Actions/SetRectValue.cs new file mode 100755 index 0000000..e8cb956 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRectValue.cs @@ -0,0 +1,38 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Rect)] + [Tooltip("Sets the value of a Rect Variable.")] + public class SetRectValue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmRect rectVariable; + [RequiredField] + public FsmRect rectValue; + public bool everyFrame; + + public override void Reset() + { + rectVariable = null; + rectValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + rectVariable.Value = rectValue.Value; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + rectVariable.Value = rectValue.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetRectValue.cs.meta b/Assets/PlayMaker/Actions/SetRectValue.cs.meta new file mode 100755 index 0000000..a56a02a --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRectValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 161bec3e164de4442986daf9a21e98a0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetRotation.cs b/Assets/PlayMaker/Actions/SetRotation.cs new file mode 100755 index 0000000..2747061 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRotation.cs @@ -0,0 +1,138 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Sets the Rotation of a Game Object. To leave any axis unchanged, set variable to 'None'.")] + public class SetRotation : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to rotate.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [Tooltip("Use a stored quaternion, or vector angles below.")] + public FsmQuaternion quaternion; + + [UIHint(UIHint.Variable)] + [Title("Euler Angles")] + [Tooltip("Use euler angles stored in a Vector3 variable, and/or set each axis below.")] + public FsmVector3 vector; + + public FsmFloat xAngle; + public FsmFloat yAngle; + public FsmFloat zAngle; + + [Tooltip("Use local or world space.")] + public Space space; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + [Tooltip("Perform in LateUpdate. This is useful if you want to override the position of objects that are animated or otherwise positioned in Update.")] + public bool lateUpdate; + + public override void Reset() + { + gameObject = null; + quaternion = null; + vector = null; + // default axis to variable dropdown with None selected. + xAngle = new FsmFloat { UseVariable = true }; + yAngle = new FsmFloat { UseVariable = true }; + zAngle = new FsmFloat { UseVariable = true }; + space = Space.World; + everyFrame = false; + lateUpdate = false; + } + + public override void OnEnter() + { + if (!everyFrame && !lateUpdate) + { + DoSetRotation(); + Finish(); + } + } + + public override void OnUpdate() + { + if (!lateUpdate) + { + DoSetRotation(); + } + } + + public override void OnLateUpdate() + { + if (lateUpdate) + { + DoSetRotation(); + } + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetRotation() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // Individual angle axis can override Quaternion and Vector angles + // So we build up the final rotation in steps + + Vector3 rotation; + + if (!quaternion.IsNone) + { + rotation = quaternion.Value.eulerAngles; + } + else if (!vector.IsNone) + { + rotation = vector.Value; + } + else + { + // use current rotation of the game object + + rotation = space == Space.Self ? go.transform.localEulerAngles : go.transform.eulerAngles; + } + + // Override each axis + + if (!xAngle.IsNone) + { + rotation.x = xAngle.Value; + } + + if (!yAngle.IsNone) + { + rotation.y = yAngle.Value; + } + + if (!zAngle.IsNone) + { + rotation.z = zAngle.Value; + } + + // apply rotation + + if (space == Space.Self) + { + go.transform.localEulerAngles = rotation; + } + else + { + go.transform.eulerAngles = rotation; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetRotation.cs.meta b/Assets/PlayMaker/Actions/SetRotation.cs.meta new file mode 100755 index 0000000..8f2e781 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetRotation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: eb466e99a5ab8d84383bbf5c5ff7d889 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetScale.cs b/Assets/PlayMaker/Actions/SetScale.cs new file mode 100755 index 0000000..595efef --- /dev/null +++ b/Assets/PlayMaker/Actions/SetScale.cs @@ -0,0 +1,89 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Sets the Scale of a Game Object. To leave any axis unchanged, set variable to 'None'.")] + public class SetScale : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to scale.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [Tooltip("Use stored Vector3 value, and/or set each axis below.")] + public FsmVector3 vector; + + public FsmFloat x; + public FsmFloat y; + public FsmFloat z; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + [Tooltip("Perform in LateUpdate. This is useful if you want to override the position of objects that are animated or otherwise positioned in Update.")] + public bool lateUpdate; + + public override void Reset() + { + gameObject = null; + vector = null; + // default axis to variable dropdown with None selected. + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + z = new FsmFloat { UseVariable = true }; + everyFrame = false; + lateUpdate = false; + } + + public override void OnEnter() + { + DoSetScale(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + if (!lateUpdate) + { + DoSetScale(); + } + } + + public override void OnLateUpdate() + { + if (lateUpdate) + { + DoSetScale(); + } + + if (!everyFrame) + { + Finish(); + } + } + + void DoSetScale() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var scale = vector.IsNone ? go.transform.localScale : vector.Value; + + if (!x.IsNone) scale.x = x.Value; + if (!y.IsNone) scale.y = y.Value; + if (!z.IsNone) scale.z = z.Value; + + go.transform.localScale = scale; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetScale.cs.meta b/Assets/PlayMaker/Actions/SetScale.cs.meta new file mode 100755 index 0000000..5cd495b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetScale.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fab7464a9d299ec42aa83aabdfb2da9f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetShadowStrength.cs b/Assets/PlayMaker/Actions/SetShadowStrength.cs new file mode 100755 index 0000000..7a738f9 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetShadowStrength.cs @@ -0,0 +1,46 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Lights)] + [Tooltip("Sets the strength of the shadows cast by a Light.")] + public class SetShadowStrength : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Light))] + public FsmOwnerDefault gameObject; + public FsmFloat shadowStrength; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + shadowStrength = 0.8f; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetShadowStrength(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetShadowStrength(); + } + + void DoSetShadowStrength() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + light.shadowStrength = shadowStrength.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetShadowStrength.cs.meta b/Assets/PlayMaker/Actions/SetShadowStrength.cs.meta new file mode 100755 index 0000000..e1444f3 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetShadowStrength.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a409f184b264b374182d5f219718fc0b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetSkybox.cs b/Assets/PlayMaker/Actions/SetSkybox.cs new file mode 100755 index 0000000..2a3df48 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetSkybox.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.RenderSettings)] + [Tooltip("Sets the global Skybox.")] + public class SetSkybox : FsmStateAction + { + public FsmMaterial skybox; + [Tooltip("Repeat every frame. Useful if the Skybox is changing.")] + public bool everyFrame; + + public override void Reset() + { + skybox = null; + } + + public override void OnEnter() + { + RenderSettings.skybox = skybox.Value; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + RenderSettings.skybox = skybox.Value; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetSkybox.cs.meta b/Assets/PlayMaker/Actions/SetSkybox.cs.meta new file mode 100755 index 0000000..6d47450 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetSkybox.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 928fc049037e6ed449289cc393fbc2c0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetStringValue.cs b/Assets/PlayMaker/Actions/SetStringValue.cs new file mode 100755 index 0000000..3eeaae8 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetStringValue.cs @@ -0,0 +1,49 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Sets the value of a String Variable.")] + public class SetStringValue : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + + [UIHint(UIHint.TextArea)] + public FsmString stringValue; + + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + stringValue = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetStringValue(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetStringValue(); + } + + void DoSetStringValue() + { + if (stringVariable == null) return; + if (stringValue == null) return; + + stringVariable.Value = stringValue.Value; + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetStringValue.cs.meta b/Assets/PlayMaker/Actions/SetStringValue.cs.meta new file mode 100755 index 0000000..a082347 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetStringValue.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8b3d2b903f5938946baf4129f67eb6f2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetTag.cs b/Assets/PlayMaker/Actions/SetTag.cs new file mode 100755 index 0000000..898a7fc --- /dev/null +++ b/Assets/PlayMaker/Actions/SetTag.cs @@ -0,0 +1,31 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Sets a Game Object's Tag.")] + public class SetTag : FsmStateAction + { + public FsmOwnerDefault gameObject; + [UIHint(UIHint.Tag)] + public FsmString tag; + + public override void Reset() + { + gameObject = null; + tag = "Untagged"; + } + + public override void OnEnter() + { + GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); + + if (go != null) + go.tag = tag.Value; + + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetTag.cs.meta b/Assets/PlayMaker/Actions/SetTag.cs.meta new file mode 100755 index 0000000..49e3c71 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetTag.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a18f0330745a73a48a1f445ac24bb57d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetTagsOnChildren.cs b/Assets/PlayMaker/Actions/SetTagsOnChildren.cs new file mode 100755 index 0000000..c8b8c4e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetTagsOnChildren.cs @@ -0,0 +1,87 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GameObject)] + [Tooltip("Set the Tag on all children of a GameObject. Optionally filter by component.")] + public class SetTagsOnChildren : FsmStateAction + { + [RequiredField] + [Tooltip("GameObject Parent")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Tag)] + [Tooltip("Set Tag To...")] + public FsmString tag; + + [UIHint(UIHint.ScriptComponent)] + [Tooltip("Only set the Tag on children with this component.")] + public FsmString filterByComponent; + + public override void Reset() + { + gameObject = null; + tag = null; + filterByComponent = null; + } + + private Type componentFilter; + + public override void OnEnter() + { + SetTag(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + void SetTag(GameObject parent) + { + if (parent == null) + { + return; + } + + if (string.IsNullOrEmpty(filterByComponent.Value)) // do all children + { + foreach (Transform child in parent.transform) + { + child.gameObject.tag = tag.Value; + } + } + else + { + UpdateComponentFilter(); + + if (componentFilter != null) // filter by component + { + var root = parent.GetComponentsInChildren(componentFilter); + foreach (var child in root) + { + child.gameObject.tag = tag.Value; + } + } + } + + Finish(); + } + + void UpdateComponentFilter() + { + componentFilter = ReflectionUtils.GetGlobalType(filterByComponent.Value); + + if (componentFilter == null) // try adding UnityEngine namespace + { + componentFilter = ReflectionUtils.GetGlobalType("UnityEngine." + filterByComponent.Value); + } + + if (componentFilter == null) + { + Debug.LogWarning("Couldn't get type: " + filterByComponent.Value); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetTagsOnChildren.cs.meta b/Assets/PlayMaker/Actions/SetTagsOnChildren.cs.meta new file mode 100755 index 0000000..4afd63f --- /dev/null +++ b/Assets/PlayMaker/Actions/SetTagsOnChildren.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f3aeb4131f42a2b4e8ba7e6fcef80ab6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetTextureOffset.cs b/Assets/PlayMaker/Actions/SetTextureOffset.cs new file mode 100755 index 0000000..370e780 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetTextureOffset.cs @@ -0,0 +1,76 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets the Offset of a named texture in a Game Object's Material. Useful for scrolling texture effects.")] + public class SetTextureOffset : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + public FsmInt materialIndex; + [RequiredField] + [UIHint(UIHint.NamedColor)] + public FsmString namedTexture; + [RequiredField] + public FsmFloat offsetX; + [RequiredField] + public FsmFloat offsetY; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + materialIndex = 0; + namedTexture = "_MainTex"; + offsetX = 0; + offsetY = 0; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetTextureOffset(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetTextureOffset(); + } + + void DoSetTextureOffset() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (renderer.material == null) + { + LogError("Missing Material!"); + return; + } + + if (materialIndex.Value == 0) + { + renderer.material.SetTextureOffset(namedTexture.Value, new Vector2(offsetX.Value, offsetY.Value)); + } + else if (renderer.materials.Length > materialIndex.Value) + { + var materials = renderer.materials; + materials[materialIndex.Value].SetTextureOffset(namedTexture.Value, new Vector2(offsetX.Value, offsetY.Value)); + renderer.materials = materials; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetTextureOffset.cs.meta b/Assets/PlayMaker/Actions/SetTextureOffset.cs.meta new file mode 100755 index 0000000..32f026b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetTextureOffset.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 68195895c1254ea4189e215accbd3e5f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetTextureScale.cs b/Assets/PlayMaker/Actions/SetTextureScale.cs new file mode 100755 index 0000000..28fdd4e --- /dev/null +++ b/Assets/PlayMaker/Actions/SetTextureScale.cs @@ -0,0 +1,74 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets the Scale of a named texture in a Game Object's Material. Useful for special effects.")] + public class SetTextureScale : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + public FsmInt materialIndex; + [UIHint(UIHint.NamedColor)] + public FsmString namedTexture; + [RequiredField] + public FsmFloat scaleX; + [RequiredField] + public FsmFloat scaleY; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + materialIndex = 0; + namedTexture = "_MainTex"; + scaleX = 1; + scaleY = 1; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetTextureScale(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoSetTextureScale(); + } + + void DoSetTextureScale() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (renderer.material == null) + { + LogError("Missing Material!"); + return; + } + + if (materialIndex.Value == 0) + { + renderer.material.SetTextureScale(namedTexture.Value, new Vector2(scaleX.Value, scaleY.Value)); + } + else if (renderer.materials.Length > materialIndex.Value) + { + var materials = renderer.materials; + materials[materialIndex.Value].SetTextureScale(namedTexture.Value, new Vector2(scaleX.Value, scaleY.Value)); + renderer.materials = materials; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetTextureScale.cs.meta b/Assets/PlayMaker/Actions/SetTextureScale.cs.meta new file mode 100755 index 0000000..cc68c92 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetTextureScale.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e63285cfd221ed0439232ef382291332 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetVector3Value.cs b/Assets/PlayMaker/Actions/SetVector3Value.cs new file mode 100755 index 0000000..be4f70b --- /dev/null +++ b/Assets/PlayMaker/Actions/SetVector3Value.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Sets the value of a Vector3 Variable.")] + public class SetVector3Value : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + [RequiredField] + public FsmVector3 vector3Value; + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + vector3Value = null; + everyFrame = false; + } + + public override void OnEnter() + { + vector3Variable.Value = vector3Value.Value; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + vector3Variable.Value = vector3Value.Value; + } + } +} + diff --git a/Assets/PlayMaker/Actions/SetVector3Value.cs.meta b/Assets/PlayMaker/Actions/SetVector3Value.cs.meta new file mode 100755 index 0000000..76b1e56 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetVector3Value.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3c671497bd752ed41af27ef70b33c580 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetVector3XYZ.cs b/Assets/PlayMaker/Actions/SetVector3XYZ.cs new file mode 100755 index 0000000..e8ea428 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetVector3XYZ.cs @@ -0,0 +1,58 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Sets the XYZ channels of a Vector3 Variable. To leave any channel unchanged, set variable to 'None'.")] + public class SetVector3XYZ : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Value; + public FsmFloat x; + public FsmFloat y; + public FsmFloat z; + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + vector3Value = null; + x = new FsmFloat{ UseVariable = true}; + y = new FsmFloat{ UseVariable = true}; + z = new FsmFloat{ UseVariable = true}; + everyFrame = false; + } + + public override void OnEnter() + { + DoSetVector3XYZ(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoSetVector3XYZ(); + } + + void DoSetVector3XYZ() + { + if (vector3Variable == null) return; + + Vector3 newVector3 = vector3Variable.Value; + + if (!vector3Value.IsNone) newVector3 = vector3Value.Value; + if (!x.IsNone) newVector3.x = x.Value; + if (!y.IsNone) newVector3.y = y.Value; + if (!z.IsNone) newVector3.z = z.Value; + + vector3Variable.Value = newVector3; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetVector3XYZ.cs.meta b/Assets/PlayMaker/Actions/SetVector3XYZ.cs.meta new file mode 100755 index 0000000..17f6761 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetVector3XYZ.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 38fdfd7b801c34047aca94430e736a64 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetVelocity.cs b/Assets/PlayMaker/Actions/SetVelocity.cs new file mode 100755 index 0000000..1b83338 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetVelocity.cs @@ -0,0 +1,96 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Sets the Velocity of a Game Object. To leave any axis unchanged, set variable to 'None'. NOTE: Game object must have a rigidbody.")] + public class SetVelocity : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + public FsmVector3 vector; + + public FsmFloat x; + public FsmFloat y; + public FsmFloat z; + + public Space space; + + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + vector = null; + // default axis to variable dropdown with None selected. + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + z = new FsmFloat { UseVariable = true }; + space = Space.Self; + everyFrame = false; + } + + public override void OnPreprocess() + { + Fsm.HandleFixedUpdate = true; + } + + // TODO: test this works in OnEnter! + public override void OnEnter() + { + DoSetVelocity(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnFixedUpdate() + { + DoSetVelocity(); + + if (!everyFrame) + Finish(); + } + + void DoSetVelocity() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + // init position + + Vector3 velocity; + + if (vector.IsNone) + { + velocity = space == Space.World ? + rigidbody.velocity : + go.transform.InverseTransformDirection(rigidbody.velocity); + } + else + { + velocity = vector.Value; + } + + // override any axis + + if (!x.IsNone) velocity.x = x.Value; + if (!y.IsNone) velocity.y = y.Value; + if (!z.IsNone) velocity.z = z.Value; + + // apply + + rigidbody.velocity = space == Space.World ? velocity : go.transform.TransformDirection(velocity); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetVelocity.cs.meta b/Assets/PlayMaker/Actions/SetVelocity.cs.meta new file mode 100755 index 0000000..2725249 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetVelocity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1c20dda97df3fd54cab324f8e260fab7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SetVisibility.cs b/Assets/PlayMaker/Actions/SetVisibility.cs new file mode 100755 index 0000000..4fde228 --- /dev/null +++ b/Assets/PlayMaker/Actions/SetVisibility.cs @@ -0,0 +1,83 @@ +// Thanks MaDDoX: http://hutonggames.com/playmakerforum/index.php?topic=159.0 + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Material)] + [Tooltip("Sets the visibility of a GameObject. Note: this action sets the GameObject Renderer's enabled state.")] + public class SetVisibility : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Renderer))] + public FsmOwnerDefault gameObject; + + //[UIHint(UIHint.Variable)] + [Tooltip("Should the object visibility be toggled?\nHas priority over the 'visible' setting")] + public FsmBool toggle; + + //[UIHint(UIHint.Variable)] + [Tooltip("Should the object be set to visible or invisible?")] + public FsmBool visible; + + [Tooltip("Resets to the initial visibility when it leaves the state")] + public bool resetOnExit; + + private bool initialVisibility; + + public override void Reset() + { + gameObject = null; + toggle = false; + visible = false; + resetOnExit = true; + initialVisibility = false; + } + + public override void OnEnter() + { + DoSetVisibility(Fsm.GetOwnerDefaultTarget(gameObject)); + + Finish(); + } + + void DoSetVisibility(GameObject go) + { + if (!UpdateCache(go)) + { + return; + } + + // remember initial visibility + initialVisibility = renderer.enabled; + + // if 'toggle' is not set, simply sets visibility to new value + if (toggle.Value == false) + { + renderer.enabled = visible.Value; + return; + } + + // otherwise, toggles the visibility + renderer.enabled = !renderer.enabled; + } + + public override void OnExit() + { + if (resetOnExit) + { + ResetVisibility(); + } + } + + void ResetVisibility() + { + if (renderer != null) + { + renderer.enabled = initialVisibility; + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SetVisibility.cs.meta b/Assets/PlayMaker/Actions/SetVisibility.cs.meta new file mode 100755 index 0000000..b6f9aeb --- /dev/null +++ b/Assets/PlayMaker/Actions/SetVisibility.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 273f126d8ce4d96439b1cf9a1066c453 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Sleep.cs b/Assets/PlayMaker/Actions/Sleep.cs new file mode 100755 index 0000000..0f758c0 --- /dev/null +++ b/Assets/PlayMaker/Actions/Sleep.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Forces a Game Object's Rigid Body to Sleep at least one frame.")] + public class Sleep : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + + public override void Reset() + { + gameObject = null; + } + + public override void OnEnter() + { + DoSleep(); + Finish(); + } + + void DoSleep() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + rigidbody.Sleep(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Sleep.cs.meta b/Assets/PlayMaker/Actions/Sleep.cs.meta new file mode 100755 index 0000000..44e471f --- /dev/null +++ b/Assets/PlayMaker/Actions/Sleep.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c111cfc52d5612a41916fa6f4f7ff780 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SmoothFollowAction.cs b/Assets/PlayMaker/Actions/SmoothFollowAction.cs new file mode 100755 index 0000000..1cf991a --- /dev/null +++ b/Assets/PlayMaker/Actions/SmoothFollowAction.cs @@ -0,0 +1,106 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Action version of Unity's Smooth Follow script.")] + public class SmoothFollowAction : FsmStateAction + { + [RequiredField] + [Tooltip("The game object to control. E.g. The camera.")] + public FsmOwnerDefault gameObject; + + [Tooltip("The GameObject to follow.")] + public FsmGameObject targetObject; + + [RequiredField] + [Tooltip("The distance in the x-z plane to the target.")] + public FsmFloat distance; + + [RequiredField] + [Tooltip("The height we want the camera to be above the target")] + public FsmFloat height; + + [RequiredField] + [Tooltip("How much to dampen height movement.")] + public FsmFloat heightDamping; + + [RequiredField] + [Tooltip("How much to dampen rotation changes.")] + public FsmFloat rotationDamping; + + // Cache for performance + private GameObject cachedObject; + private Transform myTransform; + + private GameObject cachedTarget; + private Transform targetTransform; + + public override void Reset() + { + gameObject = null; + targetObject = null; + distance = 10f; + height = 5f; + heightDamping = 2f; + rotationDamping = 3f; + } + + public override void OnLateUpdate() + { + if (targetObject.Value == null) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + if (cachedObject != go) + { + cachedObject = go; + myTransform = go.transform; + } + + if (cachedTarget != targetObject.Value) + { + cachedTarget = targetObject.Value; + targetTransform = cachedTarget.transform; + } + + + // Calculate the current rotation angles + var wantedRotationAngle = targetTransform.eulerAngles.y; + var wantedHeight = targetTransform.position.y + height.Value; + + var currentRotationAngle = myTransform.eulerAngles.y; + var currentHeight = myTransform.position.y; + + // Damp the rotation around the y-axis + currentRotationAngle = Mathf.LerpAngle(currentRotationAngle, wantedRotationAngle, rotationDamping.Value * Time.deltaTime); + + // Damp the height + currentHeight = Mathf.Lerp(currentHeight, wantedHeight, heightDamping.Value * Time.deltaTime); + + // Convert the angle into a rotation + var currentRotation = Quaternion.Euler(0, currentRotationAngle, 0); + + // Set the position of the camera on the x-z plane to: + // distance meters behind the target + myTransform.position = targetTransform.position; + myTransform.position -= currentRotation * Vector3.forward * distance.Value; + + // Set the height of the camera + myTransform.position = new Vector3(myTransform.position.x, currentHeight, myTransform.position.z); + + // Always look at the target + myTransform.LookAt(targetTransform); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SmoothFollowAction.cs.meta b/Assets/PlayMaker/Actions/SmoothFollowAction.cs.meta new file mode 100755 index 0000000..07f349e --- /dev/null +++ b/Assets/PlayMaker/Actions/SmoothFollowAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ed1c27ff26656574e9329db3c59da9d7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SmoothLookAt.cs b/Assets/PlayMaker/Actions/SmoothLookAt.cs new file mode 100755 index 0000000..483b041 --- /dev/null +++ b/Assets/PlayMaker/Actions/SmoothLookAt.cs @@ -0,0 +1,142 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Smoothly Rotates a Game Object so its forward vector points at a Target. The target can be defined as a Game Object or a world Position. If you specify both, then the position will be used as a local offset from the object's position.")] + public class SmoothLookAt : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to rotate to face a target.")] + public FsmOwnerDefault gameObject; + + [Tooltip("A target GameObject.")] + public FsmGameObject targetObject; + + [Tooltip("A target position. If a Target Object is defined, this is used as a local offset.")] + public FsmVector3 targetPosition; + + [Tooltip("Used to keep the game object generally upright. If left undefined the world y axis is used.")] + public FsmVector3 upVector; + + [Tooltip("Force the game object to remain vertical. Useful for characters.")] + public FsmBool keepVertical; + + [HasFloatSlider(0.5f,15)] + [Tooltip("How fast the look at moves.")] + public FsmFloat speed; + + [Tooltip("Draw a line in the Scene View to the look at position.")] + public FsmBool debug; + + [Tooltip("If the angle to the target is less than this, send the Finish Event below. Measured in degrees.")] + public FsmFloat finishTolerance; + + [Tooltip("Event to send if the angle to target is less than the Finish Tolerance.")] + public FsmEvent finishEvent; + + private GameObject previousGo; // track game object so we can re-initialize when it changes. + private Quaternion lastRotation; + private Quaternion desiredRotation; + + public override void Reset() + { + gameObject = null; + targetObject = null; + targetPosition = new FsmVector3 { UseVariable = true}; + upVector = new FsmVector3 { UseVariable = true}; + keepVertical = true; + debug = false; + speed = 5; + finishTolerance = 1; + finishEvent = null; + } + + public override void OnEnter() + { + previousGo = null; + } + + public override void OnLateUpdate() + { + DoSmoothLookAt(); + } + + void DoSmoothLookAt() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + var goTarget = targetObject.Value; + if (goTarget == null && targetPosition.IsNone) + { + return; + } + + // re-initialize if game object has changed + + if (previousGo != go) + { + lastRotation = go.transform.rotation; + desiredRotation = lastRotation; + previousGo = go; + } + + // desired look at position + + Vector3 lookAtPos; + if (goTarget != null) + { + lookAtPos = !targetPosition.IsNone ? + goTarget.transform.TransformPoint(targetPosition.Value) : + goTarget.transform.position; + } + else + { + lookAtPos = targetPosition.Value; + } + + if (keepVertical.Value) + { + lookAtPos.y = go.transform.position.y; + } + + // smooth look at + + var diff = lookAtPos - go.transform.position; + if (diff != Vector3.zero && diff.sqrMagnitude > 0) + { + desiredRotation = Quaternion.LookRotation(diff, upVector.IsNone ? Vector3.up : upVector.Value); + } + + lastRotation = Quaternion.Slerp(lastRotation, desiredRotation, speed.Value * Time.deltaTime); + go.transform.rotation = lastRotation; + + // debug line to target + + if (debug.Value) + { + Debug.DrawLine(go.transform.position, lookAtPos, Color.grey); + } + + // send finish event? + + if (finishEvent != null) + { + var targetDir = lookAtPos - go.transform.position; + var angle = Vector3.Angle(targetDir, go.transform.forward); + + if (Mathf.Abs(angle) <= finishTolerance.Value) + { + Fsm.Event(finishEvent); + } + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SmoothLookAt.cs.meta b/Assets/PlayMaker/Actions/SmoothLookAt.cs.meta new file mode 100755 index 0000000..d374c04 --- /dev/null +++ b/Assets/PlayMaker/Actions/SmoothLookAt.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 58c821d80048bd14d8917ce1a9dcbe72 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SmoothLookAtDirection.cs b/Assets/PlayMaker/Actions/SmoothLookAtDirection.cs new file mode 100755 index 0000000..0e85366 --- /dev/null +++ b/Assets/PlayMaker/Actions/SmoothLookAtDirection.cs @@ -0,0 +1,134 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Smoothly Rotates a Game Object so its forward vector points in the specified Direction. Lets you fire an event when minmagnitude is reached")] + public class SmoothLookAtDirection : FsmStateAction + { + [RequiredField] + [Tooltip("The GameObject to rotate.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("The direction to smoothly rotate towards.")] + public FsmVector3 targetDirection; + + [Tooltip("Only rotate if Target Direction Vector length is greater than this threshold.")] + public FsmFloat minMagnitude; + + [Tooltip("Keep this vector pointing up as the GameObject rotates.")] + public FsmVector3 upVector; + + [RequiredField] + [Tooltip("Eliminate any tilt up/down as the GameObject rotates.")] + public FsmBool keepVertical; + + [RequiredField] + [HasFloatSlider(0.5f, 15)] + [Tooltip("How quickly to rotate.")] + public FsmFloat speed; + + [Tooltip("Perform in LateUpdate. This can help eliminate jitters in some situations.")] + public bool lateUpdate; + + [Tooltip("Event to send if the direction difference is less than Min Magnitude.")] + public FsmEvent finishEvent; + + GameObject previousGo; // track game object so we can re-initialize when it changes. + Quaternion lastRotation; + Quaternion desiredRotation; + + + private bool _done; + + public override void Reset() + { + gameObject = null; + targetDirection = new FsmVector3 { UseVariable = true }; + minMagnitude = 0.1f; + upVector = new FsmVector3 { UseVariable = true }; + keepVertical = true; + speed = 5; + lateUpdate = true; + finishEvent = null; + } + + public override void OnEnter() + { + previousGo = null; + } + + public override void OnUpdate() + { + if (!lateUpdate) + { + DoSmoothLookAtDirection(); + } + } + + public override void OnLateUpdate() + { + if (lateUpdate) + { + DoSmoothLookAtDirection(); + } + } + + void DoSmoothLookAtDirection() + { + if (targetDirection.IsNone) + { + return; + } + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // re-initialize if game object has changed + + if (previousGo != go) + { + lastRotation = go.transform.rotation; + desiredRotation = lastRotation; + previousGo = go; + } + + // desired direction + + var diff = targetDirection.Value; + + if (keepVertical.Value) + { + diff.y = 0; + } + + + desiredRotation = Quaternion.LookRotation(diff, upVector.IsNone ? Vector3.up : upVector.Value); + + lastRotation = Quaternion.Slerp(lastRotation, desiredRotation, speed.Value * Time.deltaTime); + go.transform.rotation = lastRotation; + + + if (Quaternion.Angle(desiredRotation, go.transform.rotation) < minMagnitude.Value) + { + if (!_done) + { + _done = true; + Fsm.Event(finishEvent); + Finish(); + } + } + else + { + _done = false; + } + + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SmoothLookAtDirection.cs.meta b/Assets/PlayMaker/Actions/SmoothLookAtDirection.cs.meta new file mode 100755 index 0000000..bad7367 --- /dev/null +++ b/Assets/PlayMaker/Actions/SmoothLookAtDirection.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8a8fca88c56dcf74b8a5c901168b82ce +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StartCoroutine.cs b/Assets/PlayMaker/Actions/StartCoroutine.cs new file mode 100755 index 0000000..ac14acd --- /dev/null +++ b/Assets/PlayMaker/Actions/StartCoroutine.cs @@ -0,0 +1,180 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if UNITY_EDITOR +using System; +using System.Linq; +using System.Collections.Generic; +using System.Reflection; +#endif + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.ScriptControl)] + [Tooltip("Start a Coroutine in a Behaviour on a Game Object. See Unity StartCoroutine docs.")] + public class StartCoroutine : FsmStateAction + { + [RequiredField] + [Tooltip("The game object that owns the Behaviour.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [UIHint(UIHint.Behaviour)] + [Tooltip("The Behaviour that contains the method to start as a coroutine.")] + public FsmString behaviour; + + [RequiredField] + [UIHint(UIHint.Coroutine)] + [Tooltip("The name of the coroutine method.")] + public FunctionCall functionCall; + + [Tooltip("Stop the coroutine when the state is exited.")] + public bool stopOnExit; + + public override void Reset() + { + gameObject = null; + behaviour = null; + functionCall = null; + stopOnExit = false; + } + + MonoBehaviour component; + +#if UNITY_EDITOR + + private Type cachedType; + private List methodNames; + +#endif + + public override void OnEnter() + { + DoStartCoroutine(); + + Finish(); + } + + void DoStartCoroutine() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + component = go.GetComponent(ReflectionUtils.GetGlobalType(behaviour.Value)) as MonoBehaviour; + + if (component == null) + { + LogWarning("StartCoroutine: " + go.name + " missing behaviour: " + behaviour.Value); + return; + } + + switch (functionCall.ParameterType) + { + case "None": + component.StartCoroutine(functionCall.FunctionName); + return; + + case "int": + component.StartCoroutine(functionCall.FunctionName, functionCall.IntParameter.Value); + return; + + case "float": + component.StartCoroutine(functionCall.FunctionName, functionCall.FloatParameter.Value); + return; + + case "string": + component.StartCoroutine(functionCall.FunctionName, functionCall.StringParameter.Value); + return; + + case "bool": + component.StartCoroutine(functionCall.FunctionName, functionCall.BoolParameter.Value); + return; + + case "Vector2": + component.StartCoroutine(functionCall.FunctionName, functionCall.Vector2Parameter.Value); + return; + + case "Vector3": + component.StartCoroutine(functionCall.FunctionName, functionCall.Vector3Parameter.Value); + return; + + case "Rect": + component.StartCoroutine(functionCall.FunctionName, functionCall.RectParamater.Value); + return; + + case "GameObject": + component.StartCoroutine(functionCall.FunctionName, functionCall.GameObjectParameter.Value); + return; + + case "Material": + component.StartCoroutine(functionCall.FunctionName, functionCall.MaterialParameter.Value); + break; + + case "Texture": + component.StartCoroutine(functionCall.FunctionName, functionCall.TextureParameter.Value); + break; + + case "Quaternion": + component.StartCoroutine(functionCall.FunctionName, functionCall.QuaternionParameter.Value); + break; + + case "Object": + component.StartCoroutine(functionCall.FunctionName, functionCall.ObjectParameter.Value); + return; + } + } + + public override void OnExit() + { + if (component == null) + { + return; + } + + if (stopOnExit) + { + component.StopCoroutine(functionCall.FunctionName); + } + } + +#if UNITY_EDITOR + + + public override string ErrorCheck() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null || string.IsNullOrEmpty(behaviour.Value)) + { + return string.Empty; + } + + var type = ReflectionUtils.GetGlobalType(behaviour.Value); + if (type == null) + { + return "Missing Behaviour: " + behaviour.Value; + } + + if (cachedType != type) + { + cachedType = type; + methodNames = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Select(m => m.Name).ToList(); + } + + if (!string.IsNullOrEmpty(functionCall.FunctionName)) + { + if (!methodNames.Contains(functionCall.FunctionName)) + { + return "Missing Method: " + functionCall.FunctionName; + } + } + return string.Empty; + } + +#endif + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StartCoroutine.cs.meta b/Assets/PlayMaker/Actions/StartCoroutine.cs.meta new file mode 100755 index 0000000..b29e859 --- /dev/null +++ b/Assets/PlayMaker/Actions/StartCoroutine.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 842057c7f39d18e409aa991699964102 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StartLocationServiceUpdates.cs b/Assets/PlayMaker/Actions/StartLocationServiceUpdates.cs new file mode 100755 index 0000000..51cc7db --- /dev/null +++ b/Assets/PlayMaker/Actions/StartLocationServiceUpdates.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Starts location service updates. Last location coordinates can be retrieved with GetLocationInfo.")] + public class StartLocationServiceUpdates : FsmStateAction + { + [Tooltip("Maximum time to wait in seconds before failing.")] + public FsmFloat maxWait; + public FsmFloat desiredAccuracy; + public FsmFloat updateDistance; + [Tooltip("Event to send when the location services have started.")] + public FsmEvent successEvent; + [Tooltip("Event to send if the location services fail to start.")] + public FsmEvent failedEvent; + +#if UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WP8 + float startTime; +#endif + public override void Reset() + { + maxWait = 20; + desiredAccuracy = 10; + updateDistance = 10; + successEvent = null; + failedEvent = null; + } + + public override void OnEnter() + { +#if UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WP8 + startTime = FsmTime.RealtimeSinceStartup; + + Input.location.Start(desiredAccuracy.Value, updateDistance.Value); +#else + Finish(); +#endif + } + + public override void OnUpdate() + { +#if UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WP8 + + if (Input.location.status == LocationServiceStatus.Failed || + Input.location.status == LocationServiceStatus.Stopped || + (FsmTime.RealtimeSinceStartup - startTime) > maxWait.Value ) + { + Fsm.Event(failedEvent); + Finish(); + } + + if (Input.location.status == LocationServiceStatus.Running) + { + Fsm.Event(successEvent); + Finish(); + } +#endif + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StartLocationServiceUpdates.cs.meta b/Assets/PlayMaker/Actions/StartLocationServiceUpdates.cs.meta new file mode 100755 index 0000000..8ab1080 --- /dev/null +++ b/Assets/PlayMaker/Actions/StartLocationServiceUpdates.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a2cd1b09e9c55ea44a57e9df022277c7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StopAnimation.cs b/Assets/PlayMaker/Actions/StopAnimation.cs new file mode 100755 index 0000000..87f1095 --- /dev/null +++ b/Assets/PlayMaker/Actions/StopAnimation.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Animation)] + [Tooltip("Stops all playing Animations on a Game Object. Optionally, specify a single Animation to Stop.")] + public class StopAnimation : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Animation))] + public FsmOwnerDefault gameObject; + [Tooltip("Leave empty to stop all playing animations.")] + [UIHint(UIHint.Animation)] + public FsmString animName; + + public override void Reset() + { + gameObject = null; + animName = null; + } + + public override void OnEnter() + { + DoStopAnimation(); + + Finish(); + } + + void DoStopAnimation() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (!UpdateCache(go)) + { + return; + } + + if (FsmString.IsNullOrEmpty(animName)) + { + animation.Stop(); + } + else + { + animation.Stop(animName.Value); + } + } + + /* + public override string ErrorCheck() + { + return ErrorCheckHelpers.CheckAnimationSetup(gameObject.value); + }*/ + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StopAnimation.cs.meta b/Assets/PlayMaker/Actions/StopAnimation.cs.meta new file mode 100755 index 0000000..3ea8a24 --- /dev/null +++ b/Assets/PlayMaker/Actions/StopAnimation.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 65734b83a2a4b7f4081d0bff7d0d9720 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StopLocationServiceUpdates.cs b/Assets/PlayMaker/Actions/StopLocationServiceUpdates.cs new file mode 100755 index 0000000..f5f4497 --- /dev/null +++ b/Assets/PlayMaker/Actions/StopLocationServiceUpdates.cs @@ -0,0 +1,23 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Stops location service updates. This could be useful for saving battery life.")] + public class StopLocationServiceUpdates : FsmStateAction + { + public override void Reset() + { + } + + public override void OnEnter() + { +#if UNITY_IPHONE || UNITY_ANDROID || UNITY_BLACKBERRY || UNITY_WP8 + Input.location.Stop(); +#endif + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StopLocationServiceUpdates.cs.meta b/Assets/PlayMaker/Actions/StopLocationServiceUpdates.cs.meta new file mode 100755 index 0000000..d044018 --- /dev/null +++ b/Assets/PlayMaker/Actions/StopLocationServiceUpdates.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 31f8e229414b84e4bab36e3258d73312 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StopMovieTexture.cs b/Assets/PlayMaker/Actions/StopMovieTexture.cs new file mode 100755 index 0000000..3efcd6f --- /dev/null +++ b/Assets/PlayMaker/Actions/StopMovieTexture.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_FLASH || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE || UNITY_BLACKBERRY || UNITY_METRO || UNITY_WP8 || UNITY_PSM || UNITY_WEBGL) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Movie)] + [Tooltip("Stops playing the Movie Texture, and rewinds it to the beginning.")] + public class StopMovieTexture : FsmStateAction + { + [RequiredField] + [ObjectType(typeof(MovieTexture))] + public FsmObject movieTexture; + + public override void Reset() + { + movieTexture = null; + } + + public override void OnEnter() + { + var movie = movieTexture.Value as MovieTexture; + + if (movie != null) + { + movie.Stop(); + } + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StopMovieTexture.cs.meta b/Assets/PlayMaker/Actions/StopMovieTexture.cs.meta new file mode 100755 index 0000000..1e07b22 --- /dev/null +++ b/Assets/PlayMaker/Actions/StopMovieTexture.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ba927a406ee51c64b993fbeeb5da2abe +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StringChanged.cs b/Assets/PlayMaker/Actions/StringChanged.cs new file mode 100755 index 0000000..7774cd3 --- /dev/null +++ b/Assets/PlayMaker/Actions/StringChanged.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if the value of a string variable has changed. Use this to send an event on change, or store a bool that can be used in other operations.")] + public class StringChanged : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + public FsmEvent changedEvent; + [UIHint(UIHint.Variable)] + public FsmBool storeResult; + + string previousValue; + + public override void Reset() + { + stringVariable = null; + changedEvent = null; + storeResult = null; + } + + public override void OnEnter() + { + if (stringVariable.IsNone) + { + Finish(); + return; + } + + previousValue = stringVariable.Value; + } + + public override void OnUpdate() + { + if (stringVariable.Value != previousValue) + { + storeResult.Value = true; + Fsm.Event(changedEvent); + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/StringChanged.cs.meta b/Assets/PlayMaker/Actions/StringChanged.cs.meta new file mode 100755 index 0000000..2003dd2 --- /dev/null +++ b/Assets/PlayMaker/Actions/StringChanged.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1b5d01cc959ad214fabc2222238012a4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StringCompare.cs b/Assets/PlayMaker/Actions/StringCompare.cs new file mode 100755 index 0000000..8c1b52d --- /dev/null +++ b/Assets/PlayMaker/Actions/StringCompare.cs @@ -0,0 +1,73 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Compares 2 Strings and sends Events based on the result.")] + public class StringCompare : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + public FsmString compareTo; + public FsmEvent equalEvent; + public FsmEvent notEqualEvent; + [UIHint(UIHint.Variable)] + [Tooltip("Store the true/false result in a bool variable.")] + public FsmBool storeResult; + [Tooltip("Repeat every frame. Useful if any of the strings are changing over time.")] + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + compareTo = ""; + equalEvent = null; + notEqualEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoStringCompare(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoStringCompare(); + } + + void DoStringCompare() + { + if (stringVariable == null || compareTo == null) return; + + var equal = stringVariable.Value == compareTo.Value; + + if (storeResult != null) + { + storeResult.Value = equal; + } + + if (equal && equalEvent != null) + { + Fsm.Event(equalEvent); + return; + } + + if (!equal && notEqualEvent != null) + { + Fsm.Event(notEqualEvent); + } + + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StringCompare.cs.meta b/Assets/PlayMaker/Actions/StringCompare.cs.meta new file mode 100755 index 0000000..af1b46b --- /dev/null +++ b/Assets/PlayMaker/Actions/StringCompare.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2bc68b192ffe359498e74d0a626d6552 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StringContains.cs b/Assets/PlayMaker/Actions/StringContains.cs new file mode 100755 index 0000000..aa399c3 --- /dev/null +++ b/Assets/PlayMaker/Actions/StringContains.cs @@ -0,0 +1,78 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Tests if a String contains another String.")] + public class StringContains : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("The String variable to test.")] + public FsmString stringVariable; + [RequiredField] + [Tooltip("Test if the String variable contains this string.")] + public FsmString containsString; + [Tooltip("Event to send if true.")] + public FsmEvent trueEvent; + [Tooltip("Event to send if false.")] + public FsmEvent falseEvent; + [UIHint(UIHint.Variable)] + [Tooltip("Store the true/false result in a bool variable.")] + public FsmBool storeResult; + [Tooltip("Repeat every frame. Useful if any of the strings are changing over time.")] + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + containsString = ""; + trueEvent = null; + falseEvent = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoStringContains(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoStringContains(); + } + + void DoStringContains() + { + if (stringVariable.IsNone || containsString.IsNone) return; + + var contains = stringVariable.Value.Contains(containsString.Value); + + if (storeResult != null) + { + storeResult.Value = contains; + } + + if (contains && trueEvent != null) + { + Fsm.Event(trueEvent); + return; + } + + if (!contains && falseEvent != null) + { + Fsm.Event(falseEvent); + } + + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StringContains.cs.meta b/Assets/PlayMaker/Actions/StringContains.cs.meta new file mode 100755 index 0000000..cb97661 --- /dev/null +++ b/Assets/PlayMaker/Actions/StringContains.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29907e54ec98f8f40991caa82ab032b7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StringReplace.cs b/Assets/PlayMaker/Actions/StringReplace.cs new file mode 100755 index 0000000..721fd77 --- /dev/null +++ b/Assets/PlayMaker/Actions/StringReplace.cs @@ -0,0 +1,52 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.String)] + [Tooltip("Replace a substring with a new String.")] + public class StringReplace : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + public FsmString replace; + public FsmString with; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString storeResult; + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + replace = ""; + with = ""; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoReplace(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoReplace(); + } + + void DoReplace() + { + if (stringVariable == null) return; + if (storeResult == null) return; + + storeResult.Value = stringVariable.Value.Replace(replace.Value, with.Value); + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StringReplace.cs.meta b/Assets/PlayMaker/Actions/StringReplace.cs.meta new file mode 100755 index 0000000..93fbbbf --- /dev/null +++ b/Assets/PlayMaker/Actions/StringReplace.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 48b710fe4145c0e40a5576351fb00baa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/StringSwitch.cs b/Assets/PlayMaker/Actions/StringSwitch.cs new file mode 100755 index 0000000..7359d4f --- /dev/null +++ b/Assets/PlayMaker/Actions/StringSwitch.cs @@ -0,0 +1,55 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Logic)] + [Tooltip("Sends an Event based on the value of a String Variable.")] + public class StringSwitch : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmString stringVariable; + [CompoundArray("String Switches", "Compare String", "Send Event")] + public FsmString[] compareTo; + public FsmEvent[] sendEvent; + public bool everyFrame; + + public override void Reset() + { + stringVariable = null; + compareTo = new FsmString[1]; + sendEvent = new FsmEvent[1]; + everyFrame = false; + } + + public override void OnEnter() + { + DoStringSwitch(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoStringSwitch(); + } + + void DoStringSwitch() + { + if (stringVariable.IsNone) + return; + + for (int i = 0; i < compareTo.Length; i++) + { + if (stringVariable.Value == compareTo[i].Value) + { + Fsm.Event(sendEvent[i]); + return; + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/StringSwitch.cs.meta b/Assets/PlayMaker/Actions/StringSwitch.cs.meta new file mode 100755 index 0000000..ea3eca5 --- /dev/null +++ b/Assets/PlayMaker/Actions/StringSwitch.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 75c736ea0ec04004fbd1ec30b144f0cf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/SwipeGestureEvent.cs b/Assets/PlayMaker/Actions/SwipeGestureEvent.cs new file mode 100755 index 0000000..90e6553 --- /dev/null +++ b/Assets/PlayMaker/Actions/SwipeGestureEvent.cs @@ -0,0 +1,144 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + // TODO: fairly basic right now + // should have more options and be more robust, e.g., other fingers. + + [ActionCategory(ActionCategory.Device)] + [Tooltip("Sends an event when a swipe is detected.")] + public class SwipeGestureEvent : FsmStateAction + { + [Tooltip("How far a touch has to travel to be considered a swipe. Uses normalized distance (e.g. 1 = 1 screen diagonal distance). Should generally be a very small number.")] + public FsmFloat minSwipeDistance; + + [Tooltip("Event to send when swipe left detected.")] + public FsmEvent swipeLeftEvent; + [Tooltip("Event to send when swipe right detected.")] + public FsmEvent swipeRightEvent; + [Tooltip("Event to send when swipe up detected.")] + public FsmEvent swipeUpEvent; + [Tooltip("Event to send when swipe down detected.")] + public FsmEvent swipeDownEvent; + + // TODO +/* [UIHint(UIHint.Variable)] + [Tooltip("Store the speed of the swipe.")] + public FsmFloat getSpeed; + [UIHint(UIHint.Variable)] + [Tooltip("Store the distance the swipe traveled.")] + public FsmFloat getDistance;*/ + + float screenDiagonalSize; + float minSwipeDistancePixels; + bool touchStarted; + Vector2 touchStartPos; + //float touchStartTime; + + public override void Reset() + { + minSwipeDistance = 0.1f; + swipeLeftEvent = null; + swipeRightEvent = null; + swipeUpEvent = null; + swipeDownEvent = null; + } + + public override void OnEnter() + { + screenDiagonalSize = Mathf.Sqrt(Screen.width * Screen.width + Screen.height * Screen.height); + minSwipeDistancePixels = minSwipeDistance.Value * screenDiagonalSize; + } + + public override void OnUpdate() + { + if (Input.touchCount > 0) + { + var touch = Input.touches[0]; + + switch (touch.phase) + { + case TouchPhase.Began: + + touchStarted = true; + touchStartPos = touch.position; + //touchStartTime = FsmTime.RealtimeSinceStartup; + + break; + + case TouchPhase.Ended: + + if (touchStarted) + { + TestForSwipeGesture(touch); + touchStarted = false; + } + + break; + + case TouchPhase.Canceled: + + touchStarted = false; + + break; + + case TouchPhase.Stationary: + +/* if (touchStarted) + { + // don't want idle time to count towards swipe + + touchStartPos = touch.position; + touchStartTime = FsmTime.RealtimeSinceStartup; + }*/ + + break; + + case TouchPhase.Moved: + + break; + } + } + } + + void TestForSwipeGesture(Touch touch) + { + // test min distance + + var lastPos = touch.position; + var distance = Vector2.Distance(lastPos, touchStartPos); + + if (distance > minSwipeDistancePixels) + { + float dy = lastPos.y - touchStartPos.y; + float dx = lastPos.x - touchStartPos.x; + + float angle = Mathf.Rad2Deg * Mathf.Atan2(dx, dy); + + angle = (360 + angle - 45) % 360; + + Debug.Log (angle); + + if (angle < 90) + { + Fsm.Event(swipeRightEvent); + } + else if (angle < 180) + { + Fsm.Event(swipeDownEvent); + } + else if (angle < 270) + { + Fsm.Event(swipeLeftEvent); + } + else + { + Fsm.Event(swipeUpEvent); + } + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/SwipeGestureEvent.cs.meta b/Assets/PlayMaker/Actions/SwipeGestureEvent.cs.meta new file mode 100755 index 0000000..cff0a8f --- /dev/null +++ b/Assets/PlayMaker/Actions/SwipeGestureEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 66431494506220f4b84c08b4d259d7dc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TakeScreenshot.cs b/Assets/PlayMaker/Actions/TakeScreenshot.cs new file mode 100755 index 0000000..bbd4958 --- /dev/null +++ b/Assets/PlayMaker/Actions/TakeScreenshot.cs @@ -0,0 +1,51 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_FLASH || UNITY_METRO) + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Application)] + [Tooltip("Saves a Screenshot to the users MyPictures folder. TIP: Can be useful for automated testing and debugging.")] + public class TakeScreenshot : FsmStateAction + { + [RequiredField] + public FsmString filename; + public bool autoNumber; + + private int screenshotCount; + + public override void Reset() + { + filename = ""; + autoNumber = false; + } + + public override void OnEnter() + { + if (string.IsNullOrEmpty(filename.Value)) return; + + string screenshotPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)+"/"; + string screenshotFullPath = screenshotPath + filename.Value + ".png"; + + //Debug.Log(screenshotFullPath); + + if (autoNumber) + { + while (System.IO.File.Exists(screenshotFullPath)) + { + screenshotCount++; + screenshotFullPath = screenshotPath + filename.Value + screenshotCount + ".png"; + } + } + + Application.CaptureScreenshot(screenshotFullPath); + + Finish(); + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/TakeScreenshot.cs.meta b/Assets/PlayMaker/Actions/TakeScreenshot.cs.meta new file mode 100755 index 0000000..8c233cf --- /dev/null +++ b/Assets/PlayMaker/Actions/TakeScreenshot.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 09d6d60c2840eb643b61363529d70602 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TestAction.cs b/Assets/PlayMaker/Actions/TestAction.cs new file mode 100755 index 0000000..beb4153 --- /dev/null +++ b/Assets/PlayMaker/Actions/TestAction.cs @@ -0,0 +1,5 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +/* + * Accidentally checked in a test action. + * Checking in empty file since there's no way to delete files when importing unitypackage +*/ \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/TestAction.cs.meta b/Assets/PlayMaker/Actions/TestAction.cs.meta new file mode 100755 index 0000000..cff5ceb --- /dev/null +++ b/Assets/PlayMaker/Actions/TestAction.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5ed225774ad2d9c46aa2700d574a6c86 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TouchEvent.cs b/Assets/PlayMaker/Actions/TouchEvent.cs new file mode 100755 index 0000000..5e454ee --- /dev/null +++ b/Assets/PlayMaker/Actions/TouchEvent.cs @@ -0,0 +1,42 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Sends events based on Touch Phases. Optionally filter by a fingerID.")] + public class TouchEvent : FsmStateAction + { + public FsmInt fingerId; + public TouchPhase touchPhase; + public FsmEvent sendEvent; + [UIHint(UIHint.Variable)] + public FsmInt storeFingerId; + + public override void Reset() + { + fingerId = new FsmInt { UseVariable = true } ; + storeFingerId = null; + } + + public override void OnUpdate() + { + if (Input.touchCount > 0) + { + foreach (var touch in Input.touches) + { + + if (fingerId.IsNone || touch.fingerId == fingerId.Value) + { + if (touch.phase == touchPhase) + { + storeFingerId.Value = touch.fingerId; + Fsm.Event(sendEvent); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/TouchEvent.cs.meta b/Assets/PlayMaker/Actions/TouchEvent.cs.meta new file mode 100755 index 0000000..728fae6 --- /dev/null +++ b/Assets/PlayMaker/Actions/TouchEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 393d647b57c36af45b57947a4078b1ed +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TouchGUIEvent.cs b/Assets/PlayMaker/Actions/TouchGUIEvent.cs new file mode 100755 index 0000000..46221be --- /dev/null +++ b/Assets/PlayMaker/Actions/TouchGUIEvent.cs @@ -0,0 +1,251 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Sends events when a GUI Texture or GUI Text is touched. Optionally filter by a fingerID.")] + public class TouchGUIEvent : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(GUIElement))] + [Tooltip("The Game Object that owns the GUI Texture or GUI Text.")] + public FsmOwnerDefault gameObject; + + [Tooltip("Only detect touches that match this fingerID, or set to None.")] + public FsmInt fingerId; + + [ActionSection("Events")] + + [Tooltip("Event to send on touch began.")] + public FsmEvent touchBegan; + + [Tooltip("Event to send on touch moved.")] + public FsmEvent touchMoved; + + [Tooltip("Event to send on stationary touch.")] + public FsmEvent touchStationary; + + [Tooltip("Event to send on touch ended.")] + public FsmEvent touchEnded; + + [Tooltip("Event to send on touch cancel.")] + public FsmEvent touchCanceled; + + [Tooltip("Event to send if not touching (finger down but not over the GUI element)")] + public FsmEvent notTouching; + + [ActionSection("Store Results")] + + [UIHint(UIHint.Variable)] + [Tooltip("Store the fingerId of the touch.")] + public FsmInt storeFingerId; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the screen position where the GUI element was touched.")] + public FsmVector3 storeHitPoint; + + [Tooltip("Normalize the hit point screen coordinates (0-1).")] + public FsmBool normalizeHitPoint; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the offset position of the hit.")] + public FsmVector3 storeOffset; + + [Tooltip("How to measure the offset.")] + public OffsetOptions relativeTo; + + public enum OffsetOptions + { + TopLeft, + Center, + TouchStart + } + + [Tooltip("Normalize the offset.")] + public FsmBool normalizeOffset; + + [ActionSection("")] + + [Tooltip("Repeate every frame.")] + public bool everyFrame; + + // private work variables + + private Vector3 touchStartPos; + private GUIElement guiElement; + + public override void Reset() + { + gameObject = null; + fingerId = new FsmInt { UseVariable = true }; + + touchBegan = null; + touchMoved = null; + touchStationary = null; + touchEnded = null; + touchCanceled = null; + + storeFingerId = null; + storeHitPoint = null; + normalizeHitPoint = false; + storeOffset = null; + relativeTo = OffsetOptions.Center; + normalizeOffset = true; + + everyFrame = true; + } + + public override void OnEnter() + { + DoTouchGUIEvent(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoTouchGUIEvent(); + } + + void DoTouchGUIEvent() + { + if (Input.touchCount > 0) + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + guiElement = go.GetComponent() ?? (GUIElement) go.GetComponent(); + + if (guiElement == null) + { + return; + } + + foreach (var touch in Input.touches) + { + DoTouch(touch); + } + } + } + + void DoTouch(Touch touch) + { + // Filter by finger ID + + if (fingerId.IsNone || touch.fingerId == fingerId.Value) + { + // Get the screen position of the touch + + Vector3 touchPos = touch.position; + + // Is touchPos inside the guiElement's rect + + if (guiElement.HitTest(touchPos)) + { + // First touch? + + if (touch.phase == TouchPhase.Began) + { + touchStartPos = touchPos; + } + + // Store results + + storeFingerId.Value = touch.fingerId; + + if (normalizeHitPoint.Value) + { + touchPos.x /= Screen.width; + touchPos.y /= Screen.height; + } + + storeHitPoint.Value = touchPos; + + // Store touch offset + + DoTouchOffset(touchPos); + + // Send Events + + switch (touch.phase) + { + case TouchPhase.Began: + Fsm.Event(touchBegan); + return; + + case TouchPhase.Moved: + Fsm.Event(touchMoved); + return; + + case TouchPhase.Stationary: + Fsm.Event(touchStationary); + return; + + case TouchPhase.Ended: + Fsm.Event(touchEnded); + return; + + case TouchPhase.Canceled: + Fsm.Event(touchCanceled); + return; + } + } + else + { + Fsm.Event(notTouching); + } + } + } + + void DoTouchOffset(Vector3 touchPos) + { + if (storeOffset.IsNone) + { + return; + } + + var guiRect = guiElement.GetScreenRect(); + var offset = new Vector3(); + + switch (relativeTo) + { + case OffsetOptions.TopLeft: + + offset.x = touchPos.x - guiRect.x; + offset.y = touchPos.y - guiRect.y; + + break; + + case OffsetOptions.Center: + + var center = new Vector3(guiRect.x + guiRect.width * 0.5f, guiRect.y + guiRect.height * 0.5f, 0); + offset = touchPos - center; + + break; + + case OffsetOptions.TouchStart: + + offset = touchPos - touchStartPos; + + break; + } + + if (normalizeOffset.Value) + { + offset.x /= guiRect.width; + offset.y /= guiRect.height; + } + + storeOffset.Value = offset; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/TouchGUIEvent.cs.meta b/Assets/PlayMaker/Actions/TouchGUIEvent.cs.meta new file mode 100755 index 0000000..7cde12c --- /dev/null +++ b/Assets/PlayMaker/Actions/TouchGUIEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 31371b1c65846cd49ab0207915507fd8 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TouchObjectEvent.cs b/Assets/PlayMaker/Actions/TouchObjectEvent.cs new file mode 100755 index 0000000..7f8e741 --- /dev/null +++ b/Assets/PlayMaker/Actions/TouchObjectEvent.cs @@ -0,0 +1,139 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Device)] + [Tooltip("Sends events when an object is touched. Optionally filter by a fingerID. NOTE: Uses the MainCamera!")] + public class TouchObjectEvent : FsmStateAction + { + [RequiredField] + [CheckForComponent(typeof(Collider))] + [Tooltip("The Game Object to detect touches on.")] + public FsmOwnerDefault gameObject; + + [RequiredField] + [Tooltip("How far from the camera is the Game Object pickable.")] + public FsmFloat pickDistance; + + [Tooltip("Only detect touches that match this fingerID, or set to None.")] + public FsmInt fingerId; + + [ActionSection("Events")] + + [Tooltip("Event to send on touch began.")] + public FsmEvent touchBegan; + + [Tooltip("Event to send on touch moved.")] + public FsmEvent touchMoved; + + [Tooltip("Event to send on stationary touch.")] + public FsmEvent touchStationary; + + [Tooltip("Event to send on touch ended.")] + public FsmEvent touchEnded; + + [Tooltip("Event to send on touch cancel.")] + public FsmEvent touchCanceled; + + [ActionSection("Store Results")] + + [UIHint(UIHint.Variable)] + [Tooltip("Store the fingerId of the touch.")] + public FsmInt storeFingerId; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the world position where the object was touched.")] + public FsmVector3 storeHitPoint; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the surface normal vector where the object was touched.")] + public FsmVector3 storeHitNormal; + + public override void Reset() + { + gameObject = null; + pickDistance = 100; + fingerId = new FsmInt { UseVariable = true }; + + touchBegan = null; + touchMoved = null; + touchStationary = null; + touchEnded = null; + touchCanceled = null; + + storeFingerId = null; + storeHitPoint = null; + storeHitNormal = null; + } + + public override void OnUpdate() + { + if (Camera.main == null) + { + LogError("No MainCamera defined!"); + Finish(); + return; + } + + if (Input.touchCount > 0) + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + foreach (var touch in Input.touches) + { + if (fingerId.IsNone || touch.fingerId == fingerId.Value) + { + var screenPos = touch.position; + + RaycastHit hitInfo; + Physics.Raycast(Camera.main.ScreenPointToRay(screenPos), out hitInfo, pickDistance.Value); + + // Store hitInfo so it can be accessed by other actions + // E.g., Get Raycast Hit Info + Fsm.RaycastHitInfo = hitInfo; + + if (hitInfo.transform != null) + { + if (hitInfo.transform.gameObject == go) + { + storeFingerId.Value = touch.fingerId; + storeHitPoint.Value = hitInfo.point; + storeHitNormal.Value = hitInfo.normal; + + switch (touch.phase) + { + case TouchPhase.Began: + Fsm.Event(touchBegan); + return; + + case TouchPhase.Moved: + Fsm.Event(touchMoved); + return; + + case TouchPhase.Stationary: + Fsm.Event(touchStationary); + return; + + case TouchPhase.Ended: + Fsm.Event(touchEnded); + return; + + case TouchPhase.Canceled: + Fsm.Event(touchCanceled); + return; + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/TouchObjectEvent.cs.meta b/Assets/PlayMaker/Actions/TouchObjectEvent.cs.meta new file mode 100755 index 0000000..d1bec71 --- /dev/null +++ b/Assets/PlayMaker/Actions/TouchObjectEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 68b93ab07745712458231ad1ded58d0e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TrackMouseMovement.cs b/Assets/PlayMaker/Actions/TrackMouseMovement.cs new file mode 100755 index 0000000..b7cf085 --- /dev/null +++ b/Assets/PlayMaker/Actions/TrackMouseMovement.cs @@ -0,0 +1,19 @@ +using UnityEngine; +using System.Collections; + +public class TrackMouseMovement : MonoBehaviour +{ + + // Use this for initialization + void Start () + { + + } + + // Update is called once per frame + void Update () + { + + } +} + diff --git a/Assets/PlayMaker/Actions/TrackMouseMovement.cs.meta b/Assets/PlayMaker/Actions/TrackMouseMovement.cs.meta new file mode 100755 index 0000000..be0ad3c --- /dev/null +++ b/Assets/PlayMaker/Actions/TrackMouseMovement.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 55b0c3b9e1ea5934786c70769cb8f160 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TransformDirection.cs b/Assets/PlayMaker/Actions/TransformDirection.cs new file mode 100755 index 0000000..ee67561 --- /dev/null +++ b/Assets/PlayMaker/Actions/TransformDirection.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Transforms a Direction from a Game Object's local space to world space.")] + public class TransformDirection : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmVector3 localDirection; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 storeResult; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + localDirection = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoTransformDirection(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoTransformDirection(); + } + + void DoTransformDirection() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if(go == null) return; + + storeResult.Value = go.transform.TransformDirection(localDirection.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/TransformDirection.cs.meta b/Assets/PlayMaker/Actions/TransformDirection.cs.meta new file mode 100755 index 0000000..ba44eb9 --- /dev/null +++ b/Assets/PlayMaker/Actions/TransformDirection.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ead0acdc4792b3d43b8608902c1298f6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TransformInputToWorldSpace.cs b/Assets/PlayMaker/Actions/TransformInputToWorldSpace.cs new file mode 100755 index 0000000..75aacfd --- /dev/null +++ b/Assets/PlayMaker/Actions/TransformInputToWorldSpace.cs @@ -0,0 +1,128 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Input)] + [Tooltip("Transforms 2d input into a 3d world space vector. E.g., can be used to transform input from a touch joystick to a movement vector.")] + public class TransformInputToWorldSpace : FsmStateAction + { + public enum AxisPlane + { + XZ, + XY, + YZ + } + + [UIHint(UIHint.Variable)] + [Tooltip("The horizontal input.")] + public FsmFloat horizontalInput; + + [UIHint(UIHint.Variable)] + [Tooltip("The vertical input.")] + public FsmFloat verticalInput; + + [Tooltip("Input axis are reported in the range -1 to 1, this multiplier lets you set a new range.")] + public FsmFloat multiplier; + + [RequiredField] + [Tooltip("The world plane to map the 2d input onto.")] + public AxisPlane mapToPlane; + + [Tooltip("Make the result relative to a GameObject, typically the main camera.")] + public FsmGameObject relativeTo; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the direction vector.")] + public FsmVector3 storeVector; + + [UIHint(UIHint.Variable)] + [Tooltip("Store the length of the direction vector.")] + public FsmFloat storeMagnitude; + + public override void Reset() + { + horizontalInput = null; + verticalInput = null; + multiplier = 1.0f; + mapToPlane = AxisPlane.XZ; + storeVector = null; + storeMagnitude = null; + } + + public override void OnUpdate() + { + var forward = new Vector3(); + var right = new Vector3(); + + if (relativeTo.Value == null) + { + switch (mapToPlane) + { + case AxisPlane.XZ: + forward = Vector3.forward; + right = Vector3.right; + break; + + case AxisPlane.XY: + forward = Vector3.up; + right = Vector3.right; + break; + + case AxisPlane.YZ: + forward = Vector3.up; + right = Vector3.forward; + break; + } + } + else + { + var transform = relativeTo.Value.transform; + + switch (mapToPlane) + { + case AxisPlane.XZ: + forward = transform.TransformDirection(Vector3.forward); + forward.y = 0; + forward = forward.normalized; + right = new Vector3(forward.z, 0, -forward.x); + break; + + case AxisPlane.XY: + case AxisPlane.YZ: + // NOTE: in relative mode XY ans YZ are the same! + forward = Vector3.up; + forward.z = 0; + forward = forward.normalized; + right = transform.TransformDirection(Vector3.right); + break; + } + + // Right vector relative to the object + // Always orthogonal to the forward vector + + } + + // get individual axis + // leaving an axis blank or set to None sets it to 0 + + var h = horizontalInput.IsNone ? 0f : horizontalInput.Value; + var v = verticalInput.IsNone ? 0f : verticalInput.Value; + + // calculate resulting direction vector + + var direction = h * right + v * forward; + direction *= multiplier.Value; + + storeVector.Value = direction; + + if (!storeMagnitude.IsNone) + { + storeMagnitude.Value = direction.magnitude; + } + } + } +} + diff --git a/Assets/PlayMaker/Actions/TransformInputToWorldSpace.cs.meta b/Assets/PlayMaker/Actions/TransformInputToWorldSpace.cs.meta new file mode 100755 index 0000000..c24632e --- /dev/null +++ b/Assets/PlayMaker/Actions/TransformInputToWorldSpace.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0922bb5e3097a7948a84b189b86dcb65 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TransformPoint.cs b/Assets/PlayMaker/Actions/TransformPoint.cs new file mode 100755 index 0000000..98334b6 --- /dev/null +++ b/Assets/PlayMaker/Actions/TransformPoint.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Transforms a Position from a Game Object's local space to world space.")] + public class TransformPoint : FsmStateAction + { + [RequiredField] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmVector3 localPosition; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 storeResult; + public bool everyFrame; + + public override void Reset() + { + gameObject = null; + localPosition = null; + storeResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoTransformPoint(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoTransformPoint(); + } + + void DoTransformPoint() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if(go == null) return; + + storeResult.Value = go.transform.TransformPoint(localPosition.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/TransformPoint.cs.meta b/Assets/PlayMaker/Actions/TransformPoint.cs.meta new file mode 100755 index 0000000..6e97c89 --- /dev/null +++ b/Assets/PlayMaker/Actions/TransformPoint.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bc14805ab1b72f74a91e1f9e58ca6a91 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Translate.cs b/Assets/PlayMaker/Actions/Translate.cs new file mode 100755 index 0000000..6ada4c3 --- /dev/null +++ b/Assets/PlayMaker/Actions/Translate.cs @@ -0,0 +1,139 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Transform)] + [Tooltip("Translates a Game Object. Use a Vector3 variable and/or XYZ components. To leave any axis unchanged, set variable to 'None'.")] + public class Translate : FsmStateAction + { + [RequiredField] + [Tooltip("The game object to translate.")] + public FsmOwnerDefault gameObject; + + [UIHint(UIHint.Variable)] + [Tooltip("A translation vector. NOTE: You can override individual axis below.")] + public FsmVector3 vector; + + [Tooltip("Translation along x axis.")] + public FsmFloat x; + + [Tooltip("Translation along y axis.")] + public FsmFloat y; + + [Tooltip("Translation along z axis.")] + public FsmFloat z; + + [Tooltip("Translate in local or world space.")] + public Space space; + + [Tooltip("Translate over one second")] + public bool perSecond; + + [Tooltip("Repeat every frame.")] + public bool everyFrame; + + [Tooltip("Perform the translate in LateUpdate. This is useful if you want to override the position of objects that are animated or otherwise positioned in Update.")] + public bool lateUpdate; + + [Tooltip("Perform the translate in FixedUpdate. This is useful when working with rigid bodies and physics.")] + public bool fixedUpdate; + + public override void Reset() + { + gameObject = null; + vector = null; + // default axis to variable dropdown with None selected. + x = new FsmFloat { UseVariable = true }; + y = new FsmFloat { UseVariable = true }; + z = new FsmFloat { UseVariable = true }; + space = Space.Self; + perSecond = true; + everyFrame = true; + lateUpdate = false; + fixedUpdate = false; + } + + public override void OnPreprocess() + { + Fsm.HandleFixedUpdate = true; + } + + public override void OnEnter() + { + if (!everyFrame && !lateUpdate && !fixedUpdate) + { + DoTranslate(); + Finish(); + } + } + + public override void OnUpdate() + { + if (!lateUpdate && !fixedUpdate) + { + DoTranslate(); + } + } + + public override void OnLateUpdate() + { + if (lateUpdate) + { + DoTranslate(); + } + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnFixedUpdate() + { + if (fixedUpdate) + { + DoTranslate(); + } + + if (!everyFrame) + { + Finish(); + } + } + + void DoTranslate() + { + // init + + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (go == null) + { + return; + } + + // Use vector if specified + + var translate = vector.IsNone ? new Vector3(x.Value, y.Value, z.Value) : vector.Value; + + // override any axis + + if (!x.IsNone) translate.x = x.Value; + if (!y.IsNone) translate.y = y.Value; + if (!z.IsNone) translate.z = z.Value; + + // apply + + if (!perSecond) + { + go.transform.Translate(translate, space); + } + else + { + go.transform.Translate(translate * Time.deltaTime, space); + } + } + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Translate.cs.meta b/Assets/PlayMaker/Actions/Translate.cs.meta new file mode 100755 index 0000000..15206b2 --- /dev/null +++ b/Assets/PlayMaker/Actions/Translate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 64964a3148c610e4ba0de21b424e6169 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/TriggerEvent.cs b/Assets/PlayMaker/Actions/TriggerEvent.cs new file mode 100755 index 0000000..08a8636 --- /dev/null +++ b/Assets/PlayMaker/Actions/TriggerEvent.cs @@ -0,0 +1,91 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System; +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Detect collisions with objects that have RigidBody components. \nNOTE: The system events, TRIGGER ENTER, TRIGGER STAY, and TRIGGER EXIT are sent when any object collides with the trigger. Use this action to filter collisions by Tag.")] + public class TriggerEvent : FsmStateAction + { + public TriggerType trigger; + [UIHint(UIHint.Tag)] + public FsmString collideTag; + public FsmEvent sendEvent; + [UIHint(UIHint.Variable)] + public FsmGameObject storeCollider; + + public override void Reset() + { + trigger = TriggerType.OnTriggerEnter; + collideTag = "Untagged"; + sendEvent = null; + storeCollider = null; + } + + public override void OnPreprocess() + { + switch (trigger) + { + case TriggerType.OnTriggerEnter: + Fsm.HandleTriggerEnter = true; + break; + case TriggerType.OnTriggerStay: + Fsm.HandleTriggerStay = true; + break; + case TriggerType.OnTriggerExit: + Fsm.HandleTriggerExit = true; + break; + } + } + + void StoreCollisionInfo(Collider collisionInfo) + { + storeCollider.Value = collisionInfo.gameObject; + } + + public override void DoTriggerEnter(Collider other) + { + if (trigger == TriggerType.OnTriggerEnter) + { + if (other.gameObject.tag == collideTag.Value) + { + StoreCollisionInfo(other); + Fsm.Event(sendEvent); + } + } + } + + public override void DoTriggerStay(Collider other) + { + if (trigger == TriggerType.OnTriggerStay) + { + if (other.gameObject.tag == collideTag.Value) + { + StoreCollisionInfo(other); + Fsm.Event(sendEvent); + } + } + } + + public override void DoTriggerExit(Collider other) + { + if (trigger == TriggerType.OnTriggerExit) + { + if (other.gameObject.tag == collideTag.Value) + { + StoreCollisionInfo(other); + Fsm.Event(sendEvent); + } + } + } + + public override string ErrorCheck() + { + return ActionHelpers.CheckOwnerPhysicsSetup(Owner); + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/TriggerEvent.cs.meta b/Assets/PlayMaker/Actions/TriggerEvent.cs.meta new file mode 100755 index 0000000..9399922 --- /dev/null +++ b/Assets/PlayMaker/Actions/TriggerEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f9b2aeda5f6da8e449f7450fcb104bfd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/UseGUILayout.cs b/Assets/PlayMaker/Actions/UseGUILayout.cs new file mode 100755 index 0000000..5b2b4ce --- /dev/null +++ b/Assets/PlayMaker/Actions/UseGUILayout.cs @@ -0,0 +1,25 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.GUILayout)] + [Tooltip("Turn GUILayout on/off. If you don't use GUILayout actions you can get some performace back by turning GUILayout off. This can make a difference on iOS platforms.")] + public class UseGUILayout : FsmStateAction + { + [RequiredField] + public bool turnOffGUIlayout; + + public override void Reset() + { + turnOffGUIlayout = true; + } + + public override void OnEnter() + { + Fsm.Owner.useGUILayout = !turnOffGUIlayout; + Finish(); + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/UseGUILayout.cs.meta b/Assets/PlayMaker/Actions/UseGUILayout.cs.meta new file mode 100755 index 0000000..694f5f2 --- /dev/null +++ b/Assets/PlayMaker/Actions/UseGUILayout.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 087d873552a49ee4f9ba2751ce142cf0 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/UseGravity.cs b/Assets/PlayMaker/Actions/UseGravity.cs new file mode 100755 index 0000000..ed14431 --- /dev/null +++ b/Assets/PlayMaker/Actions/UseGravity.cs @@ -0,0 +1,38 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Sets whether a Game Object's Rigidy Body is affected by Gravity.")] + public class UseGravity : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + [RequiredField] + public FsmBool useGravity; + + public override void Reset() + { + gameObject = null; + useGravity = true; + } + + public override void OnEnter() + { + DoUseGravity(); + Finish(); + } + + void DoUseGravity() + { + var go = Fsm.GetOwnerDefaultTarget(gameObject); + if (UpdateCache(go)) + { + rigidbody.useGravity = useGravity.Value; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/UseGravity.cs.meta b/Assets/PlayMaker/Actions/UseGravity.cs.meta new file mode 100755 index 0000000..176bee2 --- /dev/null +++ b/Assets/PlayMaker/Actions/UseGravity.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3c5807ddf1f36fe4ea8d1a60993eef7a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3Add.cs b/Assets/PlayMaker/Actions/Vector3Add.cs new file mode 100755 index 0000000..d1bbfa3 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Add.cs @@ -0,0 +1,50 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Adds a value to Vector3 Variable.")] + public class Vector3Add : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + [RequiredField] + public FsmVector3 addVector; + public bool everyFrame; + public bool perSecond; + + public override void Reset() + { + vector3Variable = null; + addVector = new FsmVector3 { UseVariable = true }; + everyFrame = false; + perSecond = false; + } + + public override void OnEnter() + { + DoVector3Add(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoVector3Add(); + } + + void DoVector3Add() + { + if(perSecond) + vector3Variable.Value = vector3Variable.Value + addVector.Value * Time.deltaTime; + else + vector3Variable.Value = vector3Variable.Value + addVector.Value; + + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3Add.cs.meta b/Assets/PlayMaker/Actions/Vector3Add.cs.meta new file mode 100755 index 0000000..2281293 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Add.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6a6160d3d3082a444b0f832be8f920b3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3AddXYZ.cs b/Assets/PlayMaker/Actions/Vector3AddXYZ.cs new file mode 100755 index 0000000..7d32a1e --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3AddXYZ.cs @@ -0,0 +1,59 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Adds a XYZ values to Vector3 Variable.")] + public class Vector3AddXYZ : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + public FsmFloat addX; + public FsmFloat addY; + public FsmFloat addZ; + public bool everyFrame; + public bool perSecond; + + public override void Reset() + { + vector3Variable = null; + addX = 0; + addY = 0; + addZ = 0; + everyFrame = false; + perSecond = false; + } + + public override void OnEnter() + { + DoVector3AddXYZ(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoVector3AddXYZ(); + } + + void DoVector3AddXYZ() + { + var vector = new Vector3(addX.Value, addY.Value, addZ.Value); + + if(perSecond) + { + vector3Variable.Value += vector * Time.deltaTime; + } + else + { + vector3Variable.Value += vector; + } + + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3AddXYZ.cs.meta b/Assets/PlayMaker/Actions/Vector3AddXYZ.cs.meta new file mode 100755 index 0000000..e9be34a --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3AddXYZ.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 04a3c6d4bfd04f3409f9b822241251bc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3ClampMagnitude.cs b/Assets/PlayMaker/Actions/Vector3ClampMagnitude.cs new file mode 100755 index 0000000..c05b52a --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3ClampMagnitude.cs @@ -0,0 +1,44 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Clamps the Magnitude of Vector3 Variable.")] + public class Vector3ClampMagnitude : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + [RequiredField] + public FsmFloat maxLength; + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + maxLength = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoVector3ClampMagnitude(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoVector3ClampMagnitude(); + } + + void DoVector3ClampMagnitude() + { + vector3Variable.Value = Vector3.ClampMagnitude(vector3Variable.Value, maxLength.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3ClampMagnitude.cs.meta b/Assets/PlayMaker/Actions/Vector3ClampMagnitude.cs.meta new file mode 100755 index 0000000..8ad858d --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3ClampMagnitude.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: efb9a13258c70b04f901aa1501f3a5b7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3HighPassFilter.cs b/Assets/PlayMaker/Actions/Vector3HighPassFilter.cs new file mode 100755 index 0000000..c820a5d --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3HighPassFilter.cs @@ -0,0 +1,43 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Use a high pass filter to isolate sudden changes in a Vector3 Variable. Useful when working with Get Device Acceleration to remove the constant effect of gravity.")] + public class Vector3HighPassFilter : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Vector3 Variable to filter. Should generally come from some constantly updated input, e.g., acceleration.")] + public FsmVector3 vector3Variable; + [Tooltip("Determines how much influence new changes have.")] + public FsmFloat filteringFactor; + + Vector3 filteredVector; + + public override void Reset() + { + vector3Variable = null; + filteringFactor = 0.1f; + } + + public override void OnEnter() + { + filteredVector = new Vector3(vector3Variable.Value.x, vector3Variable.Value.y, vector3Variable.Value.z); + } + + public override void OnUpdate() + { + // Subtract the low-pass value from the current value to get a simplified high-pass filter + + filteredVector.x = vector3Variable.Value.x - ( (vector3Variable.Value.x * filteringFactor.Value) + (filteredVector.x * (1.0f - filteringFactor.Value)) ); + filteredVector.y = vector3Variable.Value.y - ( (vector3Variable.Value.y * filteringFactor.Value) + (filteredVector.y * (1.0f - filteringFactor.Value)) ); + filteredVector.z = vector3Variable.Value.z - ( (vector3Variable.Value.z * filteringFactor.Value) + (filteredVector.z * (1.0f - filteringFactor.Value)) ); + + vector3Variable.Value = new Vector3(filteredVector.x, filteredVector.y, filteredVector.z); + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3HighPassFilter.cs.meta b/Assets/PlayMaker/Actions/Vector3HighPassFilter.cs.meta new file mode 100755 index 0000000..fcc07bb --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3HighPassFilter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ffd5472b9aee11747aed59bf927525bd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3Interpolate.cs b/Assets/PlayMaker/Actions/Vector3Interpolate.cs new file mode 100755 index 0000000..4e5fe0a --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Interpolate.cs @@ -0,0 +1,88 @@ +// (c) Copyright HutongGames, LLC 2010-2015. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Interpolates between 2 Vector3 values over a specified Time.")] + public class Vector3Interpolate : FsmStateAction + { + public InterpolationType mode; + [RequiredField] + public FsmVector3 fromVector; + [RequiredField] + public FsmVector3 toVector; + [RequiredField] + public FsmFloat time; + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 storeResult; + public FsmEvent finishEvent; + [Tooltip("Ignore TimeScale")] + public bool realTime; + + private float startTime; + private float currentTime; + + public override void Reset() + { + mode = InterpolationType.Linear; + fromVector = new FsmVector3 { UseVariable = true }; + toVector = new FsmVector3 { UseVariable = true }; + time = 1.0f; + storeResult = null; + finishEvent = null; + realTime = false; + } + + public override void OnEnter() + { + startTime = FsmTime.RealtimeSinceStartup; + currentTime = 0f; + + if (storeResult == null) + Finish(); + else + storeResult.Value = fromVector.Value; + } + + public override void OnUpdate() + { + // update time + + if (realTime) + { + currentTime = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + currentTime += Time.deltaTime; + } + + float weight = currentTime/time.Value; + + switch (mode) { + + case InterpolationType.Linear: + break; + + case InterpolationType.EaseInOut: + weight = Mathf.SmoothStep(0, 1, weight); + break; + } + + storeResult.Value = Vector3.Lerp(fromVector.Value, toVector.Value, weight); + + if (weight >= 1) + { + if (finishEvent != null) + Fsm.Event(finishEvent); + + Finish(); + } + + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3Interpolate.cs.meta b/Assets/PlayMaker/Actions/Vector3Interpolate.cs.meta new file mode 100755 index 0000000..c71ca13 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Interpolate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f89b9214e3b15c540a096bd4ba7e22d9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3Invert.cs b/Assets/PlayMaker/Actions/Vector3Invert.cs new file mode 100755 index 0000000..72e2398 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Invert.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Reverses the direction of a Vector3 Variable. Same as multiplying by -1.")] + public class Vector3Invert : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + everyFrame = false; + } + + public override void OnEnter() + { + vector3Variable.Value = vector3Variable.Value * -1; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + vector3Variable.Value = vector3Variable.Value * -1; + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3Invert.cs.meta b/Assets/PlayMaker/Actions/Vector3Invert.cs.meta new file mode 100755 index 0000000..0d29799 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Invert.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 160c9235249d02249ae944e0b2523e69 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3Lerp.cs b/Assets/PlayMaker/Actions/Vector3Lerp.cs new file mode 100755 index 0000000..fe4949f --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Lerp.cs @@ -0,0 +1,60 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Linearly interpolates between 2 vectors.")] + public class Vector3Lerp : FsmStateAction + { + [RequiredField] + [Tooltip("First Vector.")] + public FsmVector3 fromVector; + + [RequiredField] + [Tooltip("Second Vector.")] + public FsmVector3 toVector; + + [RequiredField] + [Tooltip("Interpolate between From Vector and ToVector by this amount. Value is clamped to 0-1 range. 0 = From Vector; 1 = To Vector; 0.5 = half way between.")] + public FsmFloat amount; + + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Store the result in this vector variable.")] + public FsmVector3 storeResult; + + [Tooltip("Repeat every frame. Useful if any of the values are changing.")] + public bool everyFrame; + + public override void Reset() + { + fromVector = new FsmVector3 { UseVariable = true }; + toVector = new FsmVector3 { UseVariable = true }; + storeResult = null; + everyFrame = true; + } + + public override void OnEnter() + { + DoVector3Lerp(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoVector3Lerp(); + } + + void DoVector3Lerp() + { + storeResult.Value = Vector3.Lerp(fromVector.Value, toVector.Value, amount.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3Lerp.cs.meta b/Assets/PlayMaker/Actions/Vector3Lerp.cs.meta new file mode 100755 index 0000000..007a35c --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Lerp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4e8abfcbb5b772d44b446227d460eaf4 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3LowPassFilter.cs b/Assets/PlayMaker/Actions/Vector3LowPassFilter.cs new file mode 100755 index 0000000..7db9df1 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3LowPassFilter.cs @@ -0,0 +1,41 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Use a low pass filter to reduce the influence of sudden changes in a Vector3 Variable. Useful when working with Get Device Acceleration to isolate gravity.")] + public class Vector3LowPassFilter : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + [Tooltip("Vector3 Variable to filter. Should generally come from some constantly updated input, e.g., acceleration.")] + public FsmVector3 vector3Variable; + [Tooltip("Determines how much influence new changes have. E.g., 0.1 keeps 10 percent of the unfiltered vector and 90 percent of the previously filtered value.")] + public FsmFloat filteringFactor; + + Vector3 filteredVector; + + public override void Reset() + { + vector3Variable = null; + filteringFactor = 0.1f; + } + + public override void OnEnter() + { + filteredVector = new Vector3(vector3Variable.Value.x, vector3Variable.Value.y, vector3Variable.Value.z); + } + + public override void OnUpdate() + { + filteredVector.x = (vector3Variable.Value.x * filteringFactor.Value) + (filteredVector.x * (1.0f - filteringFactor.Value)); + filteredVector.y = (vector3Variable.Value.y * filteringFactor.Value) + (filteredVector.y * (1.0f - filteringFactor.Value)); + filteredVector.z = (vector3Variable.Value.z * filteringFactor.Value) + (filteredVector.z * (1.0f - filteringFactor.Value)); + + vector3Variable.Value = new Vector3(filteredVector.x, filteredVector.y, filteredVector.z); + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3LowPassFilter.cs.meta b/Assets/PlayMaker/Actions/Vector3LowPassFilter.cs.meta new file mode 100755 index 0000000..5155ba5 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3LowPassFilter.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8ef747ac52d7649469f8439c04b0d61b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3Multiply.cs b/Assets/PlayMaker/Actions/Vector3Multiply.cs new file mode 100755 index 0000000..9935919 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Multiply.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Multiplies a Vector3 variable by a Float.")] + public class Vector3Multiply : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + [RequiredField] + public FsmFloat multiplyBy; + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + multiplyBy = 1; + everyFrame = false; + } + + public override void OnEnter() + { + vector3Variable.Value = vector3Variable.Value * multiplyBy.Value; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + vector3Variable.Value = vector3Variable.Value * multiplyBy.Value; + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3Multiply.cs.meta b/Assets/PlayMaker/Actions/Vector3Multiply.cs.meta new file mode 100755 index 0000000..7f56903 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Multiply.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7fd6a420792cc5a46bbef572ddbf89ca +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3Normalize.cs b/Assets/PlayMaker/Actions/Vector3Normalize.cs new file mode 100755 index 0000000..2560858 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Normalize.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. +// BUG FIX: http://hutonggames.com/playmakerforum/index.php?topic=476.0;topicseen + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Normalizes a Vector3 Variable.")] + public class Vector3Normalize : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + everyFrame = false; + } + + public override void OnEnter() + { + vector3Variable.Value = vector3Variable.Value.normalized; + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + vector3Variable.Value = vector3Variable.Value.normalized; + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3Normalize.cs.meta b/Assets/PlayMaker/Actions/Vector3Normalize.cs.meta new file mode 100755 index 0000000..49ed201 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Normalize.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 870da0581c75fe744a3a742d7620ff1a +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3Operator.cs b/Assets/PlayMaker/Actions/Vector3Operator.cs new file mode 100755 index 0000000..4e85a64 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Operator.cs @@ -0,0 +1,134 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Performs most possible operations on 2 Vector3: Dot product, Cross product, Distance, Angle, Project, Reflect, Add, Subtract, Multiply, Divide, Min, Max")] + public class Vector3Operator : FsmStateAction + { + public enum Vector3Operation + { + DotProduct, + CrossProduct, + Distance, + Angle, + Project, + Reflect, + Add, + Subtract, + Multiply, + Divide, + Min, + Max + } + + [RequiredField] + public FsmVector3 vector1; + [RequiredField] + public FsmVector3 vector2; + public Vector3Operation operation = Vector3Operation.Add; + + [UIHint(UIHint.Variable)] + public FsmVector3 storeVector3Result; + + [UIHint(UIHint.Variable)] + public FsmFloat storeFloatResult; + + public bool everyFrame; + + public override void Reset() + { + vector1 = null; + vector2 = null; + operation = Vector3Operation.Add; + storeVector3Result = null; + storeFloatResult = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoVector3Operator(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoVector3Operator(); + } + + void DoVector3Operator() + { + var v1 = vector1.Value; + var v2 = vector2.Value; + + switch (operation) + { + case Vector3Operation.DotProduct: + storeFloatResult.Value = Vector3.Dot(v1, v2); + break; + + case Vector3Operation.CrossProduct: + storeVector3Result.Value = Vector3.Cross(v1, v2); + break; + + case Vector3Operation.Distance: + storeFloatResult.Value = Vector3.Distance(v1, v2); + break; + + case Vector3Operation.Angle: + storeFloatResult.Value = Vector3.Angle(v1, v2); + break; + + case Vector3Operation.Project: + storeVector3Result.Value = Vector3.Project(v1, v2); + break; + + case Vector3Operation.Reflect: + storeVector3Result.Value = Vector3.Reflect(v1, v2); + break; + + case Vector3Operation.Add: + storeVector3Result.Value = v1 + v2; + break; + + case Vector3Operation.Subtract: + storeVector3Result.Value = v1 - v2; + break; + + case Vector3Operation.Multiply: + // I know... this is a far reach and not usefull in 99% of cases. + // I do use it when I use vector3 as arrays recipients holding something else than a position in space. + var multResult = Vector3.zero; + multResult.x = v1.x * v2.x; + multResult.y = v1.y * v2.y; + multResult.z = v1.z * v2.z; + storeVector3Result.Value = multResult; + break; + + case Vector3Operation.Divide: // I know... this is a far reach and not usefull in 99% of cases. + // I do use it when I use vector3 as arrays recipients holding something else than a position in space. + var divResult = Vector3.zero; + divResult.x = v1.x / v2.x; + divResult.y = v1.y / v2.y; + divResult.z = v1.z / v2.z; + storeVector3Result.Value = divResult; + break; + + case Vector3Operation.Min: + storeVector3Result.Value = Vector3.Min(v1, v2); + break; + + case Vector3Operation.Max: + storeVector3Result.Value = Vector3.Max(v1, v2); + break; + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/Vector3Operator.cs.meta b/Assets/PlayMaker/Actions/Vector3Operator.cs.meta new file mode 100755 index 0000000..dabe1d8 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Operator.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b6b59c57607a5fb4f962de7dee5388cf +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3PerSecond.cs b/Assets/PlayMaker/Actions/Vector3PerSecond.cs new file mode 100755 index 0000000..f5b75f5 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3PerSecond.cs @@ -0,0 +1,36 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Multiplies a Vector3 variable by Time.deltaTime. Useful for frame rate independent motion.")] + public class Vector3PerSecond : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + everyFrame = false; + } + + public override void OnEnter() + { + vector3Variable.Value = vector3Variable.Value * Time.deltaTime; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + vector3Variable.Value = vector3Variable.Value * Time.deltaTime; + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3PerSecond.cs.meta b/Assets/PlayMaker/Actions/Vector3PerSecond.cs.meta new file mode 100755 index 0000000..2bf0207 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3PerSecond.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9140c048698ac8f4f86fbff73ea4d335 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3RotateTowards.cs b/Assets/PlayMaker/Actions/Vector3RotateTowards.cs new file mode 100755 index 0000000..57ff242 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3RotateTowards.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Rotates a Vector3 direction from Current towards Target.")] + public class Vector3RotateTowards : FsmStateAction + { + [RequiredField] + public FsmVector3 currentDirection; + [RequiredField] + public FsmVector3 targetDirection; + [RequiredField] + [Tooltip("Rotation speed in degrees per second")] + public FsmFloat rotateSpeed; + [RequiredField] + [Tooltip("Max Magnitude per second")] + public FsmFloat maxMagnitude; + public override void Reset() + { + currentDirection = new FsmVector3 { UseVariable = true }; + targetDirection = new FsmVector3 { UseVariable = true }; + rotateSpeed = 360; + maxMagnitude = 1; + } + + public override void OnUpdate() + { + currentDirection.Value = Vector3.RotateTowards(currentDirection.Value, targetDirection.Value, rotateSpeed.Value * Mathf.Deg2Rad * Time.deltaTime, maxMagnitude.Value); + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3RotateTowards.cs.meta b/Assets/PlayMaker/Actions/Vector3RotateTowards.cs.meta new file mode 100755 index 0000000..57af2b6 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3RotateTowards.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a5b29ac92feb00644b7eff46dd53d051 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Vector3Subtract.cs b/Assets/PlayMaker/Actions/Vector3Subtract.cs new file mode 100755 index 0000000..ba7f6f1 --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Subtract.cs @@ -0,0 +1,37 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Vector3)] + [Tooltip("Subtracts a Vector3 value from a Vector3 variable.")] + public class Vector3Subtract : FsmStateAction + { + [RequiredField] + [UIHint(UIHint.Variable)] + public FsmVector3 vector3Variable; + [RequiredField] + public FsmVector3 subtractVector; + public bool everyFrame; + + public override void Reset() + { + vector3Variable = null; + subtractVector = new FsmVector3 { UseVariable = true }; + everyFrame = false; + } + + public override void OnEnter() + { + vector3Variable.Value = vector3Variable.Value - subtractVector.Value; + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + vector3Variable.Value = vector3Variable.Value - subtractVector.Value; + } + } +} + diff --git a/Assets/PlayMaker/Actions/Vector3Subtract.cs.meta b/Assets/PlayMaker/Actions/Vector3Subtract.cs.meta new file mode 100755 index 0000000..d9a286d --- /dev/null +++ b/Assets/PlayMaker/Actions/Vector3Subtract.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e8a6ea371d5d8db4e8fd747a820cf6fa +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/WWWObject.cs b/Assets/PlayMaker/Actions/WWWObject.cs new file mode 100755 index 0000000..cb48add --- /dev/null +++ b/Assets/PlayMaker/Actions/WWWObject.cs @@ -0,0 +1,109 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +#if !(UNITY_IPHONE || UNITY_ANDROID || UNITY_FLASH || UNITY_PS3 || UNITY_PS4 || UNITY_XBOXONE || UNITY_BLACKBERRY || UNITY_WP8 || UNITY_PSM || UNITY_WEBGL) + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory("Web Player")] + [Tooltip("Gets data from a url and store it in variables. See Unity WWW docs for more details.")] + public class WWWObject : FsmStateAction + { + [RequiredField] + [Tooltip("Url to download data from.")] + public FsmString url; + + [ActionSection("Results")] + + [UIHint(UIHint.Variable)] + [Tooltip("Gets text from the url.")] + public FsmString storeText; + + [UIHint(UIHint.Variable)] + [Tooltip("Gets a Texture from the url.")] + public FsmTexture storeTexture; + + [UIHint(UIHint.Variable)] + [ObjectType(typeof(MovieTexture))] + [Tooltip("Gets a Texture from the url.")] + public FsmObject storeMovieTexture; + + [UIHint(UIHint.Variable)] + [Tooltip("Error message if there was an error during the download.")] + public FsmString errorString; + + [UIHint(UIHint.Variable)] + [Tooltip("How far the download progressed (0-1).")] + public FsmFloat progress; + + [ActionSection("Events")] + + [Tooltip("Event to send when the data has finished loading (progress = 1).")] + public FsmEvent isDone; + + [Tooltip("Event to send if there was an error.")] + public FsmEvent isError; + + private WWW wwwObject; + + public override void Reset() + { + url = null; + storeText = null; + storeTexture = null; + errorString = null; + progress = null; + isDone = null; + } + + public override void OnEnter() + { + if (string.IsNullOrEmpty(url.Value)) + { + Finish(); + return; + } + + wwwObject = new WWW(url.Value); + } + + + public override void OnUpdate() + { + if (wwwObject == null) + { + errorString.Value = "WWW Object is Null!"; + Finish(); + return; + } + + errorString.Value = wwwObject.error; + + if (!string.IsNullOrEmpty(wwwObject.error)) + { + Finish(); + Fsm.Event(isError); + return; + } + + progress.Value = wwwObject.progress; + + if (progress.Value.Equals(1f)) + { + storeText.Value = wwwObject.text; + storeTexture.Value = wwwObject.texture; + + storeMovieTexture.Value = wwwObject.movie; + + errorString.Value = wwwObject.error; + + Fsm.Event(string.IsNullOrEmpty(errorString.Value) ? isDone : isError); + + Finish(); + } + } + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/WWWObject.cs.meta b/Assets/PlayMaker/Actions/WWWObject.cs.meta new file mode 100755 index 0000000..63dda8d --- /dev/null +++ b/Assets/PlayMaker/Actions/WWWObject.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 78bccd13ebd50bd4ea5d0c5678d4b10d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/Wait.cs b/Assets/PlayMaker/Actions/Wait.cs new file mode 100755 index 0000000..148930e --- /dev/null +++ b/Assets/PlayMaker/Actions/Wait.cs @@ -0,0 +1,63 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Time)] + [Tooltip("Delays a State from finishing by the specified time. NOTE: Other actions continue, but FINISHED can't happen before Time.")] + public class Wait : FsmStateAction + { + [RequiredField] + public FsmFloat time; + public FsmEvent finishEvent; + public bool realTime; + + private float startTime; + private float timer; + + public override void Reset() + { + time = 1f; + finishEvent = null; + realTime = false; + } + + public override void OnEnter() + { + if (time.Value <= 0) + { + Fsm.Event(finishEvent); + Finish(); + return; + } + + startTime = FsmTime.RealtimeSinceStartup; + timer = 0f; + } + + public override void OnUpdate() + { + // update time + + if (realTime) + { + timer = FsmTime.RealtimeSinceStartup - startTime; + } + else + { + timer += Time.deltaTime; + } + + if (timer >= time.Value) + { + Finish(); + if (finishEvent != null) + { + Fsm.Event(finishEvent); + } + } + } + + } +} diff --git a/Assets/PlayMaker/Actions/Wait.cs.meta b/Assets/PlayMaker/Actions/Wait.cs.meta new file mode 100755 index 0000000..e2894f8 --- /dev/null +++ b/Assets/PlayMaker/Actions/Wait.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bb2b60731a9d08c499d83002ae24cc78 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/WakeAllRigidBodies.cs b/Assets/PlayMaker/Actions/WakeAllRigidBodies.cs new file mode 100755 index 0000000..570c69f --- /dev/null +++ b/Assets/PlayMaker/Actions/WakeAllRigidBodies.cs @@ -0,0 +1,48 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Rigid bodies start sleeping when they come to rest. This action wakes up all rigid bodies in the scene. E.g., if you Set Gravity and want objects at rest to respond.")] + public class WakeAllRigidBodies : FsmStateAction + { + public bool everyFrame; + + private Rigidbody[] bodies; + + public override void Reset() + { + everyFrame = false; + } + + public override void OnEnter() + { + bodies = Object.FindObjectsOfType(typeof(Rigidbody)) as Rigidbody[]; + + DoWakeAll(); + + if (!everyFrame) + Finish(); + } + + public override void OnUpdate() + { + DoWakeAll(); + } + + void DoWakeAll() + { + bodies = Object.FindObjectsOfType(typeof(Rigidbody)) as Rigidbody[]; + + if (bodies != null) + { + foreach (var body in bodies) + { + body.WakeUp(); + } + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/WakeAllRigidBodies.cs.meta b/Assets/PlayMaker/Actions/WakeAllRigidBodies.cs.meta new file mode 100755 index 0000000..6cb92c0 --- /dev/null +++ b/Assets/PlayMaker/Actions/WakeAllRigidBodies.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce2109e54235fa04d94f4dd2ac2228d7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/WakeUp.cs b/Assets/PlayMaker/Actions/WakeUp.cs new file mode 100755 index 0000000..c5a0a65 --- /dev/null +++ b/Assets/PlayMaker/Actions/WakeUp.cs @@ -0,0 +1,35 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Physics)] + [Tooltip("Forces a Game Object's Rigid Body to wake up.")] + public class WakeUp : ComponentAction + { + [RequiredField] + [CheckForComponent(typeof(Rigidbody))] + public FsmOwnerDefault gameObject; + + public override void Reset() + { + gameObject = null; + } + + public override void OnEnter() + { + DoWakeUp(); + Finish(); + } + + void DoWakeUp() + { + var go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; + if (UpdateCache(go)) + { + rigidbody.WakeUp(); + } + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/WakeUp.cs.meta b/Assets/PlayMaker/Actions/WakeUp.cs.meta new file mode 100755 index 0000000..6500e27 --- /dev/null +++ b/Assets/PlayMaker/Actions/WakeUp.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b1e7040dc5830cc4796345b20f1a26d7 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/WorldToScreenPoint.cs b/Assets/PlayMaker/Actions/WorldToScreenPoint.cs new file mode 100755 index 0000000..3afc777 --- /dev/null +++ b/Assets/PlayMaker/Actions/WorldToScreenPoint.cs @@ -0,0 +1,94 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; + +namespace HutongGames.PlayMaker.Actions +{ + [ActionCategory(ActionCategory.Camera)] + [Tooltip("Transforms position from world space into screen space. NOTE: Uses the MainCamera!")] + public class WorldToScreenPoint : FsmStateAction + { + [UIHint(UIHint.Variable)] + [Tooltip("World position to transform into screen coordinates.")] + public FsmVector3 worldPosition; + [Tooltip("World X position.")] + public FsmFloat worldX; + [Tooltip("World Y position.")] + public FsmFloat worldY; + [Tooltip("World Z position.")] + public FsmFloat worldZ; + [UIHint(UIHint.Variable)] + [Tooltip("Store the screen position in a Vector3 Variable. Z will equal zero.")] + public FsmVector3 storeScreenPoint; + [UIHint(UIHint.Variable)] + [Tooltip("Store the screen X position in a Float Variable.")] + public FsmFloat storeScreenX; + [UIHint(UIHint.Variable)] + [Tooltip("Store the screen Y position in a Float Variable.")] + public FsmFloat storeScreenY; + [Tooltip("Normalize screen coordinates (0-1). Otherwise coordinates are in pixels.")] + public FsmBool normalize; + [Tooltip("Repeat every frame")] + public bool everyFrame; + + public override void Reset() + { + worldPosition = null; + // default axis to variable dropdown with None selected. + worldX = new FsmFloat { UseVariable = true }; + worldY = new FsmFloat { UseVariable = true }; + worldZ = new FsmFloat { UseVariable = true }; + storeScreenPoint = null; + storeScreenX = null; + storeScreenY = null; + everyFrame = false; + } + + public override void OnEnter() + { + DoWorldToScreenPoint(); + + if (!everyFrame) + { + Finish(); + } + } + + public override void OnUpdate() + { + DoWorldToScreenPoint(); + } + + void DoWorldToScreenPoint() + { + if (Camera.main == null) + { + LogError("No MainCamera defined!"); + Finish(); + return; + } + + var position = Vector3.zero; + + if(!worldPosition.IsNone) position = worldPosition.Value; + + if (!worldX.IsNone) position.x = worldX.Value; + if (!worldY.IsNone) position.y = worldY.Value; + if (!worldZ.IsNone) position.z = worldZ.Value; + + position = Camera.main.WorldToScreenPoint(position); + + if (normalize.Value) + { + position.x /= Screen.width; + position.y /= Screen.height; + } + + storeScreenPoint.Value = position; + storeScreenX.Value = position.x; + storeScreenY.Value = position.y; + } + + + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Actions/WorldToScreenPoint.cs.meta b/Assets/PlayMaker/Actions/WorldToScreenPoint.cs.meta new file mode 100755 index 0000000..4f8f0e6 --- /dev/null +++ b/Assets/PlayMaker/Actions/WorldToScreenPoint.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc3a649c12f2acf42a7c0d61cefddd3f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Actions/iTween.meta b/Assets/PlayMaker/Actions/iTween.meta new file mode 100644 index 0000000..839dce6 --- /dev/null +++ b/Assets/PlayMaker/Actions/iTween.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2d8c9c1a5755c4ab99b3baddbd8b3c22 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Actions/iTween/iTweenFsmAction.cs b/Assets/PlayMaker/Actions/iTween/iTweenFsmAction.cs new file mode 100755 index 0000000..e7d47a0 --- /dev/null +++ b/Assets/PlayMaker/Actions/iTween/iTweenFsmAction.cs @@ -0,0 +1,79 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEngine; +using System.Collections.Generic; + +namespace HutongGames.PlayMaker.Actions +{ + // base type for GUI actions that need a Rect + [Tooltip("iTween base action - don't use!")] + public abstract class iTweenFsmAction : FsmStateAction + { + /* + iTween does not allow to run simultaneous iTween of the same type. Please, have this in your mind. That means you can not perform MoveTo and MoveAdd at the same time on one object + + */ + public enum AxisRestriction{ + none,x,y,z,xy,xz,yz + } + + [ActionSection("Events")] + public FsmEvent startEvent; + public FsmEvent finishEvent; + [Tooltip("Setting this to true will allow the animation to continue independent of the current time which is helpful for animating menus after a game has been paused by setting Time.timeScale=0.")] + public FsmBool realTime; + public FsmBool stopOnExit; + public FsmBool loopDontFinish; + + internal iTweenFSMEvents itweenEvents; + + //Don't forget to asign this value in descendatns in order to stop iTween when stopOnExit is true + protected string itweenType = ""; + protected int itweenID = -1; + //Since all iTween gets param delay, this variable is set automatically in order to help descedants to pass this param + + public override void Reset() + { + startEvent = null; + finishEvent = null; + realTime = new FsmBool { Value = false }; + stopOnExit = new FsmBool { Value = true }; + loopDontFinish = new FsmBool { Value = true }; + itweenType = ""; + } + + protected void OnEnteriTween(FsmOwnerDefault anOwner) + { + GameObject go = Fsm.GetOwnerDefaultTarget(anOwner); + if (go == null) return; + itweenEvents = go.AddComponent(); + itweenEvents.itweenFSMAction = this; + iTweenFSMEvents.itweenIDCount++; + itweenID = iTweenFSMEvents.itweenIDCount; + itweenEvents.itweenID = iTweenFSMEvents.itweenIDCount; + itweenEvents.donotfinish = loopDontFinish.IsNone ? false : loopDontFinish.Value; + } + + protected void IsLoop(bool aValue){ + if(itweenEvents != null) itweenEvents.islooping = aValue; + } + + protected void OnExitiTween(FsmOwnerDefault anOwner){ + GameObject go = Fsm.GetOwnerDefaultTarget(anOwner); + if (go == null) return; // iTween can auto-delete sometimes...? + if(itweenEvents) GameObject.Destroy(itweenEvents); + if(stopOnExit.IsNone) iTween.Stop(go, itweenType); + else if(stopOnExit.Value) iTween.Stop(go, itweenType); +// if(!stopOnExit.IsNone && stopOnExit.Value == true) { +// Component[] itweens = go.GetComponents(); +// for(int i = 0; i= 2) { + tempVct3 = new Vector3[transforms.Length]; + for(int i = 0;i= 2) { + tempVct3 = new Vector3[transforms.Length]; + if(reverse.IsNone ? false : reverse.Value){ + for(int i = 0;i +/// Custom inspector for PlayMakerFSM +/// +[CustomEditor(typeof(PlayMakerFSM))] +public class FsmComponentInspector : Editor +{ + private bool initialized; + + // Inspector targets + + private PlayMakerFSM fsmComponent; // Inspector target + private FsmTemplate fsmTemplate; // template used by fsmComponent + + // Inspector foldout states + + private bool showSettings = true; + private bool showControls = true; + private bool showDebug = false; + //private bool showInfo; + //private bool showStates; + //private bool showEvents; + //private bool showVariables; + + // Collect easily editable references to fsmComponent.Fsm.Variables + + List fsmVariables = new List(); + + public void OnEnable() + { + //Debug.Log("FsmComponentInspector: OnEnable"); + + fsmComponent = target as PlayMakerFSM; + } + + // Can't do this in OnEnable because it interferes with FSM init + // when playing in the editor + void Initialize() + { + fsmTemplate = fsmComponent.FsmTemplate; + RefreshTemplate(); + BuildFsmVariableList(); + initialized = true; + } + + [Localizable(false)] + public override void OnInspectorGUI() + { + if (fsmComponent == null) return; // shouldn't happen + + if (!initialized) + { + Initialize(); + } + + if (!fsmComponent.Fsm.Initialized) + { + // Note: cannot do this in OnEnable since is breaks FSMs in editor + // Safe to do now since FSM would already have initialized itself + fsmComponent.Fsm.Init(fsmComponent); + } + + FsmEditorStyles.Init(); + + var fsm = fsmComponent.Fsm; // grab Fsm for convenience + + if (fsm.States.Length > 50) // a little arbitrary, but better than nothing! + { + EditorGUILayout.HelpBox("NOTE: Collapse this inspector for better editor performance with large FSMs.", MessageType.None); + } + + // Edit FSM name + + EditorGUILayout.BeginHorizontal(); + showSettings = true; //GUILayout.Toggle(showSettings, "x"); // TODO + fsm.Name = EditorGUILayout.TextField(fsm.Name); + if (GUILayout.Button(FsmEditorContent.EditFsmButton, GUILayout.MaxWidth(45))) + { + OpenInEditor(fsmComponent); + GUIUtility.ExitGUI(); + } + EditorGUILayout.EndHorizontal(); + + if (showSettings) + { + // Edit FSM Template + + EditorGUILayout.BeginHorizontal(); + var template = (FsmTemplate)EditorGUILayout.ObjectField(FsmEditorContent.UseTemplateLabel, fsmComponent.FsmTemplate, typeof(FsmTemplate), false); + if (template != fsmComponent.FsmTemplate) + { + SelectTemplate(template); + } + if (GUILayout.Button(FsmEditorContent.BrowseTemplateButton, GUILayout.MaxWidth(45))) + { + DoSelectTemplateMenu(); + } + EditorGUILayout.EndHorizontal(); + + // Disable GUI that can't be edited if referencing a template + + EditorGUI.BeginDisabledGroup(!Application.isPlaying && fsmComponent.FsmTemplate != null); + + if (fsmComponent.FsmTemplate != null) + { + // next few fields should show template values + template = fsmComponent.FsmTemplate; + fsm = template.fsm; + } + + // Edit Description + + fsm.Description = FsmEditorGUILayout.TextAreaWithHint(fsm.Description, Strings.Label_Description___, GUILayout.MinHeight(60)); + + // Edit Help Url (lets the user link to documentation for the FSM) + + EditorGUILayout.BeginHorizontal(); + fsm.DocUrl = FsmEditorGUILayout.TextFieldWithHint(fsm.DocUrl, Strings.Tooltip_Documentation_Url); + EditorGUI.BeginDisabledGroup(!string.IsNullOrEmpty(fsm.DocUrl)); + if (FsmEditorGUILayout.HelpButton()) + { + Application.OpenURL(fsm.DocUrl); + } + EditorGUI.EndDisabledGroup(); + EditorGUILayout.EndHorizontal(); + + // Settings + + EditorGUI.BeginDisabledGroup(!Application.isPlaying && FsmEditor.SelectedFsmUsesTemplate); + + fsm.MaxLoopCountOverride = EditorGUILayout.IntField(FsmEditorContent.MaxLoopOverrideLabel, fsm.MaxLoopCountOverride); + fsm.RestartOnEnable = GUILayout.Toggle(fsm.RestartOnEnable, FsmEditorContent.ResetOnDisableLabel); + + EditorGUI.EndDisabledGroup(); // Settings + EditorGUI.EndDisabledGroup(); // Uses template + + // stop showing template values + fsm = fsmComponent.Fsm; + } + + // Controls Section + + // Show FSM variables with Inspector option checked + + FsmEditorGUILayout.LightDivider(); + showControls = EditorGUILayout.Foldout(showControls, FsmEditorContent.FsmControlsLabel, FsmEditorStyles.CategoryFoldout); + if (showControls) + { + BuildFsmVariableList(); + + var currentCategory = 0; + for (var index = 0; index < fsmVariables.Count; index++) + { + var fsmVariable = fsmVariables[index]; + if (fsmVariable.ShowInInspector) + { + var categoryID = fsmVariable.CategoryID; + if (categoryID > 0 && categoryID != currentCategory) + { + currentCategory = categoryID; + GUILayout.Label(fsmComponent.Fsm.Variables.Categories[categoryID], EditorStyles.boldLabel); + FsmEditorGUILayout.LightDivider(); + } + fsmVariable.DoInspectorGUI(FsmEditorContent.TempContent(fsmVariable.Name, fsmVariable.Name + (!string.IsNullOrEmpty(fsmVariable.Tooltip) ? ":\n" + fsmVariable.Tooltip : ""))); + } + } + } + + // Show events with Inspector option checked + // These become buttons that the user can press to send the events + + if (showControls) + { + foreach (var fsmEvent in fsm.ExposedEvents) + { + GUILayout.BeginHorizontal(); + EditorGUILayout.PrefixLabel(fsmEvent.Name); + if (GUILayout.Button(fsmEvent.Name)) + { + fsm.Event(fsmEvent); + FsmEditor.RepaintAll(); + } + GUILayout.EndHorizontal(); + } + } + + // DEBUG + + FsmEditorGUILayout.LightDivider(); + showDebug = EditorGUILayout.Foldout(showDebug, "Debug", FsmEditorStyles.CategoryFoldout); + if (showDebug) + { + fsm.ShowStateLabel = GUILayout.Toggle(fsm.ShowStateLabel, FsmEditorContent.ShowStateLabelsLabel); + fsm.EnableBreakpoints = GUILayout.Toggle(fsm.EnableBreakpoints, FsmEditorContent.EnableBreakpointsLabel); + fsm.EnableDebugFlow = GUILayout.Toggle(fsm.EnableDebugFlow, FsmEditorContent.EnableDebugFlowLabel); + } + + #region INFO + // Show general info about the FSM + + /* Is this useful...? + EditorGUI.indentLevel = 0; + FsmEditorGUILayout.LightDivider(); + showInfo = EditorGUILayout.Foldout(showInfo, Strings.Label_Info, FsmEditorStyles.CategoryFoldout); + if (showInfo) + { + EditorGUI.indentLevel = 1; + + showStates = EditorGUILayout.Foldout(showStates, string.Format(Strings.Label_States_Count, fsm.States.Length)); + if (showStates) + { + string states = ""; + + if (fsm.States.Length > 0) + { + foreach (var state in fsm.States) + { + states += FsmEditorStyles.tab2 + state.Name + FsmEditorStyles.newline; + } + states = states.Substring(0, states.Length - 1); + } + else + { + states = FsmEditorStyles.tab2 + Strings.Label_None_In_Table; + } + GUILayout.Label(states); + } + + showEvents = EditorGUILayout.Foldout(showEvents, string.Format(Strings.Label_Events_Count, fsm.Events.Length)); + if (showEvents) + { + var events = ""; + + if (fsm.Events.Length > 0) + { + foreach (var fsmEvent in fsm.Events) + { + events += FsmEditorStyles.tab2 + fsmEvent.Name + FsmEditorStyles.newline; + } + events = events.Substring(0, events.Length - 1); + } + else + { + events = FsmEditorStyles.tab2 + Strings.Label_None_In_Table; + } + GUILayout.Label(events); + } + + showVariables = EditorGUILayout.Foldout(showVariables, string.Format(Strings.Label_Variables_Count, fsmVariables.Count)); + if (showVariables) + { + var variables = ""; + + if (fsmVariables.Count > 0) + { + foreach (var fsmVar in fsmVariables) + { + variables += FsmEditorStyles.tab2 + fsmVar.Name + FsmEditorStyles.newline; + } + variables = variables.Substring(0, variables.Length - 1); + } + else + { + variables = FsmEditorStyles.tab2 + Strings.Label_None_In_Table; + } + GUILayout.Label(variables); + } + }*/ + #endregion + + + // Manual refresh if template has been edited + + if (fsmTemplate != null) + { + if (GUILayout.Button(FsmEditorContent.RefreshTemplateLabel)) + { + RefreshTemplate(); + } + } + + if (GUI.changed) + { + EditorUtility.SetDirty(fsmComponent); + FsmEditor.RepaintAll(); + } + } + + /// + /// Open the specified FSM in the Playmaker Editor + /// + public static void OpenInEditor(PlayMakerFSM fsmComponent) + { + if (FsmEditor.Instance == null) + { + FsmEditorWindow.OpenWindow(fsmComponent); + } + else + { + EditorWindow.FocusWindowIfItsOpen(); + FsmEditor.SelectFsm(fsmComponent.FsmTemplate == null ? fsmComponent.Fsm : fsmComponent.FsmTemplate.fsm); + } + } + + /// + /// Open the specified FSM in the Playmaker Editor + /// + public static void OpenInEditor(Fsm fsm) + { + if (fsm.Owner != null) + { + OpenInEditor(fsm.Owner as PlayMakerFSM); + } + } + + /// + /// Open the first PlayMakerFSM on a GameObject in the Playmaker Editor + /// + public static void OpenInEditor(GameObject go) + { + if (go != null) + { + OpenInEditor(FsmEditorUtility.FindFsmOnGameObject(go)); + } + } + + /// + /// The fsmVariables list contains easily editable references to FSM variables + /// (Similar in concept to SerializedProperty) + /// + void BuildFsmVariableList() + { + fsmVariables = FsmVariable.GetFsmVariableList(target); + fsmVariables = fsmVariables.Where(x => x.ShowInInspector).ToList(); + } + + #region Templates + + void SelectTemplate(object userdata) + { + SelectTemplate(userdata as FsmTemplate); + } + + void SelectTemplate(FsmTemplate template) + { + if (template == fsmComponent.FsmTemplate) + { + return; // don't want to lose overridden variables + } + + UndoUtility.RegisterUndo(fsmComponent, "PlayMaker : Set FSM Template"); + fsmComponent.SetFsmTemplate(template); + fsmTemplate = template; + BuildFsmVariableList(); + EditorUtility.SetDirty(fsmComponent); + + FsmEditor.RefreshInspector(); // Keep Playmaker Editor in sync + } + + void ClearTemplate() + { + fsmComponent.Reset(); + fsmTemplate = null; + + BuildFsmVariableList(); + + // If we were editing the template in the Playmaker editor + // handle this gracefully by reselecting the base FSM + + if (FsmEditor.SelectedFsmComponent == fsmComponent) + { + FsmEditor.SelectFsm(fsmComponent.Fsm); + } + } + + /// + /// A template can change since it was selected. + /// This method refreshes the UI to reflect any changes + /// while keeping any variable overrides that the use has made + /// + void RefreshTemplate() + { + if (fsmTemplate == null || Application.isPlaying) + { + return; + } + + // we want to keep the existing overrides + // so we copy the current FsmVariables + + var currentValues = new FsmVariables(fsmComponent.Fsm.Variables); + + // then we update the template + + fsmComponent.SetFsmTemplate(fsmTemplate); + + // finally we apply the original overrides back to the new FsmVariables + + fsmComponent.Fsm.Variables.OverrideVariableValues(currentValues); + + // and refresh the UI + + BuildFsmVariableList(); + + FsmEditor.RefreshInspector(); + } + + void DoSelectTemplateMenu() + { + var menu = new GenericMenu(); + + var templates = (FsmTemplate[])Resources.FindObjectsOfTypeAll(typeof(FsmTemplate)); + + menu.AddItem(new GUIContent(Strings.Menu_None), false, ClearTemplate); + + foreach (var template in templates) + { + const string submenu = "/"; + menu.AddItem(new GUIContent(template.Category + submenu + template.name), fsmComponent.FsmTemplate == template, SelectTemplate, template); + } + + menu.ShowAsContext(); + } + + #endregion + + /// + /// Actions can use OnSceneGUI to display interactive gizmos + /// + public void OnSceneGUI() + { + FsmEditor.OnSceneGUI(); + } +} + + diff --git a/Assets/PlayMaker/Editor/FsmComponentInspector.cs.meta b/Assets/PlayMaker/Editor/FsmComponentInspector.cs.meta new file mode 100755 index 0000000..29a1d43 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmComponentInspector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9306c4050cc990b469e6ae598fec8935 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmEditorHelpers.cs b/Assets/PlayMaker/Editor/FsmEditorHelpers.cs new file mode 100755 index 0000000..5795aa5 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmEditorHelpers.cs @@ -0,0 +1,5 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +public class FsmEditorHelpers +{ +} diff --git a/Assets/PlayMaker/Editor/FsmEditorHelpers.cs.meta b/Assets/PlayMaker/Editor/FsmEditorHelpers.cs.meta new file mode 100755 index 0000000..eb9f6e4 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmEditorHelpers.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d32bb7afe075420428cb885c4f6f1894 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmEditorWindow.cs b/Assets/PlayMaker/Editor/FsmEditorWindow.cs new file mode 100755 index 0000000..f744f09 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmEditorWindow.cs @@ -0,0 +1,477 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using UnityEditor; +using UnityEngine; + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT changing it breaks saved layouts + * SO wrap in namespace instead (which is also now supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + [System.Serializable] + class FsmEditorWindow : BaseEditorWindow + { + /// + /// Open the Fsm Editor and optionally show the Welcome Screen + /// + public static void OpenWindow() + { + GetWindow(); + + if (!EditorApp.IsSourceCodeVersion) + { + if (EditorPrefs.GetBool(EditorPrefStrings.ShowWelcomeScreen, true)) + { + GetWindow(true); + } + + /* Moved to WelcomeWindow.cs + if (EditorPrefs.GetBool(EditorPrefStrings.ShowUpgradeGuide, true)) + { + GetWindow(true); + }*/ + } + } + + /// + /// Open the Fsm Editor and select an Fsm Component + /// + public static void OpenWindow(PlayMakerFSM fsmComponent) + { + OpenWindow(); + + FsmEditor.SelectFsm(fsmComponent.Fsm); + } + + /// + /// Open the Fsm Editor and select an Fsm Component + /// + public static void OpenWindow(FsmTemplate fsmTemplate) + { + OpenWindow(); + + FsmEditor.SelectFsm(fsmTemplate.fsm); + } + + /// + /// Is the Fsm Editor open? + /// + public static bool IsOpen() + { + return instance != null; + } + + private static FsmEditorWindow instance; + + [SerializeField] + private FsmEditor fsmEditor; + + // tool windows (can't open them inside dll) + + [SerializeField] private FsmSelectorWindow fsmSelectorWindow; + [SerializeField] private FsmTemplateWindow fsmTemplateWindow; + [SerializeField] private FsmStateWindow stateSelectorWindow; + [SerializeField] private FsmActionWindow actionWindow; + [SerializeField] private FsmErrorWindow errorWindow; + [SerializeField] private TimelineWindow timelineWindow; + [SerializeField] private FsmLogWindow logWindow; + [SerializeField] private ContextToolWindow toolWindow; + [SerializeField] private GlobalEventsWindow globalEventsWindow; + [SerializeField] private GlobalVariablesWindow globalVariablesWindow; + [SerializeField] private ReportWindow reportWindow; + [SerializeField] private AboutWindow aboutWindow; + + // ReSharper disable UnusedMember.Local + + /// + /// Delay initialization until first OnGUI to avoid interfering with runtime system intialization. + /// + public override void Initialize() + { + instance = this; + + if (fsmEditor == null) + { + fsmEditor = new FsmEditor(); + } + + fsmEditor.InitWindow(this); + fsmEditor.OnEnable(); + } + + public override void DoGUI() + { + fsmEditor.OnGUI(); + + /* Debug Repaint events + if (Event.current.type == EventType.repaint) + { + Debug.Log("Repaint"); + }*/ + + if (Event.current.type == EventType.ValidateCommand) + { + switch (Event.current.commandName) + { + case "UndoRedoPerformed": + case "Cut": + case "Copy": + case "Paste": + case "SelectAll": + Event.current.Use(); + break; + } + } + + if (Event.current.type == EventType.ExecuteCommand) + { + switch (Event.current.commandName) + { + /* replaced with Undo.undoRedoPerformed callback added in Unity 4.3 + case "UndoRedoPerformed": + FsmEditor.UndoRedoPerformed(); + break; + */ + + case "Cut": + FsmEditor.Cut(); + break; + + case "Copy": + FsmEditor.Copy(); + break; + + case "Paste": + FsmEditor.Paste(); + break; + + case "SelectAll": + FsmEditor.SelectAll(); + break; + + case "OpenWelcomeWindow": + GetWindow(); + break; + + case "OpenToolWindow": + toolWindow = GetWindow(); + break; + + case "OpenFsmSelectorWindow": + fsmSelectorWindow = GetWindow(); + fsmSelectorWindow.ShowUtility(); + break; + + case "OpenFsmTemplateWindow": + fsmTemplateWindow = GetWindow(); + break; + + case "OpenStateSelectorWindow": + stateSelectorWindow = GetWindow(); + break; + + case "OpenActionWindow": + actionWindow = GetWindow(); + break; + + case "OpenGlobalEventsWindow": + globalEventsWindow = GetWindow(); + break; + + case "OpenGlobalVariablesWindow": + globalVariablesWindow = GetWindow(); + break; + + case "OpenErrorWindow": + errorWindow = GetWindow(); + break; + + case "OpenTimelineWindow": + timelineWindow = GetWindow(); + break; + + case "OpenFsmLogWindow": + logWindow = GetWindow(); + break; + + case "OpenAboutWindow": + aboutWindow = GetWindow(); + break; + + case "OpenReportWindow": + reportWindow = GetWindow(); + break; + + case "AddFsmComponent": + PlayMakerMainMenu.AddFsmToSelected(); + break; + + case "RepaintAll": + RepaintAllWindows(); + break; + + case "ChangeLanguage": + ResetWindowTitles(); + break; + } + + GUIUtility.ExitGUI(); + } + } + + // called when you change editor language + public void ResetWindowTitles() + { + if (toolWindow != null) + { + toolWindow.InitWindowTitle(); + } + + if (fsmSelectorWindow != null) + { + fsmSelectorWindow.InitWindowTitle(); + } + + if (stateSelectorWindow != null) + { + stateSelectorWindow.InitWindowTitle(); + } + + if (actionWindow != null) + { + actionWindow.InitWindowTitle(); + } + + if (globalEventsWindow != null) + { + globalEventsWindow.InitWindowTitle(); + } + + if (globalVariablesWindow != null) + { + globalVariablesWindow.InitWindowTitle(); + } + + if (errorWindow != null) + { + errorWindow.InitWindowTitle(); + } + + if (timelineWindow != null) + { + timelineWindow.InitWindowTitle(); + } + + if (logWindow != null) + { + logWindow.InitWindowTitle(); + } + + if (reportWindow != null) + { + reportWindow.InitWindowTitle(); + } + + if (fsmTemplateWindow != null) + { + fsmTemplateWindow.InitWindowTitle(); + } + } + + public void RepaintAllWindows() + { + if (toolWindow != null) + { + toolWindow.Repaint(); + } + + if (fsmSelectorWindow != null) + { + fsmSelectorWindow.Repaint(); + } + + if (stateSelectorWindow != null) + { + stateSelectorWindow.Repaint(); + } + + if (actionWindow != null) + { + actionWindow.Repaint(); + } + + if (globalEventsWindow != null) + { + globalEventsWindow.Repaint(); + } + + if (globalVariablesWindow != null) + { + globalVariablesWindow.Repaint(); + } + + if (errorWindow != null) + { + errorWindow.Repaint(); + } + + if (timelineWindow != null) + { + timelineWindow.Repaint(); + } + + if (logWindow != null) + { + logWindow.Repaint(); + } + + if (reportWindow != null) + { + reportWindow.Repaint(); + } + + if (fsmTemplateWindow != null) + { + fsmTemplateWindow.Repaint(); + } + + Repaint(); + } + + private void Update() + { + if (Initialized && fsmEditor != null) + { + fsmEditor.Update(); + } + } + + private void OnInspectorUpdate() + { + if (Initialized && fsmEditor != null) + { + fsmEditor.OnInspectorUpdate(); + } + } + + private void OnFocus() + { + if (Initialized && fsmEditor != null) + { + fsmEditor.OnFocus(); + } + } + + private void OnSelectionChange() + { + if (Initialized && fsmEditor != null) + { + fsmEditor.OnSelectionChange(); + } + } + + private void OnHierarchyChange() + { + if (Initialized && fsmEditor != null) + { + fsmEditor.OnHierarchyChange(); + } + } + + private void OnProjectChange() + { + if (Initialized && fsmEditor != null) + { + fsmEditor.OnProjectChange(); + } + } + + private void OnDisable() + { + if (Initialized && fsmEditor != null) + { + fsmEditor.OnDisable(); + } + + instance = null; + } + + private void OnDestroy() + { + if (toolWindow != null) + { + toolWindow.SafeClose(); + } + + if (fsmSelectorWindow != null) + { + fsmSelectorWindow.SafeClose(); + } + + if (fsmTemplateWindow != null) + { + fsmTemplateWindow.SafeClose(); + } + + if (stateSelectorWindow != null) + { + stateSelectorWindow.SafeClose(); + } + + if (actionWindow != null) + { + actionWindow.SafeClose(); + } + + if (globalVariablesWindow != null) + { + globalVariablesWindow.SafeClose(); + } + + if (globalEventsWindow != null) + { + globalEventsWindow.SafeClose(); + } + + if (errorWindow != null) + { + errorWindow.SafeClose(); + } + + if (timelineWindow != null) + { + timelineWindow.SafeClose(); + } + + if (logWindow != null) + { + logWindow.SafeClose(); + } + + if (reportWindow != null) + { + reportWindow.SafeClose(); + } + + if (aboutWindow != null) + { + aboutWindow.SafeClose(); + } + + if (Initialized && fsmEditor != null) + { + fsmEditor.OnDestroy(); + } + } + + // ReSharper restore UnusedMember.Local + } + + + +} diff --git a/Assets/PlayMaker/Editor/FsmEditorWindow.cs.meta b/Assets/PlayMaker/Editor/FsmEditorWindow.cs.meta new file mode 100755 index 0000000..61090bd --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmEditorWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2916a199406917f40ba513733da47a08 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmErrorWindow.cs b/Assets/PlayMaker/Editor/FsmErrorWindow.cs new file mode 100755 index 0000000..0c01724 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmErrorWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class FsmErrorWindow : ErrorSelector + { + } +} diff --git a/Assets/PlayMaker/Editor/FsmErrorWindow.cs.meta b/Assets/PlayMaker/Editor/FsmErrorWindow.cs.meta new file mode 100755 index 0000000..a89631a --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmErrorWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9eb8fe199c065cf45aecf7b52b9fa979 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmEventsWindow.cs b/Assets/PlayMaker/Editor/FsmEventsWindow.cs new file mode 100755 index 0000000..db18e61 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmEventsWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class FsmEventsWindow : GlobalEventsWindow + { + } +} diff --git a/Assets/PlayMaker/Editor/FsmEventsWindow.cs.meta b/Assets/PlayMaker/Editor/FsmEventsWindow.cs.meta new file mode 100755 index 0000000..d6b23f8 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmEventsWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b0320d6e9824b324992f97fec8cc1f64 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmGlobalsWindow.cs b/Assets/PlayMaker/Editor/FsmGlobalsWindow.cs new file mode 100755 index 0000000..026b5ef --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmGlobalsWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class FsmGlobalsWindow : GlobalVariablesWindow + { + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Editor/FsmGlobalsWindow.cs.meta b/Assets/PlayMaker/Editor/FsmGlobalsWindow.cs.meta new file mode 100755 index 0000000..7697e36 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmGlobalsWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ceeab317aa52436458270ec33862f2f5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmLogWindow.cs b/Assets/PlayMaker/Editor/FsmLogWindow.cs new file mode 100755 index 0000000..20a0c61 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmLogWindow.cs @@ -0,0 +1,17 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + class FsmLogWindow : FsmLogger + { + } +} + diff --git a/Assets/PlayMaker/Editor/FsmLogWindow.cs.meta b/Assets/PlayMaker/Editor/FsmLogWindow.cs.meta new file mode 100755 index 0000000..2db0ddd --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmLogWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c71222d654a5ef3429f9997b98046e0f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmSelectorWindow.cs b/Assets/PlayMaker/Editor/FsmSelectorWindow.cs new file mode 100755 index 0000000..5a875df --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmSelectorWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class FsmSelectorWindow : FsmSelector + { + } +} diff --git a/Assets/PlayMaker/Editor/FsmSelectorWindow.cs.meta b/Assets/PlayMaker/Editor/FsmSelectorWindow.cs.meta new file mode 100755 index 0000000..36c95e2 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmSelectorWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6d935c6c261d748469153524686e2359 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmStateWindow.cs b/Assets/PlayMaker/Editor/FsmStateWindow.cs new file mode 100755 index 0000000..9837241 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmStateWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class FsmStateWindow : StateSelector + { + } +} diff --git a/Assets/PlayMaker/Editor/FsmStateWindow.cs.meta b/Assets/PlayMaker/Editor/FsmStateWindow.cs.meta new file mode 100755 index 0000000..d3c0fed --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmStateWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0b9d081570715a540a4b0a769718fc21 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmTemplate.cs b/Assets/PlayMaker/Editor/FsmTemplate.cs new file mode 100755 index 0000000..7db40b3 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmTemplate.cs @@ -0,0 +1,29 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +/* Moved to PlayMake.dll + +using System; +using HutongGames.PlayMaker; +using UnityEngine; + +/// +/// Simple container for an Fsm so it can be saved as an asset in the project. +/// This asset can then be pasted into FSMs. +/// TODO: Create a new PlayMakerFSM from FsmTemplate and add to Game Object. +/// + +[Serializable] +public class FsmTemplate : ScriptableObject +{ + [SerializeField] + private string category; + public Fsm fsm; + + public string Category + { + get { return category; } + set { category = value; } + } +} + +*/ diff --git a/Assets/PlayMaker/Editor/FsmTemplate.cs.meta b/Assets/PlayMaker/Editor/FsmTemplate.cs.meta new file mode 100755 index 0000000..f45a9f8 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmTemplate.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 361089057f21be64c8034c9702b27a50 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmTemplateEditor.cs b/Assets/PlayMaker/Editor/FsmTemplateEditor.cs new file mode 100755 index 0000000..43b3e36 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmTemplateEditor.cs @@ -0,0 +1,42 @@ +using System.ComponentModel; +using HutongGames.PlayMakerEditor; +using UnityEngine; +using UnityEditor; + +[CanEditMultipleObjects] +[CustomEditor(typeof(FsmTemplate))] +public class FsmTemplateEditor : Editor +{ + private SerializedProperty categoryProperty; + private SerializedProperty descriptionProperty; + private GUIStyle multiline; + + [Localizable(false)] + public void OnEnable() + { + categoryProperty = serializedObject.FindProperty("category"); + descriptionProperty = serializedObject.FindProperty("fsm.description"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(categoryProperty); + + if (multiline == null) + { + multiline = new GUIStyle(EditorStyles.textField) { wordWrap = true }; + } + descriptionProperty.stringValue = EditorGUILayout.TextArea(descriptionProperty.stringValue, multiline, GUILayout.MinHeight(60)); + + serializedObject.ApplyModifiedProperties(); + + if (GUILayout.Button(Strings.FsmTemplateEditor_Open_In_Editor)) + { + FsmEditorWindow.OpenWindow((FsmTemplate) target); + } + + EditorGUILayout.HelpBox(Strings.Hint_Exporting_Templates, MessageType.None ); + } +} diff --git a/Assets/PlayMaker/Editor/FsmTemplateEditor.cs.meta b/Assets/PlayMaker/Editor/FsmTemplateEditor.cs.meta new file mode 100755 index 0000000..747de5b --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmTemplateEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a027b04acf4d4354eb9257d4c4880536 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmTemplateWindow.cs b/Assets/PlayMaker/Editor/FsmTemplateWindow.cs new file mode 100755 index 0000000..21b013d --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmTemplateWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class FsmTemplateWindow : FsmTemplateSelector + { + } +} diff --git a/Assets/PlayMaker/Editor/FsmTemplateWindow.cs.meta b/Assets/PlayMaker/Editor/FsmTemplateWindow.cs.meta new file mode 100755 index 0000000..ab66cbb --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmTemplateWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 427204093697d39499b7c5446a785ad3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/FsmTimelineWindow.cs b/Assets/PlayMaker/Editor/FsmTimelineWindow.cs new file mode 100755 index 0000000..8f94c1b --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmTimelineWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + public class FsmTimelineWindow : TimelineWindow + { + } +} diff --git a/Assets/PlayMaker/Editor/FsmTimelineWindow.cs.meta b/Assets/PlayMaker/Editor/FsmTimelineWindow.cs.meta new file mode 100755 index 0000000..3d5e2d6 --- /dev/null +++ b/Assets/PlayMaker/Editor/FsmTimelineWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c3a5b63705b3fd249b805f2b0179954f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/Install.meta b/Assets/PlayMaker/Editor/Install.meta new file mode 100644 index 0000000..1a67074 --- /dev/null +++ b/Assets/PlayMaker/Editor/Install.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3f6aa31d9b7a84e0584a99cfc5d8bb78 +folderAsset: yes +timeCreated: 1449957738 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Install/PlayMaker.1.7.8.4.unitypackage b/Assets/PlayMaker/Editor/Install/PlayMaker.1.7.8.4.unitypackage new file mode 100644 index 0000000..cf99643 Binary files /dev/null and b/Assets/PlayMaker/Editor/Install/PlayMaker.1.7.8.4.unitypackage differ diff --git a/Assets/PlayMaker/Editor/Install/PlayMaker.1.7.8.4.unitypackage.meta b/Assets/PlayMaker/Editor/Install/PlayMaker.1.7.8.4.unitypackage.meta new file mode 100644 index 0000000..68eda84 --- /dev/null +++ b/Assets/PlayMaker/Editor/Install/PlayMaker.1.7.8.4.unitypackage.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dd583cbbf618ba54983cdf396b28e49b +timeCreated: 1434821796 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Install/Playmaker.1.8.0.unitypackage b/Assets/PlayMaker/Editor/Install/Playmaker.1.8.0.unitypackage new file mode 100644 index 0000000..2aa7003 Binary files /dev/null and b/Assets/PlayMaker/Editor/Install/Playmaker.1.8.0.unitypackage differ diff --git a/Assets/PlayMaker/Editor/Install/Playmaker.1.8.0.unitypackage.meta b/Assets/PlayMaker/Editor/Install/Playmaker.1.8.0.unitypackage.meta new file mode 100644 index 0000000..8ce56e5 --- /dev/null +++ b/Assets/PlayMaker/Editor/Install/Playmaker.1.8.0.unitypackage.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f982487afa4f0444ea11e90a9d05b94e +timeCreated: 1434775225 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/PlayMakerAutoUpdater.cs b/Assets/PlayMaker/Editor/PlayMakerAutoUpdater.cs new file mode 100755 index 0000000..535d96e --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerAutoUpdater.cs @@ -0,0 +1,236 @@ +using System.Collections.Generic; +using System.IO; +using UnityEngine; +using UnityEditor; + +#if UNITY_5_0 || UNITY_5 + +namespace HutongGames.PlayMakerEditor +{ + /// + /// Try to fix common update problems automatically + /// Update Tasks: + /// -- Move Playmaker.dll from Assets\PlayMaker to Assets\Plugins\PlayMaker + /// -- Set plugin import settings + /// + [InitializeOnLoad] + public class PlayMakerAutoUpdater + { + static List changeList = new List(); + + private static readonly BuildTarget[] standardPlatforms = + { + BuildTarget.Android, + BuildTarget.BlackBerry, + BuildTarget.StandaloneLinux, + BuildTarget.StandaloneLinux64, + BuildTarget.StandaloneLinuxUniversal, + BuildTarget.StandaloneOSXIntel, + BuildTarget.StandaloneOSXIntel64, + BuildTarget.StandaloneOSXUniversal, + BuildTarget.StandaloneWindows, + BuildTarget.StandaloneWindows64, + BuildTarget.WebPlayer, + BuildTarget.WebPlayerStreamed, + BuildTarget.iOS + }; + + // static constructor called on load + static PlayMakerAutoUpdater() + { + if (ShouldUpdate()) + { + // Can't call assetdatabase here, so use update callback + EditorApplication.update -= RunAutoUpdate; + EditorApplication.update += RunAutoUpdate; + } + } + + static bool ShouldUpdate() + { + if (string.IsNullOrEmpty(Application.dataPath)) return false; + if (EditorPrefs.GetString("PlayMaker.LastAutoUpdate", "") != GetUpdateSignature()) + { + // save auto update settings + // so we don't get caught in infinite loop when re-importing + EditorPrefs.SetString("PlayMaker.LastAutoUpdate", GetUpdateSignature()); + return true; + } + return false; + } + + // Get a unique signature for this update to avoid repeatedly updating the same project + // NOTE: might be a better way to do this. Currently doesn't catch project changes like imports... + static string GetUpdateSignature() + { + return Application.unityVersion + "__" + Application.dataPath + "__" + VersionInfo.AssemblyVersion; + } + + // Check pre-requisites for auto updating + // e.g., Unity 5 version of Playmaker is imported + static bool CheckRequirements() + { + // If project doesn't have this folder user hasn't updated Playmaker for Unity5 + if (!EditorApp.IsSourceCodeVersion && !AssetDatabase.IsValidFolder("Assets/Plugins/PlayMaker")) + { + EditorUtility.DisplayDialog("PlayMaker AutoUpdater", + "Please import Playmaker for Unity 5." + + "\n\nTo get the latest version, update in the Unity Asset Store " + + "or download from Hutong Games Store.", "OK"); + Debug.Log("PlayMaker AutoUpdater: Please import Playmaker for Unity 5."); + EditorPrefs.DeleteKey("PlayMaker.LastAutoUpdate"); + return false; + } + return true; + } + + public static void RunAutoUpdate() + { + //Debug.Log("PlayMaker AutoUpdater " + version); + EditorApplication.update -= RunAutoUpdate; + + if (!CheckRequirements()) + { + //Debug.Log("PlayMaker AutoUpdate: Could not auto-update."); + return; + } + + if (NeedsUpdate()) + { + if (EditorUtility.DisplayDialog("PlayMaker", + "PlayMaker AutoUpdater would like to move Playmaker dlls to Plugin folders." + + "\n\nNOTE: You can run the AutoUpdater manually from PlayMaker > Tools > Run AutoUpdater", + "OK", "Cancel")) + { + DoUpdate(); + } + } + } + + static bool NeedsUpdate() + { + return AssetImporter.GetAtPath("Assets/PlayMaker/PlayMaker.dll") != null; + } + + static void DoUpdate() + { + MovePlayMakerDll(); + + // plugin settings need to be set (note doing this before move doesn't seem to take) + if (!FixPlayMakerDllSettings("Assets/Plugins/PlayMaker/PlayMaker.dll")) + { + Debug.LogWarning("Failed to change Assets/Plugins/PlayMaker/PlayMaker.dll settings."); + } + + MovePlayMakerMetroDll(); + + if (!FixPlayMakerMetroDllSettings("Assets/Plugins/PlayMaker/Metro/PlayMaker.dll")) + { + Debug.LogWarning("Failed to change Assets/Plugins/PlayMaker/Metro/PlayMaker.dll settings."); + } + + ReportChanges(); + } + + static bool FixPlayMakerDllSettings(string pluginPath) + { + var pluginImporter = (PluginImporter)AssetImporter.GetAtPath(pluginPath); + if (pluginImporter != null) + { + FixPlayMakerDllSettings(pluginImporter); + return true; + } + + return false; + } + + static void FixPlayMakerDllSettings(PluginImporter pluginImporter) + { + LogChange("Fixed Plugin Settings: " + pluginImporter.assetPath); + + pluginImporter.SetCompatibleWithAnyPlatform(false); + pluginImporter.SetCompatibleWithEditor(true); + SetCompatiblePlatforms(pluginImporter, standardPlatforms); + AssetDatabase.Refresh(); + } + + static bool FixPlayMakerMetroDllSettings(string pluginPath) + { + var pluginImporter = (PluginImporter)AssetImporter.GetAtPath(pluginPath); + if (pluginImporter != null) + { + FixPlayMakerMetroDllSettings(pluginImporter); + return true; + } + + return false; + } + + static void FixPlayMakerMetroDllSettings(PluginImporter pluginImporter) + { + LogChange("Fixed Plugin Settings: " + pluginImporter.assetPath); + + pluginImporter.SetCompatibleWithAnyPlatform(false); + pluginImporter.SetCompatibleWithPlatform(BuildTarget.WSAPlayer, true); + AssetDatabase.Refresh(); + } + + static void SetCompatiblePlatforms(PluginImporter pluginImporter, IEnumerable platforms) + { + foreach (var platform in platforms) + { + pluginImporter.SetCompatibleWithPlatform(platform, true); + } + } + + static void MovePlayMakerDll() + { + MoveAsset("Assets/PlayMaker/PlayMaker.dll", "Assets/Plugins/PlayMaker/PlayMaker.dll"); + } + + static void MovePlayMakerMetroDll() + { + MoveAsset("Assets/Plugins/Metro/PlayMaker.dll", "Assets/Plugins/PlayMaker/Metro/PlayMaker.dll"); + } + + static void MoveAsset(string from, string to) + { + LogChange("Moving " + from + " to: " + to); + AssetDatabase.DeleteAsset(to); + AssetDatabase.Refresh(); + var error = AssetDatabase.MoveAsset(from, to); + if (!string.IsNullOrEmpty(error)) + { + LogChange(error); + } + AssetDatabase.Refresh(); + } + + + static void LogChange(string change) + { + //Debug.Log("PlayMaker AutoUpdate: " + change); + changeList.Add(change); + } + + static void ReportChanges() + { + if (changeList.Count > 0) + { + var changeLog = "PlayMaker AutoUpdater Changes:"; + foreach (var change in changeList) + { + changeLog += "\n" + change; + } + Debug.Log(changeLog); + } + else + { + Debug.Log("PlayMaker AutoUpdater: No changes made"); + } + } + + } +} + +#endif \ No newline at end of file diff --git a/Assets/PlayMaker/Editor/PlayMakerAutoUpdater.cs.meta b/Assets/PlayMaker/Editor/PlayMakerAutoUpdater.cs.meta new file mode 100755 index 0000000..39e82a1 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerAutoUpdater.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e04f17956f363754e8bb25460c272e6e +timeCreated: 1428085137 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/PlayMakerBugReportWindow.cs b/Assets/PlayMaker/Editor/PlayMakerBugReportWindow.cs new file mode 100755 index 0000000..7764cf6 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerBugReportWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class PlayMakerBugReportWindow : BugReportWindow + { + } +} diff --git a/Assets/PlayMaker/Editor/PlayMakerBugReportWindow.cs.meta b/Assets/PlayMaker/Editor/PlayMakerBugReportWindow.cs.meta new file mode 100755 index 0000000..ac11d44 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerBugReportWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 22cdf5625c9e93d439b35c8a41b2fcd6 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerBuildCallbacks.cs b/Assets/PlayMaker/Editor/PlayMakerBuildCallbacks.cs new file mode 100755 index 0000000..bb3cfdd --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerBuildCallbacks.cs @@ -0,0 +1,43 @@ +using System.Linq; +using HutongGames.PlayMaker; +using UnityEngine; +using UnityEditor; +using UnityEditor.Callbacks; + +namespace HutongGames.PlayMakerEditor +{ + public class PlayMakerBuildCallbacks + { + [PostProcessSceneAttribute(2)] + public static void OnPostprocessScene() + { + /* TODO: Figure out if we need to do this! + // OnPostprocessScene is called when loading a scene in the editor + // Might not want to post process in that case...? + if (EditorApplication.isPlayingOrWillChangePlaymode) + { + return; + }*/ + + //Debug.Log("OnPostprocessScene"); + + PlayMakerGlobals.IsBuilding = true; + PlayMakerGlobals.InitApplicationFlags(); + + var fsmList = Resources.FindObjectsOfTypeAll(); + foreach (var playMakerFSM in fsmList) + { + //Debug.Log(FsmEditorUtility.GetFullFsmLabel(playMakerFSM)); + + if (!Application.isPlaying) // actually making a build vs playing in editor + { + playMakerFSM.Preprocess(); + } + } + + PlayMakerGlobals.IsBuilding = false; + + //Debug.Log("EndPostProcessScene"); + } + } +} diff --git a/Assets/PlayMaker/Editor/PlayMakerBuildCallbacks.cs.meta b/Assets/PlayMaker/Editor/PlayMakerBuildCallbacks.cs.meta new file mode 100755 index 0000000..69025f2 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerBuildCallbacks.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5faf00404eefa01429c8d0918b082392 +timeCreated: 1429984733 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/PlayMakerCustomActionWizard.cs b/Assets/PlayMaker/Editor/PlayMakerCustomActionWizard.cs new file mode 100755 index 0000000..747ff38 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerCustomActionWizard.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class PlayMakerCustomActionWizard : CustomActionWizard + { + } +} diff --git a/Assets/PlayMaker/Editor/PlayMakerCustomActionWizard.cs.meta b/Assets/PlayMaker/Editor/PlayMakerCustomActionWizard.cs.meta new file mode 100755 index 0000000..5c8e656 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerCustomActionWizard.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8fbcfa086edb590469238e90b390b2bc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerEditor.dll b/Assets/PlayMaker/Editor/PlayMakerEditor.dll new file mode 100755 index 0000000..c74201b Binary files /dev/null and b/Assets/PlayMaker/Editor/PlayMakerEditor.dll differ diff --git a/Assets/PlayMaker/Editor/PlayMakerEditor.dll.mdb b/Assets/PlayMaker/Editor/PlayMakerEditor.dll.mdb new file mode 100755 index 0000000..6d490d0 Binary files /dev/null and b/Assets/PlayMaker/Editor/PlayMakerEditor.dll.mdb differ diff --git a/Assets/PlayMaker/Editor/PlayMakerEditor.dll.mdb.meta b/Assets/PlayMaker/Editor/PlayMakerEditor.dll.mdb.meta new file mode 100755 index 0000000..a87039a --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerEditor.dll.mdb.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 676b95d8233a4f74699272b34a47277b +DefaultImporter: + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerEditor.dll.meta b/Assets/PlayMaker/Editor/PlayMakerEditor.dll.meta new file mode 100755 index 0000000..a8b4ade --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerEditor.dll.meta @@ -0,0 +1,18 @@ +fileFormatVersion: 2 +guid: 336aa50a81ce85b47b50a7b6adf85a76 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 1 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/PlayMakerEditorResources.dll b/Assets/PlayMaker/Editor/PlayMakerEditorResources.dll new file mode 100755 index 0000000..c3b19bd Binary files /dev/null and b/Assets/PlayMaker/Editor/PlayMakerEditorResources.dll differ diff --git a/Assets/PlayMaker/Editor/PlayMakerEditorResources.dll.meta b/Assets/PlayMaker/Editor/PlayMakerEditorResources.dll.meta new file mode 100755 index 0000000..4972b0d --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerEditorResources.dll.meta @@ -0,0 +1,18 @@ +fileFormatVersion: 2 +guid: 2856d9e072e50c74c8b18fe7f33db5f1 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 1 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/PlayMakerGUIInspector.cs b/Assets/PlayMaker/Editor/PlayMakerGUIInspector.cs new file mode 100755 index 0000000..2fd17cf --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerGUIInspector.cs @@ -0,0 +1,109 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using HutongGames.PlayMakerEditor; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(PlayMakerGUI))] +class PlayMakerGUIInspector : Editor +{ + private PlayMakerGUI guiComponent; + + void OnEnable() + { + guiComponent = (PlayMakerGUI) target; + + guiComponent.drawStateLabels = EditorPrefs.GetBool(EditorPrefStrings.ShowStateLabelsInGameView); + + CheckForDuplicateComponents(); + } + + public override void OnInspectorGUI() + { +#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_2 + EditorGUIUtility.LookLikeInspector(); +#else + EditorGUIUtility.labelWidth = 210; +#endif + GUILayout.Label(Strings.Label_NOTES, EditorStyles.boldLabel); + GUILayout.Label(Strings.Hint_PlayMakerGUI_Notes); + GUILayout.Label(Strings.Label_General, EditorStyles.boldLabel); + + EditorGUI.indentLevel = 1; + + guiComponent.enableGUILayout = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Enable_GUILayout, + Strings.Tooltip_Enable_GUILayout), + guiComponent.enableGUILayout); + guiComponent.controlMouseCursor = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Control_Mouse_Cursor, + Strings.Tooltip_Control_Mouse_Cursor), + guiComponent.controlMouseCursor); + + guiComponent.previewOnGUI = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Preview_GUI_Actions_While_Editing, Strings.Tooltip_Preview_GUI_Actions_While_Editing), guiComponent.previewOnGUI); + + EditorGUI.indentLevel = 0; + GUILayout.Label(Strings.Label_Debugging, EditorStyles.boldLabel); + EditorGUI.indentLevel = 1; + + var drawStateLabels = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Draw_Active_State_Labels, Strings.Tooltip_Draw_Active_State_Labels), guiComponent.drawStateLabels); + + if (drawStateLabels != guiComponent.drawStateLabels) + { + guiComponent.drawStateLabels = drawStateLabels; + EditorPrefs.SetBool(EditorPrefStrings.ShowStateLabelsInGameView, drawStateLabels); + } + + GUI.enabled = guiComponent.drawStateLabels; + //EditorGUI.indentLevel = 2; + + guiComponent.GUITextureStateLabels = EditorGUILayout.Toggle(new GUIContent(Strings.Label_GUITexture_State_Labels, Strings.Tooltip_GUITexture_State_Labels), guiComponent.GUITextureStateLabels); + guiComponent.GUITextStateLabels = EditorGUILayout.Toggle(new GUIContent(Strings.Label_GUIText_State_Labels, Strings.Tooltip_GUIText_State_Labels), guiComponent.GUITextStateLabels); + + GUI.enabled = true; + //EditorGUI.indentLevel = 1; + + guiComponent.filterLabelsWithDistance = EditorGUILayout.Toggle(new GUIContent(Strings.Label_Filter_State_Labels_With_Distance, Strings.Tooltip_Filter_State_Labels_With_Distance), guiComponent.filterLabelsWithDistance); + + GUI.enabled = guiComponent.filterLabelsWithDistance; + + guiComponent.maxLabelDistance = EditorGUILayout.FloatField(new GUIContent(Strings.Label_Camera_Distance, Strings.Tooltip_Camera_Distance), guiComponent.maxLabelDistance); + + if (GUI.changed) + { + CheckForDuplicateComponents(); + } + } + + void CheckForDuplicateComponents() + { + var components = FindObjectsOfType(typeof(PlayMakerGUI)); + + if (components.Length > 1) + { + if (EditorUtility.DisplayDialog(Strings.ProductName, Strings.Error_Multiple_PlayMakerGUI_components, Strings.Yes, Strings.No)) + { + foreach (Object component in components) + { + if (component != target) + { + var behavior = (PlayMakerGUI)component as Behaviour; + + // Delete the game object if it only has the PlayMakerGUI component? + + if (behavior.gameObject.GetComponents(typeof(Component)).Length == 2) // every game object has a transform component + { + if (EditorUtility.DisplayDialog(Strings.ProductName, string.Format(Strings.Dialog_Delete_Extra_PlayMakerGUI_GameObject, behavior.gameObject.name), Strings.Yes, Strings.No)) + { + DestroyImmediate(behavior.gameObject); + } + } + else + { + DestroyImmediate(component); + } + } + } + } + } + } + +} diff --git a/Assets/PlayMaker/Editor/PlayMakerGUIInspector.cs.meta b/Assets/PlayMaker/Editor/PlayMakerGUIInspector.cs.meta new file mode 100755 index 0000000..6e6b01b --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerGUIInspector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 09fb03dbb5f08ee439901fabf8a2e9e3 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerGlobalsInspector.cs b/Assets/PlayMaker/Editor/PlayMakerGlobalsInspector.cs new file mode 100755 index 0000000..7ece066 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerGlobalsInspector.cs @@ -0,0 +1,120 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System.Collections.Generic; +using HutongGames.PlayMaker; +using UnityEditor; +using UnityEngine; +using HutongGames.PlayMakerEditor; + +[CustomEditor(typeof(PlayMakerGlobals))] +class PlayMakerGlobalsInspector : Editor +{ + private PlayMakerGlobals globals; + private bool refresh; + + private List variableList; + + void OnEnable() + { + //Debug.Log("PlayMakerGlobalsInspector: OnEnable"); + + globals = target as PlayMakerGlobals; + + BuildVariableList(); + } + + public override void OnInspectorGUI() + { + EditorGUILayout.HelpBox(Strings.Hint_GlobalsInspector_Shows_DEFAULT_Values, MessageType.Info); + + if (refresh) + { + Refresh(); + return; + } + + GUILayout.Label(Strings.Command_Global_Variables, EditorStyles.boldLabel); + + if (variableList.Count > 0) + { + + var currentCategory = 0; + for (var index = 0; index < variableList.Count; index++) + { + var fsmVariable = variableList[index]; + var categoryID = fsmVariable.CategoryID; + if (categoryID > 0 && categoryID != currentCategory) + { + currentCategory = categoryID; + GUILayout.Label(globals.Variables.Categories[currentCategory], EditorStyles.boldLabel); + //FsmEditorGUILayout.LightDivider(); + } + + var tooltip = fsmVariable.Name; + + if (!string.IsNullOrEmpty(fsmVariable.Tooltip)) + { + tooltip += "\n" + fsmVariable.Tooltip; + } + + if (fsmVariable.Type == VariableType.Array) + { + GUILayout.Label(fsmVariable.Name); + } + fsmVariable.DoEditorGUI(new GUIContent(fsmVariable.Name, tooltip), true); + } + } + else + { + GUILayout.Label(Strings.Label_None_In_Table); + } + + GUILayout.Label(Strings.Label_Global_Events, EditorStyles.boldLabel); + + if (globals.Events.Count > 0) + { + foreach (var eventName in globals.Events) + { + GUILayout.Label(eventName); + } + } + else + { + GUILayout.Label(Strings.Label_None_In_Table); + } + + GUILayout.Space(5); + + if (GUILayout.Button("Refresh")) + { + Refresh(); + } + + GUILayout.Space(10); + + //FsmEditorGUILayout.Divider(); + + if (GUILayout.Button(Strings.Command_Export_Globals)) + { + FsmEditorUtility.ExportGlobals(); + } + + if (GUILayout.Button(Strings.Command_Import_Globals)) + { + FsmEditorUtility.ImportGlobals(); + } + EditorGUILayout.HelpBox(Strings.Hint_Export_Globals_Notes, MessageType.None); + } + + void Refresh() + { + refresh = false; + BuildVariableList(); + Repaint(); + } + + void BuildVariableList() + { + variableList = FsmVariable.GetFsmVariableList(globals); + } +} diff --git a/Assets/PlayMaker/Editor/PlayMakerGlobalsInspector.cs.meta b/Assets/PlayMaker/Editor/PlayMakerGlobalsInspector.cs.meta new file mode 100755 index 0000000..e5132f1 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerGlobalsInspector.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 194c6710abcb62f4ba17dcb7da2e0ba5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerMainMenu.cs b/Assets/PlayMaker/Editor/PlayMakerMainMenu.cs new file mode 100755 index 0000000..e84d855 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerMainMenu.cs @@ -0,0 +1,356 @@ +// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved. + +using System.ComponentModel; +using HutongGames.PlayMakerEditor; +using UnityEditor; +using UnityEngine; + +[Localizable(false)] +static class PlayMakerMainMenu +{ + // Change MenuRoot to move the Playmaker Menu + // E.g., MenuRoot = "Plugins/PlayMaker/" + private const string MenuRoot = "PlayMaker/"; + + [MenuItem(MenuRoot + "PlayMaker Editor", false, 1)] + public static void OpenFsmEditor() + { + FsmEditorWindow.OpenWindow(); + } + + #region EDITOR WINDOWS + + // priority starts at 10, leaving room for more items above + + [MenuItem(MenuRoot + "Editor Windows/FSM Browser", true)] + public static bool ValidateOpenFsmSelectorWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/FSM Browser", false, 10)] + public static void OpenFsmSelectorWindow() + { + FsmEditor.OpenFsmSelectorWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/State Browser", true)] + public static bool ValidateOpenStateSelectorWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/State Browser", false, 11)] + public static void OpenStateSelectorWindow() + { + FsmEditor.OpenStateSelectorWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/Templates Browser", true)] + public static bool ValidateOpenFsmTemplateWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Templates Browser", false, 12)] + public static void OpenFsmTemplateWindow() + { + FsmEditor.OpenFsmTemplateWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/Edit Tool Window", true)] + public static bool ValidateOpenToolWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Edit Tool Window", false, 13)] + public static void OpenToolWindow() + { + FsmEditor.OpenToolWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/Action Browser", true)] + public static bool ValidateOpenActionWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Action Browser", false, 14)] + public static void OpenActionWindow() + { + FsmEditor.OpenActionWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/Global Variables", true)] + public static bool ValidateOpenGlobalVariablesWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Global Variables", false, 15)] + public static void OpenGlobalVariablesWindow() + { + FsmEditor.OpenGlobalVariablesWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/Event Browser", true)] + public static bool ValidateOpenGlobalEventsWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Event Browser", false, 16)] + public static void OpenGlobalEventsWindow() + { + FsmEditor.OpenGlobalEventsWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/Log Window", true)] + public static bool ValidateOpenFsmLogWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Log Window", false, 17)] + public static void OpenFsmLogWindow() + { + FsmEditor.OpenFsmLogWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/Timeline Log", true)] + public static bool ValidateOpenTimelineWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Timeline Log", false, 16)] + public static void OpenTimelineWindow() + { + FsmEditor.OpenTimelineWindow(); + } + + [MenuItem(MenuRoot + "Editor Windows/Editor Log", true)] + public static bool ValidateOpenReportWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Editor Log", false, 18)] + public static void OpenReportWindow() + { + FsmEditor.OpenReportWindow(); + } + +/* Enable when window is implemeneted + [MenuItem(MenuRoot + "Editor Windows/Search", true)] + public static bool ValidateOpenSearchWindow() + { + return FsmEditorWindow.IsOpen(); + } + + [MenuItem(MenuRoot + "Editor Windows/Search", false, 19)] + public static void OpenSearchWindow() + { + FsmEditor.OpenSearchWindow(); + } +*/ + + #endregion + + #region COMPONENTS + + // priority starts at 30, leaving room for more items above + + [MenuItem(MenuRoot + "Components/Add FSM To Selected Objects", true)] + public static bool ValidateAddFsmToSelected() + { + return Selection.activeGameObject != null; + } + + [MenuItem(MenuRoot + "Components/Add FSM To Selected Objects", false, 19)] + public static void AddFsmToSelected() + { + FsmBuilder.AddFsmToSelected(); + //PlayMakerFSM playmakerFSM = Selection.activeGameObject.AddComponent(); + //FsmEditor.SelectFsm(playmakerFSM.Fsm); + } + + [MenuItem(MenuRoot + "Components/Add PlayMakerGUI to Scene", true)] + public static bool ValidateAddPlayMakerGUI() + { + return (Object.FindObjectOfType(typeof(PlayMakerGUI)) as PlayMakerGUI) == null; + } + + [MenuItem(MenuRoot + "Components/Add PlayMakerGUI to Scene", false, 20)] + public static void AddPlayMakerGUI() + { + PlayMakerGUI.Instance.enabled = true; + } + + /* Uncomment to make asset + [MenuItem("Assets/Create/PlayMakerPrefs")] + public static void CreateAsset() + { + ScriptableObjectUtility.CreateAsset(); + }*/ + + #endregion + + #region TOOLS + + [MenuItem(MenuRoot + "Tools/Load All PlayMaker Prefabs In Project", false, 25)] + public static void LoadAllPrefabsInProject() + { + var paths = FsmEditorUtility.LoadAllPrefabsInProject(); + + if (paths.Count == 0) + { + EditorUtility.DisplayDialog("Loading PlayMaker Prefabs", "No PlayMaker Prefabs Found!", "OK"); + } + else + { + EditorUtility.DisplayDialog("Loaded PlayMaker Prefabs", "Prefabs found: " + paths.Count +"\nCheck console for details...", "OK"); + } + } + + [MenuItem(MenuRoot + "Tools/Custom Action Wizard", false, 26)] + public static void CreateWizard() + { + EditorWindow.GetWindow(true); + } + + [MenuItem(MenuRoot + "Tools/Export Globals", false, 27)] + public static void ExportGlobals() + { + FsmEditorUtility.ExportGlobals(); + } + + + [MenuItem(MenuRoot + "Tools/Import Globals", false, 28)] + public static void ImportGlobals() + { + FsmEditorUtility.ImportGlobals(); + } + + [MenuItem(MenuRoot + "Tools/Documentation Helpers", false, 29)] + public static void DocHelpers() + { + EditorWindow.GetWindow(true); + } + +#if UNITY_5_0 || UNITY_5 + [MenuItem(MenuRoot + "Tools/Run AutoUpdater", false, 30)] + public static void RunAutoUpdater() + { + PlayMakerAutoUpdater.RunAutoUpdate(); + } +#endif + + #endregion + + #region DOCUMENTATION + + [MenuItem(MenuRoot + "Online Resources/HutongGames", false, 35)] + public static void HutongGames() + { + Application.OpenURL("http://www.hutonggames.com/"); + } + + [MenuItem(MenuRoot + "Online Resources/Online Manual", false, 36)] + public static void OnlineManual() + { + EditorCommands.OpenWikiHelp(); + //Application.OpenURL("https://hutonggames.fogbugz.com/default.asp?W1"); + } + + [MenuItem(MenuRoot + "Online Resources/Video Tutorials", false, 37)] + public static void VideoTutorials() + { + Application.OpenURL("http://www.screencast.com/users/HutongGames/folders/PlayMaker"); + } + + [MenuItem(MenuRoot + "Online Resources/YouTube Channel", false, 38)] + public static void YouTubeChannel() + { + Application.OpenURL("http://www.youtube.com/user/HutongGamesLLC"); + } + + [MenuItem(MenuRoot + "Online Resources/PlayMaker Forums", false, 39)] + public static void PlayMakerForum() + { + Application.OpenURL("http://hutonggames.com/playmakerforum/"); + } + + //[MenuItem(MenuRoot + "Documentation/")] + [MenuItem(MenuRoot + "Online Resources/Release Notes", false, 40)] + public static void ReleaseNotes() + { + EditorCommands.OpenWikiPage(WikiPages.ReleaseNotes); + //Application.OpenURL("https://hutonggames.fogbugz.com/default.asp?W311"); + } + + #endregion + + [MenuItem(MenuRoot + "Tools/Submit Bug Report", false, 30)] + public static void SubmitBug() + { + EditorWindow.GetWindow(true); + } + + [MenuItem(MenuRoot + "Welcome Screen", false, 45)] + public static void OpenWelcomeWindow() + { + EditorWindow.GetWindow(true); + } + + //http://u3d.as/content/hutong-games-llc/playmaker/1Az + +/* [MenuItem(MenuRoot + "Check For Updates")] + public static void CheckForUpdates() + { + AssetStore.Open("1z"); + }*/ + + /* Moved to WelcomeWindow.cs + [MenuItem(MenuRoot + "Upgrade Guide", false, 46)] + public static void OpenUpgradeGuide() + { + EditorWindow.GetWindow(true); + }*/ + + [MenuItem(MenuRoot + "About PlayMaker...", false, 47)] + public static void OpenAboutWindow() + { + EditorWindow.GetWindow(true); + } + + + #region ADDONS + + + [MenuItem(MenuRoot + "Addons/Addons Online")] + public static void OpenAddonsWiki() + { + Application.OpenURL("https://hutonggames.fogbugz.com/default.asp?W714"); + } + +#if !UNITY_5 + + /* No longer needed... + [MenuItem(MenuRoot + "Addons/BlackBerry Add-on")] + public static void GetBlackBerryAddon() + { + UnityEditorInternal.AssetStore.Open("content/10530"); + }*/ + + [MenuItem(MenuRoot + "Addons/Windows Phone 8 Add-on")] + public static void GetWindowsPhone8Addon() + { + UnityEditorInternal.AssetStore.Open("content/10602"); + } + +#endif + + #endregion +} diff --git a/Assets/PlayMaker/Editor/PlayMakerMainMenu.cs.meta b/Assets/PlayMaker/Editor/PlayMakerMainMenu.cs.meta new file mode 100755 index 0000000..115d10d --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerMainMenu.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9e54f59004df2fb4698a45143762e335 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerProjectTools.cs b/Assets/PlayMaker/Editor/PlayMakerProjectTools.cs new file mode 100755 index 0000000..8462a9d --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerProjectTools.cs @@ -0,0 +1,141 @@ +#if (UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2) +#define UNITY_PRE_5_3 +#endif + +using System.IO; +using UnityEditor; +#if !UNITY_PRE_5_3 +using UnityEditor.SceneManagement; +#endif +using UnityEngine; + +namespace HutongGames.PlayMakerEditor +{ + public class ProjectTools + { + // Change MenuRoot to move the Playmaker Menu + // E.g., MenuRoot = "Plugins/PlayMaker/" + private const string MenuRoot = "PlayMaker/"; + + [MenuItem(MenuRoot + "Tools/Update All Loaded FSMs", false, 31)] + public static void ReSaveAllLoadedFSMs() + { + SaveAllLoadedFSMs(); + } + + [MenuItem(MenuRoot + "Tools/Update All FSMs in Build", false, 32)] + public static void ReSaveAllFSMsInBuild() + { + SaveAllFSMsInBuild(); + } + + /*WIP + [MenuItem(MenuRoot + "Tools/Scan Scenes", false, 33)] + public static void ScanScenesInProject() + { + FindAllScenes(); + } +*/ + + private static void SaveAllLoadedFSMs() + { + Debug.Log("Checking loaded FSMs..."); + FsmEditor.RebuildFsmList(); + foreach (var fsm in FsmEditor.FsmList) + { + // Re-initialize loads data and forces a dirty check + // so we can just call this and let it handle dirty etc. + + fsm.Reinitialize(); + } + } + + private static void SaveAllFSMsInBuild() + { + // Allow the user to save his work! +#if UNITY_PRE_5_3 + if (!EditorApplication.SaveCurrentSceneIfUserWantsTo()) +#else + if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) +#endif + { + return; + } + + LoadPrefabsWithPlayMakerFSMComponents(); + + foreach (var scene in EditorBuildSettings.scenes) + { + Debug.Log("Open Scene: " + scene.path); +#if UNITY_PRE_5_3 + EditorApplication.OpenScene(scene.path); +#else + EditorSceneManager.OpenScene(scene.path); +#endif + SaveAllLoadedFSMs(); + +#if UNITY_PRE_5_3 + if (!EditorApplication.SaveScene()) +#else + if (!EditorSceneManager.SaveOpenScenes()) +#endif + { + Debug.LogError("Could not save scene!"); + } + } + } + + private static void LoadPrefabsWithPlayMakerFSMComponents() + { + Debug.Log("Finding Prefabs with PlayMakerFSMs"); + + var searchDirectory = new DirectoryInfo(Application.dataPath); + var prefabFiles = searchDirectory.GetFiles("*.prefab", SearchOption.AllDirectories); + + foreach (var file in prefabFiles) + { + var filePath = file.FullName.Replace(@"\", "/").Replace(Application.dataPath, "Assets"); + //Debug.Log(filePath + "\n" + Application.dataPath); + + var dependencies = AssetDatabase.GetDependencies(new[] { filePath }); + foreach (var dependency in dependencies) + { + if (dependency.Contains("/PlayMaker.dll")) + { + Debug.Log("Found Prefab with FSM: " + filePath); + AssetDatabase.LoadAssetAtPath(filePath, typeof(GameObject)); + } + } + } + + FsmEditor.RebuildFsmList(); + } + + /* WIP + [Localizable(false)] + private static void FindAllScenes() + { + Debug.Log("Finding all scenes..."); + + var searchDirectory = new DirectoryInfo(Application.dataPath); + var assetFiles = searchDirectory.GetFiles("*.unity", SearchOption.AllDirectories); + + foreach (var file in assetFiles) + { + var filePath = file.FullName.Replace(@"\", "/").Replace(Application.dataPath, "Assets"); + var obj = AssetDatabase.LoadAssetAtPath(filePath, typeof(Object)); + if (obj == null) + { + //Debug.Log(filePath + ": null!"); + } + else if (obj.GetType() == typeof(Object)) + { + Debug.Log(filePath);// + ": " + obj.GetType().FullName); + } + //var obj = AssetDatabase. + } + } + */ + } +} + diff --git a/Assets/PlayMaker/Editor/PlayMakerProjectTools.cs.meta b/Assets/PlayMaker/Editor/PlayMakerProjectTools.cs.meta new file mode 100755 index 0000000..88d5850 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerProjectTools.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c4be08eb2b7053a4c87ee457187b7806 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerUpdater.cs b/Assets/PlayMaker/Editor/PlayMakerUpdater.cs new file mode 100755 index 0000000..52f6ded --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerUpdater.cs @@ -0,0 +1,26 @@ +using HutongGames.PlayMakerEditor; +using UnityEditor; + +[InitializeOnLoad] +public class PlayMakerUpdater +{ + static PlayMakerUpdater() + { + // Delay until first update + // Otherwise process gets stomped on by other Unity initializations + // E.g., Unity loading last layout stomps on PlayMakerUpgradeGuide window. + EditorApplication.update += Update; + } + + static void Update() + { + EditorApplication.update -= Update; + + /* + var showUpgradeGuide = EditorPrefs.GetBool(EditorPrefStrings.ShowUpgradeGuide, true); + if (showUpgradeGuide) + { + EditorWindow.GetWindow(true); + }*/ + } +} diff --git a/Assets/PlayMaker/Editor/PlayMakerUpdater.cs.meta b/Assets/PlayMaker/Editor/PlayMakerUpdater.cs.meta new file mode 100755 index 0000000..9d1c0f4 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerUpdater.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f49fcf7ebc691f54982f6d23eb15f1cc +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerUpgradeGuide.cs b/Assets/PlayMaker/Editor/PlayMakerUpgradeGuide.cs new file mode 100755 index 0000000..005dc7b --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerUpgradeGuide.cs @@ -0,0 +1,77 @@ +using UnityEngine; +using UnityEditor; + +/* Moved to WelcomeWindow.cs + +namespace HutongGames.PlayMakerEditor +{ + /// + /// Shows critical upgrade info for each version + /// + public class PlayMakerUpgradeGuide : EditorWindow + { + private const string urlReleaseNotes = "https://hutonggames.fogbugz.com/default.asp?W311"; + private const string urlTroubleshooting = "https://hutonggames.fogbugz.com/default.asp?W624"; + + private bool showOnLoad; + private Vector2 scrollPosition; + + public void OnEnable() + { + title = "PlayMaker"; + position = new Rect(100,100,350,400); + minSize = new Vector2(350,200); + + showOnLoad = EditorPrefs.GetBool(EditorPrefStrings.ShowUpgradeGuide, true); + } + + public void OnGUI() + { + FsmEditorStyles.Init(); + + FsmEditorGUILayout.ToolWindowLargeTitle(this, "Upgrade Guide"); + + scrollPosition = GUILayout.BeginScrollView(scrollPosition); + + EditorGUILayout.HelpBox("Always BACKUP projects before updating!\nUse Version Control to manage changes!", MessageType.Error); + + GUILayout.Label("Version 1.8.0", EditorStyles.boldLabel); + EditorGUILayout.HelpBox("FSMs saved with 1.8.0 cannot be opened in earlier versions of PlayMaker! Please BACKUP projects!", MessageType.Warning); + + GUILayout.Label("Unity 5 Upgrade Notes", EditorStyles.boldLabel); + EditorGUILayout.HelpBox("If you run into problems updating a Unity 4.x project please check the Troubleshooting guide on the PlayMaker Wiki.", MessageType.Warning); + EditorGUILayout.HelpBox("Unity 5 removed component property shortcuts from GameObject. " + + "\n\nThe Unity auto update process replaces these properties with GetComponent calls. " + + "In many cases this is fine, but some third party actions and addons might need manual updating! " + + "Please post on the PlayMaker forums and contact the original authors for help." + + "\n\nIf you used these GameObject properties in Get Property or Set Property actions " + + "they are no longer valid, and you need to instead point to the Component directly. " + + "E.g., Drag the Component (NOT the GameObject) into the Target Object field." + + "\n", MessageType.Warning); + + GUILayout.Label("Unity 4.6 Upgrade Notes", EditorStyles.boldLabel); + EditorGUILayout.HelpBox("Find support for the new Unity GUI online in our Addons page.", MessageType.Info); + EditorGUILayout.HelpBox("PlayMakerGUI is only needed if you use OnGUI Actions. " + + "If you don't use OnGUI actions un-check Auto-Add PlayMakerGUI in PlayMaker Preferences.", MessageType.Info); + + GUILayout.EndScrollView(); + + GUILayout.FlexibleSpace(); + FsmEditorGUILayout.Divider(); + + EditorGUI.BeginChangeCheck(); + var dontShowAgain = GUILayout.Toggle(!showOnLoad, "Don't Show Again Until Next Update"); + if (EditorGUI.EndChangeCheck()) + { + showOnLoad = !dontShowAgain; + EditorPrefs.SetBool(EditorPrefStrings.ShowUpgradeGuide, showOnLoad); + } + + if (GUILayout.Button("Online Release Notes")) + { + Application.OpenURL(urlReleaseNotes); + } + } + } +} +*/ \ No newline at end of file diff --git a/Assets/PlayMaker/Editor/PlayMakerUpgradeGuide.cs.meta b/Assets/PlayMaker/Editor/PlayMakerUpgradeGuide.cs.meta new file mode 100755 index 0000000..af16e09 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerUpgradeGuide.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 97a1e109909320944b8d4357a5a09769 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerUpgradeTools.cs b/Assets/PlayMaker/Editor/PlayMakerUpgradeTools.cs new file mode 100755 index 0000000..0f1f4d4 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerUpgradeTools.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.IO; +using HutongGames.PlayMaker.Actions; +using UnityEngine; +using UnityEditor; +using HutongGames.PlayMakerEditor; + +public class PlayMakerUpgradeTools +{ + /* + // Change MenuRoot to move the Playmaker Menu + // E.g., MenuRoot = "Plugins/PlayMaker/" + private const string MenuRoot = "PlayMaker/"; + + [MenuItem(MenuRoot + "Tools/Re-Save All Loaded FSMs", false, 31)] + public static void ReSaveAllLoadedFSMs() + { + LoadPrefabsWithPlayMakerFSMComponents(); + SaveAllLoadedFSMs(); + SaveAllTemplates(); + } + + [MenuItem(MenuRoot + "Tools/Re-Save All FSMs in Build", false, 32)] + public static void ReSaveAllFSMsInBuild() + { + LoadPrefabsWithPlayMakerFSMComponents(); + SaveAllFSMsInBuild(); + SaveAllTemplates(); + } + + private static void SaveAllTemplates() + { + Debug.Log("Re-Saving All Templates..."); + + FsmEditorUtility.BuildTemplateList(); + foreach (var template in FsmEditorUtility.TemplateList) + { + FsmEditor.SetFsmDirty(template.fsm, false); + Debug.Log("Re-save Template: " + template.name); + } + } + + private static void SaveAllLoadedFSMs() + { + foreach (var fsm in FsmEditor.FsmList) + { + Debug.Log("Re-save FSM: " + FsmEditorUtility.GetFullFsmLabel(fsm)); + FsmEditor.SetFsmDirty(fsm, false); + } + } + + private static void SaveAllFSMsInBuild() + { + foreach (var scene in EditorBuildSettings.scenes) + { + Debug.Log("Open Scene: " + scene.path); + EditorApplication.OpenScene(scene.path); + FsmEditor.RebuildFsmList(); + SaveAllLoadedFSMs(); + EditorApplication.SaveScene(); + } + } + + private static void LoadPrefabsWithPlayMakerFSMComponents() + { + Debug.Log("Finding Prefabs with PlayMakerFSMs"); + + var searchDirectory = new DirectoryInfo(Application.dataPath); + var prefabFiles = searchDirectory.GetFiles("*.prefab", SearchOption.AllDirectories); + + foreach (var file in prefabFiles) + { + var filePath = file.FullName.Replace(@"\", "/").Replace(Application.dataPath, "Assets"); + //Debug.Log(filePath + "\n" + Application.dataPath); + + var dependencies = AssetDatabase.GetDependencies(new[] { filePath }); + foreach (var dependency in dependencies) + { + if (dependency.Contains("/PlayMaker.dll")) + { + Debug.Log("Found Prefab with FSM: " + filePath); + AssetDatabase.LoadAssetAtPath(filePath, typeof(GameObject)); + } + } + } + + FsmEditor.RebuildFsmList(); + } + * */ +} + diff --git a/Assets/PlayMaker/Editor/PlayMakerUpgradeTools.cs.meta b/Assets/PlayMaker/Editor/PlayMakerUpgradeTools.cs.meta new file mode 100755 index 0000000..4dc576c --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerUpgradeTools.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b2a6920d32cb98944bf2529341b9ef44 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/PlayMakerWelcomeWindow.cs b/Assets/PlayMaker/Editor/PlayMakerWelcomeWindow.cs new file mode 100644 index 0000000..d5d89c1 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerWelcomeWindow.cs @@ -0,0 +1,712 @@ +// (c) Copyright HutongGames, LLC 2010-2011. All rights reserved. + +#if (UNITY_4_3 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0) +#define UNITY_PRE_5_1 +#endif + +using System; +using UnityEditor; +using UnityEditorInternal; +using UnityEngine; + +namespace HutongGames.PlayMakerEditor +{ + /// + /// Welcome Window with getting started shortcuts + /// + [InitializeOnLoad] + public class PlayMakerWelcomeWindow : EditorWindow + { + private const string installCurrentVersion = "1.7.8.4"; + private const string installBetaVersion = "1.8.0 BETA RC35"; + + private const string editorPrefsShowAtStartup = "PlayMaker.ShowWelcomeScreen.1.7.8.4"; // Add version to ensure first time open + private const string editorPrefsSavedPage = "PlayMaker.WelcomeScreenPage"; + private const string editorPrefsShowUpgradeGuide = "PlayMaker.ShowUpgradeGuide"; + private const string urlSamples = "http://www.hutonggames.com/samples.php"; + private const string urlTutorials = "http://www.hutonggames.com/tutorials.html"; + private const string urlDocs = "https://hutonggames.fogbugz.com/default.asp?W1"; + private const string urlForums = "http://hutonggames.com/playmakerforum/index.php"; + private const string urlPhotonAddon = "https://hutonggames.fogbugz.com/default.asp?W928"; + private const string urlAddonsWiki = "https://hutonggames.fogbugz.com/default.asp?W714"; + private const string urlEcosystemWiki = "https://hutonggames.fogbugz.com/default.asp?W1181"; + //private const string urlStore = "http://www.hutonggames.com/store.html"; + //private const string photonID = "1786"; + + private const float windowWidth = 500; + private const float windowHeight = 440; + private const float pageTop = 70; + private const float pagePadding = 95; + + private static bool setupPhoton; + + private static string currentVersion; + private static string currentVersionLabel; + private static string currentVersionShort; + private static int majorVersion; // 1.8 -> 18 for easier comparisons + + private enum Page + { + Welcome = 0, + Install = 1, + GettingStarted = 2, + UpgradeGuide = 3, + Addons = 4 + } + private Page currentPage = Page.Welcome; + private Page nextPage; + private Rect currentPageRect; + private Rect nextPageRect; + private float currentPageMoveTo; + private Rect headerRect; + private Rect backButtonRect; + + private bool pageInTransition; + private float transitionStartTime; + private const float transitionDuration = 0.5f; + + private Vector2 scrollPosition; + private static bool showAtStartup; + + private static GUIStyle playMakerHeader; + private static GUIStyle labelWithWordWrap; + private static GUIStyle largeTitleWithLogo; + private static GUIStyle versionLabel; + private static Texture samplesIcon; + private static Texture docsIcon; + private static Texture videosIcon; + private static Texture forumsIcon; + private static Texture addonsIcon; + private static Texture photonIcon; + private static Texture backButton; + + private static bool stylesInitialized; + + [MenuItem("PlayMaker/Welcome Screen", false, 45)] + public static void OpenWelcomeWindow() + { + GetWindow(true); + } + + static PlayMakerWelcomeWindow() + { + EditorApplication.playmodeStateChanged -= OnPlayModeChanged; + EditorApplication.playmodeStateChanged += OnPlayModeChanged; + + showAtStartup = EditorPrefs.GetBool(editorPrefsShowAtStartup, true); + if (showAtStartup) + { + // Delay until first update + EditorApplication.update -= OpenAtStartup; + EditorApplication.update += OpenAtStartup; + } + } + + static void OnPlayModeChanged() + { + //Debug.Log("OnPlayModeChanged - remove welcome callback"); + + // don't show welcome screen on playmode change + EditorApplication.update -= OpenAtStartup; + EditorApplication.playmodeStateChanged -= OnPlayModeChanged; + } + + static void OpenAtStartup() + { + OpenWelcomeWindow(); + EditorApplication.update -= OpenAtStartup; + } + + public void OnEnable() + { +#if UNITY_PRE_5_1 + title = "Welcome To PlayMaker"; +#else + titleContent = new GUIContent("Welcome To PlayMaker"); +#endif + maxSize = new Vector2(windowWidth, windowHeight); + minSize = maxSize; + + // Try to get current playmaker version if installed + GetPlayMakerVersion(); + + // Is PlayMakerPhotonWizard available? + setupPhoton = GetType("PlayMakerPhotonWizard") != null; + + // Setup pages + + currentPageRect = new Rect(0, pageTop, windowWidth, windowHeight - pagePadding); + nextPageRect = new Rect(0, pageTop, windowWidth, windowHeight - pagePadding); + headerRect = new Rect(0, 0, windowWidth, 60); + backButtonRect = new Rect(0, windowHeight-24, 123, 24); + + // Save page to survive recompile...? + //currentPage = (Page)EditorPrefs.GetInt(editorPrefsPage, (int)Page.Welcome); + + currentPage = Page.Welcome; + + // We want to show the Upgrade Guide after installing + // However, installation forces a recompile so we save an EditorPref + + var showUpgradeGuide = EditorPrefs.GetBool(editorPrefsShowUpgradeGuide, false); + if (showUpgradeGuide) + { + //currentPage = Page.UpgradeGuide; //TODO: This was problematic, need a better solution + EditorPrefs.SetBool(editorPrefsShowUpgradeGuide, false); // reset + EditorUtility.DisplayDialog("PlayMaker", + "Please check the Upgrade Guide for more information on this release.", + "OK"); + } + + SetPage(currentPage); + Update(); + } + + private void GetPlayMakerVersion() + { + var versionInfo = GetType("HutongGames.PlayMakerEditor.VersionInfo"); + if (versionInfo != null) + { + currentVersion = versionInfo.GetMethod("GetAssemblyInformationalVersion").Invoke(null, null) as string; + if (currentVersion != null) + { + currentVersionShort = currentVersion.Substring(0, currentVersion.LastIndexOf('.')); + currentVersionLabel = "version " + currentVersionShort; + majorVersion = int.Parse(currentVersionShort.Substring(0, 3).Replace(".", "")); + } + else + { + currentVersionLabel = "version unkown"; + currentVersionShort = ""; + majorVersion = -1; + } + } + else + { + currentVersionLabel = "Not installed"; + currentVersionShort = ""; + majorVersion = -1; + } + } + + private void InitStyles() + { + if (!stylesInitialized) + { + playMakerHeader = new GUIStyle + { + normal = + { + background = Resources.Load("playMakerHeader") as Texture2D, + textColor = Color.white + }, + border = new RectOffset(253, 0, 0, 0), + }; + + largeTitleWithLogo = new GUIStyle + { + normal = + { + background = Resources.Load("logoHeader") as Texture2D, + textColor = Color.white + }, + border = new RectOffset(60, 0, 0, 0), + padding = new RectOffset(60, 0, 0, 0), + margin = new RectOffset(0, 0, 0, 0), + contentOffset = new Vector2(0, 0), + alignment = TextAnchor.MiddleLeft, + fixedHeight = 60, + fontSize = 36, + fontStyle = FontStyle.Bold, + }; + + labelWithWordWrap = new GUIStyle(EditorStyles.label) { wordWrap = true }; + versionLabel = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.LowerRight}; + + samplesIcon = (Texture) Resources.Load("linkSamples"); + videosIcon = (Texture) Resources.Load("linkVideos"); + docsIcon = (Texture) Resources.Load("linkDocs"); + forumsIcon = (Texture) Resources.Load("linkForums"); + addonsIcon = (Texture) Resources.Load("linkAddons"); + photonIcon = (Texture) Resources.Load("photonIcon"); + backButton = (Texture) Resources.Load("backButton"); + } + stylesInitialized = true; + } + + public void OnGUI() + { + InitStyles(); + + GUILayout.BeginVertical(); + + DoHeader(); + + GUILayout.BeginVertical(); + + DoPage(currentPage, currentPageRect); + + if (pageInTransition) + { + DoPage(nextPage, nextPageRect); + } + + // Bottom line + + GUILayout.FlexibleSpace(); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + + var show = GUILayout.Toggle(showAtStartup, "Show At Startup"); + if (show != showAtStartup) + { + showAtStartup = show; + EditorPrefs.SetBool(editorPrefsShowAtStartup, showAtStartup); + } + + GUILayout.Space(10); + GUILayout.EndHorizontal(); + + GUILayout.EndVertical(); + GUILayout.EndVertical(); + + if (currentPage != Page.Welcome && !pageInTransition) + { + DoBackButton(Page.Welcome); + } + } + + private void DoHeader() + { + switch (nextPage) + { + case Page.Welcome: + GUI.Box(headerRect, "", playMakerHeader); + break; + + case Page.Install: + GUI.Box(headerRect, "Installation", largeTitleWithLogo); + break; + + case Page.GettingStarted: + GUI.Box(headerRect, "Getting Started", largeTitleWithLogo); + break; + + case Page.UpgradeGuide: + GUI.Box(headerRect, "Upgrade Guide", largeTitleWithLogo); + break; + + case Page.Addons: + GUI.Box(headerRect, "Add-Ons", largeTitleWithLogo); + break; + default: + throw new ArgumentOutOfRangeException(); + } + + // Version + if (!string.IsNullOrEmpty(currentVersion) && majorVersion > 17) + { + GUI.Box(headerRect, currentVersionLabel, versionLabel); + } + + // reserve space in layout + GUILayoutUtility.GetRect(position.width, 60); + } + + private void DoPage(Page page, Rect pageRect) + { + pageRect.height = position.height - pagePadding; + GUILayout.BeginArea(pageRect); + + switch (page) + { + case Page.Welcome: + DoWelcomePage(); + break; + case Page.Install: + DoInstallPage(); + break; + case Page.GettingStarted: + DoGettingStartedPage(); + break; + case Page.UpgradeGuide: + DoUpgradeGuidePage(); + break; + case Page.Addons: + DoAddonsPage(); + break; + } + + GUILayout.EndArea(); + } + + private void DoWelcomePage() + { + GUILayout.BeginVertical(); + GUILayout.FlexibleSpace(); + + DrawLink(samplesIcon, + "Install PlayMaker", + "Import the latest version of PlayMaker.", + GotoPage, Page.Install); + + DrawLink(docsIcon, + "Upgrade Guide", + "Guide to upgrading Unity/PlayMaker.", + GotoPage, Page.UpgradeGuide); + + DrawLink(videosIcon, + "Getting Started", + "Links to samples, tutorials, forums etc.", + GotoPage, Page.GettingStarted); + + DrawLink(addonsIcon, + "Add-Ons", + "Extend PlayMaker with these powerful add-ons.", + GotoPage, Page.Addons); + + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + } + + private void DoInstallPage() + { + ShowBackupHelpBox(); + + GUILayout.BeginVertical(); + GUILayout.Space(30); + + DrawLink(samplesIcon, + "Install PlayMaker " + installCurrentVersion, + "The current official release.", + InstallLatest, null); + + DrawLink(samplesIcon, + "Install PlayMaker " + installBetaVersion, + "The latest public beta version.", + InstallBeta, null); + + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + } + + private void DoGettingStartedPage() + { + GUILayout.BeginVertical(); + GUILayout.FlexibleSpace(); + + DrawLink(samplesIcon, + "Samples", + "Download sample scenes and complete projects.", + OpenUrl, urlSamples); + + DrawLink(videosIcon, + "Tutorials", + "Watch tutorials on the PlayMaker YouTube channel.", + OpenUrl, urlTutorials); + + DrawLink(docsIcon, + "Docs", + "Browse the online manual.", + OpenUrl, urlDocs); + + DrawLink(forumsIcon, + "Forums", + "Join the PlayMaker community!", + OpenUrl, urlForums); + + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + } + + private void DoUpgradeGuidePage() + { + ShowBackupHelpBox(); + + scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); + + GUILayout.Label("Version 1.8.0", EditorStyles.boldLabel); + EditorGUILayout.HelpBox("FSMs saved with 1.8.0 cannot be opened in earlier versions of PlayMaker! Please BACKUP projects!", MessageType.Warning); + + GUILayout.Label("Unity 5 Upgrade Notes", EditorStyles.boldLabel); + EditorGUILayout.HelpBox("If you run into problems updating a Unity 4.x project please check the Troubleshooting guide on the PlayMaker Wiki.", MessageType.Warning); + EditorGUILayout.HelpBox("Unity 5 removed component property shortcuts from GameObject. " + + "\n\nThe Unity auto update process replaces these properties with GetComponent calls. " + + "In many cases this is fine, but some third party actions and addons might need manual updating! " + + "Please post on the PlayMaker forums and contact the original authors for help." + + "\n\nIf you used these GameObject properties in Get Property or Set Property actions " + + "they are no longer valid, and you need to instead point to the Component directly. " + + "E.g., Drag the Component (NOT the GameObject) into the Target Object field." + + "\n", MessageType.Warning); + + GUILayout.Label("Unity 4.6 Upgrade Notes", EditorStyles.boldLabel); + EditorGUILayout.HelpBox("Find support for the new Unity GUI online in our Addons page.", MessageType.Info); + EditorGUILayout.HelpBox("PlayMakerGUI is only needed if you use OnGUI Actions. " + + "If you don't use OnGUI actions un-check Auto-Add PlayMakerGUI in PlayMaker Preferences.", MessageType.Info); + + EditorGUILayout.EndScrollView(); + //FsmEditorGUILayout.Divider(); + } + + private void DoAddonsPage() + { + GUILayout.BeginVertical(); + GUILayout.FlexibleSpace(); + if (setupPhoton) + { + DrawLink(photonIcon, + "Photon Cloud", + "Build scalable MMOGs, FPS or any other multiplayer game " + + "and application for PC, Mac, Browser, Mobile or Console.", + LaunchPhotonSetupWizard, null); + } + else + { + DrawLink(photonIcon, + "Photon Cloud", + "Build scalable MMOGs, FPS or any other multiplayer game " + + "and application for PC, Mac, Browser, Mobile or Console.", + OpenUrl, urlPhotonAddon); + } + + DrawLink(addonsIcon, + "Ecosystem", + "An integrated online browser for custom actions, samples and addons.", + OpenUrl, urlEcosystemWiki); + + DrawLink(addonsIcon, + "Add-Ons", + "Find action packs and add-ons for NGUI, 2D Toolkit, Mecanim, Pathfinding, Smooth Moves, Ultimate FPS...", + OpenUrl, urlAddonsWiki); + + GUILayout.FlexibleSpace(); + GUILayout.EndVertical(); + + } + + private static void ShowBackupHelpBox() + { + GUILayout.BeginHorizontal(); + EditorGUILayout.HelpBox("Always BACKUP projects before updating!\nUse Version Control to manage changes!", MessageType.Error); + GUILayout.Space(5); + GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal(); + EditorGUILayout.HelpBox("With Unity 5.3 please install the 1.8.0 Beta Version to address compatibility issues!", MessageType.Error); + GUILayout.Space(5); + GUILayout.EndHorizontal(); + } + + private static void DrawLink(Texture texture, string heading, string body, LinkFunction func, object userData) + { + GUILayout.BeginHorizontal(); + + GUILayout.Space(64); + GUILayout.Box(texture, GUIStyle.none, GUILayout.MaxWidth(48)); + GUILayout.Space(10); + + GUILayout.BeginVertical(); + GUILayout.Space(1); + GUILayout.Label(heading, EditorStyles.boldLabel); + GUILayout.Label(body, labelWithWordWrap); + GUILayout.EndVertical(); + + GUILayout.EndHorizontal(); + + var rect = GUILayoutUtility.GetLastRect(); + EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link); + + if (Event.current.type == EventType.mouseDown && rect.Contains(Event.current.mousePosition)) + { + func(userData); + } + + GUILayout.Space(10); + } + + private void DoBackButton(Page toPage) + { + GUI.Box(backButtonRect, backButton, GUIStyle.none); + EditorGUIUtility.AddCursorRect(backButtonRect, MouseCursor.Link); + + if (Event.current.type == EventType.mouseDown && backButtonRect.Contains(Event.current.mousePosition)) + { + GotoPage(toPage); + GUIUtility.ExitGUI(); + } + } + + void Update() + { + if (pageInTransition) + { + DoPageTransition(); + } + } + + void DoPageTransition() + { + var t = (Time.realtimeSinceStartup - transitionStartTime) / transitionDuration; + if (t > 1f) + { + SetPage(nextPage); + return; + } + + var nextPageX = Mathf.SmoothStep(nextPageRect.x, 0, t); + var currentPageX = Mathf.SmoothStep(currentPageRect.x, currentPageMoveTo, t); + currentPageRect.Set(currentPageX, pageTop, windowWidth, position.height); + nextPageRect.Set(nextPageX, pageTop, windowWidth, position.height); + + Repaint(); + } + + bool DisplayInstallDialog(string versionInfo, string notes) + { + return EditorUtility.DisplayDialog("PlayMaker", "Install PlayMaker " + versionInfo + "\n" + + notes + "\n\nAlways backup projects before updating Unity or PlayMaker!", + "I Made a Backup. Go Ahead!", "Cancel"); + } + + // Button actions: + + public delegate void LinkFunction(object userData); + + private void InstallLatest(object userData) + { + if (majorVersion > 17 && EditorUtility.DisplayDialog("PlayMaker", "This project uses a newer version of PlayMaker not compatible with 1.7.8.4. Installing 1.7.8.4 is NOT a good idea!", "Cancel", "Do it anyway!")) + { + return; + } + + if (DisplayInstallDialog(installCurrentVersion, "The latest release version of PlayMaker.")) + { + EditorPrefs.SetBool(editorPrefsShowUpgradeGuide, true); + //ImportPackage("Assets/PlayMaker/Editor/Install/PlayMaker.1.7.8.4.unitypackage"); + // Use GUID in case user has moved Playmaker folder + ImportPackage(AssetDatabase.GUIDToAssetPath("dd583cbbf618ba54983cdf396b28e49b")); + } + } + + private void InstallBeta(object userData) + { + if (DisplayInstallDialog(installBetaVersion, "The latest BETA version of PlayMaker." + + "\n\nNOTE: Projects saved with PlayMaker 1.8.0 cannot be opened in older versions of PlayMaker!")) + { + EditorPrefs.SetBool(editorPrefsShowUpgradeGuide, true); + //ImportPackage("Assets/PlayMaker/Editor/Install/PlayMaker.1.8.0.unitypackage"); + // Use GUID in case user has moved Playmaker folder + ImportPackage(AssetDatabase.GUIDToAssetPath("f982487afa4f0444ea11e90a9d05b94e")); + } + } + + private void ImportPackage(string package) + { + try + { + AssetDatabase.ImportPackage(package, true); + } + catch (Exception) + { + Debug.LogError("Failed to import package: " + package); + throw; + } + + // This didn't work that well + // Instead let the user open the upgrade guide + //GotoPage(Page.UpgradeGuide); + } + + private void LaunchPhotonSetupWizard(object userData) + { + GetType("PlayMakerPhotonWizard").GetMethod("Init").Invoke(null, null); + } + + private void OpenUrl(object userData) + { + Application.OpenURL(userData as string); + } + + public void OpenInAssetStore(object userData) + { + AssetStore.Open("content/" + userData); + } + + private void GotoPage(object userData) + { + nextPage = (Page)userData; + pageInTransition = true; + transitionStartTime = Time.realtimeSinceStartup; + + // next page slides in from the right + // welcome screen slides offscreen left + // reversed if returning to the welcome screen + + if (nextPage == Page.Welcome) + { + nextPageRect.x = -windowWidth; + currentPageMoveTo = windowWidth; + } + else + { + nextPageRect.x = windowWidth; + currentPageMoveTo = -windowWidth; + } + + GUIUtility.ExitGUI(); + } + + private void SetPage(Page page) + { + currentPage = page; + nextPage = page; + pageInTransition = false; + currentPageRect.x = 0; + SaveCurrentPage(); + Repaint(); + } + + private void SaveCurrentPage() + { + EditorPrefs.SetInt(editorPrefsSavedPage, (int)currentPage); + } + + // Normally we would use ReflectionUtils.GetGlobalType but this window now needs to be standalone + // Instead of copy/pasting ReflectionUtils, decided to try this code from UnityAnswers: + // http://answers.unity3d.com/questions/206665/typegettypestring-does-not-work-in-unity.html + public static Type GetType(string typeName) + { + // Try Type.GetType() first. This will work with types defined + // by the Mono runtime, in the same assembly as the caller, etc. + var type = Type.GetType(typeName); + + // If it worked, then we're done here + if (type != null) + return type; + + // otherwise look in loaded assemblies + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + type = assembly.GetType(typeName); + if (type != null) + { + break; + } + } + + return type; + } + + public static Type FindTypeInLoadedAssemblies(string typeName) + { + Type _type = null; + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + _type = assembly.GetType(typeName); + if (_type != null) + break; + } + + return _type; + } + } +} \ No newline at end of file diff --git a/Assets/PlayMaker/Editor/PlayMakerWelcomeWindow.cs.meta b/Assets/PlayMaker/Editor/PlayMakerWelcomeWindow.cs.meta new file mode 100644 index 0000000..3dc4139 --- /dev/null +++ b/Assets/PlayMaker/Editor/PlayMakerWelcomeWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ae09cdaf80f2e864094117640e60c154 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/ReportWindow.cs b/Assets/PlayMaker/Editor/ReportWindow.cs new file mode 100755 index 0000000..f5184b7 --- /dev/null +++ b/Assets/PlayMaker/Editor/ReportWindow.cs @@ -0,0 +1,16 @@ +// (c) Copyright HutongGames, LLC 2010-2014. All rights reserved. + +/* NOTE: Wrapper no longer needed in Unity 4.x + * BUT: changing it breaks saved layouts + * SO: wrap in namespace instead (supported in 4.x) + */ + +// EditorWindow classes can't be called from a dll in Unity 3.5 +// so create a thin wrapper class as a workaround + +namespace HutongGames.PlayMakerEditor +{ + internal class ReportWindow : ActionReportWindow + { + } +} diff --git a/Assets/PlayMaker/Editor/ReportWindow.cs.meta b/Assets/PlayMaker/Editor/ReportWindow.cs.meta new file mode 100755 index 0000000..25e9817 --- /dev/null +++ b/Assets/PlayMaker/Editor/ReportWindow.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e5b4c89f3fd08e04b9ed418f84a2b234 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Editor/Resources.meta b/Assets/PlayMaker/Editor/Resources.meta new file mode 100644 index 0000000..ddb238a --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 693ddbf47b4954681a41b7532be10ee7 +folderAsset: yes +timeCreated: 1449957738 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Resources/backButton.png b/Assets/PlayMaker/Editor/Resources/backButton.png new file mode 100644 index 0000000..9c1c8a9 Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/backButton.png differ diff --git a/Assets/PlayMaker/Editor/Resources/backButton.png.meta b/Assets/PlayMaker/Editor/Resources/backButton.png.meta new file mode 100644 index 0000000..21a7672 --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/backButton.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: ac6641fa8d46a2d408fc356b1018cb57 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Resources/linkAddons.png b/Assets/PlayMaker/Editor/Resources/linkAddons.png new file mode 100755 index 0000000..1b3e714 Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/linkAddons.png differ diff --git a/Assets/PlayMaker/Editor/Resources/linkAddons.png.meta b/Assets/PlayMaker/Editor/Resources/linkAddons.png.meta new file mode 100755 index 0000000..86eace7 --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/linkAddons.png.meta @@ -0,0 +1,53 @@ +fileFormatVersion: 2 +guid: f06fcb30f18e9c446afa65d01a0546aa +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Resources/linkDocs.png b/Assets/PlayMaker/Editor/Resources/linkDocs.png new file mode 100755 index 0000000..2e05ba9 Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/linkDocs.png differ diff --git a/Assets/PlayMaker/Editor/Resources/linkDocs.png.meta b/Assets/PlayMaker/Editor/Resources/linkDocs.png.meta new file mode 100755 index 0000000..a8abe10 --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/linkDocs.png.meta @@ -0,0 +1,53 @@ +fileFormatVersion: 2 +guid: 249f22c45e9765d4987844b99808d255 +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Resources/linkForums.png b/Assets/PlayMaker/Editor/Resources/linkForums.png new file mode 100755 index 0000000..101f147 Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/linkForums.png differ diff --git a/Assets/PlayMaker/Editor/Resources/linkForums.png.meta b/Assets/PlayMaker/Editor/Resources/linkForums.png.meta new file mode 100755 index 0000000..02f9195 --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/linkForums.png.meta @@ -0,0 +1,53 @@ +fileFormatVersion: 2 +guid: 1f42c8e9076b1c04297aee75ba4c08ef +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Resources/linkSamples.png b/Assets/PlayMaker/Editor/Resources/linkSamples.png new file mode 100755 index 0000000..aa42922 Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/linkSamples.png differ diff --git a/Assets/PlayMaker/Editor/Resources/linkSamples.png.meta b/Assets/PlayMaker/Editor/Resources/linkSamples.png.meta new file mode 100755 index 0000000..5759374 --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/linkSamples.png.meta @@ -0,0 +1,53 @@ +fileFormatVersion: 2 +guid: 7b8554e124fc8af40a2db0b397c948d3 +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Resources/linkVideos.png b/Assets/PlayMaker/Editor/Resources/linkVideos.png new file mode 100755 index 0000000..927e0f9 Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/linkVideos.png differ diff --git a/Assets/PlayMaker/Editor/Resources/linkVideos.png.meta b/Assets/PlayMaker/Editor/Resources/linkVideos.png.meta new file mode 100755 index 0000000..b6f4917 --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/linkVideos.png.meta @@ -0,0 +1,53 @@ +fileFormatVersion: 2 +guid: be820321bac88af4a8ffb854af44fa57 +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Resources/logoHeader.png b/Assets/PlayMaker/Editor/Resources/logoHeader.png new file mode 100644 index 0000000..10310bf Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/logoHeader.png differ diff --git a/Assets/PlayMaker/Editor/Resources/logoHeader.png.meta b/Assets/PlayMaker/Editor/Resources/logoHeader.png.meta new file mode 100644 index 0000000..5669cd4 --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/logoHeader.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 40756bd2cf522954aa7350177e615933 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Resources/photonIcon.png b/Assets/PlayMaker/Editor/Resources/photonIcon.png new file mode 100755 index 0000000..fcb372e Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/photonIcon.png differ diff --git a/Assets/PlayMaker/Editor/Resources/photonIcon.png.meta b/Assets/PlayMaker/Editor/Resources/photonIcon.png.meta new file mode 100755 index 0000000..806f7de --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/photonIcon.png.meta @@ -0,0 +1,53 @@ +fileFormatVersion: 2 +guid: bb4f5fdd6b52a4942b26179f4e9aed45 +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Resources/playMakerHeader.png b/Assets/PlayMaker/Editor/Resources/playMakerHeader.png new file mode 100755 index 0000000..358fc30 Binary files /dev/null and b/Assets/PlayMaker/Editor/Resources/playMakerHeader.png differ diff --git a/Assets/PlayMaker/Editor/Resources/playMakerHeader.png.meta b/Assets/PlayMaker/Editor/Resources/playMakerHeader.png.meta new file mode 100755 index 0000000..b943168 --- /dev/null +++ b/Assets/PlayMaker/Editor/Resources/playMakerHeader.png.meta @@ -0,0 +1,53 @@ +fileFormatVersion: 2 +guid: de9664222f1ad9d4ab391905753fb1bb +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + linearTexture: 1 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -3 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: 1 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 2 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Watermarks.meta b/Assets/PlayMaker/Editor/Watermarks.meta new file mode 100644 index 0000000..cc32b5f --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1396b31800589452da448624d692d3e6 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/Watermarks/Alien.png b/Assets/PlayMaker/Editor/Watermarks/Alien.png new file mode 100755 index 0000000..ce45858 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Alien.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Alien.png.meta b/Assets/PlayMaker/Editor/Watermarks/Alien.png.meta new file mode 100755 index 0000000..0e70e55 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Alien.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 24dda0ac7b175944f8968586045fbe32 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/AnalogClock.png b/Assets/PlayMaker/Editor/Watermarks/AnalogClock.png new file mode 100755 index 0000000..02055e1 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/AnalogClock.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/AnalogClock.png.meta b/Assets/PlayMaker/Editor/Watermarks/AnalogClock.png.meta new file mode 100755 index 0000000..0544e11 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/AnalogClock.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 6a9f8cb89f6f3dc408b1097092f17c9d +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Bang.png b/Assets/PlayMaker/Editor/Watermarks/Bang.png new file mode 100755 index 0000000..934cec9 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Bang.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Bang.png.meta b/Assets/PlayMaker/Editor/Watermarks/Bang.png.meta new file mode 100755 index 0000000..b2988f1 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Bang.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: ac2f9ada26884da4588ffae7d1e8121f +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Barrel.png b/Assets/PlayMaker/Editor/Watermarks/Barrel.png new file mode 100755 index 0000000..5021dd9 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Barrel.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Barrel.png.meta b/Assets/PlayMaker/Editor/Watermarks/Barrel.png.meta new file mode 100755 index 0000000..02e36c0 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Barrel.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 569db1eca6acd1c4c893aa44b7aaeed7 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Bomb.png b/Assets/PlayMaker/Editor/Watermarks/Bomb.png new file mode 100755 index 0000000..4e3d422 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Bomb.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Bomb.png.meta b/Assets/PlayMaker/Editor/Watermarks/Bomb.png.meta new file mode 100755 index 0000000..afd670c --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Bomb.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 08bc5569fa12d2542b2db6b9fb27116c +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Broadcast.png b/Assets/PlayMaker/Editor/Watermarks/Broadcast.png new file mode 100755 index 0000000..800ccdc Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Broadcast.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Broadcast.png.meta b/Assets/PlayMaker/Editor/Watermarks/Broadcast.png.meta new file mode 100755 index 0000000..21e0e63 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Broadcast.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 531bf6557d7e6ea458ffc5f3908c6aa4 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Camera.png b/Assets/PlayMaker/Editor/Watermarks/Camera.png new file mode 100755 index 0000000..a1cb6f7 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Camera.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Camera.png.meta b/Assets/PlayMaker/Editor/Watermarks/Camera.png.meta new file mode 100755 index 0000000..c0cad03 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Camera.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: d4ed99101f3eb6f43a823a0e8b129218 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/ComboLock.png b/Assets/PlayMaker/Editor/Watermarks/ComboLock.png new file mode 100755 index 0000000..13a7974 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/ComboLock.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/ComboLock.png.meta b/Assets/PlayMaker/Editor/Watermarks/ComboLock.png.meta new file mode 100755 index 0000000..990b1a3 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/ComboLock.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 5bf966fb3b71a8a45a0ed828c86c6f38 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Crosshairs.png b/Assets/PlayMaker/Editor/Watermarks/Crosshairs.png new file mode 100755 index 0000000..0c463f4 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Crosshairs.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Crosshairs.png.meta b/Assets/PlayMaker/Editor/Watermarks/Crosshairs.png.meta new file mode 100755 index 0000000..87784cf --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Crosshairs.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: efb53602b01d8a14488b1124b167ec43 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Cycle.png b/Assets/PlayMaker/Editor/Watermarks/Cycle.png new file mode 100755 index 0000000..cb95c85 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Cycle.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Cycle.png.meta b/Assets/PlayMaker/Editor/Watermarks/Cycle.png.meta new file mode 100755 index 0000000..7d17a6e --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Cycle.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: ee577a066ea5e0942be6879c7e58fb38 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Dagger.png b/Assets/PlayMaker/Editor/Watermarks/Dagger.png new file mode 100755 index 0000000..b6629f1 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Dagger.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Dagger.png.meta b/Assets/PlayMaker/Editor/Watermarks/Dagger.png.meta new file mode 100755 index 0000000..84f56c5 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Dagger.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 8982a70e0d297f240a3f18e317812ec5 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Database.png b/Assets/PlayMaker/Editor/Watermarks/Database.png new file mode 100755 index 0000000..ad4b96e Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Database.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Database.png.meta b/Assets/PlayMaker/Editor/Watermarks/Database.png.meta new file mode 100755 index 0000000..be4cc89 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Database.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 4d438feaad25a6848b6008e957685bee +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Dazzle.png b/Assets/PlayMaker/Editor/Watermarks/Dazzle.png new file mode 100755 index 0000000..96a1086 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Dazzle.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Dazzle.png.meta b/Assets/PlayMaker/Editor/Watermarks/Dazzle.png.meta new file mode 100755 index 0000000..6516d54 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Dazzle.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 3e872e3452d8cf04aa5ac4b31e442167 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Dog.png b/Assets/PlayMaker/Editor/Watermarks/Dog.png new file mode 100755 index 0000000..29de1b3 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Dog.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Dog.png.meta b/Assets/PlayMaker/Editor/Watermarks/Dog.png.meta new file mode 100755 index 0000000..fdf26cf --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Dog.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 662b000d02a94844cab8343d1fb50b61 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Download.png b/Assets/PlayMaker/Editor/Watermarks/Download.png new file mode 100755 index 0000000..c433a7e Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Download.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Download.png.meta b/Assets/PlayMaker/Editor/Watermarks/Download.png.meta new file mode 100755 index 0000000..a2fdb0f --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Download.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: d80f9af5080f82042a9fa0ca83cd7e30 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Explosion.png b/Assets/PlayMaker/Editor/Watermarks/Explosion.png new file mode 100755 index 0000000..a7bd6a0 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Explosion.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Explosion.png.meta b/Assets/PlayMaker/Editor/Watermarks/Explosion.png.meta new file mode 100755 index 0000000..d5ca05c --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Explosion.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 5d1d437313aa5b44784afaeac8402377 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/GUISlider.png b/Assets/PlayMaker/Editor/Watermarks/GUISlider.png new file mode 100755 index 0000000..9f8c1da Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/GUISlider.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/GUISlider.png.meta b/Assets/PlayMaker/Editor/Watermarks/GUISlider.png.meta new file mode 100755 index 0000000..4ca536f --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/GUISlider.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: dc6822d89dddd4741b77cc4b63547f35 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/GUISliders.png b/Assets/PlayMaker/Editor/Watermarks/GUISliders.png new file mode 100755 index 0000000..6e59e15 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/GUISliders.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/GUISliders.png.meta b/Assets/PlayMaker/Editor/Watermarks/GUISliders.png.meta new file mode 100755 index 0000000..83cde38 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/GUISliders.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 73c31bb9f7592bc4ead5550c71e3e0a6 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Heart.png b/Assets/PlayMaker/Editor/Watermarks/Heart.png new file mode 100755 index 0000000..1057793 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Heart.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Heart.png.meta b/Assets/PlayMaker/Editor/Watermarks/Heart.png.meta new file mode 100755 index 0000000..6baabf1 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Heart.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 89e0806aa7a8e0c499ce3d53e19ab1bd +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Hierarchy.png b/Assets/PlayMaker/Editor/Watermarks/Hierarchy.png new file mode 100755 index 0000000..999231d Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Hierarchy.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Hierarchy.png.meta b/Assets/PlayMaker/Editor/Watermarks/Hierarchy.png.meta new file mode 100755 index 0000000..e7957bb --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Hierarchy.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: d60582facecebbc4e8db4390938f171f +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Hourglass.png b/Assets/PlayMaker/Editor/Watermarks/Hourglass.png new file mode 100755 index 0000000..2a3a832 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Hourglass.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Hourglass.png.meta b/Assets/PlayMaker/Editor/Watermarks/Hourglass.png.meta new file mode 100755 index 0000000..e19645e --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Hourglass.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 8d47ca498d459d64da7f40c4e0e6ebc1 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Info.png b/Assets/PlayMaker/Editor/Watermarks/Info.png new file mode 100755 index 0000000..91a30fe Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Info.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Info.png.meta b/Assets/PlayMaker/Editor/Watermarks/Info.png.meta new file mode 100755 index 0000000..8c9f0f0 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Info.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: e916f404af82731418d593ba28c1d354 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Key.png b/Assets/PlayMaker/Editor/Watermarks/Key.png new file mode 100755 index 0000000..8c16d99 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Key.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Key.png.meta b/Assets/PlayMaker/Editor/Watermarks/Key.png.meta new file mode 100755 index 0000000..3239d48 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Key.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: f66e9dd8406b6fd43b861cebe995f540 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/LeftArrow.png b/Assets/PlayMaker/Editor/Watermarks/LeftArrow.png new file mode 100755 index 0000000..c97e155 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/LeftArrow.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/LeftArrow.png.meta b/Assets/PlayMaker/Editor/Watermarks/LeftArrow.png.meta new file mode 100755 index 0000000..b698dc3 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/LeftArrow.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 612841212d163524b8d286d96a5d25d3 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/LightBulb.png b/Assets/PlayMaker/Editor/Watermarks/LightBulb.png new file mode 100755 index 0000000..a88bac7 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/LightBulb.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/LightBulb.png.meta b/Assets/PlayMaker/Editor/Watermarks/LightBulb.png.meta new file mode 100755 index 0000000..2f20b83 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/LightBulb.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: f52ce8280d679ff43a1a2d67e204d670 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/LightningBolt.png b/Assets/PlayMaker/Editor/Watermarks/LightningBolt.png new file mode 100755 index 0000000..5e4d8f3 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/LightningBolt.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/LightningBolt.png.meta b/Assets/PlayMaker/Editor/Watermarks/LightningBolt.png.meta new file mode 100755 index 0000000..14bdec3 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/LightningBolt.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: c1c4109fb586c6343863b4077298090c +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Loop.png b/Assets/PlayMaker/Editor/Watermarks/Loop.png new file mode 100755 index 0000000..36bd616 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Loop.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Loop.png.meta b/Assets/PlayMaker/Editor/Watermarks/Loop.png.meta new file mode 100755 index 0000000..a8bf658 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Loop.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 07134a7e6508040408a9d1f24eb1579e +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/LoopArrow.png b/Assets/PlayMaker/Editor/Watermarks/LoopArrow.png new file mode 100755 index 0000000..3e4d7e4 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/LoopArrow.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/LoopArrow.png.meta b/Assets/PlayMaker/Editor/Watermarks/LoopArrow.png.meta new file mode 100755 index 0000000..c9302a8 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/LoopArrow.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 1d125810f8e143941a4e463c25f62614 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Microphone.png b/Assets/PlayMaker/Editor/Watermarks/Microphone.png new file mode 100755 index 0000000..50ab6fc Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Microphone.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Microphone.png.meta b/Assets/PlayMaker/Editor/Watermarks/Microphone.png.meta new file mode 100755 index 0000000..d9c11ef --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Microphone.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 9e676d4570d532c438b913bf934579f6 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Missiles.png b/Assets/PlayMaker/Editor/Watermarks/Missiles.png new file mode 100755 index 0000000..63149c1 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Missiles.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Missiles.png.meta b/Assets/PlayMaker/Editor/Watermarks/Missiles.png.meta new file mode 100755 index 0000000..b15af81 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Missiles.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 38568907486107c47aa3094fd28757b5 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/MoneyBag.png b/Assets/PlayMaker/Editor/Watermarks/MoneyBag.png new file mode 100755 index 0000000..86a439c Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/MoneyBag.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/MoneyBag.png.meta b/Assets/PlayMaker/Editor/Watermarks/MoneyBag.png.meta new file mode 100755 index 0000000..9fb0cfe --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/MoneyBag.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 20fef5b4a54567348ae4652da2868204 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/MushroomCloud.png b/Assets/PlayMaker/Editor/Watermarks/MushroomCloud.png new file mode 100755 index 0000000..6b66f60 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/MushroomCloud.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/MushroomCloud.png.meta b/Assets/PlayMaker/Editor/Watermarks/MushroomCloud.png.meta new file mode 100755 index 0000000..82faaa9 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/MushroomCloud.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: b6610169865943f47b0cf7c97de4c201 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Music.png b/Assets/PlayMaker/Editor/Watermarks/Music.png new file mode 100755 index 0000000..2421065 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Music.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Music.png.meta b/Assets/PlayMaker/Editor/Watermarks/Music.png.meta new file mode 100755 index 0000000..3af74a8 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Music.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: f0e5750071221f64285d55ce8fb67296 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/OpenBox.png b/Assets/PlayMaker/Editor/Watermarks/OpenBox.png new file mode 100755 index 0000000..533ab42 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/OpenBox.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/OpenBox.png.meta b/Assets/PlayMaker/Editor/Watermarks/OpenBox.png.meta new file mode 100755 index 0000000..424f9cc --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/OpenBox.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 916e944e848448c47b38203b7c06a13a +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Player.png b/Assets/PlayMaker/Editor/Watermarks/Player.png new file mode 100755 index 0000000..1eb6e8b Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Player.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Player.png.meta b/Assets/PlayMaker/Editor/Watermarks/Player.png.meta new file mode 100755 index 0000000..a4bb802 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Player.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: d6fff8f37b41c2c4f9ad1d4682bd0744 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/PlayerBroadcast.png b/Assets/PlayMaker/Editor/Watermarks/PlayerBroadcast.png new file mode 100755 index 0000000..0dbc1d6 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/PlayerBroadcast.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/PlayerBroadcast.png.meta b/Assets/PlayMaker/Editor/Watermarks/PlayerBroadcast.png.meta new file mode 100755 index 0000000..8c3b076 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/PlayerBroadcast.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 54eed67d7d084f149bcc5dcfaaa7ed50 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Players.png b/Assets/PlayMaker/Editor/Watermarks/Players.png new file mode 100755 index 0000000..6594d58 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Players.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Players.png.meta b/Assets/PlayMaker/Editor/Watermarks/Players.png.meta new file mode 100755 index 0000000..afc636b --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Players.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 0cf2f0ec912e15e448197f6fb900be70 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Postcard.png b/Assets/PlayMaker/Editor/Watermarks/Postcard.png new file mode 100755 index 0000000..894b1b6 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Postcard.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Postcard.png.meta b/Assets/PlayMaker/Editor/Watermarks/Postcard.png.meta new file mode 100755 index 0000000..99c67cf --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Postcard.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 1bb3725e0549a0f4fba48a76e52b3faf +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/PowerOn.png b/Assets/PlayMaker/Editor/Watermarks/PowerOn.png new file mode 100755 index 0000000..c55bc43 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/PowerOn.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/PowerOn.png.meta b/Assets/PlayMaker/Editor/Watermarks/PowerOn.png.meta new file mode 100755 index 0000000..bf3b274 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/PowerOn.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: c44def74e220813499b0ef77f81f47b1 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Recycle.png b/Assets/PlayMaker/Editor/Watermarks/Recycle.png new file mode 100755 index 0000000..a9a3929 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Recycle.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Recycle.png.meta b/Assets/PlayMaker/Editor/Watermarks/Recycle.png.meta new file mode 100755 index 0000000..d553142 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Recycle.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 3754686a58be853478158a0568fc527b +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Rows.png b/Assets/PlayMaker/Editor/Watermarks/Rows.png new file mode 100755 index 0000000..a113d12 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Rows.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Rows.png.meta b/Assets/PlayMaker/Editor/Watermarks/Rows.png.meta new file mode 100755 index 0000000..0226a23 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Rows.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 3bc1fb38ffb4f2145afbb92ae706f329 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/SemiCircle.png b/Assets/PlayMaker/Editor/Watermarks/SemiCircle.png new file mode 100755 index 0000000..2db37c1 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/SemiCircle.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/SemiCircle.png.meta b/Assets/PlayMaker/Editor/Watermarks/SemiCircle.png.meta new file mode 100755 index 0000000..4ebd1ea --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/SemiCircle.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 3b339d97a27c1a1439a73fa626c7d28e +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Settings.png b/Assets/PlayMaker/Editor/Watermarks/Settings.png new file mode 100755 index 0000000..2820f89 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Settings.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Settings.png.meta b/Assets/PlayMaker/Editor/Watermarks/Settings.png.meta new file mode 100755 index 0000000..a7d2026 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Settings.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 51295292c735b8f49a7375d64ab91633 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/SkullAndCrossBones.png b/Assets/PlayMaker/Editor/Watermarks/SkullAndCrossBones.png new file mode 100755 index 0000000..600f354 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/SkullAndCrossBones.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/SkullAndCrossBones.png.meta b/Assets/PlayMaker/Editor/Watermarks/SkullAndCrossBones.png.meta new file mode 100755 index 0000000..172b305 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/SkullAndCrossBones.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 2fb754eb26b03ab4598fdabac6f0def0 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Soldier.png b/Assets/PlayMaker/Editor/Watermarks/Soldier.png new file mode 100755 index 0000000..204a4f4 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Soldier.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Soldier.png.meta b/Assets/PlayMaker/Editor/Watermarks/Soldier.png.meta new file mode 100755 index 0000000..71554b4 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Soldier.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: bff7060f1f2727849802c10aa29eab8b +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/SpeechBubbleRound.png b/Assets/PlayMaker/Editor/Watermarks/SpeechBubbleRound.png new file mode 100755 index 0000000..164332a Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/SpeechBubbleRound.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/SpeechBubbleRound.png.meta b/Assets/PlayMaker/Editor/Watermarks/SpeechBubbleRound.png.meta new file mode 100755 index 0000000..ce96c1c --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/SpeechBubbleRound.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 6313de4f7cb6a4a44804c898b1677488 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/SpeechBubbles.png b/Assets/PlayMaker/Editor/Watermarks/SpeechBubbles.png new file mode 100755 index 0000000..6943057 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/SpeechBubbles.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/SpeechBubbles.png.meta b/Assets/PlayMaker/Editor/Watermarks/SpeechBubbles.png.meta new file mode 100755 index 0000000..2b5ce88 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/SpeechBubbles.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 4a613549877ab9d4e88665fda6bd5575 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Splatter.png b/Assets/PlayMaker/Editor/Watermarks/Splatter.png new file mode 100755 index 0000000..850098c Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Splatter.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Splatter.png.meta b/Assets/PlayMaker/Editor/Watermarks/Splatter.png.meta new file mode 100755 index 0000000..2c7edf6 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Splatter.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: e59f4826bdaf827438ab5e2dbe1401ea +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Spy.png b/Assets/PlayMaker/Editor/Watermarks/Spy.png new file mode 100755 index 0000000..fc1fef7 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Spy.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Spy.png.meta b/Assets/PlayMaker/Editor/Watermarks/Spy.png.meta new file mode 100755 index 0000000..3b47f33 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Spy.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 178a16288adc2374b8aa385180efe2c8 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Star.png b/Assets/PlayMaker/Editor/Watermarks/Star.png new file mode 100755 index 0000000..2e8bade Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Star.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Star.png.meta b/Assets/PlayMaker/Editor/Watermarks/Star.png.meta new file mode 100755 index 0000000..88646d7 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Star.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 7e0f318a0de14754ea96e57b7da9bdbf +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/StarInCircle.png b/Assets/PlayMaker/Editor/Watermarks/StarInCircle.png new file mode 100755 index 0000000..7bcacde Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/StarInCircle.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/StarInCircle.png.meta b/Assets/PlayMaker/Editor/Watermarks/StarInCircle.png.meta new file mode 100755 index 0000000..0af14a3 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/StarInCircle.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: d06d066acbe641949a1dbabc7a5de36f +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Stars.png b/Assets/PlayMaker/Editor/Watermarks/Stars.png new file mode 100755 index 0000000..436abef Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Stars.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Stars.png.meta b/Assets/PlayMaker/Editor/Watermarks/Stars.png.meta new file mode 100755 index 0000000..3921f49 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Stars.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 66c5fc677b40c1f4a8bcac247d468660 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/ThoughtBubble.png b/Assets/PlayMaker/Editor/Watermarks/ThoughtBubble.png new file mode 100755 index 0000000..29cf9d2 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/ThoughtBubble.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/ThoughtBubble.png.meta b/Assets/PlayMaker/Editor/Watermarks/ThoughtBubble.png.meta new file mode 100755 index 0000000..a196f45 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/ThoughtBubble.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: f218ed29f9b2ba042b5b00c2bc3ac412 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Timer.png b/Assets/PlayMaker/Editor/Watermarks/Timer.png new file mode 100755 index 0000000..58aa309 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Timer.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Timer.png.meta b/Assets/PlayMaker/Editor/Watermarks/Timer.png.meta new file mode 100755 index 0000000..077913c --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Timer.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 7f48cf158f652204599f9718da5fc8b5 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/Upload.png b/Assets/PlayMaker/Editor/Watermarks/Upload.png new file mode 100755 index 0000000..682ac60 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/Upload.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/Upload.png.meta b/Assets/PlayMaker/Editor/Watermarks/Upload.png.meta new file mode 100755 index 0000000..221a7da --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/Upload.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 816c57d588a2ae143a0e1f9e5029eadb +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/WorldWireframe.png b/Assets/PlayMaker/Editor/Watermarks/WorldWireframe.png new file mode 100755 index 0000000..91e7dee Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/WorldWireframe.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/WorldWireframe.png.meta b/Assets/PlayMaker/Editor/Watermarks/WorldWireframe.png.meta new file mode 100755 index 0000000..6d59833 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/WorldWireframe.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 15306e0de1b3a0046b1fd3c5dc399ef9 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/Watermarks/playMakerLogo.png b/Assets/PlayMaker/Editor/Watermarks/playMakerLogo.png new file mode 100755 index 0000000..9926da0 Binary files /dev/null and b/Assets/PlayMaker/Editor/Watermarks/playMakerLogo.png differ diff --git a/Assets/PlayMaker/Editor/Watermarks/playMakerLogo.png.meta b/Assets/PlayMaker/Editor/Watermarks/playMakerLogo.png.meta new file mode 100755 index 0000000..0281914 --- /dev/null +++ b/Assets/PlayMaker/Editor/Watermarks/playMakerLogo.png.meta @@ -0,0 +1,45 @@ +fileFormatVersion: 2 +guid: 39389ad5c03bbaf4cb3903a9a7349bb9 +TextureImporter: + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 1024 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: diff --git a/Assets/PlayMaker/Editor/de.meta b/Assets/PlayMaker/Editor/de.meta new file mode 100644 index 0000000..bdd7e3a --- /dev/null +++ b/Assets/PlayMaker/Editor/de.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1ff4396805a784fd4a5b7e5aa97e1123 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/de/PlayMakerEditor.de.resources.dll b/Assets/PlayMaker/Editor/de/PlayMakerEditor.de.resources.dll new file mode 100755 index 0000000..84236a2 Binary files /dev/null and b/Assets/PlayMaker/Editor/de/PlayMakerEditor.de.resources.dll differ diff --git a/Assets/PlayMaker/Editor/de/PlayMakerEditor.de.resources.dll.meta b/Assets/PlayMaker/Editor/de/PlayMakerEditor.de.resources.dll.meta new file mode 100755 index 0000000..d709687 --- /dev/null +++ b/Assets/PlayMaker/Editor/de/PlayMakerEditor.de.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 95b145b64a3889b4ca78f8100839c9dc +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/es-ES.meta b/Assets/PlayMaker/Editor/es-ES.meta new file mode 100644 index 0000000..58f0a15 --- /dev/null +++ b/Assets/PlayMaker/Editor/es-ES.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 788a59a6a549442b7b54ae5ebd92d001 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/es-ES/PlayMakerEditor.es-ES.resources.dll b/Assets/PlayMaker/Editor/es-ES/PlayMakerEditor.es-ES.resources.dll new file mode 100755 index 0000000..11b98c8 Binary files /dev/null and b/Assets/PlayMaker/Editor/es-ES/PlayMakerEditor.es-ES.resources.dll differ diff --git a/Assets/PlayMaker/Editor/es-ES/PlayMakerEditor.es-ES.resources.dll.meta b/Assets/PlayMaker/Editor/es-ES/PlayMakerEditor.es-ES.resources.dll.meta new file mode 100755 index 0000000..b77a347 --- /dev/null +++ b/Assets/PlayMaker/Editor/es-ES/PlayMakerEditor.es-ES.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 519359e55debe8845a68a0e0ff935e16 +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/fr.meta b/Assets/PlayMaker/Editor/fr.meta new file mode 100644 index 0000000..42d383f --- /dev/null +++ b/Assets/PlayMaker/Editor/fr.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d2a0a98d5e8ac430899ca79919eae7ef +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/fr/PlayMakerEditor.fr.resources.dll b/Assets/PlayMaker/Editor/fr/PlayMakerEditor.fr.resources.dll new file mode 100755 index 0000000..c8e0780 Binary files /dev/null and b/Assets/PlayMaker/Editor/fr/PlayMakerEditor.fr.resources.dll differ diff --git a/Assets/PlayMaker/Editor/fr/PlayMakerEditor.fr.resources.dll.meta b/Assets/PlayMaker/Editor/fr/PlayMakerEditor.fr.resources.dll.meta new file mode 100755 index 0000000..43d1e26 --- /dev/null +++ b/Assets/PlayMaker/Editor/fr/PlayMakerEditor.fr.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e47236d35f408df498a319746efab596 +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/it.meta b/Assets/PlayMaker/Editor/it.meta new file mode 100644 index 0000000..150987d --- /dev/null +++ b/Assets/PlayMaker/Editor/it.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9b20fa95123024233b9c6e9102c5b049 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/it/PlayMakerEditor.it.resources.dll b/Assets/PlayMaker/Editor/it/PlayMakerEditor.it.resources.dll new file mode 100755 index 0000000..ea85fb0 Binary files /dev/null and b/Assets/PlayMaker/Editor/it/PlayMakerEditor.it.resources.dll differ diff --git a/Assets/PlayMaker/Editor/it/PlayMakerEditor.it.resources.dll.meta b/Assets/PlayMaker/Editor/it/PlayMakerEditor.it.resources.dll.meta new file mode 100755 index 0000000..4684ac8 --- /dev/null +++ b/Assets/PlayMaker/Editor/it/PlayMakerEditor.it.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7000414ace5effa4cab99f751c0ddc65 +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/ja.meta b/Assets/PlayMaker/Editor/ja.meta new file mode 100644 index 0000000..43359b7 --- /dev/null +++ b/Assets/PlayMaker/Editor/ja.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7593782ea78754caa858224e6c02017d +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/ja/PlayMakerEditor.ja.resources.dll b/Assets/PlayMaker/Editor/ja/PlayMakerEditor.ja.resources.dll new file mode 100755 index 0000000..9c2d8e2 Binary files /dev/null and b/Assets/PlayMaker/Editor/ja/PlayMakerEditor.ja.resources.dll differ diff --git a/Assets/PlayMaker/Editor/ja/PlayMakerEditor.ja.resources.dll.meta b/Assets/PlayMaker/Editor/ja/PlayMakerEditor.ja.resources.dll.meta new file mode 100755 index 0000000..25a9f48 --- /dev/null +++ b/Assets/PlayMaker/Editor/ja/PlayMakerEditor.ja.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d3f0148c4d46a0b4a95d717f910900a5 +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/nl.meta b/Assets/PlayMaker/Editor/nl.meta new file mode 100644 index 0000000..54999ed --- /dev/null +++ b/Assets/PlayMaker/Editor/nl.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a7fcae85768414e1ba31f9920c7b76d8 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/nl/PlayMakerEditor.nl.resources.dll b/Assets/PlayMaker/Editor/nl/PlayMakerEditor.nl.resources.dll new file mode 100755 index 0000000..7d52484 Binary files /dev/null and b/Assets/PlayMaker/Editor/nl/PlayMakerEditor.nl.resources.dll differ diff --git a/Assets/PlayMaker/Editor/nl/PlayMakerEditor.nl.resources.dll.meta b/Assets/PlayMaker/Editor/nl/PlayMakerEditor.nl.resources.dll.meta new file mode 100755 index 0000000..7259504 --- /dev/null +++ b/Assets/PlayMaker/Editor/nl/PlayMakerEditor.nl.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bab910be097f3e24fbf4e77451ea6b24 +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/pt-BR.meta b/Assets/PlayMaker/Editor/pt-BR.meta new file mode 100644 index 0000000..f165d76 --- /dev/null +++ b/Assets/PlayMaker/Editor/pt-BR.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c4ae364fe33d84a369969b972ccb7dc2 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/pt-BR/PlayMakerEditor.pt-BR.resources.dll b/Assets/PlayMaker/Editor/pt-BR/PlayMakerEditor.pt-BR.resources.dll new file mode 100755 index 0000000..208cb3e Binary files /dev/null and b/Assets/PlayMaker/Editor/pt-BR/PlayMakerEditor.pt-BR.resources.dll differ diff --git a/Assets/PlayMaker/Editor/pt-BR/PlayMakerEditor.pt-BR.resources.dll.meta b/Assets/PlayMaker/Editor/pt-BR/PlayMakerEditor.pt-BR.resources.dll.meta new file mode 100755 index 0000000..b783e1a --- /dev/null +++ b/Assets/PlayMaker/Editor/pt-BR/PlayMakerEditor.pt-BR.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 72db74579eb0aa24aaf2989374f99303 +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/sv-SE.meta b/Assets/PlayMaker/Editor/sv-SE.meta new file mode 100644 index 0000000..5ef37b4 --- /dev/null +++ b/Assets/PlayMaker/Editor/sv-SE.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8b85f3b35061d47bd80bf570278afaaa +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/sv-SE/PlayMakerEditor.sv-SE.resources.dll b/Assets/PlayMaker/Editor/sv-SE/PlayMakerEditor.sv-SE.resources.dll new file mode 100755 index 0000000..1a6a484 Binary files /dev/null and b/Assets/PlayMaker/Editor/sv-SE/PlayMakerEditor.sv-SE.resources.dll differ diff --git a/Assets/PlayMaker/Editor/sv-SE/PlayMakerEditor.sv-SE.resources.dll.meta b/Assets/PlayMaker/Editor/sv-SE/PlayMakerEditor.sv-SE.resources.dll.meta new file mode 100755 index 0000000..b0f3173 --- /dev/null +++ b/Assets/PlayMaker/Editor/sv-SE/PlayMakerEditor.sv-SE.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9bf7a4151eb9ade47a2d9f8607773b80 +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/zh-CN.meta b/Assets/PlayMaker/Editor/zh-CN.meta new file mode 100644 index 0000000..7f2bafa --- /dev/null +++ b/Assets/PlayMaker/Editor/zh-CN.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: bbf53be5b7ab44e2ea428a4e18600891 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/zh-CN/PlayMakerEditor.zh-CN.resources.dll b/Assets/PlayMaker/Editor/zh-CN/PlayMakerEditor.zh-CN.resources.dll new file mode 100755 index 0000000..d87bbd6 Binary files /dev/null and b/Assets/PlayMaker/Editor/zh-CN/PlayMakerEditor.zh-CN.resources.dll differ diff --git a/Assets/PlayMaker/Editor/zh-CN/PlayMakerEditor.zh-CN.resources.dll.meta b/Assets/PlayMaker/Editor/zh-CN/PlayMakerEditor.zh-CN.resources.dll.meta new file mode 100755 index 0000000..2dcbbee --- /dev/null +++ b/Assets/PlayMaker/Editor/zh-CN/PlayMakerEditor.zh-CN.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 45cf97bfa74384b41b4ed44acdce63da +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Editor/zh-TW.meta b/Assets/PlayMaker/Editor/zh-TW.meta new file mode 100644 index 0000000..d750f8e --- /dev/null +++ b/Assets/PlayMaker/Editor/zh-TW.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0840cefb61d674d1fb6575081b333c86 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Editor/zh-TW/PlayMakerEditor.zh-TW.resources.dll b/Assets/PlayMaker/Editor/zh-TW/PlayMakerEditor.zh-TW.resources.dll new file mode 100755 index 0000000..3dc440b Binary files /dev/null and b/Assets/PlayMaker/Editor/zh-TW/PlayMakerEditor.zh-TW.resources.dll differ diff --git a/Assets/PlayMaker/Editor/zh-TW/PlayMakerEditor.zh-TW.resources.dll.meta b/Assets/PlayMaker/Editor/zh-TW/PlayMakerEditor.zh-TW.resources.dll.meta new file mode 100755 index 0000000..3351d2d --- /dev/null +++ b/Assets/PlayMaker/Editor/zh-TW/PlayMakerEditor.zh-TW.resources.dll.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3741839e25a749b4b96666c2d7d391b2 +MonoAssemblyImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + userData: diff --git a/Assets/PlayMaker/Include.meta b/Assets/PlayMaker/Include.meta new file mode 100644 index 0000000..054efa4 --- /dev/null +++ b/Assets/PlayMaker/Include.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 60c681600cec1444484c28a375a79405 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Include/iTweenFSMEvents.cs b/Assets/PlayMaker/Include/iTweenFSMEvents.cs new file mode 100755 index 0000000..b196679 --- /dev/null +++ b/Assets/PlayMaker/Include/iTweenFSMEvents.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using System.Collections; +using HutongGames.PlayMaker; +using HutongGames.PlayMaker.Actions; + +public class iTweenFSMEvents : MonoBehaviour { + static public int itweenIDCount = 0; + public int itweenID = 0; + public iTweenFsmAction itweenFSMAction = null; + public bool donotfinish = false; + public bool islooping = false; + + void iTweenOnStart(int aniTweenID){ + if(itweenID == aniTweenID){ + itweenFSMAction.Fsm.Event(itweenFSMAction.startEvent); + } + } + + void iTweenOnComplete(int aniTweenID){ + if(itweenID == aniTweenID) { + if(islooping) { + if(!donotfinish){ + itweenFSMAction.Fsm.Event(itweenFSMAction.finishEvent); + itweenFSMAction.Finish(); + } + } else { + itweenFSMAction.Fsm.Event(itweenFSMAction.finishEvent); + itweenFSMAction.Finish(); + } + } + } +} + +public enum iTweenFSMType{ + all, + move, + rotate, + scale, + shake, + position, + value, + look +} diff --git a/Assets/PlayMaker/Include/iTweenFSMEvents.cs.meta b/Assets/PlayMaker/Include/iTweenFSMEvents.cs.meta new file mode 100755 index 0000000..421ffd2 --- /dev/null +++ b/Assets/PlayMaker/Include/iTweenFSMEvents.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2ada263bcd8b3644ab1546c6f8c602be +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Readme.txt b/Assets/PlayMaker/Readme.txt new file mode 100755 index 0000000..bb0f173 --- /dev/null +++ b/Assets/PlayMaker/Readme.txt @@ -0,0 +1,43 @@ +------------------------------------------------------ +Playmaker - Visual scripting for Unity +------------------------------------------------------ + +Realize your creative vision without knowing how to program! + +PLEASE BACKUP PROJECTS BEFORE UPDATING PLAYMAKER!! + +NOTE: The Playmaker/Asset Store license is for a single user at a time. If multiple people use Playmaker, you need multiple licenses! + +------------------------------------------------------ +INSTALLATION: +------------------------------------------------------ + +To install PlayMaker simply import all files from the unitypackage. + +Sample Scenes are now a separate download at www.hutonggames.com/tutorials.html + +NOTE: IMPORT SAMPLE SCENES INTO A NEW PROJECT TO AVOID OVERWRITING YOUR PROJECT FILES!! + +------------------------------------------------------ +UPGRADE NOTES: +------------------------------------------------------ + +To Upgrade: + +- Backup your project. +- Import the latest playmaker.unitypackage. +- Restart Unity. + +Obsolete Actions: + +After updating, you may get errors about obsolete actions in your saved projects. Obsolete actions should still work, but it is recommended that you upgrade them to the suggested action. You can turn off this check in Preferences. Obsolete actions are also hidden by default in the Action Browser. You can toggle this setting in the Action Browser settings menu. + +Updated Actions: + +After loading a project/scene you may get a notification in the Unity Console that actions have changed. Open the PlayMaker Editor Log to get more info on these changes. Most of the time Actions are updated automatically, and any new parameters are given default values. However, occasionally an action is incompatible and you will need to edit its settings. The Console window lets you quickly find and fix these Actions. + +------------------------------------------------------ + +Thanks and have fun with Playmaker! + +More info at www.hutonggames.com \ No newline at end of file diff --git a/Assets/PlayMaker/Readme.txt.meta b/Assets/PlayMaker/Readme.txt.meta new file mode 100755 index 0000000..901dd6c --- /dev/null +++ b/Assets/PlayMaker/Readme.txt.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: c011a0a1ce6dd964db105e9bd924acc1 +TextScriptImporter: + userData: diff --git a/Assets/PlayMaker/Resources.meta b/Assets/PlayMaker/Resources.meta new file mode 100644 index 0000000..08227e8 --- /dev/null +++ b/Assets/PlayMaker/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c972be17312df4719b0d6d98ed0a58b1 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Resources/PlayMakerAssemblies.txt b/Assets/PlayMaker/Resources/PlayMakerAssemblies.txt new file mode 100755 index 0000000..ce70c7a --- /dev/null +++ b/Assets/PlayMaker/Resources/PlayMakerAssemblies.txt @@ -0,0 +1 @@ +UnityEngine \ No newline at end of file diff --git a/Assets/PlayMaker/Resources/PlayMakerAssemblies.txt.meta b/Assets/PlayMaker/Resources/PlayMakerAssemblies.txt.meta new file mode 100755 index 0000000..e1fd386 --- /dev/null +++ b/Assets/PlayMaker/Resources/PlayMakerAssemblies.txt.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 271632ebb8b29e443ab35c610213c392 +TextScriptImporter: + userData: diff --git a/Assets/PlayMaker/Templates.meta b/Assets/PlayMaker/Templates.meta new file mode 100644 index 0000000..bd49502 --- /dev/null +++ b/Assets/PlayMaker/Templates.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8911436908ad74693beb3c27aba4471d +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Templates/readme.txt b/Assets/PlayMaker/Templates/readme.txt new file mode 100755 index 0000000..a0e08f8 --- /dev/null +++ b/Assets/PlayMaker/Templates/readme.txt @@ -0,0 +1,3 @@ +This is the default folder for save FSM Templates. +However, you can save Templates anywhere in your Assets Folder. +In general it's a good idea to make custom folders for your own templates. \ No newline at end of file diff --git a/Assets/PlayMaker/Templates/readme.txt.meta b/Assets/PlayMaker/Templates/readme.txt.meta new file mode 100755 index 0000000..c806278 --- /dev/null +++ b/Assets/PlayMaker/Templates/readme.txt.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 03ab525144a5be94e95b4ef07529d133 +TextScriptImporter: + userData: diff --git a/Assets/PlayMaker/UpdateHelper.cs b/Assets/PlayMaker/UpdateHelper.cs new file mode 100755 index 0000000..b0994a6 --- /dev/null +++ b/Assets/PlayMaker/UpdateHelper.cs @@ -0,0 +1,39 @@ +// Small helper class to allow Fsm to call SetDirty +// Fsm is inside dll so cannot use #if UNITY_EDITOR + +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace HutongGames.PlayMaker +{ + /// + /// Playmaker runtime code can't call unity editor code + /// This class is a workaround, allowing runtime code to call EditorUtility.SetDirty + /// + public class UpdateHelper + { + public static void SetDirty(Fsm fsm) + { +#if UNITY_EDITOR + + if (fsm == null || fsm.OwnerObject == null) return; + + //Debug.Log("SetDirty: " + FsmUtility.GetFullFsmLabel(fsm)); + + fsm.Preprocessed = false; // force pre-process to run again + + if (fsm.UsedInTemplate != null) + { + EditorUtility.SetDirty(fsm.UsedInTemplate); + } + else if (fsm.Owner != null) + { + EditorUtility.SetDirty(fsm.Owner); + } + +#endif + } + } +} diff --git a/Assets/PlayMaker/UpdateHelper.cs.meta b/Assets/PlayMaker/UpdateHelper.cs.meta new file mode 100755 index 0000000..3c9d4fd --- /dev/null +++ b/Assets/PlayMaker/UpdateHelper.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3c296afe5d1d4db4793bb16e1e9f607d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/PlayMaker/Versions.meta b/Assets/PlayMaker/Versions.meta new file mode 100644 index 0000000..a7ad36e --- /dev/null +++ b/Assets/PlayMaker/Versions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 42fd12ee0e7db44419ce981c0bdb9895 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PlayMaker/Versions/PlaymakerDefault.unitypackage b/Assets/PlayMaker/Versions/PlaymakerDefault.unitypackage new file mode 100755 index 0000000..d4f1d98 Binary files /dev/null and b/Assets/PlayMaker/Versions/PlaymakerDefault.unitypackage differ diff --git a/Assets/PlayMaker/Versions/PlaymakerDefault.unitypackage.meta b/Assets/PlayMaker/Versions/PlaymakerDefault.unitypackage.meta new file mode 100755 index 0000000..ef08800 --- /dev/null +++ b/Assets/PlayMaker/Versions/PlaymakerDefault.unitypackage.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 13193f8361d6541429275feb05e0eafe +DefaultImporter: + userData: diff --git a/Assets/PlayMaker/Versions/PlaymakerNACL.unitypackage b/Assets/PlayMaker/Versions/PlaymakerNACL.unitypackage new file mode 100755 index 0000000..b200e6d Binary files /dev/null and b/Assets/PlayMaker/Versions/PlaymakerNACL.unitypackage differ diff --git a/Assets/PlayMaker/Versions/PlaymakerNACL.unitypackage.meta b/Assets/PlayMaker/Versions/PlaymakerNACL.unitypackage.meta new file mode 100755 index 0000000..bca464e --- /dev/null +++ b/Assets/PlayMaker/Versions/PlaymakerNACL.unitypackage.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: c5850d4518854f542a803dc83d3819fd +DefaultImporter: + userData: diff --git a/Assets/PlayMaker/Versions/PlaymakerPreview.unitypackage b/Assets/PlayMaker/Versions/PlaymakerPreview.unitypackage new file mode 100755 index 0000000..23f3ec3 Binary files /dev/null and b/Assets/PlayMaker/Versions/PlaymakerPreview.unitypackage differ diff --git a/Assets/PlayMaker/Versions/PlaymakerPreview.unitypackage.meta b/Assets/PlayMaker/Versions/PlaymakerPreview.unitypackage.meta new file mode 100755 index 0000000..fdaea2a --- /dev/null +++ b/Assets/PlayMaker/Versions/PlaymakerPreview.unitypackage.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: ddda830d60ad2384b8cff5d58ce815ab +DefaultImporter: + userData: diff --git a/Assets/PlayMaker/Versions/readme.txt b/Assets/PlayMaker/Versions/readme.txt new file mode 100755 index 0000000..ffcc05c --- /dev/null +++ b/Assets/PlayMaker/Versions/readme.txt @@ -0,0 +1,18 @@ +This folder contains different versions of the Playmaker DLLs. +Double click the unitypackage to import and replace the current version. + +PlaymakerDefault + +- The default DLLs. Import this to revert to the original install. + +PlaymakerNACL + +- Playmaker version for NaCL builds. +- Switch Platform to NaCL then import this package. +- NOTE: Networking actions are not supported in NaCL builds. + +PlaymakerPreview + +- A preview only version of Playmaker. Editing is disabled. +- Useful if you want to share a Playmaker project with someone who doesn't own Playmaker. +- NOTE: Please do not include the Versions folder if distributing a Preview Project! diff --git a/Assets/PlayMaker/Versions/readme.txt.meta b/Assets/PlayMaker/Versions/readme.txt.meta new file mode 100755 index 0000000..c23f771 --- /dev/null +++ b/Assets/PlayMaker/Versions/readme.txt.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: dc7b283f82187a24f83933b751b80a90 +TextScriptImporter: + userData: diff --git a/Assets/Plugins.meta b/Assets/Plugins.meta new file mode 100644 index 0000000..443abd6 --- /dev/null +++ b/Assets/Plugins.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8ba586eb5369b444c981230f1f036a7b +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker.meta b/Assets/Plugins/PlayMaker.meta new file mode 100644 index 0000000..198dbda --- /dev/null +++ b/Assets/Plugins/PlayMaker.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c2ef3c71d721c47f4a2954442de00440 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/Metro.meta b/Assets/Plugins/PlayMaker/Metro.meta new file mode 100644 index 0000000..3f5e9cb --- /dev/null +++ b/Assets/Plugins/PlayMaker/Metro.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ff6f250d37fa64fa3b921708fe378436 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll b/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll new file mode 100755 index 0000000..0888343 Binary files /dev/null and b/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll differ diff --git a/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.mdb b/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.mdb new file mode 100755 index 0000000..140f9f5 Binary files /dev/null and b/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.mdb differ diff --git a/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.mdb.meta b/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.mdb.meta new file mode 100755 index 0000000..aae429c --- /dev/null +++ b/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.mdb.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 881662afaa6d6134ea9984063201e118 +timeCreated: 1436157526 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.meta b/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.meta new file mode 100755 index 0000000..a73c830 --- /dev/null +++ b/Assets/Plugins/PlayMaker/Metro/PlayMaker.dll.meta @@ -0,0 +1,66 @@ +fileFormatVersion: 2 +guid: fd7aabeb995f6a64aa68d02891fc2294 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + WP8: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/PlayMaker.dll b/Assets/Plugins/PlayMaker/PlayMaker.dll new file mode 100755 index 0000000..1701436 Binary files /dev/null and b/Assets/Plugins/PlayMaker/PlayMaker.dll differ diff --git a/Assets/Plugins/PlayMaker/PlayMaker.dll.mdb b/Assets/Plugins/PlayMaker/PlayMaker.dll.mdb new file mode 100755 index 0000000..c130d12 Binary files /dev/null and b/Assets/Plugins/PlayMaker/PlayMaker.dll.mdb differ diff --git a/Assets/Plugins/PlayMaker/PlayMaker.dll.mdb.meta b/Assets/Plugins/PlayMaker/PlayMaker.dll.mdb.meta new file mode 100755 index 0000000..f3b2798 --- /dev/null +++ b/Assets/Plugins/PlayMaker/PlayMaker.dll.mdb.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8947321615145f64c96e04f5e0eed46b +timeCreated: 1435108459 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/PlayMaker.dll.meta b/Assets/Plugins/PlayMaker/PlayMaker.dll.meta new file mode 100755 index 0000000..7c642af --- /dev/null +++ b/Assets/Plugins/PlayMaker/PlayMaker.dll.meta @@ -0,0 +1,87 @@ +fileFormatVersion: 2 +guid: e743331561ef77147ae48cda9bcb8209 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 1 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + BlackBerry: + enabled: 1 + settings: {} + Editor: + enabled: 1 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: x86 + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: {} + OSXIntel: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: {} + WP8: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + Web: + enabled: 1 + settings: {} + WebStreamed: + enabled: 1 + settings: {} + Win: + enabled: 1 + settings: + CPU: AnyCPU + Win64: + enabled: 1 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + iOS: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + XboxOne: + enabled: 1 + settings: {} + PS4: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/WP8.meta b/Assets/Plugins/PlayMaker/WP8.meta new file mode 100644 index 0000000..581f089 --- /dev/null +++ b/Assets/Plugins/PlayMaker/WP8.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f5784ec43386340fe8ceae03e479b824 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll b/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll new file mode 100755 index 0000000..3c8edbf Binary files /dev/null and b/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll differ diff --git a/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.mdb b/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.mdb new file mode 100755 index 0000000..ff2fffe Binary files /dev/null and b/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.mdb differ diff --git a/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.mdb.meta b/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.mdb.meta new file mode 100755 index 0000000..9d689ba --- /dev/null +++ b/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.mdb.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c23ab214516ef56459b3bd90d9b1fec0 +timeCreated: 1435108459 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.meta b/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.meta new file mode 100755 index 0000000..c9cb8b6 --- /dev/null +++ b/Assets/Plugins/PlayMaker/WP8/PlayMaker.dll.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: de72a6d2da64d114d95e3c5a01cfaec5 +timeCreated: 1428085126 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + WP8: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/WebGL.meta b/Assets/Plugins/PlayMaker/WebGL.meta new file mode 100644 index 0000000..65b7bc2 --- /dev/null +++ b/Assets/Plugins/PlayMaker/WebGL.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e5755d6149f0b45b6a385b8a5f3ad757 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll b/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll new file mode 100755 index 0000000..b63b6f2 Binary files /dev/null and b/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll differ diff --git a/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.mdb b/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.mdb new file mode 100755 index 0000000..790c627 Binary files /dev/null and b/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.mdb differ diff --git a/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.mdb.meta b/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.mdb.meta new file mode 100755 index 0000000..63b049e --- /dev/null +++ b/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.mdb.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 586f10b880b6b5b4798aa26aa284bad9 +timeCreated: 1435108459 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.meta b/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.meta new file mode 100755 index 0000000..8c11f65 --- /dev/null +++ b/Assets/Plugins/PlayMaker/WebGL/PlayMaker.dll.meta @@ -0,0 +1,71 @@ +fileFormatVersion: 2 +guid: 9754d4abda502c6458053d5ed8e4fc5a +timeCreated: 1428085133 +licenseType: Pro +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Android: + enabled: 0 + settings: + CPU: AnyCPU + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 0 + settings: + CPU: x86 + Linux64: + enabled: 0 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: AnyCPU + OSXIntel64: + enabled: 0 + settings: + CPU: AnyCPU + WP8: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: AnyCPU + Win64: + enabled: 0 + settings: + CPU: AnyCPU + WindowsStoreApps: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + iOS: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/iTween.meta b/Assets/iTween.meta new file mode 100644 index 0000000..032c9ce --- /dev/null +++ b/Assets/iTween.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f913be53afbe8487eaeb3f0d2eee6dc1 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/iTween/PlayMaker.meta b/Assets/iTween/PlayMaker.meta new file mode 100644 index 0000000..e57e1d6 --- /dev/null +++ b/Assets/iTween/PlayMaker.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3a804898f93a54a6a83cbe9a61ad98ef +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/iTween/PlayMaker/Editor.meta b/Assets/iTween/PlayMaker/Editor.meta new file mode 100644 index 0000000..7b78750 --- /dev/null +++ b/Assets/iTween/PlayMaker/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ee8b7ad2cf31548d4bda7226d6f3aed4 +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/iTween/PlayMaker/Editor/iTweenMoveToActionEditor.cs b/Assets/iTween/PlayMaker/Editor/iTweenMoveToActionEditor.cs new file mode 100755 index 0000000..a439dad --- /dev/null +++ b/Assets/iTween/PlayMaker/Editor/iTweenMoveToActionEditor.cs @@ -0,0 +1,92 @@ +using HutongGames.PlayMaker.Actions; +using HutongGames.PlayMakerEditor; +using UnityEditor; +using UnityEngine; +using System.Collections; + +[CustomActionEditor(typeof(iTweenMoveTo))] +public class iTweenMoveToActionEditor : CustomActionEditor +{ + public override bool OnGUI() + { + return DrawDefaultInspector(); + } + + public override void OnSceneGUI() + { + // Live iTween path editing + + var iTween = target as iTweenMoveTo; + if (iTween == null) // shouldn't happen! + { + return; + } + + var fsm = target.Fsm; + if (fsm == null) // shouldn't happen! + { + return; + } + + if (iTween.transforms.Length >= 2) + { +#if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_2 + Undo.SetSnapshotTarget(target.Owner, Strings.Command_Adjust_iTween_Path); +#else + Undo.RecordObject(target.Owner, Strings.Command_Adjust_iTween_Path); +#endif + var tempVct3 = new Vector3[iTween.transforms.Length]; + for (var i = 0; i < iTween.transforms.Length; i++) + { + if (iTween.transforms[i].IsNone) tempVct3[i] = iTween.vectors[i].IsNone ? Vector3.zero : iTween.vectors[i].Value; + else + { + if (iTween.transforms[i].Value == null) + { + tempVct3[i] = iTween.vectors[i].IsNone ? Vector3.zero : iTween.vectors[i].Value; + } + else + { + tempVct3[i] = iTween.transforms[i].Value.transform.position + + (iTween.vectors[i].IsNone ? Vector3.zero : iTween.vectors[i].Value); + } + } + tempVct3[i] = Handles.PositionHandle(tempVct3[i], Quaternion.identity); + if (iTween.transforms[i].IsNone) + { + if (!iTween.vectors[i].IsNone) + { + iTween.vectors[i].Value = tempVct3[i]; + } + } + else + { + if (iTween.transforms[i].Value == null) + { + if (!iTween.vectors[i].IsNone) + { + iTween.vectors[i].Value = tempVct3[i]; + } + } + else + { + if (!iTween.vectors[i].IsNone) + { + iTween.vectors[i] = tempVct3[i] - iTween.transforms[i].Value.transform.position; + } + } + } + } + + Handles.Label(tempVct3[0], string.Format(Strings.iTween_Path_Editing_Label_Begin, fsm.Name)); + Handles.Label(tempVct3[tempVct3.Length - 1], string.Format(Strings.iTween_Path_Editing_Label_End, fsm.Name)); + + if (GUI.changed) + { + FsmEditor.EditingActions(); + FsmEditor.Repaint(true); + } + } + + } +} diff --git a/Assets/iTween/PlayMaker/Editor/iTweenMoveToActionEditor.cs.meta b/Assets/iTween/PlayMaker/Editor/iTweenMoveToActionEditor.cs.meta new file mode 100755 index 0000000..c37cbd3 --- /dev/null +++ b/Assets/iTween/PlayMaker/Editor/iTweenMoveToActionEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 05d82839c60c4a04ba73f881b5f74e99 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/iTween/ReadMe!.meta b/Assets/iTween/ReadMe!.meta new file mode 100644 index 0000000..2ff97e8 --- /dev/null +++ b/Assets/iTween/ReadMe!.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 733e180f6eaa54d76b5f7249766477bd +folderAsset: yes +timeCreated: 1449957901 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/iTween/ReadMe!/ReadMe!.txt b/Assets/iTween/ReadMe!/ReadMe!.txt new file mode 100755 index 0000000..7cb81d6 --- /dev/null +++ b/Assets/iTween/ReadMe!/ReadMe!.txt @@ -0,0 +1,3 @@ +iTween can be used with all scripting languages that Unity supports including JavaScript, C# and Boo. To install iTween create a folder named "Plugins" in your project's assets (if you are using C# the location of iTween does not matter as long as it is inside your assets folder). + +For complete documentation, examples and information visit: http://itween.pixelplacement.com \ No newline at end of file diff --git a/Assets/iTween/ReadMe!/ReadMe!.txt.meta b/Assets/iTween/ReadMe!/ReadMe!.txt.meta new file mode 100755 index 0000000..80080cf --- /dev/null +++ b/Assets/iTween/ReadMe!/ReadMe!.txt.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 2f94a0aae5ce048409fa25e6d617fa3e +TextScriptImporter: + userData: diff --git a/Assets/iTween/iTween.cs b/Assets/iTween/iTween.cs new file mode 100755 index 0000000..edd0303 --- /dev/null +++ b/Assets/iTween/iTween.cs @@ -0,0 +1,14969 @@ +#if UNITY_5 || UNITY_5_0 +// USE UNITY AUTO UPDATED VERSION IN UNITY 5 +// TODO: REPLACE WITH OFFICIAL UPDATE WHEN AVAILABLE + +// Copyright (c) 2011 Bob Berkebile (pixelplacment) +// Please direct any bugs/comments/suggestions to http://pixelplacement.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/* +TERMS OF USE - EASING EQUATIONS +Open source under the BSD License. +Copyright (c)2001 Robert Penner +All rights reserved. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#region Namespaces +using System; +using System.Collections; +using System.Reflection; +using UnityEngine; +#endregion + +/// +/// Version: 2.0.44 +/// Author: Bob Berkebile (http://pixelplacement.com) +/// Support: http://itween.pixelplacement.com +/// +public class iTween : MonoBehaviour{ + +#region Variables + + //repository of all living iTweens: + public static ArrayList tweens = new ArrayList(); + + //camera fade object: + private static GameObject cameraFade; + + //status members (made public for visual troubleshooting in the inspector): + public string id, type, method; + public iTween.EaseType easeType; + public float time, delay; + public LoopType loopType; + public bool isRunning,isPaused; + /* GFX47 MOD START */ + public string _name; + /* GFX47 MOD END */ + + //private members: + private float runningTime, percentage; + private float delayStarted; //probably not neccesary that this be protected but it shuts Unity's compiler up about this being "never used" + private bool kinematic, isLocal, loop, reverse, wasPaused, physics; + private Hashtable tweenArguments; + private Space space; + private delegate float EasingFunction(float start, float end, float value); + private delegate void ApplyTween(); + private EasingFunction ease; + private ApplyTween apply; + private AudioSource audioSource; + private Vector3[] vector3s; + private Vector2[] vector2s; + private Color[,] colors; + private float[] floats; + private Rect[] rects; + private CRSpline path; + private Vector3 preUpdate; + private Vector3 postUpdate; + private NamedValueColor namedcolorvalue; + + private float lastRealTime; // Added by PressPlay + private bool useRealTime; // Added by PressPlay + + /// + /// The type of easing to use based on Robert Penner's open source easing equations (http://www.robertpenner.com/easing_terms_of_use.html). + /// + public enum EaseType{ + easeInQuad, + easeOutQuad, + easeInOutQuad, + easeInCubic, + easeOutCubic, + easeInOutCubic, + easeInQuart, + easeOutQuart, + easeInOutQuart, + easeInQuint, + easeOutQuint, + easeInOutQuint, + easeInSine, + easeOutSine, + easeInOutSine, + easeInExpo, + easeOutExpo, + easeInOutExpo, + easeInCirc, + easeOutCirc, + easeInOutCirc, + linear, + spring, + /* GFX47 MOD START */ + //bounce, + easeInBounce, + easeOutBounce, + easeInOutBounce, + /* GFX47 MOD END */ + easeInBack, + easeOutBack, + easeInOutBack, + /* GFX47 MOD START */ + //elastic, + easeInElastic, + easeOutElastic, + easeInOutElastic, + /* GFX47 MOD END */ + punch + } + + /// + /// The type of loop (if any) to use. + /// + public enum LoopType{ + /// + /// Do not loop. + /// + none, + /// + /// Rewind and replay. + /// + loop, + /// + /// Ping pong the animation back and forth. + /// + pingPong + } + + /// + /// Many shaders use more than one color. Use can have iTween's Color methods operate on them by name. + /// + public enum NamedValueColor{ + /// + /// The main color of a material. Used by default and not required for Color methods to work in iTween. + /// + _Color, + /// + /// The specular color of a material (used in specular/glossy/vertexlit shaders). + /// + _SpecColor, + /// + /// The emissive color of a material (used in vertexlit shaders). + /// + _Emission, + /// + /// The reflection color of the material (used in reflective shaders). + /// + _ReflectColor + } + + #endregion + +#region Defaults + + /// + /// A collection of baseline presets that iTween needs and utilizes if certain parameters are not provided. + /// + public static class Defaults{ + //general defaults: + public static float time = 1f; + public static float delay = 0f; + public static NamedValueColor namedColorValue = NamedValueColor._Color; + public static LoopType loopType = LoopType.none; + public static EaseType easeType = iTween.EaseType.easeOutExpo; + public static float lookSpeed = 3f; + public static bool isLocal = false; + public static Space space = Space.Self; + public static bool orientToPath = false; + public static Color color = Color.white; + //update defaults: + public static float updateTimePercentage = .05f; + public static float updateTime = 1f*updateTimePercentage; + //cameraFade defaults: + public static int cameraFadeDepth = 999999; + //path look ahead amount: + public static float lookAhead = .05f; + public static bool useRealTime = false; // Added by PressPlay + //look direction: + public static Vector3 up = Vector3.up; + } + + #endregion + +#region #1 Static Registers + + /// + /// Sets up a GameObject to avoid hiccups when an initial iTween is added. It's advisable to run this on every object you intend to run iTween on in its Start or Awake. + /// + /// + /// A to be the target to be initialized for iTween. + /// + public static void Init(GameObject target){ + MoveBy(target,Vector3.zero,0); + } + + /// + /// Instantly changes the amount(transparency) of a camera fade and then returns it back over time with MINIMUM customization options. + /// + /// + /// A or for how transparent the Texture2D that the camera fade uses is. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void CameraFadeFrom(float amount, float time){ + if(cameraFade){ + CameraFadeFrom(Hash("amount",amount,"time",time)); + }else{ + Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading."); + } + } + + /// + /// Instantly changes the amount(transparency) of a camera fade and then returns it back over time with FULL customization options. + /// + /// + /// A or for how transparent the Texture2D that the camera fade uses is. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void CameraFadeFrom(Hashtable args){ + //establish iTween: + if(cameraFade){ + ColorFrom(cameraFade,args); + }else{ + Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading."); + } + } + + /// + /// Changes the amount(transparency) of a camera fade over time with MINIMUM customization options. + /// + /// + /// A or for how transparent the Texture2D that the camera fade uses is. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void CameraFadeTo(float amount, float time){ + if(cameraFade){ + CameraFadeTo(Hash("amount",amount,"time",time)); + }else{ + Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading."); + } + } + + /// + /// Changes the amount(transparency) of a camera fade over time with FULL customization options. + /// + /// + /// A or for how transparent the Texture2D that the camera fade uses is. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void CameraFadeTo(Hashtable args){ + /* + CameraFadeAdd(Defaults.cameraFadeDepth); + + //rescale cameraFade just in case screen size has changed to ensure it takes up the full screen: + cameraFade.guiTexture.pixelInset=new Rect(0,0,Screen.width,Screen.height); + */ + + if(cameraFade){ + //establish iTween: + ColorTo(cameraFade,args); + }else{ + Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading."); + } + } + + /// + /// Returns a value to an 'oncallback' method interpolated between the supplied 'from' and 'to' values for application as desired. Requires an 'onupdate' callback that accepts the same type as the supplied 'from' and 'to' properties. + /// + /// + /// A or or or or or for the starting value. + /// + /// + /// A or or or or or for the ending value. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed (only works with Vector2, Vector3, and Floats) + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ValueTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + if (!args.Contains("onupdate") || !args.Contains("from") || !args.Contains("to")) { + Debug.LogError("iTween Error: ValueTo() requires an 'onupdate' callback function and a 'from' and 'to' property. The supplied 'onupdate' callback must accept a single argument that is the same type as the supplied 'from' and 'to' properties!"); + return; + }else{ + //establish iTween: + args["type"]="value"; + + if (args["from"].GetType() == typeof(Vector2)) { + args["method"]="vector2"; + }else if (args["from"].GetType() == typeof(Vector3)) { + args["method"]="vector3"; + }else if (args["from"].GetType() == typeof(Rect)) { + args["method"]="rect"; + }else if (args["from"].GetType() == typeof(Single)) { + args["method"]="float"; + }else if (args["from"].GetType() == typeof(Color)) { + args["method"]="color"; + }else{ + Debug.LogError("iTween Error: ValueTo() only works with interpolating Vector3s, Vector2s, floats, ints, Rects and Colors!"); + return; + } + + //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + Launch(target,args); + } + } + + /// + /// Changes a GameObject's alpha value instantly then returns it to the provided alpha over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorFrom and using the "a" parameter. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final alpha value of the animation. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void FadeFrom(GameObject target, float alpha, float time){ + FadeFrom(target,Hash("alpha",alpha,"time",time)); + } + + /// + /// Changes a GameObject's alpha value instantly then returns it to the provided alpha over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorFrom and using the "a" parameter. + /// + /// + /// A or for the initial alpha value of the animation. + /// + /// + /// A or for the initial alpha value of the animation. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void FadeFrom(GameObject target, Hashtable args){ + ColorFrom(target,args); + } + + /// + /// Changes a GameObject's alpha value over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorTo and using the "a" parameter. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final alpha value of the animation. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void FadeTo(GameObject target, float alpha, float time){ + FadeTo(target,Hash("alpha",alpha,"time",time)); + } + + /// + /// Changes a GameObject's alpha value over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorTo and using the "a" parameter. + /// + /// + /// A or for the final alpha value of the animation. + /// + /// + /// A or for the final alpha value of the animation. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void FadeTo(GameObject target, Hashtable args){ + ColorTo(target,args); + } + + /// + /// Changes a GameObject's color values instantly then returns them to the provided properties over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ColorFrom(GameObject target, Color color, float time){ + ColorFrom(target,Hash("color",color,"time",time)); + } + + /// + /// Changes a GameObject's color values instantly then returns them to the provided properties over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A or for the individual setting of the color red. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ColorFrom(GameObject target, Hashtable args){ + Color fromColor = new Color(); + Color tempColor = new Color(); + + //clean args: + args = iTween.CleanArgs(args); + + //handle children: + if(!args.Contains("includechildren") || (bool)args["includechildren"]){ + foreach(Transform child in target.transform){ + Hashtable argsCopy = (Hashtable)args.Clone(); + argsCopy["ischild"]=true; + ColorFrom(child.gameObject,argsCopy); + } + } + + //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + //set tempColor and base fromColor: + if(target.GetComponent(typeof(GUITexture))){ + tempColor=fromColor=target.GetComponent().color; + }else if(target.GetComponent(typeof(GUIText))){ + tempColor=fromColor=target.GetComponent().material.color; + }else if(target.GetComponent()){ + tempColor=fromColor=target.GetComponent().material.color; + }else if(target.GetComponent()){ + tempColor=fromColor=target.GetComponent().color; + } + + //set augmented fromColor: + if(args.Contains("color")){ + fromColor=(Color)args["color"]; + }else{ + if (args.Contains("r")) { + fromColor.r=(float)args["r"]; + } + if (args.Contains("g")) { + fromColor.g=(float)args["g"]; + } + if (args.Contains("b")) { + fromColor.b=(float)args["b"]; + } + if (args.Contains("a")) { + fromColor.a=(float)args["a"]; + } + } + + //alpha or amount? + if(args.Contains("amount")){ + fromColor.a=(float)args["amount"]; + args.Remove("amount"); + }else if(args.Contains("alpha")){ + fromColor.a=(float)args["alpha"]; + args.Remove("alpha"); + } + + //apply fromColor: + if(target.GetComponent(typeof(GUITexture))){ + target.GetComponent().color=fromColor; + }else if(target.GetComponent(typeof(GUIText))){ + target.GetComponent().material.color=fromColor; + }else if(target.GetComponent()){ + target.GetComponent().material.color=fromColor; + }else if(target.GetComponent()){ + target.GetComponent().color=fromColor; + } + + //set new color arg: + args["color"]=tempColor; + + //establish iTween: + args["type"]="color"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Changes a GameObject's color values over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, they will become the target of the animation. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ColorTo(GameObject target, Color color, float time){ + ColorTo(target,Hash("color",color,"time",time)); + } + + /// + /// Changes a GameObject's color values over time with FULL customization options. If a GUIText or GUITexture component is attached, they will become the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A or for the individual setting of the color red. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ColorTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //handle children: + if(!args.Contains("includechildren") || (bool)args["includechildren"]){ + foreach(Transform child in target.transform){ + Hashtable argsCopy = (Hashtable)args.Clone(); + argsCopy["ischild"]=true; + ColorTo(child.gameObject,argsCopy); + } + } + + //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + //establish iTween: + args["type"]="color"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Instantly changes an AudioSource's volume and pitch then returns it to it's starting volume and pitch over time with MINIMUM customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied. + /// + /// + /// A to be the target of the animation which holds the AudioSource to be changed. + /// + /// for the target level of volume. + /// A + /// + /// for the target pitch. + /// A + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void AudioFrom(GameObject target, float volume, float pitch, float time){ + AudioFrom(target,Hash("volume",volume,"pitch",pitch,"time",time)); + } + + /// + /// Instantly changes an AudioSource's volume and pitch then returns it to it's starting volume and pitch over time with FULL customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied. + /// + /// + /// A for which AudioSource to use. + /// + /// + /// A or for the target level of volume. + /// + /// + /// A or for the target pitch. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void AudioFrom(GameObject target, Hashtable args){ + Vector2 tempAudioProperties; + Vector2 fromAudioProperties; + AudioSource tempAudioSource; + + //clean args: + args = iTween.CleanArgs(args); + + //set tempAudioSource: + if(args.Contains("audiosource")){ + tempAudioSource=(AudioSource)args["audiosource"]; + }else{ + if(target.GetComponent(typeof(AudioSource))){ + tempAudioSource=target.GetComponent(); + }else{ + //throw error if no AudioSource is available: + Debug.LogError("iTween Error: AudioFrom requires an AudioSource."); + return; + } + } + + //set tempAudioProperties: + tempAudioProperties.x=fromAudioProperties.x=tempAudioSource.volume; + tempAudioProperties.y=fromAudioProperties.y=tempAudioSource.pitch; + + //set augmented fromAudioProperties: + if(args.Contains("volume")){ + fromAudioProperties.x=(float)args["volume"]; + } + if(args.Contains("pitch")){ + fromAudioProperties.y=(float)args["pitch"]; + } + + //apply fromAudioProperties: + tempAudioSource.volume=fromAudioProperties.x; + tempAudioSource.pitch=fromAudioProperties.y; + + //set new volume and pitch args: + args["volume"]=tempAudioProperties.x; + args["pitch"]=tempAudioProperties.y; + + //set a default easeType of linear if none is supplied since eased audio interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + //establish iTween: + args["type"]="audio"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Fades volume and pitch of an AudioSource with MINIMUM customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied. + /// + /// + /// A to be the target of the animation which holds the AudioSource to be changed. + /// + /// for the target level of volume. + /// A + /// + /// for the target pitch. + /// A + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void AudioTo(GameObject target, float volume, float pitch, float time){ + AudioTo(target,Hash("volume",volume,"pitch",pitch,"time",time)); + } + + /// + /// Fades volume and pitch of an AudioSource with FULL customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied. + /// + /// + /// A for which AudioSource to use. + /// + /// + /// A or for the target level of volume. + /// + /// + /// A or for the target pitch. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void AudioTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //set a default easeType of linear if none is supplied since eased audio interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + //establish iTween: + args["type"]="audio"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Plays an AudioClip once based on supplied volume and pitch and following any delay with MINIMUM customization options. AudioSource is optional as iTween will provide one. + /// + /// + /// A to be the target of the animation which holds the AudioSource to be utilized. + /// + /// + /// A for a reference to the AudioClip to be played. + /// + /// + /// A for the time in seconds the action will wait before beginning. + /// + public static void Stab(GameObject target, AudioClip audioclip, float delay){ + Stab(target,Hash("audioclip",audioclip,"delay",delay)); + } + + /// + /// Plays an AudioClip once based on supplied volume and pitch and following any delay with FULL customization options. AudioSource is optional as iTween will provide one. + /// + /// + /// A for a reference to the AudioClip to be played. + /// + /// + /// A for which AudioSource to use + /// + /// + /// A or for the target level of volume. + /// + /// + /// A or for the target pitch. + /// + /// + /// A or for the time in seconds the action will wait before beginning. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void Stab(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="stab"; + Launch(target,args); + } + + /// + /// Instantly rotates a GameObject to look at the supplied Vector3 then returns it to it's starting rotation over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to be the Vector3 that the target will look towards. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void LookFrom(GameObject target, Vector3 looktarget, float time){ + LookFrom(target,Hash("looktarget",looktarget,"time",time)); + } + + /// + /// Instantly rotates a GameObject to look at a supplied Transform or Vector3 then returns it to it's starting rotation over time with FULL customization options. + /// + /// + /// A or for a target the GameObject will look at. + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void LookFrom(GameObject target, Hashtable args){ + Vector3 tempRotation; + Vector3 tempRestriction; + + //clean args: + args = iTween.CleanArgs(args); + + //set look: + tempRotation=target.transform.eulerAngles; + if (args["looktarget"].GetType() == typeof(Transform)) { + //target.transform.LookAt((Transform)args["looktarget"]); + target.transform.LookAt((Transform)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up); + }else if(args["looktarget"].GetType() == typeof(Vector3)){ + //target.transform.LookAt((Vector3)args["looktarget"]); + target.transform.LookAt((Vector3)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up); + } + + //axis restriction: + if(args.Contains("axis")){ + tempRestriction=target.transform.eulerAngles; + switch((string)args["axis"]){ + case "x": + tempRestriction.y=tempRotation.y; + tempRestriction.z=tempRotation.z; + break; + case "y": + tempRestriction.x=tempRotation.x; + tempRestriction.z=tempRotation.z; + break; + case "z": + tempRestriction.x=tempRotation.x; + tempRestriction.y=tempRotation.y; + break; + } + target.transform.eulerAngles=tempRestriction; + } + + //set new rotation: + args["rotation"] = tempRotation; + + //establish iTween + args["type"]="rotate"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Rotates a GameObject to look at the supplied Vector3 over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to be the Vector3 that the target will look towards. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void LookTo(GameObject target, Vector3 looktarget, float time){ + LookTo(target,Hash("looktarget",looktarget,"time",time)); + } + + /// + /// Rotates a GameObject to look at a supplied Transform or Vector3 over time with FULL customization options. + /// + /// + /// A or for a target the GameObject will look at. + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void LookTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //additional property to ensure ConflictCheck can work correctly since Transforms are refrences: + if(args.Contains("looktarget")){ + if (args["looktarget"].GetType() == typeof(Transform)) { + Transform transform = (Transform)args["looktarget"]; + args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z); + args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z); + } + } + + //establish iTween + args["type"]="look"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Changes a GameObject's position over time to a supplied destination with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the destination Vector3. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveTo(GameObject target, Vector3 position, float time){ + MoveTo(target,Hash("position",position,"time",time)); + } + + /// + /// Changes a GameObject's position over time to a supplied destination with FULL customization options. + /// + /// + /// A or for a point in space the GameObject will animate to. + /// + /// + /// A or for a list of points to draw a Catmull-Rom through for a curved animation path. + /// + /// + /// A for whether to automatically generate a curve from the GameObject's current position to the beginning of the path. True by default. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A or for how much of a percentage to look ahead on a path to influence how strict "orientopath" is. + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void MoveTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //additional property to ensure ConflictCheck can work correctly since Transforms are refrences: + if(args.Contains("position")){ + if (args["position"].GetType() == typeof(Transform)) { + Transform transform = (Transform)args["position"]; + args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z); + args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z); + args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z); + } + } + + //establish iTween: + args["type"]="move"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Instantly changes a GameObject's position to a supplied destination then returns it to it's starting position over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the destination Vector3. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveFrom(GameObject target, Vector3 position, float time){ + MoveFrom(target,Hash("position",position,"time",time)); + } + + /// + /// Instantly changes a GameObject's position to a supplied destination then returns it to it's starting position over time with FULL customization options. + /// + /// + /// A or for a point in space the GameObject will animate to. + /// + /// + /// A or for a list of points to draw a Catmull-Rom through for a curved animation path. + /// + /// + /// A for whether to automatically generate a curve from the GameObject's current position to the beginning of the path. True by default. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A or for how much of a percentage to look ahead on a path to influence how strict "orientopath" is. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void MoveFrom(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + bool tempIsLocal; + + //set tempIsLocal: + if(args.Contains("islocal")){ + tempIsLocal = (bool)args["islocal"]; + }else{ + tempIsLocal = Defaults.isLocal; + } + + if(args.Contains("path")){ + Vector3[] fromPath; + Vector3[] suppliedPath; + if(args["path"].GetType() == typeof(Vector3[])){ + Vector3[] temp = (Vector3[])args["path"]; + suppliedPath=new Vector3[temp.Length]; + Array.Copy(temp,suppliedPath, temp.Length); + }else{ + Transform[] temp = (Transform[])args["path"]; + suppliedPath = new Vector3[temp.Length]; + for (int i = 0; i < temp.Length; i++) { + suppliedPath[i]=temp[i].position; + } + } + if(suppliedPath[suppliedPath.Length-1] != target.transform.position){ + fromPath= new Vector3[suppliedPath.Length+1]; + Array.Copy(suppliedPath,fromPath,suppliedPath.Length); + if(tempIsLocal){ + fromPath[fromPath.Length-1] = target.transform.localPosition; + target.transform.localPosition=fromPath[0]; + }else{ + fromPath[fromPath.Length-1] = target.transform.position; + target.transform.position=fromPath[0]; + } + args["path"]=fromPath; + }else{ + if(tempIsLocal){ + target.transform.localPosition=suppliedPath[0]; + }else{ + target.transform.position=suppliedPath[0]; + } + args["path"]=suppliedPath; + } + }else{ + Vector3 tempPosition; + Vector3 fromPosition; + + //set tempPosition and base fromPosition: + if(tempIsLocal){ + tempPosition=fromPosition=target.transform.localPosition; + }else{ + tempPosition=fromPosition=target.transform.position; + } + + //set augmented fromPosition: + if(args.Contains("position")){ + if (args["position"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["position"]; + fromPosition=trans.position; + }else if(args["position"].GetType() == typeof(Vector3)){ + fromPosition=(Vector3)args["position"]; + } + }else{ + if (args.Contains("x")) { + fromPosition.x=(float)args["x"]; + } + if (args.Contains("y")) { + fromPosition.y=(float)args["y"]; + } + if (args.Contains("z")) { + fromPosition.z=(float)args["z"]; + } + } + + //apply fromPosition: + if(tempIsLocal){ + target.transform.localPosition = fromPosition; + }else{ + target.transform.position = fromPosition; + } + + //set new position arg: + args["position"]=tempPosition; + } + + //establish iTween: + args["type"]="move"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Translates a GameObject's position over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of change in position to move the GameObject. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveAdd(GameObject target, Vector3 amount, float time){ + MoveAdd(target,Hash("amount",amount,"time",time)); + } + + /// + /// Translates a GameObject's position over time with FULL customization options. + /// + /// + /// A for the amount of change in position to move the GameObject. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void MoveAdd(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="move"; + args["method"]="add"; + Launch(target,args); + } + + /// + /// Adds the supplied coordinates to a GameObject's postion with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of change in position to move the GameObject. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveBy(GameObject target, Vector3 amount, float time){ + MoveBy(target,Hash("amount",amount,"time",time)); + } + + /// + /// Adds the supplied coordinates to a GameObject's position with FULL customization options. + /// + /// + /// A for the amount of change in position to move the GameObject. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void MoveBy(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="move"; + args["method"]="by"; + Launch(target,args); + } + + /// + /// Changes a GameObject's scale over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleTo(GameObject target, Vector3 scale, float time){ + ScaleTo(target,Hash("scale",scale,"time",time)); + } + + /// + /// Changes a GameObject's scale over time with FULL customization options. + /// + /// + /// A or for the final scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ScaleTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //additional property to ensure ConflictCheck can work correctly since Transforms are refrences: + if(args.Contains("scale")){ + if (args["scale"].GetType() == typeof(Transform)) { + Transform transform = (Transform)args["scale"]; + args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z); + args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z); + args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z); + } + } + + //establish iTween: + args["type"]="scale"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Instantly changes a GameObject's scale then returns it to it's starting scale over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleFrom(GameObject target, Vector3 scale, float time){ + ScaleFrom(target,Hash("scale",scale,"time",time)); + } + + /// + /// Instantly changes a GameObject's scale then returns it to it's starting scale over time with FULL customization options. + /// + /// + /// A or for the final scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ScaleFrom(GameObject target, Hashtable args){ + Vector3 tempScale; + Vector3 fromScale; + + //clean args: + args = iTween.CleanArgs(args); + + //set base fromScale: + tempScale=fromScale=target.transform.localScale; + + //set augmented fromScale: + if(args.Contains("scale")){ + if (args["scale"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["scale"]; + fromScale=trans.localScale; + }else if(args["scale"].GetType() == typeof(Vector3)){ + fromScale=(Vector3)args["scale"]; + } + }else{ + if (args.Contains("x")) { + fromScale.x=(float)args["x"]; + } + if (args.Contains("y")) { + fromScale.y=(float)args["y"]; + } + if (args.Contains("z")) { + fromScale.z=(float)args["z"]; + } + } + + //apply fromScale: + target.transform.localScale = fromScale; + + //set new scale arg: + args["scale"]=tempScale; + + //establish iTween: + args["type"]="scale"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Adds to a GameObject's scale over time with FULL customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of scale to be added to the GameObject's current scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleAdd(GameObject target, Vector3 amount, float time){ + ScaleAdd(target,Hash("amount",amount,"time",time)); + } + + /// + /// Adds to a GameObject's scale over time with FULL customization options. + /// + /// + /// A for the amount to be added to the GameObject's current scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ScaleAdd(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="scale"; + args["method"]="add"; + Launch(target,args); + } + + /// + /// Multiplies a GameObject's scale over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of scale to be multiplied by the GameObject's current scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleBy(GameObject target, Vector3 amount, float time){ + ScaleBy(target,Hash("amount",amount,"time",time)); + } + + /// + /// Multiplies a GameObject's scale over time with FULL customization options. + /// + /// + /// A for the amount to be multiplied to the GameObject's current scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ScaleBy(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="scale"; + args["method"]="by"; + Launch(target,args); + } + + /// + /// Rotates a GameObject to the supplied Euler angles in degrees over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the target Euler angles in degrees to rotate to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateTo(GameObject target, Vector3 rotation, float time){ + RotateTo(target,Hash("rotation",rotation,"time",time)); + } + + /// + /// Rotates a GameObject to the supplied Euler angles in degrees over time with FULL customization options. + /// + /// + /// A or for the target Euler angles in degrees to rotate to. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void RotateTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //additional property to ensure ConflictCheck can work correctly since Transforms are refrences: + if(args.Contains("rotation")){ + if (args["rotation"].GetType() == typeof(Transform)) { + Transform transform = (Transform)args["rotation"]; + args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z); + args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z); + args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z); + } + } + + //establish iTween + args["type"]="rotate"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Instantly changes a GameObject's Euler angles in degrees then returns it to it's starting rotation over time (if allowed) with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the target Euler angles in degrees to rotate from. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateFrom(GameObject target, Vector3 rotation, float time){ + RotateFrom(target,Hash("rotation",rotation,"time",time)); + } + + /// + /// Instantly changes a GameObject's Euler angles in degrees then returns it to it's starting rotation over time (if allowed) with FULL customization options. + /// + /// + /// A or for the target Euler angles in degrees to rotate to. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void RotateFrom(GameObject target, Hashtable args){ + Vector3 tempRotation; + Vector3 fromRotation; + bool tempIsLocal; + + //clean args: + args = iTween.CleanArgs(args); + + //set tempIsLocal: + if(args.Contains("islocal")){ + tempIsLocal = (bool)args["islocal"]; + }else{ + tempIsLocal = Defaults.isLocal; + } + + //set tempRotation and base fromRotation: + if(tempIsLocal){ + tempRotation=fromRotation=target.transform.localEulerAngles; + }else{ + tempRotation=fromRotation=target.transform.eulerAngles; + } + + //set augmented fromRotation: + if(args.Contains("rotation")){ + if (args["rotation"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["rotation"]; + fromRotation=trans.eulerAngles; + }else if(args["rotation"].GetType() == typeof(Vector3)){ + fromRotation=(Vector3)args["rotation"]; + } + }else{ + if (args.Contains("x")) { + fromRotation.x=(float)args["x"]; + } + if (args.Contains("y")) { + fromRotation.y=(float)args["y"]; + } + if (args.Contains("z")) { + fromRotation.z=(float)args["z"]; + } + } + + //apply fromRotation: + if(tempIsLocal){ + target.transform.localEulerAngles = fromRotation; + }else{ + target.transform.eulerAngles = fromRotation; + } + + //set new rotation arg: + args["rotation"]=tempRotation; + + //establish iTween: + args["type"]="rotate"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Adds supplied Euler angles in degrees to a GameObject's rotation over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of Euler angles in degrees to add to the current rotation of the GameObject. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateAdd(GameObject target, Vector3 amount, float time){ + RotateAdd(target,Hash("amount",amount,"time",time)); + } + + /// + /// Adds supplied Euler angles in degrees to a GameObject's rotation over time with FULL customization options. + /// + /// + /// A for the amount of Euler angles in degrees to add to the current rotation of the GameObject. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void RotateAdd(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="rotate"; + args["method"]="add"; + Launch(target,args); + } + + /// + /// Multiplies supplied values by 360 and rotates a GameObject by calculated amount over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount to be multiplied by 360 to rotate the GameObject. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateBy(GameObject target, Vector3 amount, float time){ + RotateBy(target,Hash("amount",amount,"time",time)); + } + + /// + /// Multiplies supplied values by 360 and rotates a GameObject by calculated amount over time with FULL customization options. + /// + /// + /// A for the amount to be multiplied by 360 to rotate the GameObject. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void RotateBy(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="rotate"; + args["method"]="by"; + Launch(target,args); + } + + /// + /// Randomly shakes a GameObject's position by a diminishing amount over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ShakePosition(GameObject target, Vector3 amount, float time){ + ShakePosition(target,Hash("amount",amount,"time",time)); + } + + /// + /// Randomly shakes a GameObject's position by a diminishing amount over time with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ShakePosition(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="shake"; + args["method"]="position"; + Launch(target,args); + } + + /// + /// Randomly shakes a GameObject's scale by a diminishing amount over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ShakeScale(GameObject target, Vector3 amount, float time){ + ShakeScale(target,Hash("amount",amount,"time",time)); + } + + /// + /// Randomly shakes a GameObject's scale by a diminishing amount over time with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ShakeScale(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="shake"; + args["method"]="scale"; + Launch(target,args); + } + + /// + /// Randomly shakes a GameObject's rotation by a diminishing amount over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ShakeRotation(GameObject target, Vector3 amount, float time){ + ShakeRotation(target,Hash("amount",amount,"time",time)); + } + + /// + /// Randomly shakes a GameObject's rotation by a diminishing amount over time with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ShakeRotation(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="shake"; + args["method"]="rotation"; + Launch(target,args); + } + + /// + /// Applies a jolt of force to a GameObject's position and wobbles it back to its initial position with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of the punch. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void PunchPosition(GameObject target, Vector3 amount, float time){ + PunchPosition(target,Hash("amount",amount,"time",time)); + } + + /// + /// Applies a jolt of force to a GameObject's position and wobbles it back to its initial position with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget". + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void PunchPosition(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="punch"; + args["method"]="position"; + args["easetype"]=EaseType.punch; + Launch(target,args); + } + + /// + /// Applies a jolt of force to a GameObject's rotation and wobbles it back to its initial rotation with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of the punch. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void PunchRotation(GameObject target, Vector3 amount, float time){ + PunchRotation(target,Hash("amount",amount,"time",time)); + } + + /// + /// Applies a jolt of force to a GameObject's rotation and wobbles it back to its initial rotation with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void PunchRotation(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="punch"; + args["method"]="rotation"; + args["easetype"]=EaseType.punch; + Launch(target,args); + } + + /// + /// Applies a jolt of force to a GameObject's scale and wobbles it back to its initial scale with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of the punch. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void PunchScale(GameObject target, Vector3 amount, float time){ + PunchScale(target,Hash("amount",amount,"time",time)); + } + + /// + /// Applies a jolt of force to a GameObject's scale and wobbles it back to its initial scale with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void PunchScale(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="punch"; + args["method"]="scale"; + args["easetype"]=EaseType.punch; + Launch(target,args); + } + + #endregion + +#region #2 Generate Method Targets + + //call correct set target method and set tween application delegate: + void GenerateTargets(){ + switch (type) { + case "value": + switch (method) { + case "float": + GenerateFloatTargets(); + apply = new ApplyTween(ApplyFloatTargets); + break; + case "vector2": + GenerateVector2Targets(); + apply = new ApplyTween(ApplyVector2Targets); + break; + case "vector3": + GenerateVector3Targets(); + apply = new ApplyTween(ApplyVector3Targets); + break; + case "color": + GenerateColorTargets(); + apply = new ApplyTween(ApplyColorTargets); + break; + case "rect": + GenerateRectTargets(); + apply = new ApplyTween(ApplyRectTargets); + break; + } + break; + case "color": + switch (method) { + case "to": + GenerateColorToTargets(); + apply = new ApplyTween(ApplyColorToTargets); + break; + } + break; + case "audio": + switch (method) { + case "to": + GenerateAudioToTargets(); + apply = new ApplyTween(ApplyAudioToTargets); + break; + } + break; + case "move": + switch (method) { + case "to": + //using a path? + if(tweenArguments.Contains("path")){ + GenerateMoveToPathTargets(); + apply = new ApplyTween(ApplyMoveToPathTargets); + }else{ //not using a path? + GenerateMoveToTargets(); + apply = new ApplyTween(ApplyMoveToTargets); + } + break; + case "by": + case "add": + GenerateMoveByTargets(); + apply = new ApplyTween(ApplyMoveByTargets); + break; + } + break; + case "scale": + switch (method){ + case "to": + GenerateScaleToTargets(); + apply = new ApplyTween(ApplyScaleToTargets); + break; + case "by": + GenerateScaleByTargets(); + apply = new ApplyTween(ApplyScaleToTargets); + break; + case "add": + GenerateScaleAddTargets(); + apply = new ApplyTween(ApplyScaleToTargets); + break; + } + break; + case "rotate": + switch (method) { + case "to": + GenerateRotateToTargets(); + apply = new ApplyTween(ApplyRotateToTargets); + break; + case "add": + GenerateRotateAddTargets(); + apply = new ApplyTween(ApplyRotateAddTargets); + break; + case "by": + GenerateRotateByTargets(); + apply = new ApplyTween(ApplyRotateAddTargets); + break; + } + break; + case "shake": + switch (method) { + case "position": + GenerateShakePositionTargets(); + apply = new ApplyTween(ApplyShakePositionTargets); + break; + case "scale": + GenerateShakeScaleTargets(); + apply = new ApplyTween(ApplyShakeScaleTargets); + break; + case "rotation": + GenerateShakeRotationTargets(); + apply = new ApplyTween(ApplyShakeRotationTargets); + break; + } + break; + case "punch": + switch (method) { + case "position": + GeneratePunchPositionTargets(); + apply = new ApplyTween(ApplyPunchPositionTargets); + break; + case "rotation": + GeneratePunchRotationTargets(); + apply = new ApplyTween(ApplyPunchRotationTargets); + break; + case "scale": + GeneratePunchScaleTargets(); + apply = new ApplyTween(ApplyPunchScaleTargets); + break; + } + break; + case "look": + switch (method) { + case "to": + GenerateLookToTargets(); + apply = new ApplyTween(ApplyLookToTargets); + break; + } + break; + case "stab": + GenerateStabTargets(); + apply = new ApplyTween(ApplyStabTargets); + break; + } + } + + #endregion + +#region #3 Generate Specific Targets + + void GenerateRectTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + rects=new Rect[3]; + + //from and to values: + rects[0]=(Rect)tweenArguments["from"]; + rects[1]=(Rect)tweenArguments["to"]; + } + + void GenerateColorTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + colors=new Color[1,3]; + + //from and to values: + colors[0,0]=(Color)tweenArguments["from"]; + colors[0,1]=(Color)tweenArguments["to"]; + } + + void GenerateVector3Targets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from and to values: + vector3s[0]=(Vector3)tweenArguments["from"]; + vector3s[1]=(Vector3)tweenArguments["to"]; + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateVector2Targets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector2s=new Vector2[3]; + + //from and to values: + vector2s[0]=(Vector2)tweenArguments["from"]; + vector2s[1]=(Vector2)tweenArguments["to"]; + + //need for speed? + if(tweenArguments.Contains("speed")){ + Vector3 fromV3 = new Vector3(vector2s[0].x,vector2s[0].y,0); + Vector3 toV3 = new Vector3(vector2s[1].x,vector2s[1].y,0); + float distance = Math.Abs(Vector3.Distance(fromV3,toV3)); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateFloatTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + floats=new float[3]; + + //from and to values: + floats[0]=(float)tweenArguments["from"]; + floats[1]=(float)tweenArguments["to"]; + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(floats[0] - floats[1]); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateColorToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + //colors = new Color[3]; + + //from and init to values: + if(GetComponent(typeof(GUITexture))){ + colors = new Color[1,3]; + colors[0,0] = colors[0,1] = GetComponent().color; + }else if(GetComponent(typeof(GUIText))){ + colors = new Color[1,3]; + colors[0,0] = colors[0,1] = GetComponent().material.color; + }else if(GetComponent()){ + colors = new Color[GetComponent().materials.Length,3]; + for (int i = 0; i < GetComponent().materials.Length; i++) { + colors[i,0]=GetComponent().materials[i].GetColor(namedcolorvalue.ToString()); + colors[i,1]=GetComponent().materials[i].GetColor(namedcolorvalue.ToString()); + } + //colors[0] = colors[1] = renderer.material.color; + }else if(GetComponent()){ + colors = new Color[1,3]; + colors[0,0] = colors[0,1] = GetComponent().color; + }else{ + colors = new Color[1,3]; //empty placeholder incase the GO is perhaps an empty holder or something similar + } + + //to values: + if (tweenArguments.Contains("color")) { + //colors[1]=(Color)tweenArguments["color"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1]=(Color)tweenArguments["color"]; + } + }else{ + if (tweenArguments.Contains("r")) { + //colors[1].r=(float)tweenArguments["r"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].r=(float)tweenArguments["r"]; + } + } + if (tweenArguments.Contains("g")) { + //colors[1].g=(float)tweenArguments["g"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].g=(float)tweenArguments["g"]; + } + } + if (tweenArguments.Contains("b")) { + //colors[1].b=(float)tweenArguments["b"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].b=(float)tweenArguments["b"]; + } + } + if (tweenArguments.Contains("a")) { + //colors[1].a=(float)tweenArguments["a"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].a=(float)tweenArguments["a"]; + } + } + } + + //alpha or amount? + if(tweenArguments.Contains("amount")){ + //colors[1].a=(float)tweenArguments["amount"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].a=(float)tweenArguments["amount"]; + } + }else if(tweenArguments.Contains("alpha")){ + //colors[1].a=(float)tweenArguments["alpha"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].a=(float)tweenArguments["alpha"]; + } + } + } + + void GenerateAudioToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector2s=new Vector2[3]; + + //set audioSource: + if(tweenArguments.Contains("audiosource")){ + audioSource=(AudioSource)tweenArguments["audiosource"]; + }else{ + if(GetComponent(typeof(AudioSource))){ + audioSource=GetComponent(); + }else{ + //throw error if no AudioSource is available: + Debug.LogError("iTween Error: AudioTo requires an AudioSource."); + Dispose(); + } + } + + //from values and default to values: + vector2s[0]=vector2s[1]=new Vector2(audioSource.volume,audioSource.pitch); + + //to values: + if (tweenArguments.Contains("volume")) { + vector2s[1].x=(float)tweenArguments["volume"]; + } + if (tweenArguments.Contains("pitch")) { + vector2s[1].y=(float)tweenArguments["pitch"]; + } + } + + void GenerateStabTargets(){ + //set audioSource: + if(tweenArguments.Contains("audiosource")){ + audioSource=(AudioSource)tweenArguments["audiosource"]; + }else{ + if(GetComponent(typeof(AudioSource))){ + audioSource=GetComponent(); + }else{ + //add and populate AudioSource if one doesn't exist: + gameObject.AddComponent(typeof(AudioSource)); + audioSource=GetComponent(); + audioSource.playOnAwake=false; + + } + } + + //populate audioSource's clip: + audioSource.clip=(AudioClip)tweenArguments["audioclip"]; + + //set audio's pitch and volume if requested: + if(tweenArguments.Contains("pitch")){ + audioSource.pitch=(float)tweenArguments["pitch"]; + } + if(tweenArguments.Contains("volume")){ + audioSource.volume=(float)tweenArguments["volume"]; + } + + //set run time based on length of clip after pitch is augmented + time=audioSource.clip.length/audioSource.pitch; + } + + void GenerateLookToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=transform.eulerAngles; + + //set look: + if(tweenArguments.Contains("looktarget")){ + if (tweenArguments["looktarget"].GetType() == typeof(Transform)) { + //transform.LookAt((Transform)tweenArguments["looktarget"]); + transform.LookAt((Transform)tweenArguments["looktarget"], (Vector3?)tweenArguments["up"] ?? Defaults.up); + }else if(tweenArguments["looktarget"].GetType() == typeof(Vector3)){ + //transform.LookAt((Vector3)tweenArguments["looktarget"]); + transform.LookAt((Vector3)tweenArguments["looktarget"], (Vector3?)tweenArguments["up"] ?? Defaults.up); + } + }else{ + Debug.LogError("iTween Error: LookTo needs a 'looktarget' property!"); + Dispose(); + } + + //to values: + vector3s[1]=transform.eulerAngles; + transform.eulerAngles=vector3s[0]; + + //axis restriction: + if(tweenArguments.Contains("axis")){ + switch((string)tweenArguments["axis"]){ + case "x": + vector3s[1].y=vector3s[0].y; + vector3s[1].z=vector3s[0].z; + break; + case "y": + vector3s[1].x=vector3s[0].x; + vector3s[1].z=vector3s[0].z; + break; + case "z": + vector3s[1].x=vector3s[0].x; + vector3s[1].y=vector3s[0].y; + break; + } + } + + //shortest distance: + vector3s[1]=new Vector3(clerp(vector3s[0].x,vector3s[1].x,1),clerp(vector3s[0].y,vector3s[1].y,1),clerp(vector3s[0].z,vector3s[1].z,1)); + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateMoveToPathTargets(){ + Vector3[] suppliedPath; + + //create and store path points: + if(tweenArguments["path"].GetType() == typeof(Vector3[])){ + Vector3[] temp = (Vector3[])tweenArguments["path"]; + //if only one point is supplied fall back to MoveTo's traditional use since we can't have a curve with one value: + if(temp.Length==1){ + Debug.LogError("iTween Error: Attempting a path movement with MoveTo requires an array of more than 1 entry!"); + Dispose(); + } + suppliedPath=new Vector3[temp.Length]; + Array.Copy(temp,suppliedPath, temp.Length); + }else{ + Transform[] temp = (Transform[])tweenArguments["path"]; + //if only one point is supplied fall back to MoveTo's traditional use since we can't have a curve with one value: + if(temp.Length==1){ + Debug.LogError("iTween Error: Attempting a path movement with MoveTo requires an array of more than 1 entry!"); + Dispose(); + } + suppliedPath = new Vector3[temp.Length]; + for (int i = 0; i < temp.Length; i++) { + suppliedPath[i]=temp[i].position; + } + } + + //do we need to plot a path to get to the beginning of the supplied path? + bool plotStart; + int offset; + if(transform.position != suppliedPath[0]){ + if(!tweenArguments.Contains("movetopath") || (bool)tweenArguments["movetopath"]==true){ + plotStart=true; + offset=3; + }else{ + plotStart=false; + offset=2; + } + }else{ + plotStart=false; + offset=2; + } + + //build calculated path: + vector3s = new Vector3[suppliedPath.Length+offset]; + if(plotStart){ + vector3s[1]=transform.position; + offset=2; + }else{ + offset=1; + } + + //populate calculate path; + Array.Copy(suppliedPath,0,vector3s,offset,suppliedPath.Length); + + //populate start and end control points: + //vector3s[0] = vector3s[1] - vector3s[2]; + vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]); + vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]); + + //is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline! + if(vector3s[1] == vector3s[vector3s.Length-2]){ + Vector3[] tmpLoopSpline = new Vector3[vector3s.Length]; + Array.Copy(vector3s,tmpLoopSpline,vector3s.Length); + tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3]; + tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2]; + vector3s=new Vector3[tmpLoopSpline.Length]; + Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length); + } + + //create Catmull-Rom path: + path = new CRSpline(vector3s); + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = PathLength(vector3s); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateMoveToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + if (isLocal) { + vector3s[0]=vector3s[1]=transform.localPosition; + }else{ + vector3s[0]=vector3s[1]=transform.position; + } + + //to values: + if (tweenArguments.Contains("position")) { + if (tweenArguments["position"].GetType() == typeof(Transform)){ + Transform trans = (Transform)tweenArguments["position"]; + vector3s[1]=trans.position; + }else if(tweenArguments["position"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)tweenArguments["position"]; + } + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + + //handle orient to path request: + if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){ + tweenArguments["looktarget"] = vector3s[1]; + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateMoveByTargets(){ + +/* foreach (var key in tweenArguments.Keys) + { + Debug.Log(key + ": " + tweenArguments[key]); + } +*/ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization, [4] original rotation to make sure look requests don't interfere with the direction object should move in, [5] for dial in location: + vector3s=new Vector3[6]; + + //grab starting rotation: + vector3s[4] = transform.eulerAngles; + + //from values: + vector3s[0]=vector3s[1]=vector3s[3]=transform.position; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=vector3s[0] + (Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=vector3s[0].x + (float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=vector3s[0].y +(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=vector3s[0].z + (float)tweenArguments["z"]; + } + } + + //calculation for dial in: + transform.Translate(vector3s[1],space); + vector3s[5] = transform.position; + transform.position=vector3s[0]; + + //handle orient to path request: + if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){ + tweenArguments["looktarget"] = vector3s[1]; + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateScaleToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=vector3s[1]=transform.localScale; + + //to values: + if (tweenArguments.Contains("scale")) { + if (tweenArguments["scale"].GetType() == typeof(Transform)){ + Transform trans = (Transform)tweenArguments["scale"]; + vector3s[1]=trans.localScale; + }else if(tweenArguments["scale"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)tweenArguments["scale"]; + } + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateScaleByTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=vector3s[1]=transform.localScale; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=Vector3.Scale(vector3s[1],(Vector3)tweenArguments["amount"]); + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x*=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y*=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z*=(float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateScaleAddTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=vector3s[1]=transform.localScale; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]+=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x+=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y+=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z+=(float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateRotateToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + if (isLocal) { + vector3s[0]=vector3s[1]=transform.localEulerAngles; + }else{ + vector3s[0]=vector3s[1]=transform.eulerAngles; + } + + //to values: + if (tweenArguments.Contains("rotation")) { + if (tweenArguments["rotation"].GetType() == typeof(Transform)){ + Transform trans = (Transform)tweenArguments["rotation"]; + vector3s[1]=trans.eulerAngles; + }else if(tweenArguments["rotation"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)tweenArguments["rotation"]; + } + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + + //shortest distance: + vector3s[1]=new Vector3(clerp(vector3s[0].x,vector3s[1].x,1),clerp(vector3s[0].y,vector3s[1].y,1),clerp(vector3s[0].z,vector3s[1].z,1)); + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateRotateAddTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Rotate usage to allow Space utilization: + vector3s=new Vector3[5]; + + //from values: + vector3s[0]=vector3s[1]=vector3s[3]=transform.eulerAngles; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]+=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x+=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y+=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z+=(float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateRotateByTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Rotate usage to allow Space utilization: + vector3s=new Vector3[4]; + + //from values: + vector3s[0]=vector3s[1]=vector3s[3]=transform.eulerAngles; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]+=Vector3.Scale((Vector3)tweenArguments["amount"],new Vector3(360,360,360)); + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x+=360 * (float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y+=360 * (float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z+=360 * (float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateShakePositionTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] original rotation to make sure look requests don't interfere with the direction object should move in: + vector3s=new Vector3[4]; + + //grab starting rotation: + vector3s[3] = transform.eulerAngles; + + //root: + vector3s[0]=transform.position; + + //amount: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GenerateShakeScaleTargets(){ + //values holder [0] root value, [1] amount, [2] generated amount: + vector3s=new Vector3[3]; + + //root: + vector3s[0]=transform.localScale; + + //amount: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GenerateShakeRotationTargets(){ + //values holder [0] root value, [1] amount, [2] generated amount: + vector3s=new Vector3[3]; + + //root: + vector3s[0]=transform.eulerAngles; + + //amount: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GeneratePunchPositionTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization, [4] original rotation to make sure look requests don't interfere with the direction object should move in: + vector3s=new Vector3[5]; + + //grab starting rotation: + vector3s[4] = transform.eulerAngles; + + //from values: + vector3s[0]=transform.position; + vector3s[1]=vector3s[3]=Vector3.zero; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GeneratePunchRotationTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization: + vector3s=new Vector3[4]; + + //from values: + vector3s[0]=transform.eulerAngles; + vector3s[1]=vector3s[3]=Vector3.zero; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GeneratePunchScaleTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=transform.localScale; + vector3s[1]=Vector3.zero; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + #endregion + +#region #4 Apply Targets + + void ApplyRectTargets(){ + //calculate: + rects[2].x = ease(rects[0].x,rects[1].x,percentage); + rects[2].y = ease(rects[0].y,rects[1].y,percentage); + rects[2].width = ease(rects[0].width,rects[1].width,percentage); + rects[2].height = ease(rects[0].height,rects[1].height,percentage); + + //apply: + tweenArguments["onupdateparams"]=rects[2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=rects[1]; + } + } + + void ApplyColorTargets(){ + //calculate: + colors[0,2].r = ease(colors[0,0].r,colors[0,1].r,percentage); + colors[0,2].g = ease(colors[0,0].g,colors[0,1].g,percentage); + colors[0,2].b = ease(colors[0,0].b,colors[0,1].b,percentage); + colors[0,2].a = ease(colors[0,0].a,colors[0,1].a,percentage); + + //apply: + tweenArguments["onupdateparams"]=colors[0,2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=colors[0,1]; + } + } + + void ApplyVector3Targets(){ + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + tweenArguments["onupdateparams"]=vector3s[2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=vector3s[1]; + } + } + + void ApplyVector2Targets(){ + //calculate: + vector2s[2].x = ease(vector2s[0].x,vector2s[1].x,percentage); + vector2s[2].y = ease(vector2s[0].y,vector2s[1].y,percentage); + + //apply: + tweenArguments["onupdateparams"]=vector2s[2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=vector2s[1]; + } + } + + void ApplyFloatTargets(){ + //calculate: + floats[2] = ease(floats[0],floats[1],percentage); + + //apply: + tweenArguments["onupdateparams"]=floats[2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=floats[1]; + } + } + + void ApplyColorToTargets(){ + //calculate: + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,2].r = ease(colors[i,0].r,colors[i,1].r,percentage); + colors[i,2].g = ease(colors[i,0].g,colors[i,1].g,percentage); + colors[i,2].b = ease(colors[i,0].b,colors[i,1].b,percentage); + colors[i,2].a = ease(colors[i,0].a,colors[i,1].a,percentage); + } + /* + colors[2].r = ease(colors[0].r,colors[1].r,percentage); + colors[2].g = ease(colors[0].g,colors[1].g,percentage); + colors[2].b = ease(colors[0].b,colors[1].b,percentage); + colors[2].a = ease(colors[0].a,colors[1].a,percentage); + */ + + //apply: + if(GetComponent(typeof(GUITexture))){ + //guiTexture.color=colors[2]; + GetComponent().color=colors[0,2]; + }else if(GetComponent(typeof(GUIText))){ + //guiText.material.color=colors[2]; + GetComponent().material.color=colors[0,2]; + }else if(GetComponent()){ + //renderer.material.color=colors[2]; + for (int i = 0; i < colors.GetLength(0); i++) { + GetComponent().materials[i].SetColor(namedcolorvalue.ToString(),colors[i,2]); + } + }else if(GetComponent()){ + //light.color=colors[2]; + GetComponent().color=colors[0,2]; + } + + //dial in: + if(percentage==1){ + if(GetComponent(typeof(GUITexture))){ + //guiTexture.color=colors[1]; + GetComponent().color=colors[0,1]; + }else if(GetComponent(typeof(GUIText))){ + //guiText.material.color=colors[1]; + GetComponent().material.color=colors[0,1]; + }else if(GetComponent()){ + //renderer.material.color=colors[1]; + for (int i = 0; i < colors.GetLength(0); i++) { + GetComponent().materials[i].SetColor(namedcolorvalue.ToString(),colors[i,1]); + } + }else if(GetComponent()){ + //light.color=colors[1]; + GetComponent().color=colors[0,1]; + } + } + } + + void ApplyAudioToTargets(){ + //calculate: + vector2s[2].x = ease(vector2s[0].x,vector2s[1].x,percentage); + vector2s[2].y = ease(vector2s[0].y,vector2s[1].y,percentage); + + //apply: + audioSource.volume=vector2s[2].x; + audioSource.pitch=vector2s[2].y; + + //dial in: + if(percentage==1){ + audioSource.volume=vector2s[1].x; + audioSource.pitch=vector2s[1].y; + } + } + + void ApplyStabTargets(){ + //unnecessary but here just in case + } + + void ApplyMoveToPathTargets(){ + preUpdate = transform.position; + float t = ease(0,1,percentage); + float lookAheadAmount; + + //clamp easing equation results as "back" will fail since overshoots aren't handled in the Catmull-Rom interpolation: + if(isLocal){ + transform.localPosition=path.Interp(Mathf.Clamp(t,0,1)); + }else{ + transform.position=path.Interp(Mathf.Clamp(t,0,1)); + } + + //handle orient to path request: + if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){ + + //plot a point slightly ahead in the interpolation by pushing the percentage forward using the default lookahead value: + float tLook; + if(tweenArguments.Contains("lookahead")){ + lookAheadAmount = (float)tweenArguments["lookahead"]; + }else{ + lookAheadAmount = Defaults.lookAhead; + } + //tLook = ease(0,1,percentage+lookAheadAmount); + tLook = ease(0,1, Mathf.Min(1f, percentage+lookAheadAmount)); + + //locate new leading point with a clamp as stated above: + //Vector3 lookDistance = path.Interp(Mathf.Clamp(tLook,0,1)) - transform.position; + tweenArguments["looktarget"] = path.Interp(Mathf.Clamp(tLook,0,1)); + } + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + GetComponent().MovePosition(postUpdate); + } + } + + void ApplyMoveToTargets(){ + //record current: + preUpdate=transform.position; + + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + if (isLocal) { + transform.localPosition=vector3s[2]; + }else{ + transform.position=vector3s[2]; + } + + //dial in: + if(percentage==1){ + if (isLocal) { + transform.localPosition=vector3s[1]; + }else{ + transform.position=vector3s[1]; + } + } + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + GetComponent().MovePosition(postUpdate); + } + } + + void ApplyMoveByTargets(){ + preUpdate = transform.position; + + //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation + Vector3 currentRotation = new Vector3(); + + if(tweenArguments.Contains("looktarget")){ + currentRotation = transform.eulerAngles; + transform.eulerAngles = vector3s[4]; + } + + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + transform.Translate(vector3s[2]-vector3s[3],space); + + //record: + vector3s[3]=vector3s[2]; + + //reset rotation: + if(tweenArguments.Contains("looktarget")){ + transform.eulerAngles = currentRotation; + } + + /* + //dial in: + if(percentage==1){ + transform.position=vector3s[5]; + } + */ + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + GetComponent().MovePosition(postUpdate); + } + } + + void ApplyScaleToTargets(){ + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + transform.localScale=vector3s[2]; + + //dial in: + if(percentage==1){ + transform.localScale=vector3s[1]; + } + } + + void ApplyLookToTargets(){ + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + if (isLocal) { + transform.localRotation = Quaternion.Euler(vector3s[2]); + }else{ + transform.rotation = Quaternion.Euler(vector3s[2]); + }; + } + + void ApplyRotateToTargets(){ + preUpdate=transform.eulerAngles; + + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + if (isLocal) { + transform.localRotation = Quaternion.Euler(vector3s[2]); + }else{ + transform.rotation = Quaternion.Euler(vector3s[2]); + }; + + //dial in: + if(percentage==1){ + if (isLocal) { + transform.localRotation = Quaternion.Euler(vector3s[1]); + }else{ + transform.rotation = Quaternion.Euler(vector3s[1]); + }; + } + + //need physics? + postUpdate=transform.eulerAngles; + if(physics){ + transform.eulerAngles=preUpdate; + GetComponent().MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + void ApplyRotateAddTargets(){ + preUpdate = transform.eulerAngles; + + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + transform.Rotate(vector3s[2]-vector3s[3],space); + + //record: + vector3s[3]=vector3s[2]; + + //need physics? + postUpdate=transform.eulerAngles; + if(physics){ + transform.eulerAngles=preUpdate; + GetComponent().MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + void ApplyShakePositionTargets(){ + preUpdate = transform.position; + + //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation + Vector3 currentRotation = new Vector3(); + + if(tweenArguments.Contains("looktarget")){ + currentRotation = transform.eulerAngles; + transform.eulerAngles = vector3s[3]; + } + + //impact: + if (percentage==0) { + transform.Translate(vector3s[1],space); + } + + //reset: + transform.position=vector3s[0]; + + //generate: + float diminishingControl = 1-percentage; + vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl); + vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl); + vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl); + + //apply: + transform.Translate(vector3s[2],space); + + //reset rotation: + if(tweenArguments.Contains("looktarget")){ + transform.eulerAngles = currentRotation; + } + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + GetComponent().MovePosition(postUpdate); + } + } + + void ApplyShakeScaleTargets(){ + //impact: + if (percentage==0) { + transform.localScale=vector3s[1]; + } + + //reset: + transform.localScale=vector3s[0]; + + //generate: + float diminishingControl = 1-percentage; + vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl); + vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl); + vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl); + + //apply: + transform.localScale+=vector3s[2]; + } + + void ApplyShakeRotationTargets(){ + preUpdate = transform.eulerAngles; + + //impact: + if (percentage==0) { + transform.Rotate(vector3s[1],space); + } + + //reset: + transform.eulerAngles=vector3s[0]; + + //generate: + float diminishingControl = 1-percentage; + vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl); + vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl); + vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl); + + //apply: + transform.Rotate(vector3s[2],space); + + //need physics? + postUpdate=transform.eulerAngles; + if(physics){ + transform.eulerAngles=preUpdate; + GetComponent().MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + void ApplyPunchPositionTargets(){ + preUpdate = transform.position; + + //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation + Vector3 currentRotation = new Vector3(); + + if(tweenArguments.Contains("looktarget")){ + currentRotation = transform.eulerAngles; + transform.eulerAngles = vector3s[4]; + } + + //calculate: + if(vector3s[1].x>0){ + vector3s[2].x = punch(vector3s[1].x,percentage); + }else if(vector3s[1].x<0){ + vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage); + } + if(vector3s[1].y>0){ + vector3s[2].y=punch(vector3s[1].y,percentage); + }else if(vector3s[1].y<0){ + vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage); + } + if(vector3s[1].z>0){ + vector3s[2].z=punch(vector3s[1].z,percentage); + }else if(vector3s[1].z<0){ + vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage); + } + + //apply: + transform.Translate(vector3s[2]-vector3s[3],space); + + //record: + vector3s[3]=vector3s[2]; + + //reset rotation: + if(tweenArguments.Contains("looktarget")){ + transform.eulerAngles = currentRotation; + } + + //dial in: + /* + if(percentage==1){ + transform.position=vector3s[0]; + } + */ + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + GetComponent().MovePosition(postUpdate); + } + } + + void ApplyPunchRotationTargets(){ + preUpdate = transform.eulerAngles; + + //calculate: + if(vector3s[1].x>0){ + vector3s[2].x = punch(vector3s[1].x,percentage); + }else if(vector3s[1].x<0){ + vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage); + } + if(vector3s[1].y>0){ + vector3s[2].y=punch(vector3s[1].y,percentage); + }else if(vector3s[1].y<0){ + vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage); + } + if(vector3s[1].z>0){ + vector3s[2].z=punch(vector3s[1].z,percentage); + }else if(vector3s[1].z<0){ + vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage); + } + + //apply: + transform.Rotate(vector3s[2]-vector3s[3],space); + + //record: + vector3s[3]=vector3s[2]; + + //dial in: + /* + if(percentage==1){ + transform.eulerAngles=vector3s[0]; + } + */ + + //need physics? + postUpdate=transform.eulerAngles; + if(physics){ + transform.eulerAngles=preUpdate; + GetComponent().MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + void ApplyPunchScaleTargets(){ + //calculate: + if(vector3s[1].x>0){ + vector3s[2].x = punch(vector3s[1].x,percentage); + }else if(vector3s[1].x<0){ + vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage); + } + if(vector3s[1].y>0){ + vector3s[2].y=punch(vector3s[1].y,percentage); + }else if(vector3s[1].y<0){ + vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage); + } + if(vector3s[1].z>0){ + vector3s[2].z=punch(vector3s[1].z,percentage); + }else if(vector3s[1].z<0){ + vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage); + } + + //apply: + transform.localScale=vector3s[0]+vector3s[2]; + + //dial in: + /* + if(percentage==1){ + transform.localScale=vector3s[0]; + } + */ + } + + #endregion + +#region #5 Tween Steps + + IEnumerator TweenDelay(){ + delayStarted = Time.time; + yield return new WaitForSeconds (delay); + if(wasPaused){ + wasPaused=false; + TweenStart(); + } + } + + void TweenStart(){ + CallBack("onstart"); + + if(!loop){//only if this is not a loop + ConflictCheck(); + GenerateTargets(); + } + + //run stab: + if(type == "stab"){ + audioSource.PlayOneShot(audioSource.clip); + } + + //toggle isKinematic for iTweens that may interfere with physics: + if (type == "move" || type=="scale" || type=="rotate" || type=="punch" || type=="shake" || type=="curve" || type=="look") { + EnableKinematic(); + } + + isRunning = true; + } + + IEnumerator TweenRestart(){ + if(delay > 0){ + delayStarted = Time.time; + yield return new WaitForSeconds (delay); + } + loop=true; + TweenStart(); + } + + void TweenUpdate(){ + apply(); + CallBack("onupdate"); + UpdatePercentage(); + } + + void TweenComplete(){ + isRunning=false; + + //dial in percentage to 1 or 0 for final run: + if(percentage>.5f){ + percentage=1f; + }else{ + percentage=0; + } + + //apply dial in and final run: + apply(); + if(type == "value"){ + CallBack("onupdate"); //CallBack run for ValueTo since it only calculates and applies in the update callback + } + + //loop or dispose? + if(loopType==LoopType.none){ + Dispose(); + }else{ + TweenLoop(); + } + + CallBack("oncomplete"); + } + + void TweenLoop(){ + DisableKinematic(); //give physics control again + switch(loopType){ + case LoopType.loop: + //rewind: + percentage=0; + runningTime=0; + apply(); + + //replay: + StartCoroutine("TweenRestart"); + break; + case LoopType.pingPong: + reverse = !reverse; + runningTime=0; + + //replay: + StartCoroutine("TweenRestart"); + break; + } + } + + #endregion + +#region #6 Update Callable + + /// + /// Returns a Rect that is eased between a current and target value by the supplied speed. + /// + /// + /// A + /// + /// A the starting or initial value + /// + /// + /// A the target value that the current value will be eased to. + /// + /// + /// A to be used as rate of speed (larger number equals faster animation) + /// + public static Rect RectUpdate(Rect currentValue, Rect targetValue, float speed){ + Rect diff = new Rect(FloatUpdate(currentValue.x, targetValue.x, speed), FloatUpdate(currentValue.y, targetValue.y, speed), FloatUpdate(currentValue.width, targetValue.width, speed), FloatUpdate(currentValue.height, targetValue.height, speed)); + return (diff); + } + + /// + /// Returns a Vector3 that is eased between a current and target value by the supplied speed. + /// + /// + /// A + /// + /// + /// A the starting or initial value + /// + /// + /// A the target value that the current value will be eased to. + /// + /// + /// A to be used as rate of speed (larger number equals faster animation) + /// + public static Vector3 Vector3Update(Vector3 currentValue, Vector3 targetValue, float speed){ + Vector3 diff = targetValue - currentValue; + currentValue += (diff * speed) * Time.deltaTime; + return (currentValue); + } + + /// + /// Returns a Vector2 that is eased between a current and target value by the supplied speed. + /// + /// + /// A + /// + /// + /// A the starting or initial value + /// + /// + /// A the target value that the current value will be eased to. + /// + /// + /// A to be used as rate of speed (larger number equals faster animation) + /// + public static Vector2 Vector2Update(Vector2 currentValue, Vector2 targetValue, float speed){ + Vector2 diff = targetValue - currentValue; + currentValue += (diff * speed) * Time.deltaTime; + return (currentValue); + } + + /// + /// Returns a float that is eased between a current and target value by the supplied speed. + /// + /// + /// A + /// + /// + /// A the starting or initial value + /// + /// + /// A the target value that the current value will be eased to. + /// + /// + /// A to be used as rate of speed (larger number equals faster animation) + /// + public static float FloatUpdate(float currentValue, float targetValue, float speed){ + float diff = targetValue - currentValue; + currentValue += (diff * speed) * Time.deltaTime; + return (currentValue); + } + + /// + /// Similar to FadeTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for the final alpha value of the animation. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void FadeUpdate(GameObject target, Hashtable args){ + args["a"]=args["alpha"]; + ColorUpdate(target,args); + } + + /// + /// Similar to FadeTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final alpha value of the animation. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void FadeUpdate(GameObject target, float alpha, float time){ + FadeUpdate(target,Hash("alpha",alpha,"time",time)); + } + + /// + /// Similar to ColorTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A or for the individual setting of the color red. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void ColorUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + float time; + Color[] colors = new Color[4]; + + //handle children: + if(!args.Contains("includechildren") || (bool)args["includechildren"]){ + foreach(Transform child in target.transform){ + ColorUpdate(child.gameObject,args); + } + } + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //init values: + if(target.GetComponent(typeof(GUITexture))){ + colors[0] = colors[1] = target.GetComponent().color; + }else if(target.GetComponent(typeof(GUIText))){ + colors[0] = colors[1] = target.GetComponent().material.color; + }else if(target.GetComponent()){ + colors[0] = colors[1] = target.GetComponent().material.color; + }else if(target.GetComponent()){ + colors[0] = colors[1] = target.GetComponent().color; + } + + //to values: + if (args.Contains("color")) { + colors[1]=(Color)args["color"]; + }else{ + if (args.Contains("r")) { + colors[1].r=(float)args["r"]; + } + if (args.Contains("g")) { + colors[1].g=(float)args["g"]; + } + if (args.Contains("b")) { + colors[1].b=(float)args["b"]; + } + if (args.Contains("a")) { + colors[1].a=(float)args["a"]; + } + } + + //calculate: + colors[3].r=Mathf.SmoothDamp(colors[0].r,colors[1].r,ref colors[2].r,time); + colors[3].g=Mathf.SmoothDamp(colors[0].g,colors[1].g,ref colors[2].g,time); + colors[3].b=Mathf.SmoothDamp(colors[0].b,colors[1].b,ref colors[2].b,time); + colors[3].a=Mathf.SmoothDamp(colors[0].a,colors[1].a,ref colors[2].a,time); + + //apply: + if(target.GetComponent(typeof(GUITexture))){ + target.GetComponent().color=colors[3]; + }else if(target.GetComponent(typeof(GUIText))){ + target.GetComponent().material.color=colors[3]; + }else if(target.GetComponent()){ + target.GetComponent().material.color=colors[3]; + }else if(target.GetComponent()){ + target.GetComponent().color=colors[3]; + } + } + + /// + /// Similar to ColorTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ColorUpdate(GameObject target, Color color, float time){ + ColorUpdate(target,Hash("color",color,"time",time)); + } + + /// + /// Similar to AudioTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A for which AudioSource to use. + /// + /// + /// A or for the target level of volume. + /// + /// + /// A or for the target pitch. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void AudioUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + AudioSource audioSource; + float time; + Vector2[] vector2s = new Vector2[4]; + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //set audioSource: + if(args.Contains("audiosource")){ + audioSource=(AudioSource)args["audiosource"]; + }else{ + if(target.GetComponent(typeof(AudioSource))){ + audioSource=target.GetComponent(); + }else{ + //throw error if no AudioSource is available: + Debug.LogError("iTween Error: AudioUpdate requires an AudioSource."); + return; + } + } + + //from values: + vector2s[0] = vector2s[1] = new Vector2(audioSource.volume,audioSource.pitch); + + //set to: + if(args.Contains("volume")){ + vector2s[1].x=(float)args["volume"]; + } + if(args.Contains("pitch")){ + vector2s[1].y=(float)args["pitch"]; + } + + //calculate: + vector2s[3].x=Mathf.SmoothDampAngle(vector2s[0].x,vector2s[1].x,ref vector2s[2].x,time); + vector2s[3].y=Mathf.SmoothDampAngle(vector2s[0].y,vector2s[1].y,ref vector2s[2].y,time); + + //apply: + audioSource.volume=vector2s[3].x; + audioSource.pitch=vector2s[3].y; + } + + /// + /// Similar to AudioTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the target level of volume. + /// + /// + /// A for the target pitch. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void AudioUpdate(GameObject target, float volume, float pitch, float time){ + AudioUpdate(target,Hash("volume",volume,"pitch",pitch,"time",time)); + } + + /// + /// Similar to RotateTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for the target Euler angles in degrees to rotate to. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void RotateUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + bool isLocal; + float time; + Vector3[] vector3s = new Vector3[4]; + Vector3 preUpdate = target.transform.eulerAngles; + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //set isLocal: + if(args.Contains("islocal")){ + isLocal = (bool)args["islocal"]; + }else{ + isLocal = Defaults.isLocal; + } + + //from values: + if(isLocal){ + vector3s[0] = target.transform.localEulerAngles; + }else{ + vector3s[0] = target.transform.eulerAngles; + } + + //set to: + if(args.Contains("rotation")){ + if (args["rotation"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["rotation"]; + vector3s[1]=trans.eulerAngles; + }else if(args["rotation"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)args["rotation"]; + } + } + + //calculate: + vector3s[3].x=Mathf.SmoothDampAngle(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time); + vector3s[3].y=Mathf.SmoothDampAngle(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time); + vector3s[3].z=Mathf.SmoothDampAngle(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time); + + //apply: + if(isLocal){ + target.transform.localEulerAngles=vector3s[3]; + }else{ + target.transform.eulerAngles=vector3s[3]; + } + + //need physics? + if(target.GetComponent() != null){ + Vector3 postUpdate=target.transform.eulerAngles; + target.transform.eulerAngles=preUpdate; + target.GetComponent().MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + /// + /// Similar to RotateTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the target Euler angles in degrees to rotate to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateUpdate(GameObject target, Vector3 rotation, float time){ + RotateUpdate(target,Hash("rotation",rotation,"time",time)); + } + + /// + /// Similar to ScaleTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for the final scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void ScaleUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + float time; + Vector3[] vector3s = new Vector3[4]; + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //init values: + vector3s[0] = vector3s[1] = target.transform.localScale; + + //to values: + if (args.Contains("scale")) { + if (args["scale"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["scale"]; + vector3s[1]=trans.localScale; + }else if(args["scale"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)args["scale"]; + } + }else{ + if (args.Contains("x")) { + vector3s[1].x=(float)args["x"]; + } + if (args.Contains("y")) { + vector3s[1].y=(float)args["y"]; + } + if (args.Contains("z")) { + vector3s[1].z=(float)args["z"]; + } + } + + //calculate: + vector3s[3].x=Mathf.SmoothDamp(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time); + vector3s[3].y=Mathf.SmoothDamp(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time); + vector3s[3].z=Mathf.SmoothDamp(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time); + + //apply: + target.transform.localScale=vector3s[3]; + } + + /// + /// Similar to ScaleTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleUpdate(GameObject target, Vector3 scale, float time){ + ScaleUpdate(target,Hash("scale",scale,"time",time)); + } + + /// + /// Similar to MoveTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for a point in space the GameObject will animate to. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A for whether to animate in world space or relative to the parent. False be default. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + public static void MoveUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + float time; + Vector3[] vector3s = new Vector3[4]; + bool isLocal; + Vector3 preUpdate = target.transform.position; + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //set isLocal: + if(args.Contains("islocal")){ + isLocal = (bool)args["islocal"]; + }else{ + isLocal = Defaults.isLocal; + } + + //init values: + if(isLocal){ + vector3s[0] = vector3s[1] = target.transform.localPosition; + }else{ + vector3s[0] = vector3s[1] = target.transform.position; + } + + //to values: + if (args.Contains("position")) { + if (args["position"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["position"]; + vector3s[1]=trans.position; + }else if(args["position"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)args["position"]; + } + }else{ + if (args.Contains("x")) { + vector3s[1].x=(float)args["x"]; + } + if (args.Contains("y")) { + vector3s[1].y=(float)args["y"]; + } + if (args.Contains("z")) { + vector3s[1].z=(float)args["z"]; + } + } + + //calculate: + vector3s[3].x=Mathf.SmoothDamp(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time); + vector3s[3].y=Mathf.SmoothDamp(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time); + vector3s[3].z=Mathf.SmoothDamp(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time); + + //handle orient to path: + if(args.Contains("orienttopath") && (bool)args["orienttopath"]){ + args["looktarget"] = vector3s[3]; + } + + //look applications: + if(args.Contains("looktarget")){ + iTween.LookUpdate(target,args); + } + + //apply: + if(isLocal){ + target.transform.localPosition = vector3s[3]; + }else{ + target.transform.position=vector3s[3]; + } + + //need physics? + if(target.GetComponent() != null){ + Vector3 postUpdate=target.transform.position; + target.transform.position=preUpdate; + target.GetComponent().MovePosition(postUpdate); + } + } + + /// + /// Similar to MoveTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for a point in space the GameObject will animate to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveUpdate(GameObject target, Vector3 position, float time){ + MoveUpdate(target,Hash("position",position,"time",time)); + } + + /// + /// Similar to LookTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for a target the GameObject will look at. + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void LookUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + float time; + Vector3[] vector3s = new Vector3[5]; + + //set smooth time: + if(args.Contains("looktime")){ + time=(float)args["looktime"]; + time*=Defaults.updateTimePercentage; + }else if(args.Contains("time")){ + time=(float)args["time"]*.15f; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //from values: + vector3s[0] = target.transform.eulerAngles; + + //set look: + if(args.Contains("looktarget")){ + if (args["looktarget"].GetType() == typeof(Transform)) { + //target.transform.LookAt((Transform)args["looktarget"]); + target.transform.LookAt((Transform)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up); + }else if(args["looktarget"].GetType() == typeof(Vector3)){ + //target.transform.LookAt((Vector3)args["looktarget"]); + target.transform.LookAt((Vector3)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up); + } + }else{ + Debug.LogError("iTween Error: LookUpdate needs a 'looktarget' property!"); + return; + } + + //to values and reset look: + vector3s[1]=target.transform.eulerAngles; + target.transform.eulerAngles=vector3s[0]; + + //calculate: + vector3s[3].x=Mathf.SmoothDampAngle(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time); + vector3s[3].y=Mathf.SmoothDampAngle(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time); + vector3s[3].z=Mathf.SmoothDampAngle(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time); + + //apply: + target.transform.eulerAngles=vector3s[3]; + + //axis restriction: + if(args.Contains("axis")){ + vector3s[4]=target.transform.eulerAngles; + switch((string)args["axis"]){ + case "x": + vector3s[4].y=vector3s[0].y; + vector3s[4].z=vector3s[0].z; + break; + case "y": + vector3s[4].x=vector3s[0].x; + vector3s[4].z=vector3s[0].z; + break; + case "z": + vector3s[4].x=vector3s[0].x; + vector3s[4].y=vector3s[0].y; + break; + } + + //apply axis restriction: + target.transform.eulerAngles=vector3s[4]; + } + } + + /// + /// Similar to LookTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for a target the GameObject will look at. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void LookUpdate(GameObject target, Vector3 looktarget, float time){ + LookUpdate(target,Hash("looktarget",looktarget,"time",time)); + } + + #endregion + +#region #7 External Utilities + + /// + /// Returns the length of a curved path drawn through the provided array of Transforms. + /// + /// + /// A + /// + /// + /// A + /// + public static float PathLength(Transform[] path){ + Vector3[] suppliedPath = new Vector3[path.Length]; + float pathLength = 0; + + //create and store path points: + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + Vector3[] vector3s = PathControlPointGenerator(suppliedPath); + + //Line Draw: + Vector3 prevPt = Interp(vector3s,0); + int SmoothAmount = path.Length*20; + for (int i = 1; i <= SmoothAmount; i++) { + float pm = (float) i / SmoothAmount; + Vector3 currPt = Interp(vector3s,pm); + pathLength += Vector3.Distance(prevPt,currPt); + prevPt = currPt; + } + + return pathLength; + } + + /// + /// Returns the length of a curved path drawn through the provided array of Vector3s. + /// + /// + /// The length. + /// + /// + /// A + /// + public static float PathLength(Vector3[] path){ + float pathLength = 0; + + Vector3[] vector3s = PathControlPointGenerator(path); + + //Line Draw: + Vector3 prevPt = Interp(vector3s,0); + int SmoothAmount = path.Length*20; + for (int i = 1; i <= SmoothAmount; i++) { + float pm = (float) i / SmoothAmount; + Vector3 currPt = Interp(vector3s,pm); + pathLength += Vector3.Distance(prevPt,currPt); + prevPt = currPt; + } + + return pathLength; + } + + /// + /// Creates and returns a full-screen Texture2D for use with CameraFade. + /// + /// + /// Texture2D + /// + /// + /// Color + /// + public static Texture2D CameraTexture(Color color){ + Texture2D texture = new Texture2D(Screen.width,Screen.height,TextureFormat.ARGB32, false); + Color[] colors = new Color[Screen.width*Screen.height]; + for (int i = 0; i < colors.Length; i++) { + colors[i]=color; + } + texture.SetPixels(colors); + texture.Apply(); + return(texture); + } + + /// + /// Puts a GameObject on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static void PutOnPath(GameObject target, Vector3[] path, float percent){ + target.transform.position=Interp(PathControlPointGenerator(path),percent); + } + + /// + /// Puts a GameObject on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static void PutOnPath(Transform target, Vector3[] path, float percent){ + target.position=Interp(PathControlPointGenerator(path),percent); + } + + /// + /// Puts a GameObject on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static void PutOnPath(GameObject target, Transform[] path, float percent){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + target.transform.position=Interp(PathControlPointGenerator(suppliedPath),percent); + } + + /// + /// Puts a GameObject on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static void PutOnPath(Transform target, Transform[] path, float percent){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + target.position=Interp(PathControlPointGenerator(suppliedPath),percent); + } + + /// + /// Returns a Vector3 position on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static Vector3 PointOnPath(Transform[] path, float percent){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + return(Interp(PathControlPointGenerator(suppliedPath),percent)); + } + + /// + /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Vector3s. + /// + /// + /// A + /// + public static void DrawLine(Vector3[] line) { + if(line.Length>0){ + DrawLineHelper(line,Defaults.color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Vector3s. + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLine(Vector3[] line, Color color) { + if(line.Length>0){ + DrawLineHelper(line,color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Transforms. + /// + /// + /// A + /// + public static void DrawLine(Transform[] line) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + DrawLineHelper(suppliedLine,Defaults.color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Transforms. + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLine(Transform[] line,Color color) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + + DrawLineHelper(suppliedLine, color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Vector3s with Gizmos.DrawLine(). + /// + /// + /// A + /// + public static void DrawLineGizmos(Vector3[] line) { + if(line.Length>0){ + DrawLineHelper(line,Defaults.color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Vector3s with Gizmos.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLineGizmos(Vector3[] line, Color color) { + if(line.Length>0){ + DrawLineHelper(line,color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Transforms with Gizmos.DrawLine(). + /// + /// + /// A + /// + public static void DrawLineGizmos(Transform[] line) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + DrawLineHelper(suppliedLine,Defaults.color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Transforms with Gizmos.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLineGizmos(Transform[] line,Color color) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + + DrawLineHelper(suppliedLine, color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Vector3s with Handles.DrawLine(). + /// + /// + /// A + /// + public static void DrawLineHandles(Vector3[] line) { + if(line.Length>0){ + DrawLineHelper(line,Defaults.color,"handles"); + } + } + + /// + /// Draws a line through the provided array of Vector3s with Handles.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLineHandles(Vector3[] line, Color color) { + if(line.Length>0){ + DrawLineHelper(line,color,"handles"); + } + } + + /// + /// Draws a line through the provided array of Transforms with Handles.DrawLine(). + /// + /// + /// A + /// + public static void DrawLineHandles(Transform[] line) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + DrawLineHelper(suppliedLine,Defaults.color,"handles"); + } + } + + /// + /// Draws a line through the provided array of Transforms with Handles.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLineHandles(Transform[] line,Color color) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + + DrawLineHelper(suppliedLine, color,"handles"); + } + } + + /// + /// Returns a Vector3 position on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static Vector3 PointOnPath(Vector3[] path, float percent){ + return(Interp(PathControlPointGenerator(path),percent)); + } + + /// + /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Vector3s. + /// + /// + /// A + /// + public static void DrawPath(Vector3[] path) { + if(path.Length>0){ + DrawPathHelper(path,Defaults.color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Vector3s. + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPath(Vector3[] path, Color color) { + if(path.Length>0){ + DrawPathHelper(path, color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Transforms. + /// + /// + /// A + /// + public static void DrawPath(Transform[] path) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath,Defaults.color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Transforms. + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPath(Transform[] path,Color color) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath, color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Vector3s with Gizmos.DrawLine(). + /// + /// + /// A + /// + public static void DrawPathGizmos(Vector3[] path) { + if(path.Length>0){ + DrawPathHelper(path,Defaults.color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Vector3s with Gizmos.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPathGizmos(Vector3[] path, Color color) { + if(path.Length>0){ + DrawPathHelper(path, color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Transforms with Gizmos.DrawLine(). + /// + /// + /// A + /// + public static void DrawPathGizmos(Transform[] path) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath,Defaults.color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Transforms with Gizmos.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPathGizmos(Transform[] path,Color color) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath, color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Vector3s with Handles.DrawLine(). + /// + /// + /// A + /// + public static void DrawPathHandles(Vector3[] path) { + if(path.Length>0){ + DrawPathHelper(path,Defaults.color,"handles"); + } + } + + /// + /// Draws a curved path through the provided array of Vector3s with Handles.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPathHandles(Vector3[] path, Color color) { + if(path.Length>0){ + DrawPathHelper(path, color,"handles"); + } + } + + /// + /// Draws a curved path through the provided array of Transforms with Handles.DrawLine(). + /// + /// + /// A + /// + public static void DrawPathHandles(Transform[] path) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath,Defaults.color,"handles"); + } + } + + /// + /// Draws a curved path through the provided array of Transforms with Handles.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPathHandles(Transform[] path,Color color) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath, color,"handles"); + } + } + + /// + /// Changes a camera fade's texture. + /// + /// + /// A + /// + public static void CameraFadeDepth(int depth){ + if(cameraFade){ + cameraFade.transform.position=new Vector3(cameraFade.transform.position.x,cameraFade.transform.position.y,depth); + } + } + + /// + /// Removes and destroyes a camera fade. + /// + public static void CameraFadeDestroy(){ + if(cameraFade){ + Destroy(cameraFade); + } + } + + /// + /// Changes a camera fade's texture. + /// + /// + /// A + /// + public static void CameraFadeSwap(Texture2D texture){ + if(cameraFade){ + cameraFade.GetComponent().texture=texture; + } + } + + /// + /// Creates a GameObject (if it doesn't exist) at the supplied depth that can be used to simulate a camera fade. + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A for a reference to the CameraFade. + /// + public static GameObject CameraFadeAdd(Texture2D texture, int depth){ + if(cameraFade){ + return null; + }else{ + //establish colorFade object: + cameraFade = new GameObject("iTween Camera Fade"); + cameraFade.transform.position= new Vector3(.5f,.5f,depth); + cameraFade.AddComponent(); + cameraFade.GetComponent().texture=texture; + cameraFade.GetComponent().color = new Color(.5f,.5f,.5f,0); + return cameraFade; + } + } + + /// + /// Creates a GameObject (if it doesn't exist) at the default depth that can be used to simulate a camera fade. + /// + /// + /// A + /// + /// + /// A for a reference to the CameraFade. + /// + public static GameObject CameraFadeAdd(Texture2D texture){ + if(cameraFade){ + return null; + }else{ + //establish colorFade object: + cameraFade = new GameObject("iTween Camera Fade"); + cameraFade.transform.position= new Vector3(.5f,.5f,Defaults.cameraFadeDepth); + cameraFade.AddComponent(); + cameraFade.GetComponent().texture=texture; + cameraFade.GetComponent().color = new Color(.5f,.5f,.5f,0); + return cameraFade; + } + } + + /// + /// Creates a GameObject (if it doesn't exist) at the default depth filled with black that can be used to simulate a camera fade. + /// + /// + /// A for a reference to the CameraFade. + /// + public static GameObject CameraFadeAdd(){ + if(cameraFade){ + return null; + }else{ + //establish colorFade object: + cameraFade = new GameObject("iTween Camera Fade"); + cameraFade.transform.position= new Vector3(.5f,.5f,Defaults.cameraFadeDepth); + cameraFade.AddComponent(); + cameraFade.GetComponent().texture=CameraTexture(Color.black); + cameraFade.GetComponent().color = new Color(.5f,.5f,.5f,0); + return cameraFade; + } + } + + + //################################# + //# RESUME UTILITIES AND OVERLOADS # + //################################# + + /// + /// Resume all iTweens on a GameObject. + /// + public static void Resume(GameObject target){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + item.enabled=true; + } + } + + /// + /// Resume all iTweens on a GameObject including its children. + /// + public static void Resume(GameObject target, bool includechildren){ + Resume(target); + if(includechildren){ + foreach(Transform child in target.transform){ + Resume(child.gameObject,true); + } + } + } + + /// + /// Resume all iTweens on a GameObject of a particular type. + /// + /// A name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Resume(GameObject target, string type){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.enabled=true; + } + } + } + + /// + /// Resume all iTweens on a GameObject of a particular type including its children. + /// + /// A name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Resume(GameObject target, string type, bool includechildren){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.enabled=true; + } + } + if(includechildren){ + foreach(Transform child in target.transform){ + Resume(child.gameObject,type,true); + } + } + } + + /// + /// Resume all iTweens in scene. + /// + public static void Resume(){ + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + Resume(target); + } + } + + /// + /// Resume all iTweens in scene of a particular type. + /// + /// + /// A name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Resume(string type){ + ArrayList resumeArray = new ArrayList(); + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + resumeArray.Insert(resumeArray.Count,target); + } + + for (int i = 0; i < resumeArray.Count; i++) { + Resume((GameObject)resumeArray[i],type); + } + } + + //################################# + //# PAUSE UTILITIES AND OVERLOADS # + //################################# + + /// + /// Pause all iTweens on a GameObject. + /// + public static void Pause(GameObject target){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + if(item.delay>0){ + item.delay-=Time.time-item.delayStarted; + item.StopCoroutine("TweenDelay"); + } + item.isPaused=true; + item.enabled=false; + } + } + + /// + /// Pause all iTweens on a GameObject including its children. + /// + public static void Pause(GameObject target, bool includechildren){ + Pause(target); + if(includechildren){ + foreach(Transform child in target.transform){ + Pause(child.gameObject,true); + } + } + } + + /// + /// Pause all iTweens on a GameObject of a particular type. + /// + /// A name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Pause(GameObject target, string type){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + if(item.delay>0){ + item.delay-=Time.time-item.delayStarted; + item.StopCoroutine("TweenDelay"); + } + item.isPaused=true; + item.enabled=false; + } + } + } + + /// + /// Pause all iTweens on a GameObject of a particular type including its children. + /// + /// A name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Pause(GameObject target, string type, bool includechildren){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + if(item.delay>0){ + item.delay-=Time.time-item.delayStarted; + item.StopCoroutine("TweenDelay"); + } + item.isPaused=true; + item.enabled=false; + } + } + if(includechildren){ + foreach(Transform child in target.transform){ + Pause(child.gameObject,type,true); + } + } + } + + /// + /// Pause all iTweens in scene. + /// + public static void Pause(){ + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + Pause(target); + } + } + + /// + /// Pause all iTweens in scene of a particular type. + /// + /// + /// A name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Pause(string type){ + ArrayList pauseArray = new ArrayList(); + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + pauseArray.Insert(pauseArray.Count,target); + } + + for (int i = 0; i < pauseArray.Count; i++) { + Pause((GameObject)pauseArray[i],type); + } + } + + //################################# + //# COUNT UTILITIES AND OVERLOADS # + //################################# + + /// + /// Count all iTweens in current scene. + /// + public static int Count(){ + return(tweens.Count); + } + + /// + /// Count all iTweens in current scene of a particular type. + /// + /// + /// A name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static int Count(string type){ + int tweenCount = 0; + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + string targetType = (string)currentTween["type"]+(string)currentTween["method"]; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + tweenCount++; + } + } + + return(tweenCount); + } + + /// + /// Count all iTweens on a GameObject. + /// + public static int Count(GameObject target){ + Component[] tweens = target.GetComponents(typeof(iTween)); + return(tweens.Length); + } + + /// + /// Count all iTweens on a GameObject of a particular type. + /// + /// + /// A name of the type of iTween you would like to count. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static int Count(GameObject target, string type){ + int tweenCount = 0; + Component[] tweens = target.GetComponents(typeof(iTween));foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + tweenCount++; + } + } + return(tweenCount); + } + + //################################ + //# STOP UTILITIES AND OVERLOADS # + //################################ + + /// + /// Stop and destroy all Tweens in current scene. + /// + public static void Stop(){ + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + Stop(target); + } + tweens.Clear(); + } + + /// + /// Stop and destroy all iTweens in current scene of a particular type. + /// + /// + /// A name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Stop(string type){ + ArrayList stopArray = new ArrayList(); + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + stopArray.Insert(stopArray.Count,target); + } + + for (int i = 0; i < stopArray.Count; i++) { + Stop((GameObject)stopArray[i],type); + } + } + + /* GFX47 MOD START */ + /// + /// Stop and destroy all iTweens in current scene of a particular name. + /// + /// + /// The name of iTween you would like to stop. + /// + public static void StopByName(string name){ + ArrayList stopArray = new ArrayList(); + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + stopArray.Insert(stopArray.Count,target); + } + + for (int i = 0; i < stopArray.Count; i++) { + StopByName((GameObject)stopArray[i],name); + } + } + /* GFX47 MOD END */ + + /// + /// Stop and destroy all iTweens on a GameObject. + /// + public static void Stop(GameObject target){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + item.Dispose(); + } + } + + /// + /// Stop and destroy all iTweens on a GameObject including its children. + /// + public static void Stop(GameObject target, bool includechildren){ + Stop(target); + if(includechildren){ + foreach(Transform child in target.transform){ + Stop(child.gameObject,true); + } + } + } + + /// + /// Stop and destroy all iTweens on a GameObject of a particular type. + /// + /// A name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Stop(GameObject target, string type){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.Dispose(); + } + } + } + + /* GFX47 MOD START */ + /// + /// Stop and destroy all iTweens on a GameObject of a particular name. + /// + /// The name of iTween you would like to stop. + /// + public static void StopByName(GameObject target, string name){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + /*string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.Dispose(); + }*/ + if(item._name == name){ + item.Dispose(); + } + } + } + /* GFX47 MOD END */ + + /// + /// Stop and destroy all iTweens on a GameObject of a particular type including its children. + /// + /// A name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Stop(GameObject target, string type, bool includechildren){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.Dispose(); + } + } + if(includechildren){ + foreach(Transform child in target.transform){ + Stop(child.gameObject,type,true); + } + } + } + + /* GFX47 MOD START */ + /// + /// Stop and destroy all iTweens on a GameObject of a particular name including its children. + /// + /// The name of iTween you would like to stop. + /// + public static void StopByName(GameObject target, string name, bool includechildren){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + /*string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.Dispose(); + }*/ + if(item._name == name){ + item.Dispose(); + } + } + if(includechildren){ + foreach(Transform child in target.transform){ + //Stop(child.gameObject,type,true); + StopByName(child.gameObject,name,true); + } + } + } + /* GFX47 MOD END */ + + /// + /// Universal interface to help in the creation of Hashtables. Especially useful for C# users. + /// + /// + /// A of alternating name value pairs. For example "time",1,"delay",2... + /// + /// + /// A + /// + public static Hashtable Hash(params object[] args){ + Hashtable hashTable = new Hashtable(args.Length/2); + if (args.Length %2 != 0) { + Debug.LogError("Tween Error: Hash requires an even number of arguments!"); + return null; + }else{ + int i = 0; + while(i < args.Length - 1) { + hashTable.Add(args[i], args[i+1]); + i += 2; + } + return hashTable; + } + } + + #endregion + +#region Component Segments + + void Awake(){ + RetrieveArgs(); + lastRealTime = Time.realtimeSinceStartup; // Added by PressPlay + } + + IEnumerator Start(){ + if(delay > 0){ + yield return StartCoroutine("TweenDelay"); + } + TweenStart(); + } + + //non-physics + void Update(){ + if(isRunning && !physics){ + if(!reverse){ + if(percentage<1f){ + TweenUpdate(); + }else{ + TweenComplete(); + } + }else{ + if(percentage>0){ + TweenUpdate(); + }else{ + TweenComplete(); + } + } + } + } + + //physics + void FixedUpdate(){ + if(isRunning && physics){ + if(!reverse){ + if(percentage<1f){ + TweenUpdate(); + }else{ + TweenComplete(); + } + }else{ + if(percentage>0){ + TweenUpdate(); + }else{ + TweenComplete(); + } + } + } + } + + void LateUpdate(){ + //look applications: + if(tweenArguments.Contains("looktarget") && isRunning){ + if(type =="move" || type =="shake" || type=="punch"){ + LookUpdate(gameObject,tweenArguments); + } + } + } + + void OnEnable(){ + if(isRunning){ + EnableKinematic(); + } + + //resume delay: + if(isPaused){ + isPaused=false; + if(delay > 0){ + wasPaused=true; + ResumeDelay(); + } + } + } + + void OnDisable(){ + DisableKinematic(); + } + + #endregion + +#region Internal Helpers + + private static void DrawLineHelper(Vector3[] line, Color color, string method){ + Gizmos.color=color; + for (int i = 0; i < line.Length-1; i++) { + if(method == "gizmos"){ + Gizmos.DrawLine(line[i], line[i+1]);; + }else if(method == "handles"){ + Debug.LogError("iTween Error: Drawing a line with Handles is temporarily disabled because of compatability issues with Unity 2.6!"); + //UnityEditor.Handles.DrawLine(line[i], line[i+1]); + } + } + } + + private static void DrawPathHelper(Vector3[] path, Color color, string method){ + Vector3[] vector3s = PathControlPointGenerator(path); + + //Line Draw: + Vector3 prevPt = Interp(vector3s,0); + Gizmos.color=color; + int SmoothAmount = path.Length*20; + for (int i = 1; i <= SmoothAmount; i++) { + float pm = (float) i / SmoothAmount; + Vector3 currPt = Interp(vector3s,pm); + if(method == "gizmos"){ + Gizmos.DrawLine(currPt, prevPt); + }else if(method == "handles"){ + Debug.LogError("iTween Error: Drawing a path with Handles is temporarily disabled because of compatability issues with Unity 2.6!"); + //UnityEditor.Handles.DrawLine(currPt, prevPt); + } + prevPt = currPt; + } + } + + private static Vector3[] PathControlPointGenerator(Vector3[] path){ + Vector3[] suppliedPath; + Vector3[] vector3s; + + //create and store path points: + suppliedPath = path; + + //populate calculate path; + int offset = 2; + vector3s = new Vector3[suppliedPath.Length+offset]; + Array.Copy(suppliedPath,0,vector3s,1,suppliedPath.Length); + + //populate start and end control points: + //vector3s[0] = vector3s[1] - vector3s[2]; + vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]); + vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]); + + //is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline! + if(vector3s[1] == vector3s[vector3s.Length-2]){ + Vector3[] tmpLoopSpline = new Vector3[vector3s.Length]; + Array.Copy(vector3s,tmpLoopSpline,vector3s.Length); + tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3]; + tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2]; + vector3s=new Vector3[tmpLoopSpline.Length]; + Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length); + } + + return(vector3s); + } + + //andeeee from the Unity forum's steller Catmull-Rom class ( http://forum.unity3d.com/viewtopic.php?p=218400#218400 ): + private static Vector3 Interp(Vector3[] pts, float t){ + int numSections = pts.Length - 3; + int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); + float u = t * (float) numSections - (float) currPt; + + Vector3 a = pts[currPt]; + Vector3 b = pts[currPt + 1]; + Vector3 c = pts[currPt + 2]; + Vector3 d = pts[currPt + 3]; + + return .5f * ( + (-a + 3f * b - 3f * c + d) * (u * u * u) + + (2f * a - 5f * b + 4f * c - d) * (u * u) + + (-a + c) * u + + 2f * b + ); + } + + //andeeee from the Unity forum's steller Catmull-Rom class ( http://forum.unity3d.com/viewtopic.php?p=218400#218400 ): + private class CRSpline { + public Vector3[] pts; + + public CRSpline(params Vector3[] pts) { + this.pts = new Vector3[pts.Length]; + Array.Copy(pts, this.pts, pts.Length); + } + + + public Vector3 Interp(float t) { + int numSections = pts.Length - 3; + int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); + float u = t * (float) numSections - (float) currPt; + Vector3 a = pts[currPt]; + Vector3 b = pts[currPt + 1]; + Vector3 c = pts[currPt + 2]; + Vector3 d = pts[currPt + 3]; + return .5f*((-a+3f*b-3f*c+d)*(u*u*u)+(2f*a-5f*b+4f*c-d)*(u*u)+(-a+c)*u+2f*b); + } + } + + //catalog new tween and add component phase of iTween: + static void Launch(GameObject target, Hashtable args){ + if(!args.Contains("id")){ + args["id"] = GenerateID(); + } + if(!args.Contains("target")){ + args["target"] = target; + } + tweens.Insert(0,args); + target.AddComponent(); + } + + //cast any accidentally supplied doubles and ints as floats as iTween only uses floats internally and unify parameter case: + static Hashtable CleanArgs(Hashtable args){ + Hashtable argsCopy = new Hashtable(args.Count); + Hashtable argsCaseUnified = new Hashtable(args.Count); + + foreach (DictionaryEntry item in args) { + argsCopy.Add(item.Key, item.Value); + } + + foreach (DictionaryEntry item in argsCopy) { + if(item.Value.GetType() == typeof(System.Int32)){ + int original = (int)item.Value; + float casted = (float)original; + args[item.Key] = casted; + } + if(item.Value.GetType() == typeof(System.Double)){ + double original = (double)item.Value; + float casted = (float)original; + args[item.Key] = casted; + } + } + + //unify parameter case: + foreach (DictionaryEntry item in args) { + argsCaseUnified.Add(item.Key.ToString().ToLower(), item.Value); + } + + //swap back case unification: + args = argsCaseUnified; + + return args; + } + + //random ID generator: + static string GenerateID(){ + int strlen = 15; + char[] chars = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8'}; + int num_chars = chars.Length - 1; + string randomChar = ""; + for (int i = 0; i < strlen; i++) { + randomChar += chars[(int)Mathf.Floor(UnityEngine.Random.Range(0,num_chars))]; + } + return randomChar; + } + + //grab and set generic, neccesary iTween arguments: + void RetrieveArgs(){ + foreach (Hashtable item in tweens) { + if((GameObject)item["target"] == gameObject){ + tweenArguments=item; + break; + } + } + + id=(string)tweenArguments["id"]; + type=(string)tweenArguments["type"]; + /* GFX47 MOD START */ + _name=(string)tweenArguments["name"]; + /* GFX47 MOD END */ + method=(string)tweenArguments["method"]; + + if(tweenArguments.Contains("time")){ + time=(float)tweenArguments["time"]; + }else{ + time=Defaults.time; + } + + //do we need to use physics, is there a rigidbody? + if(GetComponent() != null){ + physics=true; + } + + if(tweenArguments.Contains("delay")){ + delay=(float)tweenArguments["delay"]; + }else{ + delay=Defaults.delay; + } + + if(tweenArguments.Contains("namedcolorvalue")){ + //allows namedcolorvalue to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability: + if(tweenArguments["namedcolorvalue"].GetType() == typeof(NamedValueColor)){ + namedcolorvalue=(NamedValueColor)tweenArguments["namedcolorvalue"]; + }else{ + try { + namedcolorvalue=(NamedValueColor)Enum.Parse(typeof(NamedValueColor),(string)tweenArguments["namedcolorvalue"],true); + } catch { + Debug.LogWarning("iTween: Unsupported namedcolorvalue supplied! Default will be used."); + namedcolorvalue = iTween.NamedValueColor._Color; + } + } + }else{ + namedcolorvalue=Defaults.namedColorValue; + } + + if(tweenArguments.Contains("looptype")){ + //allows loopType to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability: + if(tweenArguments["looptype"].GetType() == typeof(LoopType)){ + loopType=(LoopType)tweenArguments["looptype"]; + }else{ + try { + loopType=(LoopType)Enum.Parse(typeof(LoopType),(string)tweenArguments["looptype"],true); + } catch { + Debug.LogWarning("iTween: Unsupported loopType supplied! Default will be used."); + loopType = iTween.LoopType.none; + } + } + }else{ + loopType = iTween.LoopType.none; + } + + if(tweenArguments.Contains("easetype")){ + //allows easeType to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability: + if(tweenArguments["easetype"].GetType() == typeof(EaseType)){ + easeType=(EaseType)tweenArguments["easetype"]; + }else{ + try { + easeType=(EaseType)Enum.Parse(typeof(EaseType),(string)tweenArguments["easetype"],true); + } catch { + Debug.LogWarning("iTween: Unsupported easeType supplied! Default will be used."); + easeType=Defaults.easeType; + } + } + }else{ + easeType=Defaults.easeType; + } + + if(tweenArguments.Contains("space")){ + //allows space to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability: + if(tweenArguments["space"].GetType() == typeof(Space)){ + space=(Space)tweenArguments["space"]; + }else{ + try { + space=(Space)Enum.Parse(typeof(Space),(string)tweenArguments["space"],true); + } catch { + Debug.LogWarning("iTween: Unsupported space supplied! Default will be used."); + space = Defaults.space; + } + } + }else{ + space = Defaults.space; + } + + if(tweenArguments.Contains("islocal")){ + isLocal = (bool)tweenArguments["islocal"]; + }else{ + isLocal = Defaults.isLocal; + } + + // Added by PressPlay + if (tweenArguments.Contains("ignoretimescale")) + { + useRealTime = (bool)tweenArguments["ignoretimescale"]; + } + else + { + useRealTime = Defaults.useRealTime; + } + + //instantiates a cached ease equation reference: + GetEasingFunction(); + } + + //instantiates a cached ease equation refrence: + void GetEasingFunction(){ + switch (easeType){ + case EaseType.easeInQuad: + ease = new EasingFunction(easeInQuad); + break; + case EaseType.easeOutQuad: + ease = new EasingFunction(easeOutQuad); + break; + case EaseType.easeInOutQuad: + ease = new EasingFunction(easeInOutQuad); + break; + case EaseType.easeInCubic: + ease = new EasingFunction(easeInCubic); + break; + case EaseType.easeOutCubic: + ease = new EasingFunction(easeOutCubic); + break; + case EaseType.easeInOutCubic: + ease = new EasingFunction(easeInOutCubic); + break; + case EaseType.easeInQuart: + ease = new EasingFunction(easeInQuart); + break; + case EaseType.easeOutQuart: + ease = new EasingFunction(easeOutQuart); + break; + case EaseType.easeInOutQuart: + ease = new EasingFunction(easeInOutQuart); + break; + case EaseType.easeInQuint: + ease = new EasingFunction(easeInQuint); + break; + case EaseType.easeOutQuint: + ease = new EasingFunction(easeOutQuint); + break; + case EaseType.easeInOutQuint: + ease = new EasingFunction(easeInOutQuint); + break; + case EaseType.easeInSine: + ease = new EasingFunction(easeInSine); + break; + case EaseType.easeOutSine: + ease = new EasingFunction(easeOutSine); + break; + case EaseType.easeInOutSine: + ease = new EasingFunction(easeInOutSine); + break; + case EaseType.easeInExpo: + ease = new EasingFunction(easeInExpo); + break; + case EaseType.easeOutExpo: + ease = new EasingFunction(easeOutExpo); + break; + case EaseType.easeInOutExpo: + ease = new EasingFunction(easeInOutExpo); + break; + case EaseType.easeInCirc: + ease = new EasingFunction(easeInCirc); + break; + case EaseType.easeOutCirc: + ease = new EasingFunction(easeOutCirc); + break; + case EaseType.easeInOutCirc: + ease = new EasingFunction(easeInOutCirc); + break; + case EaseType.linear: + ease = new EasingFunction(linear); + break; + case EaseType.spring: + ease = new EasingFunction(spring); + break; + /* GFX47 MOD START */ + /*case EaseType.bounce: + ease = new EasingFunction(bounce); + break;*/ + case EaseType.easeInBounce: + ease = new EasingFunction(easeInBounce); + break; + case EaseType.easeOutBounce: + ease = new EasingFunction(easeOutBounce); + break; + case EaseType.easeInOutBounce: + ease = new EasingFunction(easeInOutBounce); + break; + /* GFX47 MOD END */ + case EaseType.easeInBack: + ease = new EasingFunction(easeInBack); + break; + case EaseType.easeOutBack: + ease = new EasingFunction(easeOutBack); + break; + case EaseType.easeInOutBack: + ease = new EasingFunction(easeInOutBack); + break; + /* GFX47 MOD START */ + /*case EaseType.elastic: + ease = new EasingFunction(elastic); + break;*/ + case EaseType.easeInElastic: + ease = new EasingFunction(easeInElastic); + break; + case EaseType.easeOutElastic: + ease = new EasingFunction(easeOutElastic); + break; + case EaseType.easeInOutElastic: + ease = new EasingFunction(easeInOutElastic); + break; + /* GFX47 MOD END */ + } + } + + //calculate percentage of tween based on time: + void UpdatePercentage(){ + + // Added by PressPlay + if (useRealTime) + { + runningTime += (Time.realtimeSinceStartup - lastRealTime); + } + else + { + runningTime += Time.deltaTime; + } + + if(reverse){ + percentage = 1 - runningTime/time; + }else{ + percentage = runningTime/time; + } + + lastRealTime = Time.realtimeSinceStartup; // Added by PressPlay + } + + void CallBack(string callbackType){ + if (tweenArguments.Contains(callbackType) && !tweenArguments.Contains("ischild")) { + //establish target: + GameObject target; + if (tweenArguments.Contains(callbackType+"target")) { + target=(GameObject)tweenArguments[callbackType+"target"]; + }else{ + target=gameObject; + } + + //throw an error if a string wasn't passed for callback: + if (tweenArguments[callbackType].GetType() == typeof(System.String)) { + target.SendMessage((string)tweenArguments[callbackType],(object)tweenArguments[callbackType+"params"],SendMessageOptions.DontRequireReceiver); + }else{ + Debug.LogError("iTween Error: Callback method references must be passed as a String!"); + Destroy (this); + } + } + } + + void Dispose(){ + for (int i = 0; i < tweens.Count; i++) { + Hashtable tweenEntry = (Hashtable)tweens[i]; + if ((string)tweenEntry["id"] == id){ + tweens.RemoveAt(i); + break; + } + } + Destroy(this); + } + + void ConflictCheck(){//if a new iTween is about to run and is of the same type as an in progress iTween this will destroy the previous if the new one is NOT identical in every way or it will destroy the new iTween if they are: + Component[] tweens = GetComponents(typeof(iTween)); + foreach (iTween item in tweens) { + if(item.type == "value"){ + return; + }else if(item.isRunning && item.type==type){ + //cancel out if this is a shake or punch variant: + if (item.method != method) { + return; + } + + //step 1: check for length first since it's the fastest: + if(item.tweenArguments.Count != tweenArguments.Count){ + item.Dispose(); + return; + } + + //step 2: side-by-side check to figure out if this is an identical tween scenario to handle Update usages of iTween: + foreach (DictionaryEntry currentProp in tweenArguments) { + if(!item.tweenArguments.Contains(currentProp.Key)){ + item.Dispose(); + return; + }else{ + if(!item.tweenArguments[currentProp.Key].Equals(tweenArguments[currentProp.Key]) && (string)currentProp.Key != "id"){//if we aren't comparing ids and something isn't exactly the same replace the running iTween: + item.Dispose(); + return; + } + } + } + + //step 3: prevent a new iTween addition if it is identical to the currently running iTween + Dispose(); + //Destroy(this); + } + } + } + + void EnableKinematic(){ + /* + if(gameObject.GetComponent(typeof(Rigidbody))){ + if(!rigidbody.isKinematic){ + kinematic=true; + rigidbody.isKinematic=true; + } + } + */ + } + + void DisableKinematic(){ + /* + if(kinematic && rigidbody.isKinematic==true){ + kinematic=false; + rigidbody.isKinematic=false; + } + */ + } + + void ResumeDelay(){ + StartCoroutine("TweenDelay"); + } + + #endregion + +#region Easing Curves + + private float linear(float start, float end, float value){ + return Mathf.Lerp(start, end, value); + } + + private float clerp(float start, float end, float value){ + float min = 0.0f; + float max = 360.0f; + float half = Mathf.Abs((max - min) / 2.0f); + float retval = 0.0f; + float diff = 0.0f; + if ((end - start) < -half){ + diff = ((max - start) + end) * value; + retval = start + diff; + }else if ((end - start) > half){ + diff = -((max - end) + start) * value; + retval = start + diff; + }else retval = start + (end - start) * value; + return retval; + } + + private float spring(float start, float end, float value){ + value = Mathf.Clamp01(value); + value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value))); + return start + (end - start) * value; + } + + private float easeInQuad(float start, float end, float value){ + end -= start; + return end * value * value + start; + } + + private float easeOutQuad(float start, float end, float value){ + end -= start; + return -end * value * (value - 2) + start; + } + + private float easeInOutQuad(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value + start; + value--; + return -end / 2 * (value * (value - 2) - 1) + start; + } + + private float easeInCubic(float start, float end, float value){ + end -= start; + return end * value * value * value + start; + } + + private float easeOutCubic(float start, float end, float value){ + value--; + end -= start; + return end * (value * value * value + 1) + start; + } + + private float easeInOutCubic(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value + start; + value -= 2; + return end / 2 * (value * value * value + 2) + start; + } + + private float easeInQuart(float start, float end, float value){ + end -= start; + return end * value * value * value * value + start; + } + + private float easeOutQuart(float start, float end, float value){ + value--; + end -= start; + return -end * (value * value * value * value - 1) + start; + } + + private float easeInOutQuart(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value * value + start; + value -= 2; + return -end / 2 * (value * value * value * value - 2) + start; + } + + private float easeInQuint(float start, float end, float value){ + end -= start; + return end * value * value * value * value * value + start; + } + + private float easeOutQuint(float start, float end, float value){ + value--; + end -= start; + return end * (value * value * value * value * value + 1) + start; + } + + private float easeInOutQuint(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value * value * value + start; + value -= 2; + return end / 2 * (value * value * value * value * value + 2) + start; + } + + private float easeInSine(float start, float end, float value){ + end -= start; + return -end * Mathf.Cos(value / 1 * (Mathf.PI / 2)) + end + start; + } + + private float easeOutSine(float start, float end, float value){ + end -= start; + return end * Mathf.Sin(value / 1 * (Mathf.PI / 2)) + start; + } + + private float easeInOutSine(float start, float end, float value){ + end -= start; + return -end / 2 * (Mathf.Cos(Mathf.PI * value / 1) - 1) + start; + } + + private float easeInExpo(float start, float end, float value){ + end -= start; + return end * Mathf.Pow(2, 10 * (value / 1 - 1)) + start; + } + + private float easeOutExpo(float start, float end, float value){ + end -= start; + return end * (-Mathf.Pow(2, -10 * value / 1) + 1) + start; + } + + private float easeInOutExpo(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * Mathf.Pow(2, 10 * (value - 1)) + start; + value--; + return end / 2 * (-Mathf.Pow(2, -10 * value) + 2) + start; + } + + private float easeInCirc(float start, float end, float value){ + end -= start; + return -end * (Mathf.Sqrt(1 - value * value) - 1) + start; + } + + private float easeOutCirc(float start, float end, float value){ + value--; + end -= start; + return end * Mathf.Sqrt(1 - value * value) + start; + } + + private float easeInOutCirc(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return -end / 2 * (Mathf.Sqrt(1 - value * value) - 1) + start; + value -= 2; + return end / 2 * (Mathf.Sqrt(1 - value * value) + 1) + start; + } + + /* GFX47 MOD START */ + private float easeInBounce(float start, float end, float value){ + end -= start; + float d = 1f; + return end - easeOutBounce(0, end, d-value) + start; + } + /* GFX47 MOD END */ + + /* GFX47 MOD START */ + //private float bounce(float start, float end, float value){ + private float easeOutBounce(float start, float end, float value){ + value /= 1f; + end -= start; + if (value < (1 / 2.75f)){ + return end * (7.5625f * value * value) + start; + }else if (value < (2 / 2.75f)){ + value -= (1.5f / 2.75f); + return end * (7.5625f * (value) * value + .75f) + start; + }else if (value < (2.5 / 2.75)){ + value -= (2.25f / 2.75f); + return end * (7.5625f * (value) * value + .9375f) + start; + }else{ + value -= (2.625f / 2.75f); + return end * (7.5625f * (value) * value + .984375f) + start; + } + } + /* GFX47 MOD END */ + + /* GFX47 MOD START */ + private float easeInOutBounce(float start, float end, float value){ + end -= start; + float d = 1f; + if (value < d/2) return easeInBounce(0, end, value*2) * 0.5f + start; + else return easeOutBounce(0, end, value*2-d) * 0.5f + end*0.5f + start; + } + /* GFX47 MOD END */ + + private float easeInBack(float start, float end, float value){ + end -= start; + value /= 1; + float s = 1.70158f; + return end * (value) * value * ((s + 1) * value - s) + start; + } + + private float easeOutBack(float start, float end, float value){ + float s = 1.70158f; + end -= start; + value = (value / 1) - 1; + return end * ((value) * value * ((s + 1) * value + s) + 1) + start; + } + + private float easeInOutBack(float start, float end, float value){ + float s = 1.70158f; + end -= start; + value /= .5f; + if ((value) < 1){ + s *= (1.525f); + return end / 2 * (value * value * (((s) + 1) * value - s)) + start; + } + value -= 2; + s *= (1.525f); + return end / 2 * ((value) * value * (((s) + 1) * value + s) + 2) + start; + } + + private float punch(float amplitude, float value){ + float s = 9; + if (value == 0){ + return 0; + } + if (value == 1){ + return 0; + } + float period = 1 * 0.3f; + s = period / (2 * Mathf.PI) * Mathf.Asin(0); + return (amplitude * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * 1 - s) * (2 * Mathf.PI) / period)); + } + + /* GFX47 MOD START */ + private float easeInElastic(float start, float end, float value){ + end -= start; + + float d = 1f; + float p = d * .3f; + float s = 0; + float a = 0; + + if (value == 0) return start; + + if ((value /= d) == 1) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4; + }else{ + s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); + } + + return -(a * Mathf.Pow(2, 10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start; + } + /* GFX47 MOD END */ + + /* GFX47 MOD START */ + //private float elastic(float start, float end, float value){ + private float easeOutElastic(float start, float end, float value){ + /* GFX47 MOD END */ + //Thank you to rafael.marteleto for fixing this as a port over from Pedro's UnityTween + end -= start; + + float d = 1f; + float p = d * .3f; + float s = 0; + float a = 0; + + if (value == 0) return start; + + if ((value /= d) == 1) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4; + }else{ + s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); + } + + return (a * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) + end + start); + } + + /* GFX47 MOD START */ + private float easeInOutElastic(float start, float end, float value){ + end -= start; + + float d = 1f; + float p = d * .3f; + float s = 0; + float a = 0; + + if (value == 0) return start; + + if ((value /= d/2) == 2) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4; + }else{ + s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); + } + + if (value < 1) return -0.5f * (a * Mathf.Pow(2, 10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start; + return a * Mathf.Pow(2, -10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) * 0.5f + end + start; + } + /* GFX47 MOD END */ + + #endregion + +#region Deprecated and Renamed + /* + public static void audioFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: audioFrom() has been renamed to AudioFrom().");} + public static void audioTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: audioTo() has been renamed to AudioTo().");} + public static void colorFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: colorFrom() has been renamed to ColorFrom().");} + public static void colorTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: colorTo() has been renamed to ColorTo().");} + public static void fadeFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: fadeFrom() has been renamed to FadeFrom().");} + public static void fadeTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: fadeTo() has been renamed to FadeTo().");} + public static void lookFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookFrom() has been renamed to LookFrom().");} + public static void lookFromWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookFromWorld() has been deprecated. Please investigate LookFrom().");} + public static void lookTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookTo() has been renamed to LookTo().");} + public static void lookToUpdate(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookToUpdate() has been renamed to LookUpdate().");} + public static void lookToUpdateWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookToUpdateWorld() has been deprecated. Please investigate LookUpdate().");} + public static void moveAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAdd() has been renamed to MoveAdd().");} + public static void moveAddWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAddWorld() has been deprecated. Please investigate MoveAdd().");} + public static void moveBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveBy() has been renamed to MoveBy().");} + public static void moveByWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAddWorld() has been deprecated. Please investigate MoveAdd().");} + public static void moveFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveFrom() has been renamed to MoveFrom().");} + public static void moveFromWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveFromWorld() has been deprecated. Please investigate MoveFrom().");} + public static void moveTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveTo() has been renamed to MoveTo().");} + public static void moveToBezier(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToBezier() has been deprecated. Please investigate MoveTo() and the "path" property.");} + public static void moveToBezierWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToBezierWorld() has been deprecated. Please investigate MoveTo() and the "path" property.");} + public static void moveToUpdate(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToUpdate() has been renamed to MoveUpdate().");} + public static void moveToUpdateWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToUpdateWorld() has been deprecated. Please investigate MoveUpdate().");} + public static void moveToWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToWorld() has been deprecated. Please investigate MoveTo().");} + public static void punchPosition(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPosition() has been renamed to PunchPosition().");} + public static void punchPositionWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPositionWorld() has been deprecated. Please investigate PunchPosition().");} + public static void punchRotation(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPosition() has been renamed to PunchRotation().");} + public static void punchRotationWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchRotationWorld() has been deprecated. Please investigate PunchRotation().");} + public static void punchScale(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchScale() has been renamed to PunchScale().");} + public static void rotateAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateAdd() has been renamed to RotateAdd().");} + public static void rotateBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateBy() has been renamed to RotateBy().");} + public static void rotateByWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateByWorld() has been deprecated. Please investigate RotateBy().");} + public static void rotateFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateFrom() has been renamed to RotateFrom().");} + public static void rotateTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateTo() has been renamed to RotateTo().");} + public static void scaleAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleAdd() has been renamed to ScaleAdd().");} + public static void scaleBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleBy() has been renamed to ScaleBy().");} + public static void scaleFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleFrom() has been renamed to ScaleFrom().");} + public static void scaleTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleTo() has been renamed to ScaleTo().");} + public static void shake(GameObject target, Hashtable args){Debug.LogError("iTween Error: scale() has been deprecated. Please investigate ShakePosition(), ShakeRotation() and ShakeScale().");} + public static void shakeWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: shakeWorld() has been deprecated. Please investigate ShakePosition(), ShakeRotation() and ShakeScale().");} + public static void stab(GameObject target, Hashtable args){Debug.LogError("iTween Error: stab() has been renamed to Stab().");} + public static void stop(GameObject target, Hashtable args){Debug.LogError("iTween Error: stop() has been renamed to Stop().");} + public static void stopType(GameObject target, Hashtable args){Debug.LogError("iTween Error: stopType() has been deprecated. Please investigate Stop().");} + public static void tweenCount(GameObject target, Hashtable args){Debug.LogError("iTween Error: tweenCount() has been deprecated. Please investigate Count().");} + */ + #endregion +} + + +#else + +// Copyright (c) 2011 Bob Berkebile (pixelplacment) +// Please direct any bugs/comments/suggestions to http://pixelplacement.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +/* +TERMS OF USE - EASING EQUATIONS +Open source under the BSD License. +Copyright (c)2001 Robert Penner +All rights reserved. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#region Namespaces +using System; +using System.Collections; +using System.Reflection; +using UnityEngine; +#endregion + +/// +/// Version: 2.0.44 +/// Author: Bob Berkebile (http://pixelplacement.com) +/// Support: http://itween.pixelplacement.com +/// +public class iTween : MonoBehaviour{ + + #region Variables + + //repository of all living iTweens: + public static ArrayList tweens = new ArrayList(); + + //camera fade object: + private static GameObject cameraFade; + + //status members (made public for visual troubleshooting in the inspector): + public string id, type, method; + public iTween.EaseType easeType; + public float time, delay; + public LoopType loopType; + public bool isRunning,isPaused; + /* GFX47 MOD START */ + public string _name; + /* GFX47 MOD END */ + + //private members: + private float runningTime, percentage; + private float delayStarted; //probably not neccesary that this be protected but it shuts Unity's compiler up about this being "never used" + private bool kinematic, isLocal, loop, reverse, wasPaused, physics; + private Hashtable tweenArguments; + private Space space; + private delegate float EasingFunction(float start, float end, float value); + private delegate void ApplyTween(); + private EasingFunction ease; + private ApplyTween apply; + private AudioSource audioSource; + private Vector3[] vector3s; + private Vector2[] vector2s; + private Color[,] colors; + private float[] floats; + private Rect[] rects; + private CRSpline path; + private Vector3 preUpdate; + private Vector3 postUpdate; + private NamedValueColor namedcolorvalue; + + private float lastRealTime; // Added by PressPlay + private bool useRealTime; // Added by PressPlay + + /// + /// The type of easing to use based on Robert Penner's open source easing equations (http://www.robertpenner.com/easing_terms_of_use.html). + /// + public enum EaseType{ + easeInQuad, + easeOutQuad, + easeInOutQuad, + easeInCubic, + easeOutCubic, + easeInOutCubic, + easeInQuart, + easeOutQuart, + easeInOutQuart, + easeInQuint, + easeOutQuint, + easeInOutQuint, + easeInSine, + easeOutSine, + easeInOutSine, + easeInExpo, + easeOutExpo, + easeInOutExpo, + easeInCirc, + easeOutCirc, + easeInOutCirc, + linear, + spring, + /* GFX47 MOD START */ + //bounce, + easeInBounce, + easeOutBounce, + easeInOutBounce, + /* GFX47 MOD END */ + easeInBack, + easeOutBack, + easeInOutBack, + /* GFX47 MOD START */ + //elastic, + easeInElastic, + easeOutElastic, + easeInOutElastic, + /* GFX47 MOD END */ + punch + } + + /// + /// The type of loop (if any) to use. + /// + public enum LoopType{ + /// + /// Do not loop. + /// + none, + /// + /// Rewind and replay. + /// + loop, + /// + /// Ping pong the animation back and forth. + /// + pingPong + } + + /// + /// Many shaders use more than one color. Use can have iTween's Color methods operate on them by name. + /// + public enum NamedValueColor{ + /// + /// The main color of a material. Used by default and not required for Color methods to work in iTween. + /// + _Color, + /// + /// The specular color of a material (used in specular/glossy/vertexlit shaders). + /// + _SpecColor, + /// + /// The emissive color of a material (used in vertexlit shaders). + /// + _Emission, + /// + /// The reflection color of the material (used in reflective shaders). + /// + _ReflectColor + } + + #endregion + + #region Defaults + + /// + /// A collection of baseline presets that iTween needs and utilizes if certain parameters are not provided. + /// + public static class Defaults{ + //general defaults: + public static float time = 1f; + public static float delay = 0f; + public static NamedValueColor namedColorValue = NamedValueColor._Color; + public static LoopType loopType = LoopType.none; + public static EaseType easeType = iTween.EaseType.easeOutExpo; + public static float lookSpeed = 3f; + public static bool isLocal = false; + public static Space space = Space.Self; + public static bool orientToPath = false; + public static Color color = Color.white; + //update defaults: + public static float updateTimePercentage = .05f; + public static float updateTime = 1f*updateTimePercentage; + //cameraFade defaults: + public static int cameraFadeDepth = 999999; + //path look ahead amount: + public static float lookAhead = .05f; + public static bool useRealTime = false; // Added by PressPlay + //look direction: + public static Vector3 up = Vector3.up; + } + + #endregion + + #region #1 Static Registers + + /// + /// Sets up a GameObject to avoid hiccups when an initial iTween is added. It's advisable to run this on every object you intend to run iTween on in its Start or Awake. + /// + /// + /// A to be the target to be initialized for iTween. + /// + public static void Init(GameObject target){ + MoveBy(target,Vector3.zero,0); + } + + /// + /// Instantly changes the amount(transparency) of a camera fade and then returns it back over time with MINIMUM customization options. + /// + /// + /// A or for how transparent the Texture2D that the camera fade uses is. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void CameraFadeFrom(float amount, float time){ + if(cameraFade){ + CameraFadeFrom(Hash("amount",amount,"time",time)); + }else{ + Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading."); + } + } + + /// + /// Instantly changes the amount(transparency) of a camera fade and then returns it back over time with FULL customization options. + /// + /// + /// A or for how transparent the Texture2D that the camera fade uses is. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void CameraFadeFrom(Hashtable args){ + //establish iTween: + if(cameraFade){ + ColorFrom(cameraFade,args); + }else{ + Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading."); + } + } + + /// + /// Changes the amount(transparency) of a camera fade over time with MINIMUM customization options. + /// + /// + /// A or for how transparent the Texture2D that the camera fade uses is. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void CameraFadeTo(float amount, float time){ + if(cameraFade){ + CameraFadeTo(Hash("amount",amount,"time",time)); + }else{ + Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading."); + } + } + + /// + /// Changes the amount(transparency) of a camera fade over time with FULL customization options. + /// + /// + /// A or for how transparent the Texture2D that the camera fade uses is. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void CameraFadeTo(Hashtable args){ + /* + CameraFadeAdd(Defaults.cameraFadeDepth); + + //rescale cameraFade just in case screen size has changed to ensure it takes up the full screen: + cameraFade.guiTexture.pixelInset=new Rect(0,0,Screen.width,Screen.height); + */ + + if(cameraFade){ + //establish iTween: + ColorTo(cameraFade,args); + }else{ + Debug.LogError("iTween Error: You must first add a camera fade object with CameraFadeAdd() before atttempting to use camera fading."); + } + } + + /// + /// Returns a value to an 'oncallback' method interpolated between the supplied 'from' and 'to' values for application as desired. Requires an 'onupdate' callback that accepts the same type as the supplied 'from' and 'to' properties. + /// + /// + /// A or or or or or for the starting value. + /// + /// + /// A or or or or or for the ending value. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed (only works with Vector2, Vector3, and Floats) + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ValueTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + if (!args.Contains("onupdate") || !args.Contains("from") || !args.Contains("to")) { + Debug.LogError("iTween Error: ValueTo() requires an 'onupdate' callback function and a 'from' and 'to' property. The supplied 'onupdate' callback must accept a single argument that is the same type as the supplied 'from' and 'to' properties!"); + return; + }else{ + //establish iTween: + args["type"]="value"; + + if (args["from"].GetType() == typeof(Vector2)) { + args["method"]="vector2"; + }else if (args["from"].GetType() == typeof(Vector3)) { + args["method"]="vector3"; + }else if (args["from"].GetType() == typeof(Rect)) { + args["method"]="rect"; + }else if (args["from"].GetType() == typeof(Single)) { + args["method"]="float"; + }else if (args["from"].GetType() == typeof(Color)) { + args["method"]="color"; + }else{ + Debug.LogError("iTween Error: ValueTo() only works with interpolating Vector3s, Vector2s, floats, ints, Rects and Colors!"); + return; + } + + //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + Launch(target,args); + } + } + + /// + /// Changes a GameObject's alpha value instantly then returns it to the provided alpha over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorFrom and using the "a" parameter. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final alpha value of the animation. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void FadeFrom(GameObject target, float alpha, float time){ + FadeFrom(target,Hash("alpha",alpha,"time",time)); + } + + /// + /// Changes a GameObject's alpha value instantly then returns it to the provided alpha over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorFrom and using the "a" parameter. + /// + /// + /// A or for the initial alpha value of the animation. + /// + /// + /// A or for the initial alpha value of the animation. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void FadeFrom(GameObject target, Hashtable args){ + ColorFrom(target,args); + } + + /// + /// Changes a GameObject's alpha value over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorTo and using the "a" parameter. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final alpha value of the animation. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void FadeTo(GameObject target, float alpha, float time){ + FadeTo(target,Hash("alpha",alpha,"time",time)); + } + + /// + /// Changes a GameObject's alpha value over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. Identical to using ColorTo and using the "a" parameter. + /// + /// + /// A or for the final alpha value of the animation. + /// + /// + /// A or for the final alpha value of the animation. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void FadeTo(GameObject target, Hashtable args){ + ColorTo(target,args); + } + + /// + /// Changes a GameObject's color values instantly then returns them to the provided properties over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ColorFrom(GameObject target, Color color, float time){ + ColorFrom(target,Hash("color",color,"time",time)); + } + + /// + /// Changes a GameObject's color values instantly then returns them to the provided properties over time with FULL customization options. If a GUIText or GUITexture component is attached, it will become the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A or for the individual setting of the color red. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ColorFrom(GameObject target, Hashtable args){ + Color fromColor = new Color(); + Color tempColor = new Color(); + + //clean args: + args = iTween.CleanArgs(args); + + //handle children: + if(!args.Contains("includechildren") || (bool)args["includechildren"]){ + foreach(Transform child in target.transform){ + Hashtable argsCopy = (Hashtable)args.Clone(); + argsCopy["ischild"]=true; + ColorFrom(child.gameObject,argsCopy); + } + } + + //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + //set tempColor and base fromColor: + if(target.GetComponent(typeof(GUITexture))){ + tempColor=fromColor=target.guiTexture.color; + }else if(target.GetComponent(typeof(GUIText))){ + tempColor=fromColor=target.guiText.material.color; + }else if(target.renderer){ + tempColor=fromColor=target.renderer.material.color; + }else if(target.light){ + tempColor=fromColor=target.light.color; + } + + //set augmented fromColor: + if(args.Contains("color")){ + fromColor=(Color)args["color"]; + }else{ + if (args.Contains("r")) { + fromColor.r=(float)args["r"]; + } + if (args.Contains("g")) { + fromColor.g=(float)args["g"]; + } + if (args.Contains("b")) { + fromColor.b=(float)args["b"]; + } + if (args.Contains("a")) { + fromColor.a=(float)args["a"]; + } + } + + //alpha or amount? + if(args.Contains("amount")){ + fromColor.a=(float)args["amount"]; + args.Remove("amount"); + }else if(args.Contains("alpha")){ + fromColor.a=(float)args["alpha"]; + args.Remove("alpha"); + } + + //apply fromColor: + if(target.GetComponent(typeof(GUITexture))){ + target.guiTexture.color=fromColor; + }else if(target.GetComponent(typeof(GUIText))){ + target.guiText.material.color=fromColor; + }else if(target.renderer){ + target.renderer.material.color=fromColor; + }else if(target.light){ + target.light.color=fromColor; + } + + //set new color arg: + args["color"]=tempColor; + + //establish iTween: + args["type"]="color"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Changes a GameObject's color values over time with MINIMUM customization options. If a GUIText or GUITexture component is attached, they will become the target of the animation. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ColorTo(GameObject target, Color color, float time){ + ColorTo(target,Hash("color",color,"time",time)); + } + + /// + /// Changes a GameObject's color values over time with FULL customization options. If a GUIText or GUITexture component is attached, they will become the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A or for the individual setting of the color red. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ColorTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //handle children: + if(!args.Contains("includechildren") || (bool)args["includechildren"]){ + foreach(Transform child in target.transform){ + Hashtable argsCopy = (Hashtable)args.Clone(); + argsCopy["ischild"]=true; + ColorTo(child.gameObject,argsCopy); + } + } + + //set a default easeType of linear if none is supplied since eased color interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + //establish iTween: + args["type"]="color"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Instantly changes an AudioSource's volume and pitch then returns it to it's starting volume and pitch over time with MINIMUM customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied. + /// + /// + /// A to be the target of the animation which holds the AudioSource to be changed. + /// + /// for the target level of volume. + /// A + /// + /// for the target pitch. + /// A + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void AudioFrom(GameObject target, float volume, float pitch, float time){ + AudioFrom(target,Hash("volume",volume,"pitch",pitch,"time",time)); + } + + /// + /// Instantly changes an AudioSource's volume and pitch then returns it to it's starting volume and pitch over time with FULL customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied. + /// + /// + /// A for which AudioSource to use. + /// + /// + /// A or for the target level of volume. + /// + /// + /// A or for the target pitch. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void AudioFrom(GameObject target, Hashtable args){ + Vector2 tempAudioProperties; + Vector2 fromAudioProperties; + AudioSource tempAudioSource; + + //clean args: + args = iTween.CleanArgs(args); + + //set tempAudioSource: + if(args.Contains("audiosource")){ + tempAudioSource=(AudioSource)args["audiosource"]; + }else{ + if(target.GetComponent(typeof(AudioSource))){ + tempAudioSource=target.audio; + }else{ + //throw error if no AudioSource is available: + Debug.LogError("iTween Error: AudioFrom requires an AudioSource."); + return; + } + } + + //set tempAudioProperties: + tempAudioProperties.x=fromAudioProperties.x=tempAudioSource.volume; + tempAudioProperties.y=fromAudioProperties.y=tempAudioSource.pitch; + + //set augmented fromAudioProperties: + if(args.Contains("volume")){ + fromAudioProperties.x=(float)args["volume"]; + } + if(args.Contains("pitch")){ + fromAudioProperties.y=(float)args["pitch"]; + } + + //apply fromAudioProperties: + tempAudioSource.volume=fromAudioProperties.x; + tempAudioSource.pitch=fromAudioProperties.y; + + //set new volume and pitch args: + args["volume"]=tempAudioProperties.x; + args["pitch"]=tempAudioProperties.y; + + //set a default easeType of linear if none is supplied since eased audio interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + //establish iTween: + args["type"]="audio"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Fades volume and pitch of an AudioSource with MINIMUM customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied. + /// + /// + /// A to be the target of the animation which holds the AudioSource to be changed. + /// + /// for the target level of volume. + /// A + /// + /// for the target pitch. + /// A + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void AudioTo(GameObject target, float volume, float pitch, float time){ + AudioTo(target,Hash("volume",volume,"pitch",pitch,"time",time)); + } + + /// + /// Fades volume and pitch of an AudioSource with FULL customization options. Default AudioSource attached to GameObject will be used (if one exists) if not supplied. + /// + /// + /// A for which AudioSource to use. + /// + /// + /// A or for the target level of volume. + /// + /// + /// A or for the target pitch. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void AudioTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //set a default easeType of linear if none is supplied since eased audio interpolation is nearly unrecognizable: + if (!args.Contains("easetype")) { + args.Add("easetype",EaseType.linear); + } + + //establish iTween: + args["type"]="audio"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Plays an AudioClip once based on supplied volume and pitch and following any delay with MINIMUM customization options. AudioSource is optional as iTween will provide one. + /// + /// + /// A to be the target of the animation which holds the AudioSource to be utilized. + /// + /// + /// A for a reference to the AudioClip to be played. + /// + /// + /// A for the time in seconds the action will wait before beginning. + /// + public static void Stab(GameObject target, AudioClip audioclip, float delay){ + Stab(target,Hash("audioclip",audioclip,"delay",delay)); + } + + /// + /// Plays an AudioClip once based on supplied volume and pitch and following any delay with FULL customization options. AudioSource is optional as iTween will provide one. + /// + /// + /// A for a reference to the AudioClip to be played. + /// + /// + /// A for which AudioSource to use + /// + /// + /// A or for the target level of volume. + /// + /// + /// A or for the target pitch. + /// + /// + /// A or for the time in seconds the action will wait before beginning. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void Stab(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="stab"; + Launch(target,args); + } + + /// + /// Instantly rotates a GameObject to look at the supplied Vector3 then returns it to it's starting rotation over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to be the Vector3 that the target will look towards. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void LookFrom(GameObject target, Vector3 looktarget, float time){ + LookFrom(target,Hash("looktarget",looktarget,"time",time)); + } + + /// + /// Instantly rotates a GameObject to look at a supplied Transform or Vector3 then returns it to it's starting rotation over time with FULL customization options. + /// + /// + /// A or for a target the GameObject will look at. + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void LookFrom(GameObject target, Hashtable args){ + Vector3 tempRotation; + Vector3 tempRestriction; + + //clean args: + args = iTween.CleanArgs(args); + + //set look: + tempRotation=target.transform.eulerAngles; + if (args["looktarget"].GetType() == typeof(Transform)) { + //target.transform.LookAt((Transform)args["looktarget"]); + target.transform.LookAt((Transform)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up); + }else if(args["looktarget"].GetType() == typeof(Vector3)){ + //target.transform.LookAt((Vector3)args["looktarget"]); + target.transform.LookAt((Vector3)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up); + } + + //axis restriction: + if(args.Contains("axis")){ + tempRestriction=target.transform.eulerAngles; + switch((string)args["axis"]){ + case "x": + tempRestriction.y=tempRotation.y; + tempRestriction.z=tempRotation.z; + break; + case "y": + tempRestriction.x=tempRotation.x; + tempRestriction.z=tempRotation.z; + break; + case "z": + tempRestriction.x=tempRotation.x; + tempRestriction.y=tempRotation.y; + break; + } + target.transform.eulerAngles=tempRestriction; + } + + //set new rotation: + args["rotation"] = tempRotation; + + //establish iTween + args["type"]="rotate"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Rotates a GameObject to look at the supplied Vector3 over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to be the Vector3 that the target will look towards. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void LookTo(GameObject target, Vector3 looktarget, float time){ + LookTo(target,Hash("looktarget",looktarget,"time",time)); + } + + /// + /// Rotates a GameObject to look at a supplied Transform or Vector3 over time with FULL customization options. + /// + /// + /// A or for a target the GameObject will look at. + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void LookTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //additional property to ensure ConflictCheck can work correctly since Transforms are refrences: + if(args.Contains("looktarget")){ + if (args["looktarget"].GetType() == typeof(Transform)) { + Transform transform = (Transform)args["looktarget"]; + args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z); + args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z); + } + } + + //establish iTween + args["type"]="look"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Changes a GameObject's position over time to a supplied destination with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the destination Vector3. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveTo(GameObject target, Vector3 position, float time){ + MoveTo(target,Hash("position",position,"time",time)); + } + + /// + /// Changes a GameObject's position over time to a supplied destination with FULL customization options. + /// + /// + /// A or for a point in space the GameObject will animate to. + /// + /// + /// A or for a list of points to draw a Catmull-Rom through for a curved animation path. + /// + /// + /// A for whether to automatically generate a curve from the GameObject's current position to the beginning of the path. True by default. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A or for how much of a percentage to look ahead on a path to influence how strict "orientopath" is. + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void MoveTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //additional property to ensure ConflictCheck can work correctly since Transforms are refrences: + if(args.Contains("position")){ + if (args["position"].GetType() == typeof(Transform)) { + Transform transform = (Transform)args["position"]; + args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z); + args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z); + args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z); + } + } + + //establish iTween: + args["type"]="move"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Instantly changes a GameObject's position to a supplied destination then returns it to it's starting position over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the destination Vector3. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveFrom(GameObject target, Vector3 position, float time){ + MoveFrom(target,Hash("position",position,"time",time)); + } + + /// + /// Instantly changes a GameObject's position to a supplied destination then returns it to it's starting position over time with FULL customization options. + /// + /// + /// A or for a point in space the GameObject will animate to. + /// + /// + /// A or for a list of points to draw a Catmull-Rom through for a curved animation path. + /// + /// + /// A for whether to automatically generate a curve from the GameObject's current position to the beginning of the path. True by default. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A or for how much of a percentage to look ahead on a path to influence how strict "orientopath" is. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void MoveFrom(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + bool tempIsLocal; + + //set tempIsLocal: + if(args.Contains("islocal")){ + tempIsLocal = (bool)args["islocal"]; + }else{ + tempIsLocal = Defaults.isLocal; + } + + if(args.Contains("path")){ + Vector3[] fromPath; + Vector3[] suppliedPath; + if(args["path"].GetType() == typeof(Vector3[])){ + Vector3[] temp = (Vector3[])args["path"]; + suppliedPath=new Vector3[temp.Length]; + Array.Copy(temp,suppliedPath, temp.Length); + }else{ + Transform[] temp = (Transform[])args["path"]; + suppliedPath = new Vector3[temp.Length]; + for (int i = 0; i < temp.Length; i++) { + suppliedPath[i]=temp[i].position; + } + } + if(suppliedPath[suppliedPath.Length-1] != target.transform.position){ + fromPath= new Vector3[suppliedPath.Length+1]; + Array.Copy(suppliedPath,fromPath,suppliedPath.Length); + if(tempIsLocal){ + fromPath[fromPath.Length-1] = target.transform.localPosition; + target.transform.localPosition=fromPath[0]; + }else{ + fromPath[fromPath.Length-1] = target.transform.position; + target.transform.position=fromPath[0]; + } + args["path"]=fromPath; + }else{ + if(tempIsLocal){ + target.transform.localPosition=suppliedPath[0]; + }else{ + target.transform.position=suppliedPath[0]; + } + args["path"]=suppliedPath; + } + }else{ + Vector3 tempPosition; + Vector3 fromPosition; + + //set tempPosition and base fromPosition: + if(tempIsLocal){ + tempPosition=fromPosition=target.transform.localPosition; + }else{ + tempPosition=fromPosition=target.transform.position; + } + + //set augmented fromPosition: + if(args.Contains("position")){ + if (args["position"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["position"]; + fromPosition=trans.position; + }else if(args["position"].GetType() == typeof(Vector3)){ + fromPosition=(Vector3)args["position"]; + } + }else{ + if (args.Contains("x")) { + fromPosition.x=(float)args["x"]; + } + if (args.Contains("y")) { + fromPosition.y=(float)args["y"]; + } + if (args.Contains("z")) { + fromPosition.z=(float)args["z"]; + } + } + + //apply fromPosition: + if(tempIsLocal){ + target.transform.localPosition = fromPosition; + }else{ + target.transform.position = fromPosition; + } + + //set new position arg: + args["position"]=tempPosition; + } + + //establish iTween: + args["type"]="move"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Translates a GameObject's position over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of change in position to move the GameObject. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveAdd(GameObject target, Vector3 amount, float time){ + MoveAdd(target,Hash("amount",amount,"time",time)); + } + + /// + /// Translates a GameObject's position over time with FULL customization options. + /// + /// + /// A for the amount of change in position to move the GameObject. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void MoveAdd(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="move"; + args["method"]="add"; + Launch(target,args); + } + + /// + /// Adds the supplied coordinates to a GameObject's postion with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of change in position to move the GameObject. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveBy(GameObject target, Vector3 amount, float time){ + MoveBy(target,Hash("amount",amount,"time",time)); + } + + /// + /// Adds the supplied coordinates to a GameObject's position with FULL customization options. + /// + /// + /// A for the amount of change in position to move the GameObject. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void MoveBy(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="move"; + args["method"]="by"; + Launch(target,args); + } + + /// + /// Changes a GameObject's scale over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleTo(GameObject target, Vector3 scale, float time){ + ScaleTo(target,Hash("scale",scale,"time",time)); + } + + /// + /// Changes a GameObject's scale over time with FULL customization options. + /// + /// + /// A or for the final scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ScaleTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //additional property to ensure ConflictCheck can work correctly since Transforms are refrences: + if(args.Contains("scale")){ + if (args["scale"].GetType() == typeof(Transform)) { + Transform transform = (Transform)args["scale"]; + args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z); + args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z); + args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z); + } + } + + //establish iTween: + args["type"]="scale"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Instantly changes a GameObject's scale then returns it to it's starting scale over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleFrom(GameObject target, Vector3 scale, float time){ + ScaleFrom(target,Hash("scale",scale,"time",time)); + } + + /// + /// Instantly changes a GameObject's scale then returns it to it's starting scale over time with FULL customization options. + /// + /// + /// A or for the final scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ScaleFrom(GameObject target, Hashtable args){ + Vector3 tempScale; + Vector3 fromScale; + + //clean args: + args = iTween.CleanArgs(args); + + //set base fromScale: + tempScale=fromScale=target.transform.localScale; + + //set augmented fromScale: + if(args.Contains("scale")){ + if (args["scale"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["scale"]; + fromScale=trans.localScale; + }else if(args["scale"].GetType() == typeof(Vector3)){ + fromScale=(Vector3)args["scale"]; + } + }else{ + if (args.Contains("x")) { + fromScale.x=(float)args["x"]; + } + if (args.Contains("y")) { + fromScale.y=(float)args["y"]; + } + if (args.Contains("z")) { + fromScale.z=(float)args["z"]; + } + } + + //apply fromScale: + target.transform.localScale = fromScale; + + //set new scale arg: + args["scale"]=tempScale; + + //establish iTween: + args["type"]="scale"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Adds to a GameObject's scale over time with FULL customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of scale to be added to the GameObject's current scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleAdd(GameObject target, Vector3 amount, float time){ + ScaleAdd(target,Hash("amount",amount,"time",time)); + } + + /// + /// Adds to a GameObject's scale over time with FULL customization options. + /// + /// + /// A for the amount to be added to the GameObject's current scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ScaleAdd(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="scale"; + args["method"]="add"; + Launch(target,args); + } + + /// + /// Multiplies a GameObject's scale over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of scale to be multiplied by the GameObject's current scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleBy(GameObject target, Vector3 amount, float time){ + ScaleBy(target,Hash("amount",amount,"time",time)); + } + + /// + /// Multiplies a GameObject's scale over time with FULL customization options. + /// + /// + /// A for the amount to be multiplied to the GameObject's current scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ScaleBy(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="scale"; + args["method"]="by"; + Launch(target,args); + } + + /// + /// Rotates a GameObject to the supplied Euler angles in degrees over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the target Euler angles in degrees to rotate to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateTo(GameObject target, Vector3 rotation, float time){ + RotateTo(target,Hash("rotation",rotation,"time",time)); + } + + /// + /// Rotates a GameObject to the supplied Euler angles in degrees over time with FULL customization options. + /// + /// + /// A or for the target Euler angles in degrees to rotate to. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void RotateTo(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //additional property to ensure ConflictCheck can work correctly since Transforms are refrences: + if(args.Contains("rotation")){ + if (args["rotation"].GetType() == typeof(Transform)) { + Transform transform = (Transform)args["rotation"]; + args["position"]=new Vector3(transform.position.x,transform.position.y,transform.position.z); + args["rotation"]=new Vector3(transform.eulerAngles.x,transform.eulerAngles.y,transform.eulerAngles.z); + args["scale"]=new Vector3(transform.localScale.x,transform.localScale.y,transform.localScale.z); + } + } + + //establish iTween + args["type"]="rotate"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Instantly changes a GameObject's Euler angles in degrees then returns it to it's starting rotation over time (if allowed) with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the target Euler angles in degrees to rotate from. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateFrom(GameObject target, Vector3 rotation, float time){ + RotateFrom(target,Hash("rotation",rotation,"time",time)); + } + + /// + /// Instantly changes a GameObject's Euler angles in degrees then returns it to it's starting rotation over time (if allowed) with FULL customization options. + /// + /// + /// A or for the target Euler angles in degrees to rotate to. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void RotateFrom(GameObject target, Hashtable args){ + Vector3 tempRotation; + Vector3 fromRotation; + bool tempIsLocal; + + //clean args: + args = iTween.CleanArgs(args); + + //set tempIsLocal: + if(args.Contains("islocal")){ + tempIsLocal = (bool)args["islocal"]; + }else{ + tempIsLocal = Defaults.isLocal; + } + + //set tempRotation and base fromRotation: + if(tempIsLocal){ + tempRotation=fromRotation=target.transform.localEulerAngles; + }else{ + tempRotation=fromRotation=target.transform.eulerAngles; + } + + //set augmented fromRotation: + if(args.Contains("rotation")){ + if (args["rotation"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["rotation"]; + fromRotation=trans.eulerAngles; + }else if(args["rotation"].GetType() == typeof(Vector3)){ + fromRotation=(Vector3)args["rotation"]; + } + }else{ + if (args.Contains("x")) { + fromRotation.x=(float)args["x"]; + } + if (args.Contains("y")) { + fromRotation.y=(float)args["y"]; + } + if (args.Contains("z")) { + fromRotation.z=(float)args["z"]; + } + } + + //apply fromRotation: + if(tempIsLocal){ + target.transform.localEulerAngles = fromRotation; + }else{ + target.transform.eulerAngles = fromRotation; + } + + //set new rotation arg: + args["rotation"]=tempRotation; + + //establish iTween: + args["type"]="rotate"; + args["method"]="to"; + Launch(target,args); + } + + /// + /// Adds supplied Euler angles in degrees to a GameObject's rotation over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount of Euler angles in degrees to add to the current rotation of the GameObject. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateAdd(GameObject target, Vector3 amount, float time){ + RotateAdd(target,Hash("amount",amount,"time",time)); + } + + /// + /// Adds supplied Euler angles in degrees to a GameObject's rotation over time with FULL customization options. + /// + /// + /// A for the amount of Euler angles in degrees to add to the current rotation of the GameObject. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void RotateAdd(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween: + args["type"]="rotate"; + args["method"]="add"; + Launch(target,args); + } + + /// + /// Multiplies supplied values by 360 and rotates a GameObject by calculated amount over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the amount to be multiplied by 360 to rotate the GameObject. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateBy(GameObject target, Vector3 amount, float time){ + RotateBy(target,Hash("amount",amount,"time",time)); + } + + /// + /// Multiplies supplied values by 360 and rotates a GameObject by calculated amount over time with FULL customization options. + /// + /// + /// A for the amount to be multiplied by 360 to rotate the GameObject. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or can be used instead of time to allow animation based on speed + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the shape of the easing curve applied to the animation. + /// + /// + /// A or for the type of loop to apply once the animation has completed. + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void RotateBy(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="rotate"; + args["method"]="by"; + Launch(target,args); + } + + /// + /// Randomly shakes a GameObject's position by a diminishing amount over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ShakePosition(GameObject target, Vector3 amount, float time){ + ShakePosition(target,Hash("amount",amount,"time",time)); + } + + /// + /// Randomly shakes a GameObject's position by a diminishing amount over time with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ShakePosition(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="shake"; + args["method"]="position"; + Launch(target,args); + } + + /// + /// Randomly shakes a GameObject's scale by a diminishing amount over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ShakeScale(GameObject target, Vector3 amount, float time){ + ShakeScale(target,Hash("amount",amount,"time",time)); + } + + /// + /// Randomly shakes a GameObject's scale by a diminishing amount over time with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ShakeScale(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="shake"; + args["method"]="scale"; + Launch(target,args); + } + + /// + /// Randomly shakes a GameObject's rotation by a diminishing amount over time with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ShakeRotation(GameObject target, Vector3 amount, float time){ + ShakeRotation(target,Hash("amount",amount,"time",time)); + } + + /// + /// Randomly shakes a GameObject's rotation by a diminishing amount over time with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with shakes) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void ShakeRotation(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="shake"; + args["method"]="rotation"; + Launch(target,args); + } + + /// + /// Applies a jolt of force to a GameObject's position and wobbles it back to its initial position with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of the punch. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void PunchPosition(GameObject target, Vector3 amount, float time){ + PunchPosition(target,Hash("amount",amount,"time",time)); + } + + /// + /// Applies a jolt of force to a GameObject's position and wobbles it back to its initial position with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget". + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void PunchPosition(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="punch"; + args["method"]="position"; + args["easetype"]=EaseType.punch; + Launch(target,args); + } + + /// + /// Applies a jolt of force to a GameObject's rotation and wobbles it back to its initial rotation with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of the punch. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void PunchRotation(GameObject target, Vector3 amount, float time){ + PunchRotation(target,Hash("amount",amount,"time",time)); + } + + /// + /// Applies a jolt of force to a GameObject's rotation and wobbles it back to its initial rotation with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A for applying the transformation in either the world coordinate or local cordinate system. Defaults to local space. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void PunchRotation(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="punch"; + args["method"]="rotation"; + args["easetype"]=EaseType.punch; + Launch(target,args); + } + + /// + /// Applies a jolt of force to a GameObject's scale and wobbles it back to its initial scale with MINIMUM customization options. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the magnitude of the punch. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void PunchScale(GameObject target, Vector3 amount, float time){ + PunchScale(target,Hash("amount",amount,"time",time)); + } + + /// + /// Applies a jolt of force to a GameObject's scale and wobbles it back to its initial scale with FULL customization options. + /// + /// + /// A for the magnitude of shake. + /// + /// + /// A or for the individual setting of the x magnitude. + /// + /// + /// A or for the individual setting of the y magnitude. + /// + /// + /// A or for the individual setting of the z magnitude. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A or for the time in seconds the animation will wait before beginning. + /// + /// + /// A or for the type of loop to apply once the animation has completed. (only "loop" is allowed with punches) + /// + /// + /// A for the name of a function to launch at the beginning of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onstart" method. + /// + /// + /// A for arguments to be sent to the "onstart" method. + /// + /// + /// A for the name of a function to launch on every step of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "onupdate" method. + /// + /// + /// A for arguments to be sent to the "onupdate" method. + /// + /// + /// A for the name of a function to launch at the end of the animation. + /// + /// + /// A for a reference to the GameObject that holds the "oncomplete" method. + /// + /// + /// A for arguments to be sent to the "oncomplete" method. + /// + public static void PunchScale(GameObject target, Hashtable args){ + //clean args: + args = iTween.CleanArgs(args); + + //establish iTween + args["type"]="punch"; + args["method"]="scale"; + args["easetype"]=EaseType.punch; + Launch(target,args); + } + + #endregion + + #region #2 Generate Method Targets + + //call correct set target method and set tween application delegate: + void GenerateTargets(){ + switch (type) { + case "value": + switch (method) { + case "float": + GenerateFloatTargets(); + apply = new ApplyTween(ApplyFloatTargets); + break; + case "vector2": + GenerateVector2Targets(); + apply = new ApplyTween(ApplyVector2Targets); + break; + case "vector3": + GenerateVector3Targets(); + apply = new ApplyTween(ApplyVector3Targets); + break; + case "color": + GenerateColorTargets(); + apply = new ApplyTween(ApplyColorTargets); + break; + case "rect": + GenerateRectTargets(); + apply = new ApplyTween(ApplyRectTargets); + break; + } + break; + case "color": + switch (method) { + case "to": + GenerateColorToTargets(); + apply = new ApplyTween(ApplyColorToTargets); + break; + } + break; + case "audio": + switch (method) { + case "to": + GenerateAudioToTargets(); + apply = new ApplyTween(ApplyAudioToTargets); + break; + } + break; + case "move": + switch (method) { + case "to": + //using a path? + if(tweenArguments.Contains("path")){ + GenerateMoveToPathTargets(); + apply = new ApplyTween(ApplyMoveToPathTargets); + }else{ //not using a path? + GenerateMoveToTargets(); + apply = new ApplyTween(ApplyMoveToTargets); + } + break; + case "by": + case "add": + GenerateMoveByTargets(); + apply = new ApplyTween(ApplyMoveByTargets); + break; + } + break; + case "scale": + switch (method){ + case "to": + GenerateScaleToTargets(); + apply = new ApplyTween(ApplyScaleToTargets); + break; + case "by": + GenerateScaleByTargets(); + apply = new ApplyTween(ApplyScaleToTargets); + break; + case "add": + GenerateScaleAddTargets(); + apply = new ApplyTween(ApplyScaleToTargets); + break; + } + break; + case "rotate": + switch (method) { + case "to": + GenerateRotateToTargets(); + apply = new ApplyTween(ApplyRotateToTargets); + break; + case "add": + GenerateRotateAddTargets(); + apply = new ApplyTween(ApplyRotateAddTargets); + break; + case "by": + GenerateRotateByTargets(); + apply = new ApplyTween(ApplyRotateAddTargets); + break; + } + break; + case "shake": + switch (method) { + case "position": + GenerateShakePositionTargets(); + apply = new ApplyTween(ApplyShakePositionTargets); + break; + case "scale": + GenerateShakeScaleTargets(); + apply = new ApplyTween(ApplyShakeScaleTargets); + break; + case "rotation": + GenerateShakeRotationTargets(); + apply = new ApplyTween(ApplyShakeRotationTargets); + break; + } + break; + case "punch": + switch (method) { + case "position": + GeneratePunchPositionTargets(); + apply = new ApplyTween(ApplyPunchPositionTargets); + break; + case "rotation": + GeneratePunchRotationTargets(); + apply = new ApplyTween(ApplyPunchRotationTargets); + break; + case "scale": + GeneratePunchScaleTargets(); + apply = new ApplyTween(ApplyPunchScaleTargets); + break; + } + break; + case "look": + switch (method) { + case "to": + GenerateLookToTargets(); + apply = new ApplyTween(ApplyLookToTargets); + break; + } + break; + case "stab": + GenerateStabTargets(); + apply = new ApplyTween(ApplyStabTargets); + break; + } + } + + #endregion + + #region #3 Generate Specific Targets + + void GenerateRectTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + rects=new Rect[3]; + + //from and to values: + rects[0]=(Rect)tweenArguments["from"]; + rects[1]=(Rect)tweenArguments["to"]; + } + + void GenerateColorTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + colors=new Color[1,3]; + + //from and to values: + colors[0,0]=(Color)tweenArguments["from"]; + colors[0,1]=(Color)tweenArguments["to"]; + } + + void GenerateVector3Targets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from and to values: + vector3s[0]=(Vector3)tweenArguments["from"]; + vector3s[1]=(Vector3)tweenArguments["to"]; + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateVector2Targets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector2s=new Vector2[3]; + + //from and to values: + vector2s[0]=(Vector2)tweenArguments["from"]; + vector2s[1]=(Vector2)tweenArguments["to"]; + + //need for speed? + if(tweenArguments.Contains("speed")){ + Vector3 fromV3 = new Vector3(vector2s[0].x,vector2s[0].y,0); + Vector3 toV3 = new Vector3(vector2s[1].x,vector2s[1].y,0); + float distance = Math.Abs(Vector3.Distance(fromV3,toV3)); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateFloatTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + floats=new float[3]; + + //from and to values: + floats[0]=(float)tweenArguments["from"]; + floats[1]=(float)tweenArguments["to"]; + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(floats[0] - floats[1]); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateColorToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + //colors = new Color[3]; + + //from and init to values: + if(GetComponent(typeof(GUITexture))){ + colors = new Color[1,3]; + colors[0,0] = colors[0,1] = guiTexture.color; + }else if(GetComponent(typeof(GUIText))){ + colors = new Color[1,3]; + colors[0,0] = colors[0,1] = guiText.material.color; + }else if(renderer){ + colors = new Color[renderer.materials.Length,3]; + for (int i = 0; i < renderer.materials.Length; i++) { + colors[i,0]=renderer.materials[i].GetColor(namedcolorvalue.ToString()); + colors[i,1]=renderer.materials[i].GetColor(namedcolorvalue.ToString()); + } + //colors[0] = colors[1] = renderer.material.color; + }else if(light){ + colors = new Color[1,3]; + colors[0,0] = colors[0,1] = light.color; + }else{ + colors = new Color[1,3]; //empty placeholder incase the GO is perhaps an empty holder or something similar + } + + //to values: + if (tweenArguments.Contains("color")) { + //colors[1]=(Color)tweenArguments["color"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1]=(Color)tweenArguments["color"]; + } + }else{ + if (tweenArguments.Contains("r")) { + //colors[1].r=(float)tweenArguments["r"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].r=(float)tweenArguments["r"]; + } + } + if (tweenArguments.Contains("g")) { + //colors[1].g=(float)tweenArguments["g"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].g=(float)tweenArguments["g"]; + } + } + if (tweenArguments.Contains("b")) { + //colors[1].b=(float)tweenArguments["b"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].b=(float)tweenArguments["b"]; + } + } + if (tweenArguments.Contains("a")) { + //colors[1].a=(float)tweenArguments["a"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].a=(float)tweenArguments["a"]; + } + } + } + + //alpha or amount? + if(tweenArguments.Contains("amount")){ + //colors[1].a=(float)tweenArguments["amount"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].a=(float)tweenArguments["amount"]; + } + }else if(tweenArguments.Contains("alpha")){ + //colors[1].a=(float)tweenArguments["alpha"]; + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,1].a=(float)tweenArguments["alpha"]; + } + } + } + + void GenerateAudioToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector2s=new Vector2[3]; + + //set audioSource: + if(tweenArguments.Contains("audiosource")){ + audioSource=(AudioSource)tweenArguments["audiosource"]; + }else{ + if(GetComponent(typeof(AudioSource))){ + audioSource=audio; + }else{ + //throw error if no AudioSource is available: + Debug.LogError("iTween Error: AudioTo requires an AudioSource."); + Dispose(); + } + } + + //from values and default to values: + vector2s[0]=vector2s[1]=new Vector2(audioSource.volume,audioSource.pitch); + + //to values: + if (tweenArguments.Contains("volume")) { + vector2s[1].x=(float)tweenArguments["volume"]; + } + if (tweenArguments.Contains("pitch")) { + vector2s[1].y=(float)tweenArguments["pitch"]; + } + } + + void GenerateStabTargets(){ + //set audioSource: + if(tweenArguments.Contains("audiosource")){ + audioSource=(AudioSource)tweenArguments["audiosource"]; + }else{ + if(GetComponent(typeof(AudioSource))){ + audioSource=audio; + }else{ + //add and populate AudioSource if one doesn't exist: + gameObject.AddComponent(typeof(AudioSource)); + audioSource=audio; + audioSource.playOnAwake=false; + + } + } + + //populate audioSource's clip: + audioSource.clip=(AudioClip)tweenArguments["audioclip"]; + + //set audio's pitch and volume if requested: + if(tweenArguments.Contains("pitch")){ + audioSource.pitch=(float)tweenArguments["pitch"]; + } + if(tweenArguments.Contains("volume")){ + audioSource.volume=(float)tweenArguments["volume"]; + } + + //set run time based on length of clip after pitch is augmented + time=audioSource.clip.length/audioSource.pitch; + } + + void GenerateLookToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=transform.eulerAngles; + + //set look: + if(tweenArguments.Contains("looktarget")){ + if (tweenArguments["looktarget"].GetType() == typeof(Transform)) { + //transform.LookAt((Transform)tweenArguments["looktarget"]); + transform.LookAt((Transform)tweenArguments["looktarget"], (Vector3?)tweenArguments["up"] ?? Defaults.up); + }else if(tweenArguments["looktarget"].GetType() == typeof(Vector3)){ + //transform.LookAt((Vector3)tweenArguments["looktarget"]); + transform.LookAt((Vector3)tweenArguments["looktarget"], (Vector3?)tweenArguments["up"] ?? Defaults.up); + } + }else{ + Debug.LogError("iTween Error: LookTo needs a 'looktarget' property!"); + Dispose(); + } + + //to values: + vector3s[1]=transform.eulerAngles; + transform.eulerAngles=vector3s[0]; + + //axis restriction: + if(tweenArguments.Contains("axis")){ + switch((string)tweenArguments["axis"]){ + case "x": + vector3s[1].y=vector3s[0].y; + vector3s[1].z=vector3s[0].z; + break; + case "y": + vector3s[1].x=vector3s[0].x; + vector3s[1].z=vector3s[0].z; + break; + case "z": + vector3s[1].x=vector3s[0].x; + vector3s[1].y=vector3s[0].y; + break; + } + } + + //shortest distance: + vector3s[1]=new Vector3(clerp(vector3s[0].x,vector3s[1].x,1),clerp(vector3s[0].y,vector3s[1].y,1),clerp(vector3s[0].z,vector3s[1].z,1)); + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateMoveToPathTargets(){ + Vector3[] suppliedPath; + + //create and store path points: + if(tweenArguments["path"].GetType() == typeof(Vector3[])){ + Vector3[] temp = (Vector3[])tweenArguments["path"]; + //if only one point is supplied fall back to MoveTo's traditional use since we can't have a curve with one value: + if(temp.Length==1){ + Debug.LogError("iTween Error: Attempting a path movement with MoveTo requires an array of more than 1 entry!"); + Dispose(); + } + suppliedPath=new Vector3[temp.Length]; + Array.Copy(temp,suppliedPath, temp.Length); + }else{ + Transform[] temp = (Transform[])tweenArguments["path"]; + //if only one point is supplied fall back to MoveTo's traditional use since we can't have a curve with one value: + if(temp.Length==1){ + Debug.LogError("iTween Error: Attempting a path movement with MoveTo requires an array of more than 1 entry!"); + Dispose(); + } + suppliedPath = new Vector3[temp.Length]; + for (int i = 0; i < temp.Length; i++) { + suppliedPath[i]=temp[i].position; + } + } + + //do we need to plot a path to get to the beginning of the supplied path? + bool plotStart; + int offset; + if(transform.position != suppliedPath[0]){ + if(!tweenArguments.Contains("movetopath") || (bool)tweenArguments["movetopath"]==true){ + plotStart=true; + offset=3; + }else{ + plotStart=false; + offset=2; + } + }else{ + plotStart=false; + offset=2; + } + + //build calculated path: + vector3s = new Vector3[suppliedPath.Length+offset]; + if(plotStart){ + vector3s[1]=transform.position; + offset=2; + }else{ + offset=1; + } + + //populate calculate path; + Array.Copy(suppliedPath,0,vector3s,offset,suppliedPath.Length); + + //populate start and end control points: + //vector3s[0] = vector3s[1] - vector3s[2]; + vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]); + vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]); + + //is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline! + if(vector3s[1] == vector3s[vector3s.Length-2]){ + Vector3[] tmpLoopSpline = new Vector3[vector3s.Length]; + Array.Copy(vector3s,tmpLoopSpline,vector3s.Length); + tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3]; + tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2]; + vector3s=new Vector3[tmpLoopSpline.Length]; + Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length); + } + + //create Catmull-Rom path: + path = new CRSpline(vector3s); + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = PathLength(vector3s); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateMoveToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + if (isLocal) { + vector3s[0]=vector3s[1]=transform.localPosition; + }else{ + vector3s[0]=vector3s[1]=transform.position; + } + + //to values: + if (tweenArguments.Contains("position")) { + if (tweenArguments["position"].GetType() == typeof(Transform)){ + Transform trans = (Transform)tweenArguments["position"]; + vector3s[1]=trans.position; + }else if(tweenArguments["position"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)tweenArguments["position"]; + } + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + + //handle orient to path request: + if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){ + tweenArguments["looktarget"] = vector3s[1]; + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateMoveByTargets(){ + +/* foreach (var key in tweenArguments.Keys) + { + Debug.Log(key + ": " + tweenArguments[key]); + } +*/ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization, [4] original rotation to make sure look requests don't interfere with the direction object should move in, [5] for dial in location: + vector3s=new Vector3[6]; + + //grab starting rotation: + vector3s[4] = transform.eulerAngles; + + //from values: + vector3s[0]=vector3s[1]=vector3s[3]=transform.position; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=vector3s[0] + (Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=vector3s[0].x + (float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=vector3s[0].y +(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=vector3s[0].z + (float)tweenArguments["z"]; + } + } + + //calculation for dial in: + transform.Translate(vector3s[1],space); + vector3s[5] = transform.position; + transform.position=vector3s[0]; + + //handle orient to path request: + if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){ + tweenArguments["looktarget"] = vector3s[1]; + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateScaleToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=vector3s[1]=transform.localScale; + + //to values: + if (tweenArguments.Contains("scale")) { + if (tweenArguments["scale"].GetType() == typeof(Transform)){ + Transform trans = (Transform)tweenArguments["scale"]; + vector3s[1]=trans.localScale; + }else if(tweenArguments["scale"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)tweenArguments["scale"]; + } + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateScaleByTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=vector3s[1]=transform.localScale; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=Vector3.Scale(vector3s[1],(Vector3)tweenArguments["amount"]); + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x*=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y*=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z*=(float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateScaleAddTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=vector3s[1]=transform.localScale; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]+=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x+=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y+=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z+=(float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateRotateToTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + if (isLocal) { + vector3s[0]=vector3s[1]=transform.localEulerAngles; + }else{ + vector3s[0]=vector3s[1]=transform.eulerAngles; + } + + //to values: + if (tweenArguments.Contains("rotation")) { + if (tweenArguments["rotation"].GetType() == typeof(Transform)){ + Transform trans = (Transform)tweenArguments["rotation"]; + vector3s[1]=trans.eulerAngles; + }else if(tweenArguments["rotation"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)tweenArguments["rotation"]; + } + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + + //shortest distance: + vector3s[1]=new Vector3(clerp(vector3s[0].x,vector3s[1].x,1),clerp(vector3s[0].y,vector3s[1].y,1),clerp(vector3s[0].z,vector3s[1].z,1)); + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateRotateAddTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Rotate usage to allow Space utilization: + vector3s=new Vector3[5]; + + //from values: + vector3s[0]=vector3s[1]=vector3s[3]=transform.eulerAngles; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]+=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x+=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y+=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z+=(float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateRotateByTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Rotate usage to allow Space utilization: + vector3s=new Vector3[4]; + + //from values: + vector3s[0]=vector3s[1]=vector3s[3]=transform.eulerAngles; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]+=Vector3.Scale((Vector3)tweenArguments["amount"],new Vector3(360,360,360)); + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x+=360 * (float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y+=360 * (float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z+=360 * (float)tweenArguments["z"]; + } + } + + //need for speed? + if(tweenArguments.Contains("speed")){ + float distance = Math.Abs(Vector3.Distance(vector3s[0],vector3s[1])); + time = distance/(float)tweenArguments["speed"]; + } + } + + void GenerateShakePositionTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] original rotation to make sure look requests don't interfere with the direction object should move in: + vector3s=new Vector3[4]; + + //grab starting rotation: + vector3s[3] = transform.eulerAngles; + + //root: + vector3s[0]=transform.position; + + //amount: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GenerateShakeScaleTargets(){ + //values holder [0] root value, [1] amount, [2] generated amount: + vector3s=new Vector3[3]; + + //root: + vector3s[0]=transform.localScale; + + //amount: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GenerateShakeRotationTargets(){ + //values holder [0] root value, [1] amount, [2] generated amount: + vector3s=new Vector3[3]; + + //root: + vector3s[0]=transform.eulerAngles; + + //amount: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GeneratePunchPositionTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization, [4] original rotation to make sure look requests don't interfere with the direction object should move in: + vector3s=new Vector3[5]; + + //grab starting rotation: + vector3s[4] = transform.eulerAngles; + + //from values: + vector3s[0]=transform.position; + vector3s[1]=vector3s[3]=Vector3.zero; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GeneratePunchRotationTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation, [3] previous value for Translate usage to allow Space utilization: + vector3s=new Vector3[4]; + + //from values: + vector3s[0]=transform.eulerAngles; + vector3s[1]=vector3s[3]=Vector3.zero; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + void GeneratePunchScaleTargets(){ + //values holder [0] from, [1] to, [2] calculated value from ease equation: + vector3s=new Vector3[3]; + + //from values: + vector3s[0]=transform.localScale; + vector3s[1]=Vector3.zero; + + //to values: + if (tweenArguments.Contains("amount")) { + vector3s[1]=(Vector3)tweenArguments["amount"]; + }else{ + if (tweenArguments.Contains("x")) { + vector3s[1].x=(float)tweenArguments["x"]; + } + if (tweenArguments.Contains("y")) { + vector3s[1].y=(float)tweenArguments["y"]; + } + if (tweenArguments.Contains("z")) { + vector3s[1].z=(float)tweenArguments["z"]; + } + } + } + + #endregion + + #region #4 Apply Targets + + void ApplyRectTargets(){ + //calculate: + rects[2].x = ease(rects[0].x,rects[1].x,percentage); + rects[2].y = ease(rects[0].y,rects[1].y,percentage); + rects[2].width = ease(rects[0].width,rects[1].width,percentage); + rects[2].height = ease(rects[0].height,rects[1].height,percentage); + + //apply: + tweenArguments["onupdateparams"]=rects[2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=rects[1]; + } + } + + void ApplyColorTargets(){ + //calculate: + colors[0,2].r = ease(colors[0,0].r,colors[0,1].r,percentage); + colors[0,2].g = ease(colors[0,0].g,colors[0,1].g,percentage); + colors[0,2].b = ease(colors[0,0].b,colors[0,1].b,percentage); + colors[0,2].a = ease(colors[0,0].a,colors[0,1].a,percentage); + + //apply: + tweenArguments["onupdateparams"]=colors[0,2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=colors[0,1]; + } + } + + void ApplyVector3Targets(){ + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + tweenArguments["onupdateparams"]=vector3s[2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=vector3s[1]; + } + } + + void ApplyVector2Targets(){ + //calculate: + vector2s[2].x = ease(vector2s[0].x,vector2s[1].x,percentage); + vector2s[2].y = ease(vector2s[0].y,vector2s[1].y,percentage); + + //apply: + tweenArguments["onupdateparams"]=vector2s[2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=vector2s[1]; + } + } + + void ApplyFloatTargets(){ + //calculate: + floats[2] = ease(floats[0],floats[1],percentage); + + //apply: + tweenArguments["onupdateparams"]=floats[2]; + + //dial in: + if(percentage==1){ + tweenArguments["onupdateparams"]=floats[1]; + } + } + + void ApplyColorToTargets(){ + //calculate: + for (int i = 0; i < colors.GetLength(0); i++) { + colors[i,2].r = ease(colors[i,0].r,colors[i,1].r,percentage); + colors[i,2].g = ease(colors[i,0].g,colors[i,1].g,percentage); + colors[i,2].b = ease(colors[i,0].b,colors[i,1].b,percentage); + colors[i,2].a = ease(colors[i,0].a,colors[i,1].a,percentage); + } + /* + colors[2].r = ease(colors[0].r,colors[1].r,percentage); + colors[2].g = ease(colors[0].g,colors[1].g,percentage); + colors[2].b = ease(colors[0].b,colors[1].b,percentage); + colors[2].a = ease(colors[0].a,colors[1].a,percentage); + */ + + //apply: + if(GetComponent(typeof(GUITexture))){ + //guiTexture.color=colors[2]; + guiTexture.color=colors[0,2]; + }else if(GetComponent(typeof(GUIText))){ + //guiText.material.color=colors[2]; + guiText.material.color=colors[0,2]; + }else if(renderer){ + //renderer.material.color=colors[2]; + for (int i = 0; i < colors.GetLength(0); i++) { + renderer.materials[i].SetColor(namedcolorvalue.ToString(),colors[i,2]); + } + }else if(light){ + //light.color=colors[2]; + light.color=colors[0,2]; + } + + //dial in: + if(percentage==1){ + if(GetComponent(typeof(GUITexture))){ + //guiTexture.color=colors[1]; + guiTexture.color=colors[0,1]; + }else if(GetComponent(typeof(GUIText))){ + //guiText.material.color=colors[1]; + guiText.material.color=colors[0,1]; + }else if(renderer){ + //renderer.material.color=colors[1]; + for (int i = 0; i < colors.GetLength(0); i++) { + renderer.materials[i].SetColor(namedcolorvalue.ToString(),colors[i,1]); + } + }else if(light){ + //light.color=colors[1]; + light.color=colors[0,1]; + } + } + } + + void ApplyAudioToTargets(){ + //calculate: + vector2s[2].x = ease(vector2s[0].x,vector2s[1].x,percentage); + vector2s[2].y = ease(vector2s[0].y,vector2s[1].y,percentage); + + //apply: + audioSource.volume=vector2s[2].x; + audioSource.pitch=vector2s[2].y; + + //dial in: + if(percentage==1){ + audioSource.volume=vector2s[1].x; + audioSource.pitch=vector2s[1].y; + } + } + + void ApplyStabTargets(){ + //unnecessary but here just in case + } + + void ApplyMoveToPathTargets(){ + preUpdate = transform.position; + float t = ease(0,1,percentage); + float lookAheadAmount; + + //clamp easing equation results as "back" will fail since overshoots aren't handled in the Catmull-Rom interpolation: + if(isLocal){ + transform.localPosition=path.Interp(Mathf.Clamp(t,0,1)); + }else{ + transform.position=path.Interp(Mathf.Clamp(t,0,1)); + } + + //handle orient to path request: + if(tweenArguments.Contains("orienttopath") && (bool)tweenArguments["orienttopath"]){ + + //plot a point slightly ahead in the interpolation by pushing the percentage forward using the default lookahead value: + float tLook; + if(tweenArguments.Contains("lookahead")){ + lookAheadAmount = (float)tweenArguments["lookahead"]; + }else{ + lookAheadAmount = Defaults.lookAhead; + } + //tLook = ease(0,1,percentage+lookAheadAmount); + tLook = ease(0,1, Mathf.Min(1f, percentage+lookAheadAmount)); + + //locate new leading point with a clamp as stated above: + //Vector3 lookDistance = path.Interp(Mathf.Clamp(tLook,0,1)) - transform.position; + tweenArguments["looktarget"] = path.Interp(Mathf.Clamp(tLook,0,1)); + } + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + rigidbody.MovePosition(postUpdate); + } + } + + void ApplyMoveToTargets(){ + //record current: + preUpdate=transform.position; + + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + if (isLocal) { + transform.localPosition=vector3s[2]; + }else{ + transform.position=vector3s[2]; + } + + //dial in: + if(percentage==1){ + if (isLocal) { + transform.localPosition=vector3s[1]; + }else{ + transform.position=vector3s[1]; + } + } + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + rigidbody.MovePosition(postUpdate); + } + } + + void ApplyMoveByTargets(){ + preUpdate = transform.position; + + //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation + Vector3 currentRotation = new Vector3(); + + if(tweenArguments.Contains("looktarget")){ + currentRotation = transform.eulerAngles; + transform.eulerAngles = vector3s[4]; + } + + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + transform.Translate(vector3s[2]-vector3s[3],space); + + //record: + vector3s[3]=vector3s[2]; + + //reset rotation: + if(tweenArguments.Contains("looktarget")){ + transform.eulerAngles = currentRotation; + } + + /* + //dial in: + if(percentage==1){ + transform.position=vector3s[5]; + } + */ + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + rigidbody.MovePosition(postUpdate); + } + } + + void ApplyScaleToTargets(){ + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + transform.localScale=vector3s[2]; + + //dial in: + if(percentage==1){ + transform.localScale=vector3s[1]; + } + } + + void ApplyLookToTargets(){ + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + if (isLocal) { + transform.localRotation = Quaternion.Euler(vector3s[2]); + }else{ + transform.rotation = Quaternion.Euler(vector3s[2]); + }; + } + + void ApplyRotateToTargets(){ + preUpdate=transform.eulerAngles; + + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + if (isLocal) { + transform.localRotation = Quaternion.Euler(vector3s[2]); + }else{ + transform.rotation = Quaternion.Euler(vector3s[2]); + }; + + //dial in: + if(percentage==1){ + if (isLocal) { + transform.localRotation = Quaternion.Euler(vector3s[1]); + }else{ + transform.rotation = Quaternion.Euler(vector3s[1]); + }; + } + + //need physics? + postUpdate=transform.eulerAngles; + if(physics){ + transform.eulerAngles=preUpdate; + rigidbody.MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + void ApplyRotateAddTargets(){ + preUpdate = transform.eulerAngles; + + //calculate: + vector3s[2].x = ease(vector3s[0].x,vector3s[1].x,percentage); + vector3s[2].y = ease(vector3s[0].y,vector3s[1].y,percentage); + vector3s[2].z = ease(vector3s[0].z,vector3s[1].z,percentage); + + //apply: + transform.Rotate(vector3s[2]-vector3s[3],space); + + //record: + vector3s[3]=vector3s[2]; + + //need physics? + postUpdate=transform.eulerAngles; + if(physics){ + transform.eulerAngles=preUpdate; + rigidbody.MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + void ApplyShakePositionTargets(){ + preUpdate = transform.position; + + //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation + Vector3 currentRotation = new Vector3(); + + if(tweenArguments.Contains("looktarget")){ + currentRotation = transform.eulerAngles; + transform.eulerAngles = vector3s[3]; + } + + //impact: + if (percentage==0) { + transform.Translate(vector3s[1],space); + } + + //reset: + transform.position=vector3s[0]; + + //generate: + float diminishingControl = 1-percentage; + vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl); + vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl); + vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl); + + //apply: + transform.Translate(vector3s[2],space); + + //reset rotation: + if(tweenArguments.Contains("looktarget")){ + transform.eulerAngles = currentRotation; + } + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + rigidbody.MovePosition(postUpdate); + } + } + + void ApplyShakeScaleTargets(){ + //impact: + if (percentage==0) { + transform.localScale=vector3s[1]; + } + + //reset: + transform.localScale=vector3s[0]; + + //generate: + float diminishingControl = 1-percentage; + vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl); + vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl); + vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl); + + //apply: + transform.localScale+=vector3s[2]; + } + + void ApplyShakeRotationTargets(){ + preUpdate = transform.eulerAngles; + + //impact: + if (percentage==0) { + transform.Rotate(vector3s[1],space); + } + + //reset: + transform.eulerAngles=vector3s[0]; + + //generate: + float diminishingControl = 1-percentage; + vector3s[2].x= UnityEngine.Random.Range(-vector3s[1].x*diminishingControl, vector3s[1].x*diminishingControl); + vector3s[2].y= UnityEngine.Random.Range(-vector3s[1].y*diminishingControl, vector3s[1].y*diminishingControl); + vector3s[2].z= UnityEngine.Random.Range(-vector3s[1].z*diminishingControl, vector3s[1].z*diminishingControl); + + //apply: + transform.Rotate(vector3s[2],space); + + //need physics? + postUpdate=transform.eulerAngles; + if(physics){ + transform.eulerAngles=preUpdate; + rigidbody.MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + void ApplyPunchPositionTargets(){ + preUpdate = transform.position; + + //reset rotation to prevent look interferences as object rotates and attempts to move with translate and record current rotation + Vector3 currentRotation = new Vector3(); + + if(tweenArguments.Contains("looktarget")){ + currentRotation = transform.eulerAngles; + transform.eulerAngles = vector3s[4]; + } + + //calculate: + if(vector3s[1].x>0){ + vector3s[2].x = punch(vector3s[1].x,percentage); + }else if(vector3s[1].x<0){ + vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage); + } + if(vector3s[1].y>0){ + vector3s[2].y=punch(vector3s[1].y,percentage); + }else if(vector3s[1].y<0){ + vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage); + } + if(vector3s[1].z>0){ + vector3s[2].z=punch(vector3s[1].z,percentage); + }else if(vector3s[1].z<0){ + vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage); + } + + //apply: + transform.Translate(vector3s[2]-vector3s[3],space); + + //record: + vector3s[3]=vector3s[2]; + + //reset rotation: + if(tweenArguments.Contains("looktarget")){ + transform.eulerAngles = currentRotation; + } + + //dial in: + /* + if(percentage==1){ + transform.position=vector3s[0]; + } + */ + + //need physics? + postUpdate=transform.position; + if(physics){ + transform.position=preUpdate; + rigidbody.MovePosition(postUpdate); + } + } + + void ApplyPunchRotationTargets(){ + preUpdate = transform.eulerAngles; + + //calculate: + if(vector3s[1].x>0){ + vector3s[2].x = punch(vector3s[1].x,percentage); + }else if(vector3s[1].x<0){ + vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage); + } + if(vector3s[1].y>0){ + vector3s[2].y=punch(vector3s[1].y,percentage); + }else if(vector3s[1].y<0){ + vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage); + } + if(vector3s[1].z>0){ + vector3s[2].z=punch(vector3s[1].z,percentage); + }else if(vector3s[1].z<0){ + vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage); + } + + //apply: + transform.Rotate(vector3s[2]-vector3s[3],space); + + //record: + vector3s[3]=vector3s[2]; + + //dial in: + /* + if(percentage==1){ + transform.eulerAngles=vector3s[0]; + } + */ + + //need physics? + postUpdate=transform.eulerAngles; + if(physics){ + transform.eulerAngles=preUpdate; + rigidbody.MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + void ApplyPunchScaleTargets(){ + //calculate: + if(vector3s[1].x>0){ + vector3s[2].x = punch(vector3s[1].x,percentage); + }else if(vector3s[1].x<0){ + vector3s[2].x=-punch(Mathf.Abs(vector3s[1].x),percentage); + } + if(vector3s[1].y>0){ + vector3s[2].y=punch(vector3s[1].y,percentage); + }else if(vector3s[1].y<0){ + vector3s[2].y=-punch(Mathf.Abs(vector3s[1].y),percentage); + } + if(vector3s[1].z>0){ + vector3s[2].z=punch(vector3s[1].z,percentage); + }else if(vector3s[1].z<0){ + vector3s[2].z=-punch(Mathf.Abs(vector3s[1].z),percentage); + } + + //apply: + transform.localScale=vector3s[0]+vector3s[2]; + + //dial in: + /* + if(percentage==1){ + transform.localScale=vector3s[0]; + } + */ + } + + #endregion + + #region #5 Tween Steps + + IEnumerator TweenDelay(){ + delayStarted = Time.time; + yield return new WaitForSeconds (delay); + if(wasPaused){ + wasPaused=false; + TweenStart(); + } + } + + void TweenStart(){ + CallBack("onstart"); + + if(!loop){//only if this is not a loop + ConflictCheck(); + GenerateTargets(); + } + + //run stab: + if(type == "stab"){ + audioSource.PlayOneShot(audioSource.clip); + } + + //toggle isKinematic for iTweens that may interfere with physics: + if (type == "move" || type=="scale" || type=="rotate" || type=="punch" || type=="shake" || type=="curve" || type=="look") { + EnableKinematic(); + } + + isRunning = true; + } + + IEnumerator TweenRestart(){ + if(delay > 0){ + delayStarted = Time.time; + yield return new WaitForSeconds (delay); + } + loop=true; + TweenStart(); + } + + void TweenUpdate(){ + apply(); + CallBack("onupdate"); + UpdatePercentage(); + } + + void TweenComplete(){ + isRunning=false; + + //dial in percentage to 1 or 0 for final run: + if(percentage>.5f){ + percentage=1f; + }else{ + percentage=0; + } + + //apply dial in and final run: + apply(); + if(type == "value"){ + CallBack("onupdate"); //CallBack run for ValueTo since it only calculates and applies in the update callback + } + + //loop or dispose? + if(loopType==LoopType.none){ + Dispose(); + }else{ + TweenLoop(); + } + + CallBack("oncomplete"); + } + + void TweenLoop(){ + DisableKinematic(); //give physics control again + switch(loopType){ + case LoopType.loop: + //rewind: + percentage=0; + runningTime=0; + apply(); + + //replay: + StartCoroutine("TweenRestart"); + break; + case LoopType.pingPong: + reverse = !reverse; + runningTime=0; + + //replay: + StartCoroutine("TweenRestart"); + break; + } + } + + #endregion + + #region #6 Update Callable + + /// + /// Returns a Rect that is eased between a current and target value by the supplied speed. + /// + /// + /// A + /// + /// A the starting or initial value + /// + /// + /// A the target value that the current value will be eased to. + /// + /// + /// A to be used as rate of speed (larger number equals faster animation) + /// + public static Rect RectUpdate(Rect currentValue, Rect targetValue, float speed){ + Rect diff = new Rect(FloatUpdate(currentValue.x, targetValue.x, speed), FloatUpdate(currentValue.y, targetValue.y, speed), FloatUpdate(currentValue.width, targetValue.width, speed), FloatUpdate(currentValue.height, targetValue.height, speed)); + return (diff); + } + + /// + /// Returns a Vector3 that is eased between a current and target value by the supplied speed. + /// + /// + /// A + /// + /// + /// A the starting or initial value + /// + /// + /// A the target value that the current value will be eased to. + /// + /// + /// A to be used as rate of speed (larger number equals faster animation) + /// + public static Vector3 Vector3Update(Vector3 currentValue, Vector3 targetValue, float speed){ + Vector3 diff = targetValue - currentValue; + currentValue += (diff * speed) * Time.deltaTime; + return (currentValue); + } + + /// + /// Returns a Vector2 that is eased between a current and target value by the supplied speed. + /// + /// + /// A + /// + /// + /// A the starting or initial value + /// + /// + /// A the target value that the current value will be eased to. + /// + /// + /// A to be used as rate of speed (larger number equals faster animation) + /// + public static Vector2 Vector2Update(Vector2 currentValue, Vector2 targetValue, float speed){ + Vector2 diff = targetValue - currentValue; + currentValue += (diff * speed) * Time.deltaTime; + return (currentValue); + } + + /// + /// Returns a float that is eased between a current and target value by the supplied speed. + /// + /// + /// A + /// + /// + /// A the starting or initial value + /// + /// + /// A the target value that the current value will be eased to. + /// + /// + /// A to be used as rate of speed (larger number equals faster animation) + /// + public static float FloatUpdate(float currentValue, float targetValue, float speed){ + float diff = targetValue - currentValue; + currentValue += (diff * speed) * Time.deltaTime; + return (currentValue); + } + + /// + /// Similar to FadeTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for the final alpha value of the animation. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void FadeUpdate(GameObject target, Hashtable args){ + args["a"]=args["alpha"]; + ColorUpdate(target,args); + } + + /// + /// Similar to FadeTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final alpha value of the animation. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void FadeUpdate(GameObject target, float alpha, float time){ + FadeUpdate(target,Hash("alpha",alpha,"time",time)); + } + + /// + /// Similar to ColorTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A or for the individual setting of the color red. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the color green. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A or for the individual setting of the alpha. + /// + /// + /// A for whether or not to include children of this GameObject. True by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void ColorUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + float time; + Color[] colors = new Color[4]; + + //handle children: + if(!args.Contains("includechildren") || (bool)args["includechildren"]){ + foreach(Transform child in target.transform){ + ColorUpdate(child.gameObject,args); + } + } + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //init values: + if(target.GetComponent(typeof(GUITexture))){ + colors[0] = colors[1] = target.guiTexture.color; + }else if(target.GetComponent(typeof(GUIText))){ + colors[0] = colors[1] = target.guiText.material.color; + }else if(target.renderer){ + colors[0] = colors[1] = target.renderer.material.color; + }else if(target.light){ + colors[0] = colors[1] = target.light.color; + } + + //to values: + if (args.Contains("color")) { + colors[1]=(Color)args["color"]; + }else{ + if (args.Contains("r")) { + colors[1].r=(float)args["r"]; + } + if (args.Contains("g")) { + colors[1].g=(float)args["g"]; + } + if (args.Contains("b")) { + colors[1].b=(float)args["b"]; + } + if (args.Contains("a")) { + colors[1].a=(float)args["a"]; + } + } + + //calculate: + colors[3].r=Mathf.SmoothDamp(colors[0].r,colors[1].r,ref colors[2].r,time); + colors[3].g=Mathf.SmoothDamp(colors[0].g,colors[1].g,ref colors[2].g,time); + colors[3].b=Mathf.SmoothDamp(colors[0].b,colors[1].b,ref colors[2].b,time); + colors[3].a=Mathf.SmoothDamp(colors[0].a,colors[1].a,ref colors[2].a,time); + + //apply: + if(target.GetComponent(typeof(GUITexture))){ + target.guiTexture.color=colors[3]; + }else if(target.GetComponent(typeof(GUIText))){ + target.guiText.material.color=colors[3]; + }else if(target.renderer){ + target.renderer.material.color=colors[3]; + }else if(target.light){ + target.light.color=colors[3]; + } + } + + /// + /// Similar to ColorTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A to change the GameObject's color to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ColorUpdate(GameObject target, Color color, float time){ + ColorUpdate(target,Hash("color",color,"time",time)); + } + + /// + /// Similar to AudioTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A for which AudioSource to use. + /// + /// + /// A or for the target level of volume. + /// + /// + /// A or for the target pitch. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void AudioUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + AudioSource audioSource; + float time; + Vector2[] vector2s = new Vector2[4]; + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //set audioSource: + if(args.Contains("audiosource")){ + audioSource=(AudioSource)args["audiosource"]; + }else{ + if(target.GetComponent(typeof(AudioSource))){ + audioSource=target.audio; + }else{ + //throw error if no AudioSource is available: + Debug.LogError("iTween Error: AudioUpdate requires an AudioSource."); + return; + } + } + + //from values: + vector2s[0] = vector2s[1] = new Vector2(audioSource.volume,audioSource.pitch); + + //set to: + if(args.Contains("volume")){ + vector2s[1].x=(float)args["volume"]; + } + if(args.Contains("pitch")){ + vector2s[1].y=(float)args["pitch"]; + } + + //calculate: + vector2s[3].x=Mathf.SmoothDampAngle(vector2s[0].x,vector2s[1].x,ref vector2s[2].x,time); + vector2s[3].y=Mathf.SmoothDampAngle(vector2s[0].y,vector2s[1].y,ref vector2s[2].y,time); + + //apply: + audioSource.volume=vector2s[3].x; + audioSource.pitch=vector2s[3].y; + } + + /// + /// Similar to AudioTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the target level of volume. + /// + /// + /// A for the target pitch. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void AudioUpdate(GameObject target, float volume, float pitch, float time){ + AudioUpdate(target,Hash("volume",volume,"pitch",pitch,"time",time)); + } + + /// + /// Similar to RotateTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for the target Euler angles in degrees to rotate to. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A for whether to animate in world space or relative to the parent. False by default. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void RotateUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + bool isLocal; + float time; + Vector3[] vector3s = new Vector3[4]; + Vector3 preUpdate = target.transform.eulerAngles; + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //set isLocal: + if(args.Contains("islocal")){ + isLocal = (bool)args["islocal"]; + }else{ + isLocal = Defaults.isLocal; + } + + //from values: + if(isLocal){ + vector3s[0] = target.transform.localEulerAngles; + }else{ + vector3s[0] = target.transform.eulerAngles; + } + + //set to: + if(args.Contains("rotation")){ + if (args["rotation"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["rotation"]; + vector3s[1]=trans.eulerAngles; + }else if(args["rotation"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)args["rotation"]; + } + } + + //calculate: + vector3s[3].x=Mathf.SmoothDampAngle(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time); + vector3s[3].y=Mathf.SmoothDampAngle(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time); + vector3s[3].z=Mathf.SmoothDampAngle(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time); + + //apply: + if(isLocal){ + target.transform.localEulerAngles=vector3s[3]; + }else{ + target.transform.eulerAngles=vector3s[3]; + } + + //need physics? + if(target.rigidbody != null){ + Vector3 postUpdate=target.transform.eulerAngles; + target.transform.eulerAngles=preUpdate; + target.rigidbody.MoveRotation(Quaternion.Euler(postUpdate)); + } + } + + /// + /// Similar to RotateTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the target Euler angles in degrees to rotate to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void RotateUpdate(GameObject target, Vector3 rotation, float time){ + RotateUpdate(target,Hash("rotation",rotation,"time",time)); + } + + /// + /// Similar to ScaleTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for the final scale. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void ScaleUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + float time; + Vector3[] vector3s = new Vector3[4]; + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //init values: + vector3s[0] = vector3s[1] = target.transform.localScale; + + //to values: + if (args.Contains("scale")) { + if (args["scale"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["scale"]; + vector3s[1]=trans.localScale; + }else if(args["scale"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)args["scale"]; + } + }else{ + if (args.Contains("x")) { + vector3s[1].x=(float)args["x"]; + } + if (args.Contains("y")) { + vector3s[1].y=(float)args["y"]; + } + if (args.Contains("z")) { + vector3s[1].z=(float)args["z"]; + } + } + + //calculate: + vector3s[3].x=Mathf.SmoothDamp(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time); + vector3s[3].y=Mathf.SmoothDamp(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time); + vector3s[3].z=Mathf.SmoothDamp(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time); + + //apply: + target.transform.localScale=vector3s[3]; + } + + /// + /// Similar to ScaleTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for the final scale. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void ScaleUpdate(GameObject target, Vector3 scale, float time){ + ScaleUpdate(target,Hash("scale",scale,"time",time)); + } + + /// + /// Similar to MoveTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for a point in space the GameObject will animate to. + /// + /// + /// A or for the individual setting of the x axis. + /// + /// + /// A or for the individual setting of the y axis. + /// + /// + /// A or for the individual setting of the z axis. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + /// + /// A for whether to animate in world space or relative to the parent. False be default. + /// + /// + /// A for whether or not the GameObject will orient to its direction of travel. False by default. + /// + /// + /// A or A for a target the GameObject will look at. + /// + /// + /// A or for the time in seconds the object will take to look at either the "looktarget" or "orienttopath". + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + public static void MoveUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + float time; + Vector3[] vector3s = new Vector3[4]; + bool isLocal; + Vector3 preUpdate = target.transform.position; + + //set smooth time: + if(args.Contains("time")){ + time=(float)args["time"]; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //set isLocal: + if(args.Contains("islocal")){ + isLocal = (bool)args["islocal"]; + }else{ + isLocal = Defaults.isLocal; + } + + //init values: + if(isLocal){ + vector3s[0] = vector3s[1] = target.transform.localPosition; + }else{ + vector3s[0] = vector3s[1] = target.transform.position; + } + + //to values: + if (args.Contains("position")) { + if (args["position"].GetType() == typeof(Transform)){ + Transform trans = (Transform)args["position"]; + vector3s[1]=trans.position; + }else if(args["position"].GetType() == typeof(Vector3)){ + vector3s[1]=(Vector3)args["position"]; + } + }else{ + if (args.Contains("x")) { + vector3s[1].x=(float)args["x"]; + } + if (args.Contains("y")) { + vector3s[1].y=(float)args["y"]; + } + if (args.Contains("z")) { + vector3s[1].z=(float)args["z"]; + } + } + + //calculate: + vector3s[3].x=Mathf.SmoothDamp(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time); + vector3s[3].y=Mathf.SmoothDamp(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time); + vector3s[3].z=Mathf.SmoothDamp(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time); + + //handle orient to path: + if(args.Contains("orienttopath") && (bool)args["orienttopath"]){ + args["looktarget"] = vector3s[3]; + } + + //look applications: + if(args.Contains("looktarget")){ + iTween.LookUpdate(target,args); + } + + //apply: + if(isLocal){ + target.transform.localPosition = vector3s[3]; + }else{ + target.transform.position=vector3s[3]; + } + + //need physics? + if(target.rigidbody != null){ + Vector3 postUpdate=target.transform.position; + target.transform.position=preUpdate; + target.rigidbody.MovePosition(postUpdate); + } + } + + /// + /// Similar to MoveTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with MINIMUM customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for a point in space the GameObject will animate to. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void MoveUpdate(GameObject target, Vector3 position, float time){ + MoveUpdate(target,Hash("position",position,"time",time)); + } + + /// + /// Similar to LookTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A or for a target the GameObject will look at. + /// + /// + /// A . Restricts rotation to the supplied axis only. + /// + /// + /// A or for the time in seconds the animation will take to complete. + /// + public static void LookUpdate(GameObject target, Hashtable args){ + CleanArgs(args); + + float time; + Vector3[] vector3s = new Vector3[5]; + + //set smooth time: + if(args.Contains("looktime")){ + time=(float)args["looktime"]; + time*=Defaults.updateTimePercentage; + }else if(args.Contains("time")){ + time=(float)args["time"]*.15f; + time*=Defaults.updateTimePercentage; + }else{ + time=Defaults.updateTime; + } + + //from values: + vector3s[0] = target.transform.eulerAngles; + + //set look: + if(args.Contains("looktarget")){ + if (args["looktarget"].GetType() == typeof(Transform)) { + //target.transform.LookAt((Transform)args["looktarget"]); + target.transform.LookAt((Transform)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up); + }else if(args["looktarget"].GetType() == typeof(Vector3)){ + //target.transform.LookAt((Vector3)args["looktarget"]); + target.transform.LookAt((Vector3)args["looktarget"], (Vector3?)args["up"] ?? Defaults.up); + } + }else{ + Debug.LogError("iTween Error: LookUpdate needs a 'looktarget' property!"); + return; + } + + //to values and reset look: + vector3s[1]=target.transform.eulerAngles; + target.transform.eulerAngles=vector3s[0]; + + //calculate: + vector3s[3].x=Mathf.SmoothDampAngle(vector3s[0].x,vector3s[1].x,ref vector3s[2].x,time); + vector3s[3].y=Mathf.SmoothDampAngle(vector3s[0].y,vector3s[1].y,ref vector3s[2].y,time); + vector3s[3].z=Mathf.SmoothDampAngle(vector3s[0].z,vector3s[1].z,ref vector3s[2].z,time); + + //apply: + target.transform.eulerAngles=vector3s[3]; + + //axis restriction: + if(args.Contains("axis")){ + vector3s[4]=target.transform.eulerAngles; + switch((string)args["axis"]){ + case "x": + vector3s[4].y=vector3s[0].y; + vector3s[4].z=vector3s[0].z; + break; + case "y": + vector3s[4].x=vector3s[0].x; + vector3s[4].z=vector3s[0].z; + break; + case "z": + vector3s[4].x=vector3s[0].x; + vector3s[4].y=vector3s[0].y; + break; + } + + //apply axis restriction: + target.transform.eulerAngles=vector3s[4]; + } + } + + /// + /// Similar to LookTo but incredibly less expensive for usage inside the Update function or similar looping situations involving a "live" set of changing values with FULL customization options. Does not utilize an EaseType. + /// + /// + /// A to be the target of the animation. + /// + /// + /// A for a target the GameObject will look at. + /// + /// + /// A for the time in seconds the animation will take to complete. + /// + public static void LookUpdate(GameObject target, Vector3 looktarget, float time){ + LookUpdate(target,Hash("looktarget",looktarget,"time",time)); + } + + #endregion + + #region #7 External Utilities + + /// + /// Returns the length of a curved path drawn through the provided array of Transforms. + /// + /// + /// A + /// + /// + /// A + /// + public static float PathLength(Transform[] path){ + Vector3[] suppliedPath = new Vector3[path.Length]; + float pathLength = 0; + + //create and store path points: + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + Vector3[] vector3s = PathControlPointGenerator(suppliedPath); + + //Line Draw: + Vector3 prevPt = Interp(vector3s,0); + int SmoothAmount = path.Length*20; + for (int i = 1; i <= SmoothAmount; i++) { + float pm = (float) i / SmoothAmount; + Vector3 currPt = Interp(vector3s,pm); + pathLength += Vector3.Distance(prevPt,currPt); + prevPt = currPt; + } + + return pathLength; + } + + /// + /// Returns the length of a curved path drawn through the provided array of Vector3s. + /// + /// + /// The length. + /// + /// + /// A + /// + public static float PathLength(Vector3[] path){ + float pathLength = 0; + + Vector3[] vector3s = PathControlPointGenerator(path); + + //Line Draw: + Vector3 prevPt = Interp(vector3s,0); + int SmoothAmount = path.Length*20; + for (int i = 1; i <= SmoothAmount; i++) { + float pm = (float) i / SmoothAmount; + Vector3 currPt = Interp(vector3s,pm); + pathLength += Vector3.Distance(prevPt,currPt); + prevPt = currPt; + } + + return pathLength; + } + + /// + /// Creates and returns a full-screen Texture2D for use with CameraFade. + /// + /// + /// Texture2D + /// + /// + /// Color + /// + public static Texture2D CameraTexture(Color color){ + Texture2D texture = new Texture2D(Screen.width,Screen.height,TextureFormat.ARGB32, false); + Color[] colors = new Color[Screen.width*Screen.height]; + for (int i = 0; i < colors.Length; i++) { + colors[i]=color; + } + texture.SetPixels(colors); + texture.Apply(); + return(texture); + } + + /// + /// Puts a GameObject on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static void PutOnPath(GameObject target, Vector3[] path, float percent){ + target.transform.position=Interp(PathControlPointGenerator(path),percent); + } + + /// + /// Puts a GameObject on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static void PutOnPath(Transform target, Vector3[] path, float percent){ + target.position=Interp(PathControlPointGenerator(path),percent); + } + + /// + /// Puts a GameObject on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static void PutOnPath(GameObject target, Transform[] path, float percent){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + target.transform.position=Interp(PathControlPointGenerator(suppliedPath),percent); + } + + /// + /// Puts a GameObject on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static void PutOnPath(Transform target, Transform[] path, float percent){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + target.position=Interp(PathControlPointGenerator(suppliedPath),percent); + } + + /// + /// Returns a Vector3 position on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static Vector3 PointOnPath(Transform[] path, float percent){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + return(Interp(PathControlPointGenerator(suppliedPath),percent)); + } + + /// + /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Vector3s. + /// + /// + /// A + /// + public static void DrawLine(Vector3[] line) { + if(line.Length>0){ + DrawLineHelper(line,Defaults.color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Vector3s. + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLine(Vector3[] line, Color color) { + if(line.Length>0){ + DrawLineHelper(line,color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Transforms. + /// + /// + /// A + /// + public static void DrawLine(Transform[] line) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + DrawLineHelper(suppliedLine,Defaults.color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a line through the provided array of Transforms. + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLine(Transform[] line,Color color) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + + DrawLineHelper(suppliedLine, color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Vector3s with Gizmos.DrawLine(). + /// + /// + /// A + /// + public static void DrawLineGizmos(Vector3[] line) { + if(line.Length>0){ + DrawLineHelper(line,Defaults.color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Vector3s with Gizmos.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLineGizmos(Vector3[] line, Color color) { + if(line.Length>0){ + DrawLineHelper(line,color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Transforms with Gizmos.DrawLine(). + /// + /// + /// A + /// + public static void DrawLineGizmos(Transform[] line) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + DrawLineHelper(suppliedLine,Defaults.color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Transforms with Gizmos.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLineGizmos(Transform[] line,Color color) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + + DrawLineHelper(suppliedLine, color,"gizmos"); + } + } + + /// + /// Draws a line through the provided array of Vector3s with Handles.DrawLine(). + /// + /// + /// A + /// + public static void DrawLineHandles(Vector3[] line) { + if(line.Length>0){ + DrawLineHelper(line,Defaults.color,"handles"); + } + } + + /// + /// Draws a line through the provided array of Vector3s with Handles.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLineHandles(Vector3[] line, Color color) { + if(line.Length>0){ + DrawLineHelper(line,color,"handles"); + } + } + + /// + /// Draws a line through the provided array of Transforms with Handles.DrawLine(). + /// + /// + /// A + /// + public static void DrawLineHandles(Transform[] line) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + DrawLineHelper(suppliedLine,Defaults.color,"handles"); + } + } + + /// + /// Draws a line through the provided array of Transforms with Handles.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawLineHandles(Transform[] line,Color color) { + if(line.Length>0){ + //create and store line points: + Vector3[] suppliedLine = new Vector3[line.Length]; + for (int i = 0; i < line.Length; i++) { + suppliedLine[i]=line[i].position; + } + + DrawLineHelper(suppliedLine, color,"handles"); + } + } + + /// + /// Returns a Vector3 position on a path at the provided percentage + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A + /// + public static Vector3 PointOnPath(Vector3[] path, float percent){ + return(Interp(PathControlPointGenerator(path),percent)); + } + + /// + /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Vector3s. + /// + /// + /// A + /// + public static void DrawPath(Vector3[] path) { + if(path.Length>0){ + DrawPathHelper(path,Defaults.color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Vector3s. + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPath(Vector3[] path, Color color) { + if(path.Length>0){ + DrawPathHelper(path, color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Transforms. + /// + /// + /// A + /// + public static void DrawPath(Transform[] path) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath,Defaults.color,"gizmos"); + } + } + + /// + /// When called from an OnDrawGizmos() function it will draw a curved path through the provided array of Transforms. + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPath(Transform[] path,Color color) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath, color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Vector3s with Gizmos.DrawLine(). + /// + /// + /// A + /// + public static void DrawPathGizmos(Vector3[] path) { + if(path.Length>0){ + DrawPathHelper(path,Defaults.color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Vector3s with Gizmos.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPathGizmos(Vector3[] path, Color color) { + if(path.Length>0){ + DrawPathHelper(path, color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Transforms with Gizmos.DrawLine(). + /// + /// + /// A + /// + public static void DrawPathGizmos(Transform[] path) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath,Defaults.color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Transforms with Gizmos.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPathGizmos(Transform[] path,Color color) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath, color,"gizmos"); + } + } + + /// + /// Draws a curved path through the provided array of Vector3s with Handles.DrawLine(). + /// + /// + /// A + /// + public static void DrawPathHandles(Vector3[] path) { + if(path.Length>0){ + DrawPathHelper(path,Defaults.color,"handles"); + } + } + + /// + /// Draws a curved path through the provided array of Vector3s with Handles.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPathHandles(Vector3[] path, Color color) { + if(path.Length>0){ + DrawPathHelper(path, color,"handles"); + } + } + + /// + /// Draws a curved path through the provided array of Transforms with Handles.DrawLine(). + /// + /// + /// A + /// + public static void DrawPathHandles(Transform[] path) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath,Defaults.color,"handles"); + } + } + + /// + /// Draws a curved path through the provided array of Transforms with Handles.DrawLine(). + /// + /// + /// A + /// + /// + /// A + /// + public static void DrawPathHandles(Transform[] path,Color color) { + if(path.Length>0){ + //create and store path points: + Vector3[] suppliedPath = new Vector3[path.Length]; + for (int i = 0; i < path.Length; i++) { + suppliedPath[i]=path[i].position; + } + + DrawPathHelper(suppliedPath, color,"handles"); + } + } + + /// + /// Changes a camera fade's texture. + /// + /// + /// A + /// + public static void CameraFadeDepth(int depth){ + if(cameraFade){ + cameraFade.transform.position=new Vector3(cameraFade.transform.position.x,cameraFade.transform.position.y,depth); + } + } + + /// + /// Removes and destroyes a camera fade. + /// + public static void CameraFadeDestroy(){ + if(cameraFade){ + Destroy(cameraFade); + } + } + + /// + /// Changes a camera fade's texture. + /// + /// + /// A + /// + public static void CameraFadeSwap(Texture2D texture){ + if(cameraFade){ + cameraFade.guiTexture.texture=texture; + } + } + + /// + /// Creates a GameObject (if it doesn't exist) at the supplied depth that can be used to simulate a camera fade. + /// + /// + /// A + /// + /// + /// A + /// + /// + /// A for a reference to the CameraFade. + /// + public static GameObject CameraFadeAdd(Texture2D texture, int depth){ + if(cameraFade){ + return null; + }else{ + //establish colorFade object: + cameraFade = new GameObject("iTween Camera Fade"); + cameraFade.transform.position= new Vector3(.5f,.5f,depth); + cameraFade.AddComponent(); + cameraFade.guiTexture.texture=texture; + cameraFade.guiTexture.color = new Color(.5f,.5f,.5f,0); + return cameraFade; + } + } + + /// + /// Creates a GameObject (if it doesn't exist) at the default depth that can be used to simulate a camera fade. + /// + /// + /// A + /// + /// + /// A for a reference to the CameraFade. + /// + public static GameObject CameraFadeAdd(Texture2D texture){ + if(cameraFade){ + return null; + }else{ + //establish colorFade object: + cameraFade = new GameObject("iTween Camera Fade"); + cameraFade.transform.position= new Vector3(.5f,.5f,Defaults.cameraFadeDepth); + cameraFade.AddComponent(); + cameraFade.guiTexture.texture=texture; + cameraFade.guiTexture.color = new Color(.5f,.5f,.5f,0); + return cameraFade; + } + } + + /// + /// Creates a GameObject (if it doesn't exist) at the default depth filled with black that can be used to simulate a camera fade. + /// + /// + /// A for a reference to the CameraFade. + /// + public static GameObject CameraFadeAdd(){ + if(cameraFade){ + return null; + }else{ + //establish colorFade object: + cameraFade = new GameObject("iTween Camera Fade"); + cameraFade.transform.position= new Vector3(.5f,.5f,Defaults.cameraFadeDepth); + cameraFade.AddComponent(); + cameraFade.guiTexture.texture=CameraTexture(Color.black); + cameraFade.guiTexture.color = new Color(.5f,.5f,.5f,0); + return cameraFade; + } + } + + + //################################# + //# RESUME UTILITIES AND OVERLOADS # + //################################# + + /// + /// Resume all iTweens on a GameObject. + /// + public static void Resume(GameObject target){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + item.enabled=true; + } + } + + /// + /// Resume all iTweens on a GameObject including its children. + /// + public static void Resume(GameObject target, bool includechildren){ + Resume(target); + if(includechildren){ + foreach(Transform child in target.transform){ + Resume(child.gameObject,true); + } + } + } + + /// + /// Resume all iTweens on a GameObject of a particular type. + /// + /// A name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Resume(GameObject target, string type){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.enabled=true; + } + } + } + + /// + /// Resume all iTweens on a GameObject of a particular type including its children. + /// + /// A name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Resume(GameObject target, string type, bool includechildren){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.enabled=true; + } + } + if(includechildren){ + foreach(Transform child in target.transform){ + Resume(child.gameObject,type,true); + } + } + } + + /// + /// Resume all iTweens in scene. + /// + public static void Resume(){ + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + Resume(target); + } + } + + /// + /// Resume all iTweens in scene of a particular type. + /// + /// + /// A name of the type of iTween you would like to resume. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Resume(string type){ + ArrayList resumeArray = new ArrayList(); + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + resumeArray.Insert(resumeArray.Count,target); + } + + for (int i = 0; i < resumeArray.Count; i++) { + Resume((GameObject)resumeArray[i],type); + } + } + + //################################# + //# PAUSE UTILITIES AND OVERLOADS # + //################################# + + /// + /// Pause all iTweens on a GameObject. + /// + public static void Pause(GameObject target){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + if(item.delay>0){ + item.delay-=Time.time-item.delayStarted; + item.StopCoroutine("TweenDelay"); + } + item.isPaused=true; + item.enabled=false; + } + } + + /// + /// Pause all iTweens on a GameObject including its children. + /// + public static void Pause(GameObject target, bool includechildren){ + Pause(target); + if(includechildren){ + foreach(Transform child in target.transform){ + Pause(child.gameObject,true); + } + } + } + + /// + /// Pause all iTweens on a GameObject of a particular type. + /// + /// A name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Pause(GameObject target, string type){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + if(item.delay>0){ + item.delay-=Time.time-item.delayStarted; + item.StopCoroutine("TweenDelay"); + } + item.isPaused=true; + item.enabled=false; + } + } + } + + /// + /// Pause all iTweens on a GameObject of a particular type including its children. + /// + /// A name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Pause(GameObject target, string type, bool includechildren){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + if(item.delay>0){ + item.delay-=Time.time-item.delayStarted; + item.StopCoroutine("TweenDelay"); + } + item.isPaused=true; + item.enabled=false; + } + } + if(includechildren){ + foreach(Transform child in target.transform){ + Pause(child.gameObject,type,true); + } + } + } + + /// + /// Pause all iTweens in scene. + /// + public static void Pause(){ + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + Pause(target); + } + } + + /// + /// Pause all iTweens in scene of a particular type. + /// + /// + /// A name of the type of iTween you would like to pause. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Pause(string type){ + ArrayList pauseArray = new ArrayList(); + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + pauseArray.Insert(pauseArray.Count,target); + } + + for (int i = 0; i < pauseArray.Count; i++) { + Pause((GameObject)pauseArray[i],type); + } + } + + //################################# + //# COUNT UTILITIES AND OVERLOADS # + //################################# + + /// + /// Count all iTweens in current scene. + /// + public static int Count(){ + return(tweens.Count); + } + + /// + /// Count all iTweens in current scene of a particular type. + /// + /// + /// A name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static int Count(string type){ + int tweenCount = 0; + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + string targetType = (string)currentTween["type"]+(string)currentTween["method"]; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + tweenCount++; + } + } + + return(tweenCount); + } + + /// + /// Count all iTweens on a GameObject. + /// + public static int Count(GameObject target){ + Component[] tweens = target.GetComponents(typeof(iTween)); + return(tweens.Length); + } + + /// + /// Count all iTweens on a GameObject of a particular type. + /// + /// + /// A name of the type of iTween you would like to count. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static int Count(GameObject target, string type){ + int tweenCount = 0; + Component[] tweens = target.GetComponents(typeof(iTween));foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + tweenCount++; + } + } + return(tweenCount); + } + + //################################ + //# STOP UTILITIES AND OVERLOADS # + //################################ + + /// + /// Stop and destroy all Tweens in current scene. + /// + public static void Stop(){ + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + Stop(target); + } + tweens.Clear(); + } + + /// + /// Stop and destroy all iTweens in current scene of a particular type. + /// + /// + /// A name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Stop(string type){ + ArrayList stopArray = new ArrayList(); + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + stopArray.Insert(stopArray.Count,target); + } + + for (int i = 0; i < stopArray.Count; i++) { + Stop((GameObject)stopArray[i],type); + } + } + + /* GFX47 MOD START */ + /// + /// Stop and destroy all iTweens in current scene of a particular name. + /// + /// + /// The name of iTween you would like to stop. + /// + public static void StopByName(string name){ + ArrayList stopArray = new ArrayList(); + + for (int i = 0; i < tweens.Count; i++) { + Hashtable currentTween = (Hashtable)tweens[i]; + GameObject target = (GameObject)currentTween["target"]; + stopArray.Insert(stopArray.Count,target); + } + + for (int i = 0; i < stopArray.Count; i++) { + StopByName((GameObject)stopArray[i],name); + } + } + /* GFX47 MOD END */ + + /// + /// Stop and destroy all iTweens on a GameObject. + /// + public static void Stop(GameObject target){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + item.Dispose(); + } + } + + /// + /// Stop and destroy all iTweens on a GameObject including its children. + /// + public static void Stop(GameObject target, bool includechildren){ + Stop(target); + if(includechildren){ + foreach(Transform child in target.transform){ + Stop(child.gameObject,true); + } + } + } + + /// + /// Stop and destroy all iTweens on a GameObject of a particular type. + /// + /// A name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Stop(GameObject target, string type){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.Dispose(); + } + } + } + + /* GFX47 MOD START */ + /// + /// Stop and destroy all iTweens on a GameObject of a particular name. + /// + /// The name of iTween you would like to stop. + /// + public static void StopByName(GameObject target, string name){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + /*string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.Dispose(); + }*/ + if(item._name == name){ + item.Dispose(); + } + } + } + /* GFX47 MOD END */ + + /// + /// Stop and destroy all iTweens on a GameObject of a particular type including its children. + /// + /// A name of the type of iTween you would like to stop. Can be written as part of a name such as "mov" for all "MoveTo" iTweens. + /// + public static void Stop(GameObject target, string type, bool includechildren){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.Dispose(); + } + } + if(includechildren){ + foreach(Transform child in target.transform){ + Stop(child.gameObject,type,true); + } + } + } + + /* GFX47 MOD START */ + /// + /// Stop and destroy all iTweens on a GameObject of a particular name including its children. + /// + /// The name of iTween you would like to stop. + /// + public static void StopByName(GameObject target, string name, bool includechildren){ + Component[] tweens = target.GetComponents(typeof(iTween)); + foreach (iTween item in tweens){ + /*string targetType = item.type+item.method; + targetType=targetType.Substring(0,type.Length); + if(targetType.ToLower() == type.ToLower()){ + item.Dispose(); + }*/ + if(item._name == name){ + item.Dispose(); + } + } + if(includechildren){ + foreach(Transform child in target.transform){ + //Stop(child.gameObject,type,true); + StopByName(child.gameObject,name,true); + } + } + } + /* GFX47 MOD END */ + + /// + /// Universal interface to help in the creation of Hashtables. Especially useful for C# users. + /// + /// + /// A of alternating name value pairs. For example "time",1,"delay",2... + /// + /// + /// A + /// + public static Hashtable Hash(params object[] args){ + Hashtable hashTable = new Hashtable(args.Length/2); + if (args.Length %2 != 0) { + Debug.LogError("Tween Error: Hash requires an even number of arguments!"); + return null; + }else{ + int i = 0; + while(i < args.Length - 1) { + hashTable.Add(args[i], args[i+1]); + i += 2; + } + return hashTable; + } + } + + #endregion + + #region Component Segments + + void Awake(){ + RetrieveArgs(); + lastRealTime = Time.realtimeSinceStartup; // Added by PressPlay + } + + IEnumerator Start(){ + if(delay > 0){ + yield return StartCoroutine("TweenDelay"); + } + TweenStart(); + } + + //non-physics + void Update(){ + if(isRunning && !physics){ + if(!reverse){ + if(percentage<1f){ + TweenUpdate(); + }else{ + TweenComplete(); + } + }else{ + if(percentage>0){ + TweenUpdate(); + }else{ + TweenComplete(); + } + } + } + } + + //physics + void FixedUpdate(){ + if(isRunning && physics){ + if(!reverse){ + if(percentage<1f){ + TweenUpdate(); + }else{ + TweenComplete(); + } + }else{ + if(percentage>0){ + TweenUpdate(); + }else{ + TweenComplete(); + } + } + } + } + + void LateUpdate(){ + //look applications: + if(tweenArguments.Contains("looktarget") && isRunning){ + if(type =="move" || type =="shake" || type=="punch"){ + LookUpdate(gameObject,tweenArguments); + } + } + } + + void OnEnable(){ + if(isRunning){ + EnableKinematic(); + } + + //resume delay: + if(isPaused){ + isPaused=false; + if(delay > 0){ + wasPaused=true; + ResumeDelay(); + } + } + } + + void OnDisable(){ + DisableKinematic(); + } + + #endregion + + #region Internal Helpers + + private static void DrawLineHelper(Vector3[] line, Color color, string method){ + Gizmos.color=color; + for (int i = 0; i < line.Length-1; i++) { + if(method == "gizmos"){ + Gizmos.DrawLine(line[i], line[i+1]);; + }else if(method == "handles"){ + Debug.LogError("iTween Error: Drawing a line with Handles is temporarily disabled because of compatability issues with Unity 2.6!"); + //UnityEditor.Handles.DrawLine(line[i], line[i+1]); + } + } + } + + private static void DrawPathHelper(Vector3[] path, Color color, string method){ + Vector3[] vector3s = PathControlPointGenerator(path); + + //Line Draw: + Vector3 prevPt = Interp(vector3s,0); + Gizmos.color=color; + int SmoothAmount = path.Length*20; + for (int i = 1; i <= SmoothAmount; i++) { + float pm = (float) i / SmoothAmount; + Vector3 currPt = Interp(vector3s,pm); + if(method == "gizmos"){ + Gizmos.DrawLine(currPt, prevPt); + }else if(method == "handles"){ + Debug.LogError("iTween Error: Drawing a path with Handles is temporarily disabled because of compatability issues with Unity 2.6!"); + //UnityEditor.Handles.DrawLine(currPt, prevPt); + } + prevPt = currPt; + } + } + + private static Vector3[] PathControlPointGenerator(Vector3[] path){ + Vector3[] suppliedPath; + Vector3[] vector3s; + + //create and store path points: + suppliedPath = path; + + //populate calculate path; + int offset = 2; + vector3s = new Vector3[suppliedPath.Length+offset]; + Array.Copy(suppliedPath,0,vector3s,1,suppliedPath.Length); + + //populate start and end control points: + //vector3s[0] = vector3s[1] - vector3s[2]; + vector3s[0] = vector3s[1] + (vector3s[1] - vector3s[2]); + vector3s[vector3s.Length-1] = vector3s[vector3s.Length-2] + (vector3s[vector3s.Length-2] - vector3s[vector3s.Length-3]); + + //is this a closed, continuous loop? yes? well then so let's make a continuous Catmull-Rom spline! + if(vector3s[1] == vector3s[vector3s.Length-2]){ + Vector3[] tmpLoopSpline = new Vector3[vector3s.Length]; + Array.Copy(vector3s,tmpLoopSpline,vector3s.Length); + tmpLoopSpline[0]=tmpLoopSpline[tmpLoopSpline.Length-3]; + tmpLoopSpline[tmpLoopSpline.Length-1]=tmpLoopSpline[2]; + vector3s=new Vector3[tmpLoopSpline.Length]; + Array.Copy(tmpLoopSpline,vector3s,tmpLoopSpline.Length); + } + + return(vector3s); + } + + //andeeee from the Unity forum's steller Catmull-Rom class ( http://forum.unity3d.com/viewtopic.php?p=218400#218400 ): + private static Vector3 Interp(Vector3[] pts, float t){ + int numSections = pts.Length - 3; + int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); + float u = t * (float) numSections - (float) currPt; + + Vector3 a = pts[currPt]; + Vector3 b = pts[currPt + 1]; + Vector3 c = pts[currPt + 2]; + Vector3 d = pts[currPt + 3]; + + return .5f * ( + (-a + 3f * b - 3f * c + d) * (u * u * u) + + (2f * a - 5f * b + 4f * c - d) * (u * u) + + (-a + c) * u + + 2f * b + ); + } + + //andeeee from the Unity forum's steller Catmull-Rom class ( http://forum.unity3d.com/viewtopic.php?p=218400#218400 ): + private class CRSpline { + public Vector3[] pts; + + public CRSpline(params Vector3[] pts) { + this.pts = new Vector3[pts.Length]; + Array.Copy(pts, this.pts, pts.Length); + } + + + public Vector3 Interp(float t) { + int numSections = pts.Length - 3; + int currPt = Mathf.Min(Mathf.FloorToInt(t * (float) numSections), numSections - 1); + float u = t * (float) numSections - (float) currPt; + Vector3 a = pts[currPt]; + Vector3 b = pts[currPt + 1]; + Vector3 c = pts[currPt + 2]; + Vector3 d = pts[currPt + 3]; + return .5f*((-a+3f*b-3f*c+d)*(u*u*u)+(2f*a-5f*b+4f*c-d)*(u*u)+(-a+c)*u+2f*b); + } + } + + //catalog new tween and add component phase of iTween: + static void Launch(GameObject target, Hashtable args){ + if(!args.Contains("id")){ + args["id"] = GenerateID(); + } + if(!args.Contains("target")){ + args["target"] = target; + } + tweens.Insert(0,args); + target.AddComponent(); + } + + //cast any accidentally supplied doubles and ints as floats as iTween only uses floats internally and unify parameter case: + static Hashtable CleanArgs(Hashtable args){ + Hashtable argsCopy = new Hashtable(args.Count); + Hashtable argsCaseUnified = new Hashtable(args.Count); + + foreach (DictionaryEntry item in args) { + argsCopy.Add(item.Key, item.Value); + } + + foreach (DictionaryEntry item in argsCopy) { + if(item.Value.GetType() == typeof(System.Int32)){ + int original = (int)item.Value; + float casted = (float)original; + args[item.Key] = casted; + } + if(item.Value.GetType() == typeof(System.Double)){ + double original = (double)item.Value; + float casted = (float)original; + args[item.Key] = casted; + } + } + + //unify parameter case: + foreach (DictionaryEntry item in args) { + argsCaseUnified.Add(item.Key.ToString().ToLower(), item.Value); + } + + //swap back case unification: + args = argsCaseUnified; + + return args; + } + + //random ID generator: + static string GenerateID(){ + int strlen = 15; + char[] chars = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8'}; + int num_chars = chars.Length - 1; + string randomChar = ""; + for (int i = 0; i < strlen; i++) { + randomChar += chars[(int)Mathf.Floor(UnityEngine.Random.Range(0,num_chars))]; + } + return randomChar; + } + + //grab and set generic, neccesary iTween arguments: + void RetrieveArgs(){ + foreach (Hashtable item in tweens) { + if((GameObject)item["target"] == gameObject){ + tweenArguments=item; + break; + } + } + + id=(string)tweenArguments["id"]; + type=(string)tweenArguments["type"]; + /* GFX47 MOD START */ + _name=(string)tweenArguments["name"]; + /* GFX47 MOD END */ + method=(string)tweenArguments["method"]; + + if(tweenArguments.Contains("time")){ + time=(float)tweenArguments["time"]; + }else{ + time=Defaults.time; + } + + //do we need to use physics, is there a rigidbody? + if(rigidbody != null){ + physics=true; + } + + if(tweenArguments.Contains("delay")){ + delay=(float)tweenArguments["delay"]; + }else{ + delay=Defaults.delay; + } + + if(tweenArguments.Contains("namedcolorvalue")){ + //allows namedcolorvalue to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability: + if(tweenArguments["namedcolorvalue"].GetType() == typeof(NamedValueColor)){ + namedcolorvalue=(NamedValueColor)tweenArguments["namedcolorvalue"]; + }else{ + try { + namedcolorvalue=(NamedValueColor)Enum.Parse(typeof(NamedValueColor),(string)tweenArguments["namedcolorvalue"],true); + } catch { + Debug.LogWarning("iTween: Unsupported namedcolorvalue supplied! Default will be used."); + namedcolorvalue = iTween.NamedValueColor._Color; + } + } + }else{ + namedcolorvalue=Defaults.namedColorValue; + } + + if(tweenArguments.Contains("looptype")){ + //allows loopType to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability: + if(tweenArguments["looptype"].GetType() == typeof(LoopType)){ + loopType=(LoopType)tweenArguments["looptype"]; + }else{ + try { + loopType=(LoopType)Enum.Parse(typeof(LoopType),(string)tweenArguments["looptype"],true); + } catch { + Debug.LogWarning("iTween: Unsupported loopType supplied! Default will be used."); + loopType = iTween.LoopType.none; + } + } + }else{ + loopType = iTween.LoopType.none; + } + + if(tweenArguments.Contains("easetype")){ + //allows easeType to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability: + if(tweenArguments["easetype"].GetType() == typeof(EaseType)){ + easeType=(EaseType)tweenArguments["easetype"]; + }else{ + try { + easeType=(EaseType)Enum.Parse(typeof(EaseType),(string)tweenArguments["easetype"],true); + } catch { + Debug.LogWarning("iTween: Unsupported easeType supplied! Default will be used."); + easeType=Defaults.easeType; + } + } + }else{ + easeType=Defaults.easeType; + } + + if(tweenArguments.Contains("space")){ + //allows space to be set as either an enum(C# friendly) or a string(JS friendly), string case usage doesn't matter to further increase usability: + if(tweenArguments["space"].GetType() == typeof(Space)){ + space=(Space)tweenArguments["space"]; + }else{ + try { + space=(Space)Enum.Parse(typeof(Space),(string)tweenArguments["space"],true); + } catch { + Debug.LogWarning("iTween: Unsupported space supplied! Default will be used."); + space = Defaults.space; + } + } + }else{ + space = Defaults.space; + } + + if(tweenArguments.Contains("islocal")){ + isLocal = (bool)tweenArguments["islocal"]; + }else{ + isLocal = Defaults.isLocal; + } + + // Added by PressPlay + if (tweenArguments.Contains("ignoretimescale")) + { + useRealTime = (bool)tweenArguments["ignoretimescale"]; + } + else + { + useRealTime = Defaults.useRealTime; + } + + //instantiates a cached ease equation reference: + GetEasingFunction(); + } + + //instantiates a cached ease equation refrence: + void GetEasingFunction(){ + switch (easeType){ + case EaseType.easeInQuad: + ease = new EasingFunction(easeInQuad); + break; + case EaseType.easeOutQuad: + ease = new EasingFunction(easeOutQuad); + break; + case EaseType.easeInOutQuad: + ease = new EasingFunction(easeInOutQuad); + break; + case EaseType.easeInCubic: + ease = new EasingFunction(easeInCubic); + break; + case EaseType.easeOutCubic: + ease = new EasingFunction(easeOutCubic); + break; + case EaseType.easeInOutCubic: + ease = new EasingFunction(easeInOutCubic); + break; + case EaseType.easeInQuart: + ease = new EasingFunction(easeInQuart); + break; + case EaseType.easeOutQuart: + ease = new EasingFunction(easeOutQuart); + break; + case EaseType.easeInOutQuart: + ease = new EasingFunction(easeInOutQuart); + break; + case EaseType.easeInQuint: + ease = new EasingFunction(easeInQuint); + break; + case EaseType.easeOutQuint: + ease = new EasingFunction(easeOutQuint); + break; + case EaseType.easeInOutQuint: + ease = new EasingFunction(easeInOutQuint); + break; + case EaseType.easeInSine: + ease = new EasingFunction(easeInSine); + break; + case EaseType.easeOutSine: + ease = new EasingFunction(easeOutSine); + break; + case EaseType.easeInOutSine: + ease = new EasingFunction(easeInOutSine); + break; + case EaseType.easeInExpo: + ease = new EasingFunction(easeInExpo); + break; + case EaseType.easeOutExpo: + ease = new EasingFunction(easeOutExpo); + break; + case EaseType.easeInOutExpo: + ease = new EasingFunction(easeInOutExpo); + break; + case EaseType.easeInCirc: + ease = new EasingFunction(easeInCirc); + break; + case EaseType.easeOutCirc: + ease = new EasingFunction(easeOutCirc); + break; + case EaseType.easeInOutCirc: + ease = new EasingFunction(easeInOutCirc); + break; + case EaseType.linear: + ease = new EasingFunction(linear); + break; + case EaseType.spring: + ease = new EasingFunction(spring); + break; + /* GFX47 MOD START */ + /*case EaseType.bounce: + ease = new EasingFunction(bounce); + break;*/ + case EaseType.easeInBounce: + ease = new EasingFunction(easeInBounce); + break; + case EaseType.easeOutBounce: + ease = new EasingFunction(easeOutBounce); + break; + case EaseType.easeInOutBounce: + ease = new EasingFunction(easeInOutBounce); + break; + /* GFX47 MOD END */ + case EaseType.easeInBack: + ease = new EasingFunction(easeInBack); + break; + case EaseType.easeOutBack: + ease = new EasingFunction(easeOutBack); + break; + case EaseType.easeInOutBack: + ease = new EasingFunction(easeInOutBack); + break; + /* GFX47 MOD START */ + /*case EaseType.elastic: + ease = new EasingFunction(elastic); + break;*/ + case EaseType.easeInElastic: + ease = new EasingFunction(easeInElastic); + break; + case EaseType.easeOutElastic: + ease = new EasingFunction(easeOutElastic); + break; + case EaseType.easeInOutElastic: + ease = new EasingFunction(easeInOutElastic); + break; + /* GFX47 MOD END */ + } + } + + //calculate percentage of tween based on time: + void UpdatePercentage(){ + + // Added by PressPlay + if (useRealTime) + { + runningTime += (Time.realtimeSinceStartup - lastRealTime); + } + else + { + runningTime += Time.deltaTime; + } + + if(reverse){ + percentage = 1 - runningTime/time; + }else{ + percentage = runningTime/time; + } + + lastRealTime = Time.realtimeSinceStartup; // Added by PressPlay + } + + void CallBack(string callbackType){ + if (tweenArguments.Contains(callbackType) && !tweenArguments.Contains("ischild")) { + //establish target: + GameObject target; + if (tweenArguments.Contains(callbackType+"target")) { + target=(GameObject)tweenArguments[callbackType+"target"]; + }else{ + target=gameObject; + } + + //throw an error if a string wasn't passed for callback: + if (tweenArguments[callbackType].GetType() == typeof(System.String)) { + target.SendMessage((string)tweenArguments[callbackType],(object)tweenArguments[callbackType+"params"],SendMessageOptions.DontRequireReceiver); + }else{ + Debug.LogError("iTween Error: Callback method references must be passed as a String!"); + Destroy (this); + } + } + } + + void Dispose(){ + for (int i = 0; i < tweens.Count; i++) { + Hashtable tweenEntry = (Hashtable)tweens[i]; + if ((string)tweenEntry["id"] == id){ + tweens.RemoveAt(i); + break; + } + } + Destroy(this); + } + + void ConflictCheck(){//if a new iTween is about to run and is of the same type as an in progress iTween this will destroy the previous if the new one is NOT identical in every way or it will destroy the new iTween if they are: + Component[] tweens = GetComponents(typeof(iTween)); + foreach (iTween item in tweens) { + if(item.type == "value"){ + return; + }else if(item.isRunning && item.type==type){ + //cancel out if this is a shake or punch variant: + if (item.method != method) { + return; + } + + //step 1: check for length first since it's the fastest: + if(item.tweenArguments.Count != tweenArguments.Count){ + item.Dispose(); + return; + } + + //step 2: side-by-side check to figure out if this is an identical tween scenario to handle Update usages of iTween: + foreach (DictionaryEntry currentProp in tweenArguments) { + if(!item.tweenArguments.Contains(currentProp.Key)){ + item.Dispose(); + return; + }else{ + if(!item.tweenArguments[currentProp.Key].Equals(tweenArguments[currentProp.Key]) && (string)currentProp.Key != "id"){//if we aren't comparing ids and something isn't exactly the same replace the running iTween: + item.Dispose(); + return; + } + } + } + + //step 3: prevent a new iTween addition if it is identical to the currently running iTween + Dispose(); + //Destroy(this); + } + } + } + + void EnableKinematic(){ + /* + if(gameObject.GetComponent(typeof(Rigidbody))){ + if(!rigidbody.isKinematic){ + kinematic=true; + rigidbody.isKinematic=true; + } + } + */ + } + + void DisableKinematic(){ + /* + if(kinematic && rigidbody.isKinematic==true){ + kinematic=false; + rigidbody.isKinematic=false; + } + */ + } + + void ResumeDelay(){ + StartCoroutine("TweenDelay"); + } + + #endregion + + #region Easing Curves + + private float linear(float start, float end, float value){ + return Mathf.Lerp(start, end, value); + } + + private float clerp(float start, float end, float value){ + float min = 0.0f; + float max = 360.0f; + float half = Mathf.Abs((max - min) / 2.0f); + float retval = 0.0f; + float diff = 0.0f; + if ((end - start) < -half){ + diff = ((max - start) + end) * value; + retval = start + diff; + }else if ((end - start) > half){ + diff = -((max - end) + start) * value; + retval = start + diff; + }else retval = start + (end - start) * value; + return retval; + } + + private float spring(float start, float end, float value){ + value = Mathf.Clamp01(value); + value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value))); + return start + (end - start) * value; + } + + private float easeInQuad(float start, float end, float value){ + end -= start; + return end * value * value + start; + } + + private float easeOutQuad(float start, float end, float value){ + end -= start; + return -end * value * (value - 2) + start; + } + + private float easeInOutQuad(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value + start; + value--; + return -end / 2 * (value * (value - 2) - 1) + start; + } + + private float easeInCubic(float start, float end, float value){ + end -= start; + return end * value * value * value + start; + } + + private float easeOutCubic(float start, float end, float value){ + value--; + end -= start; + return end * (value * value * value + 1) + start; + } + + private float easeInOutCubic(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value + start; + value -= 2; + return end / 2 * (value * value * value + 2) + start; + } + + private float easeInQuart(float start, float end, float value){ + end -= start; + return end * value * value * value * value + start; + } + + private float easeOutQuart(float start, float end, float value){ + value--; + end -= start; + return -end * (value * value * value * value - 1) + start; + } + + private float easeInOutQuart(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value * value + start; + value -= 2; + return -end / 2 * (value * value * value * value - 2) + start; + } + + private float easeInQuint(float start, float end, float value){ + end -= start; + return end * value * value * value * value * value + start; + } + + private float easeOutQuint(float start, float end, float value){ + value--; + end -= start; + return end * (value * value * value * value * value + 1) + start; + } + + private float easeInOutQuint(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * value * value * value * value * value + start; + value -= 2; + return end / 2 * (value * value * value * value * value + 2) + start; + } + + private float easeInSine(float start, float end, float value){ + end -= start; + return -end * Mathf.Cos(value / 1 * (Mathf.PI / 2)) + end + start; + } + + private float easeOutSine(float start, float end, float value){ + end -= start; + return end * Mathf.Sin(value / 1 * (Mathf.PI / 2)) + start; + } + + private float easeInOutSine(float start, float end, float value){ + end -= start; + return -end / 2 * (Mathf.Cos(Mathf.PI * value / 1) - 1) + start; + } + + private float easeInExpo(float start, float end, float value){ + end -= start; + return end * Mathf.Pow(2, 10 * (value / 1 - 1)) + start; + } + + private float easeOutExpo(float start, float end, float value){ + end -= start; + return end * (-Mathf.Pow(2, -10 * value / 1) + 1) + start; + } + + private float easeInOutExpo(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return end / 2 * Mathf.Pow(2, 10 * (value - 1)) + start; + value--; + return end / 2 * (-Mathf.Pow(2, -10 * value) + 2) + start; + } + + private float easeInCirc(float start, float end, float value){ + end -= start; + return -end * (Mathf.Sqrt(1 - value * value) - 1) + start; + } + + private float easeOutCirc(float start, float end, float value){ + value--; + end -= start; + return end * Mathf.Sqrt(1 - value * value) + start; + } + + private float easeInOutCirc(float start, float end, float value){ + value /= .5f; + end -= start; + if (value < 1) return -end / 2 * (Mathf.Sqrt(1 - value * value) - 1) + start; + value -= 2; + return end / 2 * (Mathf.Sqrt(1 - value * value) + 1) + start; + } + + /* GFX47 MOD START */ + private float easeInBounce(float start, float end, float value){ + end -= start; + float d = 1f; + return end - easeOutBounce(0, end, d-value) + start; + } + /* GFX47 MOD END */ + + /* GFX47 MOD START */ + //private float bounce(float start, float end, float value){ + private float easeOutBounce(float start, float end, float value){ + value /= 1f; + end -= start; + if (value < (1 / 2.75f)){ + return end * (7.5625f * value * value) + start; + }else if (value < (2 / 2.75f)){ + value -= (1.5f / 2.75f); + return end * (7.5625f * (value) * value + .75f) + start; + }else if (value < (2.5 / 2.75)){ + value -= (2.25f / 2.75f); + return end * (7.5625f * (value) * value + .9375f) + start; + }else{ + value -= (2.625f / 2.75f); + return end * (7.5625f * (value) * value + .984375f) + start; + } + } + /* GFX47 MOD END */ + + /* GFX47 MOD START */ + private float easeInOutBounce(float start, float end, float value){ + end -= start; + float d = 1f; + if (value < d/2) return easeInBounce(0, end, value*2) * 0.5f + start; + else return easeOutBounce(0, end, value*2-d) * 0.5f + end*0.5f + start; + } + /* GFX47 MOD END */ + + private float easeInBack(float start, float end, float value){ + end -= start; + value /= 1; + float s = 1.70158f; + return end * (value) * value * ((s + 1) * value - s) + start; + } + + private float easeOutBack(float start, float end, float value){ + float s = 1.70158f; + end -= start; + value = (value / 1) - 1; + return end * ((value) * value * ((s + 1) * value + s) + 1) + start; + } + + private float easeInOutBack(float start, float end, float value){ + float s = 1.70158f; + end -= start; + value /= .5f; + if ((value) < 1){ + s *= (1.525f); + return end / 2 * (value * value * (((s) + 1) * value - s)) + start; + } + value -= 2; + s *= (1.525f); + return end / 2 * ((value) * value * (((s) + 1) * value + s) + 2) + start; + } + + private float punch(float amplitude, float value){ + float s = 9; + if (value == 0){ + return 0; + } + if (value == 1){ + return 0; + } + float period = 1 * 0.3f; + s = period / (2 * Mathf.PI) * Mathf.Asin(0); + return (amplitude * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * 1 - s) * (2 * Mathf.PI) / period)); + } + + /* GFX47 MOD START */ + private float easeInElastic(float start, float end, float value){ + end -= start; + + float d = 1f; + float p = d * .3f; + float s = 0; + float a = 0; + + if (value == 0) return start; + + if ((value /= d) == 1) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4; + }else{ + s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); + } + + return -(a * Mathf.Pow(2, 10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start; + } + /* GFX47 MOD END */ + + /* GFX47 MOD START */ + //private float elastic(float start, float end, float value){ + private float easeOutElastic(float start, float end, float value){ + /* GFX47 MOD END */ + //Thank you to rafael.marteleto for fixing this as a port over from Pedro's UnityTween + end -= start; + + float d = 1f; + float p = d * .3f; + float s = 0; + float a = 0; + + if (value == 0) return start; + + if ((value /= d) == 1) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4; + }else{ + s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); + } + + return (a * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) + end + start); + } + + /* GFX47 MOD START */ + private float easeInOutElastic(float start, float end, float value){ + end -= start; + + float d = 1f; + float p = d * .3f; + float s = 0; + float a = 0; + + if (value == 0) return start; + + if ((value /= d/2) == 2) return start + end; + + if (a == 0f || a < Mathf.Abs(end)){ + a = end; + s = p / 4; + }else{ + s = p / (2 * Mathf.PI) * Mathf.Asin(end / a); + } + + if (value < 1) return -0.5f * (a * Mathf.Pow(2, 10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start; + return a * Mathf.Pow(2, -10 * (value-=1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) * 0.5f + end + start; + } + /* GFX47 MOD END */ + + #endregion + + #region Deprecated and Renamed + /* + public static void audioFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: audioFrom() has been renamed to AudioFrom().");} + public static void audioTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: audioTo() has been renamed to AudioTo().");} + public static void colorFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: colorFrom() has been renamed to ColorFrom().");} + public static void colorTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: colorTo() has been renamed to ColorTo().");} + public static void fadeFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: fadeFrom() has been renamed to FadeFrom().");} + public static void fadeTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: fadeTo() has been renamed to FadeTo().");} + public static void lookFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookFrom() has been renamed to LookFrom().");} + public static void lookFromWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookFromWorld() has been deprecated. Please investigate LookFrom().");} + public static void lookTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookTo() has been renamed to LookTo().");} + public static void lookToUpdate(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookToUpdate() has been renamed to LookUpdate().");} + public static void lookToUpdateWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: lookToUpdateWorld() has been deprecated. Please investigate LookUpdate().");} + public static void moveAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAdd() has been renamed to MoveAdd().");} + public static void moveAddWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAddWorld() has been deprecated. Please investigate MoveAdd().");} + public static void moveBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveBy() has been renamed to MoveBy().");} + public static void moveByWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveAddWorld() has been deprecated. Please investigate MoveAdd().");} + public static void moveFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveFrom() has been renamed to MoveFrom().");} + public static void moveFromWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveFromWorld() has been deprecated. Please investigate MoveFrom().");} + public static void moveTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveTo() has been renamed to MoveTo().");} + public static void moveToBezier(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToBezier() has been deprecated. Please investigate MoveTo() and the "path" property.");} + public static void moveToBezierWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToBezierWorld() has been deprecated. Please investigate MoveTo() and the "path" property.");} + public static void moveToUpdate(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToUpdate() has been renamed to MoveUpdate().");} + public static void moveToUpdateWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToUpdateWorld() has been deprecated. Please investigate MoveUpdate().");} + public static void moveToWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: moveToWorld() has been deprecated. Please investigate MoveTo().");} + public static void punchPosition(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPosition() has been renamed to PunchPosition().");} + public static void punchPositionWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPositionWorld() has been deprecated. Please investigate PunchPosition().");} + public static void punchRotation(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchPosition() has been renamed to PunchRotation().");} + public static void punchRotationWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchRotationWorld() has been deprecated. Please investigate PunchRotation().");} + public static void punchScale(GameObject target, Hashtable args){Debug.LogError("iTween Error: punchScale() has been renamed to PunchScale().");} + public static void rotateAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateAdd() has been renamed to RotateAdd().");} + public static void rotateBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateBy() has been renamed to RotateBy().");} + public static void rotateByWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateByWorld() has been deprecated. Please investigate RotateBy().");} + public static void rotateFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateFrom() has been renamed to RotateFrom().");} + public static void rotateTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: rotateTo() has been renamed to RotateTo().");} + public static void scaleAdd(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleAdd() has been renamed to ScaleAdd().");} + public static void scaleBy(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleBy() has been renamed to ScaleBy().");} + public static void scaleFrom(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleFrom() has been renamed to ScaleFrom().");} + public static void scaleTo(GameObject target, Hashtable args){Debug.LogError("iTween Error: scaleTo() has been renamed to ScaleTo().");} + public static void shake(GameObject target, Hashtable args){Debug.LogError("iTween Error: scale() has been deprecated. Please investigate ShakePosition(), ShakeRotation() and ShakeScale().");} + public static void shakeWorld(GameObject target, Hashtable args){Debug.LogError("iTween Error: shakeWorld() has been deprecated. Please investigate ShakePosition(), ShakeRotation() and ShakeScale().");} + public static void stab(GameObject target, Hashtable args){Debug.LogError("iTween Error: stab() has been renamed to Stab().");} + public static void stop(GameObject target, Hashtable args){Debug.LogError("iTween Error: stop() has been renamed to Stop().");} + public static void stopType(GameObject target, Hashtable args){Debug.LogError("iTween Error: stopType() has been deprecated. Please investigate Stop().");} + public static void tweenCount(GameObject target, Hashtable args){Debug.LogError("iTween Error: tweenCount() has been deprecated. Please investigate Count().");} + */ + #endregion +} +#endif \ No newline at end of file diff --git a/Assets/iTween/iTween.cs.meta b/Assets/iTween/iTween.cs.meta new file mode 100755 index 0000000..2240d75 --- /dev/null +++ b/Assets/iTween/iTween.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1a17fc48a1ff57c49a2ee2f073629321 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: