コード例 #1
0
        public static NetConfig getInstance()
        {
            if (s_instance == null)
            {
                s_instance = new NetConfig();
            }

            return(s_instance);
        }
コード例 #2
0
ファイル: Init.cs プロジェクト: fynbntl/NjmjNew
        private async void Start()
        {
            try
            {
                if (Application.unityVersion != "2017.1.3p2")
                {
                    Log.Warning($"请使用Unity2017.1.3p2, 下载地址:\n https://beta.unity3d.com/download/744dab055778/UnityDownloadAssistant-2017.1.3p2.exe?_ga=2.42497696.443074145.1521714954-1119432033.1499739574");
                }

                SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);

                DontDestroyOnLoad(gameObject);
                Application.targetFrameRate = 45;
                // 永不息屏
                Screen.sleepTimeout = SleepTimeout.NeverSleep;
                // 禁止多点触摸
                Input.multiTouchEnabled = false;

                Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);

                Game.Scene.AddComponent <GlobalConfigComponent>();
                Game.Scene.AddComponent <NetOuterComponent>();
                Game.Scene.AddComponent <ResourcesComponent>();
                Game.Scene.AddComponent <BehaviorTreeComponent>();
                Game.Scene.AddComponent <PlayerComponent>();
                Game.Scene.AddComponent <UnitComponent>();
                Game.Scene.AddComponent <ClientFrameComponent>();
                Game.Scene.AddComponent <UIComponent>();
                Game.Scene.AddComponent <SessionComponent>();

                //新增Component
                Game.Scene.AddComponent <SoundComponent>();
                // 获取网络配置表
                await NetConfig.getInstance().Req("http://fwdown.hy51v.com/njmj/online/files/netconfig.json");

                // 下载ab包
                await BundleHelper.DownloadBundle();

                Game.Hotfix.LoadHotfixAssembly();

                // 加载配置
                Game.Scene.GetComponent <ResourcesComponent>().LoadBundle("config.unity3d");
                Game.Scene.AddComponent <ConfigComponent>();
                Game.Scene.GetComponent <ResourcesComponent>().UnloadBundle("config.unity3d");
                Game.Scene.AddComponent <OpcodeTypeComponent>();
                Game.Scene.AddComponent <MessageDispatherComponent>();

                Game.Hotfix.GotoHotfix();

                Game.EventSystem.Run(EventIdType.TestHotfixSubscribMonoEvent, "TestHotfixSubscribMonoEvent");
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #3
0
ファイル: BundleHelper.cs プロジェクト: fynbntl/NjmjNew
        public static async Task DownloadBundle()
        {
            Game.EventSystem.Run(EventIdType.LoadingBegin);
            Log.Debug("等待之前");
            await Game.Scene.GetComponent <TimerComponent>().WaitAsync(1500);

            PlatformHelper.SetIsFormal(NetConfig.getInstance().isFormal ? "0" : "1");
            Log.Debug("等待之后");
            await StartDownLoadResources();

            Game.EventSystem.Run(EventIdType.LoadRes);
        }
コード例 #4
0
ファイル: UILoadingComponent.cs プロジェクト: fynbntl/NjmjNew
        public override void Awake(UILoadingComponent self)
        {
            self.text   = self.GetParent <UI>().GameObject.Get <GameObject>("Text").GetComponent <Text>();
            self.button = self.GetParent <UI>().GameObject.Get <GameObject>("Button").GetComponent <Button>();

            self.button.onClick.Add(() =>
            {
                if (++NetConfig.getInstance().clickCount == 3)
                {
                    NetConfig.getInstance().isFormal = false;
                    ToastScript.createToast("test");
                }
            });
        }
コード例 #5
0
        public IPEndPoint ToIPEndPointWithYuMing()
        {
            string serverUrl  = NetConfig.getInstance().getServerUrl();
            int    serverPort = NetConfig.getInstance().getServerPort();

//            if (address != "")
//            {
//                serverPort = Convert.ToInt32(address.Split(':')[1]);
//            }
            // Log.Debug("serverUrl:" + serverUrl);
            // Log.Debug("serverPort:" + serverPort);
            IPAddress   ip;
            IPHostEntry IPinfo = Dns.GetHostEntry(serverUrl);

            if (IPinfo.AddressList.Length <= 0)
            {
                ToastScript.createToast("域名解析出错");
                return(null);
            }
            ip = IPinfo.AddressList[0];
            return(ToIPEndPoint(ip, serverPort));
        }