Beispiel #1
0
        private void UpdateWeaponGrid(SelectedWeaponGrid weaponGrid, CharacterSheet.WeaponItem item, int itemIndex)
        {
            var sheet = CharacterSheetStorage.Instance.selectedCharacter;

            if (sheet == null)
            {
                return;
            }
#if EXPAND_CHECKBOX
            if (weaponGrid.selectedHandler != null)
            {
                weaponGrid.selected.CheckedChanged -= weaponGrid.selectedHandler;
            }
            weaponGrid.selectedHandler = (s, e) => Weapon_CheckedChanged(item, e.Value);
            UpdateValue(weaponGrid.selected, item.selected);
            weaponGrid.selected.IsChecked       = item.selected;
            weaponGrid.selected.CheckedChanged += weaponGrid.selectedHandler;
#endif
            if (weaponGrid.activeHandler != null)
            {
                weaponGrid.active.CheckedChanged -= weaponGrid.activeHandler;
            }
            weaponGrid.activeHandler = (s, e) => WeaponActive_CheckedChanged(item, e.Value);
            UpdateValue(weaponGrid.active, item.active);
            weaponGrid.active.IsChecked       = item.active;
            weaponGrid.active.CheckedChanged += weaponGrid.activeHandler;

            UpdateValue(weaponGrid.name, item.name);
            UpdateValue(weaponGrid.attackBonus, item.AttackBonus(sheet));
            UpdateValue(weaponGrid.critical, item.critical.AsString(sheet));
            UpdateValue(weaponGrid.damage, item.Damage(sheet));
            UpdateValue(weaponGrid.damageBonus, item.DamageBonus(sheet));
            UpdateValue(weaponGrid.type, item.type);
            UpdateValue(weaponGrid.range, item.Range(sheet));
            UpdateValue(weaponGrid.ammunition, item.ammunition.GetTotal(sheet).ToString());
            UpdateValue(weaponGrid.special, item.special);
            UpdateValue(weaponGrid.weight, item.weight.GetTotal(sheet).ToString());
            UpdateValue(weaponGrid.description, item.description);

            MainPage.SetTapHandler(weaponGrid.container, (s, e) => Weapon_DoubleTap(item), 2);
#if EXPAND_WITH_TAP
#if EXPAND_CHECKBOX
            MainPage.AddTapHandler(weaponGrid.container, (s, e) => Weapon_Tap(weaponGrid.selected), 1);
#else
            MainPage.AddTapHandler(weaponGrid.container, (s, e) => Weapon_Tap(item), 1);
#endif
#endif
        }
Beispiel #2
0
        public void UpdateView()
        {
            pushedPage = null;
            var sheet = CharacterSheetStorage.Instance.selectedCharacter;

            if (sheet == null)
            {
                return;
            }
            AttackBonus.Text = item.AttackBonus(sheet);
            Critical.Text    = item.critical.AsString(sheet);
            Damage.Text      = item.Damage(sheet);
            DamageBonus.Text = item.DamageBonus(sheet).ToString();
            Range.Text       = item.range.GetTotal(sheet).ToString();
            Ammunition.Text  = item.ammunition.GetTotal(sheet).ToString();
            Weight.Text      = item.weight.GetTotal(sheet).ToString();
        }
Beispiel #3
0
        private void CreateSelectedWeaponGrid(CharacterSheet.WeaponItem item, int itemIndex)
        {
            if (item == null)
            {
                return;
            }
            var sheet = CharacterSheetStorage.Instance.selectedCharacter;

            if (sheet == null)
            {
                return;
            }
            if (selectedWeaponGridsPool.Count > 0)
            {
                var weaponGrid = selectedWeaponGridsPool[0];
                selectedWeaponGridsPool.RemoveAt(0);
                UpdateWeaponGrid(weaponGrid, item, itemIndex);
                var pos = selectedWeaponGrids.Count;
                selectedWeaponGrids.Add(weaponGrid);
                Weapon.Children.Insert(pos, weaponGrid.container);
                return;
            }
            var grid = new Grid()
            {
                ColumnSpacing   = 5,
                RowSpacing      = 5,
                BackgroundColor = Color.LightGray,
            };

            grid.ColumnDefinitions = new ColumnDefinitionCollection()
            {
                new ColumnDefinition()
                {
                    Width = GridLength.Auto
                },
                new ColumnDefinition()
                {
                    Width = GridLength.Star
                },
            };
            const int count          = 14;
            var       rowDefinitions = new RowDefinitionCollection();

            for (var i = 0; i < count; i++)
            {
                rowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
            }
            grid.RowDefinitions = rowDefinitions;
#if EXPAND_CHECKBOX
            var selectedcb = new CheckBox()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                IsChecked         = item.selected,
            };
            EventHandler <CheckedChangedEventArgs> handler = (s, e) => Weapon_CheckedChanged(item, e.Value);
            selectedcb.CheckedChanged += handler;
#endif
            var nameTitle = CreateLabel("Name:");
            var nameStack = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center,
            };
#if EXPAND_CHECKBOX
            nameStack.Children.Add(selectedcb);
#endif
            nameStack.Children.Add(nameTitle);

            var row       = 0;
            var nameValue = CreateFrame(item.name);
            grid.Children.Add(nameStack, 0, row);
            grid.Children.Add(nameValue, 1, row);
            row += 1;

            var activeTitle = CreateLabel("Active:");
            var activecb    = new CheckBox()
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                IsChecked         = item.active,
                IsEnabled         = false,
            };
            EventHandler <CheckedChangedEventArgs> activeHandler = (s, e) => WeaponActive_CheckedChanged(item, e.Value);
            activecb.CheckedChanged += activeHandler;
            grid.Children.Add(activeTitle, 0, row);
            grid.Children.Add(activecb, 1, row);
            row += 1;

            var attackBonusTitle = CreateLabel("Attack Bonus:");
            var attackBonusValue = CreateFrame(item.AttackBonus(sheet));
            grid.Children.Add(attackBonusTitle, 0, row);
            grid.Children.Add(attackBonusValue, 1, row);
            row += 1;

            var criticalTitle = CreateLabel("Critical:");
            var criticalValue = CreateFrame(item.critical.AsString(sheet));
            grid.Children.Add(criticalTitle, 0, row);
            grid.Children.Add(criticalValue, 1, row);
            row += 1;

            var damageTitle = CreateLabel("Damage:");
            var damageValue = CreateFrame(item.Damage(sheet));
            grid.Children.Add(damageTitle, 0, row);
            grid.Children.Add(damageValue, 1, row);
            row += 1;

            var damageBonusTitle = CreateLabel("Damage Bonus:");
            var damageBonusValue = CreateFrame(item.DamageBonus(sheet));
            grid.Children.Add(damageBonusTitle, 0, row);
            grid.Children.Add(damageBonusValue, 1, row);
            row += 1;

            var typeTitle = CreateLabel("Type:");
            var typeValue = CreateFrame(item.type);
            grid.Children.Add(typeTitle, 0, row);
            grid.Children.Add(typeValue, 1, row);
            row += 1;

            var rangeTitle = CreateLabel("Range:");
            var rangeValue = CreateFrame(item.Range(sheet));
            grid.Children.Add(rangeTitle, 0, row);
            grid.Children.Add(rangeValue, 1, row);
            row += 1;

            var ammunitionTitle = CreateLabel("Ammunition:");
            var ammunitionValue = CreateFrame(item.ammunition.GetTotal(sheet).ToString());
            grid.Children.Add(ammunitionTitle, 0, row);
            grid.Children.Add(ammunitionValue, 1, row);
            row += 1;

            var specialTitle = CreateLabel("Special:");
            var specialValue = CreateFrame(item.special);
            grid.Children.Add(specialTitle, 0, row);
            grid.Children.Add(specialValue, 1, row);
            row += 1;

            var weightTitle = CreateLabel("Weight:");
            var weightValue = CreateFrame(item.weight.GetTotal(sheet).ToString());
            grid.Children.Add(weightTitle, 0, row);
            grid.Children.Add(weightValue, 1, row);
            row += 1;

            var descriptionTitle = CreateLabel("Description:");
            grid.Children.Add(descriptionTitle, 0, 2, row, row + 1);
            row += 1;

            var descriptionValue = CreateFrame(item.description);
            grid.Children.Add(descriptionValue, 0, 2, row, row + 1);
            row += 1;

            MainPage.AddTapHandler(grid, (s, e) => Weapon_DoubleTap(item), 2);
#if EXPAND_CHECKBOX
            MainPage.AddTapHandler(grid, (s, e) => Weapon_Tap(selectedcb), 1);
#else
            MainPage.AddTapHandler(grid, (s, e) => Weapon_Tap(item), 1);
#endif

            var newWeaponGrid = new SelectedWeaponGrid()
            {
                container = grid,
#if EXPAND_CHECKBOX
                selectedHandler = handler,
                selected        = selectedcb,
#endif
                activeHandler    = activeHandler,
                active           = activecb,
                nameTitle        = nameTitle,
                nameFrame        = nameValue,
                name             = nameValue.Content as Label,
                attackBonusTitle = attackBonusTitle,
                attackBonus      = attackBonusValue.Content as Label,
                criticalTitle    = criticalTitle,
                critical         = criticalValue.Content as Label,
                damageTitle      = damageTitle,
                damage           = damageValue.Content as Label,
                damageBonusTitle = damageBonusTitle,
                damageBonus      = damageBonusValue.Content as Label,
                typeTitle        = typeTitle,
                type             = typeValue.Content as Label,
                rangeTitle       = rangeTitle,
                range            = rangeValue.Content as Label,
                ammunitionTitle  = ammunitionTitle,
                ammunition       = ammunitionValue.Content as Label,
                specialTitle     = specialTitle,
                special          = specialValue.Content as Label,
                weightTitle      = weightTitle,
                weight           = weightValue.Content as Label,
                descriptionTitle = descriptionTitle,
                description      = descriptionValue.Content as Label,
            };

            var newpos = selectedWeaponGrids.Count;
            selectedWeaponGrids.Add(newWeaponGrid);
            Weapon.Children.Insert(newpos, newWeaponGrid.container);
        }