Ejemplo n.º 1
0
        private static void addHeroToCurrentHeroes(DataSwitch dataSwitch)
        {
            //Check the switches value
            bool selected = dataSwitch.IsToggled;

            if (selected)
            {
                //Look up the hero in the roster that's assosciated with this switch
                Hero hero = App.roster.HeroList.First(item => item.Name.Equals(dataSwitch.HeroName));

                //Add the hero to the current heros.
                App.currentHeroes.HeroList.Add(hero);
            }
        }
Ejemplo n.º 2
0
        //On page start up we need to loop through the roster and create the row definitions for each class and put the heros into it.
        protected override void OnAppearing()
        {
            try
            {
                int tankCount    = 0;
                int damageCount  = 0;
                int supportCount = 0;

                base.OnAppearing();

                //refresh the master hero list
                App.roster.HeroList.Clear();
                App.roster.Seed();

                //Kill all children
                GridTank.Children.Clear();
                GridDamage.Children.Clear();
                GridSupport.Children.Clear();

                GridTank.RowDefinitions.Clear();
                GridDamage.RowDefinitions.Clear();
                GridSupport.RowDefinitions.Clear();

                //Generate
                foreach (Hero hero in App.roster.HeroList)
                {
                    if (hero.Role == "Tank")
                    {
                        //If the hero is a tank, add them to the tank roster

                        //Create a row definition
                        RowDefinition rowDef = new RowDefinition();
                        GridTank.RowDefinitions.Add(rowDef);

                        //Add a switch
                        DataSwitch switchControl = new DataSwitch();
                        switchControl.HeroName        = hero.Name;
                        switchControl.VerticalOptions = LayoutOptions.Center;

                        //If the hero is previously selected, set the switch to true
                        if (App.currentHeroes.HeroList.Any(x => x.Name == hero.Name))
                        {
                            switchControl.IsToggled = true;
                        }

                        GridTank.Children.Add(switchControl, 0, tankCount);

                        //Add their name
                        Label displayName = new Label();
                        displayName.Text            = hero.Name;
                        displayName.VerticalOptions = LayoutOptions.Center;
                        GridTank.Children.Add(displayName, 1, tankCount);

                        //Up the counter
                        tankCount++;
                    }

                    if (hero.Role == "Damage")
                    {
                        //If the hero is damage, add them to the damage roster

                        //Create a row definiton
                        RowDefinition rowDef = new RowDefinition();
                        GridDamage.RowDefinitions.Add(rowDef);

                        //Add a switch
                        DataSwitch switchControl = new DataSwitch();
                        switchControl.HeroName        = hero.Name;
                        switchControl.VerticalOptions = LayoutOptions.Center;



                        //If the hero is currently selected, set the switch to true
                        if (App.currentHeroes.HeroList.Any(x => x.Name == hero.Name))
                        {
                            switchControl.IsToggled = true;
                        }

                        GridDamage.Children.Add(switchControl, 0, damageCount);

                        //Add their name
                        Label displayName = new Label();
                        displayName.Text            = hero.Name;
                        displayName.VerticalOptions = LayoutOptions.Center;
                        GridDamage.Children.Add(displayName, 1, damageCount);

                        damageCount++;
                    }

                    if (hero.Role == "Support")
                    {
                        //If the hero is a support, add them to the support roster

                        //Create a row definition
                        RowDefinition rowDef = new RowDefinition();
                        GridSupport.RowDefinitions.Add(rowDef);

                        //Add a switch
                        DataSwitch switchControl = new DataSwitch();
                        switchControl.HeroName        = hero.Name;
                        switchControl.VerticalOptions = LayoutOptions.Center;
                        GridSupport.Children.Add(switchControl, 0, supportCount);

                        //If the hero is currently selected, set the switch to true
                        if (App.currentHeroes.HeroList.Any(x => x.Name == hero.Name))
                        {
                            switchControl.IsToggled = true;
                        }

                        //Add their name
                        Label displayName = new Label();
                        displayName.Text            = hero.Name;
                        displayName.VerticalOptions = LayoutOptions.Center;
                        GridSupport.Children.Add(displayName, 1, supportCount);

                        supportCount++;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }