| | |
| | | [XLua.CSharpCallLua]
|
| | | public class StoreModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk, ISwitchAccount
|
| | | {
|
| | | Dictionary<int, List<int>> storeAlchemyStudyItemShopIds = new Dictionary<int, List<int>>();
|
| | |
|
| | | public int[] normalBuyCoinsTypes { get; private set; }
|
| | | public string UNIONSTORESAVE_KEY { get; private set; }
|
| | | public string MUSTBUYSAVE_KEY { get; private set; }
|
| | |
| | |
|
| | | RuneModel runeModel { get { return ModelCenter.Instance.GetModel<RuneModel>(); } }
|
| | | PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
| | | |
| | | AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } }
|
| | |
|
| | | private bool isUpdatePlayerLv;
|
| | |
|
| | |
| | | storeTrailerLv = int.Parse(mallPush.Numerical1);
|
| | |
|
| | | MainPositionTween.switchFunctionStateEvent += OnMoveTopPart;
|
| | | alchemyModel.alchemyStateRefresh += AlchemyStateRefresh;
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | |
| | | UpdateCanBuyRedpoint();
|
| | | UpdateMustBuyRedpoint();
|
| | | UpdatePetAndMountPutAwayRedpoint();
|
| | | UpdateAlchemyStudyItemRedpoint();
|
| | | isLogin = false;
|
| | | }
|
| | |
|
| | |
| | | public override void UnInit()
|
| | | {
|
| | | MainPositionTween.switchFunctionStateEvent -= OnMoveTopPart;
|
| | | alchemyModel.alchemyStateRefresh -= AlchemyStateRefresh;
|
| | | }
|
| | |
|
| | | private void AlchemyStateRefresh()
|
| | | {
|
| | | UpdateAlchemyStudyItemRedpoint();
|
| | | }
|
| | |
|
| | | public void RefreshMysteryShop()
|
| | |
| | | }
|
| | | }
|
| | | storePushDict.Add(pushType, shopIdlist);
|
| | | }
|
| | | }
|
| | |
|
| | | if (!string.IsNullOrEmpty(storeRedRules.Numerical3))
|
| | | {
|
| | | var json = JsonMapper.ToObject(storeRedRules.Numerical3);
|
| | | foreach (var typeKey in json.Keys)
|
| | | {
|
| | | var type = int.Parse(typeKey);
|
| | | storeAlchemyStudyItemShopIds.Add(type,
|
| | | new List<int>(JsonMapper.ToObject<int[]>(json[typeKey].ToJson())));
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | UpdateCanBuyRedpoint();
|
| | | UpdateMustBuyRedpoint();
|
| | | UpdatePetAndMountPutAwayRedpoint();
|
| | | UpdateAlchemyStudyItemRedpoint();
|
| | | }
|
| | |
|
| | | private void RefreshPlayerData(PlayerDataType type)
|
| | |
| | | case PlayerDataType.GoldPaper:
|
| | | UpdateFreeShopRedpoint();
|
| | | UpdateCanBuyRedpoint();
|
| | | UpdateAlchemyStudyItemRedpoint();
|
| | | break;
|
| | | case PlayerDataType.UnionLiven:
|
| | | UpdateAlchemyStudyItemRedpoint(8);
|
| | | break;
|
| | | case PlayerDataType.FBHelpPoint:
|
| | | UpdateFreeShopRedpoint();
|
| | | UpdateCanBuyRedpoint();
|
| | | UpdateAlchemyStudyItemRedpoint();
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | ControllerRedPoint();
|
| | | }
|
| | |
|
| | | UpdateAlchemyStudyItemRedpoint(8);
|
| | | }
|
| | |
|
| | | private void RefreshServerHour()
|
| | |
| | | {
|
| | | PlayerPrefs.DeleteKey(UNIONSTORESAVE_KEY);
|
| | | }
|
| | |
|
| | | UpdateAlchemyStudyItemRedpoint(8);
|
| | | }
|
| | |
|
| | | public event Action RefreshBuyShopLimitEvent;
|
| | |
| | | UpdateCanBuyRedpoint();
|
| | | UpdateMustBuyRedpoint();
|
| | | UpdatePetAndMountPutAwayRedpoint();
|
| | | UpdateAlchemyStudyItemRedpoint();
|
| | | }
|
| | | if (RefreshBuyShopLimitEvent != null)
|
| | | RefreshBuyShopLimitEvent();
|
| | |
| | | UpdateCanBuyRedpoint();
|
| | | UpdateMustBuyRedpoint();
|
| | | UpdatePetAndMountPutAwayRedpoint();
|
| | | UpdateAlchemyStudyItemRedpoint();
|
| | | break;
|
| | | case FuncOpenEnum.BlastFurnace:
|
| | | ControllerRedPoint();
|
| | | UpdateAlchemyStudyItemRedpoint();
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public void ControllerRedPoint(bool isLook = false)
|
| | | {
|
| | | MainRedDot.Instance.fairyStoreRedPoint.state = RedPointState.None;
|
| | | fairyStoreRemindRedpoint.state = RedPointState.None;
|
| | | if (!ModelCenter.Instance.GetModel<FairyModel>().fairyStoreOpen
|
| | | || !FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BlastFurnace))
|
| | | {
|
| | |
| | | {
|
| | | if (CheckIsBuyNewItem(familyLv))
|
| | | {
|
| | | MainRedDot.Instance.fairyStoreRedPoint.state = RedPointState.Simple;
|
| | | fairyStoreRemindRedpoint.state = RedPointState.Simple;
|
| | | return;
|
| | | }
|
| | |
|
| | | if (CheckIsNewMonth())
|
| | | {
|
| | | MainRedDot.Instance.fairyStoreRedPoint.state = RedPointState.Simple;
|
| | | fairyStoreRemindRedpoint.state = RedPointState.Simple;
|
| | | return;
|
| | | }
|
| | | }
|
| | |
| | | public const int StoreFunc3_RedKey = 2203;
|
| | | public const int StoreFunc4_RedKey = 2204;
|
| | | public const int StoreFunc5_RedKey = 2205;
|
| | | public const int StoreFunc8_RedKey = 2208;
|
| | | public const int FairyStoreRemind_RedKey = 107010601;
|
| | | public Redpoint storeFuncPoint = new Redpoint(StoreFunc_RedKey);
|
| | | public Redpoint storeFunc1Point = new Redpoint(StoreFunc_RedKey, StoreFunc1_RedKey);
|
| | | public Redpoint storeFunc2Point = new Redpoint(StoreFunc_RedKey, StoreFunc2_RedKey);
|
| | | public Redpoint storeFunc3Point = new Redpoint(StoreFunc_RedKey, StoreFunc3_RedKey);
|
| | | public Redpoint storeFunc4Point = new Redpoint(StoreFunc_RedKey, StoreFunc4_RedKey);
|
| | | public Redpoint storeFunc5Point = new Redpoint(StoreFunc_RedKey, StoreFunc5_RedKey);
|
| | | public Redpoint storeFunc8Point = new Redpoint(MainRedDot.FAIRYStore_REDPOINT_KEY3, StoreFunc8_RedKey);
|
| | | public Redpoint fairyStoreRemindRedpoint = new Redpoint(MainRedDot.FAIRYStore_REDPOINT_KEY3, FairyStoreRemind_RedKey);
|
| | | public Dictionary<int, Redpoint> shopRedDict = new Dictionary<int, Redpoint>();
|
| | | public void SetShopRedpoint()
|
| | | {
|
| | |
| | | case 5:
|
| | | redKey = StoreFunc5_RedKey * 10000 + storeConfig.ID;
|
| | | redpoint = new Redpoint(StoreFunc5_RedKey, redKey);
|
| | | shopRedDict.Add(storeConfig.ID, redpoint);
|
| | | break;
|
| | | case 8:
|
| | | redKey = StoreFunc8_RedKey * 10000 + storeConfig.ID;
|
| | | redpoint = new Redpoint(StoreFunc8_RedKey, redKey);
|
| | | shopRedDict.Add(storeConfig.ID, redpoint);
|
| | | break;
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public void UpdateAlchemyStudyItemRedpoint()
|
| | | {
|
| | | foreach (var shopType in storeAlchemyStudyItemShopIds.Keys)
|
| | | {
|
| | | UpdateAlchemyStudyItemRedpoint(shopType); |
| | | }
|
| | | }
|
| | |
|
| | | public void UpdateAlchemyStudyItemRedpoint(int shopType)
|
| | | {
|
| | | if (!storeAlchemyStudyItemShopIds.ContainsKey(shopType))
|
| | | {
|
| | | return;
|
| | | }
|
| | | var shopIds = storeAlchemyStudyItemShopIds[shopType];
|
| | | if (showStoreTypeDict.ContainsKey(shopType))
|
| | | {
|
| | | var shopDatas = showStoreTypeDict[shopType];
|
| | | foreach (var shopId in shopIds)
|
| | | {
|
| | | bool redable = false;
|
| | |
|
| | | if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store))
|
| | | {
|
| | | var shopData = shopDatas.Find((x) =>
|
| | | {
|
| | | return x.shopId == shopId;
|
| | | });
|
| | | if (shopData != null)
|
| | | {
|
| | | var storeConfig = shopData.storeConfig;
|
| | | var count = 0;
|
| | | switch (shopType)
|
| | | {
|
| | | case 5:
|
| | | if (!TryGetIsSellOut(storeConfig, out count))
|
| | | {
|
| | | if (UIHelper.GetMoneyCnt(storeConfig.MoneyType) >= (ulong)storeConfig.MoneyNumber)
|
| | | {
|
| | | redable = IsSatisfyStudyAlchemy(storeConfig.ItemID);
|
| | | }
|
| | | }
|
| | | break;
|
| | | case 8:
|
| | | if (TryGetIsSellOut(storeConfig, out count))
|
| | | {
|
| | | break;
|
| | | }
|
| | | if (PlayerDatas.Instance.baseData.FamilyId == 0)
|
| | | {
|
| | | break;
|
| | | }
|
| | | if (storeConfig.VIPLV.Length > 0
|
| | | && PlayerDatas.Instance.baseData.VIPLv < storeConfig.VIPLV[0])
|
| | | {
|
| | | break;
|
| | | }
|
| | | if (PlayerDatas.Instance.fairyData.fairy.FamilyLV < storeConfig.LimitValue)
|
| | | {
|
| | | break;
|
| | | }
|
| | | if (!MoneyIsEnough(storeConfig.MoneyType, (ulong)storeConfig.MoneyNumber))
|
| | | {
|
| | | break;
|
| | | }
|
| | | redable = IsSatisfyStudyAlchemy(storeConfig.ItemID);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (shopRedDict.ContainsKey(shopId))
|
| | | {
|
| | | shopRedDict[shopId].state = redable ? RedPointState.Simple : RedPointState.None;
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
| | |
|
| | | bool IsSatisfyStudyAlchemy(int itemId)
|
| | | {
|
| | | var alchemyModel = ModelCenter.Instance.GetModel<AlchemyModel>();
|
| | | var alchemyId = 0;
|
| | | if (alchemyModel.TryGetAlchemyByStudyMaterial(itemId, out alchemyId))
|
| | | {
|
| | | if (!alchemyModel.IsGraspRecipe(alchemyId))
|
| | | {
|
| | | var error = 0;
|
| | | alchemyModel.TryLearn(alchemyId, out error);
|
| | | return error == 1;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public void ClearMustBuyRedpoint(StoreConfig storeConfig)
|
| | | {
|
| | | int type = 0;
|