Esempio n. 1
0
    void Awake()
    {
        Debug.Log("---------------  Awake ------------------------");
        XTC.oelMVCS.Logger logger = new UnityLogger();
        UIFacade.logger = logger;

        foreach (UIFacade facade in uIFacades)
        {
            facade.Register();
        }

        framework.setLogger(logger);
        framework.setConfig(new Config());
        framework.Initialize();

        SampleModel      model      = new SampleModel();
        SampleView       view       = new SampleView();
        SampleController controller = new SampleController();
        SampleService    service    = new SampleService();

        service.mono = this;

        service.MockProcessor = service.mockProcessor;
        service.useMock       = true;

        framework.getStaticPipe().RegisterModel(SampleModel.NAME, model);
        framework.getStaticPipe().RegisterView(SampleView.NAME, view);
        framework.getStaticPipe().RegisterController(SampleController.NAME, controller);
        framework.getStaticPipe().RegisterService(SampleService.NAME, service);
    }
Esempio n. 2
0
    // Use this for initialization
    IEnumerator Start()
    {
        log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("log4net.xml"));
        UnityLogger.Init();
        InitUI.SetActive(true);
        yield return(new WaitForSeconds(1f));

        TipsUI.SetActive(true);
        yield return(new WaitForSeconds(1f));

        LoadingUI.SetActive(true);
        InitUI.SetActive(false);
        yield return(new WaitForSeconds(1f));

        TipsUI.SetActive(false);
        yield return(DataManager.Instance.LoadData());

        MapService.Instance.Init();

        for (int i = 0; i < 100; i++)
        {
            progressBar.fillAmount = (i + 1) / 100f;
            progressTxt.text       = "正在加载:" + (i + 1) + "%";

            yield return(new WaitForEndOfFrame());
        }

        LoadingUI.SetActive(false);
        LoginUI.SetActive(true);
        yield return(0);
    }
        public IEnumerator ConnectServerTest()
        {
            UnityLogger   logger = new UnityLogger();
            ClientManager client = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();

            client.logger = logger;
            bool isConnected = false;

            client.onConnected += () =>
            {
                isConnected = true;
                Debug.Log("测试连接成功");
                return(Task.CompletedTask);
            };
            client.start();
            action = null;
            tryLogin();
            var room = serverClient.CreateRoom();

            Task task = client.JoinServer(room.IP, room.Port, serverClient.UserSession, room.RoomID);

            yield return(new WaitUntil(() => task.IsCompleted));

            Assert.AreEqual(0, client.id);
            Assert.True(isConnected);
        }
Esempio n. 4
0
        static async void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            // automatically run postprocessor if any excel file is imported
            string csvAsset = importedAssets.FirstOrDefault(x => x.EndsWith(".csv"));

            if (csvAsset != null)
            {
                var csvPath    = Path.GetDirectoryName(csvAsset);
                var resultPath = Path.Combine(Application.streamingAssetsPath, "CSV");

                var logger         = new UnityLogger();
                var sheetContainer = new SheetContainer(logger);

                // create csv converter from path
                var csvImporter = new CsvSheetConverter(csvPath, TimeZoneInfo.Utc);

                // bake sheets from csv converter
                await sheetContainer.Bake(csvImporter);

                // create csv converter to path
                var csvExporter = new CsvSheetConverter(resultPath, TimeZoneInfo.Utc);

                // save datasheet to streaming assets
                await sheetContainer.Store(csvExporter);

                AssetDatabase.Refresh();

                Debug.Log("CSV sheet converted.");
            }
        }
Esempio n. 5
0
    // This should be called before any other gameobject awakes
    private void Awake()
    {
        // Singleton pattern : this is the only case where it should be used
        if (ms_Instance == null)
        {
            ms_Instance = this;
            DontDestroyOnLoad(gameObject);

            m_Logger           = new UnityLogger();
            m_Updater          = new Updater();
            m_GameEventManager = new GameEventManager();
            m_InputManager     = new InputManager();
            m_LevelManager     = new LevelManager();
            m_GameFlowHSM      = new GameFlowHSM();
            m_SoundManager     = new SoundManager(m_EfxSource, m_MusicSource);
            m_SaveManager      = new SaveManager();
            m_PlayerManager    = new PlayerManager();
            OpenProxies();
            OnEngineStart();
        }
        else if (ms_Instance != this)
        {
            Destroy(gameObject);
            return;
        }
    }
        public IEnumerator sendToMultiplayerTest()
        {
            UnityLogger logger = new UnityLogger();
            HostManager host   = new GameObject(nameof(HostManager)).AddComponent <HostManager>();

            host.logger = logger;
            host.start();
            ClientManager[]          clients     = new ClientManager[5];
            Dictionary <int, object> receivedDic = new Dictionary <int, object>();

            for (int i = 0; i < clients.Length; i++)
            {
                clients[i] = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();
                int localI = i;
                clients[i].onReceive += (id, obj) =>
                {
                    receivedDic.Add(clients[localI].id, obj);
                    return(Task.CompletedTask);
                };
                clients[i].logger = logger;
                clients[i].start();
                Task task = clients[i].join(Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(), host.port);
                yield return(new WaitUntil(() => task.IsCompleted));
            }
            Task <int> sendTask = clients[0].send(1);

            yield return(new WaitUntil(() => sendTask.IsCompleted && clients.All(c => receivedDic.Keys.Contains(c.id))));

            Assert.True(sendTask.IsCompleted);
            Assert.AreEqual(1, sendTask.Result);
            Assert.True(clients.All(c => receivedDic.ContainsKey(c.id) && receivedDic[c.id] is int i && i == 1));
        }
Esempio n. 7
0
        public static void Shutdown(Assembly assembly)
        {
            var injectableTypes = INJECTABLE_TYPES.ToArray();

            foreach (var type in injectableTypes)
            {
                if (type.Assembly == assembly)
                {
                    INJECTABLE_TYPES.Remove(type);
                }
            }

            var instantiableTypes = INSTANTIABLE_TYPES.Keys.ToArray();

            foreach (var type in instantiableTypes)
            {
                if (type.Assembly == assembly)
                {
                    INSTANTIABLE_TYPES.Remove(type);
                }
            }

            var createdTypes = DEPENDENCIES.Keys.ToArray();

            foreach (var type in createdTypes)
            {
                if (type.Assembly == assembly)
                {
                    UnityLogger.Log($"removing type {type}");
                    var hashSet = DEPENDENCIES[type];
                    hashSet.Clear();
                    DEPENDENCIES.Remove(type);
                }
            }
        }
Esempio n. 8
0
        public static void CreateClient()
        {
            Debug.Log("[ERP] Creating Client");

            //Prepare the logger
            DiscordRPC.Logging.ILogger logger = null;

            //Update the logger to the unity logger
            if (Debug.isDebugBuild)
            {
                logger = new FileLogger("discordrpc.log")
                {
                    Level = logLevel
                }
            }
            ;
            if (Application.isEditor)
            {
                logger = new UnityLogger()
                {
                    Level = logLevel
                }
            }
            ;

            client = new DiscordRpcClient(
                applicationID,                                  //The Discord Application ID
                pipe: (int)targetPipe,                          //The target pipe to connect too
                // logger: logger,                              //The logger. Will Uncomment after when Lachee fixes issue #136 in Lachee/discord-rpc-csharp
                autoEvents: false,                              //WE will manually invoke events
                client: new UnityNamedPipe()                    //The client for the pipe to use. Unity MUST use a NativeNamedPipeClient since its managed client is broken.
                );
        }
Esempio n. 9
0
        static async void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            // automatically run postprocessor if any excel file is imported
            string excelAsset = importedAssets.FirstOrDefault(x => x.EndsWith(".xlsx"));

            if (excelAsset != null)
            {
                var excelPath = Path.GetDirectoryName(excelAsset);
                var jsonPath  = Path.Combine(Application.streamingAssetsPath, "Excel");

                var logger         = new UnityLogger();
                var sheetContainer = new SheetContainer(logger);

                // create excel converter from path
                var excelConverter = new ExcelSheetConverter(excelPath, TimeZoneInfo.Utc);

                // bake sheets from excel converter
                await sheetContainer.Bake(excelConverter);

                // create json converter to path
                var jsonConverter = new JsonSheetConverter(jsonPath);

                // save datasheet to streaming assets
                await sheetContainer.Store(jsonConverter);

                AssetDatabase.Refresh();

                Debug.Log("Excel sheet converted.");
            }
        }
        public IEnumerator disconnectTest()
        {
            UnityLogger logger = new UnityLogger();
            HostManager host   = new GameObject(nameof(HostManager)).AddComponent <HostManager>();

            host.logger = logger;
            host.start();
            ClientManager client = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();

            client.logger = logger;
            client.start();
            Task task = client.join(Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(), host.port);

            yield return(new WaitUntil(() => task.IsCompleted));

            bool isDisconnected = false;

            client.onDisconnect += onDisconnect;
            client.disconnect();
            void onDisconnect(DisconnectType disconnectType)
            {
                isDisconnected = true;
            }

            yield return(new WaitUntil(() => isDisconnected));
        }
        public IEnumerator connectTest()
        {
            UnityLogger logger = new UnityLogger();
            HostManager host   = new GameObject(nameof(HostManager)).AddComponent <HostManager>();

            host.logger = logger;
            host.start();
            ClientManager client = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();

            client.logger = logger;
            bool isConnected = false;

            client.onConnected += () =>
            {
                isConnected = true;
                Debug.Log("测试连接成功");
                return(Task.CompletedTask);
            };
            client.start();
            Task task = client.join(host.ip, host.port);

            yield return(new WaitUntil(() => task.IsCompleted));

            Assert.AreEqual(0, client.id);
            Assert.True(isConnected);
        }
        public IEnumerator remoteAskAllTest()
        {
            UnityLogger logger = new UnityLogger();
            HostManager host   = new GameObject(nameof(HostManager)).AddComponent <HostManager>();

            host.logger = logger;
            host.start();
            ClientManager c1 = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();

            c1.logger = logger;
            c1.start();
            _ = c1.join(Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(), host.port);
            AnswerManager a1 = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>();

            a1.client = c1;
            yield return(new WaitForSeconds(.5f));

            ClientManager c2 = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();

            c2.logger = logger;
            c2.start();
            _ = c2.join(Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString(), host.port);
            AnswerManager a2 = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>();

            a2.client = c2;
            AnswerManager a3 = new GameObject(nameof(AnswerManager)).AddComponent <AnswerManager>();

            yield return(new WaitForSeconds(.5f));

            TestRequest request = new TestRequest();
            var         task1   = a1.askAll(new int[] { c1.id, c2.id }, request, 3);
            var         task2   = a2.askAll(new int[] { c1.id, c2.id }, request, 3);
            var         task3   = a3.askAll(new int[] { c1.id, c2.id }, request, 3);

            a1.answer(c1.id, new TestResponse()
            {
                integer = 0
            });
            yield return(new WaitForSeconds(.5f));

            a2.answer(c2.id, new TestResponse()
            {
                integer = 1
            });
            yield return(new WaitForSeconds(.5f));

            Assert.True(task1.IsCompleted);
            foreach (var p in task1.Result)
            {
                Debug.Log("玩家" + p.Key + ":" + p.Value + "(PlayerID:" + p.Value.playerId + ",Value:" + (p.Value as TestResponse).integer + ")");
                Assert.AreEqual(p.Key, p.Value.playerId);
            }
            Assert.True(task2.IsCompleted);
            foreach (var p in task2.Result)
            {
                Debug.Log("玩家" + p.Key + ":" + p.Value + "(PlayerID:" + p.Value.playerId + ",Value:" + (p.Value as TestResponse).integer + ")");
                Assert.AreEqual(p.Key, p.Value.playerId);
            }
            Assert.False(task3.IsCompleted);
        }
Esempio n. 13
0
//        public CollectionGroup<IItemInstance> serverItemCollectionGroup { get; set; }
//        public CollectionGroup<IEquippableItemInstance, IEquipmentCollection<IEquippableItemInstance>> serverEquipmentCollectionGroup { get; set; }
//        public CurrencyCollectionGroup<ICurrency> serverCurrencyCollectionGroup { get; set; }

        public UNetInventoryPlayer()
        {
            logger = new UnityLogger("[UNet][player] ");

            itemCollectionGroup      = new CollectionGroup <IItemInstance>();
            equipmentCollectionGroup = new CollectionGroup <IEquippableItemInstance, IEquipmentCollection <IEquippableItemInstance> >();
            currencyCollectionGroup  = new CurrencyCollectionGroup <ICurrency>();
        }
Esempio n. 14
0
        /// <summary>
        ///  Begins creating an IUnityEnlearnClient associated with this instance.
        /// </summary>
        public void CreateClient(string gameId)
        {
            var logger = new UnityLogger();

#if UNITY_ANDROID
            _enlearnClient = new JavaBackedEnlearnClient(this, gameId, logger, () => { _isClientReady = true; Debug.Log("UnityEnlearnClient is now Ready!"); });
#endif
        }
Esempio n. 15
0
 private void InitLogging()
 {
     Interface.get_Oxide().NextTick(() => {
         this.logger = new UnityLogger();
         Interface.get_Oxide().get_RootLogger().AddLogger(this.logger);
         Interface.get_Oxide().get_RootLogger().DisableCache();
     });
 }
Esempio n. 16
0
    void Awake()
    {
        Debug.Log("---------------  Awake ------------------------");
        XTC.oelMVCS.Logger logger = new UnityLogger();
        UIFacade.logger = logger;
        framework.setLogger(logger);
        framework.setConfig(new Config());

        btnLoad.onClick.AddListener(() =>
        {
            btnLoad.gameObject.SetActive(false);
            btnDestroy.gameObject.SetActive(true);

            GameObject go = Resources.Load <GameObject>("SampleFacade");
            uiFacade      = GameObject.Instantiate(go);
            uiFacade.transform.SetParent(btnLoad.transform.parent);
            uiFacade.transform.localScale = Vector3.one;

            RectTransform rt    = uiFacade.GetComponent <RectTransform>();
            rt.anchoredPosition = Vector2.zero;
            rt.sizeDelta        = Vector2.zero;

            uiFacade.GetComponent <UIFacade>().Register();

            model      = new SampleModel();
            view       = new SampleView();
            controller = new SampleController();
            service    = new SampleService();

            service.MockProcessor = this.mockProcessor;
            service.useMock       = true;

            framework.getDynamicPipe().PushModel(SampleModel.NAME, model);
            framework.getDynamicPipe().PushView(SampleView.NAME, view);
            framework.getDynamicPipe().PushController(SampleController.NAME, controller);
            framework.getDynamicPipe().PushService(SampleService.NAME, service);
        });

        btnDestroy.onClick.AddListener(() =>
        {
            btnLoad.gameObject.SetActive(true);
            btnDestroy.gameObject.SetActive(false);

            framework.getDynamicPipe().PopModel(SampleModel.NAME);
            framework.getDynamicPipe().PopView(SampleView.NAME);
            framework.getDynamicPipe().PopController(SampleController.NAME);
            framework.getDynamicPipe().PopService(SampleService.NAME);

            if (uiFacade != null)
            {
                uiFacade.GetComponent <UIFacade>().Cancel();
                GameObject.Destroy(uiFacade);
                uiFacade = null;
            }
        });

        framework.Initialize();
    }
Esempio n. 17
0
        private static T CheckForNullAndReturn <T>(T checkingObject, string errorMessage)
        {
            if (checkingObject == null)
            {
                UnityLogger.Error(errorMessage);
            }

            return(checkingObject);
        }
    // Use this for initialization
    public void StartMatchMakingClient()
    {
        IMMEventHandler iMMEventHandler = new MM_EventHandler();
        ILogger         logger          = new UnityLogger();
        PersistentData  data            = UnityConfig.GetPersistentDataContainer().persistentData;
        string          name            = UnityConfig.GetName();

        clientEndPoint = new MatchMakerClient(config, iMMEventHandler, logger, data, name);
    }
Esempio n. 19
0
 private void InitLogging()
 {
     // Create our logger and add it to the compound logger
     Interface.Oxide.NextTick(() =>
     {
         logger = new UnityLogger();
         Interface.Oxide.RootLogger.AddLogger(logger);
         Interface.Oxide.RootLogger.DisableCache();
     });
 }
Esempio n. 20
0
        public void Log_StartsWithLogPrefix()
        {
            var interceptor = new TestUnityLoggerInterceptor();
            var logger      = new UnityLogger(new SentryOptions {
                DiagnosticLevel = SentryLevel.Debug
            }, interceptor);

            logger.Log(SentryLevel.Debug, "TestLog");

            StringAssert.StartsWith(UnityLogger.LogPrefix, interceptor.LogMessage);
        }
Esempio n. 21
0
        protected override void OnUpdate()
        {
            Entities
            .WithAll <NetworkStreamDisconnected>()
            .ForEach((Entity entity, ref NetworkIdComponent networkIdComponent, ref CommandTargetComponent commandTargetComponent) =>
            {
                PostUpdateCommands.DestroyEntity(commandTargetComponent.targetEntity);
                ServerManager.Instance.OnDisconnected(entity);

                UnityLogger.Info($"[Server] Client disconnected from server with network id = [{networkIdComponent.Value}]");
            });
        }
Esempio n. 22
0
    //---- Ctor
    //---------
    public void Init()
    {
        _log = new UnityLogger();
        LoadClientState();
        Connection          = new ClientConnection(State, _log);
        _connectionListener = new ClientConnectionListener(State, Connection, _log);
        Lobby.Init(_log);

        // Hook up listeners
        Connection.ConnectionListener = _connectionListener;
        Connection.LobbyListener      = Lobby;
    }
        private static void createHostClient(out HostManager host, out ClientManager client)
        {
            UnityLogger logger = new UnityLogger();

            host        = new GameObject(nameof(HostManager)).AddComponent <HostManager>();
            host.logger = logger;
            host.start();

            client        = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();
            client.logger = logger;
            client.start();
        }
        protected override void OnUpdate()
        {
            Entities
            .WithAll <NetworkStreamDisconnected>()
            .ForEach((Entity entity, ref CommandTargetComponent commandTargetComponent) =>
            {
                PostUpdateCommands.DestroyEntity(commandTargetComponent.targetEntity);
                ClientManager.Instance.OnDisconnected();

                UnityLogger.Info($"[Client] Disconnected from server");
            });
        }
Esempio n. 25
0
        private App()
        {
            var logger  = new UnityLogger();
            var factory = new Factory("App", logger);

            factory.Dep <ILogger>(logger);
            factory.AutoRegisterTypes();

            this.Factory          = factory;
            this.singletonManager = factory.AutoInstantiateSingletons();
            this.singletonManager.Startup();
        }
Esempio n. 26
0
        protected override void OnUpdate()
        {
            var startServer = GetSingleton <StartServer>();

            EntityManager.DestroyEntity(GetSingletonEntity <StartServer>());

            var             network = World.GetExistingSystem <NetworkStreamReceiveSystem>();
            NetworkEndPoint ep      = NetworkEndPoint.AnyIpv4;

            ep.Port = startServer.port;
            network.Listen(ep);
            UnityLogger.Info($"Server started on {ep.Port} port in {World.Name} world");
        }
Esempio n. 27
0
 public ServiceRegistry()
 {
     _logger         = new UnityLogger();
     CheckerFactory  = new CheckerFactory(Logger);
     ExceptionLogger = new ExceptionLogger(Logger);
     ConfigFetcher   = new ConfigFetcher(Logger);
     AnalysisRunner  = new AnalysisRunner
                       (
         Logger,
         CheckerFactory,
         ExceptionLogger
                       );
 }
        private void Awake()
        {
            ILogger logger = null;

            if (Application.isEditor)
            {
                logger = new UnityLogger();
            }
            var pubSub = new PubSub();

            _app = new CoinGameApp(pubSub, logger);
            _app.Init();
        }
Esempio n. 29
0
        public JavaBackedEnlearnClient(MonoBehaviour behaviour, string gameId, UnityLogger logger, Action serviceStartedCallback)
        {
            _behaviour = behaviour;
            var unityPlayerJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            var unityPlayerActivity  = unityPlayerJavaClass.GetStatic <AndroidJavaObject>("currentActivity");

            //Send request to start service
            _unityCallable       = new AndroidJavaObject("org.enlearn.enlearnServiceClient.UnityCallable", gameId, unityPlayerActivity);
            _androindJniCallable = new AndroidJniCallable(_unityCallable);
            _jniTask             = new JniTask(_androindJniCallable, 5000);
            _unityCallable.Call("StartService", new EnlearnServiceStartedListener(logger, serviceStartedCallback));
            //dispatch event back to client builder when service is started
        }
        private static void createHostClient12(out HostManager host, out ClientManager client1, out ClientManager client2)
        {
            UnityLogger logger = new UnityLogger();

            host        = new GameObject(nameof(HostManager) + "1").AddComponent <HostManager>();
            host.logger = logger;
            host.start();
            client1        = new GameObject(nameof(ClientManager) + "1").AddComponent <ClientManager>();
            client1.logger = logger;
            client1.start();
            client2        = new GameObject(nameof(ClientManager) + "2").AddComponent <ClientManager>();
            client2.logger = logger;
            client2.start();
        }