Esempio n. 1
0
        public InputAxis Union(InputAxis other)
        {
            if (other == null)
            {
                return(this);
            }

            if (other.Parameters.Count == 0)
            {
                return(this);
            }

            if (other.Parameters.Count == 1)
            {
                if (other.Parameters[0] is InputParameterEnumeration)
                {
                    return(this);
                }

                var ret = new InputAxis(ReadableName, Origin)
                {
                    KBRecord = KBRecord
                };

                float newmin = Math.Min((Parameters[0] as InputParameterNumeric).MinimumValue, (other.Parameters[0] as InputParameterNumeric).MinimumValue);
                float newmax = Math.Max((Parameters[0] as InputParameterNumeric).MaximumValue, (other.Parameters[0] as InputParameterNumeric).MaximumValue);

                var param = new InputParameterNumeric(Parameters[0].ReadableName, newmin, newmax);
                ret.Parameters.Add(param);

                return(ret);
            }

            return(null);
        }
Esempio n. 2
0
 public void CopyFrom(Consideration other)
 {
     ReadableName = other.ReadableName;
     Input        = other.Input;
     Curve.CopyFrom(other.Curve);
     ParameterValues = other.ParameterValues;
 }
Esempio n. 3
0
        public InputAxis Union(InputAxis other)
        {
            if (other == null)
            {
                return(this);
            }

            if (other.Parameters.Count == 0)
            {
                return(this);
            }

            if (other.Parameters.Count == 1)
            {
                var ret = new InputAxis(ReadableName, Origin);
                ret.KBRecord     = KBRecord;
                ret.ReadableName = ReadableName;

                float newmin = Math.Min(Parameters[0].MinimumValue, other.Parameters[0].MinimumValue);
                float newmax = Math.Max(Parameters[0].MaximumValue, other.Parameters[0].MaximumValue);

                var param = new InputParameter(Parameters[0].ReadableName, newmin, newmax);
                ret.Parameters.Add(param);

                return(ret);
            }

            return(null);
        }
Esempio n. 4
0
        public double GetInputValue(InputAxis axis, Scenario.Context context)
        {
            if (context == null)
            {
                return(GetInputValue(axis));
            }

            // TODO - figure out what input this should link to and retrieve the corresponding value
            return(0.0);
        }
Esempio n. 5
0
        public double GetInputValue(InputAxis axis)
        {
            foreach (EditWidgetConsiderationInput input in InputFlowPanel.Controls)
            {
                if (input.Tag == axis)
                {
                    return(input.GetRawValue());
                }
            }

            return(0.0);
        }
Esempio n. 6
0
        private void RefreshInputControls()
        {
            foreach (Control ctl in InputFlowPanel.Controls)
            {
                ctl.Dispose();
            }

            InputFlowPanel.Controls.Clear();

            var inputs = new Dictionary <InputAxis, List <InputAxis> >();

            foreach (Behavior b in EnabledBehaviorsListBox.CheckedItems)
            {
                foreach (Consideration c in b.Considerations)
                {
                    if (c.Input == null || c.Input.KBRec == null)
                    {
                        continue;
                    }

                    if (!inputs.ContainsKey(c.Input))
                    {
                        inputs.Add(c.Input, new List <InputAxis>());
                    }

                    var clamped = c.Input.Clamp(c.ParameterValues);
                    inputs[c.Input].Add(clamped);
                }
            }

            foreach (var kvp in inputs)
            {
                InputAxis union = null;
                foreach (var input in kvp.Value)
                {
                    union = input.Union(union);
                }

                if (union == null)
                {
                    continue;
                }

                var widget = new EditWidgetConsiderationInput(union, this)
                {
                    Tag = kvp.Key
                };
                InputFlowPanel.Controls.Add(widget);
            }

            RefreshInputs();
        }
Esempio n. 7
0
        public InputAxis Clamp(List <InputParameterValue> parameters)
        {
            if (parameters == null)
            {
                return(this);
            }

            if (parameters.Count == 0)
            {
                return(this);
            }

            if (parameters.Count == 1)
            {
                if (parameters[0] is InputParameterValueEnumeration)
                {
                    return(this);
                }

                var ret = new InputAxis(ReadableName, Origin)
                {
                    KBRecord = KBRecord
                };

                float newmin = (Parameters[0] as InputParameterNumeric).MinimumValue;
                float newmax = Math.Min((Parameters[0] as InputParameterNumeric).MaximumValue, (parameters[0] as InputParameterValueNumeric).Value);

                var param = new InputParameterNumeric(Parameters[0].ReadableName, newmin, newmax);
                ret.Parameters.Add(param);

                return(ret);
            }

            if (parameters.Count == 2)
            {
                var ret = new InputAxis(ReadableName, Origin)
                {
                    KBRecord = KBRecord
                };

                float newmin = Math.Max((Parameters[0] as InputParameterNumeric).MinimumValue, (parameters[0] as InputParameterValueNumeric).Value);
                float newmax = Math.Min((Parameters[1] as InputParameterNumeric).MaximumValue, (parameters[1] as InputParameterValueNumeric).Value);

                var param = new InputParameterNumeric(Parameters[0].ReadableName, newmin, newmax);
                ret.Parameters.Add(param);

                return(ret);
            }

            return(this);
        }
Esempio n. 8
0
        internal EditWidgetInputAxis(Project project, InputAxis axis)
        {
            InitializeComponent();
            EditedAxis    = axis;
            EditedProject = project;

            EditedAxis.DialogRebuildNeeded += Rebuild;

            NameEditWidget.Attach("Input Axis", axis);

            InputTypeComboBox.SelectedIndex = (int)axis.Origin;

            EditedAxis.ParametersChanged += (obj, args) =>
            {
                GenerateParameterControls();
            };
        }
Esempio n. 9
0
        public InputAxis Clamp(List <InputParameterValue> parameters)
        {
            if (parameters == null)
            {
                return(this);
            }

            if (parameters.Count == 0)
            {
                return(this);
            }

            if (parameters.Count == 1)
            {
                var ret = new InputAxis(ReadableName, Origin);
                ret.KBRecord     = KBRecord;
                ret.ReadableName = ReadableName;

                float newmin = Math.Max(Parameters[0].MinimumValue, parameters[0].Value);
                float newmax = Math.Min(Parameters[0].MaximumValue, parameters[0].Value);

                var param = new InputParameter(Parameters[0].ReadableName, newmin, newmax);
                ret.Parameters.Add(param);

                return(ret);
            }

            if (parameters.Count == 2)
            {
                var ret = new InputAxis(ReadableName, Origin);
                ret.KBRecord     = KBRecord;
                ret.ReadableName = ReadableName;

                float newmin = Math.Max(Parameters[0].MinimumValue, parameters[0].Value);
                float newmax = Math.Min(Parameters[1].MaximumValue, parameters[1].Value);

                var param = new InputParameter(Parameters[0].ReadableName, newmin, newmax);
                ret.Parameters.Add(param);

                return(ret);
            }

            return(this);
        }
Esempio n. 10
0
        public void Delete(InputAxis input)
        {
            Inputs.Remove(input);

            foreach (var b in Behaviors)
            {
                foreach (var c in b.Considerations)
                {
                    if (c.Input == input)
                    {
                        c.Input = null;
                    }
                }
            }

            ItemDelete(this, new DeletionEventArgs {
                DeletedObject = input
            });
        }
Esempio n. 11
0
        internal EditWidgetConsiderationInput(InputAxis axis, IInputBroker broker)
        {
            InitializeComponent();
            EditingAxis = axis;
            InputBroker = broker;

            InputValueTrackBar.Minimum = 0;
            InputValueTrackBar.Maximum = 100;

            if ((EditingAxis != null) && (EditingAxis.Parameters != null))
            {
                if (EditingAxis.Parameters.Count == 0)
                {
                    InputValueTrackBar.Visible = false;
                }
                else if (EditingAxis.Parameters.Count == 1)
                {
                    InputValueTrackBar.Minimum = (int)(EditingAxis.Parameters[0].MinimumValue * 100.0f);
                    InputValueTrackBar.Maximum = (int)(EditingAxis.Parameters[0].MaximumValue * 100.0f);
                }
                else if (EditingAxis.Parameters.Count == 2)
                {
                    InputValueTrackBar.Minimum = (int)(EditingAxis.Parameters[0].MinimumValue * 100.0f);
                    InputValueTrackBar.Maximum = (int)(EditingAxis.Parameters[1].MaximumValue * 100.0f);
                }
                else
                {
                    // TODO - handle this?
                }
            }

            int range = InputValueTrackBar.Maximum - InputValueTrackBar.Minimum;

            InputValueTrackBar.SmallChange   = range / 10;
            InputValueTrackBar.LargeChange   = range / 4;
            InputValueTrackBar.TickFrequency = range / 25;

            InputValueTrackBar.Value = InputValueTrackBar.Minimum + (range / 2);
            InputValueTrackBar_Scroll(null, null);
        }
Esempio n. 12
0
        public double GetInputValue(InputAxis axis, Context context)
        {
            double raw = 0.0;

            switch (axis.Origin)
            {
            case InputAxis.OriginType.ComputedValue:
                // TODO - compute stuff that isn't distance
                raw = Distance(context.ThinkingAgent.GetPosition(), context.Target.GetPosition());
                break;

            case InputAxis.OriginType.PropertyOfSelf:
                raw = context.ThinkingAgent.GetProperty(axis.KBRec.ReadableName);
                break;

            case InputAxis.OriginType.PropertyOfTarget:
                raw = context.Target.GetProperty(axis.KBRec.ReadableName);
                break;
            }

            return(raw);
        }
 public double GetInputValue(InputAxis axis, Scenario.Context context)
 {
     return(0.0);
 }
        internal void Attach(Behavior behavior)
        {
            foreach (Control ctl in ScoreLayoutPanel.Controls)
            {
                ctl.Dispose();
            }

            ScoreLayoutPanel.Controls.Clear();


            foreach (Control ctl in InputFlowPanel.Controls)
            {
                ctl.Dispose();
            }

            InputFlowPanel.Controls.Clear();


            EditBehavior = behavior;
            NameEditWidget.Attach("Behavior", EditBehavior);
            if (!string.IsNullOrEmpty(EditBehavior.Payload))
            {
                CustomPayload.Text = EditBehavior.Payload;
            }
            else
            {
                CustomPayload.Text = "";
            }

            EditBehavior.DialogRebuildNeeded += Rebuild;

            BehaviorWeightEditBox.Value = (decimal)EditBehavior.Weight;

            ActionComboBox.SelectedIndex    = (int)EditBehavior.Action;
            CanTargetSelfCheckBox.Checked   = EditBehavior.CanTargetSelf;
            CanTargetOthersCheckBox.Checked = EditBehavior.CanTargetOthers;

            var inputs = new Dictionary <InputAxis, List <InputAxis> >();

            foreach (var consideration in EditBehavior.Considerations)
            {
                if (consideration.Input != null)
                {
                    if (!inputs.ContainsKey(consideration.Input))
                    {
                        inputs.Add(consideration.Input, new List <InputAxis>());
                    }

                    var clamped = consideration.Input.Clamp(consideration.ParameterValues);
                    inputs[consideration.Input].Add(clamped);

                    ScoreLayoutPanel.Controls.Add(new EditWidgetConsiderationScore(consideration, this));
                }
            }

            foreach (var kvp in inputs)
            {
                InputAxis union = null;
                foreach (var input in kvp.Value)
                {
                    union = input.Union(union);
                }

                if (union == null)
                {
                    continue;
                }

                var widget = new EditWidgetConsiderationInput(union, this);
                widget.Tag = kvp.Key;
                InputFlowPanel.Controls.Add(widget);
            }

            RefreshInputs();
        }
Esempio n. 15
0
        internal EditWidgetConsiderationInput(InputAxis axis, IInputBroker broker)
        {
            InitializeComponent();
            EditingAxis = axis;
            InputBroker = broker;

            InputValueTrackBar.Minimum = 0;
            InputValueTrackBar.Maximum = 100;

            InputValueDropDown.Visible = false;

            if ((EditingAxis != null) && (EditingAxis.Parameters != null))
            {
                if (EditingAxis.Parameters.Count == 1)
                {
                    var rawparam = EditingAxis.Parameters[0];
                    if (rawparam is InputParameterNumeric)
                    {
                        var numericparam = rawparam as InputParameterNumeric;
                        InputValueTrackBar.Minimum = (int)(numericparam.MinimumValue * 100.0f);
                        InputValueTrackBar.Maximum = (int)(numericparam.MaximumValue * 100.0f);
                    }
                    else if (rawparam is InputParameterEnumeration)
                    {
                        InputValueTrackBar.Visible = false;
                        InputValueDropDown.Visible = true;
                        InputValueDropDown.Items.Clear();

                        var penum = rawparam as InputParameterEnumeration;
                        foreach (var valid in penum.ValidValues)
                        {
                            InputValueDropDown.Items.Add(valid);
                        }

                        if (penum.ValidValues.Count > 0)
                        {
                            InputValueDropDown.SelectedIndex = 0;
                        }
                    }
                }
                else if (EditingAxis.Parameters.Count == 2)
                {
                    InputValueTrackBar.Minimum = (int)((EditingAxis.Parameters[0] as InputParameterNumeric).MinimumValue * 100.0f);
                    InputValueTrackBar.Maximum = (int)((EditingAxis.Parameters[1] as InputParameterNumeric).MaximumValue * 100.0f);
                }
                else
                {
                    InputValueTrackBar.Visible = false;
                }
            }

            if (InputValueTrackBar.Visible)
            {
                int range = InputValueTrackBar.Maximum - InputValueTrackBar.Minimum;
                InputValueTrackBar.SmallChange   = range / 10;
                InputValueTrackBar.LargeChange   = range / 4;
                InputValueTrackBar.TickFrequency = range / 25;

                InputValueTrackBar.Value = InputValueTrackBar.Minimum + (range / 2);
                InputValueTrackBar_Scroll(null, null);
            }
        }
Esempio n. 16
0
 public void RegisterInput(InputAxis axis)
 {
     Inputs.Add(axis);
     InputLookupByName.Add(axis.ReadableName, axis);
 }
Esempio n. 17
0
 public double GetInputValue(InputAxis axis)
 {
     return(0.0);
 }