Ejemplo n.º 1
0
 public void BuildFromAction(VelocityAction pastAction)
 {
     TBName.Text          = pastAction.Name;
     TBTimout.Text        = pastAction.Timeout.ToString();
     CBFirst.SelectedItem = Logic.IntToString(pastAction.FirstBodyPart);
     CBRel.SelectedItem   = Logic.IntToString(pastAction.Relationship);
     TBVal.Text           = pastAction.RelationshipValue.ToString();
 }
Ejemplo n.º 2
0
        private void BBuild_Click(object sender, EventArgs e)
        {
            Action               = new VelocityAction();
            Action.Name          = TBName.Text;
            Action.FirstBodyPart = Logic.StringsToInt(CBFirst.Text);
            Action.Relationship  = Logic.StringsToInt(CBRel.Text);

            try
            {
                Action.Timeout = float.Parse(TBTimout.Text);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Timeout value must be a float");
                return;
            }

            try
            {
                Action.RelationshipValue = float.Parse(TBVal.Text);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Relationship value must be an float");

                return;
            }

            if (TBName.Text.Trim() == "")
            {
                MessageBox.Show("Action name must not be empty");
                return;
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
        private Action LoadAction(StreamReader streamReader)
        {
            Action action = null;

            string line = streamReader.ReadLine();//read ActionType:
            string type = line.Substring(11);

            if (type == "Position")
            {
                PositionAction posAction = new PositionAction();
                posAction.Name           = streamReader.ReadLine().Substring(11);                            //read name:
                posAction.Timeout        = float.Parse(streamReader.ReadLine().Substring(8));                //read FBP:
                posAction.FirstBodyPart  = int.Parse(streamReader.ReadLine().Substring(4));                  //read FBP:
                posAction.Relationship   = int.Parse(streamReader.ReadLine().Substring(9));                  //read Relationship:
                posAction.SecondBodyPart = int.Parse(streamReader.ReadLine().Substring(4));                  //read SBP:
                posAction.UpperBoundsRelationshipValue = float.Parse(streamReader.ReadLine().Substring(17)); //read UpperBoundsValue:
                posAction.LowerBoundsRelationshipValue = float.Parse(streamReader.ReadLine().Substring(17)); //read LowerBoundsValue:

                action = posAction;
            }

            else if (type == "Velocity")
            {
                VelocityAction velAction = new VelocityAction();
                velAction.Name              = streamReader.ReadLine().Substring(11);             //read name:
                velAction.Timeout           = float.Parse(streamReader.ReadLine().Substring(8)); //read FBP:
                velAction.FirstBodyPart     = int.Parse(streamReader.ReadLine().Substring(4));   //read FBP:
                velAction.Relationship      = int.Parse(streamReader.ReadLine().Substring(9));   //read Relationship:
                velAction.RelationshipValue = float.Parse(streamReader.ReadLine().Substring(6)); //read RelationshipL:

                action = velAction;
            }

            else if (type == "ConditionalVelocity")
            {
                ConditionalVelocityAction velAction = new ConditionalVelocityAction();
                velAction.Name                  = streamReader.ReadLine().Substring(11);              //read name:
                velAction.Timeout               = float.Parse(streamReader.ReadLine().Substring(8));  //read FBP:
                velAction.FirstBodyPart         = int.Parse(streamReader.ReadLine().Substring(4));    //read FBP:
                velAction.VelocityRelationship  = int.Parse(streamReader.ReadLine().Substring(17));   //read VelocityRelation:
                velAction.ConditionalBodyPart   = int.Parse(streamReader.ReadLine().Substring(12));   //read ConditionBP:
                velAction.ConditionRelationship = int.Parse(streamReader.ReadLine().Substring(24));   //read ConditionalRelationship:
                velAction.RelationshipValue     = float.Parse(streamReader.ReadLine().Substring(14)); //read VelocityValue:

                if (streamReader.ReadLine() == "-----InnerAction-----")
                {
                    velAction.PassAction = ( AndAction )LoadAction(streamReader);
                }

                action = velAction;
            }

            else if (type == "And")
            {
                AndAction andAction = new AndAction();
                andAction.Name    = streamReader.ReadLine().Substring(11);             //read name:
                andAction.Timeout = float.Parse(streamReader.ReadLine().Substring(8)); //read FBP:

                while (true)
                {
                    line = streamReader.ReadLine();
                    if (line == "-----MultiEnd-----")
                    {
                        break;
                    }
                    else if (line == "-----InnerAction-----")
                    {
                        andAction.AddAction(LoadAction(streamReader));
                    }
                }

                action = andAction;
            }

            else if (type == "Or")
            {
                OrAction andAction = new OrAction();
                andAction.Name    = streamReader.ReadLine().Substring(11);             //read name:
                andAction.Timeout = float.Parse(streamReader.ReadLine().Substring(8)); //read FBP:

                while (true)
                {
                    line = streamReader.ReadLine();
                    if (line == "-----MultiEnd-----")
                    {
                        break;
                    }
                    else if (line == "-----InnerAction-----")
                    {
                        andAction.AddAction(LoadAction(streamReader));
                    }
                }

                action = andAction;
            }

            else if (type == "Time")
            {
                TimeAction timeAction = new TimeAction();
                timeAction.Name       = streamReader.ReadLine().Substring(11);              //read name:
                timeAction.Timeout    = float.Parse(streamReader.ReadLine().Substring(8));  //read FBP:
                timeAction.TimeToPass = float.Parse(streamReader.ReadLine().Substring(11)); //read TimeToPass

                action = timeAction;
            }

            return(action);
        }