Exemple #1
0
        public void BuildFromAction(ConditionalVelocityAction cva)
        {
            Action = cva;

            TBName.Text           = Action.Name;
            TBTimout.Text         = Action.Timeout.ToString();
            CBFirst.SelectedItem  = Logic.IntToString(Action.FirstBodyPart);
            CBRel.SelectedItem    = Logic.IntToString(Action.VelocityRelationship);
            CBSecond.SelectedItem = Logic.IntToString(Action.ConditionalBodyPart);
            CBCRel.SelectedItem   = Logic.IntToString(Action.ConditionRelationship);
            TBVal.Text            = Action.RelationshipValue.ToString();
            TBActionEndPoint.Text = Action.PassAction.Name;

            BEdit.Enabled = true;
        }
        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);
        }