From f19099853b7cd095f38428dbe120311a82ac8584 Mon Sep 17 00:00:00 2001 From: Jorge Ramirez Date: Sun, 8 Apr 2018 20:49:39 -0400 Subject: [PATCH] Add functionality for addition and subtraction to the Vector2 and Vector3 variables --- Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs | 8 +++++++- Assets/Fungus/Scripts/VariableTypes/Vector3Variable.cs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs b/Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs index 03f145e8..6b9c3893 100644 --- a/Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs +++ b/Assets/Fungus/Scripts/VariableTypes/Vector2Variable.cs @@ -15,7 +15,7 @@ namespace Fungus public class Vector2Variable : VariableBase { public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals }; - public static readonly SetOperator[] setOperators = { SetOperator.Assign }; + public static readonly SetOperator[] setOperators = { SetOperator.Assign, SetOperator.Add, SetOperator.Subtract }; public virtual bool Evaluate(CompareOperator compareOperator, Vector2 value) { @@ -44,6 +44,12 @@ namespace Fungus case SetOperator.Assign: Value = value; break; + case SetOperator.Add: + Value += value; + break; + case SetOperator.Subtract: + Value -= value; + break; default: Debug.LogError("The " + setOperator.ToString() + " set operator is not valid."); break; diff --git a/Assets/Fungus/Scripts/VariableTypes/Vector3Variable.cs b/Assets/Fungus/Scripts/VariableTypes/Vector3Variable.cs index c25db0e0..4735fe38 100644 --- a/Assets/Fungus/Scripts/VariableTypes/Vector3Variable.cs +++ b/Assets/Fungus/Scripts/VariableTypes/Vector3Variable.cs @@ -15,7 +15,7 @@ namespace Fungus public class Vector3Variable : VariableBase { public static readonly CompareOperator[] compareOperators = { CompareOperator.Equals, CompareOperator.NotEquals }; - public static readonly SetOperator[] setOperators = { SetOperator.Assign }; + public static readonly SetOperator[] setOperators = { SetOperator.Assign, SetOperator.Add, SetOperator.Subtract }; public virtual bool Evaluate(CompareOperator compareOperator, Vector3 value) { @@ -44,6 +44,12 @@ namespace Fungus case SetOperator.Assign: Value = value; break; + case SetOperator.Add: + Value += value; + break; + case SetOperator.Subtract: + Value -= value; + break; default: Debug.LogError("The " + setOperator.ToString() + " set operator is not valid."); break;