Newer
Older
/*
* Script par Tanguy Gimenez
*
*/
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
public class Dialog : MonoBehaviour
{
// singleton
public static Dialog instance;
{
if (instance != null)
{
Debug.LogWarning("Il y a + d'une instance de PlayerNature");
return;
}
instance = this;
}
public GameObject dialogBox;
public Text dialogText;
public Text instructionText;
public int dialog;
public bool dialogActive;
// clé : nom de la scène
// valeur : tableau de string contenant chaque réplique
private Dictionary<string, string[]> ListDialogs = new Dictionary<string, string[]>();
// Start is called before the first frame update
void Start()
{
this.dialog = 0;
string[] DialogsLvl1 = {
"Ach... Encore eine gute chournée dans mon fillage!",
"Che defrai aller au Nord dans la forêt ja !",
"pour me déplacer, je dois utiliser mes muscles 'flèches directionnelles'"
this.ListDialogs.Add("start", DialogsLvl1);
string[] boutiqueChaussure = {
"Je fous prendrais zes chauzzures en taille Zweiundvierzig Bitte !",
};
this.ListDialogs.Add("boutiqueChaussure", boutiqueChaussure);
string[] boutiqueBaton = {
"Ze bâton me semble assez long et solide pour moi ! J'achète !",
};
this.ListDialogs.Add("boutiqueBaton", boutiqueBaton);
string[] boutiqueRechaud = {
" Ze réchaud fa être SEHR PRAKTISCH !", "j'achète tout de zuite !"
this.ListDialogs.Add("boutiqueRechaud", boutiqueRechaud);
string[] boutiqueTente = {
"J'adore ta tente, mais elle est un peu grosse non ?", "Ach, tant pis, CH'ACHETE !"
};
this.ListDialogs.Add("boutiqueTente", boutiqueTente);
"NEIN NEIN NEIN ! Il fa me falloir des chaussures pour marcher plus loin !"
this.ListDialogs.Add("borderChaussure", borderChaussure);
string[] borderBaton = {
"ACH SCHEISSE !", "Ch'ai ouplié mes patons te marches ! Che suis trop fatigué !"
};
this.ListDialogs.Add("borderBaton", borderBaton);
string[] borderRechaud = {
"Kopfertami, je commence à afoir faim !", "il me faudrait eine réchaud pour mancher !"
};
this.ListDialogs.Add("borderRechaud", borderRechaud);
string[] borderTente = {
"Hopla, c'est bientôt l'heure de la sièste !", "Si che n'ai pas de tente che ne pourrait pas continuer !"
};
this.ListDialogs.Add("borderTente", borderTente);
}
// Update is called once per frame
void Update()
{
if ((Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown("joystick button 0")) && dialogActive)
this.Next();
this.dialogBox.GetComponent<CanvasRenderer>().SetAlpha(1f);
this.dialogText.GetComponent<CanvasRenderer>().SetAlpha(1f);
this.instructionText.GetComponent<CanvasRenderer>().SetAlpha(1f);
this.dialogBox.GetComponent<CanvasRenderer>().SetAlpha(0f);
this.dialogText.GetComponent<CanvasRenderer>().SetAlpha(0f);
this.instructionText.GetComponent<CanvasRenderer>().SetAlpha(0f);
if (this.dialog >= this.ListDialogs[this.situation].Length)
this.dialogText.text = this.ListDialogs[this.situation][this.dialog];
{
this.situation = sit;
this.dialog = 0;
this.dialogActive = true;
this.Next();
}