public BatchedClick GetBatchedClick()
        {
            BatchedClick oldClicks = Clicks;

            Clicks = new BatchedClick();
            return(oldClicks);
        }
        public void ProcessMultiplayerDamage(BatchedClick damage)
        {
            int totalDamageToProcess = damage.GetDamage();

            if (CurrentMonster.GetHealth() >= totalDamageToProcess)
            {
                MonsterClickProcessor(totalDamageToProcess);
            }
            else
            {
                while (totalDamageToProcess > 0)
                {
                    int damageForCurrentMonster = CurrentMonster.GetHealth();
                    int damageToDo = totalDamageToProcess - damageForCurrentMonster;
                    if (damageToDo <= 0)
                    {
                        MonsterClickProcessor(damageToDo);
                        break;
                    }

                    totalDamageToProcess -= damageToDo;
                    MonsterClickProcessor(damageToDo);
                }
            }
        }
 private async void ReceiveUploadedBatchClicks(BatchedClick CollectedDamage)
 {
     var dispatcher = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher;
     await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         OnBatchesReceived?.Invoke(CollectedDamage, null);
     });
 }
        public CurrencyTrayViewModel()
        {
            TappedEvent = new RelayCommand(MonsterClicked);

            Clicks = new BatchedClick();

            CurrencyInView                = new CustomCoinList <Currency>();
            CurrencyInView.OnCoinAdded   += CurrencyInView_OnCoinAdded;
            CurrencyInView.OnCoinRemoved += CurrencyInView_OnCoinRemoved;
        }
        private void RequestClickBatches()
        {
            BatchedClick clicks = OnRequireBatches?.Invoke();

            if (clicks.GetDamage() > 0)
            {
                //if clicks is a valid object, serialize it and broadcast it to the server.
                MultiPlayerHub.Invoke <BatchedClick>("uploadBatchedClicks", clicks);
            }
        }