1. 실행 이미지

 

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class GameDirector : MonoBehaviour
{
    [SerializeField] UIPopupNickname uIPopupNickname;
    [SerializeField] UIHome uIHome;

    void Start()
    {
        Init();

        StartCoroutine(CoClicker());
    }

 


    IEnumerator CoClicker()
    {
        while (true)
        {
            if(this.uIHome.gameObject.activeSelf == true)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    UserData.Instance.UserCurruntExperience += 10;

                    if (UserData.Instance.UserCurruntExperience >= UserData.Instance.UserMaxExperience)
                    {
                        UserData.Instance.UserCurruntExperience = 0;
                        UserData.Instance.UserMaxExperience += 100;
                        UserData.Instance.UserLevel++;
                    }

                }
            }
          
            yield return null;
        }
    }

    private void Init()
    {
        UserData.Instance.UserCurruntExperience = 0;
        UserData.Instance.UserMaxExperience = 100;
        UserData.Instance.UserLevel = 1;
    }
}

2. GameDirector.cs

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UIHomeMain : MonoBehaviour
{

    [SerializeField] private UIHome uIHome;
    [SerializeField] private UIPopupNickname uIPopupNickname;

    void Start()
    {
        uIHome.gameObject.SetActive(false);
        uIPopupNickname.gameObject.SetActive(true);




        uIHome.AddListenerButton(() => {
            uIPopupNickname.gameObject.SetActive(true);
            uIHome.gameObject.SetActive(false);
        });
    }

    void Update()
    {
        
    }
}

3. UIHomeMain.cs

+ Recent posts