public override void OnInspectorGUI() { Quest quest = (Quest)target; QuestManager questManager = QuestManager.GetInstantiate(); List <Quest> allQuests = questManager.GetQuests(); GUIStyle boldStyle = new GUIStyle(); boldStyle.fontStyle = FontStyle.Bold; if (!allQuests.Contains(quest)) { if (eUtils.isPrefab(quest.gameObject)) { if (GUILayout.Button("!!! Registrate !!!")) { questManager.Registrate(quest); } } else { EditorGUILayout.LabelField("---Обратитесь к префабу для регистрации в Game!---"); } GUILayout.Space(10); } if (eUtils.isPrefab(quest.gameObject)) { EditorGUILayout.LabelField("---Для редактирования квеста вынесите его на сцену!---"); } else { EditorGUILayout.PropertyField(serializedObject.FindProperty("questName")); EditorGUILayout.PropertyField(serializedObject.FindProperty("shortDescription")); EditorGUILayout.PropertyField(serializedObject.FindProperty("client")); GUILayout.Space(10); EditorGUILayout.LabelField("Reward", boldStyle); eUtils.DrawMoneyInspecor(ref quest.reward); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(serializedObject.FindProperty("withDeadline")); if (quest.withDeadline) { EditorGUILayout.PropertyField(serializedObject.FindProperty("relativeDeadline")); } else { EditorGUILayout.LabelField(""); } EditorGUILayout.EndHorizontal(); if (quest.withDeadline) { eUtils.DrawTimeInspector(quest.deadline); eUtils.DrawTimeSelector(ref quest.deadline); } GUILayout.Space(10); EditorGUILayout.PropertyField(serializedObject.FindProperty("canBeRegistrated")); if (quest.canBeRegistrated) { EditorGUILayout.PropertyField(serializedObject.FindProperty("registrated")); } GUILayout.Space(10); EditorGUILayout.PropertyField(serializedObject.FindProperty("type")); EditorGUILayout.PropertyField(serializedObject.FindProperty("mainState")); int startIndex = EditorGUILayout.Popup("Start Logic Map", quest.GetLogicMaps().IndexOf(quest.startLogicMap), quest.GetLogicMapNames().ToArray()); if (startIndex != -1) { quest.startLogicMap = quest.logicMaps[startIndex]; } int endIndex = EditorGUILayout.Popup("End Logic Map", quest.GetLogicMaps().IndexOf(quest.endLogicMap), quest.GetLogicMapNames().ToArray()); if (endIndex != -1) { quest.endLogicMap = quest.logicMaps[endIndex]; } GUILayout.Space(10); eUtils.DrawLogicMapList(quest.logicMaps, quest.transform, ref showLogicMaps, serializedObject); GUILayout.Space(10); eUtils.DrawDialogList(quest.dialogs, quest.transform, ref showDialogs); GUILayout.Space(10); eUtils.DrawQuestStateList(quest.questStates, quest.transform, ref showStates, "Quest States"); GUILayout.Space(10); eUtils.DrawQuestObjectiveList(quest.questObjectives, quest.transform, ref showObjectives); GUILayout.Space(10); eUtils.DrawQuestEventList(quest.questEvents, quest.transform, ref showEvents); GUILayout.Space(10); if (GUILayout.Button(string.Format("File Notes ({0})", quest.notes.Count))) { showNotes = !showNotes; } if (showNotes) { EditorGUILayout.PropertyField(serializedObject.FindProperty("notes"), true); GUI.skin.label.wordWrap = true; foreach (FileNoteContainer note in quest.notes) { GUILayout.Label(note.GetText()); } } serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(quest); } }
public void Realize(iEffectsContainer effectsContainer, Team team) { this.effectsContainer = effectsContainer; Game game = Game.GetInstantiate(); Agency agency = Agency.GetInstantiate(); QuestManager questManager = QuestManager.GetInstantiate(); DetectiveManager detectiveManager = DetectiveManager.GetInstantiate(); UI.InterfaceManager interfaceManager = UI.InterfaceManager.GetInstantiate(); if (type == EffectType.INSTANTIATE_QUEST) { GameObject goFolder = null; if (agency.transform.Find("Quests")) { goFolder = agency.transform.Find("Quests").gameObject; } else { goFolder = new GameObject("Quests"); goFolder.transform.parent = agency.transform; } Quest questInstance = Instantiate(quest, goFolder.transform); agency.quests.Add(questInstance); questInstance.Realize(); } else if (type == EffectType.CHANGE_QUEST) { GetQuest().ChangeMainState(mainState); } else if (type == EffectType.CHANGE_TASK) { if (effectsContainer is QuestTask) { team.reportEvent.Add(questEvent); team.reportChangeTask.Add(task); team.reportTaskState.Add(mainState); if (mainState == MainState.Started && task.mainState == MainState.NotStarted) { team.reportQuest.Add(GetQuest()); List <string> keys = new List <string>() { questEvent.eventName, task.taskName }; FileNoteContainer noteContainer = FileNoteContainer.Create(Dialog.DialogManager.GetInstantiate().newTaskNote, team.transform, keys); team.reportNotes.Add(noteContainer); } } else { questEvent.ChangeTask(task, mainState); } } else if (type == EffectType.CHANGE_OBJECTIVE) { if (effectsContainer is QuestTask) { team.reportChangeObjective.Add(objective); team.reportObjectiveState.Add(mainState); } else { objective.state = mainState; } } else if (type == EffectType.CHANGE_QUEST_STATE || type == EffectType.CHANGE_DIALOG_STATE || type == EffectType.CHANGE_GLOBAL_STATE) { if (questState.type == QuestStateType.BOOL) { questState.boolValue = boolValue; } else if (questState.type == QuestStateType.INT) { questState.intValue = intValue; } else if (questState.type == QuestStateType.SPECIAL) { questState.specialValue = stringValue; } } else if (type == EffectType.ADD_FILE_NOTE) { foreach (FileNote fileNote in fileNotes) { if (fileNote != null) { if (effectsContainer is QuestTask) { team.reportQuest.Add(GetQuest()); team.reportNotes.Add(FileNoteContainer.Create(fileNote, team.transform)); } else { GetQuest().notes.Add(FileNoteContainer.Create(fileNote, GetQuest().transform)); } } } } else if (type == EffectType.ADD_ITEM) { if (team != null) { Item newItem = Instantiate(item); team.AddItem(newItem); team.reportQuest.Add(GetQuest()); FileNoteContainer noteContainer = FileNoteContainer.Create(Dialog.DialogManager.GetInstantiate().addItemNote, team.transform, newItem.itemName); team.reportNotes.Add(noteContainer); } else { Item newItem = Instantiate(item, agency.transform); agency.items.Add(newItem); } } else if (type == EffectType.CHANGE_MONEY) { agency.ChangeMoney(money); } else if (type == EffectType.REALIZE_TASK) { Team owner = effectsContainer.GetTeam(); if (owner != null) { if (!owner.targetTasks.Contains(task)) { owner.targetTasks.Insert(0, task); } } } else if (type == EffectType.REALIZE_LOGIC_MAP) { if (logicMapOwner == LogicMap.LogicMapOwnerType.QUEST) { logicMap.RealizeLogicMap(GetQuest(), team); } else if (logicMapOwner == LogicMap.LogicMapOwnerType.QUEST_TASK) { logicMap.RealizeLogicMap(task, team); } } else if (type == EffectType.START_DIALOG) { Dialog.DialogManager.GetInstantiate().StartDialog(dialog, team, GetQuest()); } else if (type == EffectType.FINALIZE_TASK) { task.FinalizeTask(); } else if (type == EffectType.TEAM_GOTO_OFFICE) { if (team != null) { team.GoTo(agency.GetOffice(), team.GetPriorityWay(), true); } } else if (type == EffectType.TEAM_GOTO_HOMES) { if (team != null) { for (int i = 0; i < team.detectives.Count; i++) { team.detectives[i].ReturnToHome(); i--; } } } else if (type == EffectType.TEAM_GOTO_EVENT) { if (team != null) { game.ChangeGameState(GameState.WAIT_ACTIVITY_CHOICE); detectiveManager.teamOnWait = team; interfaceManager.detectiveRow.ResetRow(); } } else if (type == EffectType.TELEPORT_TO_EVENT) { if (team.curTarget is QuestEvent) { ((QuestEvent)team.startPlace).RemoveTeam(team); team.startPlace = questEvent; questEvent.AddTeam(team); } } else if (type == EffectType.TIMELINE_ACTION_CHANGE_QUEST_STATE) { Timeline timeline = Timeline.GetInstantiate(); GameObject goAction = new GameObject(string.Format("TimelineAction_ChangeQuestState")); goAction.transform.parent = timeline.transform; TimelineAction action = goAction.AddComponent <TimelineAction>(); action.actionType = TimelineActionType.CHANGE_QUEST_STATE; action.questState = questState; action.flag = boolValue; action.value = intValue; action.specialValue = stringValue; if (waitType == LogicMap.WaitType.ABSOLUTE) { action.timer = GameTime.ConvertToFloat(waitTime); } else if (waitType == LogicMap.WaitType.RELATION) { action.timer = timeline.GetTime() + GameTime.ConvertToFloat(waitTime); } timeline.RegistrateAction(action); } else if (type == EffectType.CHECK_QUEST) { } }