yyl
2025-09-18 871594462e82d6bc1341918d39e11ab036d59563
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Cysharp.Threading.Tasks;
 
public class DamageContent : MonoBehaviour
{
    public GameObject line;
 
    public RectTransform parent;
 
    protected List<DamageLine> damageLineList = new List<DamageLine>();
 
    public PositionTween posTween;
 
    public ScaleTween scaleTween;
 
    private BattleDmgInfo battleDmgInfo;
 
    void Awake()
    {
        line.SetActive(false);
    }
 
    public async void SetDamage(BattleDmgInfo _damageInfo, Action _onComplete)
    {
        battleDmgInfo = _damageInfo;
 
        var damages = battleDmgInfo.battleDamageList;
 
        for (int i = damages.Count; i < damageLineList.Count; i++)
        {
            damageLineList[i].SetActive(false);
        }
 
        posTween.Play(_onComplete);
 
        if (battleDmgInfo.IsCrit())
        {
            scaleTween.Play();
        }
 
        for (int i = 0; i < damages.Count; i++)
        {
            if (i >= damageLineList.Count)
            {
                GameObject newLine = GameObject.Instantiate(line, parent);
                damageLineList.Add(newLine.GetComponent<DamageLine>());
            }
            damageLineList[i].SetActive(true);
            damageLineList[i].SetDamage(damages[i]);
            await UniTask.Delay(100);
        }
    }
 
    public void Stop()
    {
        posTween.Stop();
        if (battleDmgInfo.IsCrit())
        {
            scaleTween.Stop();
        }
    }
 
    public void Resume()
    {
        posTween.Resume();
        if (battleDmgInfo.IsCrit())
        {
            scaleTween.Resume();
        }
    }
}