티스토리 뷰

금일 작업 내용

  • 타이틀 작업
    • 시작 버튼으로 게임 시작
    • 설정 버튼으로 설정 UI 출현 | 퇴장
      • BGM과 SE 볼륨을 조절할 수 있도록 구성
    • 퇴장 버튼으로 게임 종료(영상에는 없음)
  • 임시용 BGM과 SE 추가
    • BGM 출처: Pixabay - every day -playful cute piano

 

새로운 요소

슬라이드

세팅이나 다양한 방면에서 사용 가능한 Unity 자체 지원 UI 프리셋.

public void OnSliderEvent(float volume) 을 통해서 슬라이드 바 변경 사항을 적용할 수 있다.

┗ 철자가 틀리면 정상 작동이 되지 않으므로 주의할 것. 변수도 그대로 사용해야 한다.

 

결과물(영상)

 

코드

AudioManager

더보기
public class Audio_Manager : MonoBehaviour
{
    public static Audio_Manager Instance;

    public AudioSource audio_Source;
    public AudioClip clip;

    public GameObject Setting_UI;
    public bool is_Up;
    public float up_time;
    public bool is_Moveing;

    public float BGM_Sound;
    public float SE_Sound;

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
            Destroy(this.gameObject);

        audio_Source = GetComponent<AudioSource>();

        if (PlayerPrefs.HasKey("BGM_Sound"))
            Set_BGM_Sound(PlayerPrefs.GetFloat("BGM_Sound"));
        else
            Set_BGM_Sound(1.0f);

        if (PlayerPrefs.HasKey("SE_Sound"))
            Set_SE_Sound(PlayerPrefs.GetFloat("SE_Sound"));
        else
            Set_SE_Sound(1.0f);
    }

    // Start is called before the first frame update
    void Start()
    {
        audio_Source.clip = this.clip;
        audio_Source.Play();

        is_Up = false;
    }

    public void Set_BGM_Sound(float _Degree)
    {
        BGM_Sound = _Degree;
        PlayerPrefs.SetFloat("BGM_Sound", BGM_Sound);

        audio_Source.volume = BGM_Sound;
    }

    public void Set_SE_Sound(float _Degree)
    {
        SE_Sound = _Degree;
        PlayerPrefs.SetFloat("SE_Sound", SE_Sound);
    }

    public IEnumerator Setting_UI_Move()
    {
        if (is_Up) {
            is_Moveing = true;
            for (float i = 0.0f; i < up_time; i+= Time.deltaTime)
            {
                Setting_UI.GetComponent<RectTransform>().anchoredPosition = new Vector2(-250.0f, -10.0f - (i * 120.0f / up_time));
                yield return null;
            }
            is_Moveing = false;
            is_Up = false;
        }

        else
        {
            is_Moveing = true;
            for (float i = 0.0f; i < up_time; i += Time.deltaTime)
            {
                Setting_UI.GetComponent<RectTransform>().anchoredPosition = new Vector2(-250.0f, -130.0f + (i * 120.0f / up_time));
                yield return null;
            }
            is_Moveing = false;
            is_Up = true;
        }
    }
}

음량 조절 슬라이더

더보기
public class Setting_Slider : MonoBehaviour
{
    [SerializeField]
    Slider Sli;
    float Cur_Value;
    public bool is_BGM;

    private void Start()
    {
        if (is_BGM)
            Cur_Value = Audio_Manager.Instance.BGM_Sound;
        else
            Cur_Value = Audio_Manager.Instance.SE_Sound;

        Sli.value = Cur_Value;
    }

    public void OnSliderEvent(float volume)
    {
        Cur_Value = volume;

        if (is_BGM)
            Audio_Manager.Instance.Set_BGM_Sound(volume);
        else
            Audio_Manager.Instance.Set_SE_Sound(volume);
    }
}

게임 오버 UI (체력 전소 시 GameManager에서 Game_Over 오브젝트를 활성화 하는 방식으로 사용.)

더보기
public class Game_Over: MonoBehaviour
{
    public float time;

    private void Start()
    {
        time = 0.0f;
        Audio_Manager.Instance.audio_Source.Stop();
    }

    private void Update()
    {
        time += Time.deltaTime;

        if(time >= 5.0f)
        {
            Audio_Manager.Instance.audio_Source.Play();
            SceneManager.LoadScene("Title");
        }
    }
}

이외에는 간단한 작업사항이 끝이므로 생략합니다.

 

정리하며

오늘은 전체적으로 복습에 가까운 작업들이었습니다.

다만, 슬라이더에서 사소한 문제를 못찾아서 헤메다가 작업량이 다소 많이 적었습니다...;;

 

그래도 이로써 기본적인 플레이는 가능한 게임이 작업 완료되었습니다.

물론, 실제로 플레이 하려면 플레이어를 비롯한 오브젝트들의 스프라이트를 바꿔야 한다거나, 장비 시스템을 추가해야 한다거나, 세이브 방식도 작성해야 한다거나, 적장 인 게임의 효과음은 전무하다거나, 타이틀 음악이 인 게임에는 어울리지 않는다거나 하는 등의 작업사항이 산적해 있기는 하지만, 그래도 '플레이'는 가능하니까요.

 

그래도 아직 이걸로 작업해 보지 않은 연습 사항이 몇 남아 있기도 하고, 당장 다음 주 부터 본 캠프 시작인지라, 다음 프로젝트로 넘어가지는 않을 거 같습니다. [본 캠프 까지 하면서 개인 작업까지 하기에는 시간이 좀 많이 적어요.]

일단 1차적으로 뱀서라이크 비스무리하게 만들고 난 다음에 개인 작업 단계에서는 핵앤 슬래시로 다듬는 방식이 될 거 같습니다.

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함