Пример #1
0
    private void _SetPrecValueAndTime(LoadingItem loadingItem, int addPerc)
    {
        float fTime = 2.0f / (float)50 * (float)addPerc;

        UpdatePrec up = new UpdatePrec();

        up.targetTime  = fTime / (float)addPerc;
        up.PrecValue   = addPerc;
        up.loadingItem = loadingItem;
        updatePreclist.Add(up);
    }
Пример #2
0
    void Update()
    {
        for (int i = updatePreclist.Count - 1; i >= 0; i--)
        {
            UpdatePrec up = updatePreclist[i];
            up.curTime += Time.deltaTime;
            if (up.curTime > updatePreclist[i].targetTime)
            {
                up.PrecValue--;
                up.curTime = 0.0f;
                up.loadingItem.percentage++;
                LuaComponent loadingItem = up.loadingItem.transform.GetComponent <LuaComponent>();
                if (loadingItem.table != null)
                {
                    loadingItem.table.Set("loadingState", CommonFunction.GetConstString("STR_LOADING") + up.loadingItem.percentage + "%");
                }
            }
            if (up.PrecValue == 0)
            {
                if (m_curLoadingCmd != null)
                {
                    if (up.loadingItem.ri != null)
                    {
                        if (up.loadingItem.ri.acc_id == MainPlayer.Instance.AccountID)
                        {
                            m_curLoadingCmd.m_bDone = true;
                        }
                    }
                    else
                    {
                        m_curLoadingCmd.m_bDone = true;
                    }
                }

                updatePreclist.RemoveAt(i);
            }
        }

        _InitGameMsgHandler();

        //loading queue process
        if (m_curLoadingCmd == null && m_loadingQueue.Count != 0)
        {
            m_curLoadingCmd = m_loadingQueue.Dequeue();
            m_curLoadingCmd.Execute();
        }
        if (m_curLoadingCmd != null && m_curLoadingCmd.m_bDone)
        {
            if (m_curLoadingCmd.m_bFinalCmd)
            {
                m_curLoadingStep = LoadingStep.eLoadingComplete;
            }
            m_curLoadingCmd = null;
        }
        if (m_curLoadingStep == LoadingStep.eInit)
        {
            return;
        }

        if (m_wait != null)
        {
            m_wait.Update(Time.deltaTime);
        }

        GameMatch_PVP match = GameSystem.Instance.mClient.mCurMatch as GameMatch_PVP;

        if (match == null)
        {
            if (m_curLoadingStep == LoadingStep.eLoadingComplete)
            {
                if (onComplete != null)
                {
                    onComplete();
                }
                Object.Destroy(gameObject);
            }
        }
        else
        {
            if (m_curLoadingStep == LoadingStep.eLoadedScene && match.m_bPlayerDataReady && !m_pvpLoadPlayer)
            {
                LoadCharacter(GameSystem.Instance.mClient.mPlayerManager, match);
                m_pvpLoadPlayer = true;
            }

            if (m_curLoadingStep == LoadingStep.eLoadedPlayers && !m_pvpLoadUI)
            {
                LoadUI(match);
                m_pvpLoadUI = true;
            }

            if (m_curLoadingStep == LoadingStep.eLoadingComplete && !m_pvpLoadComplete)
            {
                if (onComplete != null)
                {
                    onComplete();
                }
                m_pvpLoadComplete = true;
                GameMsgSender.SendLoadingComplete(match.GetMatchType());
            }

            if (m_curLoadingStep == LoadingStep.eLoadingComplete && disConnected)
            {
                disConnected = false;
                ShowOffLine();
            }

            if (m_delayDestroy && !MainPlayer.Instance.inPvpJoining)
            {
//               if( m_delayLoadLua != null)
//               {
//                   m_delayLoadLua.ForEach((LuaComponent item) =>
//                                 {
//                                     item.table.Set("loadingState", CommonFunction.GetConstString("STR_LOAD_COMPLETE"));
//                                     item.table.Set("loadDone", true);
//                                 });

//               }
                Object.Destroy(gameObject);
            }
        }
    }