Esempio n. 1
0
        public Entity BuildItemEntity(ItemType type, Vector2 loc, EventSoundEffects sounds)
        {
            Entity toReturn = null;

            switch (type)
            {
            case ItemType.Flower:
                toReturn = new FlowerEntity(loc, sounds);
                break;

            case ItemType.Coin:
                toReturn = new CoinEntity(loc, sounds);
                break;

            case ItemType.RedMushroom:
                toReturn = new RedMushroomEntity(loc, sounds);
                break;

            case ItemType.GreenMushroom:
                toReturn = new GreenMushroomEntity(loc, sounds);
                break;

            case ItemType.Star:
                toReturn = new StarEntity(loc, sounds);
                break;
            }
            return(toReturn);
        }
Esempio n. 2
0
 public CoinCarrier MapToCarrier(CoinEntity coinEntity)
 {
     return(new CoinCarrier()
     {
         Amount = coinEntity.Amount,
         Volume = coinEntity.Volume
     });
 }
Esempio n. 3
0
        public async Task <TData <string> > SaveForm(CoinEntity entity)
        {
            TData <string> obj = new TData <string>();
            await coinService.SaveForm(entity);

            obj.Data = entity.Id.ParseToString();
            obj.Tag  = 1;
            return(obj);
        }
Esempio n. 4
0
 public void CoinInfo(CoinEntity coin)
 {
     _logger.Info(" ");
     _logger.Info("  CoinInfo:");
     _logger.Info("    Id = " + coin.Id);
     _logger.Info("    Count = " + coin.Count);
     _logger.Info("    Value = " + coin.Value);
     _logger.Info("    IsBlocking = " + coin.IsBlocking);
     _logger.Info(" ");
 }
Esempio n. 5
0
        /*protected FakeRepository<DrinkEntity> RepositoryDrink;*/

        public virtual void Init()
        {
            Drink1 = new DrinkEntity()
            {
                CostPrice = 10,
                Count     = 2,
                Id        = Guid.Parse("FFDF9A9C-1FC1-4DEB-B552-45EB5E0EC48C"),
                ImagePath = "image1",
                Name      = "drink1"
            };

            Drink2 = new DrinkEntity()
            {
                CostPrice = 20,
                Count     = 4,
                Id        = Guid.NewGuid(),
                ImagePath = "image2",
                Name      = "drink2"
            };

            Coin1 = new CoinEntity()
            {
                Id         = Guid.NewGuid(),
                Count      = 10,
                IsBlocking = false,
                Value      = ValueCoins.One
            };

            Coin2 = new CoinEntity()
            {
                Id         = Guid.NewGuid(),
                Count      = 10,
                IsBlocking = true,
                Value      = ValueCoins.Two
            };

            CurrentState = new CurrentStateEntity()
            {
                Change  = 0,
                Deposit = 0
            };

            DrinkEntitiesList = new List <DrinkEntity> {
                Drink1, Drink2
            };
            CoinEntitiesList = new List <CoinEntity> {
                Coin1, Coin2
            };

            /*RepositoryDrink = new FakeRepository<DrinkEntity>(DrinkEntitiesList);
             * var repositoryCoin = new FakeRepository<CoinEntity>(CoinEntitiesList);*/

            VengineMachine = new VengineMachine(/*RepositoryDrink, repositoryCoin*/);
        }
        public void ChangeCoinCount(Guid id, int count)
        {
            CoinEntity coinEntity = _coinRepository.Get(id);

            _printer.CoinInfo(coinEntity);

            _vengineMachine.ChangeCoinCount(coinEntity, count);

            _logger.Info(" before _db.SaveChanges()...");
            _drinkRepository.SaveChanges();
        }
        public CoinExplosionParticle(CoinEntity c, int texX, int texY, int fullTextW, int fullTextH, double forceMult, StandardGameHUD hud)
            : base(c, texX, texY, fullTextW, fullTextH)
        {
            SetLifetime(STANDARD_LIFETIME);
            SetFadetime(STANDARD_FADETIME);

            Vec2d force = new Vec2d(texX - fullTextW / 2, texY - fullTextH / 2);

            force *= forceMult;

            AddController(new CoinExplosionController(this, force, hud, (c.owner as GameWorld).offset));
        }
Esempio n. 8
0
 public async Task SaveForm(CoinEntity entity)
 {
     if (entity.Id.IsNullOrZero())
     {
         entity.Create();
         await this.BaseRepository().Insert(entity);
     }
     else
     {
         await this.BaseRepository().Update(entity);
     }
 }
Esempio n. 9
0
        public bool AddCoin(CoinEntity coin)
        {
            if (coin.Volume + this.UsedVolume > this.TotalVolume)
            {
                return(false);
            }

            _coinJar.Add(Id++, coin);

            this.TotalValue += coin.Amount;
            this.UsedVolume += coin.Volume;

            return(true);
        }
        public void ChangeBlocking(Guid id, bool isBlocking)
        {
            CoinEntity coinEntity = _coinRepository.Get(id);

            _printer.CoinInfo(coinEntity);

            if (isBlocking)
            {
                _vengineMachine.Block(coinEntity);
            }
            else
            {
                _vengineMachine.UnBlock(coinEntity);
            }

            _logger.Info(" before _db.SaveChanges()...");
            _drinkRepository.SaveChanges();
        }
        public int AddCoin(Guid id)
        {
            CoinEntity         coinEntity   = _coinRepository.Get(id);
            CurrentStateEntity currentState = _stateRepository.GetFirst();

            _logger.Info(" before add coin");
            _printer.CoinAndStateInfo(coinEntity, currentState);

            _vengineMachine.AddCoin(coinEntity, currentState);

            _logger.Info(" after add coin");
            _printer.CoinAndStateInfo(coinEntity, currentState);

            _logger.Info(" before _db.SaveChanges()...");
            _coinRepository.SaveChanges();

            return(currentState.Deposit);
        }
        /// <summary>
        /// Выдача сдачи
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="coins"></param>
        public void GetChange(CurrentStateEntity currentState, IList <CoinEntity> coins)
        {
            /*List<CoinEntity> coins = _coinsRepo.Queryable().ToList();*/
            var change = currentState.Change;

            //Подсчет монет  для сдачи
            IList <Coin> coinsForChange = GetCoinsForChange(coins, change);

            if (coinsForChange != null)
            {
                foreach (var coin in coinsForChange)
                {
                    CoinEntity coinEntity = coins.FirstOrDefault(c => (int)c.Value == coin.Value);
                    if (coinEntity != null)
                    {
                        coinEntity.Count -= coin.Count;
                    }
                }

                currentState.Change = 0;
            }
        }
Esempio n. 13
0
        public IHttpActionResult AddCoin([FromBody] CoinCarrier coinCarrier)
        {
            if (coinCarrier == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            CoinEntity coinEntity = _coinJarMapper.MapToEntity(coinCarrier);

            var result = _coinJarManager.AddCoin(coinEntity);

            if (!result)
            {
                return(BadRequest("Volume Exceeds Max Ounces"));
            }

            return(Ok());
        }
Esempio n. 14
0
 public BouncingCoinController(CoinEntity e, Vec2d spawnForce)
     : base(e, spawnForce)
 {
     //--
 }
Esempio n. 15
0
        public bool CoinChange(long uId, CoinChangeEnum coinChangeType, string remark = "", int changeValue = 0, string operateUser = "")
        {
            var coin = letterDal.GetCoinByUId(uId);

            if (coin == null)
            {
                coin = new CoinEntity()
                {
                    UId        = uId,
                    TotalCoin  = 0,
                    CreateTime = DateTime.Now,
                    UpdateTime = DateTime.Now
                };
                bool success = letterDal.InsertCoin(coin);
                if (success)
                {
                    coin.CoinId = letterDal.GetCoinByUId(uId).CoinId;
                }
            }

            if (changeValue <= 0)
            {
                string config = "";
                switch (coinChangeType)
                {
                case CoinChangeEnum.PublishReward:
                    config = "PublishRewardValue";
                    break;

                case CoinChangeEnum.CollectedReward:
                    config = "CollectedRewardValue";
                    break;

                case CoinChangeEnum.SignReward:
                    config = "SignRewardValue";
                    break;

                case CoinChangeEnum.ShareReward:
                    config = "ShareRewardValue";
                    break;

                case CoinChangeEnum.ActivityReward:
                    config = "ActivityRewardValue";
                    break;

                case CoinChangeEnum.FirstLoginReward:
                    config = "FirstLoginRewardValue";
                    break;

                case CoinChangeEnum.PickUpDeducted:
                    config = "PickUpDeductedValue";
                    break;

                case CoinChangeEnum.ReportedDeducted:
                    config = "ReportedDeductedValue";
                    break;

                default:
                    break;
                }
                if (!string.IsNullOrWhiteSpace(config))
                {
                    string configStr = JsonSettingHelper.AppSettings[config];
                    if (!string.IsNullOrEmpty(configStr))
                    {
                        changeValue = Convert.ToInt16(configStr);
                    }
                }
            }
            if (changeValue != 0)
            {
                //金币余额为0时不再继续扣除
                if (UserTotalCoin(uId) <= 0 && changeValue < 0)
                {
                    return(true);
                }
                var coinDetail = new CoinDetailEntity()
                {
                    CoinDetailId   = Guid.NewGuid(),
                    UId            = uId,
                    CoinId         = coin.CoinId,
                    CoinChangeType = coinChangeType,
                    OperateUser    = string.IsNullOrWhiteSpace(operateUser) ? "system" : operateUser,
                    Remark         = remark,
                    ChangeValue    = changeValue,
                    CreateTime     = DateTime.Now,
                    UpdateTime     = DateTime.Now
                };
                bool insertCoinDetailSuccess = letterDal.InsertCoinDetail(coinDetail);
                if (insertCoinDetailSuccess)
                {
                    return(letterDal.UpdateUserTotalCoin(coin.CoinId, coin.UId, changeValue));
                }
            }

            LogHelper.Info("CoinChangeAsync", "用户金币变动", new Dictionary <string, string>()
            {
                { "uId", uId.ToString() },
                { "coinChangeType", coinChangeType.ToString() },
                { "changeValue", changeValue.ToString() },
                { "remark", remark.ToString() }
            });
            return(true);
        }
Esempio n. 16
0
 public void CoinAndStateInfo(CoinEntity coin, CurrentStateEntity state)
 {
     CoinInfo(coin);
     StateInfo(state);
 }
 /// <summary>
 /// Блокировка монеты
 /// </summary>
 /// <param name="coinEntity"></param>
 public void Block(CoinEntity coinEntity)
 {
     coinEntity.IsBlocking = true;
 }
 /// <summary>
 /// Разблокировка монеты
 /// </summary>
 /// <param name="coinEntity"></param>
 public void UnBlock(CoinEntity coinEntity)
 {
     coinEntity.IsBlocking = false;
 }
 /// <summary>
 /// Добавление монеты в автомат, возможно не самое лучшее название метода
 /// </summary>
 /// <param name="coinEntity"></param>
 /// <param name="currentState"></param>
 public void AddCoin(CoinEntity coinEntity, CurrentStateEntity currentState)
 {
     coinEntity.Count++;
     currentState.Deposit += (int)coinEntity.Value;
 }
 /// <summary>
 /// Изменение кол-ва монет
 /// </summary>
 /// <param name="coinEntity"></param>
 /// <param name="count"></param>
 public void ChangeCoinCount(CoinEntity coinEntity, int count)
 {
     coinEntity.Count = count;
 }
Esempio n. 21
0
        public async Task Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer,
                              [Table(TableName, Connection = "AzureWebJobsStorage")] CloudTable table, ILogger log)
        {
            log.LogInformation($"CoinValueSaver executed at: {DateTime.Now}");

            // Get coin value as JSON
            var client = new HttpClient();
            var json   = await client.GetStringAsync(ApiEndpoint);

            // Parsing prices retrived from the API endpoint
            var priceBtc = 0.0;
            var priceEth = 0.0;

            try
            {
                var array = JArray.Parse(json);

                var priceString = array.Children <JObject>()
                                  .FirstOrDefault(c => c.Property("symbol").Value.ToString().ToLower() == CoinTrend.SymbolBtc)?
                                  .Property("price_usd").Value.ToString();

                if (priceString != null)
                {
                    double.TryParse(priceString, out priceBtc);
                }

                priceString = array.Children <JObject>()
                              .FirstOrDefault(c => c.Property("symbol").Value.ToString().ToLower() == CoinTrend.SymbolEth)?
                              .Property("price_usd").Value.ToString();

                if (priceString != null)
                {
                    double.TryParse(priceString, out priceEth);
                }
            }
            catch
            {
                throw;
            }

            if (priceBtc < 0.1 || priceEth < 0.1)
            {
                log.LogInformation("Something went wrong");
                return;
            }

            // Generating table operations and model instances
            var coinBtc = new CoinEntity
            {
                RowKey       = "rowBtc" + DateTime.Now.Ticks,
                PartitionKey = "partition",

                Symbol        = CoinTrend.SymbolBtc,
                TimeOfReading = DateTime.Now,
                PriceUsd      = priceBtc
            };
            var coinBtcOperation = TableOperation.Insert(coinBtc);

            var coinEth = new CoinEntity
            {
                RowKey       = "rowEth" + DateTime.Now.Ticks,
                PartitionKey = "partition",

                Symbol        = CoinTrend.SymbolEth,
                TimeOfReading = DateTime.Now,
                PriceUsd      = priceEth
            };
            var coinEthOperation = TableOperation.Insert(coinEth);

            // Insert new values in table
            var batch = new TableBatchOperation {
                coinBtcOperation, coinEthOperation
            };
            await table.ExecuteBatchAsync(batch);

            // Send a custom metrics with the prices
            // to Azure Application Insights
            var btcPriceMetric = new MetricTelemetry("Bitcoin price in USD", priceBtc);

            _telemetryClient.TrackMetric(btcPriceMetric);
            var ethPriceMetric = new MetricTelemetry("Ethereum price in USD", priceEth);

            _telemetryClient.TrackMetric(ethPriceMetric);
        }
Esempio n. 22
0
 public CoinController(CoinEntity e, Vec2d spawnForce)
     : base(e)
 {
     movementDelta = spawnForce;
 }
Esempio n. 23
0
        public async Task <ActionResult> SaveFormJson(CoinEntity entity)
        {
            TData <string> obj = await coinBLL.SaveForm(entity);

            return(Json(obj));
        }