internal void ClientRequestFailed(ClientSlot clientSlot) { if (_finished) { return; } var reqData = _requestAllocations[clientSlot]; int revenue = 0; foreach (var itemID in reqData.Items) { Item item = GetItem(itemID); revenue += item.BaseRevenue; } _revenue -= revenue; if (_revenue < 0) { _revenue = 0; } OnClientRevenueAction?.Invoke(clientSlot, -revenue, 0); OnEarningsChanged?.Invoke(_revenue); _numFailures++; _requestAllocations.Remove(clientSlot); if (_stalledRequests.Count > 0) { var data = _stalledRequests.Dequeue(); clientSlot.InitClient(data); } }
private void ShowRevenueDelta(ClientSlot clientSlot, int delta, int tipDelta) { var coinInstance = Instantiate <CoinResourceLabel>(_coinResourcePrefab, _coinLabelsContainer); var clientPos = Camera.main.WorldToScreenPoint(clientSlot.RequestRoot.transform.position); clientPos.Scale(_scaleFactor); var rectXfm = coinInstance.GetComponent <RectTransform>(); var coinGroup = coinInstance.GetComponent <CanvasGroup>(); coinInstance.SetAmount(delta, tipDelta); coinGroup.alpha = 0.3f; coinGroup.DOFade(1.0f, 0.5f); rectXfm.anchoredPosition = clientPos; rectXfm.localScale = Vector3.one * 0.3f; rectXfm.DOAnchorPosY(rectXfm.anchoredPosition.y + 20.0f, 0.5f, true); rectXfm.DOScale(1, 0.5f).OnComplete(() => Destroy(coinInstance.gameObject)); }
public async Task <ObservableCollection <ClientSlot> > GetAllSlotsAsync() { var jsonGetAllSlots = await httpClient.GetStringAsync(SlotsUrl); ObservableCollection <ClientSlot> retVal = new ObservableCollection <ClientSlot>(); FhirJsonParser fjp = new FhirJsonParser(); Bundle bund = fjp.Parse <Bundle>(jsonGetAllSlots); if (null != bund) { foreach (var entry in bund.Entry) { ClientSlot newSlot = new ClientSlot(entry.Resource as Slot); retVal.Add(newSlot); } } return(retVal); }
public void RequestFulfilled(ClientSlot clientSlot) { if (_finished) { return; } var data = _requestAllocations[clientSlot]; float timeLeftPercent = 100 * (1 - clientSlot.TimeElapsed / data.Timeout); int revenue = 0; foreach (var itemID in data.Items) { Item itemData = GetItem(itemID); revenue += itemData.BaseRevenue; } int idx = 0; while (idx < EarningModifiers.Count && timeLeftPercent > EarningModifiers[idx].TimeLeftThresholdValue) { idx++; } float multiplier = EarningModifiers[idx].ExtraPercent; int additionalRevenue = Mathf.FloorToInt(revenue * multiplier); OnClientRevenueAction?.Invoke(clientSlot, revenue, additionalRevenue); _revenue += revenue + additionalRevenue; OnEarningsChanged?.Invoke(_revenue); _requestAllocations.Remove(clientSlot); if (_stalledRequests.Count > 0) { data = _stalledRequests.Dequeue(); clientSlot.InitClient(data); } }
public void SetSlot(ClientSlot newSlot) { Slot = newSlot; }