Exemple #1
0
 /// <summary>
 /// Add a state to the manager and active or desactive it.
 /// </summary>
 /// <param name="screen"></param>
 /// <param name="active"></param>
 public void Add(YnState state, bool isActive)
 {
     if (state.Active != isActive)
     {
         state.Enabled = isActive;
         state.Visible = isActive;
     }
     Add(state);
 }
Exemple #2
0
        /// <summary>
        /// Get the index of the screen
        /// </summary>
        /// <param name="name">State name</param>
        /// <returns>State index</returns>
        public int IndexOf(string name)
        {
            YnState state = Get(name);

            if (state != null)
            {
                return(_states.IndexOf(state));
            }

            return(-1);
        }
Exemple #3
0
        /// <summary>
        /// Add a new state to the manager. The screen is not activated or desactivated, you must manage it yourself
        /// </summary>
        /// <param name="state">Screen to add</param>
        public void Add(YnState state)
        {
            state.StateManager = this;

            if (_initialized)
            {
                state.Initialize();
            }

            if (_assetLoaded)
            {
                state.LoadContent();
            }

            _states.Add(state);
            _statesDictionary.Add(state.Name, _states.IndexOf(state));
        }
Exemple #4
0
        public void SetActive(string name, bool desactiveOtherScreens)
        {
            if (_statesDictionary.ContainsKey(name))
            {
                YnState activableState = _states[_statesDictionary[name]] as YnState;
                activableState.Active = true;

                if (desactiveOtherScreens)
                {
                    foreach (YnState screen in _states)
                    {
                        if (activableState != screen)
                        {
                            screen.Active = false;
                        }
                    }
                }
            }
            else
            {
                throw new StateManagerException("This screen name doesn't exists");
            }
        }
Exemple #5
0
        /// <summary>
        /// Replace a state by another state
        /// </summary>
        /// <param name="oldState">Old state in the collection</param>
        /// <param name="newState">New state</param>
        /// <returns>True if for success then false</returns>
        public bool Replace(YnState oldState, YnState newState)
        {
            int index = _states.IndexOf(oldState);

            if (index > -1)
            {
                newState.StateManager = this;
                _states[index]        = newState;

                if (_initialized && !newState.Initialized)
                {
                    newState.Initialize();
                }

                if (_assetLoaded && !newState.AssetLoaded)
                {
                    newState.LoadContent();
                }

                return(true);
            }

            return(false);
        }
Exemple #6
0
 /// <summary>
 /// Remove a screen to the Manager
 /// </summary>
 /// <param name="screen">Screen to remove</param>
 public void Remove(YnState state)
 {
     _states.Remove(state);
     _statesDictionary.Remove(state.Name);
 }
Exemple #7
0
 /// <summary>
 /// Get the index of the screen
 /// </summary>
 /// <param name="name">State</param>
 /// <returns>State index</returns>
 public int IndexOf(YnState state)
 {
     return(_states.IndexOf(state));
 }
Exemple #8
0
 /// <summary>
 /// Remove a screen to the Manager
 /// </summary>
 /// <param name="screen">Screen to remove</param>
 public void Remove(YnState state)
 {
     _states.Remove(state);
     _statesDictionary.Remove(state.Name);
 }
Exemple #9
0
 /// <summary>
 /// Add a state to the manager and active or desactive it.
 /// </summary>
 /// <param name="screen"></param>
 /// <param name="active"></param>
 public void Add(YnState state, bool isActive)
 {
     if (state.Active != isActive)
     {
         state.Enabled = isActive;
         state.Visible = isActive;
     }
     Add(state);
 }
Exemple #10
0
        /// <summary>
        /// Add a new state to the manager. The screen is not activated or desactivated, you must manage it yourself
        /// </summary>
        /// <param name="state">Screen to add</param>
        public void Add(YnState state)
        {
            state.StateManager = this;

            if (_initialized)
                state.Initialize();

            if (_assetLoaded)
                state.LoadContent();

            _states.Add(state);
            _statesDictionary.Add(state.Name, _states.IndexOf(state));
        }
Exemple #11
0
        /// <summary>
        /// Replace a state by another state
        /// </summary>
        /// <param name="oldState">Old state in the collection</param>
        /// <param name="newState">New state</param>
        /// <returns>True if for success then false</returns>
        public bool Replace(YnState oldState, YnState newState)
        {
            int index = _states.IndexOf(oldState);

            if (index > -1)
            {
                newState.StateManager = this;
                _states[index] = newState;

                if (_initialized && !newState.Initialized)
                    newState.Initialize();

                if (_assetLoaded && !newState.AssetLoaded)
                    newState.LoadContent();

                return true;
            }

            return false;
        }
Exemple #12
0
 /// <summary>
 /// Get the index of the screen
 /// </summary>
 /// <param name="name">State</param>
 /// <returns>State index</returns>
 public int IndexOf(YnState state)
 {
     return _states.IndexOf(state);
 }