Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        _commentaire = "Bienvenue";
        GenererSpectateurs();

        /*RenderSettings.ambientLight = new Color(0.05f, 0.05f, 0.3f);
         * RenderSettings.ambientIntensity = 0.2f;*/
        _audio = new Audio(GameObject.Find("Main Camera").gameObject);
        //_audio.AjouterSon(Son.COUPENVOI,0.4f,0.4f,false,5,false,0);
        _audio.AjouterSon(Son.STAD_BACK, 0.85f, 0.5f, true, 0, false, 0);
        _audio.AjouterSon(Son.WIND_STRONG, 0.6f, 0.7f, true, 0, false, 0);
        _audio.AjouterSon(Son.SML_STAD_BACKGROUND, 0.6f, 1, true, 0, false, 0);
        _audio.AjouterSon(Son.MUSIQUE, 0.7f, 1, false, 15, false, 0);


        _camera = 1;
        GameObject.Find("Main Camera").transform.position = new Vector3(-83, 25, -10);
        GameObject.Find("Main Camera").transform.position = new Vector3(-70, 26, 0);
        GameObject.Find("Main Camera").transform.rotation = Quaternion.Euler(new Vector3(15, 90, 0));
        if (Match.LeMatch == null)
        {
            if (Session.Instance.Partie == null)
            {
                Session.Instance.Partie = new Partie(new Gestionnaire());
            }
            Gestionnaire gestionnaire = Session.Instance.Partie.Gestionnaire;
            ParseurXML   xml          = new ParseurXML(gestionnaire);
            xml.Charger();
            Match.LeMatch = new Match(gestionnaire.ObtenirClub(1), gestionnaire.ObtenirClub(2), new System.DateTime(2018, 10, 10, 20, 0, 0));
        }

        Match _match = Match.LeMatch;


        /*
         * foreach(Club c in Gestionnaire.Instance.Clubs)
         * {
         *  foreach(Joueur j in c.Joueurs)
         *  {
         *      j.Vitesse /= 2;
         *      j.Precision /= 2;
         *  }
         * }*/


        foreach (Joueur j in _match.Equipe1.Joueurs)
        {
            j.Vitesse = (int)(j.Vitesse * 0.5f);
            GenererJoueur(j);
        }
        foreach (Joueur j in _match.Equipe2.Joueurs)
        {
            j.Vitesse = (int)(j.Vitesse * 0.5f);
            GenererJoueur(j);
        }
        StartCoroutine(Ambiance());
    }
    private void ChargerJoueurs()
    {
        XDocument doc = XDocument.Load("Database/joueurs.xml");

        foreach (XElement e in doc.Descendants("Joueurs"))
        {
            foreach (XElement e2 in e.Descendants("Joueur"))
            {
                int    idclub = int.Parse(e2.Attribute("club").Value);
                string nom    = e2.Attribute("nom").Value;
                string prenom = e2.Attribute("prenom").Value;
                bool   sexe   = e2.Attribute("sexe").Value == "M" ? true : false;
                Poste  poste  = Poste.POURSUIVEUR;
                switch (e2.Attribute("poste").Value)
                {
                case "P": poste = Poste.POURSUIVEUR; break;

                case "B": poste = Poste.BATTEUR; break;

                case "A": poste = Poste.ATTRAPEUR; break;

                case "G": poste = Poste.GARDIEN; break;
                }
                int vitesse   = int.Parse(e2.Attribute("vitesse").Value);
                int precision = int.Parse(e2.Attribute("precision").Value);
                _gestionnaire.ObtenirClub(idclub).Joueurs.Add(new Joueur
                {
                    Prenom    = prenom,
                    Nom       = nom,
                    Sexe      = sexe,
                    Poste     = poste,
                    Vitesse   = vitesse,
                    Precision = precision
                });
            }
        }

        foreach (Club c in _gestionnaire.Clubs)
        {
            if (c.Joueurs.Count < 7)
            {
                c.GenererJoueur(Poste.GARDIEN);
                c.GenererJoueur(Poste.ATTRAPEUR);
                c.GenererJoueur(Poste.BATTEUR);
                c.GenererJoueur(Poste.BATTEUR);
                c.GenererJoueur(Poste.POURSUIVEUR);
                c.GenererJoueur(Poste.POURSUIVEUR);
                c.GenererJoueur(Poste.POURSUIVEUR);
            }
        }
    }