| | |
| | | [XLua.LuaCallCSharp]
|
| | | public class RedEnvelopeModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
| | | {
|
| | | Dictionary<int, string> redpackSfxDict = new Dictionary<int, string>();
|
| | |
|
| | | PlayerRedPacketDatas redPackdata { get { return ModelCenter.Instance.GetModel<PlayerRedPacketDatas>(); } }
|
| | | OSRedEnvelopeModel envelopeModel { get { return ModelCenter.Instance.GetModel<OSRedEnvelopeModel>(); } }
|
| | | FestivalRedpackModel festivalRedpackModel { get { return ModelCenter.Instance.GetModel<FestivalRedpackModel>(); } }
|
| | |
|
| | | public override void Init()
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public void SendGetEnvelope(int _id)
|
| | | public void SendGetEnvelope(int _id,int getWay)
|
| | | {
|
| | | RedEnvelope _envelope;
|
| | | if(m_RedEnvelopeDict.TryGetValue(_id,out _envelope))
|
| | |
| | | {
|
| | | CAB12_tagCMGrabFamilyRedPacket _pak = new CAB12_tagCMGrabFamilyRedPacket();
|
| | | _pak.RedPaketID = (uint)_id;
|
| | | _pak.GetWay = (byte)getWay;
|
| | | GameNetSystem.Instance.SendInfo(_pak);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public int cacheEnvelopeId = 0;
|
| | | public int envelopeSfx { get; set; }
|
| | | public void SendOpenRedpackPackage(int _id)
|
| | | public void SendOpenRedpackPackage(int _id,int getWay)
|
| | | {
|
| | | cacheEnvelopeId = _id;
|
| | | CAB12_tagCMGrabFamilyRedPacket _pak = new CAB12_tagCMGrabFamilyRedPacket();
|
| | | _pak.RedPaketID = (uint)_id;
|
| | | _pak.GetWay = (byte)getWay;
|
| | | GameNetSystem.Instance.SendInfo(_pak);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | private void OnSystemNotifyEvent(string _key)
|
| | | {
|
| | | if (_key.Equals("OSRedpackSfx"))
|
| | | var config = Config.Instance.Get<SysInfoConfig>(_key);
|
| | | var type = 0;
|
| | | if (config != null && string.IsNullOrEmpty(config.richText))
|
| | | {
|
| | | CheckRedpackSfx();
|
| | | foreach (var key in redpackSfxDict.Keys)
|
| | | {
|
| | | if (_key.Equals(redpackSfxDict[key]))
|
| | | {
|
| | | type = key;
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | if (type != 0)
|
| | | {
|
| | | switch (type)
|
| | | {
|
| | | case 5:
|
| | | CheckRedpackSfx(type);
|
| | | break;
|
| | | case FestivalRedpackModel.FESTIVALSYSTEMREDPACK1:
|
| | | case FestivalRedpackModel.FESTIVALSYSTEMREDPACK2:
|
| | | case FestivalRedpackModel.FESTIVALTASKREDPACKTYPE:
|
| | | CheckFestivalRedpackSfx(type);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void CheckRedpackSfx()
|
| | | public void CheckRedpackSfx(int type)
|
| | | {
|
| | | if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.OpenServerRedEnvelope))
|
| | | {
|
| | |
| | | sfxRedpackTime = sfxRedpackTime.AddSeconds(_effect != null ? _effect.duration : 0);
|
| | | }
|
| | | }
|
| | |
|
| | | public void CheckFestivalRedpackSfx(int type)
|
| | | {
|
| | | if (!festivalRedpackModel.IsOpen)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (type == FestivalRedpackModel.FESTIVALTASKREDPACKTYPE)
|
| | | {
|
| | | if (festivalRedpackModel.grabRedpackTimes >= festivalRedpackModel.grabRedpackLimitTimes)
|
| | | {
|
| | | return;
|
| | | }
|
| | | }
|
| | | if (!serverInited)
|
| | | {
|
| | | return;
|
| | | }
|
| | | festivalRedpackModel.JudgePlayRedpackVoice(type);
|
| | | if (!(StageManager.Instance.CurrentStage is DungeonStage)
|
| | | || WindowCenter.Instance.IsOpen<LoadingWin>())
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (DateTime.Now >= sfxRedpackTime)
|
| | | {
|
| | | var effectId = type == FestivalRedpackModel.FESTIVALSYSTEMREDPACK1 ? 5217 : 5162;
|
| | | var _effect = EffectMgr.Instance.PlayUIEffect(effectId, 4500, WindowCenter.Instance.uiRoot.tipsCanvas, false);
|
| | | sfxRedpackTime = sfxRedpackTime.AddSeconds(2f);
|
| | | }
|
| | | }
|
| | | #endregion
|
| | |
|
| | | void ParseConfig()
|
| | | {
|
| | | var config = Config.Instance.Get<FuncConfigConfig>("OpenServerRedPacketRain");
|
| | | var json = LitJson.JsonMapper.ToObject(config.Numerical2);
|
| | | foreach (var key in json.Keys)
|
| | | {
|
| | | var type = int.Parse(key);
|
| | | redpackSfxDict.Add(type, json[key].ToString());
|
| | | }
|
| | | if (!redpackSfxDict.ContainsKey(5))
|
| | | {
|
| | | redpackSfxDict.Add(5, "OSRedpackSfx");
|
| | | }
|
| | | }
|
| | |
|
| | | public struct RedEnvelope
|