예제 #1
0
 public void SimulationStart(bool heatMapActivated, IPathfinding pathfinding, int milliseconds)
 {
     HeatMapActivated   = heatMapActivated;
     HasSimulationEnded = false;
     People             = OnPrepareSimulation?.Invoke(LocalFloorPlan);
     OnUISimulationStart?.Invoke(heatMapActivated, pathfinding, milliseconds);
 }
예제 #2
0
파일: HexControl.cs 프로젝트: v-free/hexMap
 public HexControl(int sizeX, int sizeZ, IMapGenerator generator)
 {
     this.sizeX = sizeX;
     this.sizeZ = sizeZ;
     tiles      = generator.GenerateTiles(sizeX, sizeZ);
     pathfinder = new Pathfinding();
 }
예제 #3
0
파일: Data.cs 프로젝트: 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;
 }
예제 #4
0
파일: UserInterface.cs 프로젝트: pprintz/p2
 public void SimulationStart(bool heatMapActivated, IPathfinding pathfinding, int milliseconds)
 {
     HeatMapActivated = heatMapActivated;
     HasSimulationEnded = false;
     People = OnPrepareSimulation?.Invoke(LocalFloorPlan);
     OnUISimulationStart?.Invoke(heatMapActivated, pathfinding, milliseconds);
 }
예제 #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;
    }
예제 #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();
 }
예제 #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();
    }
예제 #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;
 }
예제 #9
0
파일: Data.cs 프로젝트: 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);
        }
예제 #10
0
파일: Data.cs 프로젝트: 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;
        }
예제 #11
0
 public static IPathfinding GetPathfinding()
 {
     return(sPathfinding ?? (sPathfinding = new DefaultPathfinding()));
 }
예제 #12
0
 private void Awake()
 {
     _nodeMap     = nodeMapGameObject.GetComponent <NodeGridmapComponent>();
     _pathfinding = new AstarPathfinding();
 }
예제 #13
0
파일: Data.cs 프로젝트: 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;
 }