예제 #1
0
 public override void Copy(int slot, int doc, IState state)
 {
     _values[slot] = new DistanceValue
     {
         Value = CalculateDistance(doc, state)
     };
 }
 public ScoreObjectCountRule(int md, bool mdsot, int mos, DistanceValue p)
 {
     minDistance = md;
     minDistanceSameObjectType = mdsot;
     minObjectSeparation       = mos;
     probability = p;
 }
예제 #3
0
 public ScoreObjectCountRule(int md, bool mdsot, int mos, DistanceValue p)
 {
     minDistance = md;
     minDistanceSameObjectType = mdsot;
     minObjectSeparation = mos;
     probability = p;
 }
예제 #4
0
        public static double Convert(DistanceValue value, ValueTypeEnum convertTo)
        {
            int fval = (int)value.ValueType;    //from
            int tval = (int)convertTo;          //to

            return(value.Value * Math.Pow(10, tval - fval));
        }
 public ServerViewModel(GeographicalServer server, DistanceValue distance)
 {
     if (server == null)
     {
         throw new ArgumentNullException("server");
     }
     this.< Server > k__BackingField = server;
     this._distance = distance;
 }
예제 #6
0
 public override void SetBottom(int slot)
 {
     _bottom = _values[slot];
 }
예제 #7
0
 public DistanceValueList(DistanceValue v)
 {
     values = new List <DistanceValue>();
     values.Add(v);
 }
예제 #8
0
    private int addRule()
    {
        if (startDistance >= endDistance && useEndDistance)
        {
            return(1);
        }

        if (((!minDistanceSameObjectType || minObjectSeperation > 0) && targetObject == null))
        {
            return(2);
        }

        // no point in adding the rule if both of these values are zero
        if (minDistance == 0 && minObjectSeperation == 0)
        {
            return(3);
        }

        List <ObjectRuleMap> appearanceRules;

        if (avoidObjectRule)
        {
            appearanceRules = ((AppearanceRules)target).avoidObjectRuleMaps;
        }
        else
        {
            appearanceRules = ((AppearanceRules)target).probabilityAdjustmentMaps;
        }

        int  ruleInsertIndex     = 0;
        int  subRuleInsertIndex  = 0;
        bool parentBreak         = false;
        bool infiniteObjectFound = false;

        for ( ; ruleInsertIndex < appearanceRules.Count; ++ruleInsertIndex)
        {
            if (targetObject == appearanceRules[ruleInsertIndex].targetObject)
            {
                List <ScoreObjectCountRule> scoreObjectCountRules = appearanceRules[ruleInsertIndex].rules;
                for ( ; subRuleInsertIndex < scoreObjectCountRules.Count; ++subRuleInsertIndex)
                {
                    // error if the current probability is overlapping an existing probability or within it
                    DistanceValue prob = scoreObjectCountRules[subRuleInsertIndex].probability;
                    if ((startDistance < prob.startDistance && endDistance > prob.startDistance) ||
                        (startDistance > prob.startDistance && endDistance < prob.endDistance) ||
                        (startDistance < prob.endDistance && endDistance > prob.endDistance) ||
                        (!prob.useEndDistance && startDistance > prob.startDistance) ||
                        (!useEndDistance && startDistance < prob.endDistance))
                    {
                        return(4);
                    }

                    // two probabilities can't ignore the end distance
                    if (!useEndDistance && !prob.useEndDistance)
                    {
                        return(5);
                    }

                    // found our place
                    if (endDistance <= prob.startDistance)
                    {
                        parentBreak = true;
                        break;
                    }
                }
                infiniteObjectFound = true;
                break;
            }
            if (parentBreak)
            {
                break;
            }
        }

        DistanceValue        distanceProb         = new DistanceValue(startDistance, startProbability, endDistance, endProbability, useEndDistance);
        ScoreObjectCountRule scoreObjectCountRule = new ScoreObjectCountRule(minDistance, minDistanceSameObjectType, minObjectSeperation, distanceProb);

        if (infiniteObjectFound)
        {
            List <ScoreObjectCountRule> scoreObjectCountRules = appearanceRules[ruleInsertIndex].rules;
            scoreObjectCountRules.Insert(subRuleInsertIndex, scoreObjectCountRule);
        }
        else
        {
            ObjectRuleMap objectRuleMap = new ObjectRuleMap(targetObject, scoreObjectCountRule);
            appearanceRules.Insert(ruleInsertIndex, objectRuleMap);
        }

        EditorUtility.SetDirty(target);
        return(0);
    }
예제 #9
0
    public void showAppearanceRules(List <ObjectRuleMap> appearanceRules, bool avoidObjectRules)
    {
        bool parentBreak = false;

        for (int i = 0; i < appearanceRules.Count; ++i)
        {
            if (appearanceRules[i].rules.Count == 0)
            {
                continue;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("{0} Rules", (appearanceRules[i].targetObject != null ? appearanceRules[i].targetObject.name : "All")));
            if (GUILayout.Button("Remove"))
            {
                appearanceRules.RemoveAt(i);
                break;
            }
            GUILayout.EndHorizontal();

            List <ScoreObjectCountRule> scoreObjectCountRules = appearanceRules[i].rules;
            for (int j = 0; j < scoreObjectCountRules.Count; ++j)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(string.Format("  Rule {0}", (j + 1)));
                if (GUILayout.Button("Remove"))
                {
                    scoreObjectCountRules.RemoveAt(j);
                    // Remove the parent as well if there are no sub-rules left
                    if (scoreObjectCountRules.Count == 0)
                    {
                        appearanceRules.RemoveAt(i);
                        parentBreak = true;
                    }
                    EditorUtility.SetDirty(target);
                    break;
                }
                GUILayout.EndHorizontal();

                GUILayout.Label(string.Format("    Min Distance {0}", scoreObjectCountRules[j].minDistance));
                if (scoreObjectCountRules[j].minDistanceSameObjectType)
                {
                    GUILayout.Label("    Uses min distance for same object type");
                }
                else
                {
                    GUILayout.Label("    Uses min distance for object specified");
                }
                GUILayout.Label(string.Format("    Min Object Separation {0}", scoreObjectCountRules[j].minObjectSeparation));

                DistanceValue prob = scoreObjectCountRules[j].probability;
                if (avoidObjectRules)
                {
                    if (prob.useEndDistance)
                    {
                        GUILayout.Label(string.Format("    Affects Distance {0} - {1}", prob.startDistance, prob.endDistance));
                    }
                    else
                    {
                        GUILayout.Label(string.Format("    Affects Distance {0} - End", prob.startDistance));
                    }
                }
                else     // probability adjustment uses the full set of probability variables
                {
                    if (prob.useEndDistance)
                    {
                        GUILayout.Label(string.Format("    Affects Distance {0} - {1}", prob.startDistance, prob.endDistance));
                        GUILayout.Label(string.Format("    With Probability {0} - {1}", Math.Round(prob.startValue, 2), Math.Round(prob.endValue, 2)));
                    }
                    else
                    {
                        GUILayout.Label(string.Format("    Affects Distance {0} - End", prob.startDistance));
                        GUILayout.Label(string.Format("    With Probability {0}", Math.Round(prob.startValue, 2)));
                    }
                }
            }
            if (parentBreak)
            {
                break;
            }
        }
    }
예제 #10
0
    private int addRule()
    {
        if (startDistance >= endDistance && useEndDistance) {
            return 1;
        }

        if (((!minDistanceSameObjectType || minObjectSeperation > 0) && targetObject == null))
            return 2;

        // no point in adding the rule if both of these values are zero
        if (minDistance == 0 && minObjectSeperation == 0)
            return 3;

        List<ObjectRuleMap> appearanceRules;
        if (avoidObjectRule) {
            appearanceRules = ((AppearanceRules)target).avoidObjectRuleMaps;
        } else {
            appearanceRules = ((AppearanceRules)target).probabilityAdjustmentMaps;
        }

        int ruleInsertIndex = 0;
        int subRuleInsertIndex = 0;
        bool parentBreak = false;
        bool infiniteObjectFound = false;
        for ( ; ruleInsertIndex < appearanceRules.Count; ++ruleInsertIndex) {
            if (targetObject == appearanceRules[ruleInsertIndex].targetObject) {
                List<ScoreObjectCountRule> scoreObjectCountRules = appearanceRules[ruleInsertIndex].rules;
                for ( ; subRuleInsertIndex < scoreObjectCountRules.Count; ++subRuleInsertIndex) {
                    // error if the current probability is overlapping an existing probability or within it
                    DistanceValue prob = scoreObjectCountRules[subRuleInsertIndex].probability;
                    if ((startDistance < prob.startDistance && endDistance > prob.startDistance) ||
                        (startDistance > prob.startDistance && endDistance < prob.endDistance) ||
                        (startDistance < prob.endDistance && endDistance > prob.endDistance) ||
                        (!prob.useEndDistance && startDistance > prob.startDistance) ||
                        (!useEndDistance && startDistance < prob.endDistance)) {
                            return 4;
                    }

                    // two probabilities can't ignore the end distance
                    if (!useEndDistance && !prob.useEndDistance) {
                        return 5;
                    }

                    // found our place
                    if (endDistance <= prob.startDistance) {
                        parentBreak = true;
                        break;
                    }
                }
                infiniteObjectFound = true;
                break;
            }
            if (parentBreak)
                break;
        }

        DistanceValue distanceProb = new DistanceValue(startDistance, startProbability, endDistance, endProbability, useEndDistance);
        ScoreObjectCountRule scoreObjectCountRule = new ScoreObjectCountRule(minDistance, minDistanceSameObjectType, minObjectSeperation, distanceProb);
        if (infiniteObjectFound) {
            List<ScoreObjectCountRule> scoreObjectCountRules = appearanceRules[ruleInsertIndex].rules;
            scoreObjectCountRules.Insert(subRuleInsertIndex, scoreObjectCountRule);
        } else {
            ObjectRuleMap objectRuleMap = new ObjectRuleMap(targetObject, scoreObjectCountRule);
            appearanceRules.Insert(ruleInsertIndex, objectRuleMap);
        }

        EditorUtility.SetDirty(target);
        return 0;
    }
예제 #11
0
        public void OnApplyPressed()
        {
            // Item type
            TypeValue typeFilter = new TypeValue(Type_Value.Activities);

            // Category
            Category_Value cv     = Category_Value.All;
            int            numSet = 0;

            if (model.physicalActivityToggle.value)
            {
                numSet++;
                cv |= Category_Value.Physical_Activities;
            }
            if (model.healthWellnessToggle.value)
            {
                numSet++;
                cv |= Category_Value.Health_Wellness;
            }
            if (model.foodNutritionToggle.value)
            {
                numSet++;
                cv |= Category_Value.Food_Nutrition;
            }

            if (numSet >= global::System.Enum.GetNames(typeof(Category_Value)).Length - 1)
            {
                cv = Category_Value.All;
            }

            CategoryValue categoryFilter = new CategoryValue(cv);


            // Audience
            Audience_Value av = Audience_Value.All;

            numSet = 0;
            if (model.audienceKidsToggle.value)
            {
                numSet++;
                av |= Audience_Value.Children;
            }
            if (model.audienceTeensToggle.value)
            {
                numSet++;
                av |= Audience_Value.Teenagers;
            }
            if (model.audienceAdultsToggle.value)
            {
                numSet++;
                av |= Audience_Value.Adults;
            }
            if (model.audienceSeniorsToggle.value)
            {
                numSet++;
                av |= Audience_Value.Senior_Citizen;
            }

            if (numSet >= global::System.Enum.GetNames(typeof(Audience_Value)).Length - 1)
            {
                av = Audience_Value.All;
            }

            AudienceValue audienceFilter = new AudienceValue(av);


            // Skill
            SkillLevel_Value sv = SkillLevel_Value.All;

            numSet = 0;
            if (model.skillBeginnerToggle.value)
            {
                numSet++;
                sv |= SkillLevel_Value.Beginner_Friendly;
            }
            if (model.skillIntermediateToggle.value)
            {
                numSet++;
                sv |= SkillLevel_Value.Intermediate;
            }
            if (model.skillAdvancedToggle.value)
            {
                numSet++;
                sv |= SkillLevel_Value.Advanced;
            }
            if (model.skillExpertToggle.value)
            {
                numSet++;
                sv |= SkillLevel_Value.Expert;
            }

            if (numSet >= global::System.Enum.GetNames(typeof(SkillLevel_Value)).Length - 1)
            {
                sv = SkillLevel_Value.All;
            }

            SkillLevelValue skillFilter = new SkillLevelValue(sv);

            //Distance
            int           distance       = CalculateDistance();
            DistanceValue distanceFilter = new DistanceValue(distance);

            //Admission
            Admission_Value admissionType = Admission_Value.All;

            if (model.priceFreeToggle.value)
            {
                admissionType = Admission_Value.Free;
            }
            if (model.pricePaidToggle.value)
            {
                admissionType = Admission_Value.Fee;
            }

            if (model.priceFreeToggle.value == model.pricePaidToggle.value)
            {
                admissionType = Admission_Value.All;
            }

            AdmissionValue admissionFilter = new AdmissionValue(admissionType);

            ITTFilterRequest filterRequest = new ITTFilterRequest();

            filterRequest.AddFilterValue(typeFilter);
            filterRequest.AddFilterValue(categoryFilter);
            filterRequest.AddFilterValue(audienceFilter);
            filterRequest.AddFilterValue(skillFilter);
            filterRequest.AddFilterValue(distanceFilter);
            filterRequest.AddFilterValue(admissionFilter);
            filterRequest.AddFilterValue(new MinDateValue(DateTime.Today));

            ITTGoogleAnalytics.Instance.googleAnalytics.LogEvent(new EventHitBuilder()
                                                                 .SetEventCategory("Filter - Filter Screen")
                                                                 .SetEventAction("Click - Filter Apply Button")
                                                                 .SetEventLabel("User has clicked on the apply button with the following url values: " + filterRequest.RetrieveFilterURLString()));
            filterResultsController._filterRequest    = filterRequest;
            ITTMainSceneManager.Instance.currentState = ITTMainSceneManager.ITTStates.FilterResults;
        }
예제 #12
0
 public DistanceValueList(DistanceValue v)
 {
     values = new List<DistanceValue>();
     values.Add(v);
 }