public EventStateControllerData GetData() { var data = new EventStateControllerData(); data.timeInState = timeInState; data.currentState = currentState.name.Contains("(") ? currentState.name.Substring(0, currentState.name.IndexOf("(")).Trim() : currentState.name; data.dialogManagerData = dialogManager.GetData(); data.eventObjectIds = (eventObjects != null ? new List<EventObject>(eventObjects) : new List<EventObject>()) .Select(eventObject => eventObject.ObjectId).ToList(); return data; }
public void SetData(EventStateControllerData data) { timeInState = data.timeInState; if (data.currentState != null && data.currentState != "") { currentState = GameObject.Instantiate(ResourceManager.GetEventState(data.currentState)); currentState.name = currentState.name.Contains("(") ? currentState.name.Substring(0, currentState.name.IndexOf("(")).Trim() : currentState.name; var bgmAction = currentState.enterActions.Last<Action>(action => action is PlayBgmAction); if (bgmAction) { bgmAction.Act(this); } } List<EventObject> loadedEventObjects = new List<EventObject>(); foreach(int eventObjectId in data.eventObjectIds) { EventObject[] eventObjects = FindObjectsOfType<EventObject>(); foreach(EventObject eventObject in eventObjects) { if (eventObject.ObjectId == eventObjectId) { loadedEventObjects.Add(eventObject); } } }; eventObjects = loadedEventObjects.ToArray(); AwakeObj(); dialogManager.SetData(data.dialogManagerData); sceneWasLoaded = true; }