コード例 #1
0
        /// <summary>
        /// Get an transition based on it's kind.
        /// It will new the transition if it hasn't been used yet.
        /// This will also call the Reset from BaseTransition
        /// </summary>
        /// <param name="kind">The kind of transition</param>
        /// <returns>An resetted transition based on the kind</returns>
        public static BaseTransition GetTransition(TransitionKind kind)
        {
            if (transitions == null)
            {
                transitions = new Dictionary <TransitionKind, BaseTransition>();
            }

            if (!transitions.Keys.Contains <TransitionKind>(kind))
            {
                switch (kind)
                {
                case TransitionKind.FadeIn:
                    transitions.Add(kind, new FadeInTransition());
                    break;

                case TransitionKind.FadeOut:
                    transitions.Add(kind, new FadeOutTransition());
                    break;
                }
            }


            BaseTransition transition = transitions[kind];

            transition.Reset();
            return(transition);
        }
コード例 #2
0
        private ScreenManager()
        {
            screenStack = new List<BaseScreen>();

            transition = new FadeInTransition();
        }
コード例 #3
0
        /// <summary>
        /// Change the current screen. 
        /// This will load the content of the screen if necessary
        /// </summary>
        /// <param name="screen">The screen to add to the stack</param>
        public void SetScreen(BaseScreen screen)
        {
            screenStack.Add(screen);

            if (!screen.isContentLoaded)
            {
                Task.Factory.StartNew(() =>
                {
                    this.state = State.Loading;
                    screen.LoadContent(Game1.Instance.Content);
                    this.transition = TransitionFactory.GetTransition(screen.transitionKind);
                    this.transition.Start();
                    this.state = State.Transitioning;
                });
            }
        }