Beispiel #1
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (!enter) {
         compteur=0;
         Dialogue dial = new Dialogue ();
         lines = dial.open ("Dialogue");
         box = (GameObject)Instantiate (Resources.Load ("Prefab/Dialog"));
         string[] info = dial.ReadLine (lines [compteur]);
         compteur++;
         Image im=box.transform.GetChild(3).GetComponent<Image>();
         im.sprite=Resources.Load<Sprite>("Texture/"+info[0]);
         Text te = box.transform.GetChild (0).gameObject.GetComponent<Text> ();
         te.text = info [0];
         te = box.transform.GetChild (2).gameObject.GetComponent<Text> ();
         te.text = info [1];
         enter=true;
     }
 }
Beispiel #2
0
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if(Input.GetKeyDown(KeyCode.E)||Input.GetKeyDown(KeyCode.KeypadEnter)){
         if (compteur == lines.GetLength(0)-1||!Personnage.pnjcollide) {
             enter=false;
             animator.SetBool("Dialogue",false);
             compteur=0;
         }else{
         Dialogue dial = new Dialogue ();
         string[] info=dial.ReadLine (lines [compteur]);
         compteur++;
         Image im=box.transform.GetChild(3).GetComponent<Image>();
         im.sprite=Resources.Load<Sprite>("Texture/"+info[0]);
         Text te=box.transform.GetChild(0).gameObject.GetComponent<Text>();
         te.text = info[0];
             te=box.transform.GetChild(2).gameObject.GetComponent<Text>();
         te.text = info [1];
         }
     }
 }
        public void loadDialogues()
        {
            XmlDocument doc = new XmlDocument ();
            doc.Load (dataPath + "/Dialogues.xml");
            XmlNodeList nodes = doc.DocumentElement.ChildNodes;
            foreach (XmlNode node in nodes) {
                Dialogue d = new Dialogue();
                d.texte = node.SelectSingleNode ("Texte").InnerText;
                d.poids = double.Parse (node.SelectSingleNode ("Poids").InnerText);
                if (node.SelectSingleNode ("Type").InnerText != "NULL") {
                    d.type = (TypeDeDialogue) Enum.Parse (typeof(TypeDeDialogue), node.SelectSingleNode ("Type").InnerText);
                }
                d.faction = this.getFaction(node.SelectSingleNode ("Faction").InnerText);

                listeDialogue.Add(d);
            }
        }