예제 #1
0
        protected override void OnEnter()
        {
            Variable var   = GetInput("Value");
            int      value = var.ConvertedValue <int>();

            int smallest = -1;
            Pin pin      = null;

            foreach (var w in Weights)
            {
                Variable wv     = Variables.GetByName(w.VariableName);
                int      weight = wv.ConvertedValue <int>();
                if (weight == value)
                {
                    pin = PinCollection.Get(w.OutputName);
                    break;
                }
                else if (weight > value && smallest > weight)
                {
                    pin      = PinCollection.Get(w.OutputName);
                    smallest = weight;
                }
            }
            _calculatedNextNode = pin;
            IsFinished          = true;
        }
예제 #2
0
        protected override void OnEnter()
        {
            Variable input = GetInput("Condition");
            string   name  = (input.ConvertedValue <bool>()) ? "True" : "False";

            _calculatedNextNode = PinCollection.Get(name);
            IsFinished          = true;
        }
예제 #3
0
        protected override void OnInit()
        {
            PinCollection.AddInput("Input", typeof(object));
            var input = PinCollection.Get("Input");

            input.IsDynamicType = true;

            PinCollection.AddOutput("Result", typeof(string));
        }
예제 #4
0
        public void ChangeVariable(string name)
        {
            VariableName = name;
            Variable v = GetVariable();

            if (v == null)
            {
                VariableName = "";
            }

            var value = PinCollection.Get("Value");

            value.VariableType = (v != null) ? v.type : typeof(object);
            HasChanges         = true;
            Root.HasChanges    = true;
        }
예제 #5
0
        void onInputTypeChanged(bool wasInput, bool isInput)
        {
            var pin = PinCollection.Get("Value");

            if (pin != null)
            {
                Pin.Disconnect(pin);
            }

            PinCollection.Clear();
            if (IsInput)
            {
                PinCollection.AddInput("Value", Type);
            }
            else
            {
                PinCollection.AddOutput("Value", Type);
            }
        }
예제 #6
0
        void onInputTypeChanged(bool wasInput, bool isInput)
        {
            string removeName = (IsInput) ? "OUT" : "IN";
            var    pin        = PinCollection.Get(removeName);

            if (pin != null)
            {
                Pin.Disconnect(pin);
            }

            PinCollection.Clear();
            if (IsInput)
            {
                PinCollection.AddInTransition("IN");
            }
            else
            {
                PinCollection.AddOutTransition("OUT");
            }
        }
예제 #7
0
        /// <summary>
        /// Changes the variable to another one.
        /// </summary>
        /// <param name="name"></param>
        public void ChangeVariable(string name)
        {
            VariableName = name;
            Variable variable = GetVariable();

            if (variable == null)
            {
                VariableName = "";
            }

            var value = PinCollection.Get("Value");

            value.VariableType = (variable != null) ? variable.type : typeof(object);

            var newValue = PinCollection.Get("NewValue");

            newValue.VariableType = (variable != null) ? variable.type : typeof(object);

            RemoveStoredVariable("NewValue");

            HasChanges      = true;
            Root.HasChanges = true;
        }
예제 #8
0
 public void SelectAnswer(string outputName)
 {
     _calculatedNextNode = PinCollection.Get(outputName);
     IsFinished          = true;
 }