Beispiel #1
0
        /*
         * Set all the Label.Text variables to its assosiated element.
         * Param Nothing.
         * Returns Nothing.
         */
        private void InitializeStats()
        {
            Character.Text       = dungeon.user.Character;
            CharacterName.Text   = dungeon.user.Username;
            CharacterHealth.Text = CharacterHP.ToString();
            CharacterMana.Text   = CharacterMP.ToString();

            Boss.Text       = dungeon.CurrentBoss;
            BossName.Text   = dungeon.CurrentName;
            BossHealth.Text = BossHP.ToString();
        }
Beispiel #2
0
        private void CreateItemDisplay(ItemModel item, List <ItemModel> list)
        {
            var frame = new Frame();

            frame.CornerRadius = 5;
            frame.Padding      = new Thickness(15, 15, 5, 15);

            var layout = new StackLayout();

            layout.Orientation = StackOrientation.Horizontal;

            var Name = new Label();

            Name.Text = item.item;
            Name.VerticalTextAlignment = TextAlignment.Center;
            Name.Margin         = new Thickness(0, 0, 10, 0);
            Name.FontAttributes = FontAttributes.Bold;
            if (item.item.Contains("HealthPotion"))
            {
                Name.TextColor      = Color.FromHex("#F44336");
                frame.BorderColor   = Color.FromHex("#F44336");
                Name.FontAttributes = FontAttributes.Bold;
            }
            else
            {
                Name.TextColor      = Color.DarkTurquoise;
                frame.BorderColor   = Color.DarkTurquoise;
                Name.FontAttributes = FontAttributes.Bold;
            }


            var extras = new Label();

            extras.FontSize  = 10;
            extras.TextColor = Color.Black;
            extras.Text      = string.Format("{0}: {1} - {2} {3}",
                                             ItemInfoModel.ObtainItemString(item.item, true),
                                             ItemInfoModel.ObtainItemInfo(item.item, true),
                                             ItemInfoModel.ObtainItemInfo(item.item, false),
                                             ItemInfoModel.ObtainItemString(item.item, false));
            extras.HorizontalTextAlignment = TextAlignment.Center;
            extras.HorizontalOptions       = LayoutOptions.CenterAndExpand;
            extras.VerticalTextAlignment   = TextAlignment.Center;

            var button = new Button();

            button.HorizontalOptions = LayoutOptions.EndAndExpand;
            button.Text            = "USE";
            button.CornerRadius    = 5;
            button.BackgroundColor = Color.White;
            button.TextColor       = Color.Accent;


            button.Clicked += async(s, e) =>
            {
                if (battlesequence)
                {
                    battlesequence = false;
                    await Task.Run(async() =>
                    {
                        Animations.CloseStackLayout(layout, "closing", 30, 500);
                    });

                    Items.Children.Remove(frame);
                    pots.Remove(item); // Remove off list
                    string invetory = "";
                    foreach (ItemModel itemInv in pots)
                    {
                        if (!String.IsNullOrEmpty(itemInv.item))
                        {
                            invetory += itemInv.item + ","; // Create string for file
                        }
                    }
                    UserModel.Rewrite("Items:", invetory, dungeon.items.Localfile);

                    try
                    {
                        dungeon.items.Invfile.Object.Items = invetory;
                        await dungeon.items.UpdateInv();
                    }
                    catch { }

                    dungeon.itemInv.pots = this.pots;

                    await ItemAbility.FadeTo(0, 200);

                    DisableorEnableFrameLayouts(false, ItemAbility);

                    if (item.item.Contains("HealthPotion"))
                    {
                        int buff = Obtainbuff(item.item);
                        CharacterHP += buff;
                        await Announcer(string.Format("Healed for {0}", buff.ToString()), true);

                        CharacterHealth.Text = CharacterHP.ToString();
                        CharacterHealth.RelRotateTo(360, 500);
                        await CharacterHealth.ScaleTo(5, 300);

                        await CharacterHealth.ScaleTo(1, 300);
                    }
                    else if (item.item.Contains("MagicPotion"))
                    {
                        int buff = Obtainbuff(item.item);
                        CharacterMP += buff;
                        await Announcer(string.Format("Restored {0} Mana", buff.ToString()), true);

                        CharacterMana.Text = CharacterMP.ToString();
                        CharacterMana.RelRotateTo(360, 500);
                        await CharacterMana.ScaleTo(5, 300);

                        await CharacterMana.ScaleTo(1, 300);
                    }

                    await Announcer("BOSS TURN", false);

                    BossAttack();
                }
            };

            layout.Children.Add(Name);
            layout.Children.Add(extras);
            layout.Children.Add(button);

            frame.Content = layout;
            Items.Children.Add(frame);
        }
Beispiel #3
0
        /*
         * The dodge sequence, this combines all animations, health checks and damage counters.
         *  Param Nothing
         *  Returns Nothing.
         */
        private async void MagicBtn(object sender, EventArgs e)
        {
            if (MagicAbility.IsEnabled != true)
            {
                DisableorEnableFrameLayouts(false, ItemAbility);

                if (!ItemAbility.IsEnabled && !ANNOUNCING && battlesequence)
                {
                    DisableorEnableFrameLayouts(true, MagicAbility);
                    MagicAbility.Opacity = 0;
                    await MagicAbility.FadeTo(1, 200);

                    if (!MagicPage)
                    {
                        MagicPage           = true;
                        ButtonFire.Clicked += async(s, a) =>
                        {
                            if (CheckMana(CharacterMP, 15))
                            {
                                Random rand = new Random();
                                CharacterMP -= 15;
                                MagicDamage  = rand.Next(15, 30 + 1);
                                message      = "Casted Fireball";
                                await MagicAbility.FadeTo(0, 200);

                                DisableorEnableFrameLayouts(false, MagicAbility);
                            }
                            else
                            {
                                DisplayAlert("Error", "Not enough mana", "Close");
                            }
                        };

                        ButtonLightning.Clicked += async(s, a) =>
                        {
                            if (CheckMana(CharacterMP, 30))
                            {
                                Random rand = new Random();
                                CharacterMP -= 30;
                                MagicDamage  = rand.Next(25, 45 + 1);
                                message      = "Casted Lightning";
                                await MagicAbility.FadeTo(0, 200);

                                DisableorEnableFrameLayouts(false, MagicAbility);
                            }
                            else
                            {
                                DisplayAlert("Error", "Not enough mana", "Close");
                            }
                        };

                        ButtonVoid.Clicked += async(s, a) =>
                        {
                            if (CheckMana(CharacterMP, 50))
                            {
                                Random rand = new Random();
                                CharacterMP -= 50;
                                MagicDamage  = rand.Next(35, 55 + 1);
                                message      = "Casted Voidball";
                                await MagicAbility.FadeTo(0, 200);

                                DisableorEnableFrameLayouts(false, MagicAbility);
                            }
                            else
                            {
                                DisplayAlert("Error", "Not enough mana", "Close");
                            }
                        };
                    }


                    while (MagicDamage == 0)
                    {
                        await Task.Delay(25); if (!battlesequence)
                        {
                            return;
                        }
                        if (ItemAbility.IsEnabled)
                        {
                            return;
                        }
                    }
                    await Task.Delay(200);
                    await Announcer(message, true);
                    await Announcer(string.Format("Dealt {0} damage", MagicDamage.ToString()), true);

                    battlesequence = false;
                    BossHP        -= MagicDamage;

                    MagicDamage = 0;
                    message     = "";


                    CharacterMana.Text = CharacterMP.ToString();
                    CharacterMana.RelRotateTo(360, 500);
                    await AttackPixelCharacter();

                    BossHealth.RelRotateTo(360, 500);
                    await BossHealth.ScaleTo(5, 300);

                    await BossHealth.ScaleTo(1, 300);

                    if (BossHP <= 0)
                    {
                        WON = true; await CheckHP();
                    }
                    await Announcer("BOSS TURN", false);

                    BossAttack();
                }
            }
        }