public void SimulationStart(bool heatMapActivated, IPathfinding pathfinding, int milliseconds) { HeatMapActivated = heatMapActivated; HasSimulationEnded = false; People = OnPrepareSimulation?.Invoke(LocalFloorPlan); OnUISimulationStart?.Invoke(heatMapActivated, pathfinding, milliseconds); }
public HexControl(int sizeX, int sizeZ, IMapGenerator generator) { this.sizeX = sizeX; this.sizeZ = sizeZ; tiles = generator.GenerateTiles(sizeX, sizeZ); pathfinder = new Pathfinding(); }
//Subscribes to the correct simulation events, when evacuated is set to false, it subscrives to OnPersonMoved event. private void AddPersonToSimulation(Person person, IPathfinding pathfindingAlgorithm, int simulationSpeed) { person.Evacuated = false; person.OnPersonEvacuated += RemoveEvacuatedPerson; person.SimulationSpeed = simulationSpeed; person.OnExtendedPathRequest += FindNewPath; }
private void GeneratePath() { _algorithm?.Cleanup(); // cleanup algorithm's edits to node grid _runtime = 0f; _algorithm = new AStar(_grid); _path = _algorithm.FindPath(_start, _end); _state = _algorithm.ChangeController; }
// /// <summary> /// Creates a HexagonButton grid in xSize * ySize, needs a reference to the handler window. /// </summary> /// <param name="handler"></param> /// <param name="xSize"></param> /// <param name="ySize"></param> public MapTest(GameForm game, int size, IPathfinding path) { _totalHexagonRows = size; _totalHexagonColumns = size; this.path = path; hexMap = new HexagonButton[TotalHexagonColumns, TotalHexagonRows]; CreateMap(game); FindNeighbours(); }
public static void InitializeModules(Balance balance, Timers timers, Localization localization, SceneNames sceneNames) { Balance = balance; Timers = timers; Localization = localization; SceneNames = sceneNames; TSVReader = new TSVReader(); Pathfinding = new SimplePathfinding(); Localization.Initialize(); }
public void Construct( ITailor tailor, QuestManager questManager, NPCData data, IAnimCtrl animationControl, IPathfinding pathfinding ) { _tailor = tailor; _questManager = questManager; _data = data; _animationControl = animationControl; _pathfinding = pathfinding; }
public Dictionary <int, Person> StartSimulation(bool heatmap, IPathfinding pathfindingAlgorithm, int simulationSpeed) //<---- kan formentligt være void? { //If the simulation scroller has been touched, the person gets another value in ticksToWait. foreach (Person person in AllPeople.Values.Where(p => p.SimulationSpeed != simulationSpeed)) { person.SimulationSpeed = simulationSpeed; } if (UserInterface.BuildingHasBeenChanged) { if (AllPeople != null) { foreach (Person person in AllPeople.Values.Where(p => !p.NoPathAvailable)) // IF the building has been changed, calculate new routes. { person.PathList.Clear(); //If its a new person, the person subscribes to the simulation events.. if (person.NewPersonInGrid) { AddPersonToSimulation(person, pathfindingAlgorithm, simulationSpeed); person.NewPersonInGrid = false; } person.PathList.AddRange( pathfindingAlgorithm.CalculatePath(person).Cast <BuildingBlock>().ToList()); } } UserInterface.BuildingHasBeenChanged = false; } if (AllPeople == null) { return(null); } foreach (Person person in AllPeople.Values.Where(p => p.PathList.Count == 0 && !p.NoPathAvailable)) { if (person.NewPersonInGrid) { AddPersonToSimulation(person, pathfindingAlgorithm, simulationSpeed); person.NewPersonInGrid = false; } person.PathList.AddRange( pathfindingAlgorithm.CalculatePath(person).Cast <BuildingBlock>().ToList()); } //Event to the loading bar, to update it. OnPathCalculationDone?.Invoke(this, null); StartTicks(); return(AllPeople); }
public Dictionary<int, Person> StartSimulation(bool heatmap, IPathfinding pathfindingAlgorithm, int simulationSpeed) //<---- kan formentligt være void? { //If the simulation scroller has been touched, the person gets another value in ticksToWait. foreach (Person person in AllPeople.Values.Where(p => p.SimulationSpeed != simulationSpeed)) { person.SimulationSpeed = simulationSpeed; } if (UserInterface.BuildingHasBeenChanged) { if (AllPeople != null) { foreach (Person person in AllPeople.Values.Where(p => !p.NoPathAvailable)) // IF the building has been changed, calculate new routes. { person.PathList.Clear(); //If its a new person, the person subscribes to the simulation events.. if (person.NewPersonInGrid) { AddPersonToSimulation(person, pathfindingAlgorithm, simulationSpeed); person.NewPersonInGrid = false; } person.PathList.AddRange( pathfindingAlgorithm.CalculatePath(person).Cast<BuildingBlock>().ToList()); } } UserInterface.BuildingHasBeenChanged = false; } if (AllPeople == null) return null; foreach (Person person in AllPeople.Values.Where(p => p.PathList.Count == 0 && !p.NoPathAvailable)) { if (person.NewPersonInGrid) { AddPersonToSimulation(person, pathfindingAlgorithm, simulationSpeed); person.NewPersonInGrid = false; } person.PathList.AddRange( pathfindingAlgorithm.CalculatePath(person).Cast<BuildingBlock>().ToList()); } //Event to the loading bar, to update it. OnPathCalculationDone?.Invoke(this, null); StartTicks(); return AllPeople; }
public static IPathfinding GetPathfinding() { return(sPathfinding ?? (sPathfinding = new DefaultPathfinding())); }
private void Awake() { _nodeMap = nodeMapGameObject.GetComponent <NodeGridmapComponent>(); _pathfinding = new AstarPathfinding(); }