// Update is called once per frame void Update() { if (currentlyInteracting) { if (Input.GetKeyDown(KeyCode.Return)) { if (!currentReaction.NextStep()) { if (!currentReactionCollection.TryNextReaction()) { Debug.Log("Free to go"); currentReaction = null; currentReactionCollection = null; currentlyInteracting = false; reactionDisplayArea.gameObject.SetActive(false); Destroy(reactionDisplayArea.transform.GetChild(0).gameObject); allowMovement.Raise(); } else { currentReaction = currentReactionCollection.GetNextReaction(); Destroy(reactionDisplayArea.transform.GetChild(0).gameObject); var reactionInstance = Instantiate(currentReaction.getReactionObject(), reactionDisplayArea.transform); currentReaction.React(reactionInstance); } } } } }
private void OnEnable() { reactionCollection = (ReactionCollection)target; reactionsProperty = serializedObject.FindProperty(reactionsPropName); CheckAndCreateSubEditors(reactionCollection.reactions); SetReactionNamesArray(); }
private void OnEnable() { reactionCollection = (ReactionCollection)target; reactionsProperty = serializedObject.FindProperty(reactionsPropName); PrepareNestedEditors(reactionCollection.reactions); FillReactionNamesArray(); }
private int SelectedIndex; // Property which is maintained to identify the currently selected index in the editor private void OnEnable() { // Reference current instance, properties of the serialized object (should match name in reaction collection) ReactionCollection = (ReactionCollection)target; ReactionsProperty = serializedObject.FindProperty("Reactions"); RecreateSubEditors(ReactionCollection.Reactions); SetReactionNamesArray(); }
// Pincer Mode에서 아이템을 얻을 때, 얻은 아이템의 정보를 Displayer 좌측 상단에 전송 public void GetItem(string itemName, string itemExp, string talkScript, ReactionCollection afterReaction) { // 기존의 코루틴이 실행중이면 중단 if (talkScriptCoroutine != null) { StopCoroutine(itemInfoCoroutine); } if (talkScriptCoroutine != null) { StopCoroutine(talkScriptCoroutine); } // 아무런 아이템(문서)를 얻지 못한 경우 if (itemName == "") { } // 정보를 얻은 경우 else if (itemName == "기 록") { // 문서 획득 효과음 출력 audioSource.clip = audioClipForDocu; audioSource.Play(); // 얻은 문서를 작은 Panel에 담아 화면에 표시 gettingItemName.text = itemName; gettingItemExp.text = itemExp; // 문서 획득 창이 꺼질때 발생되는 이벤트를 기록 this.afterReaction = afterReaction; gettingItemPanel.SetActive(true); } // 아이템을 얻은 경우 else { // 아이템 획득 효과음 출력 audioSource.clip = audioClipForItem; audioSource.Play(); // 얻은 아이템을 정보를 기록 gettingItemName.text = itemName; gettingItemExp.text = itemExp; // 아이템 획득 창이 꺼질때 발생되는 이벤트를 기록 this.afterReaction = afterReaction; gettingItemPanel.SetActive(true); } // 아이템 정보를 Displayer 좌측 상단에 전달하여 표시하는 코루틴 실행 itemInfoCoroutine = ItemInfoText(itemName, itemExp); StartCoroutine(itemInfoCoroutine); // NPC 대사를 Displayer 좌측 하단에 전달하여 표시하는 코루틴 실행 talkScriptCoroutine = TalkScriptText(talkScript); StartCoroutine(talkScriptCoroutine); }
private void OnEnable() // fidning target, cash it, find serialized property, i create subeditors, { reactionCollection = (ReactionCollection)target; reactionsProperty = serializedObject.FindProperty(reactionsPropName); CheckAndCreateSubEditors(reactionCollection.reactions); SetReactionNamesArray(); }
private void OnEnable() { reactionCollection = (ReactionCollection)target; //Caching the target of the editor reactionsProperty = serializedObject.FindProperty(reactionsPropName); CheckAndCreateSubEditors(reactionCollection.reactions); //Creates the subeditors that are needed SetReactionNamesArray(); }
public static ReactionCollection CreateReactionCollection(string description, string elementDescription) { ReactionCollection newReactionCollection = CreateInstance <ReactionCollection>(); newReactionCollection.reactionCollectionDescription = description; newReactionCollection.reactionCollection = new Reaction[1]; newReactionCollection.reactionCollection[0] = ReactionEditor.CreateReaction(elementDescription, typeof(DefaultReaction)); return(newReactionCollection); }
// Called when this Script is Enabled private void OnEnable() { // Cache the Target reactionCollection = (ReactionCollection)target; // Set Reaction Property by Finding the Property in Target reactionProperty = serializedObject.FindProperty(reactionPropName); // Check and Create the New ReactionEditors (subEditors) CheckAndCreateSubEditors(reactionCollection.reactions); // Create the Reaction Names SetReactionNamesArray(); }
// Caching the vertical spacing between GUI elements. private void OnEnable() { // Cache the target. reactionCollection = (ReactionCollection)target; // Cache the SerializedProperty reactionsProperty = serializedObject.FindProperty(reactionsPropName); // If new editors are required for Reactions, create them. CheckAndCreateSubEditors(reactionCollection.reactions); // Set the array of types and type names of subtypes of Reaction. SetReactionNamesArray(); }
public void ShowChoiceFrame(string firstText, ReactionCollection firstReaction) { gameObject.SetActive(true); this.firstText.text = firstText; firstButton.onClick.AddListener(delegate { transform.parent.GetComponent <TextDisplayer>().reactionButton.enabled = true; firstReaction.InitAndReact(); HideChoiceFrame(); }); StartCoroutine(Visible()); }
public void TriggerReaction(ReactionCollection reactionCollection) { if (!currentlyInteracting) { reactionDisplayArea.SetActive(true); currentlyInteracting = true; currentReactionCollection = reactionCollection; currentReaction = reactionCollection.GetNextReaction(); var reactionInstance = Instantiate(currentReaction.getReactionObject(), reactionDisplayArea.transform); currentReaction.React(reactionInstance); } else { Debug.LogError("Can't run multiple reactions at once"); } }
// 아이템(문서) 획득 Panel 제거 public void OnClickExitOnGettingPanel() { // 클릭 효과음 출력 audioSource.clip = audioClipForClick; audioSource.Play(); // Panel 제거 gettingItemPanel.SetActive(false); // 만약 after 이벤트가 등록되어 있으면 실행 if (afterReaction != null) { afterReaction.InitAndReact(); afterReaction = null; } }
public void SetReferences(ref ReactionCollection caller) { int callerID = caller.GetInstanceID(); if (!ReactionCollection.ReactionReferences.Contains(callerID)) { /*Make new refrences here and add them to dictionary*/ if (caller.reactions.Length > 0) { for (int i = 0; i < caller.reactions.Length; i++) { caller.reactions[i] = Instantiate(caller.reactions[i]); } } ReactionCollection.ReactionReferences.Add(callerID); } }
// Caching the vertical spacing between GUI elements. private void OnEnable() { // Cache the target. reactionCollection = (ReactionCollection)target; if (reactionCollection.Reactions == null) { reactionCollection.Reactions = new Reaction[0]; } verticalSpacing = EditorGUIUtility.standardVerticalSpacing; // Cache the SerializedProperty reactionsProperty = serializedObject.FindProperty(reactionsPropName); CleanupEmptyReactions(); // If new editors are required for Reactions, create them. CheckAndCreateSubEditors(reactionCollection.Reactions); // Set the array of types and type names of subtypes of Reaction. SetReactionNamesArray(); }
public static Dictionary <string, ConditionCollection> nodeA() { GameObject nodeAgo = nodes.GetNode("A"); SceneSounds ss = FindObjectOfType <SceneSounds> (); AudioReaction whoosh_sound = new AudioReaction(); whoosh_sound.audioSource = nodeAgo.GetComponent <AudioSource>() as AudioSource; whoosh_sound.audioClip = ss.getSceneSoundByName("movewhoosh").clip; whoosh_sound.delay = 0.0f; //float right ConditionCollection cc = new ConditionCollection(); ReactionCollection temp_react_collection = new ReactionCollection(); MoveReaction temp_react = new MoveReaction(); temp_react.destination = "B"; temp_react_collection.reactions = new Reaction[] { temp_react, whoosh_sound }; cc.reactionCollection = temp_react_collection; Condition temp_cond = new Condition(); temp_cond.toEval = () => { return(true); }; cc.requiredConditions = new Condition[] { temp_cond }; //float left ConditionCollection floatleftcc = new ConditionCollection(); ReactionCollection floatleft_react_collection = new ReactionCollection(); ReactionCollection floatleft_negreact_collection = new ReactionCollection(); PlayerTextReaction floatleft_react = new PlayerTextReaction(); floatleft_react.message = "I'm outta here."; floatleft_react.delay = 0f; SceneReaction win_reaction = new SceneReaction(); win_reaction.delay = 0; win_reaction.toLoad = 3; floatleft_react_collection.reactions = new Reaction[] { floatleft_react, win_reaction }; PlayerTextReaction floatleft_neg_react = new PlayerTextReaction(); floatleft_neg_react.message = "I can't get out ... London La Croix will see."; floatleft_neg_react.delay = 0f; AudioReaction nooutside_react_sound = new AudioReaction(); nooutside_react_sound.audioSource = nodeAgo.GetComponent <AudioSource>() as AudioSource; nooutside_react_sound.audioClip = ss.getSceneSoundByName("nooutside").clip; nooutside_react_sound.delay = 0.0f; floatleft_negreact_collection.reactions = new Reaction[] { floatleft_neg_react, nooutside_react_sound }; floatleftcc.reactionCollection = floatleft_react_collection; floatleftcc.negReactionCollection = floatleft_negreact_collection; Condition floatleft_cond = new Condition(); floatleft_cond.toEval = () => { return((bool)GameData.GlobalBools["can_exit_tent"]); }; floatleftcc.requiredConditions = new Condition[] { floatleft_cond }; floatleftcc.reactionCollection.DoInit(); floatleftcc.negReactionCollection.DoInit(); //look ConditionCollection cclook = new ConditionCollection(); ReactionCollection look_react_collection = new ReactionCollection(); PlayerTextReaction look_react = new PlayerTextReaction(); look_react.message = "UGH! this music... gotta break out of here."; look_react.delay = 0.0f; AudioReaction concert_react_sound = new AudioReaction(); concert_react_sound.audioSource = nodeAgo.GetComponent <AudioSource>() as AudioSource; concert_react_sound.audioClip = ss.getSceneSoundByName("concert").clip; concert_react_sound.delay = 0.0f; look_react_collection.reactions = new Reaction[] { look_react, concert_react_sound }; Condition always_true_cond = new Condition(); always_true_cond.toEval = () => { return(true); }; cclook.reactionCollection = look_react_collection; cclook.requiredConditions = new Condition[] { always_true_cond }; cclook.reactionCollection.DoInit(); Dictionary <string, ConditionCollection> htm = new Dictionary <string, ConditionCollection>(); htm.Add("float right", cc); htm.Add("float left", floatleftcc); htm.Add("look", cclook); return(htm); }
private void OnEnable() { editor = (ReactionCollection)target; reactionCollectionProperty = serializedObject.FindProperty("reactionCollection"); }
public static Dictionary <string, ConditionCollection> nodeC() { GameObject nodeCgo = nodes.GetNode("C"); SceneSounds ss = FindObjectOfType <SceneSounds> (); AudioReaction whoosh_sound = new AudioReaction(); whoosh_sound.audioSource = nodeCgo.GetComponent <AudioSource>() as AudioSource; whoosh_sound.audioClip = ss.getSceneSoundByName("movewhoosh").clip; whoosh_sound.delay = 0.0f; //float left ConditionCollection ccfloatleft = new ConditionCollection(); ReactionCollection floatleft_react_collection = new ReactionCollection(); MoveReaction floatleft_react = new MoveReaction(); floatleft_react.destination = "B"; floatleft_react_collection.reactions = new Reaction[] { floatleft_react, whoosh_sound }; ccfloatleft.reactionCollection = floatleft_react_collection; Condition always_true_cond = new Condition(); always_true_cond.toEval = () => { return(true); }; ccfloatleft.requiredConditions = new Condition[] { always_true_cond }; //float right ConditionCollection ccfloatright = new ConditionCollection(); ReactionCollection floatright_react_collection = new ReactionCollection(); PlayerTextReaction floatright_react = new PlayerTextReaction(); floatright_react.message = "There is nothing to the right."; // floatright_react.textColor = Color.white; floatright_react.delay = 0.01f; AudioReaction floatright_react_sound = new AudioReaction(); floatright_react_sound.audioSource = nodeCgo.GetComponent <AudioSource>() as AudioSource; floatright_react_sound.audioClip = ss.getSceneSoundByName("meow1").clip; floatright_react_sound.delay = 0.0f; floatright_react_collection.reactions = new Reaction[] { floatright_react, floatright_react_sound }; Condition always_true_init_cond = new Condition(); always_true_init_cond.toEval = () => { ccfloatright.reactionCollection.DoInit(); return(true); }; ccfloatright.reactionCollection = floatright_react_collection; ccfloatright.requiredConditions = new Condition[] { always_true_init_cond }; //grab ConditionCollection ccgrab = new ConditionCollection(); ReactionCollection grab_react_collection = new ReactionCollection(); PickedUpItemReaction grab_react = new PickedUpItemReaction(); SceneItems si = FindObjectOfType <SceneItems> (); grab_react.item = si.getSceneItemByName("pills"); GameObjectReaction grab_pills_react = new GameObjectReaction(); GameObject[] gos = FindObjectsOfType <GameObject> (); foreach (var g in gos) { if (g.name == "pills") { grab_pills_react.gameObject = g; break; } } grab_pills_react.activeState = false; AudioReaction grab_pills_react_sound = new AudioReaction(); grab_pills_react_sound.audioSource = nodeCgo.GetComponent <AudioSource>() as AudioSource; grab_pills_react_sound.audioClip = ss.getSceneSoundByName("pills").clip; grab_pills_react_sound.delay = 0.0f; grab_react_collection.reactions = new Reaction[] { grab_react, grab_pills_react, grab_pills_react_sound }; Condition pills_not_yet_acquired = new Condition(); pills_not_yet_acquired.toEval = () => { return(!inv.Contains("pills")); }; ccgrab.reactionCollection = grab_react_collection; ccgrab.requiredConditions = new Condition[] { pills_not_yet_acquired }; ccgrab.reactionCollection.DoInit(); //look ConditionCollection cclook = new ConditionCollection(); ReactionCollection look_react_collection = new ReactionCollection(); PlayerTextReaction look_react = new PlayerTextReaction(); look_react.message = "My human’s happy pills, fun to bat under the couch."; // floatright_react.textColor = Color.white; look_react.delay = 0.01f; look_react_collection.reactions = new Reaction[] { look_react }; cclook.reactionCollection = look_react_collection; cclook.requiredConditions = new Condition[] { pills_not_yet_acquired }; cclook.reactionCollection.DoInit(); //interact ConditionCollection ccinteract = new ConditionCollection(); ReactionCollection interact_react_collection = new ReactionCollection(); PlayerTextReaction interact_ptext_react = new PlayerTextReaction(); interact_ptext_react.message = "meow...pills are for humans, not magic cats!"; interact_ptext_react.delay = 0f; interact_react_collection.reactions = new Reaction[] { interact_ptext_react }; Condition cannot_exit_cond = new Condition(); cannot_exit_cond.toEval = () => { return(!(bool)GameData.GlobalBools["can_exit_tent"]); }; ccinteract.reactionCollection = interact_react_collection; cclook.requiredConditions = new Condition[] { pills_not_yet_acquired, cannot_exit_cond }; ccinteract.reactionCollection.DoInit(); Dictionary <string, ConditionCollection> htm = new Dictionary <string, ConditionCollection>(); htm.Add("float left", ccfloatleft); htm.Add("float right", ccfloatright); htm.Add("grab", ccgrab); htm.Add("look", cclook); htm.Add("interact", ccinteract); return(htm); }
public static Dictionary <string, ConditionCollection> nodeB() { GameObject nodeBgo = nodes.GetNode("B"); SceneSounds ss = FindObjectOfType <SceneSounds> (); AudioReaction whoosh_sound = new AudioReaction(); whoosh_sound.audioSource = nodeBgo.GetComponent <AudioSource>() as AudioSource; whoosh_sound.audioClip = ss.getSceneSoundByName("movewhoosh").clip; whoosh_sound.delay = 0.0f; //float left ConditionCollection ccfloatleft = new ConditionCollection(); ReactionCollection floatleft_react_collection = new ReactionCollection(); MoveReaction floatleft_react = new MoveReaction(); floatleft_react.destination = "A"; floatleft_react_collection.reactions = new Reaction[] { floatleft_react, whoosh_sound }; ccfloatleft.reactionCollection = floatleft_react_collection; Condition always_true_cond = new Condition(); always_true_cond.toEval = () => { return(true); }; ccfloatleft.requiredConditions = new Condition[] { always_true_cond }; //float right ConditionCollection ccfloatright = new ConditionCollection(); ReactionCollection floatright_react_collection = new ReactionCollection(); MoveReaction floatright_react = new MoveReaction(); floatright_react.destination = "C"; floatright_react_collection.reactions = new Reaction[] { floatright_react, whoosh_sound }; ccfloatright.reactionCollection = floatright_react_collection; ccfloatright.requiredConditions = new Condition[] { always_true_cond }; //kombucha conditions Condition kombucha_not_appeared = new Condition(); kombucha_not_appeared.toEval = () => { return(!((bool)GameData.GlobalBools["kombucha_appeared"])); }; Condition kombucha_appeared = new Condition(); kombucha_appeared.toEval = () => { return((bool)GameData.GlobalBools["kombucha_appeared"]); }; //grab ConditionCollection ccgrab = new ConditionCollection(); ReactionCollection grab_react_collection = new ReactionCollection(); InstantiateReaction grab_react = new InstantiateReaction(); grab_react.prefab = Resources.Load <GameObject> ("Prefabs/Kombucha"); grab_react.pos = new Vector3(5200, 350, 0); GlobalBoolReaction kombucha_appeared_reaction = new GlobalBoolReaction(); kombucha_appeared_reaction.toSet = "kombucha_appeared"; kombucha_appeared_reaction.setTo = true; AudioReaction kombucha_appeared_react_sound = new AudioReaction(); kombucha_appeared_react_sound.audioSource = nodeBgo.GetComponent <AudioSource>() as AudioSource; kombucha_appeared_react_sound.audioClip = ss.getSceneSoundByName("oww").clip; kombucha_appeared_react_sound.delay = 0.0f; grab_react_collection.reactions = new Reaction[] { grab_react, kombucha_appeared_reaction, kombucha_appeared_react_sound }; ccgrab.reactionCollection = grab_react_collection; ccgrab.requiredConditions = new Condition[] { kombucha_not_appeared }; ccgrab.reactionCollection.DoInit(); //look kombucha ConditionCollection cclookk = new ConditionCollection(); ReactionCollection lookk_react_collection = new ReactionCollection(); PlayerTextReaction lookk_react = new PlayerTextReaction(); lookk_react.message = "My human drinks a lot of kombucha."; lookk_react.delay = 0f; lookk_react_collection.reactions = new Reaction[] { lookk_react }; cclookk.reactionCollection = lookk_react_collection; cclookk.requiredConditions = new Condition[] { kombucha_appeared }; cclookk.reactionCollection.DoInit(); //look ConditionCollection cclook = new ConditionCollection(); ReactionCollection look_react_collection = new ReactionCollection(); ReactionCollection look_neg_react_collection = new ReactionCollection(); PlayerTextReaction look_react = new PlayerTextReaction(); look_react.message = "kombucha, gross."; look_react.delay = 0f; PlayerTextReaction look_neg_react = new PlayerTextReaction(); look_neg_react.message = "meeeow...if only there was a way to distract her!"; look_neg_react.delay = 0f; look_react_collection.reactions = new Reaction[] { look_react }; look_neg_react_collection.reactions = new Reaction[] { look_neg_react }; cclook.reactionCollection = look_react_collection; cclook.negReactionCollection = look_neg_react_collection; cclook.requiredConditions = new Condition[] { kombucha_appeared //TODO: bey is gone? }; cclook.reactionCollection.DoInit(); cclook.negReactionCollection.DoInit(); //interact kombucha ConditionCollection ccinteractk = new ConditionCollection(); ReactionCollection interactk_react_collection = new ReactionCollection(); GameObjectReaction interactk_go_reaction = new GameObjectReaction(); GameObject[] gos = FindObjectsOfType <GameObject> (); foreach (var g in gos) { if (g.name == "Bey") { interactk_go_reaction.gameObject = g; break; } } interactk_go_reaction.activeState = false; GlobalBoolReaction can_exit_tent_reaction = new GlobalBoolReaction(); can_exit_tent_reaction.toSet = "can_exit_tent"; can_exit_tent_reaction.setTo = true; UninstantiateReaction uninstantiate_kombucha_reaction = new UninstantiateReaction(); uninstantiate_kombucha_reaction.objectName = "kombucha"; AudioReaction kombucha_drugged_react_sound = new AudioReaction(); kombucha_drugged_react_sound.audioSource = nodeBgo.GetComponent <AudioSource>() as AudioSource; kombucha_drugged_react_sound.audioClip = ss.getSceneSoundByName("drugged_the_human").clip; kombucha_drugged_react_sound.delay = 0.0f; Condition pills_acquired = new Condition(); pills_acquired.toEval = () => { return(inv.Contains("pills")); }; LostItemReaction pill_loss_react = new LostItemReaction(); SceneItems si = FindObjectOfType <SceneItems> (); pill_loss_react.item = si.getSceneItemByName("pills"); interactk_react_collection.reactions = new Reaction[] { interactk_go_reaction, pill_loss_react, can_exit_tent_reaction, uninstantiate_kombucha_reaction, kombucha_drugged_react_sound }; ccinteractk.reactionCollection = interactk_react_collection; ccinteractk.requiredConditions = new Condition[] { pills_acquired, kombucha_appeared }; ccinteractk.reactionCollection.DoInit(); Dictionary <string, ConditionCollection> htm = new Dictionary <string, ConditionCollection>(); htm.Add("float left", ccfloatleft); htm.Add("float right", ccfloatright); htm.Add("grab", ccgrab); htm.Add("look kombucha", cclookk); htm.Add("look", cclook); htm.Add("interact kombucha", ccinteractk); return(htm); }