Exemple #1
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);
             }
         }
     }
 }
Exemple #2
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);
     }
 }
Exemple #3
0
    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(ConnectToServer());
        socket.On("USER_CONNECTED", OnUserConnected);
        socket.On("PLAY", OnUserPlay);
        socket.On("MOVE", onUserMove);
        socket.On("USER_DISCONNECTED", onUserDisconnected);
        socket.On("AUCUNE_SESSION_DISPO", onAucuneSessionDispo);
        socket.On("ITEM_PICKUP_RESPONSE", onItemPickupResponce);
        socket.On("PLAYER_PICKUP_ITEM", onOtherPlayerPickup);
        socket.On("PLAYER_LOSE_HEALTH", onPlayerTakingDamage);
        socket.On("DROP_RESPONSE", onUserDropItem);
        socket.On("UN_JOUEUR_EST_MORT", onUserDeath);
        socket.On("RESPAWN", onUserRespawn);
        socket.On("SPAWN_ARME", onWeaponSpawn);
        socket.On("FIRE_BOW", onUserFireBow);
        socket.On("GAME_OVER", onGameOver);
        socket.On("BEGIN_GAME", onGameBegin);
        GestionnaireAttaque.ajouterEvenement("VieJ1Changer", onHitPlayer);
        GestionnaireItem.ajouterEvenement("Ramassable", onUserPickupItem);
        GestionnaireEvenement.ajouterEvenement("ObjetLancer", onPlayerDropItem);
        GestionnaireEvenement.ajouterEvenement("JoueurMort", onPlayerDeath);
        GestionnaireEvenement.ajouterEvenement("arcTirer", onArcTirer);
        //joystick.gameObject.SetActive(false);
        loginPanel.playBtn.onClick.AddListener(OnClickPlayBtn);
        //joystick.OnCommandMove += OnCommandMove;

        if (this.UITime == null)
        {
            Debug.LogWarning("WARN    " + this.gameObject.name + ":Controller::start(): No GameObject set for countdown display; timer will not work.");
        }
        else if (this.UITime.GetComponent <UI_Time>() == null)
        {
            Debug.LogWarning("WARN    " + this.gameObject.name + ":Controller::start(): No UI_Time script set for countdown display; timer will not work.");
        }
    }