/// <summary>
        /// 收集本地输入,通过服务器发送给其他玩家
        /// </summary>
        /// <returns></returns>
        private SyncedData UpdateData()
        {
            Debug.Log("UpdateData");
            SyncedData result;

            if (replayMode == ReplayMode.LOAD_REPLAY)
            {
                result = null;
            }
            else
            {
                SyncedData @new = SyncedData.pool.GetNew();
                @new.Init(localPlayer.ID, ticks);
                GetLocalData(@new.inputData); //调用OnSyncedInput();输入数据给到@new.inputData里面
                localPlayer.AddData(@new);    //数据塞给TSPlayer的controls
                if (communicator != null)
                {
                    localPlayer.GetSendData(ticks, _syncedDataCacheUpdateData);                                                     //从TSplayer的controls里取数据
                    communicator.OpRaiseEvent(SEND_CODE, SyncedData.Encode(_syncedDataCacheUpdateData), true, auxActivePlayersIds); //将自己的输入数据发给其他玩家
                }
                result = @new;
            }
            return(result);
        }
示例#2
0
 protected override void OnSyncedDataReceived(TSPlayer player, List <SyncedData> data)
 {
     player.AddData(data);
 }