Example #1
0
    private void OnEnable()
    {
        if (this.gameObject.GetComponent <mouvement>() != null)
        {
            GestionnaireEvenement.ajouterEvenement("directionChanger", changerDirection);
        }
        this.prevPos = this.transform.position;

        VieJoueur vie = this.GetComponent <VieJoueur>();

        if (vie != null)
        {
            vie.setEstLocal(this.estLocal);
        }
        else
        {
            Debug.LogWarning("WARN    ManagerJoueur::OnEnable: Missing VieJoueur component.");
        }

        DegatsJoueur dgJ = this.GetComponent <DegatsJoueur>();

        if (dgJ != null)
        {
            dgJ.setSiJoueurLocal(this.estLocal);
        }
        else
        {
            Debug.LogWarning("WARN    ManagerJoueur::OnEnable: Missing DegatsJoueur component.");
        }
    }
Example #2
0
 public void attaquer(bool ataqueInterne)
 {
     if (apartienAuJoueur1 || ataqueInterne == false)
     {
         Vector3 departRay = new Vector3(this.transform.position.x + positionBaseRay, this.transform.position.y, this.transform.position.z);
         //Debug.Log(directionRay);
         RaycastHit2D[] toucher = Physics2D.RaycastAll(departRay, new Vector2(directionRay, 0), distanceRay, HitLayers);
         //Debug.DrawRay(departRay, new Vector3(90, 0, 90), Color.red, 5);
         foreach (RaycastHit2D hit in toucher)
         {
             Debug.Log(hit.rigidbody.gameObject.name);
             VieJoueur joueur = null;
             joueur = hit.rigidbody.gameObject.GetComponent <VieJoueur>();
             if (joueur != null)
             {
                 Debug.Log("hit");
                 joueur.faireDegat(degats);
                 if (this.gameObject.transform.parent.transform.position.x > hit.rigidbody.gameObject.transform.position.x && quantitierKnockBackx > 0)
                 {
                     quantitierKnockBackx *= -1;
                 }
                 else if (this.gameObject.transform.parent.transform.position.x < hit.rigidbody.gameObject.transform.position.x && quantitierKnockBackx < 0)
                 {
                     quantitierKnockBackx *= -1;
                 }
                 //hit.rigidbody.AddForce(new Vector2(quantitierKnockBackx, quantitierKnockBacky));
                 GestionnaireAttaque.declancherEvenement("VieJ1Changer", degats, joueur.name, quantitierKnockBackx);
             }
         }
     }
 }
Example #3
0
 // Use this for initialization
 void Start()
 {
     this.phys = this.gameObject.GetComponent <Rigidbody2D>();
     this.vie  = this.gameObject.GetComponent <VieJoueur>();
     if (!(this.phys && this.vie))
     {
         Debug.LogError("ERRR    DegatsJoueur::Start: DegatsJoueur attached on invalid player entity.");
     }
 }
Example #4
0
 public void ajouterJoueur(VieJoueur v)
 {
     if (this.nombreJoueurs >= 4)
     {
         Debug.LogError("ERRR    " + this.gameObject.name + ":UI_Health::ajouterJoueur(" + v.gameObject.name + "): Number of players is above 4!!!");
     }
     else
     {
         this.joueurs[this.nombreJoueurs] = v;
         this.nombreJoueurs++;
     }
 }
Example #5
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        VieJoueur vieJ = collision.gameObject.GetComponent <VieJoueur>();

        if (vieJ)
        {
            if (vieJ.getIfAlive())
            {
                vieJ.faireDegat(vieJ.getVieMaximale());
            }
        }
    }
Example #6
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        Debug.Log("INFO    ObstacleEnvironnemental:OnCollisionEnter2D(Collision2D collision) triggered for " + this.gameObject.name);
        VieJoueur    vieJ  = collider.gameObject.GetComponent <VieJoueur>();
        DegatsJoueur testJ = collider.gameObject.GetComponent <DegatsJoueur>();

        if (vieJ && testJ)
        {
            Vector3 force3d = collider.gameObject.transform.position - this.gameObject.transform.position;
            Vector2 force2d = new Vector2(force3d.x, force3d.y);
            testJ.repousserJoueur(force2d, this.dmg * 32.0f);
            vieJ.faireDegat(this.dmg);
        }
        else
        {
            Debug.Log("INFO    ObstacleEnvironnemental:OnCollisionEnter2D(Collision2D collision) Colliding entity is not a player.");
        }
    }
    private static void damagePlayer(VieJoueur joueur)
    {
        DegatsJoueur test_joueur = joueur.gameObject.GetComponent <DegatsJoueur>();

        if (test_joueur)
        {
            if (joueur.getIfAlive())
            {
                test_joueur.affichageDegats();
            }
            else
            {
                Debug.Log("INFO    GestionnaireDegats::dmgPlayer: Dead player " + joueur.gameObject.name + " took damage while dead.");
            }
        }
        else
        {
            Debug.LogWarning("WARN    GestionnaireDegats::dmgPlayer: Damage Event called on an invalid Player entity.");
        }
    }
Example #8
0
    private static void killPlayer(VieJoueur joueur)
    {
        DegatsJoueur test_joueur = joueur.gameObject.GetComponent <DegatsJoueur>();

        if (test_joueur)
        {
            if (joueur.getIfAlive())
            {
                Debug.Log("INFO    Player " + joueur.gameObject.name + " died.");
                test_joueur.tuerJoueur();
            }
            else
            {
                Debug.LogWarning("WARN    GestionnaireMort:killPlayer(" + joueur.gameObject.name + "): Death event called on a dead player!!!");
            }
        }
        else
        {
            Debug.LogWarning("WARN    GestionnaireMort:killPlayer(" + joueur.gameObject.name + "): Event called on an invalid Player entity.");
        }
    }
Example #9
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.layer == this.gameObject.layer)
     {
         Debug.Log("collision" + collision.gameObject.name);
         VieJoueur joueur = null;
         joueur = collision.gameObject.GetComponent <VieJoueur>();
         if (joueur != null && collision.gameObject.GetComponent <mouvement>() != null)
         {
             GestionnaireAttaque.declancherEvenement("VieJ1Changer", degat, collision.gameObject.name, 0);
             areterFleche(collision);
         }
         else if (collision.gameObject.GetComponent <ObjetRamasable>() == null)
         {
             areterFleche(collision);
         }
     }
     else
     {
         areterFleche(collision);
     }
 }
Example #10
0
 private void Start()
 {
     CoeurOn   = true;
     vieJoueur = GetComponent <VieJoueur>();
 }