Beispiel #1
0
 private WarnState()
 {
     if (_instance != null)
     {
         return;
     }
     _instance = this;
 }
Beispiel #2
0
    private void UpdateWarningState(List <VoosActor> actorsToControl)
    {
        messagePanelLazy = messagePanelLazy ?? GameObject.FindObjectOfType <PersistentMessagePanel>();
        if (messagePanelLazy == null)
        {
            return;
        }
        // If we haven't been assigned a player number yet, don't warn.
        if (GetMyPlayerNumber() <= 0)
        {
            return;
        }
        // Whenever we go into edit mode, we reset to "not warned state" to warn the user again if they
        // go into play mode.
        if (userMain.InEditMode())
        {
            warnState = WarnState.NO_WARNING;
            messagePanelLazy.Hide();
            return;
        }
        switch (warnState)
        {
        case WarnState.NO_WARNING:
            if (actorsToControl.Count != 1)
            {
                warnState       = WarnState.COUNTING_DOWN;
                countdownToWarn = DELAY_BEFORE_WARNING;
            }
            break;

        case WarnState.COUNTING_DOWN:
            if (actorsToControl.Count == 1)
            {
                warnState = WarnState.NO_WARNING;
            }
            if (engine.GetIsRunning() && 0 > (countdownToWarn -= Time.unscaledDeltaTime))
            {
                warnState = WarnState.SHOWING_WARNING;
                ShowControlsWarning(actorsToControl);
            }
            break;

        case WarnState.SHOWING_WARNING:
            if (actorsToControl.Count == 1)
            {
                warnState = WarnState.NO_WARNING;
                messagePanelLazy.Hide();
            }
            break;

        default:
            throw new System.Exception("Invalid warn state " + warnState);
        }
    }