Exemplo n.º 1
0
 public void SimulationStart(bool heatMapActivated, IPathfinding pathfinding, int milliseconds)
 {
     HeatMapActivated   = heatMapActivated;
     HasSimulationEnded = false;
     People             = OnPrepareSimulation?.Invoke(LocalFloorPlan);
     OnUISimulationStart?.Invoke(heatMapActivated, pathfinding, milliseconds);
 }
Exemplo n.º 2
0
 public HexControl(int sizeX, int sizeZ, IMapGenerator generator)
 {
     this.sizeX = sizeX;
     this.sizeZ = sizeZ;
     tiles      = generator.GenerateTiles(sizeX, sizeZ);
     pathfinder = new Pathfinding();
 }
Exemplo n.º 3
0
Arquivo: Data.cs Projeto: Bargsteen/p2
 //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;
 }
Exemplo n.º 4
0
 public void SimulationStart(bool heatMapActivated, IPathfinding pathfinding, int milliseconds)
 {
     HeatMapActivated = heatMapActivated;
     HasSimulationEnded = false;
     People = OnPrepareSimulation?.Invoke(LocalFloorPlan);
     OnUISimulationStart?.Invoke(heatMapActivated, pathfinding, milliseconds);
 }
Exemplo n.º 5
0
    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;
    }
Exemplo n.º 6
0
 //
 /// <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();
 }
Exemplo n.º 7
0
    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();
    }
Exemplo n.º 8
0
 public void Construct(
     ITailor tailor,
     QuestManager questManager,
     NPCData data,
     IAnimCtrl animationControl,
     IPathfinding pathfinding
     )
 {
     _tailor           = tailor;
     _questManager     = questManager;
     _data             = data;
     _animationControl = animationControl;
     _pathfinding      = pathfinding;
 }
Exemplo n.º 9
0
Arquivo: Data.cs Projeto: Bargsteen/p2
        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);
        }
Exemplo n.º 10
0
Arquivo: Data.cs Projeto: pprintz/p2
        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;
        }
Exemplo n.º 11
0
 public static IPathfinding GetPathfinding()
 {
     return(sPathfinding ?? (sPathfinding = new DefaultPathfinding()));
 }
Exemplo n.º 12
0
 private void Awake()
 {
     _nodeMap     = nodeMapGameObject.GetComponent <NodeGridmapComponent>();
     _pathfinding = new AstarPathfinding();
 }
Exemplo n.º 13
0
Arquivo: Data.cs Projeto: pprintz/p2
 //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;
 }