//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, February 08, 2018
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using System;
|
using System.Collections.Generic;
|
|
namespace Snxxz.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;
|
|
List<IInGamePush> m_InGamePushs = new List<IInGamePush>();
|
Dictionary<IInGamePush, Transform> m_InGamePushTrans = new Dictionary<IInGamePush, Transform>();
|
|
WorldBossModel worldBossModel { get { return ModelCenter.Instance.GetModel<WorldBossModel>(); } }
|
BossHomeModel bossHomeModel { get { return ModelCenter.Instance.GetModel<BossHomeModel>(); } }
|
CrossServerBossModel crossServerBossModel { get { return ModelCenter.Instance.GetModel<CrossServerBossModel>(); } }
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
FBHelpPointExchageModel exchageModel { get { return ModelCenter.Instance.GetModel<FBHelpPointExchageModel>(); } }
|
FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
|
BetterEquipGetModel betterEquipGetModel { get { return ModelCenter.Instance.GetModel<BetterEquipGetModel>(); } }
|
RealmBetterEquipModel realmEquipModel { get { return ModelCenter.Instance.GetModel<RealmBetterEquipModel>(); } }
|
PreciousItemGetModel preciousItemGetModel { get { return ModelCenter.Instance.GetModel<PreciousItemGetModel>(); } }
|
ItemUseModel itemUseModel { get { return ModelCenter.Instance.GetModel<ItemUseModel>(); } }
|
ItemOverdueModel itemOverdue { get { return ModelCenter.Instance.GetModel<ItemOverdueModel>(); } }
|
ResourcesBackModel resourcesBack { get { return ModelCenter.Instance.GetModel<ResourcesBackModel>(); } }
|
PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
OffLineTimeLackModel offLineTimeLackModel { get { return ModelCenter.Instance.GetModel<OffLineTimeLackModel>(); } }
|
GuardModel guardModel { get { return ModelCenter.Instance.GetModel<GuardModel>(); } }
|
FirstTimeRechargeModel firstTimeRechargeModel { get { return ModelCenter.Instance.GetModel<FirstTimeRechargeModel>(); } }
|
DogzModel dogzModel { get { return ModelCenter.Instance.GetModel<DogzModel>(); } }
|
InSevenDayModel inSevenDayModel { get { return ModelCenter.Instance.GetModel<InSevenDayModel>(); } }
|
AuctionNewGetShowModel auctionNewGetShowModel { get { return ModelCenter.Instance.GetModel<AuctionNewGetShowModel>(); } }
|
|
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);
|
|
SetInGamePushContainerSort();
|
}
|
|
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();
|
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.gameObject.SetActive(true);
|
m_HelpPointExchangeNotify.SetDisplay();
|
}
|
else
|
{
|
m_HelpPointExchangeNotify.gameObject.SetActive(false);
|
}
|
}
|
|
private void CheckRealmBetterEquip()
|
{
|
if (string.IsNullOrEmpty(realmEquipModel.currentEquipGuid))
|
{
|
m_RealmBetterEquipPusher.gameObject.SetActive(false);
|
}
|
else
|
{
|
if (betterEquipGetModel.ShowBetterEquipAble())
|
{
|
m_RealmBetterEquipPusher.gameObject.SetActive(true);
|
m_RealmBetterEquipPusher.ShowBetterEquip();
|
}
|
else
|
{
|
m_RealmBetterEquipPusher.gameObject.SetActive(false);
|
}
|
}
|
}
|
|
private void CheckBetterEquip()
|
{
|
if (string.IsNullOrEmpty(betterEquipGetModel.currentEquipGuid))
|
{
|
m_BetterEquipPusher.gameObject.SetActive(false);
|
}
|
else
|
{
|
if (betterEquipGetModel.ShowBetterEquipAble())
|
{
|
ModelCenter.Instance.GetModel<TaskModel>().taskWait.Push(TaskModel.TaskWaitType.BetterEquip);
|
m_BetterEquipPusher.gameObject.SetActive(true);
|
m_BetterEquipPusher.ShowBetterEquip();
|
}
|
else
|
{
|
m_BetterEquipPusher.gameObject.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.gameObject.SetActive(false);
|
}
|
else
|
{
|
if (preciousItemGetModel.ShowPreciousItemAble())
|
{
|
m_PreciousItemPusher.gameObject.SetActive(true);
|
m_PreciousItemPusher.ShowItem();
|
}
|
else
|
{
|
m_PreciousItemPusher.gameObject.SetActive(false);
|
}
|
}
|
}
|
|
private void CheckItemUse()
|
{
|
if (itemUseModel.currentShowItem == default(ItemUseModel.UseItem))
|
{
|
m_itemUsePusher.gameObject.SetActive(false);
|
}
|
else
|
{
|
if (itemUseModel.ShowUseItemAble())
|
{
|
m_itemUsePusher.gameObject.SetActive(true);
|
m_itemUsePusher.ShowItem();
|
|
}
|
else
|
{
|
m_itemUsePusher.gameObject.SetActive(false);
|
}
|
}
|
}
|
|
private void CheckItemOverdue()
|
{
|
if (itemOverdue.currentShowItem == default(ItemOverdueModel.OverdueItem))
|
{
|
m_itemOverduePusher.gameObject.SetActive(false);
|
}
|
else
|
{
|
if (itemOverdue.ShowUseItemAble())
|
{
|
m_itemOverduePusher.gameObject.SetActive(true);
|
m_itemOverduePusher.ShowItem();
|
}
|
else
|
{
|
m_itemOverduePusher.gameObject.SetActive(false);
|
}
|
}
|
}
|
|
private void CheckEquipDecompose()
|
{
|
if (playerPack.addDecomposeExp > 0
|
&& playerPack.isAutoDecompose)
|
{
|
m_DecomposePusher.gameObject.SetActive(true);
|
}
|
else
|
{
|
m_DecomposePusher.gameObject.SetActive(false);
|
}
|
}
|
|
private void CheckBossReborn()
|
{
|
var notifies = findPreciousModel.bossNotifies;
|
for (var i = notifies.Count - 1; i >= 0; i--)
|
{
|
if (BossFakeLineUtility.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 < GeneralDefine.bossWearyValues[0] + worldBossModel.extraBossWearyValue;
|
show = !GeneralDefine.worldBossNoRebornRemindMaps.Contains(mapId);
|
break;
|
case FindPreciousType.BossHome:
|
killable = bossHomeModel.wearyValue < vipModel.GetVipPrivilegeCnt(VipPrivilegeType.BossHomeAwardLimit);
|
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:
|
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.gameObject.SetActive(false);
|
}
|
else
|
{
|
m_BossRebornPusher.gameObject.SetActive(true);
|
m_BossRebornPusher.DisplayRebornBoss();
|
}
|
}
|
|
private void CheckOffLineLack()
|
{
|
if (PlayerDatas.Instance.baseData.LV >= GeneralDefine.OffLineTimeLackRemendLevelLimit
|
&& !offLineTimeLackModel.hasRemindOffLineTimeLack
|
&& PlayerDatas.Instance.baseData.hangTime < 5 * 3600)
|
{
|
m_OffLineTimeLackBehaviour.gameObject.SetActive(true);
|
}
|
else
|
{
|
m_OffLineTimeLackBehaviour.gameObject.SetActive(false);
|
}
|
}
|
|
private void CheckDungeonGuard()
|
{
|
if (guardModel.fairyLandGuard && guardModel.fairyLandItemModel != null)
|
{
|
m_DungeonGuardBehaviour.gameObject.SetActive(true);
|
m_DungeonGuardBehaviour.Display(guardModel.fairyLandItemModel);
|
}
|
else
|
{
|
m_DungeonGuardBehaviour.gameObject.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.gameObject.SetActive(true);
|
}
|
else
|
{
|
m_ResourceBackBehaviour.gameObject.SetActive(false);
|
}
|
}
|
|
private void FirstChargeTrialShow()
|
{
|
if (firstTimeRechargeModel.IsTipShow)
|
{
|
m_FirstChargeTrialBehaviour.gameObject.SetActive(true);
|
}
|
else
|
{
|
m_FirstChargeTrialBehaviour.gameObject.SetActive(false);
|
}
|
|
}
|
|
private void InSevenDayShow()
|
{
|
if (inSevenDayModel.IsMainGo)
|
{
|
m_InSevenDayBehavior.gameObject.SetActive(true);
|
m_InSevenDayBehavior.GetintDay();
|
}
|
else
|
{
|
m_InSevenDayBehavior.gameObject.SetActive(false);
|
}
|
}
|
|
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();
|
}
|
}
|
|
|
|