Beispiel #1
0
        private bool NewMenuItem(string itemID)
        {//need to fix this...
            MenuItem newItem = new MenuItem();

            //all new records will be give a negative int autoid...
            //when they are updated then sql will generate one for them overiding this set value...
            //it will allow us to give uniqueness to the tempory new records...
            //Before they are updated to the entity and given an autoid...
            //we use a negative number and keep subtracting by 1 for each new item added...
            //This will allow it to alwasy be unique and never interfere with SQL's positive autoid...
            _newMenuItemAutoId = _newMenuItemAutoId - 1;
            newItem.AutoID     = _newMenuItemAutoId;
            newItem.MenuItemID = itemID;
            newItem.CompanyID  = ClientSessionSingleton.Instance.CompanyID;
            //new items will be added to selected item
            newItem.ParentMenuID = SelectedMenuItem.MenuItemID;
            //add it to the repository list
            MenuItemList.Add(newItem);
            _serviceAgent.AddToMenuItemRepository(newItem);

            //add it to the treeviewList
            NestedMenuItem newNestedItem = new NestedMenuItem(newItem);

            newNestedItem.IsValid         = 1;
            newNestedItem.NotValidMessage = "New Record Key Field/s Are Required.";
            SelectedMenuItem.Children.Add(newNestedItem);

            AllowEdit = true;
            Dirty     = false;
            return(true);
        }
Beispiel #2
0
        //MenuItem Object Scope Validation check the entire object for validity...
        private byte MenuItemIsValid(NestedMenuItem item, out string errorMessage)
        {   //validate key
            errorMessage = "";
            if (string.IsNullOrEmpty(item.MenuItemID))
            {
                errorMessage = "ID Is Required.";
                return(1);
            }
            MenuItem     menuItem    = MenuItemList.FirstOrDefault(q => q.AutoID == item.AutoID);
            EntityStates entityState = GetMenuItemState(menuItem);

            if (entityState == EntityStates.Added && MenuItemExists(item.MenuItemID))
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //check cached list for duplicates...
            int count = MenuItemList.Count(q => q.MenuItemID == item.MenuItemID);

            if (count > 1)
            {
                errorMessage = "Item All Ready Exists.";
                return(1);
            }
            //validate Description
            if (string.IsNullOrEmpty(item.Name))
            {
                errorMessage = "Name Is Required.";
                return(1);
            }
            //a value of 2 is pending changes...
            //On Commit we will give it a value of 0...
            return(2);
        }
Beispiel #3
0
        public void AddMenuItem <TDataContext, TUserControl>(string header) where TUserControl : UserControl
        {
            var obj = new MenuItemObject()
            {
                DataContextObject = typeof(TDataContext),
                UserControl       = typeof(TUserControl)
            };

            MenuItemObjectList.Add(obj);

            var item = new MenuItem()
            {
                Header      = header,
                IsCheckable = true,
                IsEnabled   = true
            };

            item.Click += new RoutedEventHandler(ClickEvent);

            Binding menuCheckBinding = new Binding("IsChecked")
            {
                Source = this,
                Mode   = BindingMode.TwoWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };

            BindingOperations.SetBinding(item, MenuItem.IsCheckableProperty, menuCheckBinding);
            MenuItemList.Add(item);
        }
Beispiel #4
0
        protected override async Task <bool> SpeakImplAsync()
        {
            MenuItemList theList = new MenuItemList("Yes", "No");
            int          choice;

            await TextArea.PrintLine();

            await TextArea.PrintLine(TheEvent.ShopName, XleColor.Green);

            await TextArea.PrintLine();

            await TextArea.PrintLine(string.Format(
                                         "Read your fortune for {0} gold?", (int)(6 * TheEvent.CostFactor)));

            choice = await QuickMenu.QuickMenu(theList, 3, 1);

            if (choice == 0)
            {
            }

            await TextArea.PrintLine("Fortune teller is not implemented.");

            await StoreSound(LotaSound.Medium);

            return(true);
        }
Beispiel #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog wSchemaDialog = new OpenFileDialog();
            wSchemaDialog.DefaultExt = "dll";
            wSchemaDialog.CheckFileExists = true;

            wSchemaDialog.Filter = "DLL Files (*.dll;*.exe)|*.dll;*.exe|All Files (*.*)|*.*";
            wSchemaDialog.ShowReadOnly = true;

            MenuItemList wMenuItemList = new MenuItemList();
            
     
            if (wSchemaDialog.ShowDialog() == DialogResult.OK)
            {
                MenuItem wMenuItem = new MenuItem();
                Assembly ass = new Assembly(wSchemaDialog.FileName);
                lblFileName.Text = wSchemaDialog.FileName;
                foreach (AssemblyClass wAssemblyClass in ass.ClassCollections)
                {
                    if (wAssemblyClass.BaseType != null)
                    {
                        if (wAssemblyClass.BaseType.Name.Contains("Form"))
                        {
                            wMenuItem = new MenuItem();
                            wMenuItem.AssemblyInfo = wAssemblyClass.FullyQualifiedName;
                            wMenuItem.FormName = wAssemblyClass.Name;
                            wMenuItemList.Add(wMenuItem);
                        }
                    }
                }

                listBox1.DataSource = wMenuItemList;
            }
        }
Beispiel #6
0
 CartDaoCollection()
 {
     if (usercart == null)
     {
         long Dictionary = new long();
         MenuItemList.Add();
     }
 }
Beispiel #7
0
        private void AddSubItem(MenuItemList item, string name, EventHandler handler = null, Keys shortcutKeys = Keys.None, bool isChecked = false)
        {
            var subSubItem = new MenuItem {
                Name = name, Handler = handler, ShortcutKeys = shortcutKeys, IsChecked = isChecked
            };

            item.Items.Add(subSubItem);
        }
Beispiel #8
0
        public MainPage()
        {
            InitializeComponent();
            menuList = new List <MenuItemList>();
            var profile = new MenuItemList()
            {
                Title = "Profile", Icon = "user.png", TargetType = typeof(ProfilePage)
            };
            var post = new MenuItemList()
            {
                Title = "Posts", Icon = "post.png", TargetType = typeof(PostPage)
            };
            var myCourse = new MenuItemList()
            {
                Title = "My Course", Icon = "mycourse.png", TargetType = typeof(MyCoursePage)
            };
            var grade = new MenuItemList()
            {
                Title = "Grades", Icon = "grade.png", TargetType = typeof(GradePage)
            };
            var upcomingEvent = new MenuItemList()
            {
                Title = "Upcoming Event", Icon = "upcomingevent.png", TargetType = typeof(UpcomingEventPage)
            };
            var campusMap = new MenuItemList()
            {
                Title = "Campus Map", Icon = "location.png", TargetType = typeof(CampusMapPage)
            };
            var schedule = new MenuItemList()
            {
                Title = "Schedule", Icon = "upcomingevent.png", TargetType = typeof(SchedulePage)
            };
            var logout = new MenuItemList()
            {
                Title = "Logout", Icon = "logout.png", TargetType = typeof(LogoutPage)
            };

            menuList.Add(profile);
            menuList.Add(post);
            menuList.Add(myCourse);
            menuList.Add(grade);
            menuList.Add(upcomingEvent);
            menuList.Add(campusMap);
            menuList.Add(schedule);
            menuList.Add(logout);

            menuListView.ItemsSource = menuList;

            Detail = new NavigationPage((Page)Activator.CreateInstance(typeof(PostPage)));
            this.BindingContext = new
            {
                UserName  = "******",
                Logo      = "logo.png",
                UserEmail = "*****@*****.**"
            };
        }
Beispiel #9
0
        private bool Delete(NestedMenuItem item)
        {//deletes are done indenpendently of the repository as a delete will not commit
            //dirty records it will simply just delete the record...
            MenuItem menuItem = MenuItemList.FirstOrDefault(q => q.AutoID == item.AutoID);

            _serviceAgent.DeleteFromMenuItemRepository(menuItem);
            //remove it from the cache repository list
            MenuItemList.Remove(menuItem);
            return(true);
        }
Beispiel #10
0
        public async Task OfferMuseumCoin()
        {
            int          coin = -1;
            MenuItemList menu = new MenuItemList("Yes", "No");

            coin = NextMuseumCoinOffer();

            if (coin == -1)
            {
                return;
            }

            int amount = 50 + (int)(Random.NextDouble() * 20 * Player.Level);

            if (amount > Player.Gold)
            {
                amount /= 2;
            }

            SoundMan.PlaySound(LotaSound.Question);

            await TextArea.PrintLine("Would you like to buy a ");

            await GameControl.WaitAsync(1);

            await TextArea.PrintLine("museum coin for " + amount.ToString() + " gold?");

            await GameControl.WaitAsync(1);

            await TextArea.PrintLine();

            await GameControl.WaitAsync(1);

            int choice = await QuickMenu.QuickMenu(menu, 3, 0);

            if (choice == 0)
            {
                if (Player.Spend(amount))
                {
                    string coinName = Data.ItemList[coin].Name;

                    await TextArea.PrintLine("Use this " + coinName + " well!");

                    Player.Items[coin] += 1;

                    SoundMan.PlaySound(LotaSound.Sale);
                }
                else
                {
                    await TextArea.PrintLine("Not enough gold.");

                    SoundMan.PlaySound(LotaSound.Medium);
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// This function creates a sub menu in the top of the map section and
        /// forces the player to chose an option from the list provided.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="choice"></param>
        /// <param name="items">A MenuItemList collection of menu items</param>
        /// <returns>The choice the user made.</returns>
        public Task <int> SubMenu(string title, int choice, MenuItemList items, Color?backColor = null)
        {
            SubMenu menu = new SubMenu();

            menu.title     = title;
            menu.value     = choice;
            menu.theList   = items;
            menu.BackColor = backColor ?? XleColor.Black;

            return(RunSubMenu(menu));
        }
Beispiel #12
0
        protected override async Task <MagicSpell> RunMagicMenu(IList <MagicSpell> magics)
        {
            await TextArea.PrintLine();

            await TextArea.PrintLine();

            await TextArea.PrintLine("Use which magic?", XleColor.Purple);

            await TextArea.PrintLine();

            bool hasFlames = magics.Contains(Data.MagicSpells[1]);
            bool hasBolts  = magics.Contains(Data.MagicSpells[2]);

            int  defaultValue = 0;
            int  otherStart   = 2 - (hasBolts ? 0 : 1) - (hasFlames ? 0 : 1);
            bool anyOthers    = otherStart < magics.Count;

            if (hasFlames == false)
            {
                defaultValue = 1;

                if (hasBolts == false)
                {
                    defaultValue = 2;
                }
            }

            var menu = new MenuItemList("Flame", "Bolt", anyOthers ? "Other" : "Nothing");

            int choice = await QuickMenu.QuickMenu(menu, 2, defaultValue,
                                                   XleColor.Purple, XleColor.White);

            if (choice == 0)
            {
                return(Data.MagicSpells[1]);
            }
            else if (choice == 1)
            {
                return(Data.MagicSpells[2]);
            }
            else
            {
                if (anyOthers == false)
                {
                    return(null);
                }

                await TextArea.PrintLine(" - select above", XleColor.White);

                await TextArea.PrintLine();

                return(await MagicMenu(magics.Skip(otherStart).ToList()));
            }
        }
Beispiel #13
0
        private async Task OfferMail()
        {
            Town twn = GameState.Map as Town;

            if (Player.Items[MailItemId] > 0)
            {
                return;
            }
            if (twn == null)
            {
                return;
            }
            if (twn.Mail.Count == 0)
            {
                return;
            }

            int target = SelectDeliveryTarget(twn);

            if (target < 0)
            {
                return;
            }

            SoundMan.PlaySound(LotaSound.Question);

            await TextArea.PrintLine();

            await TextArea.PrintLine("Would you like to earn some gold?");

            MenuItemList menu = new MenuItemList("Yes", "No");

            int choice = await QuickMenu(menu, 2);

            if (choice == 0)
            {
                Player.Items[MailItemId] = 1;
                Player.mailTown          = target;

                await TextArea.PrintLine();

                await TextArea.PrintLine("Here's some mail to");

                await TextArea.PrintLine("deliver to " + Data.MapList[target].Name + ".");

                await TextArea.PrintLine();

                await TextArea.PrintLine("        Press Key to Continue");

                await WaitForKey();
            }
        }
Beispiel #14
0
        static void LoadRecursive(TreeNode pTreeNodeRoot, MenuItemList pMenuItemChilds)
        {
            TreeNode wTreeNodeChild = null;
            foreach (MenuItem wMenuItem in pMenuItemChilds)
            {
                wTreeNodeChild = new TreeNode(wMenuItem.DisplayName);
                wTreeNodeChild.Tag = wMenuItem;

                pTreeNodeRoot.Nodes.Add(wTreeNodeChild);

                LoadRecursive(wTreeNodeChild, wMenuItem.MenuItemList);
            }
        }
Beispiel #15
0
 public override void SelectItemChanged()
 {
     if (MenuSelectIndex < 0)
     {
         MenuSelectIndex = 0;
     }
     else if (MenuSelectIndex > MenuItemList.Count - 1)
     {
         MenuSelectIndex = MenuItemList.Count - 1;
     }
     LastSelectTime = TimeMain;
     MenuItemList.ForEach(x => x.Selected = false);
     MenuItemList[MenuSelectIndex].Select();
 }
Beispiel #16
0
        public void SaveCommand()
        {
            MenuItem menuItem = MenuItemList.FirstOrDefault(q => q.AutoID == SelectedMenuItem.AutoID);

            if (GetMenuItemState(menuItem) != EntityStates.Detached)
            {
                if (Update(SelectedMenuItem, "", ""))
                {
                    Commit();
                }
                else//if and where we have a hole in our allowcommit logic...
                {
                    NotifyMessage("Save Failed Check Your Work And Try Again...");
                }
            }
        }
Beispiel #17
0
        protected async Task <MagicSpell> MagicMenu(IList <MagicSpell> magics)
        {
            MenuItemList menu = new MenuItemList("Nothing");

            menu.AddRange(magics.Select(x => x.Name));

            int choice = await SubMenu.SubMenu("Pick magic", 0, menu);

            if (choice == 0)
            {
                await TextArea.PrintLine("Select no magic.", XleColor.White);

                return(null);
            }

            return(magics[choice - 1]);
        }
Beispiel #18
0
        public async Task <WeaponItem> PickWeapon(GameState state, WeaponItem defaultItem, Color?backColor = null)
        {
            MenuItemList theList = new MenuItemList();

            theList.Add("Nothing");
            theList.AddRange(state.Player.Weapons.Select(x => x.NameWithQuality(Data)));

            int sel = await subMenu.SubMenu("Pick Weapon", state.Player.Weapons.IndexOf(defaultItem) + 1,
                                            theList, backColor ?? XleColor.Black);

            if (sel == 0)
            {
                return(null);
            }
            else
            {
                return(state.Player.Weapons[sel - 1]);
            }
        }
Beispiel #19
0
        public async Task <int> ChooseItem()
        {
            await TextArea.PrintLine("-choose above", XleColor.Cyan);

            MenuItemList theList = new MenuItemList();
            int          value   = 0;

            theList.Add("Nothing");

            foreach (int i in from kvp in Data.ItemList
                     where Player.Items[kvp.Key] > 0 &&
                     Data.MagicSpells.Values.All(
                         x => x.ItemID != kvp.Key)
                     select kvp.Key)
            {
                string itemName = Data.ItemList[i].Name;

                if (itemName.Contains("coin"))
                {
                    continue;
                }

                /*
                 * if (i == 9)			// mail
                 * {
                 *  itemName = XleCore.GetMapName(state.Player.mailTown) + " " + itemName;
                 * }*/

                if (i <= Player.Hold)
                {
                    value++;
                }

                theList.Add(itemName);
            }

            var index = await SubMenu.SubMenu("Hold Item", value, theList);

            var selectedName = theList[index];

            return(Data.ItemList.Where(x => x.Value.Name == selectedName)
                   .Select(x => x.Key).First());
        }
Beispiel #20
0
        public List <MenuItemList> CreateMenuDataStructure(Layers layers, EventHandler handler1, EventHandler handler2, EventHandler handler3, EventHandler handler4, EventHandler handler5)
        {
            var menuItems = new List <MenuItemList>();

            var subItem = new MenuItemList {
                Name = "&File", Items = new List <MenuItem>()
            };

            AddSubItem(subItem, "New", handler1);
            AddSubItem(subItem, "Open", handler2);
            AddSubItem(subItem, "Save", handler3, (Keys)Shortcut.CtrlS);
            AddSubItem(subItem, "-");
            AddSubItem(subItem, "Exit", handler4, (Keys)Shortcut.AltF4);
            menuItems.Add(subItem);

            subItem = new MenuItemList {
                Name = "&Layers", Items = new List <MenuItem>()
            };
            int cnt = 0;

            foreach (string layer in layers.GetLayers())
            {
                AddSubItem(subItem, layer, handler5, Keys.None, cnt == 0);
                cnt++;
            }
            menuItems.Add(subItem);

            subItem = new MenuItemList {
                Name = "&Help", Items = new List <MenuItem>()
            };
            var subSubItem = new MenuItem {
                Name = "About"
            };

            subItem.Items.Add(subSubItem);
            menuItems.Add(subItem);

            return(menuItems);
        }
Beispiel #21
0
        public override async Task Execute()
        {
            MenuItemList theList = new MenuItemList("1", "2", "3", "4", "5");

            await TextArea.PrintLine();

            await TextArea.PrintLine("** Change gamespeed **", XleColor.Yellow);

            await TextArea.PrintLine("    (1 is fastest)", XleColor.Yellow);

            await TextArea.PrintLine();

            Player.Gamespeed = 1 + await QuickMenu.QuickMenu(theList, 2, Player.Gamespeed - 1);

            await TextArea.Print("Gamespeed is: ", XleColor.Yellow);

            await TextArea.PrintLine(Player.Gamespeed.ToString(), XleColor.White);

            systemState.Factory.SetGameSpeed(GameState, Player.Gamespeed);

            await gameControl.WaitAsync(GameState.GameSpeed.AfterSetGamespeedTime);
        }
Beispiel #22
0
        //Object.Property Scope Validation...
        private bool MenuItemIsValid(NestedMenuItem item, _menuItemValidationProperties validationProperties, out string errorMessage)
        {
            errorMessage = "";
            switch (validationProperties)
            {
            case _menuItemValidationProperties.MenuItemID:
                //validate key
                if (string.IsNullOrEmpty(item.MenuItemID))
                {
                    errorMessage = "ID Is Required.";
                    return(false);
                }
                MenuItem     menuItem    = MenuItemList.FirstOrDefault(q => q.AutoID == item.AutoID);
                EntityStates entityState = GetMenuItemState(menuItem);
                if (entityState == EntityStates.Added && MenuItemExists(item.MenuItemID))
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                //check cached list for duplicates...
                int count = MenuItemList.Count(q => q.MenuItemID == item.MenuItemID);
                if (count > 1)
                {
                    errorMessage = "Item All Ready Exists...";
                    return(false);
                }
                break;

            case _menuItemValidationProperties.Name:
                //validate Description
                if (string.IsNullOrEmpty(item.Name))
                {
                    errorMessage = "Description Is Required.";
                    return(false);
                }
                break;
            }
            return(true);
        }
Beispiel #23
0
        //udpate merely updates the repository a commit is required
        //to commit it to the db...
        private bool Update(NestedMenuItem item, string propertyName, object propertyValue)
        {//get the menuItem from the Repository List...
            MenuItem menuItem = MenuItemList.FirstOrDefault(q => q.AutoID == item.AutoID);

            //Set the edited field when present...
            if (!string.IsNullOrEmpty(propertyName))
            {
                menuItem.SetPropertyValue(propertyName, propertyValue);
            }
            //update the repository with the field change...
            _serviceAgent.UpdateMenuItemRepository(menuItem);
            Dirty = true;
            if (CommitIsAllowed())
            {
                AllowCommit = true;
            }
            else
            {
                AllowCommit = false;
            }
            return(AllowCommit);
        }
Beispiel #24
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog wSchemaDialog = new OpenFileDialog();

            wSchemaDialog.DefaultExt      = "dll";
            wSchemaDialog.CheckFileExists = true;

            wSchemaDialog.Filter       = FileFunctions.OpenFilterEnums.OpenAssembliesFilter;
            wSchemaDialog.ShowReadOnly = true;

            MenuItemList wMenuItemList = new MenuItemList();

            if (wSchemaDialog.ShowDialog() == DialogResult.OK)
            {
                Fwk.UI.Controls.Menu.Tree.MenuItem wMenuItem = new Fwk.UI.Controls.Menu.Tree.MenuItem();
                Assembly wAssembly = new Assembly(wSchemaDialog.FileName);
                lblFileName.Text = wSchemaDialog.FileName;

                foreach (AssemblyClass wAssemblyClass in wAssembly.ClassCollections)
                {
                    if (wAssemblyClass.BaseType != null)
                    {
                        foreach (string filter in _BaseClassNameFilter)
                        {
                            if (wAssemblyClass.BaseType.Name.Contains(filter))
                            {
                                wMenuItem = new Fwk.UI.Controls.Menu.Tree.MenuItem();
                                wMenuItem.AssemblyInfo = wAssemblyClass.FullyQualifiedName;

                                wMenuItemList.Add(wMenuItem);
                            }
                        }
                    }
                }

                listBox1.DataSource = wMenuItemList;
            }
        }
Beispiel #25
0
 private void ResetTreeTempFields(NestedMenuItem parent)
 {
     foreach (NestedMenuItem child in parent.Children)
     {
         child.IsValid         = 0;
         child.NotValidMessage = "";
         //autoID is set a negative value until it is seeded from the db...
         if (child.AutoID < 0)
         {
             //locate the record to fetch the seeded autoid value...
             MenuItem menuItem = MenuItemList.FirstOrDefault(q => q.MenuItemID == child.MenuItemID &&
                                                             q.CompanyID == ClientSessionSingleton.Instance.CompanyID);
             child.AutoID = menuItem.AutoID;
         }
         //if it is selected we need to modify SelectedMenuItem as well...
         if (child.IsSelected == true)
         {
             SelectedMenuItem.IsValid         = 0;
             SelectedMenuItem.NotValidMessage = "";
         }
         ResetTreeTempFields(child);
     }
 }
Beispiel #26
0
        protected override async Task <bool> SpeakImplAsync()
        {
            MenuItemList theList = new MenuItemList("Buy", "Sell", "Neither");

            Title = TheEvent.ShopName;

            InitializeWindows();

            TextArea.Clear();
            int choice = await QuickMenu(theList, 2, 0);

            await Wait(1);

            if (choice == 0)
            {
                await BuyItem();
            }
            else if (choice == 1)               // sell item
            {
                await SellItem();
            }

            return(true);
        }
 public MenuItemCollection(IEnumerable<MenuItem> items)
 {
     _menuItems = new MenuItemList(items);
 }
Beispiel #28
0
        private async Task SpeakToMonster()
        {
            await TextArea.PrintLine();

            if (!Encounters.IsMonsterFriendly)
            {
                await TextArea.PrintLine();

                await TextArea.PrintLine("The " + Encounters.MonsterName + " does not reply.");

                await GameControl.WaitAsync(250);

                return;
            }

            const int    talkTypes = 5;
            int          type;
            int          qual = Random.Next(5);
            int          cost = 0;
            int          item = 0;
            MenuItemList menu = new MenuItemList("Yes", "No");

            Color qcolor = XleColor.White;

            string[] quality = new string[5] {
                "a Well Crafted", "a Slightly Used", "a Sparkling New", "a Wonderful", "an Awesome"
            };

            do
            {
                type = Random.Next(talkTypes) + 1;
            } while (Player.MaxHP == Player.HP && type == 4);

            string name = "";

            switch (type)
            {
            case 1:             // buy armor
            case 2:             // buy weapon

                await TextArea.Print("Do you want to buy ", XleColor.Cyan);

                await TextArea.Print(quality[qual], XleColor.White);

                await TextArea.PrintLine();

                if (type == 1)
                {
                    item = Random.Next(4) + 1;
                    cost = (int)(Data.ArmorCost(item, qual) * (Random.NextDouble() * 0.6 + 0.6));
                    name = Data.ArmorList[item].Name;
                }
                else if (type == 2)
                {
                    item = Random.Next(7) + 1;
                    cost = (int)(Data.WeaponCost(item, qual) * (Random.NextDouble() * 0.6 + 0.6));
                    name = Data.WeaponList[item].Name;
                }

                await TextArea.Print(name, XleColor.White);

                await TextArea.Print(" for ", XleColor.Cyan);

                await TextArea.Print(cost.ToString(), XleColor.White);

                await TextArea.Print(" Gold?", XleColor.Cyan);

                await TextArea.PrintLine();

                qcolor = XleColor.Cyan;

                break;

            case 3:                     // buy food

                item = Random.Next(21) + 20;
                cost = (int)(item * (Random.NextDouble() * 0.4 + 0.8));

                await TextArea.Print("Do you want to buy ", XleColor.Green);

                await TextArea.Print(item.ToString(), XleColor.Yellow);

                await TextArea.PrintLine();

                // line 2
                await TextArea.Print("Days of food for ", XleColor.Green);

                await TextArea.Print(cost.ToString(), XleColor.Yellow);

                await TextArea.Print(" gold?", XleColor.Green);

                await TextArea.PrintLine();

                qcolor = XleColor.Green;

                break;

            case 4:                     // buy hp

                item = Random.Next(Player.MaxHP / 4) + 20;

                if (item > (Player.MaxHP - Player.HP))
                {
                    item = (Player.MaxHP - Player.HP);
                }

                cost = (int)(item * (Random.NextDouble() * 0.15 + 0.75));

                await TextArea.Print("Do you want to buy a potion worth ", XleColor.Green);

                await TextArea.PrintLine();

                // line 2
                await TextArea.Print(item.ToString(), XleColor.Yellow);

                await TextArea.Print(" Hit Points for ", XleColor.Green);

                await TextArea.Print(cost.ToString(), XleColor.Yellow);

                await TextArea.Print(" gold?", XleColor.Green);

                await TextArea.PrintLine();

                qcolor = XleColor.Green;

                break;

            default:
            case 5:                     // buy museum coin
                MuseumCoinSale.ResetCoinOffers();
                await MuseumCoinSale.OfferMuseumCoin();

                break;
            }

            if (type != 5)
            {
                await TextArea.PrintLine();

                int choice = await QuickMenu.QuickMenu(menu, 3, 0, qcolor);

                if (choice == 0)
                {
                    if (Player.Spend(cost))
                    {
                        SoundMan.PlaySound(LotaSound.Sale);

                        await TextArea.PrintLine();

                        await TextArea.PrintLine("Purchase Completed.");

                        Color clr2 = XleColor.White;

                        switch (type)
                        {
                        case 1:
                            Player.AddArmor(item, qual);

                            break;

                        case 2:
                            Player.AddWeapon(item, qual);

                            break;

                        case 3:
                            Player.Food += item;
                            clr2         = XleColor.Green;

                            break;

                        case 4:
                            Player.HP += item;
                            clr2       = XleColor.Green;

                            break;

                        case 5:
                            break;
                        }

                        await GameControl.FlashHPWhileSound(clr2);
                    }
                    else
                    {
                        GameControl.PlaySound(LotaSound.Medium);

                        await TextArea.PrintLine();

                        await TextArea.PrintLine("You don't have enough gold...");
                    }
                }
                else
                {
                    GameControl.PlaySound(LotaSound.Medium);

                    await TextArea.PrintLine();

                    if (1 + Random.Next(2) == 1)
                    {
                        await TextArea.PrintLine("Maybe Later...");
                    }
                    else
                    {
                        await TextArea.PrintLine("You passed up a good deal!");
                    }
                }
            }

            Encounters.CancelEncounter();
        }
Beispiel #29
0
        public async Task HitMonster(int dam)
        {
            await TextArea.Print("Enemy hit by blow of ", XleColor.White);

            await TextArea.Print(dam.ToString(), XleColor.Cyan);

            await TextArea.Print(".", XleColor.White);

            await TextArea.PrintLine();

            await GameControl.WaitAsync(250 + 100 *Player.Gamespeed, keyBreak : true);

            currentMonst[monstCount - 1].HP -= dam;

            if (KilledOne())
            {
                await GameControl.WaitAsync(250);

                SoundMan.PlaySound(LotaSound.EnemyDie);

                await TextArea.PrintLine();

                await TextArea.PrintLine("the " + MonsterName + " dies.");

                int  gold, food;
                bool finished = FinishedCombat(out gold, out food);

                await GameControl.WaitAsync(250 + 150 *Player.Gamespeed);

                if (finished)
                {
                    await TextArea.PrintLine();

                    if (food > 0)
                    {
                        MenuItemList menu = new MenuItemList("Yes", "No");
                        int          choice;

                        await TextArea.PrintLine("Would you like to use the");

                        await TextArea.PrintLine(MonsterName + "'s flesh for food?");

                        await TextArea.PrintLine();

                        choice = await QuickMenu.QuickMenu(menu, 3, 0);

                        if (choice == 1)
                        {
                            food = 0;
                        }
                        else
                        {
                            await TextArea.Print("You gain ", XleColor.White);

                            await TextArea.Print(food.ToString(), XleColor.Green);

                            await TextArea.Print(" days of food.", XleColor.White);

                            await TextArea.PrintLine();

                            Player.Food += food;
                        }
                    }


                    if (gold < 0)
                    {
                        // gain weapon or armor
                    }
                    else if (gold > 0)
                    {
                        await TextArea.Print("You find ", XleColor.White);

                        await TextArea.Print(gold.ToString(), XleColor.Yellow);

                        await TextArea.Print(" gold.", XleColor.White);

                        await TextArea.PrintLine();

                        Player.Gold += gold;
                    }

                    await GameControl.WaitAsync(400 + 100 *Player.Gamespeed);
                }
            }
        }
Beispiel #30
0
        private async Task BuyItem()
        {
            itemsPrompt.Text = "Items               Prices";

            int[] itemList  = new int[16];
            int[] qualList  = new int[16];
            int[] priceList = new int[16];

            FillItems(Player.TimeQuality, itemList, qualList, priceList);

            await StoreSound(LotaSound.Sale);

            int count = 0;

            for (int i = 1; i < 16 && itemList[i] > 0; i++)
            {
                count = i + 1;
                var name  = ItemName(itemList[i], qualList[i]);
                var price = priceList[i];

                AddItemToDisplay(i, name, price);
                await Wait(1);
            }

            MenuItemList theList2 = new MenuItemList();

            for (int k = 0; k < count; k++)
            {
                theList2.Add(k.ToString());
            }

            await TextArea.PrintLine();

            await TextArea.PrintLine("Make choice (hit 0 to cancel)");

            await TextArea.PrintLine();

            int choice = await QuickMenu(theList2, 2, 0);

            if (choice == 0)
            {
                await TextArea.PrintLine();

                await TextArea.PrintLine("Nothing purchased");

                await TextArea.PrintLine();

                await StoreSound(LotaSound.Medium);
            }
            else if (Player.Spend(priceList[choice]))
            {
                // spend the cash, if they have it
                if (AddItem(Player, itemList[choice], qualList[choice]))
                {
                    await TextArea.PrintLine(ItemName(itemList[choice], qualList[choice]) + " purchased.");

                    await TextArea.PrintLine();

                    await StoreSound(LotaSound.Sale);
                }
                else
                {
                    Player.Gold += priceList[choice];
                    await TextArea.PrintLine();

                    await TextArea.PrintLine();

                    await TextArea.PrintLine();

                    await TextArea.PrintLine("No purchase.  You're");

                    await TextArea.PrintLine("carrying too much.");
                }
            }
            else
            {
                await TextArea.PrintLine("You're short on gold.");
                await StoreSound(LotaSound.Medium);
            }
        }
Beispiel #31
0
 public ContextMenu()
 {
     Items           = new MenuItemList();
     BackgroundBrush = Color.Silver;
 }
Beispiel #32
0
        protected override async Task <bool> SpeakImplAsync()
        {
            int choice;

            robbing = false;

            Screen.ClearWindows();

            Title = "Convenience Bank";

            var promptWindow = new TextWindow();

            promptWindow.Location = new Point(14, 3);
            promptWindow.WriteLine("Our Services");
            promptWindow.WriteLine("---------------");

            var optionsWindow = new TextWindow();

            optionsWindow.Location = new Point(10, 7);

            optionsWindow.WriteLine("1.  Deposit Funds");
            optionsWindow.WriteLine();
            optionsWindow.WriteLine("2.  Withdraw Funds");
            optionsWindow.WriteLine();
            optionsWindow.WriteLine("3.  Balance Inquiry");

            Screen.AddWindow(promptWindow);
            Screen.AddWindow(optionsWindow);

            await TextArea.PrintLine();

            await TextArea.PrintLine();

            await TextArea.PrintLine("Make choice (Hit 0 to cancel)");

            await TextArea.PrintLine();

            MenuItemList theList = new MenuItemList("0", "1", "2", "3");

            choice = await QuickMenuService.QuickMenu(theList, 2, 0);

            switch (choice)
            {
            case 1:
                await MakeDeposit();

                break;

            case 2:
                await MakeWithdrawal();

                break;

            case 3:
                await PrintBalance();

                break;
            }


            return(true);
        }
Beispiel #33
0
        protected override async Task <bool> SpeakImplAsync()
        {
            int          choice    = 0;
            int          raftCost  = (int)(400 * TheEvent.CostFactor);
            int          gearCost  = (int)(50 * TheEvent.CostFactor);
            MenuItemList theList   = new MenuItemList("Yes", "No");
            bool         skipRaft  = false;
            bool         offerCoin = false;

            if (IsLoanOverdue())
            {
                await StoreDeclinePlayer();

                return(true);
            }
            // check to see if there are any rafts near the raft drop point
            skipRaft = CheckForNearbyRaft(skipRaft);

            await TextArea.PrintLine();

            await TextArea.PrintLine("** " + TheEvent.ShopName + " **", XleColor.Yellow);

            await TextArea.PrintLine();

            if (skipRaft == false)
            {
                await TextArea.PrintLine("Want to buy a raft for " + raftCost.ToString() + " gold?");

                choice = await QuickMenu.QuickMenu(theList, 3, 1);

                if (choice == 0)
                {
                    // Purchase raft
                    if (Player.Spend(raftCost))
                    {
                        Player.Rafts.Add(new RaftData(TheEvent.BuyRaftPt.X, TheEvent.BuyRaftPt.Y, TheEvent.BuyRaftMap));

                        await TextArea.PrintLine("Raft purchased.");

                        SoundMan.PlaySound(LotaSound.Sale);
                        await GameControl.WaitAsync(1000);

                        await TextArea.PrintLine("Board raft outside.");

                        offerCoin = true;
                    }
                    else
                    {
                        await TextArea.PrintLine("Not enough gold.");

                        SoundMan.PlaySound(LotaSound.Medium);
                        await GameControl.WaitAsync(750);
                    }
                }
            }

            if (skipRaft == true || choice == 1)
            {
                await TextArea.PrintLine("How about some climbing gear");

                await TextArea.PrintLine("for " + gearCost.ToString() + " gold?");

                await TextArea.PrintLine();

                choice = await QuickMenu.QuickMenu(theList, 3, 1);

                if (choice == 0)
                {
                    if (Player.Spend(gearCost))
                    {
                        await TextArea.PrintLine("Climbing gear purchased.");

                        Player.Items[ClimbingGearItemId] += 1;
                        offerCoin = true;

                        SoundMan.PlaySound(LotaSound.Sale);
                    }
                    else
                    {
                        await TextArea.PrintLine("Not enough gold.");

                        SoundMan.PlaySound(LotaSound.Medium);
                    }
                }
                else if (choice == 1)
                {
                    await TextArea.PrintLine();

                    await TextArea.PrintLine("Nothing Purchased.");

                    SoundMan.PlaySound(LotaSound.Medium);
                }

                await GameControl.WaitAsync(750);
            }

            if (offerCoin)
            {
                await CheckOfferMuseumCoin(Player);
            }

            return(true);
        }