コード例 #1
0
        bool CheckIfCustomProbability()
        {
            bool customProb = false;

            VariableMixingType mixingType = (VariableMixingType)VariableProperty.FindPropertyRelative(nameof(IndependentVariable.MixingType)).intValue;

            customProb = mixingType == VariableMixingType.CustomProbability;


            return(customProb);
        }
コード例 #2
0
        protected override void DrawVariableSpecificInspector()
        {
            SerializedProperty blockProperty = VariableProperty.FindPropertyRelative(nameof(IndependentVariable.Block));

            CheckMaxBlockPermutationsAllowed(blockProperty.boolValue);



            EditorGUILayout.PropertyField(blockProperty);

            SerializedProperty mixType = VariableProperty.FindPropertyRelative(nameof(IndependentVariable.MixingType));
            VariableMixingType op      = (VariableMixingType)mixType.intValue;

            op = (VariableMixingType)EditorGUILayout.EnumPopup("Mixing Type", op);
            mixType.intValue = (int)op;



            if (valuesProperty.arraySize == 0)
            {
                VariableValidationResults.AddWarning("No values");
            }

            bool isCustomProbability = CheckIfCustomProbability();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            valuesList.DoLayoutList();
            EditorGUILayout.Space();

            if (isCustomProbability)
            {
                CalculateFinalProbability();
                CheckProbabilityErrors(true);
            }


            if (waitingToClearAllValues)
            {
                int n = valuesProperty.arraySize;
                for (int i = 0; i < n; i++)
                {
                    RemoveValue(0);
                    RemoveProbability(0);
                }

                waitingToClearAllValues = false;
            }
        }
コード例 #3
0
        public static IndependentVariableValuesAdderStrategy <T> Create <T>(VariableMixingType mixingTypeOfVariable)
        {
            switch (mixingTypeOfVariable)
            {
            case VariableMixingType.Balanced:
                return(new BalancedAdderStrategy <T>());

            case VariableMixingType.Looped:
                return(new LoopedAdderStrategy <T>());

            case VariableMixingType.EvenProbability:
                return(new EvenProbabilityAdderStrategy <T>());

            case VariableMixingType.CustomProbability:
                return(new CustomProbabilityAdderStrategy <T>());

            default:
                throw new ArgumentOutOfRangeException(nameof(mixingTypeOfVariable), mixingTypeOfVariable, null);
            }
        }