예제 #1
0
        void LoadLoggerConfig()
        {
            DataElement loggerConfig = GetConfiguration("logger");

            if (loggerConfig.IsNull)
            {
                return;
            }

            int         defaultThreshold = 0;
            DataElement defaultModule    = loggerConfig[CoreLogger.DefaultModuleName];

            if (!defaultModule.IsNull)
            {
                defaultThreshold = CoreLogger.Severity.ParseSeverity(defaultModule);
            }

            CoreLogger.LogDebug(LoggerModules.GameApplication, "/////////////////////////// setting logger thresholds ////////////////////////");

            foreach (string moduleName in CoreLogger.Modules)
            {
                CoreLogger.SetThreshold(moduleName, defaultThreshold);
            }

            CoreLogger.SetThreshold(defaultThreshold);

            foreach (KeyValuePair <string, DataElement> kvp in loggerConfig.GetDataPairs())
            {
                string moduleName      = kvp.Key;
                int    moduleThreshold = CoreLogger.Severity.ParseSeverity(kvp.Value);

                CoreLogger.SetThreshold(moduleName, moduleThreshold);
            }
        }
        public override void Execute()
        {
            CoreLogger.LogDebug(LoggerModules.SocialServices, "Execute IsLoggedIn " + isLoggedIn);

            socialStateModel.WaitingForSocialLogin = false;


            if (!isLoggedIn)
            {
                //toggleLoadingDialogSignal.Dispatch(false);
                return;
            }

            SocialConnectData socialConnectData = new SocialConnectData();

            socialConnectData.network         = SocialNetwork.Facebook;
            socialConnectData.email           = socialNetworkService.Email;
            socialConnectData.photoUrl        = socialNetworkService.PhotoUrl;
            socialConnectData.userName        = socialNetworkService.UserName;
            socialConnectData.userId          = socialNetworkService.UserId;
            socialConnectData.userToken       = socialNetworkService.UserToken;
            socialConnectData.initiatedByUser = true;

            socialSync.ConnectToNetwork(socialConnectData);
        }
예제 #3
0
        public override void Execute()
        {
            CoreLogger.LogDebug("LoadBindingsCommand", "Execute");

            List <BindingData> bindings = gsdkConfigModel.GetBindings();

            foreach (BindingData binding in bindings)
            {
                try
                {
                    string json = LitJson.JsonMapper.ToJson(new List <BindingData> {
                        binding
                    });
                    injectionBinder.ConsumeBindings(json);

                    Debug.Log("BindingLoading - Successfully binded: " + binding.ToString());
                }
                catch (InjectionException ex)
                {
                    Debug.Log("BindingLoading - did not load binding: " + binding);
                }
                catch (BinderException ex)
                {
                    Debug.Log("BindingLoading - did not load binding: " + binding);
                    Debug.LogWarning(ex.ToString());
                }
            }

            LoadNullBindings();
        }
예제 #4
0
        void EnqueueServiceResolution <TService>(System.Action <TService> setter, bool blocking)
            where TService : class, IService
        {
            if (blocking)
            {
                _taskQueue.Enqueue(() => {
                    TService service = _serviceResolver.Get <TService>();
                    setter(service);
                });
                return;
            }

            bool     found        = false;
            TService foundService = null;

            _taskQueue.Enqueue(() => {
                _serviceResolver.Get <TService>((result, service) => {
                    foundService = service;
                    setter(service);
                    found = true;
                });
            });

            _taskQueue.Parallelize(() => found, -1, string.Format("find service {0}", typeof(TService).Name)).Done += result => {
                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("done preparing service {0}: {1}; provider is: {2}", typeof(TService).Name, result,
                                                                                 foundService == null ? "null" : foundService.GetType().Name));
            };
        }
예제 #5
0
        /// <summary>
        /// This is the part of the initialization sequence which is always synchronous -
        /// it merely creates an instance of the GameApplication object, without doing any
        /// initialization - there's no need to make it async., since it's fast anyway.
        /// It's called by both the sync. and asnyc. versions of the CreateInstance method.
        /// </summary>
        /// <returns>The or get.</returns>
        public static GameApplication CreateOrGet()
        {
            //if an instance has already been created, don't create a new one
            s_instance = FindObjectOfType <GameApplication>();
            if (s_instance != null)
            {
                CoreLogger.LogDebug(LoggerModules.GameApplication, "an instance of GameApplication has miraculously appeared...");
                return(s_instance);
            }

            //we want to create the instance as it is defined in the resources folder
            GameApplication instance;

            Object prefab = LoadFrameworkResource(s_applicationResourceName);

            if (prefab == null)
            {
                //no prefab found - we can still create a default
                Debug.LogError(string.Format("Unable to load {0}.prefab - creating object with defaults", s_applicationResourceName));
                GameObject appObj = new GameObject();
                instance = appObj.AddComponent <GameApplication>();
            }
            else
            {
                GameObject appObj = Instantiate(prefab) as GameObject;
                instance = appObj.GetComponent <GameApplication>();
            }

            GameObject.DontDestroyOnLoad(instance);

            return(instance);
        }
        /*
         * private ServerTime _serverTime;
         * public ServerTime ServerTime { get { return _serverTime; } }
         *
         * private ModelSyncService _modelSyncService;
         * public ModelSyncService ModelSyncService { get { return _modelSyncService; } }
         */

        protected override IEnumerator ModuleInitializer()
        {
            Debug.Log("GameDbInitializer - ModuleInitializer start --------------------------------------------1");

            _gameDB = new GameDB();

            if (Application.loadedLevelName.Contains("Upload") && Application.isEditor)
            {
                _gameDB.InitLocalDB();
            }
            else
            {
                _gameDB.InitDB();
            }

            /*
             * _serverTime = new ServerTime();
             *
             * _modelSyncService = new ModelSyncService();
             * _modelSyncService.Init(_gameDB,this,_serverTime);
             * //yield return StartCoroutine(_modelSyncService.PregameConnect());
             * //StartCoroutine(_modelSyncService.AsyncLoop());
             *
             * _modelSyncService.Start();
             *
             * yield return StartCoroutine(_modelSyncService.WaitForState(ModelSyncService.SyncLoopState.Connected));
             */

            CoreLogger.LogDebug("GameDbInitializer", "done with Init");

            Debug.Log("GameDbInitializer - ModuleInitializer end --------------------------------------------2");

            yield break;
        }
예제 #7
0
        IEnumerator Loop()
        {
            CoreLogger.LogDebug(LoggerModules.Tasks, string.Format("dispatcher {0} starting up!", name));

            while (true)
            {
                int count = 0;
                while (_news.Count > 0 && (count < actionsPerIteration || actionsPerIteration < 0))
                {
                    _post.Add(_news.Dequeue());
                    count++;
                }

                foreach (Entry entry in _post)
                {
                    entry.delay--;
                    if (entry.delay == 0)
                    {
                        try
                        {
                            entry.action();
                        } catch (System.Exception ex)
                        {
                            CoreLogger.LogError(LoggerModules.Tasks, string.Format("Error in Dispatcher Action: {0}\n Stack Trace:{1}", ex.Message, ex.StackTrace));
                        }
                    }
                }

                _post.RemoveAll(e => e.delay == 0);

                yield return(null);
            }
        }
예제 #8
0
        public void Get <TService>(System.Action <TaskEnding, TService> handler)
            where TService : IService
        {
            IService service = FetchService(typeof(TService));

            if (service != null)
            {
                handler(TaskEnding.Done, (TService)service);
                return;
            }

            //no active provider - see if we can activate a dormant provider

            CoreLogger.LogDebug(_loggerModule, string.Format("adding service {0}, now looking for provider...", typeof(TService).Name));

            _taskFactory.FromEnumerableAction(() =>
                                              ActivateServiceProvider(typeof(TService), s => {
                if (s == null)
                {
                    handler(TaskEnding.Cancelled, default(TService));
                }
                else
                {
                    handler(TaskEnding.Done, (TService)s);
                }
            })).Start(-1);
        }
예제 #9
0
        IService FetchService(Type serviceType)
        {
            //an active provider already assigned to this service?
            IService serviceProvider;

            if (_serviceProviders.TryGetValue(serviceType, out serviceProvider))
            {
                return(serviceProvider);
            }

            //do we even know this service?
            if (!_unprovidedServices.Contains(serviceType))
            {
                CoreLogger.LogNotice(_loggerModule, string.Format("requested service {0} is not known to this container!", serviceType.Name));
                return(null);
            }

            //do we have an active provider for this service? an active provider is probably already providing other services,
            //but can provide this as well
            IService activeProvider = _activeProviders.Where(p => p.GetType().GetInterfaces().Contains(serviceType)).FirstOrDefault();

            if (activeProvider != null)
            {
                CoreLogger.LogDebug(_loggerModule, string.Format("adding service {0}, provided by {1}", serviceType.Name, activeProvider.GetType().Name));
                _serviceProviders[serviceType] = activeProvider;
                return(activeProvider);
            }

            return(null);
        }
예제 #10
0
 void EnqueueAddProviders()
 {
     _taskQueue.Enqueue(() => {
         _serviceResolver.AddProviders(GetComponentsInChildren(typeof(IService)).Cast <IService>());
     }, "Add Service Providers to Service Resolver").Done += result => {
         CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("done finding service providers: {0}", result));
     };
 }
예제 #11
0
 public override void Execute()
 {
     CoreLogger.LogDebug("ShowRateUsCommand", "Execute");
     if (rateUsService.ShouldShowRateUs())
     {
         modalityManager.Add(new AppModalHandle("GamePopups/RateUsModal", IModalMaskType.Masked), true);
     }
 }
예제 #12
0
        public TModule Get <TModule>()
            where TModule : IModule
        {
            IModule module;

            if (_modules.TryGetValue(typeof(TModule), out module))
            {
                return((TModule)module);
            }

            if (!_availableModules.TryGetValue(typeof(TModule), out module))
            {
                return(default(TModule));
            }

            if (_modulesInInitState.ContainsKey(module))
            {
                CoreLogger.LogError(LoggerModules.GameApplication, string.Format("module {0} is initializing and cannot be retrieved at the moment", module.GetType().Name));
                return(default(TModule));
            }

            ITask init = module.GetInitializer(this);

            if (init == null)
            {
                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("unable to retrieve initializer for module {0} failed", module.GetType().Name));
                _failedModules[typeof(TModule)] = module;
                _availableModules.Remove(typeof(TModule));
                return(default(TModule));
            }

            _modulesInInitState[module] = init;
            TaskEnding result = init.Handle();

            _modulesInInitState.Remove(module);

            if (result.IsOk())
            {
                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("successfully initialized module {0}", module.GetType().Name));
                _modules[typeof(TModule)] = module;
                _availableModules.Remove(typeof(TModule));
            }
            else
            {
                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("failed to initialize module {0}", module.GetType().Name));
                _failedModules[typeof(TModule)] = module;
                _availableModules.Remove(typeof(TModule));
                return(default(TModule));
            }

            if (_started)
            {
                module.StartModule();
                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("starting module {0}", module.GetType().Name));
            }

            return((TModule)module);
        }
예제 #13
0
 void EnqueueCreateResolvers()
 {
     _taskQueue.Enqueue(() => {
         CreateServiceResolver();
         CreateModuleContainer();
     }, "Create Resolvers").Done += result => {
         CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("done creating module containers: {0}", result));
     };
 }
예제 #14
0
        public void Init(int fromStage, int toStage, System.Action handler)
        {
            CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("requesgted non blocking initialization of modules stages {0} to {1}; total available: {2}", fromStage, toStage, _availableModules.Count));

            int pending = 0;

            ICollection <ITask> tasks = new List <ITask>();

            IList <KeyValuePair <Type, IModule> > modulesToRemove = new List <KeyValuePair <Type, IModule> >();

            foreach (KeyValuePair <Type, IModule> kvp in _availableModules.Where(kvp => (kvp.Value.Stage >= fromStage) && (kvp.Value.Stage <= toStage)))
            {
                //always remember to create a local-scoped variable within foreach loops that use lambdas!!!
                IModule localModule = kvp.Value;

                if (!_modules.ContainsKey(localModule.GetType()))
                {
                    ITask init = localModule.GetInitializer(this);
                    if (init != null)
                    {
                        tasks.Add(init);

                        CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("located module {0} - starting init", localModule.GetType().Name));

                        init.Done += result => {
                            if (result.IsOk())
                            {
                                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("successfully done with module {0} ({1}); {2} modules remaining", localModule.GetType().Name, result, pending));
                                _modules[localModule.GetType()] = localModule;
                            }
                            else
                            {
                                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("failed with module {0} ({1}); {2} modules remaining", localModule.GetType().Name, result, pending));
                                _failedModules[localModule.GetType()] = localModule;
                            }
                        };
                    }
                    else
                    {
                        CoreLogger.LogError(LoggerModules.GameApplication, string.Format("failed to retrieve initializer for module {0}", localModule.GetType().Name));
                        _failedModules[localModule.GetType()] = localModule;
                    }
                }
            }

            _taskFactory.Parallelize(tasks).Start(result => {
                handler();
            });

            foreach (KeyValuePair <Type, IModule> toRemove in modulesToRemove)
            {
                _availableModules.Remove(toRemove);
            }
        }
예제 #15
0
        IService ActivateServiceProvider(Type serviceType)
        {
            //non-active providers that implement the requested interface, sorted by priority
            List <ProviderWithPriority> dormantProviders = _dormantProviders.Where(p => p.Provider.GetType().GetInterfaces().Contains(serviceType)).ToList();

            dormantProviders.Sort((p1, p2) => p1.Priority.CompareTo(p2.Priority));
//			IEnumerable<TBase> dormantProviders = _dormantProviders.Where(p => p.Provider.GetType().GetInterfaces().Contains(serviceType))
//				.OrderBy(p => p.Priority).Select(p => p.Provider);

            foreach (IService dormantProvider in dormantProviders.Select(p => p.Provider))
            {
                if (InitNow(dormantProvider))
                {
                    CoreLogger.LogDebug(_loggerModule, string.Format("successfully iniialized provider {0} for service {1}", dormantProvider.GetType().Name, serviceType.Name));
                    _serviceProviders[serviceType] = dormantProvider;
                    _dormantProviders.Remove(_dormantProviders.First(p => p.Provider == dormantProvider));
                    _activeProviders.Add(dormantProvider);
                    _unprovidedServices.Remove(serviceType);
                    return(dormantProvider);
                }
                else
                {
                    CoreLogger.LogDebug(_loggerModule, string.Format("failed to initalize provider {0} for service {1}", dormantProvider.GetType().Name, serviceType.Name));
                    _dormantProviders.Remove(_dormantProviders.First(p => p.Provider == dormantProvider));
                    _failedProviders.Add(dormantProvider);
                }
            }

            foreach (KeyValuePair <Type, System.Func <IService> > kvp in _providerFactories)
            {
                if (kvp.Key.GetInterfaces().Contains(serviceType))
                {
                    IService provider = kvp.Value();
                    if (provider != null)
                    {
                        if (InitNow(provider))
                        {
                            CoreLogger.LogDebug(_loggerModule, string.Format("successfully iniialized provider {0} for service {1}", provider.GetType().Name, serviceType.Name));
                            _serviceProviders[serviceType] = provider;
                            _activeProviders.Add(provider);
                            _unprovidedServices.Remove(serviceType);
                            return(provider);
                        }
                        else
                        {
                            CoreLogger.LogDebug(_loggerModule, string.Format("failed to initalize provider for service {0}", serviceType.Name));
                        }
                    }
                }
            }

            return(null);
        }
예제 #16
0
        private IEnumerator ShowSplashScreen()
        {
            _renderer.sprite = null;

            int numTasks = Count;

            CoreLogger.LogDebug(_loggerModule, string.Format("starting with {0} sprites and {1} tasks...", segments.Length, numTasks));

            if (segments.Length < 1)
            {
                while (TasksPending)
                {
                    yield return(new WaitForEndOfFrame());
                }

                CoreLogger.LogDebug(_loggerModule, string.Format("finished with 0 sprites and {0} tasks", numTasks));

                Done();
                yield break;
            }

            int i = 0;

            while (TasksPending)
            {
                _captureCamera.Capture();
                if (_renderer.sprite != null)
                {
                    _switchTime = Time.time;
                }
                yield return(null);

                SplashScreenSegment segment = segments[_splashIndex];
                float waitTime = SetSprite(segment);

                yield return(new WaitForSeconds(waitTime));

                i++;
                if (cyclic)
                {
                    _splashIndex = (_splashIndex + 1) % segments.Length;
                }
                else
                {
                    _splashIndex = Mathf.Min(_splashIndex + 1, segments.Length - 1);
                }
            }

            CoreLogger.LogDebug(_loggerModule, string.Format("done showing {0} sprites out of {1}, with {2} tasks", i, segments.Length, numTasks));

            Done();
        }
예제 #17
0
        public void StartProviders()
        {
            CoreLogger.LogDebug(_loggerModule, string.Format("resolver starting all providers..."));

            foreach (Type serviceType in _unprovidedServices)
            {
                IService provider = Get(serviceType);
                if (provider != null)
                {
                    CoreLogger.LogDebug(_loggerModule, string.Format("resolver will now provide for service {0} with {1}", serviceType.Name, provider.GetType().Name));
                }
            }
        }
        public override void Execute()
        {
            CoreLogger.LogDebug("AchievementsButtonCommand", "Execute");

            socialService.ShowAchievements();

            //socialNetworkService.Init();

            //          GeneralDialogData data = new GeneralDialogData();
            //          data.buttons.Add(new BasicDialogButtonData("button1"));
            //          data.isCloseOnOutSideTap=false;
            //          generalDialog.Show(data);
        }
예제 #19
0
        public void AddProvider(IService provider, int priority = 0)
        {
            //check if it is already here - either as an active provider, or as a dormant one
            if (IsProviderKnown(provider))
            {
                CoreLogger.LogDebug(_loggerModule, string.Format("provider {0} already handled by this container", provider.GetType().Name));
                return;
            }

            //if not, it is first a dormant one
            _dormantProviders.Add(new ProviderWithPriority {
                Provider = provider, Priority = priority
            });
        }
예제 #20
0
        public IService Get(Type serviceType)
        {
            IService service = FetchService(serviceType);

            if (service != null)
            {
                return(service);
            }

            //no active provider - see if we can activate a dormant provider

            CoreLogger.LogDebug(_loggerModule, string.Format("adding service {0}, now looking for provider...", serviceType.Name));

            return(ActivateServiceProvider(serviceType));
        }
예제 #21
0
        public void Connect()
        {
            if (_socket != null)
            {
                _socket.Disconnect(false);

                _socket = null;
            }

            CoreLogger.LogDebug("ServerLoggerProvider", "creating socket...");

            try {
                AddressFamily addressFamily = AddressFamily.InterNetwork;
                SocketType    socketType    = SocketType.Stream;
                ProtocolType  protocolType  = ProtocolType.Tcp;
                _socket = new Socket(addressFamily, socketType, protocolType);
                CoreLogger.LogInfo("ServerLoggerProvider", "socket created");
                _socket.SendTimeout = sendTimeout;
            } catch (Exception ex) {
                CoreLogger.LogWarning("ServerLoggerProvider", string.Format("failed to create socket: {0}, stack: {1} - reverting to previous logger", ex.Message, ex.StackTrace));
                _socket = null;
                return;
            }

            IPEndPoint remoteEndPoint = GetRemoteEndPoint();

            CoreLogger.LogInfo("ServerLoggerProvider", string.Format("server is in {0}", remoteEndPoint));

            try {
                _socket.Connect(remoteEndPoint);
            } catch (Exception ex) {
                CoreLogger.LogWarning("ServerLoggerProvider", "failed to connect to socket: " + ex.Message);
                _socket = null;
                return;
            }

            foreach (string module in CoreLogger.Modules)
            {
                string msg  = string.Format("+node|{0}|TabTaleLog\r\n", module);
                int    sent = _socket.Send(msg.ToByteArray(Encoding.ASCII));
                if (sent != msg.Length)
                {
                    _oldLogWarning("ServerLoggerProvider", "failed to send registraion of module " + module);
                }
            }

            LogDebug("ServerLoggerProvider", "provider set");
        }
예제 #22
0
        void OnApplicationPause(bool pauseStatus)
        {
            CoreLogger.LogDebug("GameDbInitializer", "OnApplicationPause " + pauseStatus);

            if (Application.platform.IsEditor())
            {
                return;
            }

            /*
             * if(!pauseStatus && _modelSyncService!=null){
             *      _modelSyncService.RestartFlowAfterBackground();
             *
             * }
             */
        }
        public override void Execute()
        {
            CoreLogger.LogDebug("ShowAppShelfCommand : Attempting to show app shelf");

            if (locationManager.IsReady(ApplicationLocation.MoreApps))
            {
                Retain();
                popupHandle = locationManager.Get(ApplicationLocation.MoreApps);
                popupHandle.Closed.AddListener(HandleCloseResult);
                popupHandle.Open(HandleShowResult);
            }
            else
            {
                Debug.LogWarning("ShowAppShelfCommand - Will not show app shelf, location not ready");
            }
        }
예제 #24
0
        public void StartModule()
        {
            CoreLogger.LogDebug("StrangeRoot", string.Format("StartModule"));

            _mainContext = new MainContext(this);
            context      = _mainContext;

            GameObject go = new GameObject();

            go.name   = "GameRoot";
            _gameRoot = go.AddComponent <GameRoot>();
            _gameRoot.Init(this.gameObject);

            //HookupApplicationEvents(); //TODO: Uncomment

            StartCoroutine(StartCoro());
        }
예제 #25
0
        /// <summary>
        /// This initializes the GameApplication singleton as a blocking call - it means
        /// that access to Instance is valied immediately as this method returns.
        /// </summary>
        public static GameApplication CreateInstanceSync()
        {
#if UNITY_EDITOR
            s_requestingScene = "";
#endif

            if (s_instance != null)
            {
                CoreLogger.LogError(LoggerModules.GameApplication, "calling GameApplication sync init while in async init - this is a serious error, unless in a special debug mode!!");
                return(s_instance);
            }

            CoreLogger.LogDebug(LoggerModules.GameApplication, "creating GameApplication instance synchronously");

            GameApplication instance = CreateOrGet();
            if (instance == null)
            {
                CoreLogger.LogCritical(LoggerModules.GameApplication, "unable to obtain kernel instance!");
                return(null);
            }

            if (!instance.AllowSynchronousCreation)
            {
                if (instance.synchronousCreationFallbackScene != null && instance.synchronousCreationFallbackScene != "")
                {
                    CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("synchronous creation not allowed in this game - " +
                                                                                     "reverting to scene {0}", instance.synchronousCreationFallbackScene));
                    string scene = instance.synchronousCreationFallbackScene;
                    DestroyObject(instance.gameObject);
#if UNITY_EDITOR
                    GameApplication.Init(scene);
#endif
                    return(null);
                }

                CoreLogger.LogCritical(LoggerModules.GameApplication, "synchrnous creation not allowed in this Game!!!");
                return(null);
            }

            IEnumerator steps = instance.Init(true);
            while (steps.MoveNext())
            {
            }

            return(instance);
        }
예제 #26
0
        /// <summary>
        /// Go over all existing modules, and initialize them, if possible immediately.
        /// </summary>
        public void Init(int fromStage, int toStage)
        {
            CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("requested blocking initialization of modules stages {0} to {1}", fromStage, toStage));

            IList <KeyValuePair <Type, IModule> > modulesToRemove = new List <KeyValuePair <Type, IModule> >();

            foreach (KeyValuePair <Type, IModule> kvp in _availableModules.Where(kvp => (kvp.Value.Stage >= fromStage) && (kvp.Value.Stage <= toStage)))
            {
                IModule module = kvp.Value;

                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("located module {0}", module.GetType().Name));
                modulesToRemove.Add(kvp);

                if (!_modules.ContainsKey(module.GetType()))
                {
                    ITask init = module.GetInitializer(this);
                    if (init != null)
                    {
                        TaskEnding result = init.Handle();
                        if (result.IsOk())
                        {
                            CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("successfully initialized module {0}", module.GetType().Name));
                            _modules[module.GetType()] = module;
                        }
                        else
                        {
                            CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("failed to initalize module {0}: {1}", module.GetType().Name, result));
                            _failedModules[module.GetType()] = module;
                        }
                    }
                    else
                    {
                        CoreLogger.LogError(LoggerModules.GameApplication, string.Format("failed to retrieve initializer for module {0}", module.GetType().Name));
                        _failedModules[module.GetType()] = module;
                    }
                }
            }

            foreach (KeyValuePair <Type, IModule> toRemove in modulesToRemove)
            {
                _availableModules.Remove(toRemove);
            }
        }
예제 #27
0
        /// <summary>
        /// Sets the next sprite on the splash, handling
        /// transition effects if defined.
        /// </summary>
        /// <returns>Amount of seconds which are the minimum wait time for this sprite.</returns>
        /// <param name="sprite">Sprite.</param>
        private float SetSprite(SplashScreenSegment segment)
        {
            if (_renderer.sprite == segment.sprite)
            {
                return(0f);
            }

            CoreLogger.LogDebug(_loggerModule, "setting new sprite");

            _renderer.sprite = segment.sprite;

            if (autoFit)
            {
                AutoFit();
            }

            float waitTime = (_processor != null ? Mathf.Max(segment.delay, transition.duration) : segment.delay);

            return(waitTime);
        }
예제 #28
0
        /// <summary>
        /// Adds a managed service to this resolver. If a provider is present, the
        /// resolver will now know how to return it in response to requests for this
        /// service. The service must derive from TBase.
        /// </summary>
        /// <returns><c>true</c>, if service was added, <c>false</c> otherwise. A service will
        /// not be added if it does not derive from TBase</returns>
        /// <param name="serviceType">Service type.</param>
        public bool AddService(Type serviceType)
        {
            //check if service is relevant
            if (!typeof(IService).IsAssignableFrom(serviceType))
            {
                CoreLogger.LogWarning(_loggerModule, string.Format("cannot add incompatible type {0} to loader of {1}", serviceType.Name, typeof(IService).Name));
                return(false);
            }

            //if so, check if it's already here
            if (IsServiceKnown(serviceType))
            {
                CoreLogger.LogDebug(_loggerModule, string.Format("service {0} already handled by this container", serviceType.Name));
                return(true);
            }

            //now add it
            _unprovidedServices.Add(serviceType);

            return(true);
        }
예제 #29
0
        public static void Init(string initSceneName)
        {
            if (s_instance != null)
            {
                return;
            }

            if (initSceneName == null || initSceneName == "")
            {
                CoreLogger.LogDebug(LoggerModules.GameApplication, "request to init GameApplication synchronously");
                IGameApplication app = GameApplication.Instance;
                if (app == null)
                {
                    CoreLogger.LogCritical(LoggerModules.GameApplication, "failed to create GameApplication!");
                    return;
                }
            }

            s_requestingScene = Application.loadedLevelName;
            Application.LoadLevel(initSceneName);
        }
예제 #30
0
        public void Start()
        {
            if (_started)
            {
                CoreLogger.LogWarning(LoggerModules.GameApplication, "Start called twice!");
                return;
            }

            foreach (IModule module in _modules.Values)
            {
                CoreLogger.LogDebug(LoggerModules.GameApplication, string.Format("starting module {0}", module.GetType().Name));
                try
                {
                    module.StartModule();
                } catch (Exception ex)
                {
                    CoreLogger.LogError(LoggerModules.GameApplication, string.Format("failed to initialize module {0}:{1}", module.GetType().Name, ex));
                }
            }

            _started = true;
        }