예제 #1
0
    /// <summary>
    /// 异步读取
    /// </summary>
    private IEnumerator ReadAsync(Action <EngineCfg> ReadFinished)
    {
        EngineCfg config = null;
        WWW       www    = null;

        string srcPath = null;

                #if UNITY_IOS
        srcPath = "file://" + Path.Combine(DeviceInfo.StreamingPath, "Config/Engine.cfg");
                #elif UNITY_ANDROID
        srcPath = Path.Combine(DeviceInfo.StreamingPath, "Config/Engine.cfg");
                #endif

                #if UNITY_EDITOR
        srcPath = "file:///" + Path.Combine(DeviceInfo.StreamingPath, "Config/Engine.cfg");
                #endif

        www = new WWW(srcPath);
        yield return(www);

        byte[] data = www.bytes;

        using (StreamReader sr = new StreamReader(new MemoryStream(data))) {
            string wholeTxt = sr.ReadToEnd();
            config = JSON.Instance.ToObject <EngineCfg>(wholeTxt);
        }

        www.Dispose();

        if (ReadFinished != null)
        {
            ReadFinished(config);
        }
    }
예제 #2
0
        public RealServer(WarInfo war, Action RepBinded, Action PubBinded)
        {
            mWar = war;

            cached = ServerCached.Instance;
            cached.clear();

            RepBindCompleted = RepBinded;
            PubBindCompleted = PubBinded;

            monitor = new MonitorClient();
            monitor.startMonitor(mWar);

            EngineCfg engCfg = Core.EngCfg;

            cached.curServer = new ServerInfo()
            {
                IpAddr        = "127.0.0.1",
                PubPort       = engCfg.PubPort,
                PairPort      = engCfg.PairPort,
                HeartBeatPort = engCfg.HeartBeatPort,
                ServerName    = "Allen",
                ServerID      = DeviceInfo.GUID,
            };

            publisher = new PubServer(war, PubBindCompleted);
            Resper    = new ResponseServer(war, HandleMQMsg, RepBindCompleted);

            type      = GetType();
            c_bf      = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance;
            cmdMethod = new Dictionary <string, MethodInfo>();
            cachedMethod();

            proxyCli = new ProxyClient(-1, publisher);
        }
예제 #3
0
    static int Initialize(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        EngineCfg arg0 = LuaScriptMgr.GetNetObject <EngineCfg>(L, 1);

        Core.Initialize(arg0);
        return(0);
    }
예제 #4
0
파일: Core.cs 프로젝트: wxl-007/ShadowDota
    /// <summary>
    /// Initialize this instance.
    /// We must follow special sequnce.
    /// 仅且仅初始化一次
    /// </summary>
    public static void Initialize(EngineCfg cfg)
    {
        ConsoleEx.DebugLog("Core Engine is initializing ....", ConsoleEx.YELLOW);
        //Initial sequnce
        DevFSM  = DeviceFSM.Instance;
        GameFSM = GamePlayFSM.Instance;
        EngCfg  = cfg;

        if (GameFSM.InitOK == Consts.FAILURE)
        {
            //Have one NetMQContext ONLY. This will be used to created ALL sockets within the process.
            ZeroMQ = NetMQContext.Create();

            //DataPersisteManager should be initialize first. and tell the non-account path
            DPM = LocalIOManager.getInstance(DeviceInfo.PersistRootPath);
            //Unity UI Basically Manager
            EntityMgr = new EntityManager();
            //Timer should run.
            TimerEng = new TimerMaster();
            //Sound manager.
            SoundEng = SoundEngine.GetSingleton();
            //EventCenter must initialize later than Network Engine
            NetEng = new NetworkEngine();
            //EventCenter also must initialize later than Aysnc Engine
            AsyncEng = AsyncTask.Current;
            //Coroutine
            Coroutine = CoroutineProvider.Instance();

            EVC    = new EventCenter(NetEng.httpEngine, NetEng.SockEngine, EntityMgr);
            ResEng = new Loader();

            Data = new DataCore();

            //register some vars.
            CoreParam();
        }
        else
        {
            //TODO: 此分支是初始化一次OK后,注销之后进入的分支情况
        }

        RegisterInterface();
        ConsoleEx.DebugLog("Core Engine is initialized ....", ConsoleEx.YELLOW);
        GameFSM.OnInitOk();
    }
예제 #5
0
 public BaseSsock(WarInfo war)
 {
     warInfo = war;
     EngCfg  = Core.EngCfg;
 }
예제 #6
0
파일: Main.cs 프로젝트: wxl-007/ShadowDota
 void ReadFinished(EngineCfg cfg)
 {
     ConsoleEx.DebugLog("---Read Engine Configure Finished ----");
     Application.targetFrameRate = cfg.FrameRate;
     Core.Initialize(cfg);
 }