Exemplo n.º 1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        PlayerEntity player          = collision.gameObject.GetComponent <PlayerEntity>();
        Rigidbody2D  playerRigidbody = collision.gameObject.GetComponent <Rigidbody2D>();

        if (!_isSticky)
        {
            _wallManagerScript.Bounce(player.GetLastFrameVelocity(), collision.GetContact(0).normal, playerRigidbody, player.speed, friction);
        }
        else
        {
            _wallManagerScript.StickyWall(playerRigidbody);
        }

        //permet aux murs connectés de partagés leur dommages
        //Si un mur est connecté à celui à sa droite, alors le mur à la droite prendra les mêmes dégâts que celui à gauche, et vice-versa
        if (_isConnected)
        {
            if (player.GetPlayerINPUTSTATE() != PlayerEntity.INPUTSTATE.GivingInput)
            {
                _wallManagerScript.ConnectedtWallDammage(player.GetVelocityRatio(), gameObject, _connectedWallProprieties, _connectedWallChange);
                _thisWallChange.SetShaderNeededTrue();
                _connectedWallChange.SetShaderNeededTrue();
            }
        }
    }
Exemplo n.º 2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        PlayerEntity player          = collision.gameObject.GetComponent <PlayerEntity>();
        Rigidbody2D  playerRigidbody = collision.gameObject.GetComponent <Rigidbody2D>();

        _anim.SetBool("isHit", true);

        _wallManagerScript.Bounce(player.GetLastFrameVelocity(), collision.GetContact(0).normal, playerRigidbody, player.speed, friction);
        if (_newSoundManagerScript != null)
        {
            _newSoundManagerScript.PlaySound("BumperHit");
        }
    }