Beispiel #1
0
        private IEnumerator SimulateRecvPkg(LinkedList <TransPkg> pkgList, SyncObject targetBall)
        {
            while (true)
            {
                if (pkgList.Count > 0)
                {
                    var itr = pkgList.First;
                    while (itr != null)
                    {
                        float now = SyncTransUtils.Now;

                        TransPkg pkg = itr.Value;
                        if (pkg.Time > now)
                        {
                            break;
                        }

                        this.m_ballSyncTarget.RecvPkg(pkg);

                        itr = itr.Next;
                        pkgList.RemoveFirst();

                        m_TransPkgPool.Release(pkg);
                    }
                }
                yield return(null);
            }
        }
Beispiel #2
0
 public void SyncTrans(TransPkg pkg)
 {
     this.targetAcc           = (pkg.velocity - this.targetVelocity) / (pkg.time - this.targetTime);
     this.targetTime          = pkg.time;
     this.targetPos           = pkg.pos;
     this.targetVelocity      = pkg.velocity;
     this.canStartInterpolate = true;
     this.targetHolding       = pkg.isHolding;
 }
Beispiel #3
0
        private void SendTransPkg()
        {
            TransPkg pkg = m_TransPkgPool.Get();

            pkg.time      = SyncTransUtils.Now;
            pkg.pos       = m_ball.transform.localPosition;
            pkg.velocity  = m_ball.Velocity;
            pkg.isHolding = false;

            // 模拟延时队列
            m_syncQue.AddLast(pkg);
        }