public ReplayData loadFile(string filename)
        {
            Stream          inputStream    = File.OpenRead(filename);
            BinaryFormatter inputFormatter = new BinaryFormatter();

            mData         = ( ReplayData )inputFormatter.Deserialize(inputStream);
            mMaxIndex     = mData.mDataList.Count;
            mCurrentState = DataPlayerState.Ready;
            return(mData);
        }
 public void pause()
 {
     if (mCurrentState == DataPlayerState.Playing)
     {
         mCurrentState = DataPlayerState.Paused;
     }
     else if (mCurrentState == DataPlayerState.Paused)
     {
         beginPlay();
     }
 }
        private void play()
        {
            if (mCurrentState == DataPlayerState.Uninitialized)
            {
                throw new BadJooJooException("Can't start playing data if uninitialized");
            }

            mCurrentState = DataPlayerState.Playing;

            mPreciseCounter.Start();
            while ((mCurrentIndex < mMaxIndex) && mCurrentState == DataPlayerState.Playing)
            {
                SensorDataEntry data = mData.mDataList[mCurrentIndex];
                if (mPreciseCounter.Elapsed.CompareTo(data.timeSpan - mOffsetSpan) >= 0)
                {
                    NotifyObservers(data);
                    mCurrentIndex++;
                }
                Thread.SpinWait(500);
            }
            ;

            Logger.Info("Player leaving while loop");
            if (mCurrentIndex >= mMaxIndex)
            {
                mPreciseCounter.Reset();
                //mMaxIndex = 0;
                mCurrentIndex = 0;
                mCurrentState = DataPlayerState.Finished;
                mOffsetSpan   = TimeSpan.Zero;
                Logger.Info("Player leaving beause current index > max");
                return;
            }

            if (mCurrentState == DataPlayerState.Paused)
            {
                Logger.Info("Player leaving beause state change to pause");
                mPreciseCounter.Stop();
                return;
            }
        }
Пример #4
0
            internal static void adjustCollabIcon(CelesteNetPlayerListComponent.BlobPlayer blob, DataPlayerState state)
            {
                // if we are in a collab map, change the icon displayed in the CelesteNet player list to the lobby icon.
                AreaData data = AreaData.Get(state.SID);

                if (data != null)
                {
                    string lobbySID = GetLobbyForLevelSet(data.LevelSet);
                    if (lobbySID != null)
                    {
                        blob.Location.Icon = AreaData.Get(lobbySID)?.Icon ?? blob.Location.Icon;
                    }
                }
            }