Ejemplo n.º 1
0
        //暂时把新建新手场景的方法写在这里
        private void addNewNewBieWorld()
        {
            string        timeStr = "-" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second;
            string        path    = GameConfig.Instance.WorldSavedPath + "/" + GameConfig.Instance.defaultWorldConfigStr + "_" + "剧情模式" + timeStr + "_" + GameConfig.Instance.defalutSeed;
            DirectoryInfo dd      = new DirectoryInfo(path);

            if (!dd.Exists)
            {
                dd.Create();
            }


            UnityEngine.Object[] objlist = Resources.LoadAll("Data/Plot/SceneData/Newbie");
            for (int i = 0; i < objlist.Length; i++)
            {
                if (objlist[i] is TextAsset)
                {
                    //string objstr = objlist[i].ToString();
                    byte[]     bt   = (objlist[i] as TextAsset).bytes;
                    FileInfo   newf = new FileInfo(path + "/" + objlist[i].name + ".mtb");
                    FileStream fs   = newf.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite);
                    //byte[] byteArray = System.Text.Encoding.Default.GetBytes(objstr);
                    fs.Write(bt, 0, bt.Length);
                    fs.Close();
                }
            }

            UIManager.Instance.closeUI(uiType);
            LoadingUI loadingUI = UIManager.Instance.showUI <LoadingUI>(UITypes.LOADING) as LoadingUI;

            loadingUI.setProcessEvt(EventMacro.CHUNK_GENERATE_FINISH, 121);
            loadingUI.setFinishEvt(EventMacro.GENERATE_FIRST_WORLD_FINISH);
            EventManager.SendEvent(EventMacro.SELECT_WORLD, NetType.Single, GameConfig.Instance.defaultWorldConfigStr, "剧情模式" + timeStr, GameConfig.Instance.defalutSeed);
        }
Ejemplo n.º 2
0
        private void onNewWorldSet(string worldName)
        {
            string timeStr = "-" + DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second;

            UIManager.Instance.closeUI(uiType);
            LoadingUI loadingUI = UIManager.Instance.showUI <LoadingUI>(UITypes.LOADING) as LoadingUI;

            loadingUI.setProcessEvt(EventMacro.CHUNK_GENERATE_FINISH, 121);
            loadingUI.setFinishEvt(EventMacro.GENERATE_FIRST_WORLD_FINISH);
            EventManager.SendEvent(EventMacro.SELECT_WORLD, NetType.Single, GameConfig.Instance.defaultWorldConfigStr, worldName + timeStr, GameConfig.Instance.defalutSeed);
        }
Ejemplo n.º 3
0
 private void onSelectWorld(params object[] paras)
 {
     if ((UITypes)paras[0] == uiType)
     {
         if ((NetType)paras[1] == NetType.Single)
         {
             UIManager.Instance.closeUI(uiType);
             LoadingUI loadingUI = UIManager.Instance.showUI <LoadingUI>(UITypes.LOADING) as LoadingUI;
             loadingUI.setProcessEvt(EventMacro.CHUNK_GENERATE_FINISH, 121);
             loadingUI.setFinishEvt(EventMacro.GENERATE_FIRST_WORLD_FINISH);
             EventManager.SendEvent(EventMacro.SELECT_WORLD, NetType.Single, paras[2], paras[3], paras[4]);
         }
         else
         {
             EventManager.RegisterEvent(NetEventMacro.ON_LINK_SERVER, OnLinkServer);
             NetManager.Instance.client.Connect((string)paras[2], (int)paras[3]);
         }
     }
 }
Ejemplo n.º 4
0
        private void OnJoinGame(object[] param)
        {
            EventManager.UnRegisterEvent(NetEventMacro.ON_JION_GAME, OnJoinGame);
            PlayerInfo info = (PlayerInfo)param[0];

            Debug.Log("进入游戏成功!isMe:" + info.isMe);
            if (!info.isMe)
            {
                return;
            }
            string worldConfigName = (string)param[1];
            int    seed            = (int)param[2];
            float  worldTime       = (float)param[3];

            UIManager.Instance.closeUI(uiType);
            LoadingUI loadingUI = UIManager.Instance.showUI <LoadingUI>(UITypes.LOADING) as LoadingUI;

            loadingUI.setProcessEvt(EventMacro.CHUNK_GENERATE_FINISH, 121);
            loadingUI.setFinishEvt(EventMacro.GENERATE_FIRST_WORLD_FINISH);
            EventManager.SendEvent(EventMacro.SELECT_WORLD, NetType.Local, worldConfigName, "", seed, info, worldTime);
        }