Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            var mazeBuilder = new MazeBuilder();

            services.AddSingleton <MazeBuilder>(mazeBuilder);
            services.AddSingleton <UpdateManager>(new UpdateManager(mazeBuilder));
            services.AddSignalR();

            services.AddControllers()
            .AddNewtonsoftJson()
            .ConfigureApiBehaviorOptions(options =>
            {
                options.SuppressConsumesConstraintForFormFileParameters = true;
                options.SuppressInferBindingSourcesForParameters        = true;
                options.SuppressModelStateInvalidFilter = true;
                options.SuppressMapClientErrors         = true;
                options.ClientErrorMapping[404].Link    =
                    "https://httpstatuses.com/404";
            });
            //services.AddMvc();

            services.AddCors(options =>
            {
                options.AddPolicy("AllowAllHeaders",
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader();
                });
            });
        }
 public UpdateManager(MazeBuilder mazeBuilder)
 {
     _initialized    = false;
     _updateTimer    = new Timer(new TimerCallback(TimerTask), null, Timeout.Infinite, Timeout.Infinite);
     _resetGameTimer = new Timer(new TimerCallback(ResetGameTimer), null, 1000 * 60 * 10, 1000 * 60 * 10);
     Players         = new List <Player>();
     Enemies         = new List <Enemy>();
     _mazeBuilder    = mazeBuilder;
     CreateEnemies();
 }