public ShopNotificationModel(List <ShopCardData> shopCardDatas, ShopNotificationData data) { _data = data; shopCardDatas.ForEach(shopCard => { shopCard.PurchaseStateChanged += (purchaseState) => { var notificationCount = 0; for (var index = 0; index < shopCardDatas.Count; index++) { ShopCardData x = shopCardDatas[index]; var all = true; for (var i = 0; i < x.price.Length; i++) { Shop.PriceData price = x.price[i]; if (price.amount != 0) { all = false; break; } } if (all && purchaseState == ECardState.Taked) { notificationCount++; } } _data.NotificationCount = notificationCount; _data.NotifyThatDataChanged(); }; }); }
public static void Create(List <ShopCardData> shopCardDatas) { var notificationData = new ShopNotificationData(); var shopNotificationModel = new ShopNotificationModel(shopCardDatas, notificationData); var shopNotificationView = Object.FindObjectOfType <ShopNotificationView>(); notificationData.Changed += (changedData) => shopNotificationView.DataChanged(new ShopNotificationViewData(changedData)); notificationData.NotifyThatDataChanged(); }