Beispiel #1
0
 public override void DrawGUI(IntelligenceState parentState, Intelligence intelligence, CallbackCollection callbacks)
 {
     #if UNITY_EDITOR
     Type = (TargetType)EditorGUILayout.EnumPopup("Type:", Type);
     targetClassification = (IntelligenceType) EditorGUILayout.EnumPopup("Classification:", targetClassification);
     range = EditorGUILayout.FloatField("Range:", range);
     checkLOS = EditorGUILayout.Toggle("Check LOS:", checkLOS);
     saveVar = EditorGUILayout.Toggle("Save", saveVar);
     if (saveVar)
     {
         EditorGUILayout.BeginHorizontal();
         GUILayout.Label("Var name:");
         storageVar = EditorGUILayout.TextField(storageVar);
         EditorGUILayout.EndHorizontal();
     }
     #endif
 }
        internal Intelligence(Level parent, IntelligenceType type)
        {
            fParent           = parent.Hierarchy;
            fIntelligenceType = type;
            if (type == IntelligenceType.itMemberToDate)
            {
                fDisplayName = string.Format(RadarUtils.GetResStr("rsiMemberToDate"), parent.DisplayName);

                fExpression = "COALESCEEMPTY({2}(PERIODSTODATE(" + parent.UniqueName + ",{0}), {1}), 0)";

                fIntelligenceGroup = string.Format(RadarUtils.GetResStr("rsiTimeIntelligence"), fParent.DisplayName);

                return;
            }
            if (type == IntelligenceType.itMemberGrowth)
            {
                fDisplayName = string.Format(RadarUtils.GetResStr("rsiMemberGrowth"), parent.DisplayName);
                //                fExpression = "COALESCEEMPTY({2}({{0}}, {1}), 0) - COALESCEEMPTY({2}({PARALLELPERIOD(" + parent.UniqueName + ",1,{0})}, {1}), 0)";

                fExpression = "COALESCEEMPTY(({0}, {1}) - (PARALLELPERIOD(" + parent.UniqueName + ",1,{0}), {1}), 0)";

                fIntelligenceGroup = string.Format(RadarUtils.GetResStr("rsiTimeIntelligence"), fParent.DisplayName);
            }
        }
Beispiel #3
0
 public Human GetNearestHuman(Vector3 position, IntelligenceType typeFilter)
 {
     if (typeFilter == IntelligenceType.Undefined) {
         return GetNearestHuman (position);
     }
     if (humans.Count == 0) {
         return null;
     }
     var nearest = humans [0];
     var dist = float.PositiveInfinity;
     bool found = false;
     for (var i = 1; i < humans.Count; i++) {
         if (!humans [i].Behaviour)
             continue;
         if (typeFilter == IntelligenceType.Human) {
             IntelligenceType ht = humans [i].Behaviour.Classification;
             if (ht != IntelligenceType.Citizen & ht != IntelligenceType.Human & ht != IntelligenceType.Police) {
                 continue;
             }
         } else {
             if (humans [i].Behaviour.Classification != typeFilter) {
                 continue;
             }
         }
         var curDist = AstarMath.SqrMagnitudeXZ (humans [i].transform.position, position);
         if (curDist < dist) {
             nearest = humans [i];
             dist = curDist;
             found = true;
         }
     }
     if (!found) {
         return null;
     }
     return nearest;
 }
Beispiel #4
0
 public List<Human> GetHumans(Vector3 position, float radius, IntelligenceType filter)
 {
     var rangeQuery = new List<Human> ();
     for (var i = 0; i < humans.Count; i++) {
         if (!humans [i].Behaviour) {
             continue;
         }
         var humanClassification = humans [i].Behaviour.Classification;
         if (filter == IntelligenceType.Human) {
             if (humanClassification != IntelligenceType.Human & humanClassification != IntelligenceType.Citizen &
                             humanClassification != IntelligenceType.Police) {
                 continue;
             }
         } else {
             if (humanClassification != filter) {
                 continue;
             }
         }
         if (AstarMath.SqrMagnitudeXZ (humans [i].transform.position, position) <= radius * radius) {
             rangeQuery.Add (humans [i]);
         }
     }
     return rangeQuery;
 }