using UnityEngine; namespace Fungus { /// /// Command to execute and store the result of basic trigonometry /// [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); } } }