Browse Source

Added Fungus Commands for most of MathF

Added Math demo scene
master
desktop-maesty/steve 7 years ago
parent
commit
7c57d8c9a8
  1. 9
      Assets/Fungus/Scripts/Commands/Math.meta
  2. 26
      Assets/Fungus/Scripts/Commands/Math/Abs.cs
  3. 12
      Assets/Fungus/Scripts/Commands/Math/Abs.cs.meta
  4. 25
      Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs
  5. 12
      Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs.meta
  6. 66
      Assets/Fungus/Scripts/Commands/Math/Clamp.cs
  7. 12
      Assets/Fungus/Scripts/Commands/Math/Clamp.cs.meta
  8. 29
      Assets/Fungus/Scripts/Commands/Math/Curve.cs
  9. 12
      Assets/Fungus/Scripts/Commands/Math/Curve.cs.meta
  10. 26
      Assets/Fungus/Scripts/Commands/Math/Exp.cs
  11. 12
      Assets/Fungus/Scripts/Commands/Math/Exp.cs.meta
  12. 28
      Assets/Fungus/Scripts/Commands/Math/Inv.cs
  13. 12
      Assets/Fungus/Scripts/Commands/Math/Inv.cs.meta
  14. 46
      Assets/Fungus/Scripts/Commands/Math/InvLerp.cs
  15. 12
      Assets/Fungus/Scripts/Commands/Math/InvLerp.cs.meta
  16. 63
      Assets/Fungus/Scripts/Commands/Math/Lerp.cs
  17. 12
      Assets/Fungus/Scripts/Commands/Math/Lerp.cs.meta
  18. 56
      Assets/Fungus/Scripts/Commands/Math/Log.cs
  19. 12
      Assets/Fungus/Scripts/Commands/Math/Log.cs.meta
  20. 48
      Assets/Fungus/Scripts/Commands/Math/Map.cs
  21. 12
      Assets/Fungus/Scripts/Commands/Math/Map.cs.meta
  22. 61
      Assets/Fungus/Scripts/Commands/Math/MinMax.cs
  23. 12
      Assets/Fungus/Scripts/Commands/Math/MinMax.cs.meta
  24. 26
      Assets/Fungus/Scripts/Commands/Math/Neg.cs
  25. 12
      Assets/Fungus/Scripts/Commands/Math/Neg.cs.meta
  26. 39
      Assets/Fungus/Scripts/Commands/Math/Pow.cs
  27. 12
      Assets/Fungus/Scripts/Commands/Math/Pow.cs.meta
  28. 50
      Assets/Fungus/Scripts/Commands/Math/Round.cs
  29. 12
      Assets/Fungus/Scripts/Commands/Math/Round.cs.meta
  30. 26
      Assets/Fungus/Scripts/Commands/Math/Sign.cs
  31. 12
      Assets/Fungus/Scripts/Commands/Math/Sign.cs.meta
  32. 26
      Assets/Fungus/Scripts/Commands/Math/Sqrt.cs
  33. 12
      Assets/Fungus/Scripts/Commands/Math/Sqrt.cs.meta
  34. 65
      Assets/Fungus/Scripts/Commands/Math/ToInt.cs
  35. 12
      Assets/Fungus/Scripts/Commands/Math/ToInt.cs.meta
  36. 85
      Assets/Fungus/Scripts/Commands/Math/Trig.cs
  37. 12
      Assets/Fungus/Scripts/Commands/Math/Trig.cs.meta
  38. 9
      Assets/FungusExamples/Math.meta
  39. 1724
      Assets/FungusExamples/Math/MathQuiz.unity
  40. 8
      Assets/FungusExamples/Math/MathQuiz.unity.meta

9
Assets/Fungus/Scripts/Commands/Math.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 09c52cfe3a6ff4747a9c207bec24ba11
folderAsset: yes
timeCreated: 1503202781
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Abs.cs

@ -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";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Abs.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6d11e978db36df445816ec2535d381ce
timeCreated: 1501211592
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

25
Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs

@ -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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/BaseUnaryMathCommand.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 513a02811ba512d4ab54d157a15ae8c2
timeCreated: 1501211592
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

66
Assets/Fungus/Scripts/Commands/Math/Clamp.cs

@ -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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Clamp.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2929f1e90a24b6446a70d27316cff20a
timeCreated: 1501225403
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

29
Assets/Fungus/Scripts/Commands/Math/Curve.cs

@ -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";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Curve.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c03f48fc50d3747478ad85653a21a5f5
timeCreated: 1501226831
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Exp.cs

@ -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";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Exp.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f28df8ed8a80fa345b3b5e3dcacdea65
timeCreated: 1501211938
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

28
Assets/Fungus/Scripts/Commands/Math/Inv.cs

@ -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";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Inv.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 36d3a877e83b1d1478f1ac099414d17a
timeCreated: 1501213679
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

46
Assets/Fungus/Scripts/Commands/Math/InvLerp.cs

@ -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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/InvLerp.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 80c88869f66a81f4b95e843c36724e65
timeCreated: 1501213063
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

63
Assets/Fungus/Scripts/Commands/Math/Lerp.cs

@ -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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Lerp.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b44d8d3a71d3e7b45a89437c8f84e687
timeCreated: 1501212773
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

56
Assets/Fungus/Scripts/Commands/Math/Log.cs

@ -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";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Log.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 47ecda391b679d8449893d4466f41b13
timeCreated: 1501211938
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

48
Assets/Fungus/Scripts/Commands/Math/Map.cs

@ -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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Map.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 78d80bb5401d8044eb9eee0d4eb0b645
timeCreated: 1501226122
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

61
Assets/Fungus/Scripts/Commands/Math/MinMax.cs

@ -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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/MinMax.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 514ec18f5085cba48bbe6701e4697eb0
timeCreated: 1501212523
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Neg.cs

@ -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";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Neg.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ff146879925212d4988aa4318efcbbd5
timeCreated: 1501213679
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

39
Assets/Fungus/Scripts/Commands/Math/Pow.cs

@ -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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Pow.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 23b09e2ab627fec4cb0200f7252dbc90
timeCreated: 1501497818
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

50
Assets/Fungus/Scripts/Commands/Math/Round.cs

@ -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();
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Round.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b9c834185b491334d8e41ca4fc49a56e
timeCreated: 1501212403
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Sign.cs

@ -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";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Sign.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6a03542258f6b654b8a6d64938803f71
timeCreated: 1501211938
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

26
Assets/Fungus/Scripts/Commands/Math/Sqrt.cs

@ -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";
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Sqrt.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6e52daa13ab8fe7499a7774ebc194fc5
timeCreated: 1501211938
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

65
Assets/Fungus/Scripts/Commands/Math/ToInt.cs

@ -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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/ToInt.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 209dba259f0c4134daa0ec3b64c78062
timeCreated: 1501210911
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

85
Assets/Fungus/Scripts/Commands/Math/Trig.cs

@ -0,0 +1,85 @@
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 : Command
{
public enum Function
{
Rad2Deg,
Deg2Rad,
ACos,
ASin,
ATan,
Cos,
Sin,
Tan
}
[Tooltip("Trigonometric function to run.")]
[SerializeField]
protected Function function = Function.Sin;
[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 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);
}
}
}

12
Assets/Fungus/Scripts/Commands/Math/Trig.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ee9ab1525ab1b794489f2517aab1d5e2
timeCreated: 1501148787
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/FungusExamples/Math.meta

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8603b184910aa8344a8ac021ea619bfd
folderAsset: yes
timeCreated: 1503202781
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

1724
Assets/FungusExamples/Math/MathQuiz.unity

File diff suppressed because it is too large Load Diff

8
Assets/FungusExamples/Math/MathQuiz.unity.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ca798e8e7987c1d4a99c8970f179eccc
timeCreated: 1469542890
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save