GameObject CreateActionFromData(StoryActionData sad, System.Action actionActivated) { if (sad.actionType == StoryActionData.ActionType.Skill) { return(CreateSkillStoryActionVisuals(CreateSkillStoryAction(sad), actionActivated)); } else { return(CreateStoryActionVisuals(sad, actionActivated)); } }
GameObject CreateStoryActionVisuals(StoryActionData data, System.Action actionActivated) { var actionGO = GameObject.Instantiate(PrefabGetter.storyActionPrefab) as GameObject; var visuals = actionGO.GetComponent <StoryActionVisuals>(); visuals.restrictions = data.restrictions.ConvertAll(r => r.Create(playerCharacter.GetCharacter())); visuals.Setup(data.storyDescription, data.gameplayDescription); visuals.ActivatedEvent += actionActivated; if (data.successMessage != "") { visuals.FinishedEvent += () => textArea.AddLine(data.successMessage); } visuals.actionEvents = data.successEvents.ConvertAll(ae => ae.Create()); return(actionGO); }
SkillStoryAction CreateSkillStoryAction(StoryActionData actionData) { var sa = DesertContext.StrangeNew <SkillStoryAction>(); sa.skill = actionData.skill; sa.difficulty = actionData.difficulty; sa.storyDescription = actionData.storyDescription; sa.gameDescription = actionData.gameplayDescription; sa.successMessage = actionData.successMessage; sa.failMessage = actionData.failedMessage; sa.successEvents = actionData.successEvents.ConvertAll(ae => ae.Create()); sa.failEvents = actionData.failEvents.ConvertAll(ae => ae.Create()); sa.restrictions = actionData.restrictions.ConvertAll(r => r.Create(playerCharacter.GetCharacter())); return(sa); }
public override void OnInspectorGUI() { storyAction = target as StoryActionData; storyAction.actionType = (StoryActionData.ActionType)EditorGUILayout.EnumPopup("Action Type", storyAction.actionType); ShowDescriptions(); ShowRestrictions(); if (storyAction.actionType == StoryActionData.ActionType.Skill) { ShowSkillActionData(); } else if (storyAction.actionType == StoryActionData.ActionType.Immediate) { ShowImmediateActionData(); } EditorUtility.SetDirty(storyAction); }
void DestroyAction(StoryActionData data) { GameObject.DestroyImmediate(data, true); }