Correction de l'API pour la fenêtre de ChatWindow

deux méthodes publiques implémentées:

writeDay: écrit les jours, appelées depuis DayController.cs
writeMessage: écrit les messages, appelées depuis TchatAnim.cs

Ajout de balise de style via les balises RichText.
This commit is contained in:
Romain Pellé 2015-01-25 16:00:11 +01:00
parent 55686f63fb
commit 881e539602
4 changed files with 42 additions and 9 deletions

View File

@ -28527,7 +28527,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
machine: {fileID: 2130265911}
maxDay: 30
maxDay: 10
maxNight: 5
maxKilling: 15
--- !u!1 &2136149714

View File

@ -7,15 +7,15 @@ public class ChatWindow : MonoBehaviour {
public Text text_chat;
public ScrollRect scrollrect;
GameObject chat_input;
TchatAnim tchatAnim;
//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> ();
//chat_input = GameObject.Find ("tchat_complet");
//tchatAnim = chat_input.GetComponent<TchatAnim> ();
text_chat.text = "";
@ -25,20 +25,41 @@ public class ChatWindow : MonoBehaviour {
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.
}

View File

@ -32,7 +32,7 @@ public class DayController : MonoBehaviour {
chatWindow = chatWindowScroll.GetComponent<ChatWindow> ();
dayNb = 1;
chatWindow.writeText("\n\n\n JOUR 1 \n");
chatWindow.writeDay (dayNb);
}
@ -80,7 +80,7 @@ public class DayController : MonoBehaviour {
dayNb ++;
string message = "\n\n\n JOUR "+ dayNb.ToString()+"\n";
chatWindow.writeText(message);
chatWindow.writeDay(dayNb);
print("le jour se lève, discutez!");
}

View File

@ -13,11 +13,21 @@ public class TchatAnim : MonoBehaviour {
int max_timer;
public string message;
//appel de Window Chat
GameObject chatWindowScroll;
ChatWindow chatWindow;
// Use this for initialization
void Start () {
timer_sec = 0;
max_timer = 15;
//appel de Window Chat
chatWindowScroll = GameObject.Find ("ChatWindowScroll");
chatWindow = chatWindowScroll.GetComponent<ChatWindow> ();
}
@ -30,6 +40,7 @@ public class TchatAnim : MonoBehaviour {
void Update () {
//print (machine.GetInteger("etat_chat"));
if (myfield.isFocused) {
img_bg.color = Color.green;
@ -82,6 +93,7 @@ public class TchatAnim : MonoBehaviour {
//En cas de validation du message
if(Input.GetKeyDown("space") && myfield.isFocused){
chatWindow.writeMessage("perceval",myfield.text);
myfield.gameObject.SetActive(false);
myfield.text=" ";
charac_nb.text="";