wangguan
2020-10-22 7a007a8d1e7cd712fa4571efdbc3f2eba7a7e4d0
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
 
/**
 * 无尽模式选择buff
 * @Author: chenxin
 * @Date: 2020-10-15 17:00:26
 */
namespace KTGMGemClient
{
    public class SelectBuffIcon : MonoBehaviour
    {
        public Image Icon;
 
        public Image BgMask;
 
        public Image Check;
 
        public Text Name;
 
        public Text Effect;
 
        public event Action<int> OnSelectBuffCompleted;
 
        /// <summary>
        /// 选择的索引
        /// </summary>
        public int Index;
 
        private void Start()
        {
            SetState(EndlessBuffSelectState.Normal);
        }
 
        /// <summary>
        /// 设置选中状态
        /// </summary>
        /// <param name="state"></param>
        public void SetState(EndlessBuffSelectState state)
        {
            switch (state)
            {
                case EndlessBuffSelectState.Normal:
                    Check.gameObject.SetActive(false);
                    BgMask.gameObject.SetActive(false);
 
                    break;
                case EndlessBuffSelectState.Unselected:
                    Check.gameObject.SetActive(false);
                    BgMask.gameObject.SetActive(true);
                    break;
                case EndlessBuffSelectState.Selected:
                    Check.gameObject.SetActive(true);
                    BgMask.gameObject.SetActive(false);
                    break;
            }
        }
 
        public void OnClick()
        {
            if (OnSelectBuffCompleted != null)
                OnSelectBuffCompleted(Index);
        }
 
        public void SetIcon(Sprite param)
        {
            Icon.sprite = param;
        }
 
        public void SetName(string buffName)
        {
            Name.text = buffName;
        }
 
        /// <summary>
        /// 设置buff效果描述
        /// </summary>
        /// <param name="effect"></param>
        public void SetEffect(string effect)
        {
            Effect.text = effect;
        }
 
        /// <summary>
        /// 设置品级
        /// </summary>
        /// <param name="rare"></param>
        public void SetRare(int rare)
        {
            Name.color = EndlessBuffData.GetColorByRare(rare);
        }
    }
}