コード例 #1
0
        // Convert one condition from object builder to in-game representation.
        private static MyCondition <float> ParseOneCondition(MyAnimationController animationController,
                                                             MyObjectBuilder_AnimationSMCondition objBuilderCondition)
        {
            MyCondition <float> condition;

            if (objBuilderCondition.ValueLeft == null || objBuilderCondition.ValueRight == null)
            {
                Debug.Fail("Missing operand in transition condition.");
                return(null);
            }

            double lhs, rhs;

            if (Double.TryParse(objBuilderCondition.ValueLeft, out lhs))
            {
                if (Double.TryParse(objBuilderCondition.ValueRight, out rhs))
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition <float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation), (float)lhs,
                            (float)rhs);
                }
                else
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition <float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation), (float)lhs,
                            objBuilderCondition.ValueRight);
                }
            }
            else
            {
                if (Double.TryParse(objBuilderCondition.ValueRight, out rhs))
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition <float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation),
                            objBuilderCondition.ValueLeft, (float)rhs);
                }
                else
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition <float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation),
                            objBuilderCondition.ValueLeft, objBuilderCondition.ValueRight);
                }
            }
            return(condition);
        }
コード例 #2
0
        // Convert one condition from object builder to in-game representation.
        private static MyCondition <float> ParseOneCondition(MyAnimationController animationController,
                                                             MyObjectBuilder_AnimationSMCondition objBuilderCondition)
        {
            MyCondition <float> condition;

            objBuilderCondition.ValueLeft = objBuilderCondition.ValueLeft != null?objBuilderCondition.ValueLeft.ToLower() : "0";

            objBuilderCondition.ValueRight = objBuilderCondition.ValueRight != null?objBuilderCondition.ValueRight.ToLower() : "0";

            double lhs, rhs;

            if (Double.TryParse(objBuilderCondition.ValueLeft, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out lhs))
            {
                if (Double.TryParse(objBuilderCondition.ValueRight, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out rhs))
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition <float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation), (float)lhs,
                            (float)rhs);
                }
                else
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition <float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation), (float)lhs,
                            objBuilderCondition.ValueRight);
                }
            }
            else
            {
                if (Double.TryParse(objBuilderCondition.ValueRight, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out rhs))
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition <float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation),
                            objBuilderCondition.ValueLeft, (float)rhs);
                }
                else
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition <float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation),
                            objBuilderCondition.ValueLeft, objBuilderCondition.ValueRight);
                }
            }
            return(condition);
        }
        // Convert one condition from object builder to in-game representation.
        private static MyCondition<float> ParseOneCondition(MyAnimationController animationController,
            MyObjectBuilder_AnimationSMCondition objBuilderCondition)
        {
            MyCondition<float> condition;

            objBuilderCondition.ValueLeft = objBuilderCondition.ValueLeft != null ? objBuilderCondition.ValueLeft.ToLower() : "0";
            objBuilderCondition.ValueRight = objBuilderCondition.ValueRight != null ? objBuilderCondition.ValueRight.ToLower() : "0";
            double lhs, rhs;
            if (Double.TryParse(objBuilderCondition.ValueLeft, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out lhs))
            {
                if (Double.TryParse(objBuilderCondition.ValueRight, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out rhs))
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition<float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation), (float) lhs,
                            (float) rhs);
                }
                else
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition<float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation), (float) lhs,
                            objBuilderCondition.ValueRight);
                }
            }
            else
            {
                if (Double.TryParse(objBuilderCondition.ValueRight, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out rhs))
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition<float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation),
                            objBuilderCondition.ValueLeft, (float) rhs);
                }
                else
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition<float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation),
                            objBuilderCondition.ValueLeft, objBuilderCondition.ValueRight);
                }
            }
            return condition;
        }
        // Convert one condition from object builder to in-game representation.
        private static MyCondition<float> ParseOneCondition(MyAnimationController animationController,
            MyObjectBuilder_AnimationSMCondition objBuilderCondition)
        {
            MyCondition<float> condition;
            if (objBuilderCondition.ValueLeft == null || objBuilderCondition.ValueRight == null)
            {
                Debug.Fail("Missing operand in transition condition.");
                return null;
            }

            double lhs, rhs;
            if (Double.TryParse(objBuilderCondition.ValueLeft, out lhs))
            {
                if (Double.TryParse(objBuilderCondition.ValueRight, out rhs))
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition<float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation), (float) lhs,
                            (float) rhs);
                }
                else
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition<float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation), (float) lhs,
                            objBuilderCondition.ValueRight);
                }
            }
            else
            {
                if (Double.TryParse(objBuilderCondition.ValueRight, out rhs))
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition<float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation),
                            objBuilderCondition.ValueLeft, (float) rhs);
                }
                else
                {
                    condition =
                        new VRage.Generics.StateMachine.MyCondition<float>(
                            animationController.Variables,
                            ConvertOperation(objBuilderCondition.Operation),
                            objBuilderCondition.ValueLeft, objBuilderCondition.ValueRight);
                }
            }
            return condition;
        }