Ejemplo n.º 1
0
    void OnCollisionEnter2D(Collision2D hit)
    {
        if (hit.gameObject.layer == 8)
        {
            //Collision avec un autre joueur
            PlayerMovementController collPlayerMovementManager = hit.gameObject.GetComponent <PlayerMovementController>();
            PlayerBehaviour          collPlayerBehaviour       = hit.gameObject.GetComponent <PlayerBehaviour>();
            dashedDirection = collPlayerMovementManager.GetDashDirection();
            //dashedSpeed = collPlayerMovementManager.dashSpeed * (collPlayerBehaviour.strength / playerBehaviour.strength);
            dashedSpeed = collPlayerMovementManager.dashSpeed * collPlayerBehaviour.strength;
            dashedTime  = startDashedTime * collPlayerBehaviour.strength;
            if (collPlayerMovementManager.GetIsDashing() && !playerMovementController.GetIsDashing())
            {
                collPlayerMovementManager.CancelDash();
                playerMovementController.SetIsDashed(true);
            }
            else if (collPlayerMovementManager.GetIsDashing() && playerMovementController.GetIsDashing())
            {
                playerMovementController.CancelDash();
                if (playerBehaviour.strength < collPlayerBehaviour.strength)
                {
                    playerMovementController.SetIsDashed(true);
                }
            }
        }
        else if (hit.gameObject.layer == 10)
        {
            //Collision avec un mur
            playerMovementController.CancelDash();
        }

        /*
         * else if (hit.gameObject.layer == 12)
         * {
         *  Debug.Log("hit dino");
         *  playerBehaviour.Die();
         * }
         */
    }