게임클라이언트 프로그래밍/Guns N Rachel's

Dice 버그 수정, 연출 추가(등급별 연출)

Game Client Lee Hwanguk 2023. 5. 25. 04:58

#Dice를 계속 테스트 중이다. 치명적인 버그 몇가지가 있었다.

1. Dice의 Go 버튼이 비활성화되는 시점(Gold부족 or 용량부족)에서 버튼이 계속 비활성화 되어있다. 

    원래 짜놓은 로직은 비활성화가 되는 코루틴을 돌고 1f초 뒤 다시 활성화가 되어야한다.

    =>코루틴이 돌고있는 도중 close버튼이나 dim버튼을 누르고 UI가 비활성화되면 코루틴이 돌고 있는 도중 비활성화 되            고 버튼 활성화 과정까지 오지않는 버그였다. 버튼 비활성화 단계에서 close 버튼과 dim을 비활성화 해줌으로 해결

private IEnumerator RollDiceBtnSetting()
    {
        while (true)
        {
            yield return new WaitForSeconds(0.2f);
            this.closeBtn.interactable = false;
            this.dim.interactable = false;
            this.BtnGoColorDown();
            this.rollBtn.interactable = false;
            if (this.dice.rb.velocity.magnitude == 0)
            {
                this.dice.StopDice();
                this.rollBtn.interactable = true;
                this.BtnGoColorUp();
                this.dice.DiceResultImg();
                this.closeBtn.interactable = true;
                this.dim.interactable = true;

                //Percentage
                this.dice.GradePercentage();
                this.dice.TypePercentage();
                yield break;
            }           
        }
    }

 

2.Stage가 진행되어도 txtDicePrice가 갱신이되지 않고 있다.

   info 참조를 잘못하고 있는 듯 보였다.

    =>Init에서 info를 참조하고 현재 stage를 참조하고있었다. 디버그를 찍어보니 Init은 한번만 했고

        던전 씬에 있는동안은 계속 1Stage인 상황이었다. 활성화 될때마다(유저가 Dice UI를 활성화 시킬때마다) info를                참조 하는 로직으로 변경했다 OnEnable에서 참조하게 변경

    private void OnEnable()
    {
        Debug.Log("DiceActive");
        this.txtDicePrice.text = DataManager.Instance.GetGamblePrice(InfoManager.instance.dungeonInfo.CurrentStageInfo).ToString() + "Gold";
    }

 

#연출을 추가했다. 지금은 어떤 등급이 나와도 모두 같은 연출이고 연출도 맘에들지 않았다. DoTween.DoMove에서 다른 easing을 사용해봤다. 

그리고 Diamond 등급 장비가 나올때는 파티클을 활성화하고 폭죽 느낌의 연출을 만들어봤다.

파티클은 직접 만들어본 경험이 적어서 자료를 참고해야했다. 

 

*참고자료

https://rito15.github.io/posts/unity-particle-system-example-07-fireworks/

 

파티클 시스템 예제 - 07 - Fireworks

목차

rito15.github.io

public void StopDice()
    {
        this.rb.isKinematic = true;
        //Wood,Iron,Gold 등급 연출
        if (this.eRewardGrade == ErewardGrade.Wood || this.eRewardGrade == ErewardGrade.Iron 
            || this.eRewardGrade == ErewardGrade.Gold)
        {
            Debug.LogFormat("{0}", this.eRewardGrade);
            this.transform.DOMove(new Vector3(0, 2.5f, 0), 2f).SetEase(Ease.OutExpo);
        }
        //Diamond 등급 연출
        else if(this.eRewardGrade == ErewardGrade.Diamond)
        {
            Debug.LogFormat("{0}", this.eRewardGrade);
            this.transform.DOMove(new Vector3(0, 2.5f, 0), 1.2f).SetEase(Ease.OutExpo).OnComplete(() =>
            {
                StartCoroutine(this.CoFireWorksParticle());
            });
        }
        Quaternion targetRotation = Quaternion.Euler(0f, -360f, 0f); //-360f
        this.transform.DORotate(targetRotation.eulerAngles, 0.01f).SetEase(Ease.OutExpo);
    }
    private IEnumerator CoFireWorksParticle()
    {
        this.fireWorksParticle.gameObject.SetActive(true);
        this.fireWorksParticle.transform.position = this.transform.position + new Vector3(-0.01317787f, -1.07f, 1.875343f);
        this.fireWorksParticle.Play();
        yield return new WaitForSeconds(5f);
        this.fireWorksParticle.gameObject.SetActive(false);
    }

*주사위가 멈추는 시점 StopDice에서 결과등급을 확인하고 연출을 나눠봤다

Wood,Iron,Gold 등급에서는 DOMove(new Vector3(0, 2.5f, 0), 2f).SetEase(Ease.OutExpo); 에서 2f초 동안 지속되게하고

Diamond 등급에서는  this.transform.DOMove(new Vector3(0, 2.5f, 0), 1.2f).SetEase(Ease.OutExpo);

로 1.2f 동안 지속되게 하여 상대적으로 빠르게 보여지는 연출을 만들어봤다.

 

이 연출만으론 부족하니 파티클을 추가하여 Diamond등급일때 더 연출이 돋보이게 만들어봤다.

 

*Wood,Iron,Gold 등급일떄

*Diamond 등급일때 파티클 활성