//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Friday, November 24, 2017 //-------------------------------------------------------- using UnityEngine; using System.Collections; using UnityEngine.UI; using System.Collections.Generic; using System; using vnxbqy.UI; //用于记录主界面的一些信息 public class PlayerMainDate : Model, IBeforePlayerDataInitialize, IPlayerLoginOk { CapacityDelayModel m_CapacityDelayModel; CapacityDelayModel capacityDelayModel { get { return m_CapacityDelayModel ?? (m_CapacityDelayModel = ModelCenter.Instance.GetModel()); } } PlayerDeadModel _deadModel; PlayerDeadModel DeadModel { get { return _deadModel ?? (_deadModel = ModelCenter.Instance.GetModel()); } } PackModel m_PlayerPackModel; PackModel playerPack { get { return m_PlayerPackModel ?? (m_PlayerPackModel = ModelCenter.Instance.GetModel()); } } BuffModel m_BuffModel; BuffModel Buffmodel { get { return m_BuffModel ?? (m_BuffModel = ModelCenter.Instance.GetModel()); } } DungeonAssistModel assistModel { get { return ModelCenter.Instance.GetModel(); } } public event Action AddPowerEvent; //用于记录XP技能的信息 public delegate void OnXpSkill(); public static event OnXpSkill Event_XpSkill; public int SkillID = 0; //-------------------------------------------------------------- public Dictionary GetCurrencyItemID = new Dictionary(); //关于自动寻路 public bool MoveBool = false; //-------用于每分钟经验的获取 public delegate void OnExperience(int _source, int _ExpPoint, int _Exp);//(1.单位经验亿点,2.经验单位点) public static event OnExperience Event_Experience; //--------------------用于战斗力滚动 private ulong prowNum = 0; public ulong ProwNumAdd = 0; private bool prowBool = true; //----------用于显示电量; public float ElectricQuantity = 1; public static Action ElectricQuantityEvent; //---------用于网络信号; public int NetworkState = 1; public int WifiSignal = 3;//wifi信号强度 public static Action NetworkStateEvent; //--------娲皇遗迹;中的层数记录一下下 public Dictionary WHYJPowerDic = new Dictionary(); public int ruinsTranscriptMapId;//娲皇地图ID public int WaHuangHighestFloor = 0;//记录娲皇层数扣除参数 public int _layerNumber = 1;//服务端的层数 public int LayerNumber { get { if (_layerNumber < 0) { _layerNumber = 0; } return _layerNumber; } set { _layerNumber = value; } } public int LayerNumberNow = 0;//现在的选择层数 public bool IsSend = false;//像服务端法宝请求回包保护 //-------------用来控住主界面的Tip的执行调用 public bool IsTipBool = true; //创建角色奖励领取状态 public int createAwardState = -1; //----------记录任务面板玩家是否执行点击,进行自动任务 public bool IsSelfMotionTask = false; //-------------记录仙盟任务放弃任务否不再提示 public bool IsBoolFairyAuTaskAbandon = false; //------------记录仙盟任务花费仙玉是否不再提示 public bool IsBoolFairyAuTask = false; //------------记录赏金任务花费仙玉是否不再提示 public bool IsBoolCoinTask = false; //-----记录当前神秘任务的ID public int MysteriousTaskID = 0; // 用来记录区域状态 (PK模式) public int AreaState = 0;//默认和平状态 //-------用于记录在Boss区域任务条的显隐状态 public bool IsBossAreaTask = false; // --用于任务仙玉不足购买飞鞋 public bool IsFlyShoseBool = false; public int FlyShoseTaskID = 0; //--------获取玩家死亡状态 public bool IsDead = false; //----------关于某些副本可以进行地图挂机 public List OneKeyList = new List(); //----------使用娲皇卷轴后的Buff表现 public static event Action EmperorBuffEvent; public bool IsEmperor = false; //---------关于任务需要的数据 public List TaskId_Skill = new List();//任务ID public List SkillIndex = new List();//技能槽索引 public List NeedFairyJade = new List();//所需解锁仙玉 public int Skill_Index = 0; public int TaskSkillID = 0; //-----关于支线翅膀任务的特殊逻辑 public int WingTask = 0; //------ 关于切线PK状态的特殊逻辑 public List ActivityList = new List(); public List ShieldedArea = new List();//需要屏蔽的地图区域 //---------记录主界面Top面板是否在可见位置 public bool MainTopPanelShow = true; //任务面板受伤血界面影响 public static Action DemonJarDamageRankWinChange; public event Func customDisplayPower; public override void Init() { IsTipBool = true; ElectricQuantity = ynmbxxjUtil.Instance.BatteryLevel * 0.01f; if (GetCurrencyItemID.Count <= 0) { string str = FuncConfigConfig.Get("MoneyDisplayModel").Numerical1; GetCurrencyItemID = ConfigParse.GetDic(str); } OneKeyList.Clear(); var funconfig = FuncConfigConfig.Get("OneKeyBtnMap"); int[] Listmap = ConfigParse.GetMultipleStr(funconfig.Numerical1); for (int i = 0; i < Listmap.Length; i++) { OneKeyList.Add(Listmap[i]); } NetworkState = (int)ynmbxxjUtil.Instance.NetworkType; GetPassiveSkillTask(); var WingsTask = FuncConfigConfig.Get("WingsTask"); WingTask = int.Parse(WingsTask.Numerical1); var ActivityListcon = FuncConfigConfig.Get("FairyGrabMapLine"); int[] Activity_List = ConfigParse.GetMultipleStr(ActivityListcon.Numerical1); for (int i = 0; i < Activity_List.Length; i++) { ActivityList.Add(Activity_List[i]); } //ShieldedArea.Add(10010); //ShieldedArea.Add(10020); //ShieldedArea.Add(10030); //ShieldedArea.Add(10040); string WaHuangHighestFloorStr= FuncConfigConfig.Get("WaHuangHighestFloor").Numerical1; WaHuangHighestFloor = int.Parse(WaHuangHighestFloorStr); ruinsTranscriptMapId = int.Parse(FuncConfigConfig.Get("SpRewardMapID").Numerical1);//娲皇地图ID WHYJPowerDic.Clear(); for (int i = 0; i < 8; i++) { DungeonHelpBattleConfig Config = assistModel.GetHelpBattleConfig(51010,i); if (Config != null) { int type = i + 1; if (type == 1) { WHYJPowerDic.Add(type, 0); } else { WHYJPowerDic.Add(type, Config.RobotFightPower); } } } // WHYJPowerDic = ConfigParse.GetDic(FuncConfigConfig.Get("WHFloorChoose").Numerical1);//娲皇战力 } private void GetPassiveSkillTask()//获取任务数据 { TaskId_Skill.Clear(); SkillIndex.Clear(); NeedFairyJade.Clear(); var PassiveSkillTaskconfig = FuncConfigConfig.Get("PassiveSkillTask"); int[] TaskId_SkillInt = ConfigParse.GetMultipleStr(PassiveSkillTaskconfig.Numerical1); for (int i = 0; i < TaskId_SkillInt.Length; i++) { TaskId_Skill.Add(TaskId_SkillInt[i]); } int[] TaskId_SkillInt1 = ConfigParse.GetMultipleStr(PassiveSkillTaskconfig.Numerical2); for (int i = 0; i < TaskId_SkillInt1.Length; i++) { SkillIndex.Add(TaskId_SkillInt1[i]); } int[] TaskId_SkillInt2 = ConfigParse.GetMultipleStr(PassiveSkillTaskconfig.Numerical3); for (int i = 0; i < TaskId_SkillInt2.Length; i++) { NeedFairyJade.Add(TaskId_SkillInt2[i]); } } private void UseItemSuccessAct(int Index, int ItemID) { if (ItemID == 221) { if (!WindowCenter.Instance.IsOpen()) { WindowCenter.Instance.CloseAll(WindowCenter.CloseAllIgnoreType.SystemAndCustom); WindowCenter.Instance.Open(); } if (PlayerDatas.Instance.hero != null) { SFXController _sfx = SFXPlayUtility.Instance.PlayBattleEffect(5174, PlayerDatas.Instance.hero); _sfx.m_OnFinished += OnSFXDisable; } } } private void OnSFXDisable(SFXController _controller) { _controller.m_OnFinished -= OnSFXDisable; if (EmperorBuffEvent != null) { IsEmperor = true; EmperorBuffEvent(); } } public override void UnInit() { } public void OnPlayerLoginOk() { MapTransferUtility.s_OnHeroStartMoveToNPC -= OnStartPathFind; PlayerDatas.Instance.hero.OnPathFindStop -= OnFinishedPathFind; ynmbxxjUtil.Instance.OnBatteryLevelChanged -= OnBatteryChanged;//电量 ynmbxxjUtil.Instance.OnNetworkStatusChanged -= OnNetStatusChanged;//无网络 DeadModel.playerDieEvent -= playerDieEvent; playerPack.useItemSuccessEvent -= UseItemSuccessAct; PlayerDatas.Instance.playerDataRefreshEvent -= Updatefighting; MapTransferUtility.s_OnHeroStartMoveToNPC += OnStartPathFind; PlayerDatas.Instance.hero.OnPathFindStop += OnFinishedPathFind; ynmbxxjUtil.Instance.OnBatteryLevelChanged += OnBatteryChanged;//电量 ynmbxxjUtil.Instance.OnNetworkStatusChanged += OnNetStatusChanged;//无网络 DeadModel.playerDieEvent += playerDieEvent;//获取玩家死亡状态 playerPack.useItemSuccessEvent += UseItemSuccessAct; PlayerDatas.Instance.playerDataRefreshEvent += Updatefighting; } private void Updatefighting(PlayerDataType _tCDBPlayerRefresh) { if (_tCDBPlayerRefresh == PlayerDataType.ExAttr5)//判断是否再跨服 { bool Isbool = CrossServerUtility.IsCrossServerBoss(); if (!Isbool) { int mapID = PlayerDatas.Instance.baseData.MapID; var config = MapConfig.Get(mapID); if (Buffmodel.PkType != config.Camp) { Buffmodel.PkType = config.Camp; DTCA202_tagMCAttackMode.Send_SwitchAttackMode((E_AttackMode)config.Camp); } } } } private void playerDieEvent() { IsDead = true; } public void OnBeforePlayerDataInitialize() { FlyShoseTaskID = 0; IsFlyShoseBool = false; IsTipBool = true; prowNum = 0; ProwNumAdd = 0; prowBool = true; SkillID = 0; MoveBool = false; IsSelfMotionTask = false; IsBoolFairyAuTask = false; IsBoolFairyAuTaskAbandon = false; IsBoolCoinTask = false; IsBossAreaTask = false; IsDead = false; IsEmperor = false; if (PlayerDatas.Instance.hero != null) { MapTransferUtility.s_OnHeroStartMoveToNPC -= OnStartPathFind; PlayerDatas.Instance.hero.OnPathFindStop -= OnFinishedPathFind; } } private void OnNetStatusChanged(NetworkReachability arg0) { NetworkState = (int)arg0; if (NetworkStateEvent != null) { NetworkStateEvent(); } } private void onWifiSignalChanged(int arg0) { WifiSignal = arg0; NetworkState = arg0; if (NetworkStateEvent != null) { NetworkStateEvent(); } } private void onPhoneSignalChanged(int arg0) { NetworkState = arg0; if (NetworkStateEvent != null) { NetworkStateEvent(); } } private void OnBatteryChanged(int arg0) { ElectricQuantity = ynmbxxjUtil.Instance.BatteryLevel * 0.01f; if (ElectricQuantityEvent != null) { ElectricQuantityEvent(); } } private void OnStartPathFind() { MoveBool = true; } private void OnFinishedPathFind() { MoveBool = false; } public void XpSkill(int _SkillID, int _RemainTime) { SkillID = _SkillID; if (Event_XpSkill != null) Event_XpSkill(); } public void PowerAdd(ulong power) { if (prowBool) { prowNum = power; prowBool = false; } else { if (power > prowNum) { ProwNumAdd = power - prowNum; prowNum = power; if (customDisplayPower != null && customDisplayPower()) { return; } if (WindowCenter.Instance.IsOpen()) { AddPowerEvent?.Invoke(); return; } WindowCenter.Instance.Open(); } else { prowNum = power; } } } public void CustomPowerUp(ulong power) { ProwNumAdd = power; if (WindowCenter.Instance.IsOpen()) { AddPowerEvent?.Invoke(); return; } WindowCenter.Instance.Open(); } public void KissMonsterExperience(int _source, int _ExpPoint, int _Exp)//(1.单位经验亿点,2.经验单位点) { if (Event_Experience != null) { Event_Experience(_source, _ExpPoint, _Exp); } } public bool IsRedPointShowPanel()//当主界面有带有“领”字的红点上层面板默认展开 { bool IsBool = false; var State1 = RedpointCenter.Instance.GetRedpointState(201);//福利 var State2 = RedpointCenter.Instance.GetRedpointState(210); if (State1 == RedPointState.Simple || State1 == RedPointState.GetReward || State2 == RedPointState.Simple) { IsBool = true; } return IsBool; } }