Ejemplo n.º 1
0
 /*
  * Contructor for Masterpage, initialize all components and BindingContext
  *
  * PARAM
  * page: encapsulate page
  * user: encapsulate user
  * items: encapsulate items
  * weapon: encapsulate weapon
  * truth: encapsulate truth
  * mainpage: encapsulate mainpage
  * ContentPage: encapsulate display
  *
  * RETURNS Nothing
  */
 public MasterPageViewModel(Page page, UserModel user, InventoryItemsModel items, WeaponInfoModel weapon, logged truth,
                            MasterPageView mainpage, ContentPage display, DungeonView dungeon, ItemInfoModel ItemInv, ShopModel Shop, CharacterInfoModel Characters)
 {
     this.page       = page;
     this.user       = user;
     this.items      = items;
     this.truth      = truth;
     this.weapon     = weapon;
     this.ItemInv    = ItemInv;
     this.Characters = Characters;
     this.mainpage   = mainpage;
     this.dungeon    = dungeon;
     this.Shop       = Shop;
     weapon.SetWeaponAsync(display, UserModel.CheckForstring(items.Localfile, "Equipped:"));
     Tasks_Clicked     = new Command(async() => await TaskNavAsync());
     Inventory_Clicked = new Command(async() => await InventoryNavAsync());
     Dungeon_Clicked   = new Command(async() => await DungeonNavAsync());
     About_Clicked     = new Command(async() => await AboutNavAsync());
     Settings_Clicked  = new Command(async() => await SettingsNavAsync());
     Stats_Clicked     = new Command(async() => await StatsNavAsync());
     Shop_Clicked      = new Command(async() => await ShopNavAsync());
     PageOn            = new PageOpenModel();
     PageOn.Tasks      = true;
     dungeon.Shop      = this.Shop;
 }
        private async Task NavigateToDetailPageAsync(ItemInfoModel args)
        {
            var page = args.SelectedItem.ToString().Replace(" ", string.Empty) + "Page";

            switch (page)
            {
            case "PropertyTriggerPage":
                await Application.Current.MainPage.Navigation.PushAsync(new PropertyTriggerPage());

                break;

            case "DataTriggerPage":
                await Application.Current.MainPage.Navigation.PushAsync(new DataTriggerPage());

                break;

            case "EventTriggerPage":
                await Application.Current.MainPage.Navigation.PushAsync(new EventTriggerPage());

                break;

            case "MultiTriggerPage":
                await Application.Current.MainPage.Navigation.PushAsync(new MultiTriggerPage());

                break;

            case "BehaviorPage":
                await Application.Current.MainPage.Navigation.PushAsync(new BehaviorPage());

                break;
            }
        }
Ejemplo n.º 3
0
 public AccountItemViewModel(ItemInfoModel item)
 {
     _item    = item;
     ItemImg  = PublicMathods.GetImage(item.IconName);
     ItemName = item.ItemName;
     ChangeSelecState(false);
 }
Ejemplo n.º 4
0
        private int Obtainbuff(string item)
        {
            Random rand    = new Random();
            int    minimum = ItemInfoModel.ObtainItemInfo(item, true);
            int    maximum = ItemInfoModel.ObtainItemInfo(item, false);

            return(rand.Next(minimum, maximum + 1));
        }
Ejemplo n.º 5
0
        public void TestItemsCreation()// Test if the items generated at all.
        {
            FirebaseUser client   = new FirebaseUser();
            string       tempFile = Path.GetTempFileName();//create a temporary file

            File.WriteAllText(tempFile, "Weapons:IronDagger,IronBow,\nKeys:0\nGold:500\nEquipped:IronDagger\nItems:");
            ItemInfoModel test = new ItemInfoModel(new InventoryItemsModel(tempFile));

            Assert.Empty(test.pots);//Default value is nothing
        }
Ejemplo n.º 6
0
        public void TestItemsInfo()                   // Test if constructor gets file items
        {
            string tempFile = Path.GetTempFileName(); //create a temporary file

            File.WriteAllText(tempFile, "Weapons:IronDagger,IronBow,\nKeys:0\nGold:500\nEquipped:IronDagger\nItems:HealthPotion,MagicPotion");
            ItemInfoModel test = new ItemInfoModel(new InventoryItemsModel(tempFile));

            Assert.Equal("HealthPotion", test.pots[0].item);
            Assert.Equal("MagicPotion", test.pots[1].item);//Test if values appear
        }
Ejemplo n.º 7
0
        public void TestItemInfoValueIncorrect()
        {
            string tempFile = Path.GetTempFileName();//create a temporary file

            File.WriteAllText(tempFile, "Weapons:IronDagger,IronBow,\nKeys:0\nGold:500\nEquipped:IronDagger\nItems:SOMEWEAPON");
            ItemInfoModel test = new ItemInfoModel(new InventoryItemsModel(tempFile));

            string Incorrect      = test.pots[0].item;
            int    incorrectvalue = ItemInfoModel.ObtainItemValue(Incorrect);

            Assert.Equal(0, incorrectvalue);
        }
Ejemplo n.º 8
0
 /*
  * Constructor for Dungeon
  * Encapsulates UserModel,InventoryItems,WeaponInfo,Stats objects + the bool variable
  *
  * PARAM
  * UserModel:parse UserModel,
  * items: parse items,
  * weapon: parse weapon ,
  * stats: parse stats,
  * tut: true of false if the tutorial display alert is wished to be displayed
  *
  * RETURN Nothing
  */
 public DungeonView(UserModel user, InventoryItemsModel items, WeaponInfoModel weapon, ItemInfoModel itemInv, StatsModel stats, bool tut, DungeonModel realdungeon)
 {
     this.realdungeon = realdungeon;
     this.user        = user;
     this.items       = items;
     this.weapon      = weapon;
     this.stats       = stats;
     this.tut         = tut;
     this.itemInv     = itemInv;
     InitializeComponent();
     InitializeBoss();
 }
Ejemplo n.º 9
0
        public void TestItemInfoStringIncorrect()
        {
            string tempFile = Path.GetTempFileName();//create a temporary file

            File.WriteAllText(tempFile, "Weapons:IronDagger,IronBow,\nKeys:0\nGold:500\nEquipped:IronDagger\nItems:Cool");
            ItemInfoModel test = new ItemInfoModel(new InventoryItemsModel(tempFile));

            string Incorrect  = test.pots[0].item;
            string wrong      = ItemInfoModel.ObtainItemString(Incorrect, false);
            string wrongextra = ItemInfoModel.ObtainItemString(Incorrect, true);

            Assert.Null(wrongextra);
            Assert.Null(wrong);
        }
Ejemplo n.º 10
0
        logged truth = new logged();// Used for telling threads of the application to stop running whenever this is false

        /*
         * Initialize all components and classes for traversing through both details page and masterpage
         * PARAM
         * user: the user data
         * items: the items data
         * RETURNS Nothing
         */
        public AddView(UserModel user, InventoryItemsModel items, StatsModel stats)
        {
            InitializeComponent();
            WeaponInfoModel    weapon      = new WeaponInfoModel(items);
            ItemInfoModel      Invitem     = new ItemInfoModel(items);
            CharacterInfoModel Characters  = new CharacterInfoModel(items, user.LocalLogin);
            ShopModel          Shop        = new ShopModel(items);
            DungeonModel       realDungeon = new DungeonModel();

            Xamarin.Forms.NavigationPage.SetHasNavigationBar(this, false);
            DungeonView dungeon = new DungeonView(user, items, weapon, Invitem, stats, false, realDungeon);

            this.Detail = new NavigationPage(new TasksView(user, items, truth, dungeon, new InventoryView(items, weapon, user, Invitem, Characters))); // Set Detailspage arguments with user information and truth value.
            this.Master = new MasterPageView(Detail, user, items, weapon, truth, dungeon, Invitem, Shop, Characters);                                  // set the masterpage information with user, items, and truth values.
        }
Ejemplo n.º 11
0
        public void TestItemInfoIncorrect()
        {
            string tempFile = Path.GetTempFileName();//create a temporary file

            File.WriteAllText(tempFile, "Weapons:IronDagger,IronBow,\nKeys:0\nGold:500\nEquipped:IronDagger\nItems:SICKONEPALL");
            ItemInfoModel test = new ItemInfoModel(new InventoryItemsModel(tempFile));

            string incorrect = test.pots[0].item;

            int value  = ItemInfoModel.ObtainItemInfo(incorrect, false);
            int value2 = ItemInfoModel.ObtainItemInfo(incorrect, true);

            Assert.Equal(0, value);
            Assert.Equal(0, value2);//Test Wrong values
        }
Ejemplo n.º 12
0
        public void TestItemInfoMaximum()
        {
            string tempFile = Path.GetTempFileName();//create a temporary file

            File.WriteAllText(tempFile, "Weapons:IronDagger,IronBow,\nKeys:0\nGold:500\nEquipped:IronDagger\nItems:HealthPotion,MagicPotion");
            ItemInfoModel test = new ItemInfoModel(new InventoryItemsModel(tempFile));

            string HealthPot = test.pots[0].item;
            string MagicPot  = test.pots[1].item;

            int healthvalue = ItemInfoModel.ObtainItemInfo(HealthPot, false);
            int manavalue   = ItemInfoModel.ObtainItemInfo(MagicPot, false);

            Assert.Equal(40, healthvalue);
            Assert.Equal(60, manavalue);//Test Maximum values
        }
Ejemplo n.º 13
0
 public ShopViewModel(ShopModel items, ItemInfoModel Inv, WeaponInfoModel Weapon, CharacterInfoModel Characters, UserModel user, bool test = false)
 {
     Gold            = UserModel.CheckForstring(items.Inv.Localfile, "Gold:");
     Keys            = UserModel.CheckForstring(items.Inv.Localfile, "Keys:");
     Character       = user.Character;
     this.items      = items;
     this.Inv        = Inv;
     this.Weapon     = Weapon;
     this.Characters = Characters;
     if (!test)
     {
         Volumes = new ObservableCollection <ItemModel>();
         Task.Run(async() =>
         {
             await CreateLists(items, Volumes);
         });
     }
 }
Ejemplo n.º 14
0
 /*
  * Constructor for Inventory
  * PARAM items to be used by the class
  * RETURNS Nothing
  */
 public InventoryView(InventoryItemsModel items, WeaponInfoModel weapon, UserModel user, ItemInfoModel ItemInv, CharacterInfoModel characters)
 {
     tutorial        = false;
     this.items      = items;
     this.weapon     = weapon;
     this.User       = user;
     this.ItemInv    = ItemInv;
     this.pots       = ItemInv.pots;
     this.weapons    = weapon.weapons;
     this.characters = characters.Characters;
     InitializeComponent();
     DisplayInventory();
     DisplayKey();
     DisplayGold();
     DisplayEquipped();
     DisplayNoWep();
     DisplayNoItem();
     Character.Text = User.Character;
 }
Ejemplo n.º 15
0
        public StatsViewModel(ItemInfoModel item, UserModel user, StatsModel stats)
        {
            this.items = item;
            this.user  = user;
            this.stats = stats;
            int Level  = Int32.Parse(UserModel.CheckForstring(stats.Localfile, "LEVEL:"));
            int expInt = Int32.Parse(UserModel.CheckForstring(stats.Localfile, "EXP:"));

            Name         = UserModel.CheckForstring(user.LocalLogin, "Fullname:");
            Character    = user.Character;
            BossDefeated = UserModel.CheckForstring(stats.Localfile, "TOTAL_BOSSES:");
            Keys         = UserModel.CheckForstring(item.items.Localfile, "TOTAL_KEYS:");
            Health       = String.Format("{0}", UserModel.CheckForstring(stats.Localfile, "HEALTH:"));
            Mana         = String.Format("{0}", UserModel.CheckForstring(stats.Localfile, "MANA:"));
            int Remaining = (((Level * 21) + 15) - expInt);

            Levels = UserModel.CheckForstring(stats.Localfile, "LEVEL:");
            Exp    = String.Format("{0}", Remaining.ToString());
        }
Ejemplo n.º 16
0
        public void TestItemInfoString()
        {
            string tempFile = Path.GetTempFileName();//create a temporary file

            File.WriteAllText(tempFile, "Weapons:IronDagger,IronBow,\nKeys:0\nGold:500\nEquipped:IronDagger\nItems:HealthPotion,MagicPotion");
            ItemInfoModel test = new ItemInfoModel(new InventoryItemsModel(tempFile));

            string HealthPot = test.pots[0].item;
            string MagicPot  = test.pots[1].item;

            string healthextra = ItemInfoModel.ObtainItemString(HealthPot, false);
            string health      = ItemInfoModel.ObtainItemString(HealthPot, true);
            string magicextra  = ItemInfoModel.ObtainItemString(MagicPot, false);
            string magic       = ItemInfoModel.ObtainItemString(MagicPot, true);

            Assert.Equal("Heal", health);
            Assert.Equal("HP", healthextra);
            Assert.Equal("Restore", magic);
            Assert.Equal("MP", magicextra);//Test string values
        }
        public NormalPaymentViewModel(NormalPaymentBussiness bussiness)
        {
            _bussiness     = bussiness;
            ItemCollection = new ObservableCollection <AccountItemViewModel>();
            AccountDate    = DateTime.Now;

            _bussiness.ItemsChangedEvent += items =>
            {
                ItemCollection.Clear();
                _currentItem = null;
                items.ForEach(i =>
                {
                    ItemCollection.Add(new AccountItemViewModel(i));
                    ItemCollection.Last().ItemSelectedEvent += item =>
                    {
                        _currentItem = item;
                        foreach (AccountItemViewModel accountItem in ItemCollection.Where(t => t.ItemID != item.ItemID))
                        {
                            accountItem.ChangeSelecState(false);
                        }
                    };
                });
            };
        }
Ejemplo n.º 18
0
 /*
  * Contructor for Masterpage, initialize all components and BindingContext
  *
  * PARAM
  * page: encapsulate page
  * user: encapsulate user
  * items: encapsulate items
  * weapon: encapsulate weapon
  * truth: encapsulate truth
  *
  * RETURNS Nothing
  */
 public MasterPageView(Page page, UserModel user, InventoryItemsModel items, WeaponInfoModel weapon,
                       logged truth, DungeonView dungeon, ItemInfoModel itemInv, ShopModel Shop, CharacterInfoModel Characters)
 {
     InitializeComponent();
     BindingContext = new MasterPageViewModel(page, user, items, weapon, truth, this, this, dungeon, itemInv, Shop, Characters);
 }
Ejemplo n.º 19
0
 public StatsView(ItemInfoModel Inv, UserModel user, StatsModel stats)
 {
     BindingContext = new StatsViewModel(Inv, user, stats);
     InitializeComponent();
 }
Ejemplo n.º 20
0
 public ShopView(ShopModel items, ItemInfoModel Inv, WeaponInfoModel Weapon, CharacterInfoModel Characters, UserModel user)
 {
     InitializeComponent();
     BindingContext = new ShopViewModel(items, Inv, Weapon, Characters, user);
 }
Ejemplo n.º 21
0
        /*
         *
         * This Method is responsible for taking the
         * current selected ItemModel that contains a
         * weapon and creates and displays details of
         * that specific item. You can also equip and sell the weapon.
         *
         * PARAM Nothing
         * RETURNS Nothing
         */
        private void CreateDisplayItem(ItemModel stash, int itemtype, StackLayout layout, List <ItemModel> list)
        {
            int sellcount  = 0;
            var frame      = new Frame();
            var LayoutItem = new StackLayout();

            var item  = new Label();
            var extra = new Label();
            var equip = new Button();
            var sell  = new Button(); // Initialize

            LayoutItem.HorizontalOptions = LayoutOptions.FillAndExpand;
            LayoutItem.Orientation       = StackOrientation.Horizontal;
            LayoutItem.BackgroundColor   = Color.White;

            item.Margin                  = new Thickness(5, 0, 0, 0);
            item.Text                    = stash.item;
            item.FontAttributes          = FontAttributes.Bold;
            item.HorizontalTextAlignment = TextAlignment.Start;
            item.VerticalTextAlignment   = TextAlignment.Center;
            item.TextColor               = Color.FromHex("#212121");


            if (itemtype == 0)
            {
                extra.Text = string.Format("Damage: {0} - {1}",
                                           WeaponInfoModel.ObtainWeaponInfo(stash.item, true).ToString(),
                                           WeaponInfoModel.ObtainWeaponInfo(stash.item, false));
                extra.TextColor = Color.Red;
                extra.FontSize  = 10;
                extra.Margin    = new Thickness(15, 0, 0, 0);
                extra.HorizontalTextAlignment = TextAlignment.Start;
                extra.VerticalTextAlignment   = TextAlignment.Center;

                equip.Text = "equip";
                equip.HorizontalOptions = LayoutOptions.End;
                equip.WidthRequest      = 70;
                equip.HeightRequest     = 50;
                equip.BackgroundColor   = Color.FromHex("#00CC33");
                equip.TextColor         = Color.White;
            }
            else if (itemtype == 1)
            {
                extra.Text = string.Format("{0}: {1} - {2} {3}",
                                           ItemInfoModel.ObtainItemString(stash.item, true),
                                           ItemInfoModel.ObtainItemInfo(stash.item, true),
                                           ItemInfoModel.ObtainItemInfo(stash.item, false),
                                           ItemInfoModel.ObtainItemString(stash.item, false));
                extra.TextColor = Color.Red;
                extra.HorizontalTextAlignment = TextAlignment.Start;
                extra.VerticalTextAlignment   = TextAlignment.Center;
            }
            else
            {
                item.FontSize = 30;
                item.HorizontalTextAlignment = TextAlignment.Center;
                item.HorizontalOptions       = LayoutOptions.CenterAndExpand;
                extra.Text = "";
                equip.Text = "equip";
                equip.HorizontalOptions = LayoutOptions.End;
                equip.WidthRequest      = 70;
                equip.HeightRequest     = 50;
                equip.BackgroundColor   = Color.FromHex("#00CC33");
                equip.TextColor         = Color.White;
            }

            sell.Text = "sell";
            sell.HorizontalOptions = LayoutOptions.EndAndExpand;
            sell.FontSize          = 10;
            sell.WidthRequest      = 50;
            sell.HeightRequest     = 50;
            sell.BackgroundColor   = Color.White;
            sell.TextColor         = Color.Gold;

            equip.Clicked += async(s, a) =>
            {
                if (itemtype == 0)
                {
                    if (await weapon.SetWeaponAsync(this, stash.item)) // If the weapon is not already equipped
                    {
                        await DisplayAlert("Equipped", string.Format("You have equipped: {0}", stash.item), "Close");
                    }
                    DisplayEquipped();
                }
                else if (itemtype == 2)
                {
                    if (Character.Text != stash.item)
                    {
                        UserModel.Rewrite("Character:", stash.item, User.LocalLogin);
                        User.Character = stash.item;
                        Character.Text = stash.item;
                        try
                        {
                            User.UserLogin.Object.Character = stash.item;
                            await User.RewriteDATA();
                        }
                        catch { }
                    }
                    else
                    {
                        await DisplayAlert("Equipped", "Character already equipped", "Close");
                    }
                }
            };

            sell.Clicked += async(s, a) =>
            {
                if (CharactersList.Children.Count == 1 && itemtype == 2)
                {
                    await DisplayAlert("Error", "Cannot delete your only character", "Close");

                    return;
                }

                if (Character.Text == stash.item && itemtype == 2) //If there is no more of the same character then allow to delete.
                {
                    await DisplayAlert("Error", "Please unequip before selling", "Close");

                    return;
                }

                int Goldvalue = 0;
                if (itemtype == 0)
                {
                    Goldvalue = WeaponInfoModel.ObtainWeaponValue(stash.item);
                }
                if (itemtype == 1)
                {
                    Goldvalue = ItemInfoModel.ObtainItemValue(stash.item);
                }
                if (itemtype == 2)
                {
                    Goldvalue = 50;
                }

                int CurrentGold = Int32.Parse(UserModel.CheckForstring(items.Localfile, "Gold:"));
                int TotalGold   = Goldvalue + CurrentGold; // Get your gold and add onto the gold you have recieved.

                sell.Text = Goldvalue.ToString() + " G";
                sellcount++;
                if (sellcount == 2)     // If pressed twice
                {
                    list.Remove(stash); // Remove off list
                    string invetory = "";
                    foreach (ItemModel itemInv in list)
                    {
                        if (!String.IsNullOrEmpty(itemInv.item))
                        {
                            invetory += itemInv.item + ","; // Create string for file
                        }
                    }

                    if (itemtype == 0)
                    {
                        UserModel.Rewrite("Weapons:", invetory, items.Localfile);
                        try
                        {
                            items.Invfile.Object.Weapons = invetory;
                            await items.UpdateInv(); // Replace the number of weapons if the remaining weapons set by the weapons list.
                        }
                        catch { }
                        weapon.weapons = this.weapons;
                    }
                    else if (itemtype == 1)
                    {
                        UserModel.Rewrite("Items:", invetory, items.Localfile);
                        try
                        {
                            items.Invfile.Object.Items = invetory;
                            await items.UpdateInv(); // Replace the number of weapons if the remaining weapons set by the weapons list.
                        }
                        catch { }
                        ItemInv.pots = this.pots;
                    }
                    else
                    {
                        UserModel.Rewrite("Characters:", invetory, items.Localfile);
                        try
                        {
                            items.Invfile.Object.Characters = invetory;
                            await items.UpdateInv(); // Replace the number of weapons if the remaining weapons set by the weapons list.
                        }
                        catch { }
                        ItemInv.pots = this.pots;
                    }
                    UserModel.Rewrite("Gold:", TotalGold.ToString(), items.Localfile);
                    try
                    {
                        items.Invfile.Object.Gold = TotalGold.ToString();
                        await items.UpdateInv(); // Replace the number of weapons if the remaining weapons set by the weapons list.
                    }
                    catch { }

                    DisplayGold(); //Display the gold

                    string equipped = UserModel.CheckForstring(items.Localfile, "Equipped:");
                    if (!UserModel.CheckForstring(items.Localfile, "Weapons:").Contains(equipped) && itemtype == 0) //If the Weapons: section is empty replace with "Not Equipped"
                    {
                        UserModel.Rewrite("Equipped:", "Not Equipped", items.Localfile);
                        try
                        {
                            items.Invfile.Object.Equipped = "Not Equipped";
                            await items.UpdateInv(); // Replace the number of weapons if the remaining weapons set by the weapons list.
                        }
                        catch { }
                        await weapon.SetWeaponAsync(this, "Not Equipped"); //Rewrite and Set weapon to nothing
                    }
                    DisplayEquipped();
                    await Task.Run(async() =>
                    {
                        Animations.CloseStackLayout(LayoutItem, "CloseItem", 60, 250);
                    });                            //Run stacklayout close animation.

                    layout.Children.Remove(frame); //Remove stacklayout
                    DisplayNoWep();                // Check if stacklayout is empty and display "No Weapon"
                    DisplayNoItem();
                    await DisplayAlert("Sold", string.Format("You gained {0} gold", Goldvalue.ToString()), "Close");
                }
            };

            LayoutItem.Children.Add(item);
            LayoutItem.Children.Add(extra);
            LayoutItem.Children.Add(sell);
            if (itemtype == 0 || itemtype == 2)
            {
                LayoutItem.Children.Add(equip);
            }

            frame.Padding     = 3;
            frame.BorderColor = Color.Black;
            frame.Content     = LayoutItem;
            layout.Children.Add(frame); // Add onto itemlist stacklayout
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
0
 private async Task CreateLists(ShopModel items, ObservableCollection <ItemModel> Volumes)
 {
     Volumes.Add(new ItemModel("Title")
     {
         Title = "Weapons", frameOn = false, frameVis = false, titleTrue = true, titleVis = true
     });
     foreach (ItemModel item in items.BuyWeapons)
     {
         if (item.item.Contains("Sold"))
         {
             Volumes.Add(new ItemModel(item.item)
             {
                 notes      = string.Format("{0}", item.item),
                 item       = string.Format("{0} - {1} dmg", WeaponInfoModel.ObtainWeaponInfo(item.item, true), WeaponInfoModel.ObtainWeaponInfo(item.item, false)),
                 texthoz    = TextAlignment.Center,
                 hozopnotes = LayoutOptions.CenterAndExpand,
                 isenabled  = false,
                 isvisible  = false,
                 isvisItem  = false,
                 isenbItem  = false,
                 frameOn    = true,
                 frameVis   = true,
                 titleTrue  = false,
                 titleVis   = false,
                 buy        = "Buy",
             });
         }
         else
         {
             Volumes.Add(new ItemModel(item.item)
             {
                 notes      = string.Format("{0}", item.item),
                 texthoz    = TextAlignment.Start,
                 item       = string.Format("{0} - {1} dmg", WeaponInfoModel.ObtainWeaponInfo(item.item, true), WeaponInfoModel.ObtainWeaponInfo(item.item, false)),
                 isenabled  = true,
                 isvisible  = true,
                 frameOn    = true,
                 frameVis   = true,
                 titleTrue  = false,
                 titleVis   = false,
                 isvisItem  = true,
                 isenbItem  = true,
                 hozopnotes = LayoutOptions.Start,
                 buy        = "Buy",
             });
         }
     }
     Volumes.Add(new ItemModel("Title")
     {
         Title = "Potions", frameOn = false, frameVis = false, titleTrue = true, titleVis = true
     });
     foreach (ItemModel item in items.BuyItem)
     {
         Volumes.Add(new ItemModel(item.item)
         {
             notes   = string.Format("{0}", item.item),
             texthoz = TextAlignment.Start,
             item    = 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)),
             isenabled  = true,
             isvisible  = true,
             frameOn    = true,
             frameVis   = true,
             titleTrue  = false,
             titleVis   = false,
             isvisItem  = true,
             isenbItem  = true,
             hozopnotes = LayoutOptions.Start,
             buy        = "Buy",
         });
     }
     Volumes.Add(new ItemModel("Title")
     {
         Title = "Characters", frameOn = false, frameVis = false, titleTrue = true, titleVis = true
     });
     foreach (ItemModel item in items.BuyCharacter)
     {
         if (item.item.Contains("Sold"))
         {
             Volumes.Add(new ItemModel(item.item)
             {
                 notes      = string.Format("{0}", item.item),
                 item       = string.Format("{0} - {1} dmg", WeaponInfoModel.ObtainWeaponInfo(item.item, true), WeaponInfoModel.ObtainWeaponInfo(item.item, false)),
                 texthoz    = TextAlignment.Center,
                 hozopnotes = LayoutOptions.CenterAndExpand,
                 isenabled  = false,
                 isvisible  = false,
                 isvisItem  = false,
                 isenbItem  = false,
                 frameOn    = true,
                 frameVis   = true,
                 titleTrue  = false,
                 titleVis   = false,
                 buy        = "Buy",
             });
         }
         else
         {
             Volumes.Add(new ItemModel(item.item)
             {
                 notes      = string.Format("{0}", item.item),
                 texthoz    = TextAlignment.Center,
                 item       = "",
                 isenabled  = true,
                 isvisible  = true,
                 frameOn    = true,
                 frameVis   = true,
                 titleTrue  = false,
                 titleVis   = false,
                 isvisItem  = true,
                 isenbItem  = true,
                 hozopnotes = LayoutOptions.CenterAndExpand,
                 buy        = "Buy",
             });
         }
     }
 }
Ejemplo n.º 24
0
        public async System.Threading.Tasks.Task <bool> BuyAsync(InventoryItemsModel items, int typecase, string ChoItem, bool test = false)
        {
            foreach (ItemModel item in Characters.Characters)
            {
                if (ChoItem == item.item)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Already have this Character", "Close");

                    return(false);
                }
            }

            int CurrentGold = CurrentGold = Int32.Parse(UserModel.CheckForstring(items.Localfile, "Gold:"));
            int Price       = 0;
            int TotalGold;

            if (typecase == 0)
            {
                Price = WeaponInfoModel.ObtainWeaponValue(ChoItem);
            }
            else if (typecase == 1)
            {
                Price = ItemInfoModel.ObtainItemValue(ChoItem);
            }
            else
            {
                Price = 50;
            }
            TotalGold = CurrentGold - Price;
            if (CurrentGold - Price >= 0)
            {
                if (typecase == 0)
                {
                    UserModel.AddOntoLine("Weapons:", ChoItem + ",", items.Localfile);
                    try
                    {
                        items.Invfile.Object.Weapons += ChoItem + ",";
                    }catch { }
                    Weapon.Rebuild();
                }
                else if (typecase == 1)
                {
                    UserModel.AddOntoLine("Items:", ChoItem + ",", items.Localfile);
                    try
                    {
                        items.Invfile.Object.Items += ChoItem + ",";
                    }catch { }
                    Inv.Rebuild();
                }
                else
                {
                    UserModel.AddOntoLine("Characters:", ChoItem + ",", items.Localfile);
                    try
                    {
                        items.Invfile.Object.Characters += ChoItem + ",";
                    }
                    catch { }
                    Characters.Rebuild();
                }
                UserModel.Rewrite("Gold:", TotalGold.ToString(), items.Localfile); //Rewrite the gold values
                try
                {
                    items.Invfile.Object.Gold = TotalGold.ToString();
                    await items.UpdateInv();
                }
                catch { }
                Gold = UserModel.CheckForstring(items.Localfile, "Gold:");
                if (!test)
                {
                    await Application.Current.MainPage.DisplayAlert("Success", string.Format("You bought a {0}.", ChoItem), "Close");
                }
                return(true);
            }
            else
            {
                int remainder = CurrentGold - Price;
                remainder = remainder * -1;
                if (!test)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", string.Format("You need {0} more gold to purchase this item", remainder.ToString()), "Close");
                }
                return(false);
            }
        }