少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-20 a87120c155c48fa45b20a97c1a58bdbeb77318b7
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Snxxz.UI
{
    [XLua.Hotfix]
    public static class EquipShowSwitch
    {
        static MagicianModel godWeaponModel
        {
            get { return ModelCenter.Instance.GetModel<MagicianModel>(); }
        }
 
        const int GODWEAPON_EFFECT_STAGE = 3;
 
        public static bool IsGodWeaponEffectOn(uint value, out Dictionary<int, int> dict)
        {
            dict = new Dictionary<int, int>();
            foreach (var type in godWeaponModel.godWeaponEffectTypes)
            {
                var level = 0;
                if (IsGodWeaponEffectOn(value, type, out level))
                {
                    dict.Add(type, level);
                }
            }
            return dict.Count > 0;
        }
 
        public static bool IsGodWeaponEffectOn(uint value, int type, out int level)
        {
            level = 0;
            if (value == 7)
            {
                return false;
            }
            for (int i = 0; i < GODWEAPON_EFFECT_STAGE; i++)
            {
                var stage = i + 1;
                var index = GetGodWeaponEquipShowIndex(type, stage);
                if (MathUtility.GetBitValue(value, index))
                {
                    level = godWeaponModel.GetGodWeaponStageRequireLevel(type, stage);
                    return true;
                }
            }
            return false;
        }
 
        public static byte GetGodWeaponEquipShowIndex(int type, int stage)
        {
            EquipShowSwitchType switchType = EquipShowSwitchType.GodWeapon_Life1;
            switch (type)
            {
                case 1:
                    switchType = stage == 1 ? EquipShowSwitchType.GodWeapon_Life1 : stage == 2 ?
                        EquipShowSwitchType.GodWeapon_Life2 : EquipShowSwitchType.GodWeapon_Life3;
                    break;
                case 2:
                    switchType = stage == 1 ? EquipShowSwitchType.GodWeapon_Atk1 : stage == 2 ?
                        EquipShowSwitchType.GodWeapon_Atk2 : EquipShowSwitchType.GodWeapon_Atk3;
                    break;
                case 4:
                    switchType = stage == 1 ? EquipShowSwitchType.GodWeapon_Defend1 : stage == 2 ?
                        EquipShowSwitchType.GodWeapon_Defend2 : EquipShowSwitchType.GodWeapon_Defend3;
                    break;
            }
            return (byte)switchType;
        }
 
        public static void SendGodWeaponEffectOn(int type, int stage, bool isOn)
        {
            var level = 0;
            var value = PlayerDatas.Instance.baseData.equipShowSwitch;
            var requireLevel = godWeaponModel.GetGodWeaponStageRequireLevel(type, stage);
            if (isOn && IsGodWeaponEffectOn(value, type, out level)
                && level != requireLevel)
            {
                var _stage = 0;
                if (godWeaponModel.TryGetGodWeaponStage(type, level, out _stage))
                {
                    var index = GetGodWeaponEquipShowIndex(type, _stage);
                    value = (uint)MathUtility.SetBitValue((int)value, index, false);
                }
            }
 
            {
                var index = GetGodWeaponEquipShowIndex(type, stage);
                value = (uint)MathUtility.SetBitValue((int)value, index, isOn);
            }
 
            if (value != PlayerDatas.Instance.baseData.equipShowSwitch)
            {
                SendPackage(value);
            }
        }
 
        public static bool IsEquipShowSwitchOn(EquipShowSwitchType type, uint value)
        {
            if ((int)type >= (int)EquipShowSwitchType.max)
            {
                return false;
            }
            return MathUtility.GetBitValue(value, (ushort)type);
        }
 
        public static void SendPackage(uint value)
        {
            C032F_tagCRequestEquipShowHide pak = new C032F_tagCRequestEquipShowHide();
            pak.EquipShowSwitch = value;
            GameNetSystem.Instance.SendInfo(pak);
        }
 
        public enum EquipShowSwitchType : byte
        {
            GodWeapon_Life1,//生命
            GodWeapon_Life2,
            GodWeapon_Life3,
            GodWeapon_Atk1,//攻击
            GodWeapon_Atk2,
            GodWeapon_Atk3,
            GodWeapon_Defend1,//护盾
            GodWeapon_Defend2,
            GodWeapon_Defend3,
            max = 32,
        }
    }
}