Chris Gregan
7 years ago
313 changed files with 44069 additions and 6243 deletions
Binary file not shown.
@ -1,22 +1,34 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f02b3fe0a866fca419671914a860554a |
||||
guid: 46975cd389724d0499db55591d961a35 |
||||
timeCreated: 1499691956 |
||||
licenseType: Store |
||||
PluginImporter: |
||||
serializedVersion: 1 |
||||
serializedVersion: 2 |
||||
iconMap: {} |
||||
executionOrder: {} |
||||
isPreloaded: 0 |
||||
isOverridable: 0 |
||||
platformData: |
||||
Any: |
||||
enabled: 0 |
||||
settings: {} |
||||
Editor: |
||||
enabled: 1 |
||||
settings: |
||||
DefaultValueInitialized: true |
||||
WindowsStoreApps: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
data: |
||||
first: |
||||
Any: |
||||
second: |
||||
enabled: 0 |
||||
settings: {} |
||||
data: |
||||
first: |
||||
Editor: Editor |
||||
second: |
||||
enabled: 1 |
||||
settings: |
||||
DefaultValueInitialized: true |
||||
data: |
||||
first: |
||||
Windows Store Apps: WindowsStoreApps |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
||||
|
Binary file not shown.
@ -1,22 +1,34 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 07e97bd03b7bdeb40bbc176326cd8d7a |
||||
guid: a4f7ad432f1fed24caa2acbe1ceeef39 |
||||
timeCreated: 1499692003 |
||||
licenseType: Store |
||||
PluginImporter: |
||||
serializedVersion: 1 |
||||
serializedVersion: 2 |
||||
iconMap: {} |
||||
executionOrder: {} |
||||
isPreloaded: 0 |
||||
isOverridable: 0 |
||||
platformData: |
||||
Any: |
||||
enabled: 0 |
||||
settings: {} |
||||
Editor: |
||||
enabled: 1 |
||||
settings: |
||||
DefaultValueInitialized: true |
||||
WindowsStoreApps: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
data: |
||||
first: |
||||
Any: |
||||
second: |
||||
enabled: 0 |
||||
settings: {} |
||||
data: |
||||
first: |
||||
Editor: Editor |
||||
second: |
||||
enabled: 1 |
||||
settings: |
||||
DefaultValueInitialized: true |
||||
data: |
||||
first: |
||||
Windows Store Apps: WindowsStoreApps |
||||
second: |
||||
enabled: 0 |
||||
settings: |
||||
CPU: AnyCPU |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
||||
|
@ -1,8 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 29cae11326cb84802b83fc3ff25a47e8 |
||||
timeCreated: 1478978272 |
||||
timeCreated: 1495441032 |
||||
licenseType: Free |
||||
NativeFormatImporter: |
||||
mainObjectFileID: 11400000 |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
||||
|
After Width: | Height: | Size: 5.0 KiB |
@ -0,0 +1,92 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 6368c1c16ebb1694091262337e4f8c44 |
||||
timeCreated: 1500456217 |
||||
licenseType: Free |
||||
TextureImporter: |
||||
fileIDToRecycleName: {} |
||||
serializedVersion: 4 |
||||
mipmaps: |
||||
mipMapMode: 0 |
||||
enableMipMap: 0 |
||||
sRGBTexture: 0 |
||||
linearTexture: 0 |
||||
fadeOut: 0 |
||||
borderMipMap: 0 |
||||
mipMapFadeDistanceStart: 1 |
||||
mipMapFadeDistanceEnd: 3 |
||||
bumpmap: |
||||
convertToNormalMap: 0 |
||||
externalNormalMap: 0 |
||||
heightScale: 0.25 |
||||
normalMapFilter: 0 |
||||
isReadable: 0 |
||||
grayScaleToAlpha: 0 |
||||
generateCubemap: 6 |
||||
cubemapConvolution: 0 |
||||
seamlessCubemap: 0 |
||||
textureFormat: 1 |
||||
maxTextureSize: 2048 |
||||
textureSettings: |
||||
filterMode: 1 |
||||
aniso: -1 |
||||
mipBias: -1 |
||||
wrapMode: 1 |
||||
nPOTScale: 0 |
||||
lightmap: 0 |
||||
compressionQuality: 50 |
||||
spriteMode: 1 |
||||
spriteExtrude: 1 |
||||
spriteMeshType: 1 |
||||
alignment: 0 |
||||
spritePivot: {x: 0.5, y: 0.5} |
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
||||
spritePixelsToUnits: 100 |
||||
alphaUsage: 1 |
||||
alphaIsTransparency: 1 |
||||
spriteTessellationDetail: -1 |
||||
textureType: 2 |
||||
textureShape: 1 |
||||
maxTextureSizeSet: 0 |
||||
compressionQualitySet: 0 |
||||
textureFormatSet: 0 |
||||
platformSettings: |
||||
- buildTarget: DefaultTexturePlatform |
||||
maxTextureSize: 1024 |
||||
textureFormat: -1 |
||||
textureCompression: 0 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
- buildTarget: Standalone |
||||
maxTextureSize: 1024 |
||||
textureFormat: -1 |
||||
textureCompression: 0 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
- buildTarget: Android |
||||
maxTextureSize: 1024 |
||||
textureFormat: -1 |
||||
textureCompression: 0 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
- buildTarget: WebGL |
||||
maxTextureSize: 1024 |
||||
textureFormat: -1 |
||||
textureCompression: 0 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
spriteSheet: |
||||
serializedVersion: 2 |
||||
sprites: [] |
||||
outline: [] |
||||
spritePackingTag: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
After Width: | Height: | Size: 5.0 KiB |
@ -0,0 +1,92 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 1c99c9bf7557e23469ed5dfce00504c0 |
||||
timeCreated: 1500455974 |
||||
licenseType: Free |
||||
TextureImporter: |
||||
fileIDToRecycleName: {} |
||||
serializedVersion: 4 |
||||
mipmaps: |
||||
mipMapMode: 0 |
||||
enableMipMap: 0 |
||||
sRGBTexture: 0 |
||||
linearTexture: 0 |
||||
fadeOut: 0 |
||||
borderMipMap: 0 |
||||
mipMapFadeDistanceStart: 1 |
||||
mipMapFadeDistanceEnd: 3 |
||||
bumpmap: |
||||
convertToNormalMap: 0 |
||||
externalNormalMap: 0 |
||||
heightScale: 0.25 |
||||
normalMapFilter: 0 |
||||
isReadable: 0 |
||||
grayScaleToAlpha: 0 |
||||
generateCubemap: 6 |
||||
cubemapConvolution: 0 |
||||
seamlessCubemap: 0 |
||||
textureFormat: 1 |
||||
maxTextureSize: 2048 |
||||
textureSettings: |
||||
filterMode: 1 |
||||
aniso: -1 |
||||
mipBias: -1 |
||||
wrapMode: 1 |
||||
nPOTScale: 0 |
||||
lightmap: 0 |
||||
compressionQuality: 50 |
||||
spriteMode: 1 |
||||
spriteExtrude: 1 |
||||
spriteMeshType: 1 |
||||
alignment: 0 |
||||
spritePivot: {x: 0.5, y: 0.5} |
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
||||
spritePixelsToUnits: 100 |
||||
alphaUsage: 1 |
||||
alphaIsTransparency: 1 |
||||
spriteTessellationDetail: -1 |
||||
textureType: 2 |
||||
textureShape: 1 |
||||
maxTextureSizeSet: 0 |
||||
compressionQualitySet: 0 |
||||
textureFormatSet: 0 |
||||
platformSettings: |
||||
- buildTarget: DefaultTexturePlatform |
||||
maxTextureSize: 1024 |
||||
textureFormat: -1 |
||||
textureCompression: 0 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
- buildTarget: Standalone |
||||
maxTextureSize: 1024 |
||||
textureFormat: -1 |
||||
textureCompression: 0 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
- buildTarget: Android |
||||
maxTextureSize: 1024 |
||||
textureFormat: -1 |
||||
textureCompression: 0 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
- buildTarget: WebGL |
||||
maxTextureSize: 1024 |
||||
textureFormat: -1 |
||||
textureCompression: 0 |
||||
compressionQuality: 50 |
||||
crunchedCompression: 0 |
||||
allowsAlphaSplitting: 0 |
||||
overridden: 0 |
||||
spriteSheet: |
||||
serializedVersion: 2 |
||||
sprites: [] |
||||
outline: [] |
||||
spritePackingTag: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f24b15e84ed1f42e39fd80dd9042c882 |
||||
folderAsset: yes |
||||
timeCreated: 1489513669 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 81dbcde0f90df4e9ba9ca2794490e57a |
||||
timeCreated: 1491251885 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 1cd4689522982464db8b5de6a590db9b |
||||
timeCreated: 1491251886 |
||||
licenseType: Free |
||||
TextScriptImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 90098f8abed37d1418f36896e7e1279d |
||||
folderAsset: yes |
||||
timeCreated: 1503744400 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,60 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
// <summary> |
||||
/// Store Input.GetAxis in a variable |
||||
/// </summary> |
||||
[CommandInfo("Input", |
||||
"GetAxis", |
||||
"Store Input.GetAxis in a variable")] |
||||
[AddComponentMenu("")] |
||||
public class GetAxis : Command |
||||
{ |
||||
[SerializeField] |
||||
protected StringData axisName; |
||||
|
||||
[Tooltip("If true, calls GetAxisRaw instead of GetAxis")] |
||||
[SerializeField] |
||||
protected bool axisRaw = false; |
||||
|
||||
[Tooltip("Float to store the value of the GetAxis")] |
||||
[SerializeField] |
||||
protected FloatData outValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
if (axisRaw) |
||||
{ |
||||
outValue.Value = Input.GetAxisRaw(axisName.Value); |
||||
} |
||||
else |
||||
{ |
||||
outValue.Value = Input.GetAxis(axisName.Value); |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return axisName + (axisRaw ? " Raw" : ""); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
public override bool HasReference(Variable variable) |
||||
{ |
||||
if (axisName.stringRef == variable || outValue.floatRef == variable) |
||||
return true; |
||||
|
||||
return false; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: bb18ee740f55ba24680c15466ff13ece |
||||
timeCreated: 1503744409 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 53bec3476dd0fa945af5703dda0cd24f |
||||
folderAsset: yes |
||||
timeCreated: 1501401094 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,116 @@
|
||||
using UnityEngine; |
||||
using UnityEngine.Serialization; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Abstract base class for LeanTween commands. |
||||
/// </summary> |
||||
[ExecuteInEditMode] |
||||
public abstract class BaseLeanTweenCommand : Command |
||||
{ |
||||
[Tooltip("Target game object to apply the Tween to")] |
||||
[SerializeField] |
||||
protected GameObjectData _targetObject; |
||||
|
||||
[Tooltip("The time in seconds the animation will take to complete")] |
||||
[SerializeField] |
||||
protected FloatData _duration = new FloatData(1f); |
||||
|
||||
public enum ToFrom { To, From } |
||||
[Tooltip("Does the tween act from current TO destination or is it reversed and act FROM destination to its current")] |
||||
[SerializeField] |
||||
protected ToFrom _toFrom; |
||||
public bool IsInFromMode { get { return _toFrom == ToFrom.From; } } |
||||
|
||||
public enum AbsAdd { Absolute, Additive } |
||||
[Tooltip("Does the tween use the value as a target or as a delta to be added to current.")] |
||||
[SerializeField] |
||||
protected AbsAdd _absAdd; |
||||
public bool IsInAddativeMode { get { return _absAdd == AbsAdd.Additive; } } |
||||
|
||||
|
||||
[Tooltip("The shape of the easing curve applied to the animation")] |
||||
[SerializeField] |
||||
protected LeanTweenType easeType = LeanTweenType.easeInOutQuad; |
||||
|
||||
[Tooltip("The type of loop to apply once the animation has completed")] |
||||
[SerializeField] |
||||
protected LeanTweenType loopType = LeanTweenType.once; |
||||
|
||||
[Tooltip("Number of times to repeat the tween, -1 is infinite.")] |
||||
[SerializeField] |
||||
protected int repeats = 0; |
||||
|
||||
[Tooltip("Stop any previously LeanTweens on this object before adding this one. Warning; expensive.")] |
||||
[SerializeField] |
||||
protected bool stopPreviousTweens = false; |
||||
|
||||
[Tooltip("Wait until the tween has finished before executing the next command")] |
||||
[SerializeField] |
||||
protected bool waitUntilFinished = true; |
||||
|
||||
|
||||
[HideInInspector] protected LTDescr ourTween; |
||||
|
||||
|
||||
protected virtual void OnTweenComplete() |
||||
{ |
||||
Continue(); |
||||
} |
||||
|
||||
#region Public members |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
if (_targetObject.Value == null) |
||||
{ |
||||
Continue(); |
||||
return; |
||||
} |
||||
|
||||
if (stopPreviousTweens) |
||||
{ |
||||
LeanTween.cancel(_targetObject.Value); |
||||
} |
||||
|
||||
ourTween = ExecuteTween(); |
||||
|
||||
ourTween.setEase(easeType) |
||||
.setRepeat(repeats) |
||||
.setLoopType(loopType); |
||||
|
||||
if (waitUntilFinished) |
||||
{ |
||||
if(ourTween != null) |
||||
{ |
||||
ourTween.setOnComplete(OnTweenComplete); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
Continue(); |
||||
} |
||||
} |
||||
|
||||
public abstract LTDescr ExecuteTween(); |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
if (_targetObject.Value == null) |
||||
{ |
||||
return "Error: No target object selected"; |
||||
} |
||||
|
||||
return _targetObject.Value.name + " over " + _duration.Value + " seconds"; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(233, 163, 180, 255); |
||||
} |
||||
|
||||
#endregion |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 22379d19093ceb34098232d6f1b848a0 |
||||
timeCreated: 1499564933 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,55 @@
|
||||
|
||||
using UnityEngine; |
||||
using UnityEngine.Serialization; |
||||
using System.Collections; |
||||
using System; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Moves a game object to a specified position over time. The position can be defined by a transform in another object (using To Transform) or by setting an absolute position (using To Position, if To Transform is set to None). |
||||
/// </summary> |
||||
[CommandInfo("LeanTween", |
||||
"Move", |
||||
"Moves a game object to a specified position over time. The position can be defined by a transform in another object (using To Transform) or by setting an absolute position (using To Position, if To Transform is set to None).")] |
||||
[AddComponentMenu("")] |
||||
[ExecuteInEditMode] |
||||
public class MoveLean : BaseLeanTweenCommand |
||||
{ |
||||
[Tooltip("Target transform that the GameObject will move to")] |
||||
[SerializeField] |
||||
protected TransformData _toTransform; |
||||
|
||||
[Tooltip("Target world position that the GameObject will move to, if no From Transform is set")] |
||||
[SerializeField] |
||||
protected Vector3Data _toPosition; |
||||
|
||||
[Tooltip("Whether to animate in world space or relative to the parent. False by default.")] |
||||
[SerializeField] |
||||
protected bool isLocal; |
||||
|
||||
|
||||
public override LTDescr ExecuteTween() |
||||
{ |
||||
var loc = _toTransform.Value == null ? _toPosition.Value : _toTransform.Value.position; |
||||
|
||||
if(IsInAddativeMode) |
||||
{ |
||||
loc += _targetObject.Value.transform.position; |
||||
} |
||||
|
||||
if(IsInFromMode) |
||||
{ |
||||
var cur = _targetObject.Value.transform.position; |
||||
_targetObject.Value.transform.position = loc; |
||||
loc = cur; |
||||
} |
||||
|
||||
if (isLocal) |
||||
return LeanTween.moveLocal(_targetObject.Value, loc, _duration); |
||||
else |
||||
return LeanTween.move(_targetObject.Value, loc, _duration); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 3ca31fffe1be42a49b96bbb8b7ff5a50 |
||||
timeCreated: 1499566229 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,74 @@
|
||||
|
||||
using UnityEngine; |
||||
using UnityEngine.Serialization; |
||||
using System.Collections; |
||||
using System; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Rotates a game object to the specified angles over time. |
||||
/// </summary> |
||||
[CommandInfo("LeanTween", |
||||
"Rotate", |
||||
"Rotates a game object to the specified angles over time.")] |
||||
[AddComponentMenu("")] |
||||
[ExecuteInEditMode] |
||||
public class RotateLean : BaseLeanTweenCommand |
||||
{ |
||||
[Tooltip("Target transform that the GameObject will rotate to")] |
||||
[SerializeField] |
||||
protected TransformData _toTransform; |
||||
|
||||
[Tooltip("Target rotation that the GameObject will rotate to, if no To Transform is set")] |
||||
[SerializeField] |
||||
protected Vector3Data _toRotation; |
||||
|
||||
[Tooltip("Whether to animate in world space or relative to the parent. False by default.")] |
||||
[SerializeField] |
||||
protected bool isLocal; |
||||
|
||||
public enum RotateMode { PureRotate, LookAt2D, LookAt3D} |
||||
[Tooltip("Whether to use the provided Transform or Vector as a target to look at rather than a euler to match.")] |
||||
[SerializeField] |
||||
protected RotateMode rotateMode = RotateMode.PureRotate; |
||||
|
||||
|
||||
public override LTDescr ExecuteTween() |
||||
{ |
||||
var rot = _toTransform.Value == null ? _toRotation.Value : _toTransform.Value.rotation.eulerAngles; |
||||
|
||||
if(rotateMode == RotateMode.LookAt3D) |
||||
{ |
||||
var pos = _toTransform.Value == null ? _toRotation.Value : _toTransform.Value.position; |
||||
var dif = pos - _targetObject.Value.transform.position; |
||||
rot = Quaternion.LookRotation(dif.normalized).eulerAngles; |
||||
} |
||||
else if(rotateMode == RotateMode.LookAt2D) |
||||
{ |
||||
var pos = _toTransform.Value == null ? _toRotation.Value : _toTransform.Value.position; |
||||
var dif = pos - _targetObject.Value.transform.position; |
||||
dif.z = 0; |
||||
|
||||
rot = Quaternion.FromToRotation(_targetObject.Value.transform.up, dif.normalized).eulerAngles; |
||||
} |
||||
|
||||
if (IsInAddativeMode) |
||||
{ |
||||
rot += _targetObject.Value.transform.rotation.eulerAngles; |
||||
} |
||||
|
||||
if (IsInFromMode) |
||||
{ |
||||
var cur = _targetObject.Value.transform.rotation.eulerAngles; |
||||
_targetObject.Value.transform.rotation = Quaternion.Euler(rot); |
||||
rot = cur; |
||||
} |
||||
|
||||
if (isLocal) |
||||
return LeanTween.rotateLocal(_targetObject.Value, rot, _duration); |
||||
else |
||||
return LeanTween.rotate(_targetObject.Value, rot, _duration); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: b8feaa22bae049c43a1c6dfe095c498c |
||||
timeCreated: 1499583595 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,46 @@
|
||||
|
||||
using UnityEngine; |
||||
using UnityEngine.Serialization; |
||||
using System.Collections; |
||||
using System; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Changes a game object's scale to a specified value over time. |
||||
/// </summary> |
||||
[CommandInfo("LeanTween", |
||||
"Scale", |
||||
"Changes a game object's scale to a specified value over time.")] |
||||
[AddComponentMenu("")] |
||||
[ExecuteInEditMode] |
||||
public class ScaleLean : BaseLeanTweenCommand |
||||
{ |
||||
[Tooltip("Target transform that the GameObject will scale to")] |
||||
[SerializeField] |
||||
protected TransformData _toTransform; |
||||
|
||||
[Tooltip("Target scale that the GameObject will scale to, if no To Transform is set")] |
||||
[SerializeField] |
||||
protected Vector3Data _toScale = new Vector3Data(Vector3.one); |
||||
|
||||
public override LTDescr ExecuteTween() |
||||
{ |
||||
var sc = _toTransform.Value == null ? _toScale.Value : _toTransform.Value.localScale; |
||||
|
||||
if (IsInAddativeMode) |
||||
{ |
||||
sc += _targetObject.Value.transform.localScale; |
||||
} |
||||
|
||||
if (IsInFromMode) |
||||
{ |
||||
var cur = _targetObject.Value.transform.localScale; |
||||
_targetObject.Value.transform.localScale = sc; |
||||
sc = cur; |
||||
} |
||||
|
||||
return LeanTween.scale(_targetObject.Value, sc, _duration); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 30cbb61ab588b1a4093d2ef0254045b0 |
||||
timeCreated: 1499585056 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,47 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// |
||||
/// </summary> |
||||
[CommandInfo("LeanTween", |
||||
"StopTweens", |
||||
"Stops the LeanTweens on a target GameObject")] |
||||
[AddComponentMenu("")] |
||||
[ExecuteInEditMode] |
||||
public class StopTweensLean : Command |
||||
{ |
||||
[Tooltip("Target game object stop LeanTweens on")] |
||||
[SerializeField] |
||||
protected GameObjectData _targetObject; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
if (_targetObject.Value != null) |
||||
{ |
||||
LeanTween.cancel(_targetObject.Value); |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
if (_targetObject.Value == null) |
||||
{ |
||||
return "Error: No target object selected"; |
||||
} |
||||
|
||||
return "Stop all LeanTweens on " + _targetObject.Value.name; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(233, 163, 180, 255); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: d998218fa600bac43adbc431e9dd6c0c |
||||
timeCreated: 1499761355 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,126 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
using Fungus; |
||||
using MoonSharp.Interpreter; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
public class LuaCondition : Condition |
||||
{ |
||||
[Tooltip("Lua Environment to use to execute this Lua script (null for global)")] |
||||
[SerializeField] protected LuaEnvironment luaEnvironment; |
||||
|
||||
[Tooltip("The lua comparison string to run; implicitly prepends 'return' onto this")] |
||||
[TextArea] |
||||
public string luaCompareString; |
||||
protected bool initialised; |
||||
protected string friendlyName = ""; |
||||
protected Closure luaFunction; |
||||
|
||||
protected override bool EvaluateCondition() |
||||
{ |
||||
bool condition = false; |
||||
luaEnvironment.RunLuaFunction(luaFunction, false, (returnValue) => { |
||||
if( returnValue != null ) |
||||
{ |
||||
condition = returnValue.Boolean; |
||||
} |
||||
else |
||||
{ |
||||
Debug.LogWarning("No return value from " + friendlyName); |
||||
} |
||||
}); |
||||
return condition; |
||||
} |
||||
|
||||
protected override bool HasNeededProperties() |
||||
{ |
||||
return !string.IsNullOrEmpty(luaCompareString); |
||||
} |
||||
|
||||
protected virtual void Start() |
||||
{ |
||||
InitExecuteLua(); |
||||
} |
||||
|
||||
protected virtual string GetLuaString() |
||||
{ |
||||
return "return not not (" + luaCompareString + ")"; |
||||
} |
||||
|
||||
/// <summary> |
||||
/// Initialises the Lua environment and compiles the Lua string for execution later on. |
||||
/// </summary> |
||||
protected virtual void InitExecuteLua() |
||||
{ |
||||
if (initialised) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
// Cache a descriptive name to use in Lua error messages |
||||
friendlyName = gameObject.name + "." + ParentBlock.BlockName + "." + this.GetType().ToString() + " #" + CommandIndex.ToString(); |
||||
|
||||
Flowchart flowchart = GetFlowchart(); |
||||
|
||||
// See if a Lua Environment has been assigned to this Flowchart |
||||
if (luaEnvironment == null) |
||||
{ |
||||
luaEnvironment = flowchart.LuaEnv; |
||||
} |
||||
|
||||
// No Lua Environment specified so just use any available or create one. |
||||
if (luaEnvironment == null) |
||||
{ |
||||
luaEnvironment = LuaEnvironment.GetLua(); |
||||
} |
||||
|
||||
string s = GetLuaString(); |
||||
luaFunction = luaEnvironment.LoadLuaFunction(s, friendlyName); |
||||
|
||||
// Add a binding to the parent flowchart |
||||
if (flowchart.LuaBindingName != "") |
||||
{ |
||||
Table globals = luaEnvironment.Interpreter.Globals; |
||||
if (globals != null) |
||||
{ |
||||
globals[flowchart.LuaBindingName] = flowchart; |
||||
} |
||||
} |
||||
|
||||
// Always initialise when playing in the editor. |
||||
// Allows the user to edit the Lua script while the game is playing. |
||||
if ( !(Application.isPlaying && Application.isEditor) ) |
||||
{ |
||||
initialised = true; |
||||
} |
||||
|
||||
} |
||||
|
||||
#region Public members |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
if (string.IsNullOrEmpty(luaCompareString)) |
||||
{ |
||||
return "Error: no lua compare string provided"; |
||||
} |
||||
|
||||
return luaCompareString; |
||||
} |
||||
|
||||
|
||||
public override bool OpenBlock() |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(253, 253, 150, 255); |
||||
} |
||||
|
||||
#endregion |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 75ddfadd68d3d4713803a6b170cb0b51 |
||||
timeCreated: 1493078204 |
||||
licenseType: Pro |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,38 @@
|
||||
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). |
||||
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) |
||||
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true. |
||||
/// </summary> |
||||
[CommandInfo("Flow", |
||||
"Lua Else If", |
||||
"Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true.")] |
||||
[AddComponentMenu("")] |
||||
public class LuaElseIf : LuaCondition |
||||
{ |
||||
protected override bool IsElseIf { get { return true; } } |
||||
|
||||
#region Public members |
||||
|
||||
public override bool OpenBlock() |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public override bool CloseBlock() |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(253, 253, 150, 255); |
||||
} |
||||
|
||||
#endregion |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 9739de3269e5246b399e3a1cd41b94de |
||||
timeCreated: 1493078204 |
||||
licenseType: Pro |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,26 @@
|
||||
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). |
||||
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) |
||||
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// If the test expression is true, execute the following command block. |
||||
/// </summary> |
||||
[CommandInfo("Flow", |
||||
"Lua If", |
||||
"If the test expression is true, execute the following command block.")] |
||||
[AddComponentMenu("")] |
||||
public class LuaIf : LuaCondition |
||||
{ |
||||
#region Public members |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(253, 253, 150, 255); |
||||
} |
||||
|
||||
#endregion |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: a8d396bcbf372485cad471c0bb64bb44 |
||||
timeCreated: 1493078204 |
||||
licenseType: Pro |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 09c52cfe3a6ff4747a9c207bec24ba11 |
||||
folderAsset: yes |
||||
timeCreated: 1503202781 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,26 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to execute and store the result of a Abs |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Abs", |
||||
"Command to execute and store the result of a Abs")] |
||||
[AddComponentMenu("")] |
||||
public class Abs : BaseUnaryMathCommand |
||||
{ |
||||
public override void OnEnter() |
||||
{ |
||||
outValue.Value = Mathf.Abs(inValue.Value); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Abs"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 6d11e978db36df445816ec2535d381ce |
||||
timeCreated: 1501211592 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,25 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Base class for all simple Unary |
||||
/// </summary> |
||||
[AddComponentMenu("")] |
||||
public abstract class BaseUnaryMathCommand : Command |
||||
{ |
||||
[Tooltip("Value to be passed in to the function.")] |
||||
[SerializeField] |
||||
protected FloatData inValue; |
||||
|
||||
[Tooltip("Where the result of the function is stored.")] |
||||
[SerializeField] |
||||
protected FloatData outValue; |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 513a02811ba512d4ab54d157a15ae8c2 |
||||
timeCreated: 1501211592 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,66 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to contain a value between a lower and upper bound, with optional wrapping modes |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Clamp", |
||||
"Command to contain a value between a lower and upper bound, with optional wrapping modes")] |
||||
[AddComponentMenu("")] |
||||
public class Clamp : Command |
||||
{ |
||||
public enum Mode |
||||
{ |
||||
Clamp, |
||||
Repeat, |
||||
PingPong |
||||
} |
||||
|
||||
[SerializeField] |
||||
protected Mode mode = Mode.Clamp; |
||||
|
||||
//[Tooltip("LHS Value ")] |
||||
[SerializeField] |
||||
protected FloatData lower, upper, value; |
||||
|
||||
[Tooltip("Result put here, if using pingpong don't use the same var for value as outValue.")] |
||||
[SerializeField] |
||||
protected FloatData outValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
var l = lower.Value; |
||||
var u = upper.Value; |
||||
var v = value.Value; |
||||
|
||||
switch (mode) |
||||
{ |
||||
case Mode.Clamp: |
||||
outValue.Value = Mathf.Clamp(value.Value, lower.Value, upper.Value); |
||||
break; |
||||
case Mode.Repeat: |
||||
outValue.Value = (Mathf.Repeat(v - l, u - l)) + l; |
||||
break; |
||||
case Mode.PingPong: |
||||
outValue.Value = (Mathf.PingPong(v - l, u - l)) + l; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return Mode.Clamp.ToString() + (mode != Mode.Clamp ? " & " + mode.ToString() : ""); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 2929f1e90a24b6446a70d27316cff20a |
||||
timeCreated: 1501225403 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,29 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Pass a value through an AnimationCurve |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Curve", |
||||
"Pass a value through an AnimationCurve")] |
||||
[AddComponentMenu("")] |
||||
public class Curve : BaseUnaryMathCommand |
||||
{ |
||||
[SerializeField] |
||||
protected AnimationCurve curve = AnimationCurve.Linear(0, 0, 1, 1); |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
outValue.Value = curve.Evaluate(inValue.Value); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Curve"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: c03f48fc50d3747478ad85653a21a5f5 |
||||
timeCreated: 1501226831 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,26 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to execute and store the result of a Exp |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Exp", |
||||
"Command to execute and store the result of a Exp")] |
||||
[AddComponentMenu("")] |
||||
public class Exp : BaseUnaryMathCommand |
||||
{ |
||||
public override void OnEnter() |
||||
{ |
||||
outValue.Value = Mathf.Exp(inValue.Value); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Exp"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f28df8ed8a80fa345b3b5e3dcacdea65 |
||||
timeCreated: 1501211938 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,28 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Multiplicative Inverse of a float (1/f) |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Inverse", |
||||
"Multiplicative Inverse of a float (1/f)")] |
||||
[AddComponentMenu("")] |
||||
public class Inv : BaseUnaryMathCommand |
||||
{ |
||||
public override void OnEnter() |
||||
{ |
||||
var v = inValue.Value; |
||||
|
||||
outValue.Value = v != 0 ? (1.0f / inValue.Value) : 0.0f; |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Inverse 1/f"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 36d3a877e83b1d1478f1ac099414d17a |
||||
timeCreated: 1501213679 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,46 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Calculates the inverse lerp, the percentage a value is between two others. |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"InvLerp", |
||||
"Calculates the inverse lerp, the percentage a value is between two others.")] |
||||
[AddComponentMenu("")] |
||||
public class InvLerp : Command |
||||
{ |
||||
[Tooltip("Clamp percentage to 0-1?")] |
||||
[SerializeField] |
||||
protected bool clampResult = true; |
||||
|
||||
//[Tooltip("LHS Value ")] |
||||
[SerializeField] |
||||
protected FloatData a, b, value; |
||||
|
||||
//[Tooltip("Where the result of the function is stored.")] |
||||
[SerializeField] |
||||
protected FloatData outValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
if (clampResult) |
||||
outValue.Value = Mathf.InverseLerp(a.Value, b.Value, value.Value); |
||||
else |
||||
outValue.Value = (value.Value - a.Value) / (b.Value - a.Value); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "InvLerp [" + a.Value.ToString() + "-" + b.Value.ToString() + "]"; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 80c88869f66a81f4b95e843c36724e65 |
||||
timeCreated: 1501213063 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,63 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Linearly Interpolate from A to B |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Lerp", |
||||
"Linearly Interpolate from A to B")] |
||||
[AddComponentMenu("")] |
||||
public class Lerp : Command |
||||
{ |
||||
public enum Mode |
||||
{ |
||||
Lerp, |
||||
LerpUnclamped, |
||||
LerpAngle |
||||
} |
||||
|
||||
[SerializeField] |
||||
protected Mode mode = Mode.Lerp; |
||||
|
||||
//[Tooltip("LHS Value ")] |
||||
[SerializeField] |
||||
protected FloatData a = new FloatData(0), b = new FloatData(1), percentage; |
||||
|
||||
//[Tooltip("Where the result of the function is stored.")] |
||||
[SerializeField] |
||||
protected FloatData outValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
switch (mode) |
||||
{ |
||||
case Mode.Lerp: |
||||
outValue.Value = Mathf.Lerp(a.Value, b.Value, percentage.Value); |
||||
break; |
||||
case Mode.LerpUnclamped: |
||||
outValue.Value = Mathf.LerpUnclamped(a.Value, b.Value, percentage.Value); |
||||
break; |
||||
case Mode.LerpAngle: |
||||
outValue.Value = Mathf.LerpAngle(a.Value, b.Value, percentage.Value); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return mode.ToString() + " [" + a.Value.ToString() + "-" + b.Value.ToString() + "]"; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: b44d8d3a71d3e7b45a89437c8f84e687 |
||||
timeCreated: 1501212773 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,56 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to execute and store the result of a Log |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Log", |
||||
"Command to execute and store the result of a Log")] |
||||
[AddComponentMenu("")] |
||||
public class Log : BaseUnaryMathCommand |
||||
{ |
||||
public enum Mode |
||||
{ |
||||
Base10, |
||||
Natural |
||||
} |
||||
|
||||
[Tooltip("Which log to use, natural or base 10")] |
||||
[SerializeField] |
||||
protected Mode mode = Mode.Natural; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
switch (mode) |
||||
{ |
||||
case Mode.Base10: |
||||
outValue.Value = Mathf.Log10(inValue.Value); |
||||
break; |
||||
case Mode.Natural: |
||||
outValue.Value = Mathf.Log(inValue.Value); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
switch (mode) |
||||
{ |
||||
case Mode.Base10: |
||||
return "Log Base 10"; |
||||
case Mode.Natural: |
||||
return "Natural Log"; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
return "Log"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 47ecda391b679d8449893d4466f41b13 |
||||
timeCreated: 1501211938 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,48 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Map a value that exists in 1 range of numbers to another. |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Map", |
||||
"Map a value that exists in 1 range of numbers to another.")] |
||||
[AddComponentMenu("")] |
||||
public class Map : Command |
||||
{ |
||||
//[Tooltip("LHS Value ")] |
||||
[SerializeField] |
||||
protected FloatData initialRangeLower = new FloatData(0), initialRangeUpper = new FloatData(1), value; |
||||
|
||||
[SerializeField] |
||||
protected FloatData newRangeLower = new FloatData(0), newRangeUpper = new FloatData(1); |
||||
|
||||
[SerializeField] |
||||
protected FloatData outValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
var p = value.Value - initialRangeLower.Value; |
||||
p /= initialRangeUpper.Value - initialRangeLower.Value; |
||||
|
||||
var res = p * (newRangeUpper.Value - newRangeLower.Value); |
||||
res += newRangeLower.Value; |
||||
|
||||
outValue.Value = res; |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Map [" + initialRangeLower.Value.ToString() + "-" + initialRangeUpper.Value.ToString() + "] to [" + |
||||
newRangeLower.Value.ToString() + "-" + newRangeUpper.Value.ToString() + "]"; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 78d80bb5401d8044eb9eee0d4eb0b645 |
||||
timeCreated: 1501226122 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,61 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to store the min or max of 2 values |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"MinMax", |
||||
"Command to store the min or max of 2 values")] |
||||
[AddComponentMenu("")] |
||||
public class MinMax : Command |
||||
{ |
||||
public enum Function |
||||
{ |
||||
Min, |
||||
Max |
||||
} |
||||
|
||||
[Tooltip("Min Or Max")] |
||||
[SerializeField] |
||||
protected Function function = Function.Min; |
||||
|
||||
//[Tooltip("LHS Value ")] |
||||
[SerializeField] |
||||
protected FloatData inLHSValue, inRHSValue; |
||||
|
||||
//[Tooltip("Where the result of the function is stored.")] |
||||
[SerializeField] |
||||
protected FloatData outValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
switch (function) |
||||
{ |
||||
case Function.Min: |
||||
outValue.Value = Mathf.Min(inLHSValue.Value, inRHSValue.Value); |
||||
break; |
||||
case Function.Max: |
||||
outValue.Value = Mathf.Max(inLHSValue.Value, inRHSValue.Value); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return function.ToString(); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 514ec18f5085cba48bbe6701e4697eb0 |
||||
timeCreated: 1501212523 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,26 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Negate a float |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Negate", |
||||
"Negate a float")] |
||||
[AddComponentMenu("")] |
||||
public class Neg : BaseUnaryMathCommand |
||||
{ |
||||
public override void OnEnter() |
||||
{ |
||||
outValue.Value = -(inValue.Value); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Negate"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ff146879925212d4988aa4318efcbbd5 |
||||
timeCreated: 1501213679 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,39 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Raise a value to the power of another |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Pow", |
||||
"Raise a value to the power of another.")] |
||||
[AddComponentMenu("")] |
||||
public class Pow : Command |
||||
{ |
||||
[SerializeField] |
||||
protected FloatData baseValue, exponentValue; |
||||
|
||||
[Tooltip("Where the result of the function is stored.")] |
||||
[SerializeField] |
||||
protected FloatData outValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
outValue.Value = Mathf.Pow(baseValue.Value, exponentValue.Value); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Pow"; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 23b09e2ab627fec4cb0200f7252dbc90 |
||||
timeCreated: 1501497818 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,50 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to execute and store the result of a Round |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Round", |
||||
"Command to execute and store the result of a Round")] |
||||
[AddComponentMenu("")] |
||||
public class Round : BaseUnaryMathCommand |
||||
{ |
||||
public enum Mode |
||||
{ |
||||
Round, |
||||
Floor, |
||||
Ceil |
||||
} |
||||
|
||||
[Tooltip("Mode; Round (closest), floor(smaller) or ceil(bigger).")] |
||||
[SerializeField] |
||||
protected Mode function = Mode.Round; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
switch (function) |
||||
{ |
||||
case Mode.Round: |
||||
outValue.Value = Mathf.Round(inValue.Value); |
||||
break; |
||||
case Mode.Floor: |
||||
outValue.Value = Mathf.Floor(inValue.Value); |
||||
break; |
||||
case Mode.Ceil: |
||||
outValue.Value = Mathf.Ceil(inValue.Value); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return function.ToString(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: b9c834185b491334d8e41ca4fc49a56e |
||||
timeCreated: 1501212403 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,26 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to execute and store the result of a Sign |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Sign", |
||||
"Command to execute and store the result of a Sign")] |
||||
[AddComponentMenu("")] |
||||
public class Sign : BaseUnaryMathCommand |
||||
{ |
||||
public override void OnEnter() |
||||
{ |
||||
outValue.Value = Mathf.Sign(inValue.Value); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Sign"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 6a03542258f6b654b8a6d64938803f71 |
||||
timeCreated: 1501211938 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,26 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to execute and store the result of a Sqrt |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Sqrt", |
||||
"Command to execute and store the result of a Sqrt")] |
||||
[AddComponentMenu("")] |
||||
public class Sqrt : BaseUnaryMathCommand |
||||
{ |
||||
public override void OnEnter() |
||||
{ |
||||
outValue.Value = Mathf.Sqrt(inValue.Value); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return "Sqrt"; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 6e52daa13ab8fe7499a7774ebc194fc5 |
||||
timeCreated: 1501211938 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,65 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to execute and store the result of a float to int conversion |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"ToInt", |
||||
"Command to execute and store the result of a float to int conversion")] |
||||
[AddComponentMenu("")] |
||||
public class ToInt : Command |
||||
{ |
||||
public enum Mode |
||||
{ |
||||
RoundToInt, |
||||
FloorToInt, |
||||
CeilToInt, |
||||
} |
||||
|
||||
|
||||
[Tooltip("To integer mode; round, floor or ceil.")] |
||||
[SerializeField] |
||||
protected Mode function = Mode.RoundToInt; |
||||
|
||||
[Tooltip("Value to be passed in to the function.")] |
||||
[SerializeField] |
||||
protected FloatData inValue; |
||||
|
||||
[Tooltip("Where the result of the function is stored.")] |
||||
[SerializeField] |
||||
protected IntegerData outValue; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
switch (function) |
||||
{ |
||||
case Mode.RoundToInt: |
||||
outValue.Value = Mathf.RoundToInt(inValue.Value); |
||||
break; |
||||
case Mode.FloorToInt: |
||||
outValue.Value = Mathf.FloorToInt(inValue.Value); |
||||
break; |
||||
case Mode.CeilToInt: |
||||
outValue.Value = Mathf.CeilToInt(inValue.Value); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return function.ToString(); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 209dba259f0c4134daa0ec3b64c78062 |
||||
timeCreated: 1501210911 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,77 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Command to execute and store the result of basic trigonometry |
||||
/// </summary> |
||||
[CommandInfo("Math", |
||||
"Trig", |
||||
"Command to execute and store the result of basic trigonometry")] |
||||
[AddComponentMenu("")] |
||||
public class Trig : BaseUnaryMathCommand |
||||
{ |
||||
public enum Function |
||||
{ |
||||
Rad2Deg, |
||||
Deg2Rad, |
||||
ACos, |
||||
ASin, |
||||
ATan, |
||||
Cos, |
||||
Sin, |
||||
Tan |
||||
} |
||||
|
||||
|
||||
[Tooltip("Trigonometric function to run.")] |
||||
[SerializeField] |
||||
protected Function function = Function.Sin; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
switch (function) |
||||
{ |
||||
case Function.Rad2Deg: |
||||
outValue.Value = inValue.Value * Mathf.Rad2Deg; |
||||
break; |
||||
case Function.Deg2Rad: |
||||
outValue.Value = inValue.Value * Mathf.Deg2Rad; |
||||
break; |
||||
case Function.ACos: |
||||
outValue.Value = Mathf.Acos(inValue.Value); |
||||
break; |
||||
case Function.ASin: |
||||
outValue.Value = Mathf.Asin(inValue.Value); |
||||
break; |
||||
case Function.ATan: |
||||
outValue.Value = Mathf.Atan(inValue.Value); |
||||
break; |
||||
case Function.Cos: |
||||
outValue.Value = Mathf.Cos(inValue.Value); |
||||
break; |
||||
case Function.Sin: |
||||
outValue.Value = Mathf.Sin(inValue.Value); |
||||
break; |
||||
case Function.Tan: |
||||
outValue.Value = Mathf.Tan(inValue.Value); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return function.ToString(); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: ee9ab1525ab1b794489f2517aab1d5e2 |
||||
timeCreated: 1501148787 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,59 @@
|
||||
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus). |
||||
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) |
||||
|
||||
using UnityEngine; |
||||
using UnityEngine.Serialization; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Shuffle the order of the items in a Fungus Menu |
||||
/// </summary> |
||||
[CommandInfo("Narrative", |
||||
"Menu Shuffle", |
||||
"Shuffle the order of the items in a Fungus Menu")] |
||||
[AddComponentMenu("")] |
||||
[ExecuteInEditMode] |
||||
public class MenuShuffle : Command |
||||
{ |
||||
public enum Mode |
||||
{ |
||||
Every, |
||||
Once |
||||
} |
||||
[SerializeField] |
||||
[Tooltip("Determines if the order is shuffled everytime this command is it (Every) or if it is consistent when returned to but random (Once)")] |
||||
protected Mode shuffleMode = Mode.Once; |
||||
|
||||
private int seed = -1; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
var menuDialog = MenuDialog.GetMenuDialog(); |
||||
|
||||
//if we shuffle every time or we haven't shuffled yet |
||||
if(shuffleMode == Mode.Every || seed == -1) |
||||
{ |
||||
seed = Random.Range(0,1000000); |
||||
} |
||||
|
||||
if (menuDialog != null) |
||||
{ |
||||
menuDialog.Shuffle(new System.Random(seed)); |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return shuffleMode.ToString(); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(184, 210, 235, 255); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 4d88125c88dab4a44851835e94ff4d90 |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 103d5735e5e7b4a409ae0bb18c246f22 |
||||
folderAsset: yes |
||||
timeCreated: 1513473561 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 168ad11319df4784eaaf28cf8e564365 |
||||
folderAsset: yes |
||||
timeCreated: 1503731365 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,85 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
// <summary> |
||||
/// Add force to a Rigidbody2D |
||||
/// </summary> |
||||
[CommandInfo("Rigidbody2D", |
||||
"AddForce2D", |
||||
"Add force to a Rigidbody2D")] |
||||
[AddComponentMenu("")] |
||||
public class AddForce2D : Command |
||||
{ |
||||
[SerializeField] |
||||
protected Rigidbody2DData rb; |
||||
|
||||
[SerializeField] |
||||
protected ForceMode2D forceMode = ForceMode2D.Force; |
||||
|
||||
public enum ForceFunction |
||||
{ |
||||
AddForce, |
||||
AddForceAtPosition, |
||||
AddRelativeForce |
||||
} |
||||
|
||||
[SerializeField] |
||||
protected ForceFunction forceFunction = ForceFunction.AddForce; |
||||
|
||||
[Tooltip("Vector of force to be added")] |
||||
[SerializeField] |
||||
protected Vector2Data force; |
||||
|
||||
[Tooltip("Scale factor to be applied to force as it is used.")] |
||||
[SerializeField] |
||||
protected FloatData forceScaleFactor = new FloatData(1); |
||||
|
||||
[Tooltip("World position the force is being applied from. Used only in AddForceAtPosition")] |
||||
[SerializeField] |
||||
protected Vector2Data atPosition; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
switch (forceFunction) |
||||
{ |
||||
case ForceFunction.AddForce: |
||||
rb.Value.AddForce(force.Value * forceScaleFactor.Value, forceMode); |
||||
break; |
||||
case ForceFunction.AddForceAtPosition: |
||||
rb.Value.AddForceAtPosition(force.Value * forceScaleFactor.Value, atPosition.Value, forceMode); |
||||
break; |
||||
case ForceFunction.AddRelativeForce: |
||||
rb.Value.AddRelativeForce(force.Value * forceScaleFactor.Value, forceMode); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return forceMode.ToString() + ": " + force.ToString(); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
public override bool HasReference(Variable variable) |
||||
{ |
||||
if (rb.rigidbody2DRef == variable || force.vector2Ref == variable || forceScaleFactor.floatRef == variable || |
||||
atPosition.vector2Ref == variable) |
||||
return true; |
||||
|
||||
return false; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 59927941e3d79be4dac4408058904465 |
||||
timeCreated: 1503094848 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,56 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
// <summary> |
||||
/// Add Torque to a Rigidbody2D |
||||
/// </summary> |
||||
[CommandInfo("Rigidbody2D", |
||||
"AddTorque2D", |
||||
"Add Torque to a Rigidbody2D")] |
||||
[AddComponentMenu("")] |
||||
public class AddTorque2D : Command |
||||
{ |
||||
[SerializeField] |
||||
protected Rigidbody2DData rb; |
||||
|
||||
[SerializeField] |
||||
protected ForceMode2D forceMode = ForceMode2D.Force; |
||||
|
||||
[Tooltip("Amount of torque to be added")] |
||||
[SerializeField] |
||||
protected FloatData force; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
rb.Value.AddTorque(force.Value, forceMode); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
if (rb.Value == null) |
||||
{ |
||||
return "Error: rb not set"; |
||||
} |
||||
|
||||
return forceMode.ToString() + ": " + force.Value.ToString() + (force.floatRef != null ? " (" + force.floatRef.Key + ")" : ""); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
public override bool HasReference(Variable variable) |
||||
{ |
||||
if (rb.rigidbody2DRef == variable || force.floatRef == variable) |
||||
return true; |
||||
|
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 42fb61d4cee69b244bcf4fcc8e4ae28b |
||||
timeCreated: 1503744011 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,69 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
// <summary> |
||||
/// Stop velocity and angular velocity on a Rigidbody2D |
||||
/// </summary> |
||||
[CommandInfo("Rigidbody2D", |
||||
"StopMotion2D", |
||||
"Stop velocity and angular velocity on a Rigidbody2D")] |
||||
[AddComponentMenu("")] |
||||
public class StopMotionRigidBody2D : Command |
||||
{ |
||||
[SerializeField] |
||||
protected Rigidbody2DData rb; |
||||
|
||||
public enum Motion |
||||
{ |
||||
Velocity, |
||||
AngularVelocity, |
||||
AngularAndLinearVelocity |
||||
} |
||||
|
||||
[SerializeField] |
||||
protected Motion motionToStop = Motion.AngularAndLinearVelocity; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
switch (motionToStop) |
||||
{ |
||||
case Motion.Velocity: |
||||
rb.Value.velocity = Vector2.zero; |
||||
break; |
||||
case Motion.AngularVelocity: |
||||
rb.Value.angularVelocity = 0; |
||||
break; |
||||
case Motion.AngularAndLinearVelocity: |
||||
rb.Value.angularVelocity = 0; |
||||
rb.Value.velocity = Vector2.zero; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return motionToStop.ToString(); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
public override bool HasReference(Variable variable) |
||||
{ |
||||
if (rb.rigidbody2DRef == variable) |
||||
return true; |
||||
|
||||
return false; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: bd2e830ee16360d418acee50d83c9c13 |
||||
timeCreated: 1504225685 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 3c625aa42f45f484cb2a4f4bef7adede |
||||
folderAsset: yes |
||||
timeCreated: 1501237083 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,35 @@
|
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
/// <summary> |
||||
/// Reload the current scene |
||||
/// </summary> |
||||
[CommandInfo("Scene", |
||||
"Reload", |
||||
"Reload the current scene")] |
||||
[AddComponentMenu("")] |
||||
public class ReloadScene : Command |
||||
{ |
||||
[Tooltip("Image to display while loading the scene")] |
||||
[SerializeField] |
||||
protected Texture2D loadingImage; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
SceneLoader.LoadScene(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name, loadingImage); |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
return ""; |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 9c784b19efbe8424fa879e0d6d883281 |
||||
timeCreated: 1501237128 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2 |
||||
guid: f7ddb80a0487d1342b36129da32ad1f6 |
||||
folderAsset: yes |
||||
timeCreated: 1503815490 |
||||
licenseType: Free |
||||
DefaultImporter: |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -0,0 +1,217 @@
|
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using UnityEngine; |
||||
|
||||
namespace Fungus |
||||
{ |
||||
// <summary> |
||||
/// Get or Set a property of a transform component |
||||
/// </summary> |
||||
[CommandInfo("Transform", |
||||
"Property", |
||||
"Get or Set a property of a transform component")] |
||||
[AddComponentMenu("")] |
||||
public class TransformProperty : Command |
||||
{ |
||||
public enum GetSet |
||||
{ |
||||
Get, |
||||
Set, |
||||
} |
||||
public GetSet getOrSet = GetSet.Get; |
||||
|
||||
public enum Property |
||||
{ |
||||
ChildCount, |
||||
EulerAngles, |
||||
Forward, |
||||
HasChanged, |
||||
HierarchyCapacity, |
||||
HierarchyCount, |
||||
LocalEulerAngles, |
||||
LocalPosition, |
||||
LocalScale, |
||||
LossyScale, |
||||
Parent, |
||||
Position, |
||||
Right, |
||||
Root, |
||||
Up, |
||||
//no quat or mat4 yet |
||||
//LocalRotation, |
||||
//Rotation, |
||||
//LocalToWorldMatrix, |
||||
//WorldToLocalMatrix |
||||
} |
||||
[SerializeField] |
||||
protected Property property = Property.Position; |
||||
|
||||
[SerializeField] |
||||
protected TransformData transformData; |
||||
|
||||
[SerializeField] |
||||
[VariableProperty(typeof(BooleanVariable), |
||||
typeof(IntegerVariable), |
||||
typeof(Vector3Variable), |
||||
typeof(TransformVariable))] |
||||
protected Variable inOutVar; |
||||
|
||||
public override void OnEnter() |
||||
{ |
||||
var iob = inOutVar as BooleanVariable; |
||||
var ioi = inOutVar as IntegerVariable; |
||||
var iov = inOutVar as Vector3Variable; |
||||
var iot = inOutVar as TransformVariable; |
||||
|
||||
var t = transformData.Value; |
||||
|
||||
switch (getOrSet) |
||||
{ |
||||
case GetSet.Get: |
||||
switch (property) |
||||
{ |
||||
case Property.ChildCount: |
||||
ioi.Value = t.childCount; |
||||
break; |
||||
case Property.EulerAngles: |
||||
iov.Value = t.eulerAngles; |
||||
break; |
||||
case Property.Forward: |
||||
iov.Value = t.forward; |
||||
break; |
||||
case Property.HasChanged: |
||||
iob.Value = t.hasChanged; |
||||
break; |
||||
case Property.HierarchyCapacity: |
||||
ioi.Value = t.hierarchyCapacity; |
||||
break; |
||||
case Property.HierarchyCount: |
||||
ioi.Value = t.hierarchyCount; |
||||
break; |
||||
case Property.LocalEulerAngles: |
||||
iov.Value = t.localEulerAngles; |
||||
break; |
||||
case Property.LocalPosition: |
||||
iov.Value = t.localPosition; |
||||
break; |
||||
case Property.LocalScale: |
||||
iov.Value = t.localScale; |
||||
break; |
||||
case Property.LossyScale: |
||||
iov.Value = t.lossyScale; |
||||
break; |
||||
case Property.Parent: |
||||
iot.Value = t.parent; |
||||
break; |
||||
case Property.Position: |
||||
iov.Value = t.position; |
||||
break; |
||||
case Property.Right: |
||||
iov.Value = t.right; |
||||
break; |
||||
case Property.Root: |
||||
iot.Value = t.parent; |
||||
break; |
||||
case Property.Up: |
||||
iov.Value = t.up; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
break; |
||||
case GetSet.Set: |
||||
switch (property) |
||||
{ |
||||
case Property.ChildCount: |
||||
Debug.LogWarning("Cannot Set childCount, it is read only"); |
||||
break; |
||||
case Property.EulerAngles: |
||||
t.eulerAngles = iov.Value; |
||||
break; |
||||
case Property.Forward: |
||||
t.forward = iov.Value; |
||||
break; |
||||
case Property.HasChanged: |
||||
t.hasChanged = iob.Value; |
||||
break; |
||||
case Property.HierarchyCapacity: |
||||
t.hierarchyCapacity = ioi.Value; |
||||
break; |
||||
case Property.HierarchyCount: |
||||
Debug.LogWarning("Cannot Set HierarchyCount, it is read only"); |
||||
break; |
||||
case Property.LocalEulerAngles: |
||||
t.localEulerAngles = iov.Value; |
||||
break; |
||||
case Property.LocalPosition: |
||||
t.localPosition = iov.Value; |
||||
break; |
||||
case Property.LocalScale: |
||||
t.localScale = iov.Value; |
||||
break; |
||||
case Property.LossyScale: |
||||
Debug.LogWarning("Cannot Set LossyScale, it is read only"); |
||||
break; |
||||
case Property.Parent: |
||||
t.parent = iot.Value; |
||||
break; |
||||
case Property.Position: |
||||
t.position = iov.Value; |
||||
break; |
||||
case Property.Right: |
||||
t.right = iov.Value; |
||||
break; |
||||
case Property.Root: |
||||
Debug.LogWarning("Cannot Set Root, it is read only"); |
||||
break; |
||||
case Property.Up: |
||||
t.up = iov.Value; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
Continue(); |
||||
} |
||||
|
||||
public override string GetSummary() |
||||
{ |
||||
if (transformData.Value == null) |
||||
{ |
||||
return "Error: no transform set"; |
||||
} |
||||
|
||||
var iob = inOutVar as BooleanVariable; |
||||
var ioi = inOutVar as IntegerVariable; |
||||
var iov = inOutVar as Vector3Variable; |
||||
var iot = inOutVar as TransformVariable; |
||||
|
||||
if (iob == null && ioi == null && iov == null && iot == null) |
||||
{ |
||||
return "Error: no variable set to push or pull data to or from"; |
||||
} |
||||
|
||||
//We could do further checks here, eg, you have selected childcount but set a vec3variable |
||||
|
||||
return getOrSet.ToString() + " " + property.ToString(); |
||||
} |
||||
|
||||
public override Color GetButtonColor() |
||||
{ |
||||
return new Color32(235, 191, 217, 255); |
||||
} |
||||
|
||||
public override bool HasReference(Variable variable) |
||||
{ |
||||
if (transformData.transformRef == variable || inOutVar == variable) |
||||
return true; |
||||
|
||||
return false; |
||||
} |
||||
|
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue