コード例 #1
0
        public void Set(ScriptExecutionEnvironment environment, ScriptVariable value)
        {
            if (_variable == null)
            {
                environment.Console.Warn("Cannot use index for null variable");
                return;
            }
            if (_index == null)
            {
                environment.Console.Warn("Cannot use null as index");
                return;
            }
            ListVariable   list = _variable as ListVariable;
            StringVariable key  = _index as StringVariable;

            if (list != null && key != null)
            {
                list[key.Value] = value;
                return;
            }

            int indexInt = _index.ToInteger();

            if (!_variable.SetIndexedValue(indexInt, value))
            {
                environment.Console.Warn(string.Format("Invalid index : {0}", _index.ToString()));
            }
        }
コード例 #2
0
        public static void SerializeStringVariable()
        {
            var a = new StringVariable("foobar");
            var b = SerializationUtil.Reserialize(a);

            Assert.AreEqual(a, b);
        }
コード例 #3
0
ファイル: If.cs プロジェクト: gdseller/fungus
        public bool EvaluateCondition()
        {
            BooleanVariable booleanVariable = variable as BooleanVariable;
            IntegerVariable integerVariable = variable as IntegerVariable;
            FloatVariable   floatVariable   = variable as FloatVariable;
            StringVariable  stringVariable  = variable as StringVariable;

            bool condition = false;

            if (booleanVariable != null)
            {
                condition = booleanVariable.Evaluate(compareOperator, booleanData.Value);
            }
            else if (integerVariable != null)
            {
                condition = integerVariable.Evaluate(compareOperator, integerData.Value);
            }
            else if (floatVariable != null)
            {
                condition = floatVariable.Evaluate(compareOperator, floatData.Value);
            }
            else if (stringVariable != null)
            {
                condition = stringVariable.Evaluate(compareOperator, stringData.Value);
            }

            return(condition);
        }
コード例 #4
0
    public void UnloadScene(string scenename)
    {
        StringVariable var = ScriptableObject.CreateInstance <StringVariable>();

        var.value = scenename;
        UnloadScene(var);
    }
コード例 #5
0
        public ScriptVariable Get(ScriptExecutionEnvironment environment)
        {
            if (_variable == null)
            {
                environment.Console.Warn("Cannot use indexer for null variable");
                return(null);
            }
            if (_index == null)
            {
                environment.Console.Warn("Cannot use null as indexer");
                return(null);
            }
            ListVariable   list = _variable as ListVariable;
            StringVariable key  = _index as StringVariable;

            if (list != null && key != null)
            {
                return(list[key.Value]);
            }

            int            indexInt = _index.ToInteger();
            ScriptVariable ret;

            if (!_variable.GetIndexedValue(indexInt, out ret))
            {
                environment.Console.Warn(string.Format("Invalid index : {0}", _index.ToString()));
                ret = null;
            }
            return(ret);
        }
コード例 #6
0
        public void Add_And_Get_Items()
        {
            const string var1Name = "var1name";
            const string var2Name = "var2name";
            const string var3Name = "var3name";

            var var1 = new IntVariable(1234);
            var var2 = new StringVariable("theValue");
            var var3 = new BoolVariable(true);

            var vg = new VariablesGroup
            {
                { var1Name, var1 },
                new KeyValuePair <string, IVariable>(var2Name, var2)
            };

            vg[var3Name] = var3;

            Assert.That(vg.Count, Is.EqualTo(3));
            Assert.That((int)vg[var1Name].GetValue() !, Is.EqualTo(1234));
            Assert.That((string)vg[var2Name].GetValue() !, Is.EqualTo("theValue"));
            Assert.That(vg.Keys.Count, Is.EqualTo(3));
            Assert.That(vg.ContainsKey(var1Name));
            Assert.That(vg.Values.Count, Is.EqualTo(3));
            Assert.That(vg.Values.Contains(var1));
            Assert.That(vg.Values.Contains(var2));
            Assert.That(vg.Values.Contains(var3));
            Assert.That(vg.ContainsKey(var2Name));
            Assert.That(vg.TryGetValue(var1Name + "False", out _), Is.False);
        }
コード例 #7
0
 public void DrawLet(StringVariable check)
 {
     if (LinkedLetter.Value == check.Value)
     {
         GetComponentInChildren <Text>().text = LinkedLetter.Value;
     }
 }
コード例 #8
0
        public void TestStringValue()
        {
            StringVariable var = new StringVariable();

            var.CheckForStore("string");
            Assert.AreEqual("string", var.Value);
        }
コード例 #9
0
        public void TestStringVariableNullValue()
        {
            StringVariable var    = new StringVariable();
            bool           actual = var.CheckForStore(null);

            Assert.IsFalse(actual);
        }
コード例 #10
0
        private static void SelectTest()
        {
            IDbProvider provider = new SqlDataProvider();

            provider.ConnectionString = $@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog={Settings.Instance.Database};Data Source={Settings.Instance.ServerName}";
            var repository = new Repository <Customer>(provider);

            string[] fields = { "Id", "Name" };

            var name      = new StringVariable("Name");
            var value     = new StringConstant("o");
            var condition = new ComparativeOperator <string>(ComparativeOperatorType.Like, name, value);
            List <DataProperty[]> result = repository.Select(condition, fields);

            //List<Customer2> allCustomers = repository.LoadAll();
            //List<Customer2> customersById = repository.LoadById(1,2,3);
            //List<Customer2> customersByFilter = repository.LoadByFilter(condition);

            if (result.Count != 0)
            {
                Console.WriteLine(result.Select(record => "{" + record.Select(p => p.Name + ": " + p.Value).Aggregate((p1, p2) => p1 + ", " + p2) + "}")
                                  .Aggregate((r1, r2) => r1 + "\n" + r2));
            }
            else
            {
                Console.WriteLine("No record has been found for this condition!");
            }
        }
コード例 #11
0
        void InitProxy()
        {
            Destroy(movement); movement = null;
            Destroy(fire); fire         = null;
            Destroy(damage); damage     = null;
            Destroy(boosterController); boosterController = null;
            Destroy(rigidBody); rigidBody   = null;
            Destroy(collider2d); collider2d = null;

            // Replace PlayerName
            PlayerName = ScriptableObject.CreateInstance <StringVariable>();
            GetComponentInChildren <TextReplacer>().Variable = PlayerName;

            // Replace IsDead
            proxy.IsDead    = ScriptableObject.CreateInstance <BoolVariable>();
            IsDead.Variable = proxy.IsDead;

            // Replace WalkSpeed
            movement.WalkSpeed          = ScriptableObject.CreateInstance <FloatVariable>();
            boosterController.WalkSpeed = movement.WalkSpeed;

            // Replace Dash Rate
            movement.DashRate          = ScriptableObject.CreateInstance <FloatVariable>();
            boosterController.DashRate = movement.DashRate;

            // Replace FireRate
            weaponController.FireRate = ScriptableObject.CreateInstance <FloatVariable>();
            fire.FireRate.Variable    = weaponController.FireRate;
        }
コード例 #12
0
        public void TestVariableName()
        {
            StringVariable var     = new StringVariable();
            string         varName = "string";

            var.Name = varName;
            Assert.AreEqual(varName, var.Name);
        }
コード例 #13
0
        public void UpdateVariable(string varName, string varValue)
        {
            StringVariable stringVar = globalVars.GetOrAddVariable <String>(varName, varValue, typeof(StringVariable)) as StringVariable;

            // GetOrAddVariable doesn't always update the variable to the given value (in the case of a Get)
            // so we have to do it ourselves
            stringVar.Value = varValue;
        }
コード例 #14
0
    public void StringVariableTest_AreTheSameValue()
    {
        string         expected = "randomString";
        StringVariable actual   = ScriptableObject.CreateInstance <StringVariable>();

        actual.Value = "randomString";
        Assert.AreEqual(expected, actual.Value);
    }
コード例 #15
0
ファイル: ActionOpenURL.cs プロジェクト: Giff1/Super-Hero
    public void Load(StringVariable variable)
    {
#if UNITY_WEBGL && !UNITY_EDITOR
        openWindow(variable.Value);
#else
        Application.OpenURL(variable.Value);
#endif
    }
コード例 #16
0
        public void StringVariableChangeValueTest()
        {
            var variable = new StringVariable("My initial text");

            Assert.AreEqual("My initial text", variable.Value);
            variable.Value = "Hello world!";
            Assert.AreEqual("Hello world!", variable.Value);
        }
コード例 #17
0
    private void AddValueToList(FieldInfo f)
    {
        IBaseVariable variable = null;

        if (f.FieldType.ToString() == "System.String")
        {
            variable = new StringVariable();
        }
        else if (f.FieldType.ToString() == "System.Int32")
        {
            variable = new IntegerVariable();
        }
        else if (f.FieldType.ToString() == "System.Single")
        {
            variable = new FloatVariable();
        }
        else if (f.FieldType.ToString() == "System.Boolean")
        {
            variable = new BooleanVariable();
        }
        else if (f.FieldType.ToString() == "System.String[]")
        {
            variable = new StringVariableArray();
        }
        else if (f.FieldType.ToString() == "System.Int32[]")
        {
            variable = new IntegerVariableArray();
        }
        else if (f.FieldType.ToString() == "System.Single[]")
        {
            variable = new FloatVariableArray();
        }
        else if (f.FieldType.ToString() == "System.Boolean[]")
        {
            variable = new BooleanVariableArray();
        }
        else if (f.FieldType.ToString() == "UnityEngine.Vector2")
        {
            variable = new Vector2Variable();
        }
        else if (f.FieldType.ToString() == "UnityEngine.Vector3")
        {
            variable = new Vector3Variable();
        }
        else if (f.FieldType.ToString() == "UnityEngine.Vector2[]")
        {
            variable = new Vector2VariableArray();
        }
        else if (f.FieldType.ToString() == "UnityEngine.Vector3[]")
        {
            variable = new Vector3VariableArray();
        }
        if (variable != null)
        {
            variable.value = f.GetValue(this);
            ListValue.Add((string)f.Name, variable);
        }
    }
コード例 #18
0
        protected override bool CommandLogic()
        {
            string         temp   = GetSource1() + GetSource2();
            StringVariable newVar = new StringVariable(temp);

            m_variableDictionary.SetVariable(m_sDestination, newVar);

            return(true);
        }
コード例 #19
0
    public static DateTime GetDate(StringVariable variable)
    {
        if (string.IsNullOrEmpty(variable.Value))
        {
            return(new DateTime(1990, 1, 1));
        }

        return(DateTime.Parse(variable.Value));
    }
コード例 #20
0
 protected virtual void Awake()
 {
     tileBoard = FindObjectOfType <TileBoardController>();
     TileController.AnyClicked += OnAnyTileClicked;
     swapDurationVar            = tileSwapVals.GetVariable("swapDuration") as FloatVariable;
     swapEnabledVar             = tileSwapVals.GetVariable("swapEnabled") as BooleanVariable;
     cancelAxisVar              = tileSwapVals.GetVariable("cancelAxis") as StringVariable;
     airTileVar           = gameVals.GetVariable("airTileType") as ObjectVariable;
     AnyPhysicalSwapMade += this.OnAnyPhysicalSwapMade;
 }
コード例 #21
0
        /// <summary>
        /// Adds a single or list variable with the given value.
        /// </summary>
        protected static void InsertVariable(LSGlobals ls, bool isCapture, bool recursive, IEnumerable <string> values, string variableName,
                                             string prefix = "", string suffix = "", bool urlEncode = false, bool createEmpty = true)
        {
            var data = ls.BotData;
            var list = values.Select(v => ReplaceValues(prefix, ls) + v.Trim() + ReplaceValues(suffix, ls)).ToList();

            if (urlEncode)
            {
                list = list.Select(v => Uri.EscapeDataString(v)).ToList();
            }

            Variable variable = null;

            if (recursive)
            {
                if (list.Count > 0 || createEmpty)
                {
                    variable = new ListOfStringsVariable(list)
                    {
                        Name = variableName
                    };
                }
            }
            else
            {
                if (list.Count == 0)
                {
                    if (createEmpty)
                    {
                        variable = new StringVariable(string.Empty)
                        {
                            Name = variableName
                        };
                    }
                }
                else
                {
                    variable = new StringVariable(list.First())
                    {
                        Name = variableName
                    };
                }
            }

            if (variable != null)
            {
                GetVariables(data).Set(variable);
                data.Logger.Log($"Parsed variable | Name: {variable.Name} | Value: {variable.AsString()}", isCapture ? LogColors.OrangeRed : LogColors.Gold);
                variable.MarkedForCapture = isCapture;
            }
            else
            {
                data.Logger.Log("Could not parse any data. The variable was not created.", LogColors.White);
            }
        }
コード例 #22
0
        public ScriptVariable Call(IList <ScriptVariable> args, ScriptConsole console)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args", "args cannot be null");
            }
            if (args.Count < 1)
            {
                throw new ArgumentException("args must have one or more elements", "args");
            }
            if (args[0] == null)
            {
                throw new ArgumentException("first element of args cannot be null", "args");
            }
            string       viewerName = args[0].ToString();
            SequenceView viewer     = SequenceViewerController.Singleton.GetViewByTitle(viewerName);

            if (viewer == null)
            {
                throw new ArgumentException("first element of args must be resultSequence name : " + viewerName, "args");
            }

            SequenceProcEnv env2 = new SequenceProcEnv(console.SequenceController, viewer.Sequence);

            IList <ProcParam <SequenceProcEnv> > parameters = this.Operation.GetParameters() ?? new ProcParam <SequenceProcEnv> [0];

            if (args.Count != parameters.Count + 1)
            {
                throw new ArgumentException(string.Format(global::MotionDataHandler.Properties.Settings.Default.Msg_NumberOfArgumentsRequired, parameters.Count + 1));
            }
            for (int i = 0; i < parameters.Count; i++)
            {
                string errorStr = "";
                if (!parameters[i].FromScriptVariable(env2, args[i + 1], ref errorStr))
                {
                    throw new ArgumentException(string.Format(global::MotionDataHandler.Properties.Settings.Default.Msg_InvalidNthArgument + ": {1}", i + 1, errorStr ?? ""), "args");
                }
            }
            SequenceData   resultSequence = this.Operation.Operate(parameters, env2);
            ScriptVariable ret            = null;

            if (resultSequence != null)
            {
                console.SequenceController.AddSequence(resultSequence, viewer.IsLocked);
                ret = new StringVariable(resultSequence.Title);
            }
            console.SequenceController.DoAllocationChanged();

            if (this.Operation.ReplacesInternalData)
            {
                env2.SelectedSequence.IsDataChanged = true;
            }

            return(ret);
        }
コード例 #23
0
ファイル: AvatarShape.cs プロジェクト: menduz/explorer
        void Awake()
        {
            currentPlayerInfoCardId = Resources.Load <StringVariable>(CURRENT_PLAYER_ID);

            if (string.IsNullOrEmpty(currentSerialization))
            {
                SetMinimapRepresentationActive(false);
            }

            onPointerDown.OnPointerDownReport += PlayerClicked;
        }
コード例 #24
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            StringVariable myScript = (StringVariable)target;

            if (GUILayout.Button("Invoke"))
            {
                myScript.ValueChangedEvent.Invoke();
            }
        }
コード例 #25
0
        public void Get_WasNotSet_ReturnsDefaultValue()
        {
            var variable1 = new IntVariable("Var1", 1);
            var variable2 = new StringVariable("Var2", "default");

            Assert.That(variable1.DefaultValue, Is.EqualTo(1));
            Assert.That(variable1.Get(_storage), Is.EqualTo(variable1.DefaultValue));

            Assert.That(variable2.DefaultValue, Is.EqualTo("default"));
            Assert.That(variable2.Get(_storage), Is.EqualTo(variable2.DefaultValue));
        }
コード例 #26
0
    public void SetValue(StringVariable value)
    {
        Value = value.Value;

        RiseOnChange();

        if (isPersistent)
        {
            Save();
        }
    }
コード例 #27
0
        public override ScriptVariable ToScriptVariable(SequenceProcEnv environment)
        {
            List <ScriptVariable> list = new List <ScriptVariable>();

            foreach (var pair in this.Value)
            {
                StringVariable key   = new StringVariable(pair.Key);
                StringVariable value = new StringVariable(pair.Value);
                list.Add(new ListVariable(key, value));
            }
            return(new ListVariable(list));
        }
コード例 #28
0
 public void OnConditionEventOccured(StringVariable eventCondition)
 {
     for (int i = 0; i < conditions.Count; i++)
     {
         if (conditions[i].eventCondition == eventCondition)
         {
             conditions[i].occured = true;
             CheckAllConditionsOccured();
             return;
         }
     }
 }
コード例 #29
0
        public override void OnEnter()
        {
            if (key == "" ||
                variable == null)
            {
                Continue();
                return;
            }

            var flowchart = GetFlowchart();

            // Prepend the current save profile (if any)
            string prefsKey = SetSaveProfile.saveProfile + "_" + flowchart.SubstituteVariables(key);

            System.Type variableType = variable.GetType();

            if (variableType == typeof(BooleanVariable))
            {
                BooleanVariable booleanVariable = variable as BooleanVariable;
                if (booleanVariable != null)
                {
                    // PlayerPrefs does not have bool accessors, so just use int
                    booleanVariable.Value = (PlayerPrefs.GetInt(prefsKey) == 1);
                }
            }
            else if (variableType == typeof(IntegerVariable))
            {
                IntegerVariable integerVariable = variable as IntegerVariable;
                if (integerVariable != null)
                {
                    integerVariable.Value = PlayerPrefs.GetInt(prefsKey);
                }
            }
            else if (variableType == typeof(FloatVariable))
            {
                FloatVariable floatVariable = variable as FloatVariable;
                if (floatVariable != null)
                {
                    floatVariable.Value = PlayerPrefs.GetFloat(prefsKey);
                }
            }
            else if (variableType == typeof(StringVariable))
            {
                StringVariable stringVariable = variable as StringVariable;
                if (stringVariable != null)
                {
                    stringVariable.Value = PlayerPrefs.GetString(prefsKey);
                }
            }

            Continue();
        }
コード例 #30
0
        public string GetVariable(string varName)
        {
            StringVariable stringVar = globalVars.GetVariable(varName) as StringVariable;

            if (stringVar == null)
            {
                return(null);
            }
            else
            {
                return(stringVar.Value);
            }
        }