コード例 #1
0
    // Check if given hitbox connected with target hurtbox with adjusted positions
    protected static bool IsHitTarget(Hitbox userHit, float userScaleX, Vector2 userPos,
                                      Hitbox targetHurt, float targetScaleX, Vector2 targetPos)
    {
        // Shift user hitbox to position
        var userFlip = (int)Mathf.Sign(userScaleX);

        userHit.UpdateBox(userPos, userFlip);
        // Shift target hurtbox to position
        var tarFlip = (int)Mathf.Sign(targetScaleX);

        targetHurt.UpdateBox(targetPos, tarFlip);

        // See if the hitbox came into contact with hurtbox
        return(userHit.CheckHit(targetHurt));
    }