| | |
| | | // [Author]: 第二世界 |
| | | // [ Date ]: Thursday, September 27, 2018 |
| | | //-------------------------------------------------------- |
| | |
|
| | | using LitJson;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | |
| | | using LitJson; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using TableConfig; |
| | | using UnityEngine;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | 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()
|
| | | {
|
| | | 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 double[][] AngleList; |
| | | public event Action<float> WheelOfFortuneUpdate; |
| | | |
| | | private string StrKey = string.Empty; |
| | | private bool IsOk = false; |
| | | private const int Redpoint_key1 = 20106;//幸运转盘红点 |
| | | public Redpoint redPointStre1 = new Redpoint(201, 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<double[][]>(BindJadewheel.Numerical5); |
| | | for (int i = 0; i < AngleList.Length; i++) |
| | | { |
| | | if (AngleDic.Count <= 0) |
| | | { |
| | | int Type = i + 1; |
| | | AngleClass angleClass = new AngleClass(); |
| | | angleClass.AngleStart = (float)AngleList[i][0]; |
| | | angleClass.AngleEnd = (float)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) |
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; |
| | | IsOk = true; |
| | | StrKey = "IsOpenFiaryJadeRedPoint" + PlayerDatas.Instance.baseData.PlayerID; |
| | | AngleSave = LocalSave.GetFloat(StrKey); |
| | | RedPoint(); |
| | | }
|
| | |
|
| | | 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();
|
| | | private void OnFuncStateChangeEvent(int obj) |
| | | { |
| | | if (obj == 144) |
| | | { |
| | | 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); |
| | | if (flo > 360f) |
| | | { |
| | | flo = flo - 360f; |
| | | } |
| | | 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;
|
| | | }
|
| | | }
|
| | | } |
| | | 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() |
| | | { |
| | | if (!FuncOpen.Instance.IsFuncOpen(144) /*|| Number<=0*/) |
| | | { |
| | | return; |
| | | } |
| | | int GetDayOfYear = DateTime.Now.DayOfYear; |
| | | string strKey = "WheelOfRedPoint" + PlayerDatas.Instance.baseData.PlayerID; |
| | | int day = LocalSave.GetInt(strKey); |
| | | if (day != GetDayOfYear) |
| | | { |
| | | redPointStre1.state = RedPointState.Simple; |
| | | } |
| | | else |
| | | { |
| | | redPointStre1.state = RedPointState.None; |
| | | } |
| | | } |
| | | |
| | | public int GetTheGrid(float angle) |
| | | { |
| | | foreach (var key in AngleDic.Keys) |
| | | { |
| | | if (angle > AngleDic[key].AngleStart && angle < AngleDic[key].AngleEnd) |
| | | { |
| | | return key; |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | } |