Exemple #1
0
    private void CheckCollided()
    {
        PlayerControl p           = null;
        RaycastHit2D  leftCheck   = Raycast(new Vector2(-coll.size.x / 2, -coll.size.y / 2), Vector2.down, 0.1f, playerLayer);
        RaycastHit2D  rightCheck  = Raycast(new Vector2(+coll.size.x / 2, -coll.size.y / 2), Vector2.down, 0.1f, playerLayer);
        RaycastHit2D  middleCheck = Raycast(new Vector2(0f, -coll.size.y / 2), Vector2.down, 0.1f, playerLayer);

        if ((leftCheck || rightCheck || middleCheck) && !player.CheckFall() && !isHollow)
        {
            if (coin != null)
            {
                coin.WakeUp();
                player.AddCoin();
            }
            if (mus != null)
            {
                mus.WakeUp();
            }
            hitNumber--;
            if (hitNumber <= 0)
            {
                isHollow = true;
                anim.SetBool("isHollow", isHollow);
            }
        }
    }