Exemplo n.º 1
0
 // Clear current lists so they can be reused
 public void ClearCharacterLists()
 {
     AvailableCharacters.Clear();
     SelectedCharacters.Clear();
     SelectedMonsters.Clear();
     availItems.Clear();
     ExecuteLoadDataCommand();
 }
Exemplo n.º 2
0
        // Command that Loads the Data
        private async Task ExecuteLoadDataCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                // Reload the Available character list from the Character View Model
                AvailableCharacters.Clear();
                var availableCharacters = CharactersViewModel.Instance.Dataset;
                foreach (var data in availableCharacters)
                {
                    AvailableCharacters.Add(data);
                }

                // Reload the Selected Monster List from the Battle engine monster list
                SelectedMonsters.Clear();
                var selectedMon = BattleEngine.MonsterList;
                foreach (var mon in selectedMon)
                {
                    SelectedMonsters.Add(mon);
                }

                // Reload the Selected Character List from the Battle engine character list
                SelectedCharacters.Clear();
                var selectedChar = BattleEngine.CharacterList;
                foreach (var ch in selectedChar)
                {
                    SelectedCharacters.Add(ch);
                }

                // Reload the availItems List from the Battle engine itemspool list
                availItems.Clear();
                var avaItems = BattleEngine.ItemPool;
                foreach (var it in avaItems)
                {
                    availItems.Add(it);
                }
            }
            // Catch any exceptions
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            // Set isBusy to false
            finally
            {
                IsBusy = false;
            }
        }