少年修仙传客户端代码仓库
client_Hale
2018-10-09 fddfc335126c8e408f573449659ad5bd79811eed
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, September 27, 2018
//--------------------------------------------------------
 
using LitJson;
using System;
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
 
namespace Snxxz.UI
{
 
    public class WheelOfFortuneModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
        public class AngleClass
        {
            public float AngleStart;
            public float AngleEnd;
        }
 
        public int Lattice = -1;//格子
        public int Number = 0;//次数
        public int NeedJade = 0;//需要仙玉
        public float AngleSave = 0f;//角度记录
        public Dictionary<int, AngleClass> AngleDic = new Dictionary<int, AngleClass>();
        private  int[][] AngleList;
        public event Action<float> WheelOfFortuneUpdate;
 
        private string StrKey = string.Empty;
        private bool IsOk = false;
 
        private const int Redpoint_key1 = 66666;//幸运转盘红点
        public Redpoint redPointStre1 = new Redpoint(6666, Redpoint_key1);
        VipModel m_Vipmodel;
        VipModel vipmodel { get { return m_Vipmodel ?? (m_Vipmodel = ModelCenter.Instance.GetModel<VipModel>()); } }
        public override void Init()
        {
            var BindJadewheel = Config.Instance.Get<FuncConfigConfig>("BindJadeWheelCfg");
            NeedJade = int.Parse(BindJadewheel.Numerical1);
            AngleList = JsonMapper.ToObject<int[][]>(BindJadewheel.Numerical5);
            for (int i = 0; i < AngleList.Length; i++)
            {
                if (AngleDic.Count <= 0)
                {
                    int Type = i + 1;
                    AngleClass angleClass = new AngleClass();
                    angleClass.AngleStart = AngleList[i][0];
                    angleClass.AngleEnd = AngleList[i][1];
                    AngleDic.Add(Type, angleClass);
                }
            }
        }
 
        public override void UnInit()
        {
 
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            IsOk = false;
          
        }
 
        public void OnPlayerLoginOk()
        {
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= Updatefighting;//数据的刷新(h0418)
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent += Updatefighting;//数据的刷新(h0418)
            IsOk = true;
            StrKey = "IsOpenFiaryJadeRedPoint" + PlayerDatas.Instance.baseData.PlayerID;
            AngleSave = LocalSave.GetFloat(StrKey);
            RedPoint();
        }
 
      
 
        public void BindJadeWheelResult(HA324_tagMCBindJadeWheelResult Info)
        {
            Lattice = Info.Index;
            Number = Info.Cnt;
            if (IsOk)
            {
                if (AngleDic.ContainsKey(Lattice))
                {
 
                    float flo = UnityEngine.Random.Range(AngleDic[Lattice].AngleStart + 0.05f, AngleDic[Lattice].AngleEnd - 0.05f);
                    LocalSave.SetFloat(StrKey, flo);
                    AngleSave = LocalSave.GetFloat(StrKey);
                }
                if (WheelOfFortuneUpdate != null)
                {
                    WheelOfFortuneUpdate(AngleSave);
                }
                RedPoint();
            }
           
        }
        public void StartTheDraw()//开始抽奖
        {
            CA517_tagCMStartBindJadeWheel _tagC517 = new CA517_tagCMStartBindJadeWheel();
            GameNetSystem.Instance.SendInfo(_tagC517);
        }
 
        private void Updatefighting(PlayerDataRefresh obj)//红点
        {
            if (obj == PlayerDataRefresh.VIPLv)
            {
                RedPoint();
            }
        }
        private void RedPoint()
        {
            redPointStre1.state = RedPointState.None;
            int LotteryNumber = vipmodel.GetVipPrivilegeCnt(VipPrivilegeType.BindJadeWheel);
            if (LotteryNumber > Number)
            {
                redPointStre1.state = RedPointState.Simple;
            }
        }
    }
 
}