//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Thursday, February 08, 2018 //-------------------------------------------------------- using UnityEngine; using System.Collections; using UnityEngine.UI; using System; using System.Collections.Generic; namespace vnxbqy.UI { public class InGamePushContainer : MonoBehaviour { [SerializeField] BetterItemGetBehaviour m_BetterEquipPusher; [SerializeField] RealmBetterEquipBehaviour m_RealmBetterEquipPusher; [SerializeField] PreciousItemGetBehaviour m_PreciousItemPusher; [SerializeField] FindPreciousBossRebornBehaviour m_BossRebornPusher; [SerializeField] ItemUseBehaviour m_itemUsePusher; [SerializeField] ItemOverdueBehaviour m_itemOverduePusher; [SerializeField] ResourceBackBehaviour m_ResourceBackBehaviour; [SerializeField] EquipDecomposeBehaviour m_DecomposePusher; //[SerializeField] OffLineTimeLackBehaviour m_OffLineTimeLackBehaviour; [SerializeField] DungeonGuardCheckBehaviour m_DungeonGuardBehaviour; [SerializeField] FirstChargeTrialBehaviour m_FirstChargeTrialBehaviour; [SerializeField] DogzNotifyBehaviour m_DogzNotifyBehaviour; [SerializeField] InSevenDayBehavior m_InSevenDayBehavior; [SerializeField] FBHelpPointExchageNotify m_HelpPointExchangeNotify; [SerializeField] MyFocusAuctionBehaviour m_MyFocusBehavio; [SerializeField] AuctionNewGetBehaviour m_AuctionNewGetBehaviour; [SerializeField] AlchemyNotifyBehaviour m_AlchemyNotifyBehaviour; [SerializeField] FuncNotifyBehaviour m_FuncNotifyBehaviour; List m_InGamePushs = new List(); Dictionary m_InGamePushTrans = new Dictionary(); WorldBossModel worldBossModel { get { return ModelCenter.Instance.GetModel(); } } BossHomeModel bossHomeModel { get { return ModelCenter.Instance.GetModel(); } } CrossServerBossModel crossServerBossModel { get { return ModelCenter.Instance.GetModel(); } } VipModel vipModel { get { return ModelCenter.Instance.GetModel(); } } DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel(); } } FBHelpPointExchageModel exchageModel { get { return ModelCenter.Instance.GetModel(); } } FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel(); } } BetterEquipGetModel betterEquipGetModel { get { return ModelCenter.Instance.GetModel(); } } RealmBetterEquipModel realmEquipModel { get { return ModelCenter.Instance.GetModel(); } } PreciousItemGetModel preciousItemGetModel { get { return ModelCenter.Instance.GetModel(); } } ItemUseModel itemUseModel { get { return ModelCenter.Instance.GetModel(); } } ItemOverdueModel itemOverdue { get { return ModelCenter.Instance.GetModel(); } } ResourcesBackModel resourcesBack { get { return ModelCenter.Instance.GetModel(); } } PackModel playerPack { get { return ModelCenter.Instance.GetModel(); } } GuardModel guardModel { get { return ModelCenter.Instance.GetModel(); } } FirstTimeRechargeModel firstTimeRechargeModel { get { return ModelCenter.Instance.GetModel(); } } DogzModel dogzModel { get { return ModelCenter.Instance.GetModel(); } } InSevenDayModel inSevenDayModel { get { return ModelCenter.Instance.GetModel(); } } AuctionNewGetShowModel auctionNewGetShowModel { get { return ModelCenter.Instance.GetModel(); } } private void Awake() { SetInGamePush(m_BetterEquipPusher, m_BetterEquipPusher.transform); SetInGamePush(m_RealmBetterEquipPusher, m_RealmBetterEquipPusher.transform); SetInGamePush(m_PreciousItemPusher, m_PreciousItemPusher.transform); SetInGamePush(m_BossRebornPusher, m_BossRebornPusher.transform); SetInGamePush(m_itemUsePusher, m_itemUsePusher.transform); SetInGamePush(m_itemOverduePusher, m_itemOverduePusher.transform); SetInGamePush(m_ResourceBackBehaviour, m_ResourceBackBehaviour.transform); SetInGamePush(m_DecomposePusher, m_DecomposePusher.transform); //SetInGamePush(m_OffLineTimeLackBehaviour, m_OffLineTimeLackBehaviour.transform); SetInGamePush(m_DungeonGuardBehaviour, m_DungeonGuardBehaviour.transform); SetInGamePush(m_FirstChargeTrialBehaviour, m_FirstChargeTrialBehaviour.transform); SetInGamePush(m_DogzNotifyBehaviour, m_DogzNotifyBehaviour.transform); SetInGamePush(m_InSevenDayBehavior, m_InSevenDayBehavior.transform); SetInGamePush(m_HelpPointExchangeNotify, m_HelpPointExchangeNotify.transform); SetInGamePush(m_MyFocusBehavio, m_MyFocusBehavio.transform); SetInGamePush(m_AuctionNewGetBehaviour, m_AuctionNewGetBehaviour.transform); SetInGamePush(m_AlchemyNotifyBehaviour, m_AlchemyNotifyBehaviour.transform); SetInGamePush(m_FuncNotifyBehaviour, m_FuncNotifyBehaviour.transform); SetInGamePushContainerSort(); } public void SetInGamePush(IInGamePush inGamePush, Transform trans) { m_InGamePushs.Add(inGamePush); m_InGamePushTrans.Add(inGamePush, trans); } public void Init() { CheckBetterEquip(); CheckRealmBetterEquip(); CheckPreciousItem(); CheckBossReborn(); CheckItemUse(); CheckItemOverdue(); ResourcesBackShow(); CheckEquipDecompose(); //CheckOffLineLack(); CheckDungeonGuard(); FirstChargeTrialShow(); CheckDogzNotify(); InSevenDayShow(); CheckHelpPointExchange(); CheckNewAuction(); m_MyFocusBehavio.Init(); m_AlchemyNotifyBehaviour.Initialize(); m_FuncNotifyBehaviour.Display(); exchageModel.UpdateHelpPointShopEvent += CheckHelpPointExchange; playerPack.RefreshDecomAttrAct += CheckEquipDecompose; betterEquipGetModel.showEquipRefreshEvent += CheckBetterEquip; realmEquipModel.showEquipRefreshEvent += CheckRealmBetterEquip; preciousItemGetModel.showItemRefreshEvent += CheckPreciousItem; findPreciousModel.bossRebornNotifyChangeEvent += CheckBossReborn; itemUseModel.showItemRefreshEvent += CheckItemUse; itemOverdue.showItemRefreshEvent += CheckItemOverdue; NewBieCenter.Instance.guideBeginEvent += OnNewBieGuideBegin; guardModel.onDungeonEquipGuardEvent += CheckDungeonGuard; firstTimeRechargeModel.IsTipShowEvent += FirstChargeTrialShow; dogzModel.UpdateDogzPutRedEvent += CheckDogzNotify; auctionNewGetShowModel.newAcutionRefreshEvent += CheckNewAuction; } public void UnInit() { m_MyFocusBehavio.Unit(); m_AlchemyNotifyBehaviour.UnInitialize(); exchageModel.UpdateHelpPointShopEvent -= CheckHelpPointExchange; playerPack.RefreshDecomAttrAct -= CheckEquipDecompose; betterEquipGetModel.showEquipRefreshEvent -= CheckBetterEquip; preciousItemGetModel.showItemRefreshEvent -= CheckPreciousItem; findPreciousModel.bossRebornNotifyChangeEvent -= CheckBossReborn; itemUseModel.showItemRefreshEvent -= CheckItemUse; NewBieCenter.Instance.guideBeginEvent -= OnNewBieGuideBegin; guardModel.onDungeonEquipGuardEvent -= CheckDungeonGuard; firstTimeRechargeModel.IsTipShowEvent -= FirstChargeTrialShow; realmEquipModel.showEquipRefreshEvent -= CheckRealmBetterEquip; dogzModel.UpdateDogzPutRedEvent -= CheckDogzNotify; auctionNewGetShowModel.newAcutionRefreshEvent -= CheckNewAuction; } private void CheckHelpPointExchange() { int pushId = exchageModel.currentShopId; StoreConfig storeConfig = StoreConfig.Get(pushId); if (pushId != 0 && storeConfig != null) { m_HelpPointExchangeNotify.SetActive(true); m_HelpPointExchangeNotify.SetDisplay(); } else { m_HelpPointExchangeNotify.SetActive(false); } } private void CheckRealmBetterEquip() { if (string.IsNullOrEmpty(realmEquipModel.currentEquipGuid)) { m_RealmBetterEquipPusher.SetActive(false); } else { if (betterEquipGetModel.ShowBetterEquipAble()) { m_RealmBetterEquipPusher.SetActive(true); m_RealmBetterEquipPusher.ShowBetterEquip(); } else { m_RealmBetterEquipPusher.SetActive(false); } } } private void CheckBetterEquip() { if (string.IsNullOrEmpty(betterEquipGetModel.currentEquipGuid)) { m_BetterEquipPusher.SetActive(false); } else { if (betterEquipGetModel.ShowBetterEquipAble()) { ModelCenter.Instance.GetModel().taskWait.Push(TaskModel.TaskWaitType.BetterEquip); m_BetterEquipPusher.SetActive(true); m_BetterEquipPusher.ShowBetterEquip(); } else { m_BetterEquipPusher.SetActive(false); } } } private void CheckDogzNotify() { m_DogzNotifyBehaviour.SetDisplay(); } private void CheckNewAuction() { m_AuctionNewGetBehaviour.Display(auctionNewGetShowModel.showingAuction); } private void CheckPreciousItem() { if (preciousItemGetModel.currentShowItem == default(PreciousItemGetModel.PreciousItem)) { m_PreciousItemPusher.SetActive(false); } else { if (preciousItemGetModel.ShowPreciousItemAble()) { m_PreciousItemPusher.SetActive(true); m_PreciousItemPusher.ShowItem(); } else { m_PreciousItemPusher.SetActive(false); } } } private void CheckItemUse() { if (itemUseModel.currentShowItem == default(ItemUseModel.UseItem)) { m_itemUsePusher.SetActive(false); } else { if (itemUseModel.ShowUseItemAble()) { m_itemUsePusher.SetActive(true); m_itemUsePusher.ShowItem(); } else { m_itemUsePusher.SetActive(false); } } } private void CheckItemOverdue() { if (itemOverdue.currentShowItem == default(ItemOverdueModel.OverdueItem)) { m_itemOverduePusher.SetActive(false); } else { if (itemOverdue.ShowUseItemAble()) { m_itemOverduePusher.SetActive(true); m_itemOverduePusher.ShowItem(); } else { m_itemOverduePusher.SetActive(false); } } } private void CheckEquipDecompose() { if (playerPack.addDecomposeExp > 0 && playerPack.isAutoDecompose) { m_DecomposePusher.SetActive(true); } else { m_DecomposePusher.SetActive(false); } } private void CheckBossReborn() { var notifies = findPreciousModel.bossNotifies; for (var i = notifies.Count - 1; i >= 0; i--) { if (BossJiaLineUtility.Instance.IsBossVisible(findPreciousModel.currentBossNotify.bossId)) { findPreciousModel.ReportConfirmBossRebornNotify(findPreciousModel.currentBossNotify); continue; } var findPreciousType = findPreciousModel.GetBossFindPreciousType(findPreciousModel.currentBossNotify.bossId); var killable = false; var show = true; var mapId = PlayerDatas.Instance.baseData.MapID; switch (findPreciousType) { case FindPreciousType.WorldBoss: killable = worldBossModel.wearyValue < worldBossModel.WorldBossMaxCount + worldBossModel.extraBossWearyValue; show = !GeneralDefine.worldBossNoRebornRemindMaps.Contains(mapId); break; case FindPreciousType.BossHome: killable = bossHomeModel.remindTimes > 0; show = !GeneralDefine.bossHomeNoRebornRemindMaps.Contains(mapId); break; case FindPreciousType.ElderGodArea: var elderGodEnterTimes = dungeonModel.GetEnterTimes(ElderGodAreaModel.ELDERGODAREA_MAPID); var elderGodTotalTimes = dungeonModel.GetTotalTimes(ElderGodAreaModel.ELDERGODAREA_MAPID); killable = elderGodTotalTimes > elderGodEnterTimes; show = !GeneralDefine.elderGodNoRebornRemindMaps.Contains(mapId); break; case FindPreciousType.DemonJar: { var totalTimes = dungeonModel.GetTotalTimes(DemonJarModel.DATA_MAPID); var enterTimes = dungeonModel.GetEnterTimes(DemonJarModel.DATA_MAPID); killable = totalTimes > enterTimes; show = !GeneralDefine.demonJarNoRebornRemindMaps.Contains(mapId); } break; case FindPreciousType.CrossServerBoss: if (CrossServerBossConfig.Get(findPreciousModel.currentBossNotify.bossId).MonsterType == 5) { killable = CrossServerMHBossModel.Instance.GetBossKilledCnt() < GeneralDefine.bossWearyValues[2]; } else { killable = crossServerBossModel.wearyValue < GeneralDefine.bossWearyValues[2]; } show = !GeneralDefine.dogzNoRebornRemindMaps.Contains(mapId); break; case FindPreciousType.JadeDynastyBoss: { var totalTimes = dungeonModel.GetTotalTimes(JadeDynastyBossModel.JADEDYNASTY_MAP); var enterTimes = dungeonModel.GetEnterTimes(JadeDynastyBossModel.JADEDYNASTY_MAP); killable = totalTimes > enterTimes; show = !GeneralDefine.demonJarNoRebornRemindMaps.Contains(mapId); } break; } if (!killable) { findPreciousModel.ReportConfirmBossRebornNotify(findPreciousModel.currentBossNotify); continue; } if (!show) { findPreciousModel.ReportConfirmBossRebornNotify(findPreciousModel.currentBossNotify); continue; } if (findPreciousModel.currentBossNotify != default(FindPreciousModel.BossNotify)) { break; } } if (findPreciousModel.currentBossNotify == default(FindPreciousModel.BossNotify)) { m_BossRebornPusher.SetActive(false); } else { m_BossRebornPusher.SetActive(true); m_BossRebornPusher.DisplayRebornBoss(); } } private void CheckDungeonGuard() { if (guardModel.fairyLandGuard && guardModel.fairyLandItemModel != null) { m_DungeonGuardBehaviour.SetActive(true); m_DungeonGuardBehaviour.Display(guardModel.fairyLandItemModel); } else { m_DungeonGuardBehaviour.SetActive(false); } } private void OnNewBieGuideBegin() { var guideConfig = GuideConfig.Get(NewBieCenter.Instance.currentGuide); switch ((GuideTriggerType)guideConfig.TriggerType) { case GuideTriggerType.EquipQuality: m_BetterEquipPusher.transform.SetAsLastSibling(); SetInGamePushContainerSort(); break; case GuideTriggerType.Item: m_PreciousItemPusher.transform.SetAsLastSibling(); SetInGamePushContainerSort(); break; default: break; } } private void ResourcesBackShow() { if (resourcesBack.IsMainGo) { m_ResourceBackBehaviour.SetActive(true); } else { m_ResourceBackBehaviour.SetActive(false); } } private void FirstChargeTrialShow() { if (firstTimeRechargeModel.IsTipShow) { m_FirstChargeTrialBehaviour.SetActive(true); } else { m_FirstChargeTrialBehaviour.SetActive(false); } } private void InSevenDayShow() { if (inSevenDayModel.IsMainGo) { m_InSevenDayBehavior.SetActive(true); m_InSevenDayBehavior.GetintDay(); } else { m_InSevenDayBehavior.SetActive(false); } } public void SetInGamePushContainerSort() { m_InGamePushs.Sort((x, y) => { return -x.GetSiblingIndex().CompareTo(y.GetSiblingIndex()); }); SetInGamePushContainerScale(); } void SetInGamePushContainerScale() { var alreadyExist = false; for (int i = 0; i < m_InGamePushs.Count; i++) { var inGamePush = m_InGamePushs[i]; var trans = m_InGamePushTrans[inGamePush]; if (inGamePush.IsActive()) { if (!alreadyExist) { if (!trans.localScale.Equals(Vector3.one)) { trans.localScale = Vector3.one; } } else { if (!trans.localScale.Equals(Vector3.zero)) { trans.localScale = Vector3.zero; } } alreadyExist = true; } } } private void LateUpdate() { SetInGamePushContainerScale(); } } public interface IInGamePush { int GetSiblingIndex(); bool IsActive(); } public class ILIInGamePush : IInGamePush { public int GetSiblingIndex() { return funcGetSiblingIndex(); } public bool IsActive() { return funcIsActive(); } private Func funcGetSiblingIndex; private Func funcIsActive; public ILIInGamePush(Func getSiblingIndex, Func isActive) { funcGetSiblingIndex = getSiblingIndex; funcIsActive = isActive; } } }