반응형

Unity ugui로 스킬쿨타임 간단 구현 하겟습니다.









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
32
33
34
35
36
37
38
39
40
41
42
43
bool isCharging = false;
    float nowDelayTime = 0;
    public void Chk_SkillcoolTime()
    {
        User_Abillity abil = UserdataManager.Instance.user.user_Abillity;
        text_skillLv.text = string.Format("Skill\nLv.{0}", abil.SkillLv);
 
        if (!isCharging)
            StartCoroutine(ChargeSkill(abil));
        else
            nowDelayTime = 0;
    }
 
    IEnumerator ChargeSkill(User_Abillity _abil)
    {
        
        
 
        while (_abil.SkillLv <= 2)
        {
            isCharging = true;
            nowDelayTime += Time.deltaTime;
 
            if (nowDelayTime >= _abil.SkillChargeCoolTime)
            {
                nowDelayTime = 0;
                _abil.SkillLv++;
 
                if (_abil.SkillLv == 3)
                    isCharging = false;
 
                text_skillLv.text = string.Format("Skill\nLv.{0}", _abil.SkillLv);
 
            }
            else
            {
                image_skillCooltime.fillAmount = nowDelayTime / _abil.SkillChargeCoolTime;
            }
 
            yield return null;
        }
    }
 
cs


반응형

+ Recent posts