Ejemplo n.º 1
0
 public static void LoadAllNavigation()
 {
     for (int i = 0; i < excel_scn_list.Count; ++i)
     {
         excel_scn_list scnList = excel_scn_list.GetByIndex(i);
         if (scnList.temp > 0)
         {
             LoadingNav(scnList.name);
         }
     }
 }
Ejemplo n.º 2
0
    public void ChangeScene(int scnID, Action <Scene> onLoaded = null)
    {
        Debug.Log("Change Scene To " + scnID + " ...");
        if (mCurrentScene != null)
        {
            mCurrentScene.Exit();
            mCurrentScene = null;
        }
        excel_scn_list scnList = excel_scn_list.Find(scnID);

        if (scnList == null)
        {
            Debug.LogError("没有找到ID为" + scnID + "的场景表!");
            return;
        }
        GameApp.Instance.StartCoroutine(LoadingScn(scnList, onLoaded));
    }
Ejemplo n.º 3
0
    IEnumerator LoadingScn(excel_scn_list scnList, Action <Scene> onLoaded)
    {
        AsyncOperation scnLoadRequest = SceneManager.LoadSceneAsync(scnList.name);

        while (!scnLoadRequest.isDone)
        {
            yield return(null);
        }

        Scene scn = new Scene();

        scn.mScnLists = scnList;

        mCurrentScene = scn;

        if (onLoaded != null)
        {
            onLoaded(scn);
        }

        scn.Enter();
    }
Ejemplo n.º 4
0
    public static List <excel_refresh> LoadRefreshExcel(int scnID)
    {
        var scnRefreshMap = RefreshSystem.Instance.mScnRefreshDatas;
        List <excel_refresh> refreshDatas = null;

        if (scnRefreshMap.TryGetValue(scnID, out refreshDatas))
        {
            return(refreshDatas);
        }
        refreshDatas = new List <excel_refresh>();
        scnRefreshMap.Add(scnID, refreshDatas);

        excel_scn_list scnList = excel_scn_list.Find(scnID);

        if (scnList == null || string.IsNullOrEmpty(scnList.refreshPath))
        {
            return(null);
        }
        if (mRefrshFieldData == null)
        {
            string configText = string.Empty;
            using (FileStream fsRead = new FileStream(@"../Data/SvrExcel/config/refresh.json", FileMode.Open))
            {
                byte[] configDatas = new byte[fsRead.Length];
                fsRead.Read(configDatas, 0, configDatas.Length);
                configText = System.Text.Encoding.UTF8.GetString(configDatas);
                fsRead.Close();
            }
            JsonData data = JsonMapper.ToObject(configText);
            mRefrshFieldData = data["field"];
        }

        Type       excel_type     = typeof(excel_refresh);
        FieldInfo  excelViewField = excel_type.BaseType.GetField("excelView");
        Type       viewType       = excelViewField.FieldType;
        object     vd             = System.Activator.CreateInstance(viewType);
        MethodInfo addMethod      = viewType.GetMethod("Add");

        MethodInfo initMethod = excel_type.BaseType.GetMethod("Initialize");

        string excelStr = null;

        using (FileStream fsRead = new FileStream(@"../Data/SvrExcel/" + scnList.refreshPath + ".txt", FileMode.Open))
        {
            byte[] excelDatas = new byte[fsRead.Length];
            fsRead.Read(excelDatas, 0, excelDatas.Length);
            fsRead.Close();
            excelStr = System.Text.Encoding.Unicode.GetString(excelDatas);
        }
        string[] excel_lines = excelStr.Split(new string[] { "\r\n" }, StringSplitOptions.None);
        //GetLines(excelDatas);
        for (int l = 1; l < excel_lines.Length; ++l)
        {
            string excel_line = excel_lines[l];
            if (string.IsNullOrWhiteSpace(excel_line) || string.IsNullOrEmpty(excel_line))
            {
                continue;
            }
            string[] excel_line_data = excel_line.Split('\t');
            if (excel_line_data.Length != mRefrshFieldData.Count)
            {
                Console.WriteLine("Excel Error: Excel Data Number Is Not Equal To Config Data Number! File: " + scnList.refreshPath);
                continue;
            }

            object excel = System.Activator.CreateInstance(excel_type);
            int    id    = 0;

            for (int m = 0; m < mRefrshFieldData.Count; ++m)
            {
                JsonData  fieldDef   = mRefrshFieldData[m];
                string    fieldName  = fieldDef["name"].ToString();
                string    fieldType  = fieldDef["type"].ToString();
                FieldInfo excelField = excel_type.GetField(fieldName);
                string    strValue   = excel_line_data[m];
                if (string.IsNullOrWhiteSpace(strValue))
                {
                    continue;
                }
                object value = GetFieldValueByType(fieldType, strValue);
                if (value != null)
                {
                    if (fieldName == "id")
                    {
                        id = (int)value + scnID * 1000;
                    }
                    excelField.SetValue(excel, value);
                }
            }
            if (id != 0)
            {
                addMethod.Invoke(vd, new object[] { excel });
            }

            excel_refresh er = excel as excel_refresh;
            refreshDatas.Add(er);
        }
        excelViewField.SetValue(null, vd);
        initMethod.Invoke(vd, new object[] { });

        return(refreshDatas);
    }
Ejemplo n.º 5
0
    void OnInitPlayers(byte[] data)
    {
        NotifyStartGame startGame = ProtoBufUtils.Deserialize <NotifyStartGame>(data);
        excel_scn_list  scnList   = SceneSystem.Instance.mCurrentScene.mScnLists;

        GameController.mServerStartTime = startGame.ServerStartTime;
        GameController.mClientStartTime = Time.realtimeSinceStartup;

        for (int i = 0; i < startGame.Players.Count; ++i)
        {
            ScnPlayerInfo playerInfo = startGame.Players[i];

            excel_cha_class chaClass = excel_cha_class.Find(mScnLists.temp);
            if (chaClass == null)
            {
                continue;
            }

            excel_cha_list chaList = excel_cha_list.Find(chaClass.chaListID);

            GameObject o = ResourceSystem.Load <GameObject>(chaList.path);
            if (o != null)
            {
                GameObject mainPlayer = GameObject.Instantiate(o);
                Player     player     = mainPlayer.GetComponent <Player>();
                player.gid      = playerInfo.GID;
                player.UserID   = playerInfo.UserID;
                player.mChaList = chaList;

                mainPlayer.transform.position   = new Vector3(82.51f, 7.25f, 34.82f);
                mainPlayer.transform.localScale = new Vector3(chaList.scale[0], chaList.scale[1], chaList.scale[2]);

                mPlayersList.Add(player);
                mCharacterList.Add(player);
                mPlayers.Add(player.gid, player);
                mCharacters.Add(player.gid, player);

                if (GameController.mUserInfo.uid == playerInfo.UserID)
                {
                    player.mEvent += TargetChgEvent;

                    MessageSystem.Instance.MsgDispatch(MessageType.OnSetChaClass, chaClass);

                    GameController.OnPlayerInit(player);
                }
            }

            //ResourceSystem.LoadAsync<GameObject>(chaList.path, (obj) =>
            //{
            //    GameObject o = obj as GameObject;
            //    if (o != null)
            //    {
            //        GameObject mainPlayer = GameObject.Instantiate(o);
            //        Player player = mainPlayer.GetComponent<Player>();
            //        player.gid = playerInfo.GID;
            //        player.UserID = playerInfo.UserID;
            //        player.mChaList = chaList;

            //        mainPlayer.transform.position = new Vector3(82.51f, 7.25f, 34.82f);
            //        mainPlayer.transform.localScale = new Vector3(chaList.scale[0], chaList.scale[1], chaList.scale[2]);

            //        mPlayersList.Add(player);
            //        mCharacterList.Add(player);
            //        mPlayers.Add(player.gid, player);
            //        mCharacters.Add(player.gid, player);

            //        if (GameController.mUserInfo.uid == playerInfo.UserID)
            //        {
            //            player.mEvent += TargetChgEvent;

            //            MessageSystem.Instance.MsgDispatch(MessageType.OnSetChaClass, chaClass);

            //            GameController.OnPlayerInit(player);
            //        }
            //    }
            //});
        }
    }