/// <summary> /// Validates the transition from the current state to the nextBattleState passed in. /// </summary> /// <param name="nextBattleState"> The desired next battle state. </param> /// <returns> Returns the next state or null depending on the validity of the state transition requested. </returns> private IShowdownState ValidateStateTransition(ShowdownState.ShowdownStateType nextBattleState) { IShowdownState nextState = null; if (!currentState.StateType.Equals(nextBattleState)) { ShowdownStateTransition transition = new ShowdownStateTransition(currentState.StateType, nextBattleState); if (!transitions.TryGetValue(transition, out nextState)) { UnityEngine.Debug.Log("Invalid Transition from:" + currentState.StateType.ToString() + " to:" + nextBattleState.ToString()); } } return(nextState); }
/// <summary> /// Overrides the Equals operator so that we can compare our custom types to one another. /// </summary> /// <param name="obj"> the object to compare.</param> /// <returns> True if objects are the same, false if they are not. </returns> public override bool Equals(object obj) { ShowdownStateTransition other = obj as ShowdownStateTransition; return(other != null && this.currentState == other.currentState && this.nextState == other.nextState); }