Ejemplo n.º 1
0
        /// <summary>
        /// Constructor for application
        /// Sets up logging and other services as configured
        /// </summary>
        public App()
        {
            try
            {
                var serviceCollection = new ServiceCollection();
                ConfigureServices(serviceCollection);
                _serviceProvider = serviceCollection.BuildServiceProvider();

                Log.Information("Application starting up");

                if (!Directory.Exists(StaticGlobals.GetAppDirectory()))
                {
                    Directory.CreateDirectory(StaticGlobals.GetAppDirectory());
                    Log.Information("Created app directory");
                }

                // Ensure database exists
                using (DataContext context = new DataContext())
                {
                    context.Database.EnsureCreated();
                }
            }
            catch (Exception Ex)
            {
                Log.Error($"Error setting up application: {Ex.Message}");
                Log.Error($"Stack Trace: {Ex.StackTrace}");
                Log.Error($"Inner Exception: {Ex.InnerException}");
            }
        }
Ejemplo n.º 2
0
    // Start by initializing variables
    private void Awake()
    {
        m_health  = m_maxHealth;
        m_globals = GameObject.FindGameObjectWithTag("globals").GetComponent <StaticGlobals>();
        if (m_globals == null)
        {
            Debug.LogError("No globals gameobject was found.");
        }

        m_collider = GetComponent <Collider>();
        if (m_collider == null)
        {
            Debug.LogError("Missing collider on shooter agent.");
        }

        m_bulletPrefab = Resources.Load("bullet") as GameObject;
        if (m_bulletPrefab == null)
        {
            Debug.LogError("No bullet prefab was found in shooter agent.");
        }

        m_navAgent = GetComponent <NavMeshAgent>();
        if (m_navAgent == null)
        {
            Debug.LogError("No navmesh agent found on agent.");
        }

        m_simulator = GameObject.FindGameObjectWithTag("matchSimulator").GetComponent <MatchSimulator>();
        if (m_simulator == null)
        {
            Debug.LogError("No MatchSimulator object was found in ShooterAgent");
        }
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Configures services for Dependency Injection, set logging level here
 /// </summary>
 /// <param name="services">IServiceCollection of Services</param>
 internal void ConfigureServices(IServiceCollection services)
 {
     services.AddSingleton <MainWindow>();
     services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true));
     services.AddDbContext <DataContext>();
     Log.Logger = new LoggerConfiguration()
                  .WriteTo.Console()
                  .WriteTo.RollingFile(Path.Combine(StaticGlobals.GetAppDirectory(), "VibesSwap-{Date}.log"), fileSizeLimitBytes: 5242880, retainedFileCountLimit: 5)
                  .MinimumLevel.Information()
                  .CreateLogger();
 }
Ejemplo n.º 4
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     optionsBuilder.UseSqlite(StaticGlobals.GetConnectionString())
     .EnableSensitiveDataLogging();
 }