Beispiel #1
0
	public void SetVariable(HamTimeline timeline, int id)
	{
		if (id == HamTimeline.InvalidID)
		{
			this.Operand = null;
		}
		else
		{
			this.Operand = new VariableValue(timeline.Variables[id]);
		}
		this.VariableID = id;
	}	
Beispiel #2
0
	public void Unpack(DataUnpacker unpacker)
	{
		this.timeline = new HamTimeline();
		this.timeline.Unpack(unpacker);

		int varSize;
		unpacker.Unpack(out varSize);
		for (int i = 0; i < varSize; ++i)
		{
			int key;
			unpacker.Unpack(out key);
			VariableValue val = new VariableValue();
			val.Unpack(unpacker);
			this.variables[key] = val;
		}
		unpacker.Unpack(out this.currentNodeID);
		unpacker.Unpack(out this.currentSceneID);

		int charSize;
		unpacker.Unpack(out charSize);
		for (int i = 0; i < charSize; ++i)
		{
			int next;
			unpacker.Unpack(out next);
			this.currentCharactersInScene.Add(next);
		}

		int historySize;
		unpacker.Unpack(out historySize);
		for (int i = 0; i < historySize; ++i)
		{
			int history;
			unpacker.Unpack(out history);
			this.nodeHistory.Add(history);
		}
	}
Beispiel #3
0
	public void Execute(VariableValue instanceVal)
	{
		instanceVal.Operate(this.Operator, this.Operand);
	}
Beispiel #4
0
	public HamOperation()
	{
		this.VariableID = HamTimeline.InvalidID;
		this.Operator = VariableOperation.Set;
		this.Operand = null;
	}
        static SendReply CreateSendReply(ModelItem target, object context)
        {
            SendReply reply = null;
            ModelItem receive = (ModelItem)context;
            if (null != receive)
            {
                Receive receiveInstance = (Receive)receive.GetCurrentValue();
                string name = null;
                //if no correlation is set - create one
                if (null == receiveInstance.CorrelatesWith)
                {
                    Variable handleVariable = null;
                    //first, look for nearest variable scope 
                    ModelItemCollection variableScope = VariableHelper.FindRootVariableScope(receive).GetVariableCollection();
                    if (null != variableScope)
                    {
                        ModelItemCollection correlations = receive.Properties["CorrelationInitializers"].Collection;
                        bool hasRequestReplyHandle = false;
                        foreach (ModelItem item in correlations)
                        {
                            if (item.ItemType.IsAssignableFrom(typeof(RequestReplyCorrelationInitializer)))
                            {
                                hasRequestReplyHandle = true;
                                break;
                            }
                        }

                        if (!hasRequestReplyHandle)
                        {
                            //create unique variable name
                            name = variableScope.CreateUniqueVariableName("__handle", 1);
                            //create variable
                            handleVariable = Variable.Create(name, typeof(CorrelationHandle), VariableModifiers.None);
                            //add it to the scope
                            variableScope.Add(handleVariable);
                            //setup correlation
                            ImportDesigner.AddImport(CorrelationHandleTypeNamespace, receive.GetEditingContext());
                            VariableValue<CorrelationHandle> expression = new VariableValue<CorrelationHandle> { Variable = handleVariable };
                            InArgument<CorrelationHandle> handle = new InArgument<CorrelationHandle>(expression);
                            correlations.Add(new RequestReplyCorrelationInitializer { CorrelationHandle = handle });
                        }
                    }
                }

                reply = new SendReply()
                {
                    DisplayName = string.Format(CultureInfo.CurrentUICulture, "SendReplyTo{0}", receive.Properties["DisplayName"].ComputedValue),
                    Request = (Receive)receive.GetCurrentValue(),
                };
            }
            else
            {
                MessageBox.Show(
                    (string)StringResourceDictionary.Instance["receiveActivityCreateReplyErrorLabel"] ?? "Source 'Reply' element not found!",
                    (string)StringResourceDictionary.Instance["MessagingActivityTitle"] ?? "Send",
                    MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return reply;
        }
Beispiel #6
0
 private void VariableValueField(VariableValue varValue)
 {
     switch (varValue.Type)
     {
         case VariableType.Boolean:
         {
             bool bVal = varValue.Get<bool>();
             if (GUILayout.Button(bVal.ToString()))
             {
                 varValue.Set(!bVal);
             }
             break;
         }
         case VariableType.Integer:
         {
             int iVal = varValue.Get<int>();
             string stringVal = GUILayout.TextField(iVal.ToString());
             int cVal;
             if (Int32.TryParse(stringVal, out cVal) && cVal != iVal)
             {
                 varValue.Set(cVal);
             }
             break; 
         }
     } 
 }
Beispiel #7
0
        public void Localtime_should_return_current_Unix_time()
        {
            var value = _callerUnderTest.Call(BuiltinFunctionCall.Localtime);

            Assert.NotEqual(VariableValue.NewNumber(0), value);
        }
Beispiel #8
0
 private void CreateVariable(string VariableName, int Itterations)
 {
     try
     {
         Variable Variable = new Variable();
         VariableValue VariableValue = null;
         Variable.Name = VariableName;
         int CurrentItteration = 0;
         if (Itterations < 0)
             Itterations = 1;
         while (!(CurrentItteration == Itterations))
         {
             VariableValue = new VariableValue();
             VariableValue.Value = "";
             Variable.Values.Add(VariableValue);
             CurrentItteration++;
         }
         Variables.Add(Variable);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Beispiel #9
0
 public SetVariableResult SetVariable(string name, VariableValue value) => _traitStore.SetVariable(name, value);
Beispiel #10
0
 protected static VariableValue GetMoves(Creature creature) => VariableValue.Create(creature.Moves);
Beispiel #11
0
 protected static SetVariableResult SetName(Creature creature, VariableValue value) => value.TryGetString(out creature.Name) ? SetVariableResult.Success : SetVariableResult.TypeMismatch;
Beispiel #12
0
 protected static VariableValue GetName(Creature creature) => VariableValue.Create(creature.Name);
Beispiel #13
0
 protected static VariableValue GetTrainer(Creature creature) => VariableValue.Create(creature.Trainer);
Beispiel #14
0
 protected static VariableValue GetSpecies(Creature creature) => VariableValue.Create(creature.Species);
Beispiel #15
0
        public void Escape_should_escape_the_specified_characters_in_a_string_with_backslash()
        {
            var value = _callerUnderTest.Call(BuiltinFunctionCall.NewEscape(@"C:\Program Files", @" \"));

            Assert.Equal(VariableValue.NewString(@"C:\\Program\ Files"), value);
        }
Beispiel #16
0
 private void AssertValue(string name, VariableValue value)
 {
     Assert.Equal(value, _variableMap[name]);
 }
Beispiel #17
0
	public bool EvaluatePredicate(HamPredicate predicate, VariableValue instanceValue)
	{
		if (predicate.VariableID == InvalidID)
		{
			Debug.LogError("Predicate variable not set");
			return false;
		}
		HamTimelineVariable timelineVar = this.Variables[predicate.VariableID];
		return timelineVar.Compare(predicate.Comparison, instanceValue);
	}
Beispiel #18
0
 public void VariableChanged(int index, VariableValue value)
 {
     TraitChanged(index);
 }
Beispiel #19
0
 private void ExpandVariableDepth(Variable Variable, int NewItterations)
 {
     int CurrentItterations = 0;
     VariableValue VariableValue = null;
     CurrentItterations = Variable.Values.Count;
     if (NewItterations <= CurrentItterations)
         return;
     while (!(NewItterations == CurrentItterations))
     {
         VariableValue = new VariableValue();
         VariableValue.Value = "";
         Variable.Values.Add(VariableValue);
         CurrentItterations++;
     }
 }
Beispiel #20
0
        public void Exists_should_return_0_for_variable_that_does_not_exist()
        {
            var value = _callerUnderTest.Call(BuiltinFunctionCall.NewExists("x"));

            Assert.Equal(VariableValue.NewNumber(0), value);
        }