void SplashDamage() { foreach (var enemy in PracticeEnemySpawner.enemies) { if (enemy != null && BalanceData.AreaOfEffect >= Vector3.Distance(transform.position, enemy.transform.position)) { var health = enemy.GetComponent <OfflineHealth>(); if (health != null) { health.TakeDamage(BalanceData.GetDamage(WeaponType)); } } } var practicePlayerObject = GameObject.Find(AppConstants.PracticePlayerName); if (practicePlayerObject == null) { return; } var practicePlayer = practicePlayerObject.GetComponent <PracticePlayer>(); if (BalanceData.AreaOfEffect >= Vector3.Distance(transform.position, practicePlayer.transform.position)) { var health = practicePlayer.GetComponent <OfflineHealth>(); if (health != null) { health.TakeDamage(BalanceData.GetDamage(WeaponType)); } } }
public long?GetBalance(string address) { string url = string.Format("{0}/addresses/balance/{1}", NodeUrl, address); BalanceData balance = this.CallChainAPI <BalanceData>(url); return(balance.Balance); }
public static Balance ToModel(this BalanceData node) { var model = new Balance() { Id = node.Id, TargetId = node.TargetId, TargetCategory = node.TargetCategory, EnergyCategory = node.EnergyCategory, Price = node.Price, EnergyConsumption = node.EnergyConsumption, Overplus = node.Overplus, Prepay = node.Prepay, Subsidy = node.Subsidy, Recharge = node.Recharge, CashCharge = node.CashCharge, CashCorrect = node.CashCorrect, Usage = node.Usage, Refund = node.Refund, BadDebt = node.BadDebt, Total = node.Total, AuditDate = node.AuditDate, CreateDate = node.CreateDate, TotalCashCharge = node.TotalCashCharge, TotalRecharge = node.TotalRecharge, TotalSubsidy = node.TotalSubsidy, OperatorId = node.OperatorId }; if (node.BalanceDetails.Count > 0) { model.BalanceDetails = node.BalanceDetails.Select(x => x.ToModel()).ToList(); } return(model); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JToken jObject = JToken.ReadFrom(reader); BalanceData result = null; if (jObject["amount"] != null) { if (jObject["amount"].Type == JTokenType.Array) { result = new NFCBalanceData(); } else if (jObject["amount"].Type == JTokenType.Integer) { result = new FCBalanceData(); } else { //TODO not supported balance format throw new NotSupportedException(); } } else { //TODO not supported balance format throw new NotSupportedException(); } serializer.Populate(jObject.CreateReader(), result); return(result); }
void openBalanceUpdateForm(BalanceType btype, int entry_index = 0) { UpdateBalanceForm balance_form = new UpdateBalanceForm(); //пополнение balance_form.entry_sum_direction.SelectedIndex = (int)btype; balance_form.btnApply.Click += (fSender, eSender) => { decimal bdata_amount = balance_form.entry_amount.Value; FundEntry entry = logic.getEntry(entry_index); decimal entry_balance = logic.calcEntryBalance(entry); bool can_continue = true; //если вычет средств, то проверяем баланс if (btype == BalanceType.Outcome && bdata_amount > entry_balance) { //запрашивается вычет баланса больше, чем есть can_continue = false; alert("Вы пытаетесь вычесть баланса больше, чем доступно в задаче"); } if (can_continue) { BalanceData bdata = new BalanceData(); bdata.amount = bdata_amount; bdata.comment = balance_form.textBox_comment.Text; bdata.type = btype; logic.addBalanceData(bdata, btype, entry_index); balance_form.Close(); rebuildTable(); } }; balance_form.ShowDialog(); }
public async Task OnGetAsync() { HttpClient client = new HttpClient(); //get account balance and display it client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer sk_test_f075718722a05eb8182c77beb0279ebe1d2249d2"); string response = await client.GetStringAsync("https://api.paystack.co/balance"); BalanceData row = JsonConvert.DeserializeObject <BalanceData>(response); //check if account balance returned a value if (row.status) { foreach (Models.Balance item in row.data) { AccountBalance = string.Format("{0:n}", Convert.ToDecimal(item.balance) / 100); } } else { AccountBalance = "Not Available"; } client.Dispose(); }
public void GetBalanceData(Action <BackendResult <BalanceData, ResultCode> > callback) { VKRequestsDispatcher.DispatchRequestToVK <BalanceDataResponse>("execute.getBalanceData", new Dictionary <string, string>() { { "type", "votes" }, { "merchant", "microsoft" }, { "no_inapp", "1" } }, (Action <BackendResult <BalanceDataResponse, ResultCode> >)(result => { BalanceData balanceData = new BalanceData(); ResultCode resultCode = result.ResultCode; BalanceDataResponse resultData = result.ResultData; List <StockItem> stockItems1 = null; BackendResult <BalanceData, ResultCode> backendResult1 = new BackendResult <BalanceData, ResultCode>(); backendResult1.ResultCode = resultCode; BalanceData balanceData1 = balanceData; backendResult1.ResultData = balanceData1; BackendResult <BalanceData, ResultCode> response = backendResult1; if (resultData != null) { balanceData.Balance = resultData.balance; VKList <StockItem> stockItems2 = resultData.stockItems; stockItems1 = stockItems2 != null ? stockItems2.items : null; } if (result.ResultCode == ResultCode.Succeeded && stockItems1 != null) { VotesPacksGenerator.Generate(AppGlobalStateManager.Current.GlobalState.PaymentType, stockItems1, (Action <List <VotesPack> >)(votesPacks => { balanceData.VotesPacks = votesPacks; Action <BackendResult <BalanceData, ResultCode> > action = callback; if (action == null) { return; } BackendResult <BalanceData, ResultCode> backendResult2 = response; action(backendResult2); })); } else { Action <BackendResult <BalanceData, ResultCode> > action = callback; if (action == null) { return; } BackendResult <BalanceData, ResultCode> backendResult2 = response; action(backendResult2); } }), null, false, true, new CancellationToken?(), null); }
private void ProcessData(BalanceData balanceData, Action callback = null) { BalanceRefillViewModel.LoadUnfulfilledConsumables((Action <List <InAppUnfulfilledProduct> >)(unfulfilledProducts => { BalanceData balanceData1 = balanceData; this.Balance = balanceData1 != null ? balanceData1.Balance : 0; this.VotesPacks = new List <VotesPackViewModel>(); BalanceData balanceData2 = balanceData; List <VotesPack> m0List; if (balanceData2 == null) { m0List = null; } else { List <VotesPack> votesPacks = balanceData2.VotesPacks; m0List = votesPacks != null ? Enumerable.ToList <VotesPack>(Enumerable.OrderBy <VotesPack, int>(votesPacks, (Func <VotesPack, int>)(votesPack => votesPack.VotesCount))) : null; } List <VotesPack> votesPackList = m0List; if (votesPackList != null) { for (int index = 0; index < votesPackList.Count; ++index) { VotesPack votesPack = votesPackList[index]; bool flag = Enumerable.Any <InAppUnfulfilledProduct>(unfulfilledProducts, (Func <InAppUnfulfilledProduct, bool>)(product => product.ProductId == votesPack.MerchantProductId)); VotesPackViewModel votesPackViewModel = new VotesPackViewModel(votesPack); votesPackViewModel.IconCoinId = index + 1; int num = !flag ? 1 : 0; votesPackViewModel.CanPurchase = num != 0; this.VotesPacks.Add(votesPackViewModel); } } Execute.ExecuteOnUIThread((Action)(() => { // ISSUE: type reference // ISSUE: method reference this.NotifyPropertyChanged <int>(() => this.Balance); // ISSUE: type reference // ISSUE: method reference this.NotifyPropertyChanged <List <VotesPackViewModel> >(() => this.VotesPacks); })); Action action = callback; if (action == null) { return; } action(); })); }
private void TriggerWeapon(Collision2D collision) { if (cluster) { RpcspawnLasers(collision); } Destroy(gameObject); var health = collision.gameObject.GetComponent <Health.Health>(); if (health != null) { health.TakeDamage(BalanceData.GetDamage(WeaponType)); } }
void Start () { returnToHub = FindObjectOfType<ReturnToHub>(); //Cursor.visible = true; //Cursor.lockState = CursorLockMode.None; currentData = allData[ PlayerPrefs.GetInt("BalanceProgress",0) % allData.Length ]; for(int i=0;i<currentData.weights.Length;i++){ togglesUI[i].GetComponentInChildren<Text>().text = currentData.weights[i].ToString(); GameObject obj = Instantiate(currentData.objects[i]) as GameObject; obj.transform.position = sources[i].transform.position; obj.transform.parent = sources[i].transform; obj.name = currentData.weights[i].ToString(); } CalculateBalance(); }
private void TriggerWeapon(Collision2D collision) { if (WeaponType == WeaponType.CLUSTERBOMB) { RpcSpawnLasers(collision); } Destroy(gameObject); var healthOfObject = collision.gameObject.GetComponent <OfflineHealth>(); if (healthOfObject != null) { healthOfObject.TakeDamage(BalanceData.GetDamage(WeaponType)); } }
public bool FromDataTable(DataTable table) { try { foreach (DataRow row in table.Rows) { var item = new BalanceData(); item.FromDBTable(row); Items.Add(item); } return(true); } catch { return(false); } }
private void ProcessData(BalanceData balanceData, Action callback = null) { BalanceRefillViewModel.LoadUnfulfilledConsumables((Action <List <InAppUnfulfilledProduct> >)(unfulfilledProducts => { BalanceData balanceData1 = balanceData; this.Balance = balanceData1 != null ? balanceData1.Balance : 0; this.VotesPacks = new List <VotesPackViewModel>(); BalanceData balanceData2 = balanceData; List <VotesPack> votesPackList1; if (balanceData2 == null) { votesPackList1 = (List <VotesPack>)null; } else { List <VotesPack> votesPacks = balanceData2.VotesPacks; votesPackList1 = votesPacks != null ? votesPacks.OrderBy <VotesPack, int>((Func <VotesPack, int>)(votesPack => votesPack.VotesCount)).ToList <VotesPack>() : (List <VotesPack>)null; } List <VotesPack> votesPackList2 = votesPackList1; if (votesPackList2 != null) { for (int index = 0; index < votesPackList2.Count; ++index) { VotesPack votesPack = votesPackList2[index]; bool flag = unfulfilledProducts.Any <InAppUnfulfilledProduct>((Func <InAppUnfulfilledProduct, bool>)(product => product.ProductId == votesPack.MerchantProductId)); VotesPackViewModel votesPackViewModel = new VotesPackViewModel(votesPack); votesPackViewModel.IconCoinId = index + 1; int num = !flag ? 1 : 0; votesPackViewModel.CanPurchase = num != 0; this.VotesPacks.Add(votesPackViewModel); } } Execute.ExecuteOnUIThread((Action)(() => { this.NotifyPropertyChanged <int>((Expression <Func <int> >)(() => this.Balance)); this.NotifyPropertyChanged <List <VotesPackViewModel> >((Expression <Func <List <VotesPackViewModel> > >)(() => this.VotesPacks)); })); Action action = callback; if (action == null) { return; } action(); })); }
public List <BalanceData> buildFinanceList(Dictionary <EntryType, bool> exclude_types = null) { //кажется, нужен refactoring List <BalanceData> result_list = new List <BalanceData>(); //string line = ""; decimal entry_balance = 0; string[] enum_descriptions = EntryType.Payment.Descriptions(); decimal[] enum_balances = new decimal[enum_descriptions.Length]; //проход по записям for (int i = 0; i < dataContainer.entrys_list.Count; i++) { FundEntry entry = dataContainer.entrys_list[i]; entry_balance = this.calcEntryBalance(entry); int entry_typeINT = (int)entry.type; enum_balances[entry_typeINT] += entry_balance; } //проход по типам записей for (int j = 0; j < enum_descriptions.Length; j++) { bool can_continue = true; if (exclude_types != null) { //exclude_types EntryType entry_type = (EntryType)j; if (exclude_types[entry_type] == true) { //найден тип, который надо исключить //Debug.Print("Исключаем тип: " + entry_type.GetDescription()); can_continue = false; } } if (can_continue) { BalanceData bdata = new BalanceData(); bdata.amount = enum_balances[j]; bdata.comment = enum_descriptions[j] + ": " + enum_balances[j].ToString() + " д.ед"; result_list.Add(bdata); } } return(result_list); }
void SplashDamage() { if (BalanceData.AreaOfEffect >= Vector3.Distance(transform.position, GameManager.localPlayer.transform.position)) { var health = GameManager.localPlayer.GetComponent <Health.Health>(); if (health != null) { health.TakeDamage(BalanceData.GetDamage(WeaponType)); } } if (GameManager.opponentPlayer != null) { if (BalanceData.AreaOfEffect >= Vector3.Distance(transform.position, GameManager.opponentPlayer.transform.position)) { var health = GameManager.opponentPlayer.GetComponent <Health.Health>(); if (health != null) { health.TakeDamage(BalanceData.GetDamage(WeaponType)); } } } }
public void addBalanceData(BalanceData bdata, BalanceType btype, int entry_index = 0) { //TODO: проверку, не выходит ли индекс за пределы bool is_ok = true; switch (btype) { default: is_ok = false; break; case BalanceType.Income: dataContainer.entrys_list[entry_index].income.Add(bdata); break; case BalanceType.Outcome: dataContainer.entrys_list[entry_index].outcome.Add(bdata); break; } if (is_ok) { fs.save(dataContainer); } }
private void IniciarLectura() { pararLectura = false; nuevoPeso = true; EscucharComandos(); fechaCambioPeso = DateTime.Now; var thread = new Thread(() => { while (true) { if (pararLectura) { break; } if (_isEditing) { continue; } var tipoImpresion = "IP"; var peso = _balanceDevice.SendAndRead(tipoImpresion); var pesoNumerico = Convert.ToInt64(Regex.Match(peso, @"-?\d+").Value); var utimoPesoNumerico = ultimoPeso != "" ? Convert.ToInt64(Regex.Match(ultimoPeso, @"-?\d+").Value) : 0; if (peso != ultimoPeso) { ultimoPeso = peso; fechaCambioPeso = DateTime.Now; if (pesoNumerico <= Configuracion.EmptyWeigth) { nuevoPeso = true; } this.Invoke(new Action(() => { if (nuevoPeso) { } lblPeso.ForeColor = SystemColors.HotTrack; lblPeso.Text = ultimoPeso; })); } else { if (nuevoPeso) { var ahora = DateTime.Now; var tiempoTranscurrido = (ahora - fechaCambioPeso) .TotalMilliseconds; //Tiempo desde que cambió el último valor if (tiempoTranscurrido >= Configuracion.StabilityTime && pesoNumerico > 0) { fechaUltimaLectura = DateTime.Now; this.Invoke(new Action(() => { if (Work != null && Work.Status == BalanceStatus.Reading) { Data = new BalanceData { WorkId = Work.WorkId, OriginalData = ultimoPeso, Weight = utimoPesoNumerico, CreatedDate = DateTime.Now }; _context.BalanceDatas.Add(Data); _context.SaveChanges(); DataCollection.Add(Data); RefrescarDatos(); nuevoPeso = false; lblPeso.ForeColor = Color.Green; } })); } } else if (Data != null) { var tiempoAcomodar = (DateTime.Now - fechaCambioPeso) .TotalMilliseconds; //Tiempo en acomodar peso, luego de haber estabilizado el peso var diferenciaPeso = Math.Abs(Data.Weight - pesoNumerico); //Diferencia de peso mínima para contabilizar if (diferenciaPeso >= Configuracion.AccommodateWeigthMin && tiempoAcomodar > Configuracion.AccommodateTime) { Data.OriginalData = ultimoPeso; Data.Weight = utimoPesoNumerico; Data.UpdateDate = DateTime.Now; _context.Entry(Data).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); this.Invoke(new Action(() => { lblPeso.ForeColor = Color.Green; })); fechaUltimaLectura = DateTime.Now; RefrescarDatos(); } } } } }) { IsBackground = true }; thread.Start(); }
public static BalanceData ToViewData(this Balance node, CategoryDictionary suffix = CategoryDictionary.None) { if (node == null) { return(null); } var model = new BalanceData() { Id = node.Id, TargetId = node.TargetId, TargetCategory = node.TargetCategory, EnergyCategory = node.EnergyCategory, Price = node.Price, EnergyConsumption = node.EnergyConsumption, Overplus = node.Overplus, Prepay = node.Prepay, Subsidy = node.Subsidy, Recharge = node.Recharge, CashCharge = node.CashCharge, CashCorrect = node.CashCorrect, Usage = node.Usage, Refund = node.Refund, BadDebt = node.BadDebt, Total = node.Total, AuditDate = node.AuditDate, CreateDate = node.CreateDate, OperatorId = node.OperatorId, TotalCashCharge = node.TotalCashCharge, TotalRecharge = node.TotalRecharge, TotalSubsidy = node.TotalSubsidy, BalanceDetails = node.BalanceDetails.ToList().Select(x => x.ToViewData()).ToList() }; if ((suffix & CategoryDictionary.Manager) == CategoryDictionary.Manager) { var ctx_user = new UserBLL(); var op = ctx_user.Find(model.OperatorId); if (op != null) { model.Operator = op.ToViewData(); } } if ((suffix & CategoryDictionary.Building) == CategoryDictionary.Building || (suffix & CategoryDictionary.Organization) == CategoryDictionary.Organization) { if (model.TargetCategory == (int)CategoryDictionary.Building) { var ctx_bid = new BuildingBLL(); var b = ctx_bid.Find(model.TargetId); if (b != null) { model.Target = b.ToViewData(); } } if (model.TargetCategory == (int)CategoryDictionary.Organization) { var ctx_org = new OrganizationBLL(); var o = ctx_org.Find(model.TargetId); if (o != null) { model.Target = o.ToViewData(); } } } return(model); }
private void OnLoss(BalanceData bal) { _losses++; _currentGuesses = 0; _isPreroll = true; var lss = new CashOutData { game_id = _gameData.id.ToString(), outcome = "LOSS", win = 0, wins = ((_wins / (_wins + _losses)) * 100).ToString("##.##"), }; foreach (var pickedNumber in _pickedNumbers) { lss.mines += pickedNumber; } _pickedNumbers.Clear(); AddToView(lss); if (_isPractice) { _currentBalance -= double.Parse((_currentBet).ToString("0.000000", new CultureInfo("en-US"))); _profit -= double.Parse((_currentBet / (decimal)ConvertMultiplier).ToString("0.000000", new CultureInfo("en-US"))); } if (!_gameIsStop) { if (_currentBet > 0) { _currentBet = _currentBet * (decimal)_multiplier; _beforePreroll = _currentBet; } if (_currentBet > 0) { _currentBet = 0; NewGame(); } else { if (_currentBet <= (decimal)bal.balance || bal.balance == 0) { if (_currentBet > _maxBet) { _currentBet = _baseBet; } NewGame(); } else { _gameIsStop = true; _isError = true; _title = "Betting Stopped"; _message = "The current bet is bigger than balance"; } } } else { _gameIsStop = true; _isError = true; _title = "Betting Stopped"; _message = "The game was ended"; } }
public void Prepaint(Report report, RowData data, Cell innercell, FilterSrv filter, AgileArgs args, DataHelper datahelper, ReportSummaryData reportsummary, RowBalance rowbalance, AccumulateData accumulate, BalanceData balance, object[] others) { Current current = null; int grouplevels = report.GroupLevels; int currentindex = -1; int startindex = -1; Groups groups = null; Group currentgroup = null; RowData columntodata = null; Current previous = new Current(rowbalance); if (rowbalance != null) { currentindex = rowbalance.CurrentIndex; startindex = rowbalance.StartIndex; } SemiRow cells = (data != null ? data.SemiRow : null); SemiRow row = cells; IKeyToObject nametodata = cells as IKeyToObject; StimulateCell cell = new StimulateCell(innercell); if (data is Group) { cell.bInGroup = true; currentgroup = data as Group; columntodata = currentgroup; } else if (!(data is ReportSummaryData)) { current = new Current(data); columntodata = data; } else { cell.bInReportSummary = true; columntodata = data; } if (nametodata == null) { nametodata = columntodata as IKeyToObject; } Global global; if (datahelper.Global == null) { global = new Global(); global.DataHelper = datahelper; datahelper.Global = global; } else { global = datahelper.Global as Global; } if (Convert.ToDouble(reportsummary["不良品数量"]) == 0) { cell.Caption = 0; return; } if (current != null) { cell.Caption = Convert.ToDouble(current["不良品数量"]) / Convert.ToDouble(reportsummary["不良品数量"]); } else if (currentgroup != null) { cell.Caption = Convert.ToDouble(currentgroup["不良品数量"]) / Convert.ToDouble(reportsummary["不良品数量"]); } else { cell.Caption = 1; } }