Esempio n. 1
0
        /// <summary>
        /// Invoke the true or false event stack based on a comparison of your targetVariable and a fixed number
        /// The comparison only runs when the Raise() is called, it's not monitored in Update or etc.
        /// </summary>
        public override void Raise()
        {
            if (targetVariable == null)
            {
                Debug.Log("No number variable assigned in a fixed number to numberVariable comparison! " + this.gameObject.name);
                return;
            }

            if (targetVariable is FloatVariable)
            {
                FloatVariable f = (FloatVariable)targetVariable;
                if (f.value < fixedNumber)
                {
                    IfVariableIsLower.Invoke();
                }
                else
                {
                    IfVariableIsHigher.Invoke();
                }
            }

            if (targetVariable is IntVariable)
            {
                IntVariable i = (IntVariable)targetVariable;
                int         v = Mathf.RoundToInt(fixedNumber);
                if (i.value < v)
                {
                    IfVariableIsLower.Invoke();
                }
                else
                {
                    IfVariableIsHigher.Invoke();
                }
            }
        }
Esempio n. 2
0
        public void Add(NumberVariable v)
        {
            if (v is FloatVariable)
            {
                FloatVariable f = (FloatVariable)v;
                value += Mathf.RoundToInt(f.value);
            }

            if (v is IntVariable)
            {
                IntVariable i = (IntVariable)v;
                value += i.value;
            }
        }
        public void Add(NumberVariable v)
        {
            if (v is FloatVariable)
            {
                FloatVariable f = (FloatVariable)v;
                value += f.value;
            }

            if (v is IntVariable)
            {
                IntVariable i = (IntVariable)v;
                value += i.value;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Raise true or false event stack based on the comparison of two number variables
        /// </summary>
        public override void Raise()
        {
            if (value1 == null || value2 == null)
            {
                Debug.Log("Number variable comparison doesn't have variables assigned! " + this.gameObject);
                return;
            }

            float v1 = 0;
            float v2 = 0;

            if (value1 is FloatVariable)
            {
                FloatVariable f = (FloatVariable)value1;
                v1 = f.value;
            }

            if (value1 is IntVariable)
            {
                IntVariable i = (IntVariable)value1;
                v1 = i.value;
            }

            if (value2 is FloatVariable)
            {
                FloatVariable f = (FloatVariable)value2;
                v2 = f.value;
            }

            if (value2 is IntVariable)
            {
                IntVariable i = (IntVariable)value2;
                v2 = i.value;
            }

            if (v1 < v2)
            {
                IfValue1IsLower.Invoke();
            }
            else
            {
                IfValue1IsHigher.Invoke();
            }
        }