yyl
9 小时以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
 
public class DamageContent : MonoBehaviour
{
    public GameObject line;
 
    public RectTransform parent;
 
    protected List<DamageLine> damageLineList = new List<DamageLine>();
 
    public PositionTween posTween;
 
    void Awake()
    {
        line.SetActive(false);
    }
 
    public void SetDamage(List<int> damages, Action _onComplete)
    {
        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]);
        }
 
        for (int i = damages.Count; i < damageLineList.Count; i++)
        {
            damageLineList[i].SetActive(false);
        }
 
        posTween.Play(_onComplete);
    }
 
    public void Stop()
    {
        posTween.Stop();
    }
 
    public void Resume()
    {
        posTween.Resume();
    }
}