yyl
2 天以前 973edc44a04dceb8b48a32ca912e6167f86189d4
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
 
public class HeroCallResultCell : MonoBehaviour
{
    [SerializeField] UIHeroController heroModel;
    [SerializeField] Image newMarkImg;
    [SerializeField] UIEffectPlayer starEffect;
    [SerializeField] UIEffectPlayer lightEffect;
    [SerializeField] UIEffectPlayer boomEffect;
    [SerializeField] UIEffectPlayer tableEffect;
 
 
    /// <summary>
    /// 抽奖结果的小人展示
    /// </summary>
    /// <param name="heroID"></param>
    /// <param name="index">第几抽,0代表单抽</param>
    /// <param name="isForceSkip">强制跳过动画</param>
    public void Display(int heroID, int index, bool isForceSkip=false)
    {
        DisplayAsync(heroID, index, isForceSkip).Forget();
    }
 
    async UniTask DisplayAsync(int heroID, int index, bool isForceSkip=false)
    {
        this.transform.localScale = Vector3.zero;
        int delaytime = LocalSave.GetBool(HeroUIManager.skipKey, false) ? 50 * index : 100 * index;
 
        await UniTask.Delay(delaytime);
        this.transform.localScale = Vector3.one;
        //先显示台子,再显示小人
        heroModel.SetActive(false);
        newMarkImg.SetActive(false);
        var heroConfig = HeroConfig.Get(heroID);
        var quality = heroConfig.Quality;
 
        //是否跳过动画
        if (isForceSkip || LocalSave.GetBool(HeroUIManager.skipKey, false))
        {
            //红色特殊
            if (!isForceSkip)
            { 
                boomEffect.playDelayTime = 0;
                boomEffect.PlayByArrIndex(quality > 4 ? 0 : 1);
            }
            DisplayNewMark(heroID);
            DisplayHero(heroConfig);
            tableEffect.Stop();
            tableEffect.isPlaySpineLoop = true;
            tableEffect.PlayByArrIndex(quality);
            return;
        }
 
 
        starEffect.PlayByArrIndex(index);
        //紫色开始有播放
        if (quality <= 1)
        {
            lightEffect.Stop();
        }
        else
        {
            lightEffect.PlayByArrIndex(quality - 2);
        }
        boomEffect.playDelayTime = lightEffect.playDelayTime;
        //红色特殊
        boomEffect.PlayByArrIndex(quality > 4 ? 0 : 1);
 
        //先播放灰色台子上升,再播放小人
        tableEffect.onComplete = () =>
        {
            DisplayNewMark(heroID);
            DisplayHero(heroConfig);
            tableEffect.isPlaySpineLoop = true;
            tableEffect.PlayByArrIndex(quality);
        };
        tableEffect.Stop();
        tableEffect.isPlaySpineLoop = false;
        tableEffect.PlayByArrIndex(0);
 
 
    }
 
    public void DisplayNewMark(int heroID)
    {
        newMarkImg.SetActive(HeroUIManager.Instance.IsNewHero(heroID));
    }
    
    public void DisplayHero(HeroConfig heroConfig)
    {
        heroModel.SetActive(true);
        heroModel.Create(heroConfig.SkinIDList[0], 0.7f);
    }
}