示例#1
0
        void Tick(object s, EventArgs e)
        {
            if (state == State.Exiting)
            {
                return;
            }
            if (state != State.NoSC2 && !Process.IsSC2Open())
            {
                state = State.NoSC2;
                return;
            }

            if (state == State.NoSC2 || state == State.UnsupportedVersion)
            {
                if (Process.IsSC2Open())
                {
                    Process.Init();
                    if (Offsets.Supports(Process.Version))
                    {
                        Offsets.Init(Process.Version);
                        state = State.NoGame;
                    }
                    else
                    {
                        state = State.UnsupportedVersion;
                    }
                }
                else
                {
                    state = State.NoSC2;
                }
            }

            if (state > State.NoSC2 && !Offsets.Supports(Process.Version))
            {
                state = State.UnsupportedVersion;
            }

            try
            {
                if (state == State.NoGame && GameState.IsInGame())
                {
                    if (GameState.IsObserver())
                    {
                        UpdateScoreboard();
                    }
                    state = State.InGame;
                }
                else if ((state == State.InGame || state == State.EndGame) && !GameState.IsInGame())
                {
                    state = State.NoGame;
                }

                if (state == State.InGame)
                {
                    if (GameState.IsObserver())
                    {
                        CheckGameStatus();
                    }
                }
            }
            catch (InvalidOperationException f)
            {
                state = State.NoSC2;
            }
        }
示例#2
0
 public static bool IsInGame()
 {
     // 0.5s is a reasonably safe margin
     return(Offsets.Supports(Process.Version) &&
            Process.ReadInt(Offsets.GameTick) > 0x800);
 }