少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, January 31, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
 
 
//灵宠的技能
namespace Snxxz.UI
{
 
    public class SkillButtonPet : CellView
    {
 
        [SerializeField] Button skillBtn;
        [SerializeField] Image skillIcon;
        [SerializeField] GameObject lockObj;
        [SerializeField] Text lockLvText;
 
        PetModel petModel { get { return ModelCenter.Instance.GetModel<PetModel>(); } }
        MountModel mountModel { get { return ModelCenter.Instance.GetModel<MountModel>(); } }
 
        public void SetModel(int skillId, int skillUnlock, bool isUnlock, int petId, SkillType skillType, bool isAll = false)
        {
            SkillConfig skillConfig = SkillConfig.Get(skillId);
            if (skillConfig == null) return;
 
            skillIcon.SetSprite(skillConfig.IconName);
            if (isUnlock)
            {
                lockObj.SetActive(false);
                lockLvText.gameObject.SetActive(false);
            }
            else
            {
                lockObj.SetActive(true);
                if (!isAll)
                {
                    lockLvText.gameObject.SetActive(true);
                    lockLvText.text = skillUnlock +Language.Get("Z1041");
 
                }
                else
                {
                    lockLvText.gameObject.SetActive(false);
                }
            }
 
            skillBtn.RemoveAllListeners();
            skillBtn.AddListener(() =>
            {
                string[] str = new string[2];
 
                int fightPower = 0;
 
                switch (skillType)
                {
                    case SkillType.PetSkill:
                        if (petModel.TryGetPetId(skillId, out petId))
                        {
                            PetInfoConfig petInfo = PetInfoConfig.Get(petId);
                            str[0] = skillConfig.Description;
                            str[1] = Language.Get("pet_SkillTipLv", petInfo.Name, petModel.GetSkillUnlockLevel(skillId));
                            fightPower = skillConfig.FightPower;
                        }
                        else
                        {
                            List<int> skills;
                            var effect = SkillConfig.GetSkillEffectValue(skillConfig);
                            var count = effect.GetHasValueCount();
                            var values = new int[count];
                            if (petModel.TryGetPetSkills(effect, out skills))
                            {
                                foreach (var id in skills)
                                {
                                    if (petModel.IsSkillUnlock(id))
                                    {
                                        var skillEffectGroup = petModel.GetSkillEffectGroup(id);
                                        for (int i = 0; i < count; i++)
                                        {
                                            values[i] += skillEffectGroup.GetEffectValue(i);
                                        }
                                        var config = SkillConfig.Get(id);
                                        fightPower += config.FightPower;
                                    }
                                }
                            }
                            str[0] = SkillConfig.GetSkillDescription(skillConfig.Description, values);
                            str[1] = string.Empty;
                        }
                        break;
                    case SkillType.MountSkill:
                        {
                            if (mountModel.GetMountSkillAndItem.ContainsKey(skillId))
                            {
                                var horseId = mountModel.GetMountSkillAndItem[skillId].HorseID;
                                var horseConfig = HorseConfig.Get(horseId);
                                if (horseConfig != null)
                                {
                                    str[0] = skillConfig.Description;
                                    str[1] = Language.Get("pet_SkillTipLv", horseConfig.Name, mountModel.GetSkillUnlockLevel(skillId));
                                }
                                fightPower = skillConfig.FightPower;
                            }
                            else
                            {
                                var effect = SkillConfig.GetSkillEffectValue(skillConfig);
                                List<int> skills;
                                var count = effect.GetHasValueCount();
                                var values = new int[count];
                                if (mountModel.TryGetHorseSkills(effect, out skills))
                                {
                                    foreach (var id in skills)
                                    {
                                        if (mountModel.IsSkillUnlock(id))
                                        {
                                            var skillEffectGroup = mountModel.GetSkillEffectGroup(id);
                                            for (int i = 0; i < count; i++)
                                            {
                                                values[i] += skillEffectGroup.GetEffectValue(i);
                                            }
                                            var config = SkillConfig.Get(id);
                                            fightPower += config.FightPower;
                                        }
                                    }
                                }
                                str[0] = SkillConfig.GetSkillDescription(skillConfig.Description, values);
                                str[1] = string.Empty;
                            }
                        }
                        break;
                }
                SkillDetails.ShowSkillDetails(skillId, SkillDetails.SkillSourceType.PetSkill, fightPower, str);
            });
        }
 
    }
 
    public enum SkillType
    {
        PetSkill,
        MountSkill,
    }
}