public void StartCommunication() { // If interactable Object is near to the player then start the interaction, else do nothing if (Vector3.Distance(player.transform.position, trader.GetClosestObject("InteractionObject", player).transform.position) < distance) { string interactableObjectName = trader.closest.name; string npcType = dialogue.GetNpcType(interactableObjectName, json); //disable other UI Buttons openMapButton.interactable = false; openMenuButton.interactable = false; //set speech field active textBox.SetActive(true); //get content for communication npcName.text = dialogue.GetNpcName(interactableObjectName, json); npcText.text = dialogue.GetNpcText(interactableObjectName, json); if (npcType == "Trader") { acceptButton.onClick.AddListener(delegate() { OpenGameList(interactableObjectName); }); cancelButton.onClick.AddListener(delegate() { CancelCommunication(); }); } else if (npcType == "ScriptedNPC") { if (interactableObjectName == "Buergermeister") { //Debug.Log("Show attacker"); acceptButton.onClick.AddListener(delegate() { ssa.ShowAttacker(); }); cancelButton.onClick.AddListener(delegate() { ssa.ShowAttacker(); }); } else if (interactableObjectName == "Buergermeister_1") { acceptButton.onClick.AddListener(delegate() { ssa.ShowMajor(); }); cancelButton.onClick.AddListener(delegate() { ssa.ShowMajor(); }); } else if (interactableObjectName == "Buergermeister_2") { acceptButton.onClick.AddListener(delegate() { ssa.DeleteColor(); }); cancelButton.onClick.AddListener(delegate() { ssa.DeleteColor(); }); } } else if (npcType == "Chest") { Debug.Log("The NPC is a chest, do not try to talk with him"); acceptButton.onClick.AddListener(delegate() { handleChest.OpenChest(interactableObjectName); }); cancelButton.onClick.AddListener(delegate() { handleChest.OpenChest(interactableObjectName); }); } else { acceptButton.onClick.AddListener(delegate() { CancelCommunication(); }); cancelButton.onClick.AddListener(delegate() { CancelCommunication(); }); } } }