예제 #1
0
 /// <summary>
 /// Generates a crowd with the given arguments.
 /// </summary>
 /// <param name="criteria">The crowd's criteria</param>
 /// <param name="isStatic">Are the crowd's members static?</param>
 /// <param name="collection">The crowd's event scheduler.</param>
 public SmartCrowd GenerateCrowd(ISmartCrowdCriteria criteria, bool isStatic, EventCollection collection)
 {
     SmartCrowd instance = new GameObject(NamePrefix + currentCrowdIndex).AddComponent<SmartCrowd>();
     instance.tag = "Smart Object";
     if (Parent != null)
     {
         instance.transform.parent = Parent.transform;
     }
     instance.Initialize(criteria, isStatic, collection);
     instance.Portrait = GetPortrait(currentCrowdIndex);
     currentCrowdIndex++;
     return instance;
 }
예제 #2
0
 /// <summary>
 /// Gets all the SmartObjects satisfying the given criteria, using the known satisfiers given in existingSatisfiers as base. Modifies this set
 /// and then returns it.
 /// </summary>
 public static HashSet<SmartObject> AllSatisfyingCriteria(ISmartCrowdCriteria criteria, HashSet<SmartObject> existingSatisfiers)
 {
     foreach (SmartObject obj in ObjectManager.Instance.GetObjects())
     {
         if (!(obj is SmartCrowd) && criteria.SatisfiesCriteria(obj))
         {
             existingSatisfiers.Add(obj);
         }
     }
     toRemove.Clear();
     foreach (SmartObject obj in existingSatisfiers)
     {
         if (!criteria.SatisfiesCriteria(obj))
         {
             toRemove.Add(obj);
         }
     }
     foreach (SmartObject obj in toRemove)
     {
         existingSatisfiers.Remove(obj);
     }
     return existingSatisfiers;
 }
예제 #3
0
 /// <summary>
 /// Opens the window to create a new EventScheduler for the selected crowd.
 /// </summary>
 private void CreateEventScheduler(ISmartCrowdCriteria criteria)
 {
     EventSchedulerWindow schedulerSetup = new EventSchedulerWindow();
     mainArea = schedulerSetup;
     notificationBar = new NotificationBar("You have selected a crowd. See the game view for the contained objects. You can now create an EventScheduler for the crowd or cancel.");
     MouseHandler.GetInstance().DeregisterDragEvents(crowdRectangleSelectAction);
     MouseHandler.GetInstance().DeregisterDragEvents(drawRectangleAction);
     ActionBar.AddButton("Set And Save Scheduler", () =>
     {
         Debug.Log("Exectuting Set and save");
         CrowdGenerator.Instance.GenerateCrowd(criteria, crowdStatic, schedulerSetup.ToEventCollection(true));
         Reset();
     });
     ActionBar.AddButton("Set Scheduler", () =>
     {
         CrowdGenerator.Instance.GenerateCrowd(criteria, crowdStatic, schedulerSetup.ToEventCollection(false));
         Reset();
     });
 }
예제 #4
0
 /// <summary>
 /// Gets all SmartObjects satisfying the given criteria.
 /// </summary>
 public static HashSet<SmartObject> AllSatisfyingCriteria(ISmartCrowdCriteria criteria)
 {
     return AllSatisfyingCriteria(criteria, new HashSet<SmartObject>());
 }