Exemple #1
0
        public void HandleCoins()
        {
            if (Voxels == null || Coins == null)
            {
                return;
            }

            if (Voxels.Count == 0)
            {
                foreach (Body component in Coins)
                {
                    KillCoins(component);
                }
                Coins.Clear();
            }

            int numCoins = (int)Math.Ceiling(Math.Min(Math.Max((float)(decimal)Money / (float)(decimal)MoneyPerPile, 1.0f), (float)Voxels.Count));

            if (Money == 0m)
            {
                numCoins = 0;
            }
            if (Coins.Count > numCoins)
            {
                for (int i = Coins.Count - 1; i >= numCoins; i--)
                {
                    KillCoins(Coins[i]);
                    Coins.RemoveAt(i);
                }
            }
            else if (Coins.Count < numCoins)
            {
                for (int i = Coins.Count; i < numCoins; i++)
                {
                    CreateCoins(Voxels[i].WorldPosition + VertexNoise.GetNoiseVectorFromRepeatingTexture(Voxels[i].WorldPosition));
                }
            }


            for (int i = 0; i < Coins.Count - 1; i++)
            {
                var fixture = Coins[i].GetRoot().GetComponent <CoinPileFixture>();
                fixture.SetFullness(1.0f);
                fixture.Name = MoneyPerPile.ToString();
            }

            DwarfBux remainder = Money - (Coins.Count - 1) * MoneyPerPile;

            if (Coins.Count > 0)
            {
                var fixture = Coins.Last().GetRoot().GetComponent <CoinPileFixture>();
                fixture.SetFullness((float)(decimal)remainder / (float)(decimal)MoneyPerPile);
                fixture.Name = remainder.ToString();
            }

            if (IsFull() && Faction.Treasurys.Count(t => !t.IsFull()) == 0 && Voxels.Count > 0)
            {
                Faction.World.MakeAnnouncement("Our treasury is full! Build more treasuries to store more money.");
            }
        }
        // Reloads the level and reinitializes Mario to his default state.
        public void Reset()
        {
            Enemies.Clear();
            Blocks.Clear();
            Pipes.Clear();
            Coins.Clear();
            Checkpoints.Clear();
            Flagpoles.Clear();
            levelData.Clear();

            InvisibleBarrier = new InvisibleBarrier(Vector2.Zero);
            CoinRoomPosition = Vector2.Zero;

            DynamicObjects.Clear();
            StaticObjects.Clear();

            PowerUpState = false;

            Mario.Instance.ResetPlayer();

            SoundManager.Instance.gameOverPlayOnce = true;

            levelData = ParseLevelCSV(fileName);
            BuildLevel(levelData);
        }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            Coins.Clear();

            try
            {
                var data = new CoinService().GetAllCoins().Result;
                foreach (var value in data)
                {
                    Coins.Add(value);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #4
0
 private void Search()
 {
     Coins.Clear();
     Coins.AddRange((SearchText != null && SearchText.Trim() != string.Empty) ? SourceCoins.Where(c =>
                                                                                                  c.Name.Trim().ToLower().Contains(SearchText.ToLower()) ||
                                                                                                  c.Symbol.Trim().ToLower().Contains(SearchText.ToLower())) : LoadCoins(0));
 }
Exemple #5
0
        private async Task GetCoins()
        {
            IsBusy = true;
            try
            {
                var result = await RestRepository.GetCoins();

                result.Remove(result.First(c => BitcoinId.Equals(c.Id)));
                Coins.Clear();
                SourceCoins.Clear();
                SourceCoins.AddRange(result);
                Coins.AddRange(LoadCoins(0));
                if (!string.IsNullOrWhiteSpace(SearchText))
                {
                    Search();
                }
            } catch (Exception e)
            {
                Crashes.TrackError(e);
                await PageDialogService.DisplayAlertAsync("Error", e.Message, "OK");
            } finally
            {
                IsBusy = false;
            }
        }
Exemple #6
0
 public void RemoveCoins()
 {
     foreach (Coin c in Coins)
     {
         c.Remove();
     }
     Coins.Clear();
 }
Exemple #7
0
        public async Task LoadCoins()
        {
            Coins.Clear();
            foreach (PortfolioCoin p in PortfolioCoins)
            {
                var coin = await _http.GetFromJsonAsync <Coin>($"api/coin/{p.Coinid}");

                Coins.Add(coin);
            }
            CalcsChanged();
        }