- Home /
Adding dialouge
Hi i make game but i dont know how to make and add dialouge pls help me
Comment
Answer by mcunha98 · Sep 19, 2010 at 05:32 PM
This is my component from NPC,
using UnityEngine; using System.Collections; [AddComponentMenu("BillyOposto/NPC/Dialogo")] public class NPCDialogo : MonoBehaviour { public enum NPCDialogoLoop { ndlSempre = 0, ndlUmaVez = 1 }
public string[] dialogos;
public Texture2D dialogoimagem;
public GUISkin dialogoskin;
public int estadoesperado = -1;
public GameObject portalparaativar;
public NPCDialogoLoop cicloDialogo;
private bool falando = false;
private bool avisar = false;
private bool falou = false;
private int indice = -1;
private int boxMarginLeft = 30;
private int boxHeight = 200;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (falou == true && cicloDialogo == NPCDialogoLoop.ndlUmaVez)
{
return;
}
if (Input.GetKeyDown(KeyCode.Space) && avisar == true)
{
avisar = false;
falando = true;
BillyManager.habilitarcontrole = false;
}
if (Input.GetKeyDown(KeyCode.Space) && falando == true)
{
indice++;
if (indice >= dialogos.Length)
{
BillyManager.habilitarcontrole = true;
falando = false;
avisar = true;
indice = -1;
falou = true;
if (portalparaativar != null)
{
Portal scr = (Portal)portalparaativar.GetComponent("Portal");
scr.disabled = false;
}
}
}
}
void OnTriggerEnter(Collider collision)
{
if (falou == true && cicloDialogo == NPCDialogoLoop.ndlUmaVez)
{
avisar = false;
}
else
{
if (avisar == false) avisar = true;
}
}
void OnTriggerExit(Collider collision)
{
falando = false;
avisar = false;
indice = -1;
}
void OnGUI()
{
if (dialogoskin != null) GUI.skin = dialogoskin;
if (avisar == true)
{
GUI.DrawTexture(new Rect((Screen.width / 2) - (256 / 2), (Screen.height / 2) - (64 / 2), 256, 64), this.dialogoimagem);
}
else
{
if (falando == true)
{
string texto = this.dialogos[indice];
string estilo = "box";
if (texto.Contains("B:") || texto.Contains("b:"))
{
estilo = "box-billy";
texto = texto.Replace("B:", "");
texto = texto.Replace("b:", "");
}
GUI.Label(new Rect(boxMarginLeft, Screen.height - boxHeight, Screen.width - (boxMarginLeft * 2), boxHeight), texto, estilo);
}
//Debug.Log(indice + " o indice");
}
}
void OnDrawGizmos()
{
Gizmos.DrawIcon(transform.position, "npcdialogo.png");
}
}
Your answer
Follow this Question
Related Questions
npc dialogue 0 Answers
NPC dialogue - Loading a text file to a string? 1 Answer
How to put this Dialogue SCRIPT on an NPC game object? 1 Answer
Int resetting? 2 Answers
Cant Get Dialogue Trigger Working 0 Answers