public void Evaluate(GameTime gameTime, object Input, out bool IsCompleted, out List <object> Result)
            {
                string VariableNameLower = VariableName.ToLower();
                double Value             = (double)Input;

                if (!Info.Map.DicMapVariables.ContainsKey(VariableNameLower))
                {
                    if (SignOperator == Operators.SignOperators.Equal)
                    {
                        Info.Map.DicMapVariables.Add(VariableNameLower, Value);
                    }
                    else
                    {
                        throw new Exception(SignOperator.ToString() + " can't be used on " + VariableNameLower + " as this variable is unassigned.");
                    }
                }
                else
                {
                    switch (SignOperator)
                    {
                    case Operators.SignOperators.Equal:
                        Info.Map.DicMapVariables[VariableNameLower] = Value;
                        break;

                    case Operators.SignOperators.PlusEqual:
                        Info.Map.DicMapVariables[VariableNameLower] += Value;
                        break;

                    case Operators.SignOperators.MinusEqual:
                        Info.Map.DicMapVariables[VariableNameLower] -= Value;
                        break;

                    case Operators.SignOperators.MultiplicatedEqual:
                        Info.Map.DicMapVariables[VariableNameLower] *= Value;
                        break;

                    case Operators.SignOperators.DividedEqual:
                        Info.Map.DicMapVariables[VariableNameLower] /= Value;
                        break;

                    case Operators.SignOperators.ModuloEqual:
                        Info.Map.DicMapVariables[VariableNameLower] %= Value;
                        break;
                    }
                }

                Result      = new List <object>();
                IsCompleted = true;
            }
Example #2
0
        public override void Update(int Index)
        {
            string VariableNameLower = VariableName.ToLower();

            if (!Map.DicMapVariables.ContainsKey(VariableNameLower))
            {
                if (SignOperator == Operators.SignOperators.Equal)
                {
                    Map.DicMapVariables.Add(VariableNameLower, Value);
                }
                else
                {
                    throw new Exception(SignOperator.ToString() + " can't be used on " + VariableNameLower + " as this variable is unassigned.");
                }
            }
            else
            {
                switch (SignOperator)
                {
                case Operators.SignOperators.Equal:
                    Map.DicMapVariables[VariableNameLower] = Value;
                    break;

                case Operators.SignOperators.PlusEqual:
                    Map.DicMapVariables[VariableNameLower] += Value;
                    break;

                case Operators.SignOperators.MinusEqual:
                    Map.DicMapVariables[VariableNameLower] -= Value;
                    break;

                case Operators.SignOperators.MultiplicatedEqual:
                    Map.DicMapVariables[VariableNameLower] *= Value;
                    break;

                case Operators.SignOperators.DividedEqual:
                    Map.DicMapVariables[VariableNameLower] /= Value;
                    break;

                case Operators.SignOperators.ModuloEqual:
                    Map.DicMapVariables[VariableNameLower] %= Value;
                    break;
                }
            }
            Map.ExecuteFollowingScripts(this, 0);
        }