public void deflash()
 {
     state     = IMState.HIDING;
     up        = true;
     flashtime = 0;
 }
        void Update()
        {
            if (tofadewhite)
            {
                foreach (Transform t in mainworld.transform)
                {
                    Fade f = t.GetComponent <Fade>();
                    if (f != null && f.image != null)
                    {
                        tofade = false;
                        f.FadeOut();
                    }
                }
            }

            switch (state)
            {
            case IMState.FLASHING:
                if (up)
                {
                    flashtime   += Time.deltaTime * 4f;
                    g.rampOffset = flashtime > 1f ? 1f : flashtime;
                    if (flashtime > 1f)
                    {
                        up        = false;
                        flashtime = 1f;
                    }
                }
                else
                {
                    flashtime -= Time.deltaTime * 4f;

                    g.rampOffset = flashtime < 0f ? 0f : flashtime;
                    if (g.rampOffset == 0f)
                    {
                        state = IMState.COUNTING;
                    }
                    time_to_show = 0;
                }
                break;

            case IMState.COUNTING:
                time_to_show += Time.deltaTime;
                if (time_to_show > showtime)
                {
                    showOptions();
                    state = IMState.OPTIONS;
                }
                break;

            case IMState.HIDING:
                if (up)
                {
                    flashtime   += Time.deltaTime * 4f;
                    g.rampOffset = flashtime > 1f ? 1f : flashtime;
                    if (flashtime > 1f)
                    {
                        up        = false;
                        flashtime = 1f;
                        state     = IMState.HIDING2;
                        g.enabled = false;
                        white.SetActive(true);
                        white.GetComponent <Image>().CrossFadeAlpha(0f, 0.5f, false);
                    }
                }
                break;

            case IMState.HIDING2:
                waithalf += Time.deltaTime;
                if (waithalf > 0.5f)
                {
                    state = IMState.NONE;
                    up    = false;
                    Game.main.eventFinished(ev);
                    waithalf = 0;
                }
                break;

            default:
                break;
            }
        }
 public void flash()
 {
     state     = IMState.FLASHING;
     up        = true;
     flashtime = -1;
 }