public override void CopyInfo(SerializedClass info) { LevelStateChangeInfo i = (LevelStateChangeInfo)info; levelName = i.LevelName; stateName = i.ModifierName; action = i.Action; }
public void ChangeLevelState(LevelStateChangeInfo changeInfo) { int levelStateInfoIndex = gameState.LevelStates.IndexOf(new LevelStateInfo(changeInfo.LevelName)); if (levelStateInfoIndex != -1) { gameState.LevelStates[levelStateInfoIndex].ChangeState(changeInfo.ModifierName, changeInfo.Action); } else { if (changeInfo.LevelName != CurrentLevelName) { int unknownLevelStateInfoIndex = gameState.UnknownLevelStateInfo.IndexOf(new UnknownLevelStateInfo(changeInfo.LevelName)); if (unknownLevelStateInfoIndex == -1) // If new level hasn't been registered { gameState.UnknownLevelStateInfo.Add(new UnknownLevelStateInfo(changeInfo.LevelName, changeInfo.ModifierName)); int indexOfAddedItem = gameState.UnknownLevelStateInfo.Count - 1; gameState.UnknownLevelStateInfo[indexOfAddedItem].ChangeState(changeInfo.ModifierName, changeInfo.Action); Debug.LogWarning("GameManager/ChangeLevelState (LevelStateChangeInfo change) : level of levelChange isn't registered."); } else { // The level is already registered in UnknownLevelStateInfo // Look if the modifier has been registered in this level int unknownModIndex = gameState.UnknownLevelStateInfo[unknownLevelStateInfoIndex]. UnknownLevelModifiers.IndexOf(new LevelState.UnknownLevelModifier(changeInfo.ModifierName)); if (unknownModIndex == -1) { // Modifier hasn't been registered. Will add that modifier. gameState.UnknownLevelStateInfo[unknownLevelStateInfoIndex].UnknownLevelModifiers.Add(new LevelState.UnknownLevelModifier(changeInfo.ModifierName)); // Then gotta Trigger/Untrigger that modifier } gameState.UnknownLevelStateInfo[unknownLevelStateInfoIndex].ChangeState(changeInfo.ModifierName, changeInfo.Action); } } } if (changeInfo.LevelName == CurrentLevelName) { currentLevelState.ChangeState(changeInfo.ModifierName, changeInfo.Action); } }