コード例 #1
0
    // randomize background theme
    // - no repeating themes
    public void RandomizeBackgroundTheme()
    {
        // stop if already transitioning
        if (m_backgroundTransitioning)
        {
            return;
        }

        // loop until backgound does not repeat
        bool changed = false;

        while (!changed)
        {
            // randomize a theme index
            BackgroundTheme newTheme = (BackgroundTheme)Random.Range(0, m_backgrounds.Count);

            // if not current theme, change theme
            if (m_currentTheme != newTheme)
            {
                StartCoroutine(SetBackgroundThemeWithTransition(newTheme));
                m_currentTheme = newTheme;
                changed        = true;
            }
        }
    }
コード例 #2
0
 // set background theme
 private void SetBackgroundTheme(BackgroundTheme theme)
 {
     foreach (BackgroundThemeHolder background in m_backgrounds)
     {
         background.SetStatus(false);
     }
     m_currentTheme = theme;
     m_backgrounds[(int)m_currentTheme].SetStatus(true);
     m_backgrounds[(int)m_currentTheme].InitializePositions();
 }
コード例 #3
0
        private String GetImagePath(BackgroundTheme theme)
        {
            switch (theme)
            {
            case (BackgroundTheme.Morning): return(@"Resources\morning.jpg");

            case (BackgroundTheme.Day): return(@"Resources\day.jpg");

            case (BackgroundTheme.Evening): return(@"Resources\evening.jpg");

            default: return(@"Resources\night.jpg");
            }
        }
コード例 #4
0
 void ChangeStyleType()
 {
     if (!openAirBackground)
     {
         _currentStyleName = OpenAirStyle[Random.Range(0, OpenAirStyle.Count)];
         openAirBackground = true;
     }
     else
     {
         _currentStyleName = CavernStyle[Random.Range(0, CavernStyle.Count)];
         openAirBackground = false;
     }
     _currentTheme = _styleDictionary[_currentStyleName];
 }
コード例 #5
0
        private static void SetBackgroundColor(GridLabel target, BackgroundTheme theme)
        {
            switch (theme)
            {
            case BackgroundTheme.Black:
                target.Background = Brushes.Black;
                target.Foreground = Brushes.White;
                break;

            case BackgroundTheme.White:
                target.Background = Brushes.White;
                target.Foreground = Brushes.Black;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(theme), theme, null);
            }
        }
コード例 #6
0
    private IEnumerator SetBackgroundThemeWithTransition(BackgroundTheme theme)
    {
        m_backgroundTransitioning = true;

        // initialize transition
        InitializeTransition();
        m_transition.gameObject.SetActive(true);

        bool changed       = false;
        bool transitioning = true;

        while (transitioning)
        {
            // if dude move pass a threshold, change background
            if (!changed)
            {
                if (DudeController.instance.transform.position.y < m_transition.GetBackgroundY() - 5.0f)
                {
                    SetBackgroundTheme(theme);
                    changed = true;
                }
            }

            // if dude move pass a threashold, break from loop
            else
            {
                if (DudeController.instance.transform.position.y < m_transition.GetBackgroundY() - 12.0f)
                {
                    transitioning = false;
                }
            }

            yield return(null);
        }

        // deactivate transition
        m_transition.gameObject.SetActive(false);

        m_backgroundTransitioning = false;
    }
コード例 #7
0
    void InitializeBackgrounds()
    {
        _currentTheme    = _styleDictionary[_currentStyleName];
        _backgroundGroup = _currentTheme.BackgroundGroup;
        _foregroundGroup = _currentTheme.ForegroundGroup;
        //First background panel is to the left of the player;
        float firstBackgroundPositionX = -_currentTheme.Width;

        //group of elements that make one complete background image
        for (int i = 0; i < _backgroundGroup.Count; i++)
        {
            //layers in one background image
            foreach (var group in _backgroundGroup[i])
            {
                group.SetActive(true);
                group.transform.position = new Vector3(
                    firstBackgroundPositionX + _currentTheme.Width * i,
                    group.transform.position.y, group.transform.position.z);
            }
            _currentTheme.IncreaseBackgroundIndex();
        }

        for (int i = 0; i < _foregroundGroup.Count; i++)
        {
            //layers in one foreground image
            foreach (var group in _foregroundGroup[i])
            {
                group.SetActive(true);
                group.transform.position = new Vector3(
                    firstBackgroundPositionX + _currentTheme.Width * i,
                    group.transform.position.y, group.transform.position.z);
            }
            _currentTheme.IncreaseForegroundIndex();
        }
        _widthLastBackground = _widthLastForeground = _currentTheme.Width;
    }
コード例 #8
0
        public string AddToast(string title, string content, BackgroundTheme toastBg = BackgroundTheme.info)
        {
            var id    = Guid.NewGuid().ToString("N");
            var model = new ToastModel()
            {
                Title   = title,
                Content = content,
                Time    = DateTime.Now.ToShortTimeString(),
                ToastBg = toastBg
            };

            lock (dict)
                dict.Add(id, model);
            //如果配置了自动关闭
            if (AutoClose)
            {
                Task.Delay(AutoCloseTime).ContinueWith(t =>
                {
                    CloseToast(id);
                });
            }
            InvokeAsync(StateHasChanged);
            return(id);
        }
コード例 #9
0
 public BackgroundManager()
 {
     CurrentTheme = (BackgroundTheme)RandomProvider.Random.Next(0, 4);
     UpdateTheme();
 }