Пример #1
0
 public void UpdateCountOfClick(GameData data, GameParameter parameter) =>
 // TODO クリックして得られるクッキーの数を更新する
 CountOfClick = ItemsExtension.GetEnumerable()
                .Select(i => new { Type = i, Count = data.GetItemCount(i) })
                .Join(parameter.GetParameters(), v => v.Type, p => p.Type, (v, p) => v.Count * p.CountOfClick)
                .Append(1M)
                .Sum();
Пример #2
0
        public void UpdateIsBuy(GameData data, GameParameter parameter)
        {
            // TODO アイテムが購入できるか決定する
            var query = StoreItems
                        .Select(i => new { Item = i, IsBuy = (data.TotalCookies >= i.Price) });

            foreach (var q in query)
            {
                q.Item.IsBuy = q.IsBuy;
            }
        }
Пример #3
0
        public void UpdatePrice(GameData data, GameParameter parameter)
        {
            // TODO アイテムの価格を決定する
            var query = StoreItems
                        .Join(parameter.GetParameters(), i => i.Type, p => p.Type, (i, p) => new { Store = i, Param = p })
                        .Select(v => new { Store = v.Store, Param = v.Param, Count = data.GetItemCount(v.Store.Type) })
                        .Select(v => new { Store = v.Store, Price = v.Param.SellPriceBase * (v.Count + 1) });

            foreach (var q in query)
            {
                q.Store.Price = q.Price;
            }
        }
Пример #4
0
        public Store(GameData gameData, GameParameter gameParameter)
        {
            gameData.PropertyChanged += (obj, arg) =>
            {
                var data = obj as GameData;
                if (data != null)
                {
                    UpdatePrice(data, _gameParameter);
                    UpdateIsBuy(data, _gameParameter);
                }
            };

            _gameParameter = gameParameter;
        }
Пример #5
0
        public Cookies(GameData gameData, GameParameter gameParameter)
        {
            _gameParameter = gameParameter;

            gameData.PropertyChanged += (obj, arg) =>
            {
                var data = obj as GameData;
                if (data != null)
                {
                    UpdateCountOfClick(data, _gameParameter);
                    UpdateCountOfAutomatic(data, _gameParameter);
                }
            };
        }
Пример #6
0
 public void UpdateCountOfAutomatic(GameData data, GameParameter parameter) =>
 // 自動で取得できるクッキーの数を更新する
 CountOfAutomatic = ItemsExtension.GetEnumerable()
                    .Select(i => new { Type = i, Count = data.GetItemCount(i) })
                    .Join(parameter.GetParameters(), v => v.Type, p => p.Type, (v, p) => v.Count * p.CountOfAutomatic)
                    .Sum();