akadoc/Assets/scripts/ChatWindow.cs

66 lines
1.6 KiB
C#

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ChatWindow : MonoBehaviour {
public Text text_chat;
public ScrollRect scrollrect;
//GameObject chat_input;
//TchatAnim tchatAnim;
string message_old;
// Use this for initialization
void Start () {
//chat_input = GameObject.Find ("tchat_complet");
//tchatAnim = chat_input.GetComponent<TchatAnim> ();
text_chat.text = "";
}
// Update is called once per frame
void Update () {
/* a supp une fois le nouveau système de message fonctionelle
if (Input.GetKeyDown ("space") && tchatAnim.message != message_old) {
scrollrect.verticalNormalizedPosition = 0;
text_chat.text += "perceval > " + tchatAnim.message + "\n";
message_old= tchatAnim.message;
}*/
}
//permet d'écrire du texte en brut dans la fenetre de chat. Sans style. A priori, ne doit pas etre utilisé...
public void writeText(string text){
text_chat.text += text;
}
//prend en arguement le nombre de jour écoulé pour l'afficher dans la fenetre de chat.
public void writeDay(int nbDay){
text_chat.text += "\n\n\n <b><color=#000080ff>Day " + nbDay.ToString() + "\n</color></b>" ;
scrollrect.verticalNormalizedPosition = 0;
}
//prend en argument le pseudo et le message reçu par TchatAnim.cs et l'inscrit dans la fenetre.
public void writeMessage(string nom, string message){
text_chat.text += "<color=#0000ffff>" + nom + ": </color>"+ message + "\n";
scrollrect.verticalNormalizedPosition = 0;
}
// TODO: rédiger des fonctions pour afficher les morts, les deconnections et certains évènement importants.
}