/// <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); }
/// <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); }
/// <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)); }
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"); } }
/// <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); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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; }
/// <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); }