Beispiel #1
0
        public Player(AController controller)
        {
            m_started = false;
            m_controller = controller;
            m_currentObject = null;
            m_stopWatch = new Stopwatch();
            m_timeOffset = new TimeSpan(0);
            m_hasBeenActed = new List<bool>();
            m_delta = new Stopwatch();

            m_actors = new List<osu.HitActor>();

            DoubleTime = false;
            m_lastActId = -1;
        }
Beispiel #2
0
        public Player(AController controller)
        {
            m_started       = false;
            m_controller    = controller;
            m_currentObject = null;
            m_stopWatch     = new Stopwatch();
            m_timeOffset    = new TimeSpan(0);
            m_hasBeenActed  = new List <bool>();
            m_delta         = new Stopwatch();

            m_actors = new List <osu.HitActor>();

            DoubleTime  = false;
            m_lastActId = -1;
        }
Beispiel #3
0
        public void Update()
        {
            if (m_started)
            {
                TimeSpan elapsed = m_delta.Elapsed;
                m_delta.Restart();

                m_currentObject = null;
                osu.HitObject.Data m_nextObject = null;
                int actedId = -1;
                for (int i = m_songData.HitObjects.Count - 1; i >= 0; i--)
                {
                    if (PassedTime >= new TimeSpan(0, 0, 0, 0, (int)m_songData.HitObjects[i].HitData.Time))
                    {
                        if (m_hasBeenActed[i] == false)
                        {
                            m_currentObject = m_actors[i];
                            actedId = i;

                            if (actedId > m_lastActId && m_lastActId != -1)
                            {
                                m_hasBeenActed[m_lastActId] = true;
                            }

                            m_lastActId = actedId;
                            break;
                        }
                        else
                        {
                            if (m_nextObject == null)
                            {
                                if (i + 1 < m_songData.HitObjects.Count)
                                {
                                    m_nextObject = m_songData.HitObjects[i + 1].HitData;
                                }
                            }
                        }
                    }
                }

                if (m_currentObject != null)
                {
                    if (m_currentObject.HasBeenInit == false)
                    {
                        m_currentObject.Init(m_songData, m_controller, PassedTime, elapsed, DoubleTime);
                    }
                    m_hasBeenActed[actedId] = m_currentObject.Act(m_controller, PassedTime, elapsed, DoubleTime);
                }
                else
                {
                    //Interpolate
                    if (m_nextObject != null)
                    {
                        WinAPI.POINT cursor = new WinAPI.POINT();
                        WinAPI.GetCursorPos(ref cursor);
                        WinAPI.POINT dest = new WinAPI.POINT();
                        dest.x = m_nextObject.X;
                        dest.y = m_nextObject.Y;
                        osu.OsuOptions.Convert(ref dest, m_controller.WindowHandle.Size().x, m_controller.WindowHandle.Size().y);

                        Vector2 newpos = m_controller.WindowHandle.ConvertToScreen(new Vector2(dest.x, dest.y));
                        dest.x = newpos.x;
                        dest.y = newpos.y;
                        const double INTER_SPEED = 1.3f;
                        if (cursor.x < dest.x)
                        {
                            cursor.x += (int)(INTER_SPEED * elapsed.TotalMilliseconds);
                        }
                        if (cursor.x > dest.x)
                        {
                            cursor.x -= (int)(INTER_SPEED * elapsed.TotalMilliseconds);
                        }
                        if (cursor.y < dest.y)
                        {
                            cursor.y += (int)(INTER_SPEED * elapsed.TotalMilliseconds);
                        }
                        if (cursor.y > dest.y)
                        {
                            cursor.y -= (int)(INTER_SPEED * elapsed.TotalMilliseconds);
                        }
                        WinAPI.SetCursorPos(cursor.x, cursor.y);
                    }
                    if (actedId >= 0)
                    {
                        m_hasBeenActed[actedId] = true;
                    }
                }
            }
        }
Beispiel #4
0
        public void Update()
        {
            if (m_started)
            {
                TimeSpan elapsed = m_delta.Elapsed;
                m_delta.Restart();

                m_currentObject = null;
                osu.HitObject.Data m_nextObject = null;
                int actedId = -1;
                for (int i = m_songData.HitObjects.Count - 1; i >= 0; i--)
                {
                    if (PassedTime >= new TimeSpan(0, 0, 0, 0, (int)m_songData.HitObjects[i].HitData.Time))
                    {
                        if (m_hasBeenActed[i] == false)
                        {
                            m_currentObject = m_actors[i];
                            actedId         = i;

                            if (actedId > m_lastActId && m_lastActId != -1)
                            {
                                m_hasBeenActed[m_lastActId] = true;
                            }

                            m_lastActId = actedId;
                            break;
                        }
                        else
                        {
                            if (m_nextObject == null)
                            {
                                if (i + 1 < m_songData.HitObjects.Count)
                                {
                                    m_nextObject = m_songData.HitObjects[i + 1].HitData;
                                }
                            }
                        }
                    }
                }


                if (m_currentObject != null)
                {
                    if (m_currentObject.HasBeenInit == false)
                    {
                        m_currentObject.Init(m_songData, m_controller, PassedTime, elapsed, DoubleTime);
                    }
                    m_hasBeenActed[actedId] = m_currentObject.Act(m_controller, PassedTime, elapsed, DoubleTime);
                }
                else
                {
                    //Interpolate
                    if (m_nextObject != null)
                    {
                        WinAPI.POINT cursor = new WinAPI.POINT();
                        WinAPI.GetCursorPos(ref cursor);
                        WinAPI.POINT dest = new WinAPI.POINT();
                        dest.x = m_nextObject.X;
                        dest.y = m_nextObject.Y;
                        osu.OsuOptions.Convert(ref dest, m_controller.WindowHandle.Size().x, m_controller.WindowHandle.Size().y);

                        Vector2 newpos = m_controller.WindowHandle.ConvertToScreen(new Vector2(dest.x, dest.y));
                        dest.x = newpos.x;
                        dest.y = newpos.y;
                        const double INTER_SPEED = 1.3f;
                        if (cursor.x < dest.x)
                        {
                            cursor.x += (int)(INTER_SPEED * elapsed.TotalMilliseconds);
                        }
                        if (cursor.x > dest.x)
                        {
                            cursor.x -= (int)(INTER_SPEED * elapsed.TotalMilliseconds);
                        }
                        if (cursor.y < dest.y)
                        {
                            cursor.y += (int)(INTER_SPEED * elapsed.TotalMilliseconds);
                        }
                        if (cursor.y > dest.y)
                        {
                            cursor.y -= (int)(INTER_SPEED * elapsed.TotalMilliseconds);
                        }
                        WinAPI.SetCursorPos(cursor.x, cursor.y);
                    }
                    if (actedId >= 0)
                    {
                        m_hasBeenActed[actedId] = true;
                    }
                }
            }
        }