void OnTriggerEnter(Collider other) { if (other.GetComponent <VIDE_Assign>() != null) { inTrigger = other.GetComponent <VIDE_Assign>(); } }
//Casts a ray to see if we hit an NPC and, if so, we interact void TryInteract() { RaycastHit rHit; if (Physics.Raycast(transform.position, transform.forward, out rHit, 2)) { //In this example, any Gameobject name containing 'NPC' is considered an NPC if (rHit.collider.name.Contains("NPC")) { //Lets grab the NPC's DialogueAssign script... VIDE_Assign assigned = rHit.collider.GetComponent <VIDE_Assign>(); if (!diagUI.dialogue.isLoaded) { //... and use it to begin the conversation diagUI.Begin(assigned); } else { //If conversation already began, let's just progress through it diagUI.NextNode(); } } } }
//Refresh dialogue list public void loadFiles() { AssetDatabase.Refresh(); d = (VIDE_Assign)target; TextAsset[] files = Resources.LoadAll <TextAsset>("Dialogues"); d.diags = new List <string>(); if (files.Length < 1) { return; } foreach (TextAsset f in files) { d.diags.Add(f.name); } d.diags.Sort(); if (d.assignedIndex >= d.diags.Count) { d.assignedIndex = 0; } if (d.assignedIndex != -1) { d.assignedDialogue = d.diags[d.assignedIndex]; } //Lets make sure we still have the right file IDCheck(); Repaint(); }
private void UpdateDialogState() { bool isPlayerActionStage = getIsDialogActionCkicked() || actionsContainer.activeSelf; if (!getIsLeftMouseClick() || isPlayerActionStage) { return; } if (VD.isActive) { VD.Next(); return; } VIDE_Assign vide = getTargetVide(); if (vide == null) { return; } if (!GetIsPlayerInRange()) { GoToDialogTriggerZone(); return; } StartDialog(vide); }
//When the sprite collides with an NPC, assign the NPC's VIDE_Assign node //to the sprite void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <VIDE_Assign>() != null) { inTrigger = other.GetComponent <VIDE_Assign>(); } if (other.gameObject.tag == "NewScene") { scene = other.GetComponent <ChangeScene>(); scene.leaveScene = true; Debug.Log("leaveScene = " + scene.leaveScene); Debug.Log("newScene = " + scene.newScene); } if (other.gameObject.tag == "NewSceneWalk") { scene = other.GetComponent <ChangeScene>(); scene.leaveSceneWalk = true; } else { scene.leaveSceneWalk = false; Debug.Log(scene.leaveScene); } }
void DoInteraction() { //Lets grab the NPC's DialogueAssign script... VIDE_Assign assigned = discussionPartner.GetComponent <VIDE_Assign>(); Sprite player = discussionPartner.GetComponent <Entity>().character.characterDialogSprite; Sprite NPC = GetComponent <Entity>().character.characterDialogSprite; if (!dialogueUI.dialogue.isLoaded) { //... and use it to begin the conversation dialogueUI.Begin(assigned); } else { //If conversation already began, let's just progress through it dialogueUI.NextNode(); } if (dialogueUI.dialogue.nodeData.currentIsPlayer) { dialogueUI.dialogImage.sprite = NPC; dialogueUI.dialogImage.transform.SetAsFirstSibling(); dialogueUI.dialogImage.rectTransform.localScale = Vector3.one; } else { dialogueUI.dialogImage.sprite = player; dialogueUI.dialogImage.transform.SetAsLastSibling(); dialogueUI.dialogImage.rectTransform.localScale = new Vector3(-1, 1, 1); } dialogueUI.npcName.text = discussionPartner.name; }
//Refresh dialogue list public void loadFiles() { d = (VIDE_Assign)target; TextAsset[] files = Resources.LoadAll <TextAsset>("Dialogues"); d.diags = new List <string>(); if (files.Length < 1) { return; } foreach (TextAsset f in files) { d.diags.Add(f.name); } if (d.assignedIndex >= d.diags.Count) { d.assignedIndex = 0; } d.assignedDialogue = d.diags[d.assignedIndex]; Repaint(); }
//Refresh dialogue list public void loadFiles() { AssetDatabase.Refresh(); d = (VIDE_Assign)target; TextAsset[] files = Resources.LoadAll <TextAsset>("Dialogues"); d.diags = new List <string>(); fullPaths = new List <string>(); if (files.Length < 1) { return; } foreach (TextAsset f in files) { d.diags.Add(f.name); fullPaths.Add(AssetDatabase.GetAssetPath(f)); } d.diags.Sort(); //Lets make sure we still have the right file IDCheck(); Repaint(); }
//Call this to begin the dialogue and advance through it public void Interact(VIDE_Assign dialogue, OverrideNodeInfo[] nodeOverrideInfo = null) { //Sometimes, we might want to check the ExtraVariables and VAs before moving forward //We might want to modify the dialogue or perhaps go to another node, or dont start the dialogue at all //In such cases, the function will return true var doNotInteract = PreConditions(dialogue); if (doNotInteract) { return; } if (nodeOverrideInfo != null) { SpecialStartNodeOverrides(ref dialogue, nodeOverrideInfo); } if (!VD.isActive) { Begin(dialogue); } else { CallNext(); } }
//This begins the conversation (Called by examplePlayer script) public void Begin(VIDE_Assign diagToLoad) { //First step is to call BeginDialogue, passing the required 'DialogueAssign' component //This will store the first Node data in dialogue.nodeData dialogue.BeginDialogue(diagToLoad); //Let's clean the NPC text variables npcText.text = ""; npcName.text = ""; //If we already talked to this NPC, lets modify the start of the conversation if (dialogue.assigned.interactionCount > 0 && gotItem) { string name = dialogue.assigned.dialogueName; switch (name) { case "Crazy Cap": dialogue.nodeData = dialogue.SetNode(17); break; } } //Everytime dialogue.nodeData gets updated, we update our UI with the new data UpdateUI(); }
//This begins the conversation void Begin(VIDE_Assign dialogue) { //Let's reset the NPC text variables NPC_Text.text = ""; NPC_label.text = ""; playerLabel.text = ""; NPCPhotoFrame.transform.localEulerAngles = new Vector3(0, 0, Random.Range(rotationMin, rotationMax)); playerPhotoFrame.transform.localEulerAngles = new Vector3(0, 0, Random.Range(rotationMin, rotationMax)); //First step is to call BeginDialogue, passing the required VIDE_Assign component //This will store the first Node data in VD.nodeData //But before we do so, let's subscribe to certain events that will allow us to easily //Handle the node-changes VD.OnActionNode += ActionHandler; VD.OnNodeChange += UpdateUI; VD.OnEnd += EndDialogue; VD.BeginDialogue(dialogue); //Begins dialogue, will call the first OnNodeChange dialogueContainer.transform.DOKill(); dialogueContainer.transform.localPosition = new Vector3(0, 300); dialogueContainer.transform.DOLocalMoveY(0, .5f).SetEase(Ease.OutExpo); dialogueContainer.SetActive(true); //Let's make our dialogue container visible CameraFollow.instance.target = dialogue.gameObject.transform; CameraFollow.instance.ChangeDefaultDistance(false, CameraFollow.instance.zoomDefaultDistance); }
void OnTriggerExit(Collider other) { if (other.GetComponent <VIDE_Assign>() != null) { inTrigger = null; } }
private void OnTriggerStay(Collider other) { if (other.GetComponent <VIDE_Assign>() != null) { inTrigger = other.GetComponent <VIDE_Assign>(); } }
// SetConditions sets the start node of the current dialogue based on: // 1. has the player met the NPC before? // 2. Does the player have the item the NPC wants? // not every NPC needs an item from the player // if the player does have what npc needs, set doNotEngage to true to prevent future interactions private void SetStartNode(VIDE_Assign dialogue) { // if NPC has not been met return immediately & start at the beginning // Otherwise, otherwise adjust start if (!met && npcName != "Bartender" && npcName != "CoatCheck") // we do not want to have initial convo if item is found { return; } else { if (npcName == "Bartender") { if (ItemCollect.playerInventory != null && ItemCollect.playerInventory.Contains("Wallet")) //ObjectFound() { dialogue.overrideStartNode = 6; doNotEngage = true; } else if (!met) { return; } else { dialogue.overrideStartNode = 15; } } else if (npcName == "Drunk") { if (ItemCollect.playerInventory != null && ItemCollect.playerInventory.Contains("Wallet")) { dialogue.overrideStartNode = 16; } else { dialogue.overrideStartNode = 12; } } else if (npcName == "CoatCheck") // CoatCheck Character still needs to be added to scene { if (ItemCollect.playerInventory != null && ItemCollect.playerInventory.Contains("Ticket")) { dialogue.overrideStartNode = 5; doNotEngage = true; } else if (!met) { return; } else { dialogue.overrideStartNode = 4; } } else if (npcName == "RandomPartier") { dialogue.overrideStartNode = 7; } } }
// Start is called before the first frame update void Start() { assign = GetComponent <VIDE_Assign>(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <SpriteController>(); playerMorals = player.moralCompass; indicator.gameObject.SetActive(false); }
public void Interact(VIDE_Assign dialogue) { if (!VD.isActive) { Begin(dialogue); //Debug.Log(dialogue); } }
public void Begin(VIDE_Assign videAssign) { VD.OnNodeChange += UpdateUI; VD.OnEnd += End; // This loads the VIDE_Assign into the VD. //If you want to play other dialogs, you would have to select a different VIDE_Assign here. VD.BeginDialogue(videAssign); }
private bool doNotEngage = false; // when player has everything they need, do not converse anymore // Start is called before the first frame update void Start() { dialogueUI = FindObjectOfType <DialogueUI>(); assigned = GetComponent <VIDE_Assign>(); npcName = this.gameObject.tag; Debug.Log("This NPC name is " + npcName); }
private void CheckDialogTriggerExit(Collider2D collider) { VIDE_Assign vide = collider.gameObject.GetComponent <VIDE_Assign>(); if (vide != null) { uiManager.ExitDialogTrigger(); } }
private void StartDialog(VIDE_Assign videAssign) { HideJoystick(); HideDialogAction(); ShowReplicaContainer(); VD.OnNodeChange += UpdateDialogUI; VD.OnEnd += EndDialog; VD.BeginDialogue(videAssign); }
// Start is called before the first frame update void Start() { particle = particleEffect.GetComponent <ParticleSystem>(); particle.Stop(); personScript = person.GetComponent <Person>(); vide = GetComponent <VIDE_Assign>(); vide.overrideStartNode = inactiveNode; //vide.AssignNew(dialogueAssign); }
//THIS IS HOW WE ACTIVATE DIALOGUE, WOOO public void Interact(VIDE_Assign dialogue) { dialogueUI.Interact(dialogue); lastTrigger = dialogue; //This creates a back-up that we can use to advance dialogue up above. movementScript.SetMoveVelocity(Vector2.zero); //NOTE: "Interact" both begins dialogue and advances it. //We'll have to be careful about making sure dialogue isn't activated when we run this, unless we want the player to automatically advance. }
void OnTriggerExit(Collider other) { if (other.GetComponent <VIDE_Assign>() != null) //This is to make sure that the player can't lose their dialogue if an unrelated trigger enters and exits while they're still within an ACTUAL VA { inTrigger = null; canInteract = false; validInteractNotif.InteractSignalSwitch(false); } }
private void OnTriggerExit2D(Collider2D collision) { if (collision.GetComponent <VIDE_Assign>() != null) { inTrigger = null; canInteract = false; validInteractNotif.InteractSignalSwitch(false); } }
//DEMO variables for item inventory //Crazy cap NPC in the demo has items you can collect void OnTriggerEnter(Collider other) { if (other.GetComponent <VIDE_Assign>() != null) { inTrigger = other.GetComponent <VIDE_Assign>(); } nameNPC = other.gameObject.name; }
//SEGUN EL NOMBRE DEL PLAYER SELECCIONAMOS UN DIALOGUE U OTRO void AssignDialogue(string playerName) { for (int i = 0; i < dialogues.Length; i++) { if (dialogues[i].name.Contains(playerName)) { VIDE = dialogues[i].GetComponent <VIDE_Assign>(); } } }
public void LoadDialogue(string dialogueName, int overrideStartNode) { Setup(); VIDE_Assign assign = new VIDE_Assign(); assign.overrideStartNode = overrideStartNode; assign.AssignNew(dialogueName); VD.BeginDialogue(assign); }
//Este metodo es el primero que se llama al empezar el dialogo public void Begin(VIDE_Assign vide_Assign, GameObject npc, GameObject npcTxt) { Container_NPC = npc; Container_NPC.SetActive(false); textNpc = npcTxt.GetComponent <Text>(); npcSayLine = npcTxt.GetComponent <SayLineText>(); VD.OnNodeChange += UpdateUI; VD.OnEnd += End; VD.BeginDialogue(vide_Assign); }
// Update is called once per frame void Update() { // Consider moving it somewhere that is called in the beginning of the game if (!hasDialoguePlayed) { hasDialoguePlayed = true; VIDE_Assign startDialogue = this.GetComponent <VIDE_Assign>(); dialogueManager.StartDialogue(startDialogue); } }
void Start() { //VD.LoadDialogues(); GM gm = FindObjectOfType <GM>(); story = GetComponent <VIDE_Assign>(); story.overrideStartNode = gm.nodes[gm.GetIndex()]; //VD.LoadDialogues(); Begin(); }