Esempio n. 1
0
        public Form1(float hte, int cleaners, int cleaningTime, int movieDuration, int eatDuration, int elevatorDelay)
        {
            InitializeComponent();
            hotelStatus_label.Text = "Running";
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            _Hotel = Hotel.GetInstance();
            _Hotel.CreateElevator(elevatorDelay);
            _Hotel.SetCleaners(cleaners, cleaningTime);
            _Hotel.SetScreeningTime(movieDuration);
            _Hotel.EatDuration = eatDuration;
            var hel = new HEListener();

            Paint += DrawHotel;

            HotelEventManager.Register(hel);
            HTE_Factor = hte;
            HotelEventManager.HTE_Factor = HTE_Factor;


            Timer = new System.Timers.Timer(1000 / HotelEventManager.HTE_Factor)
            {
                Enabled = true
            };
            Timer.Start();
            Stopwatch = new Stopwatch();
            Stopwatch.Start();

            HotelEventManager.Start();

            Timer.Elapsed += TimerHandler;
            Console.WriteLine(Timer.Interval);

            KeyUp += SpacePress;
        }
Esempio n. 2
0
        public SimulationForm(string fileLocation, Settings settings)
        {
            InitializeComponent();

            ImportLayout import = new ImportLayout();

            import.LayoutImport(fileLocation);

            Hotel.Settings = settings;


            Graph.CreateGraph();

            Hotel.Reception.HireCleaners(Hotel.Settings.CleanerAmount);

            _BackgroundBuffer = new Bitmap(Hotel.Floors[0].Areas.Length * 60 + 1, Hotel.Floors.Length * 55 + 1);
            _ForegroundBuffer = new Bitmap(Hotel.Floors[0].Areas.Length * 60 + 1, Hotel.Floors.Length * 55 + 1);
            _Wireframe        = new Bitmap(Hotel.Floors[0].Areas.Length * 60 + 1, Hotel.Floors.Length * 55 + 1);

            DrawBackground();

            HotelEventManager.Start();
            HotelEventManager.HTE_Factor = (float)Hotel.Settings.HTEFactor;

            TimerHTE.Interval = (int)(1000 / Hotel.Settings.HTEFactor);
            TimerHTE.Start();

            DrawForeground();

            BackgroundLayer.Size = _BackgroundBuffer.Size;
            Size = new Size(BackgroundLayer.Size.Width + BackgroundLayer.Location.X * 3, BackgroundLayer.Size.Height + BackgroundLayer.Location.Y * 3);
        }
Esempio n. 3
0
        private void HotelPB_Click(object sender, EventArgs e)
        {
            Point pos = new Point(Cursor.Position.X, Cursor.Position.Y);

            if (hotel.DidIClickOnTheReception(pos))
            {
                if (timer.Enabled) // if timer is enabled then stop timer
                {
                    timer.Stop();
                    frameTimer.Stop();
                    sw.Stop();
                    HotelEventManager.Pauze();
                    Console.WriteLine("Timer gestopt");
                    panelPauze.Visible = true;
                    panelPauze.BringToFront();
                    labelInfo.Text = hotel.Info();
                }
                else // if timer is disabled then start timer
                {
                    timer.Start();
                    frameTimer.Start();
                    sw.Start();
                    HotelEventManager.Start();
                    Console.WriteLine("Timer gestart");
                    panelPauze.Visible = false;
                    labelInfo.Text     = null;
                }
            }
        }
Esempio n. 4
0
        public Simulation(List <LayoutJsonModel> layout, ConfigJsonModel ConfigJson)
        {
            InitializeComponent();
            // Setting form to fullscreen
            Rectangle resolution = Screen.PrimaryScreen.Bounds;

            this.Size        = resolution.Size;
            this.WindowState = FormWindowState.Maximized;

            // Placing Pauze panel on right location and hiding it
            panelPauze.Visible = false;
            double PauzeWidth  = resolution.Width * 0.20;
            double PauzeHeight = resolution.Height * 0.75;

            this.panelPauze.Size       = new Size((int)PauzeWidth, (int)PauzeHeight);
            this.panelPauze.Top        = (this.ClientSize.Height - panelPauze.Height) / 2;
            this.panelPauze.Left       = 10;
            this.labelGamePauzed.Width = this.panelPauze.Width;
            this.labelInfo.Width       = this.panelPauze.Width;
            this.labelInfo.Height      = this.panelPauze.Height - this.labelGamePauzed.Height;

            // initialize timer for hte
            timer.Tick += new EventHandler(OnTimedEvent);
            double MilisecondsPerHte = 1.0 / ConfigJson.HtesPerSecond;
            int    intervalOne       = Convert.ToInt32(MilisecondsPerHte * 1000); // van seconde milisecondes maken

            timer.Interval = (intervalOne >= 1) ? (int)intervalOne : 1;


            // initialize timer for frame updates
            frameTimer.Tick += new EventHandler(OnFrameTimerUpdate);
            int    FPS       = 60; // fps instelbaar
            double interval2 = (double)1000 / FPS;

            frameTimer.Interval = (interval2 >= 1) ? (int)interval2 : 1;

            // create hotel
            hotel = new Hotel(layout, ConfigJson, timer);
            hotel.Display(MainSimDisplay);
            hotel.hotelPB.Click += HotelPB_Click;
            hotel.AddMaid((int)ConfigJson.RoomCleaningHTE);
            hotel.AddMaid((int)ConfigJson.RoomCleaningHTE);

            // create eventmanager
            HotelEventManager.Register(new myEventListener(hotel));
            HotelEventManager.HTE_Factor = (int)ConfigJson.HtesPerSecond;

            // start simulation
            timer.Start();
            frameTimer.Start();
            sw.Start();
            HotelEventManager.Start();
        }
Esempio n. 5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Exit the simulation if there is no layout path.
            if (ServiceLocator.Get <ConfigLoader>().GetConfig().LayoutPath == null)
            {
                Environment.Exit(0);
            }

            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            // Create new information window
            _informationWindow = new InformationWindow();

            // Make a new hotel.
            _hotel = new Hotel();

            // Register components to the roomfactory
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Room", new GuestRoomFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Empty", new EmptyRoomFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Lobby", new LobbyFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Cinema", new CinemaFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Restaurant", new CafeFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("ElevatorShaft", new ElevatorShaftFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Staircase", new StaircaseFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Fitness", new FitnessFactoryComponent());
            _hotel.HotelBuilder.RoomFactory.RegisterComponent("Pool", new PoolFactoryComponent());

            _hotel.BuildHotel();

            // Create other things.
            _camera             = new Camera(GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight);
            _camera.Controlable = true;
            _closeUpCamera      = new Camera(200, 200);

            // Create the handlers and managers and start throwing events.
            HotelEventManager.Start();
            HotelEventHandler hotelEventHandler = new HotelEventHandler(_hotel);

            _listener = new EventListener(hotelEventHandler);
            HotelEventManager.Register(_listener);

            // Create a background.
            _background = new Sprite();
            _background.LoadSprite("Background");
            _background.SetPosition(new Point(0, 0));
            _background.SetSize(new Point(GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight));
        }
 /// <summary>
 /// Pause the simulation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PauseButton_Click(object sender, EventArgs e)
 {
     if (buttonCounter % 2 == 0 || buttonCounter == 0)
     {
         HotelEventManager.Pauze();
         timer.Stop();
         pauseButton.Text = "Hervat";
         buttonCounter++;
     }
     else
     {
         HotelEventManager.Start();
         timer.Start();
         pauseButton.Text = "Pauze";
         buttonCounter++;
     }
 }
        public MainForm(Settings settings)
        {
            this.settings          = settings; //store the selected settings
            timer.Interval         = 1000;     //set the tick frequency
            timerForMaids.Interval = 1000;
            roomFactory.GenerateEntity();
            manager = new Manager(roomFactory.coordinates, settings.amountOfMaids, this);

            //creating background and inintializing personLayout
            background   = draw.DrawLayout(roomFactory.coordinates);
            personLayout = new Bitmap(background.Width, background.Height);


            InitializeComponent();
            hotelMap.BackgroundImage = background; //set the background


            //Setup buttons
            int distanceButtons = 100;

            pauseButton.Location = new Point(background.Width + distanceButtons, hotelMap.Location.Y + distanceButtons);
            pauseButton.Size     = new Size(250, 100);
            pauseButton.Text     = "Pauze";
            pauseButton.Click   += new EventHandler(PauseButton_Click);
            speedButton.Location = new Point(background.Width + distanceButtons, pauseButton.Height + distanceButtons);
            speedButton.Size     = pauseButton.Size;
            speedButton.Text     = "Versnellen";
            speedButton.Click   += new EventHandler(SpeedButton_Click);
            stopButton.Location  = new Point(background.Width + distanceButtons, speedButton.Location.Y + distanceButtons);
            stopButton.Size      = pauseButton.Size;
            stopButton.Text      = "Stop";
            stopButton.Click    += new EventHandler(StopButton_Click);
            Controls.Add(pauseButton);
            Controls.Add(speedButton);
            Controls.Add(stopButton);

            //Start the hotel events
            HotelEventManager.Start();
            timer.Start();
            timerForMaids.Start();

            //call the update function after each timer tick.
            timer.Tick += new EventHandler(UpdateImage);
        }
 /// <summary>
 /// imitialize hotelsimulation
 /// </summary>
 public HotelSimulation()
 {
     _roomQueue     = new Queue <Room>();
     _eventChecker  = new EventChecker();
     _huidigeCinema = new Cinema();
     _customers     = new List <Customer>();
     _reception     = new Reception();
     _hotel         = new Hotel();
     _simplePath    = new SimplePath();
     listener       = new EventListener();
     HotelEventManager.Register(listener);
     HotelEventManager.HTE_Factor = 4;
     HotelEventManager.Start();
     graphics = new GraphicsDeviceManager(this);
     //uncomment for fullscreen
     //graphics.IsFullScreen = true;
     //graphics.HardwareModeSwitch = false;
     _isPaused             = false;
     Content.RootDirectory = "Content";
 }
Esempio n. 9
0
        /// <summary>
        ///     Allows the game to perform any initialization it needs to before starting to run.
        ///     This is where it can query for any required services and load any non-graphic
        ///     related content.  Calling base.Initialize will enumerate through any components
        ///     and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            //add/create a new hotel
            hotel = new Hotel();

            //instantiate new listeners
            _checkInListener  = new CheckInListener(ref hotel);
            _checkOutListener = new CheckOutListener(ref hotel);

            //register listeners to HotelEventManager
            HotelEventManager.Register(_checkInListener);
            HotelEventManager.Register(_checkOutListener);

            //start HotelEventManager
            HotelEventManager.Start();

            this.IsMouseVisible = true;

            base.Initialize();
        }
Esempio n. 10
0
        /// <summary>
        /// Creates a function hotel
        /// </summary>
        /// <param name="layout">A file which contains a functioning layout</param>
        /// <param name="settings">The Settings for the simulation</param>
        /// <param name="TypeOfBuilder">A type of builder that can handle the provided file</param>
        public Hotel(List <JsonModel> layout, SettingsModel settings, IHotelBuilder TypeOfBuilder)
        {
            // Hotel will handle the CheckIn_events so it can add them to its list
            // making it possible to keep the list private
            HotelEventManager.Register(this);

            _hotelBuilder = TypeOfBuilder;

            // Build the hotel
            HotelAreas    = _hotelBuilder.BuildHotel(layout, settings);
            HotelMovables = _hotelBuilder.BuildMovable(settings, this);

            // Set calculation properties
            HotelWidth  = HotelAreas.OrderBy(X => X.Position.X).Last().Position.X;
            HotelHeight = HotelAreas.OrderBy(Y => Y.Position.Y).Last().Position.Y;

            _elevatorCart = (ElevatorCart)HotelMovables.Find(X => X is ElevatorCart);

            // Methods for final initialization
            Dijkstra.IntilazeDijkstra(this);
            HotelEventManager.Start();
        }
Esempio n. 11
0
        /// <summary>
        /// This is the constructor off the hotel
        /// </summary>
        /// <param name="file"></param>
        public Hotel(string file, Settings hte)
        {
            // Setting the settingsfile of this class
            this.hte = hte;

            // Definitions
            HotelTimer = new Stopwatch();
            Facilities = new List <LocationType>();

            // Methods
            CreateFactory();
            CreateFactoryObjects(file);
            LinkLocationTypes();
            CreateCleaners();

            // We add this class to the listener list so it can be updated
            HotelEventManager.Register(this);
            // Setting the HTE on how fast the events should come in
            HotelEventManager.HTE_Factor = hte.Hte;
            // Start the events
            HotelEventManager.Start();
            // Start the timer
            HotelTimer.Start();
        }
Esempio n. 12
0
 /// <summary>
 /// Resuming the simulation and starting the events again
 /// </summary>
 private void _startSimulation()
 {
     _timer.Start();
     HotelEventManager.Start();
 }
Esempio n. 13
0
 /// <summary>
 /// Adaptor Method that calls HotelEvent.Manager.Start();
 /// </summary>
 public void Start_events()
 {
     HotelEventManager.Start();
 }