1인 개발/PushAndSlash

푸쉬앤슬래시 개인 프로젝트 30일차

잼잼재미 2024. 6. 24. 14:43

구현 내용


1. 광고 구현


 

 

 

보상형 광고 구현

  • 광고 시청 후, 코인 획득
  • 클리어 후, 광고 시청으로 보상 2배 획득

 

 

//사용 시, 호출
public void LoadRewardedAd()
{
    // Clean up the old ad before loading a new one.
    if (_rewardedAd != null)
    {
        _rewardedAd.Destroy();
        _rewardedAd = null;
    }

    // create our request used to load the ad.
    var adRequest = new AdRequest();

    // send the request to load the ad.
    RewardedAd.Load(_adRewardUnitId, adRequest,
        (RewardedAd ad, LoadAdError error) =>
        {
            // if error is not null, the load request failed.
            if (error != null || ad == null)
            {
                Debug.LogError("Rewarded ad failed to load an ad " +
                               "with error : " + error);
                return;
            }

            Debug.Log("Rewarded ad loaded with response : "
                      + ad.GetResponseInfo());

            _rewardedAd = ad;
            RegisterEventHandlers(_rewardedAd);
            ShowRewardedAd();
        });
}

private void ShowRewardedAd()
{
    if (_rewardedAd != null && _rewardedAd.CanShowAd())
    {
        _rewardedAd.Show((Reward reward) =>
        {
            // 광고 보상 입력       
            }
        });
    }
}



private void RegisterEventHandlers(RewardedAd ad)
{
    // Raised when the ad is estimated to have earned money.
    ad.OnAdPaid += (AdValue adValue) =>
    {
        Debug.Log(String.Format("Rewarded ad paid {0} {1}.",
            adValue.Value,
            adValue.CurrencyCode));
    };
    // Raised when an impression is recorded for an ad.
    ad.OnAdImpressionRecorded += () =>
    {
        Debug.Log("Rewarded ad recorded an impression.");
    };
    // Raised when a click is recorded for an ad.
    ad.OnAdClicked += () =>
    {
        Debug.Log("Rewarded ad was clicked.");
    };
    // Raised when an ad opened full screen content.
    ad.OnAdFullScreenContentOpened += () =>
    {
        Debug.Log("Rewarded ad full screen content opened.");
    };
    // Raised when the ad closed full screen content.
    ad.OnAdFullScreenContentClosed += () =>
    {
        Debug.Log("Rewarded ad full screen content closed.");

        // 광고 창을 닫을 때, 실행할 내용
    };
    // Raised when the ad failed to open full screen content.
    ad.OnAdFullScreenContentFailed += (AdError error) =>
    {
        Debug.LogError("Rewarded ad failed to open full screen content " +
                       "with error : " + error);
        LoadRewardedAd();
    };
}

 

 

배너 광고 구현

  • 배틀맵에서 배너광고 생성

 

 

//광고 로드, 사용 시 호출
public void LoadBannerAd()
{
    if (_bannerView == null)
    {
        CreateBannerView();
    }

    var adRequest = new AdRequest();

    Debug.Log("Loading banner ad.");
    _bannerView.LoadAd(adRequest);
}

//광고 보여주기
private void CreateBannerView()
{
    Debug.Log("Creating banner view");

    if (_bannerView != null)
    {
        DestroyAd();
    }

    _bannerView = new BannerView(_adBannerUnitId, AdSize.Leaderboard, AdPosition.Bottom);

    //적응형 배너(꽉찬 사이즈)
    //AdSize adaptiveSize = AdSize.GetCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(AdSize.FullWidth);
    //_bannerView = new BannerView(_adBannerUnitId, adaptiveSize, AdPosition.Bottom);
}

private void DestroyAd()
{
    if (_bannerView != null)
    {
        Debug.Log("Destroying banner ad.");
        _bannerView.Destroy();
        _bannerView = null;
    }
}

 

 

https://kkln2486.tistory.com/398

 

광고 넣기 (Google AdMob)

광고 넣기1. 기본 셋팅Google AdMob 접속https://apps.admob.com/v2/home?subid=kr-ko-ha-z-g-a-de!o3~17547741505~141599850121~%EC%95%A0%EB%93%9C%EB%AA%B9~e&_ga=2.82521494.1447179567.1713169856-971684977.1713169856 AdMob이메일 또는 휴대전화ac

kkln2486.tistory.com

 

 

2. BGM 추가


  • 각 씬마다 BGM 추가
  • 무료 에셋 사용
  • SoundManager 사용

 

 

3. UI 효과 추가


 

Dotween Pro 에셋을 사용해서 게임 UI 연출 효과를 추가

 

 

트러블 슈팅


1. 3D 캐릭터 그림자 깨짐 현상

 

어느 순간부터 배틀맵에서 움직이는 캐릭터의 그림자가 많이 깨져서 어색하게 표현이 되었다.

 

 

 

분명 예전에 구현했을 때는 그림자가 정상적으로 나왔다.

 

 

 

  • Project Settings - Shadow Resolution을 Very High Resolution으로 변경
  • Shadow Distance 를 100으로 변경

 

 

 

이렇게 수정해도 기존의 그림자 처럼 자연스럽게 나오지는 않았지만, 크게 불편하지는 않았다. 갑자기 그림자가 깨지게 된 이유에 대해서 조금 더 알아보고 수정할 수 있다면 수정하도록하겠다. 일단 해결 완료!

 

 

회고


드디어 기획했던 모든 기능들을 구현했다. 사실 적 보스 캐릭터 구현도 기획했던 내용에 있었지만, 게임 자체가 PVP용 게임이기 때문에 크게 급하게 구현할 필요는 없다고 생각했다. 이제 모바일로 빌드해서 버그를 수정하고 마무리하고 빌드하도록 하겠다. 생각했던 기간보다 훨씬 많이 걸렸지만 정말 많은것들을 공부했다고 생각한다. 특히 멀티 관련해서 아주 많이 공부가 되었다. 앞으로도 주로 최대한 멀티를 이용한 게임을 개발하고 포트폴리오를 제작하도록 하겠다.