Example #1
0
        public TownMap()
            : base("Town Map", false, true)
        {
            DimBackground = false;
                Description = new TextBlock("Choose where you want to go around town.");
                Entry entryShop = new Entry("My Shop");
                entryShop.Content = new TextBlock("Your shop! Manage your shop's inventory, put items out on display, and, most importantly, open your shop for business.");
                entryShop.Selected += ToMyShop;
                MenuEntries.Add(entryShop);

                Entry entryTownSquare = new Entry("Town Square");
                entryTownSquare.Content = new TextBlock("Hear the latest rumors and gossip about the town.");
                entryTownSquare.Selected += ToTownSquare;
                MenuEntries.Add(entryTownSquare);

                Entry entryTavern = new Entry("Tavern");
                entryTavern.Content = new TextBlock("Find and hire new adventurers to expand your loot-obtaining capabilities.");
                MenuEntries.Add(entryTavern);

                Entry entryDungeon = new Entry("Dungeon");
                entryDungeon.Content = new TextBlock("Delve into the dungeons in search of loot and more loot!");
                entryDungeon.Selected += ToDungeon;
                MenuEntries.Add(entryDungeon);
        }
Example #2
0
 public override void Initialize()
 {
     //item = Item.Generate(GameSession.Random.Next(1, 50), GameSession.Random);
     testBlock = new TextBlock("#MENU_ACCEPT# Generate loot #NL# #MENU_CANCEL# Return to main menu");
 }
Example #3
0
        public override void Draw(GameTime gameTime)
        {
            float entriesHeight = 0;
            foreach (Entry e in entries) {
                if (e.Visible) entriesHeight += e.Height;
            }
            float heightSoFar = 0;
            int left = Resolution.Left;
            int top = Resolution.Top;
            int right = Resolution.Right;
            int bottom = Resolution.Bottom;

            int padding = 8;
            int margin = 16;

            SpriteFont descriptionFont = GameSession.Current.UIFontSmall;
            SpriteFont backFont = GameSession.Current.UIFontSmall;

            int menuOffsetX = (!HasContent && Centered ? Resolution.Right / 2 - Width / 2 : 0);

            Vector2 entriesOrigin = new Vector2(left + margin + menuOffsetX - (Width) * (Centered ? 0 : TransitionPositionSquared), (Resolution.Bottom / 2) - (entriesHeight / 2));
            Rectangle descriptionRect = RectangleHelper.FromVectors(new Vector2(left + Width + margin * 2, bottom - descriptionFont.LineSpacing - margin - padding * 2), new Vector2(right - margin, bottom - margin));
            //descriptionRect.Height = Convert.ToInt32((float)descriptionRect.Height * (1 - TransitionPositionSquared));
            Rectangle cancelRect = RectangleHelper.FromVectors(new Vector2(left + margin + menuOffsetX, bottom - backFont.LineSpacing - margin - padding * 2), new Vector2(left + Width + margin, bottom - margin));
            Vector2 titleOrigin = new Vector2(0, top + margin);
            Rectangle contentRect = RectangleHelper.FromVectors(new Vector2(left + Width + margin * 2, titleOrigin.Y + Font.LineSpacing + margin), new Vector2(right - margin, Description == null ? bottom - margin : descriptionRect.Top - margin));
            contentRect.Height = Convert.ToInt32((float)contentRect.Height * (1 - TransitionPositionSquared));
            titleOrigin.X = (Centered ? Resolution.Right / 2 : contentRect.Center.X);
            if (Centered) cancelRect.X = Resolution.Right / 2 - cancelRect.Width / 2;

            ScreenManager.BeginSpriteBatch();

            if (DimBackground) ScreenManager.SpriteBatch.Draw(GameSession.Current.Pixel, new Rectangle(0, 0, Resolution.Right, Resolution.Bottom), new Color(0f, 0f, 0f, 0.85f) * TransitionAlpha);

            if (Title != null) ScreenManager.SpriteBatch.DrawStringOutlined(Font, Title, titleOrigin, Color.White * TransitionAlpha, Color.Black, 0.0f, new Vector2(Font.MeasureString(Title).X / 2, 0), 1f);

            if (HasContent) {
                ScreenManager.SpriteBatch.Draw(GameSession.Current.Pixel, contentRect, new Color(0.25f, 0.25f, 0.25f) * TransitionAlpha);
                if (Content != null) Content.Draw(ScreenManager.SpriteBatch, GameSession.Current.UIFontSmall, new Vector2(contentRect.X + padding, contentRect.Y + padding), TextBlock.TextAlign.Left, contentRect.Width - padding * 2, TransitionAlpha);
            }

            if (Description != null) {
                ScreenManager.SpriteBatch.Draw(GameSession.Current.Pixel, descriptionRect, new Color(0.35f, 0.35f, 0.35f) * TransitionAlpha);
                Description.Draw(ScreenManager.SpriteBatch, descriptionFont, new Vector2(descriptionRect.X + padding, descriptionRect.Y + padding), TextBlock.TextAlign.Left, descriptionRect.Width - padding * 2, TransitionAlpha);
            }

            if (Cancelable && ShowCancel) {
                ScreenManager.SpriteBatch.Draw(GameSession.Current.Pixel, cancelRect, new Color(0.35f, 0.35f, 0.35f) * TransitionAlpha);
                TextBlock backBlock = new TextBlock("#MENU_CANCEL# Back");
                backBlock.Draw(ScreenManager.SpriteBatch, backFont, new Vector2(cancelRect.X + padding, cancelRect.Y + padding), TextBlock.TextAlign.Left, null, TransitionAlpha);
            }

            for (int i = 0; i < entries.Count; i++) {
                if (entries[i].Visible) {
                    entries[i].Draw(ScreenManager.SpriteBatch, gameTime, entriesOrigin + new Vector2(0, heightSoFar), TransitionAlpha);
                    heightSoFar += entries[i].Height;
                }
            }

            ScreenManager.SpriteBatch.End();
        }
Example #4
0
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            if (input.IsInput(Inputs.MenuDown, ControllingPlayer)) {
                do {
                    selectedIndex++;
                    if (selectedIndex >= entries.Count) selectedIndex -= entries.Count;
                }
                while (!entries[selectedIndex].Enabled);
                GameSession.Current.MenuCursor.Play(GameSession.Current.SoundEffectVolume, 0, 0);
            }

            if (input.IsInput(Inputs.MenuUp, ControllingPlayer)) {
                do {
                    selectedIndex--;
                    if (selectedIndex < 0) selectedIndex += entries.Count;
                }
                while (!entries[selectedIndex].Enabled);
                GameSession.Current.MenuCursor.Play(GameSession.Current.SoundEffectVolume, 0, 0);
            }

            if (entries[selectedIndex].Content != null) Content = entries[selectedIndex].Content;
            else Content = null;

            PlayerIndex playerIndex;
            if (input.IsInput(Inputs.MenuAccept, ControllingPlayer, out playerIndex)) {
                if (entries[selectedIndex].IsCancel) GameSession.Current.MenuCancel.Play(GameSession.Current.SoundEffectVolume, 0, 0);
                else if (entries[selectedIndex].HasSelected) GameSession.Current.MenuAccept.Play(GameSession.Current.SoundEffectVolume, 0, 0);
                else GameSession.Current.MenuDeny.Play(GameSession.Current.SoundEffectVolume, 0, 0);
                OnSelectEntry(selectedIndex, playerIndex);
            }
            if (input.IsInput(Inputs.MenuLeft, ControllingPlayer, out playerIndex)) {
                if (entries[selectedIndex].HasSwipeLeft) GameSession.Current.MenuCursor.Play(GameSession.Current.SoundEffectVolume, 0, 0);
                OnSwipeLeftEntry(selectedIndex, playerIndex);
            }
            if (input.IsInput(Inputs.MenuRight, ControllingPlayer, out playerIndex)) {
                if (entries[selectedIndex].HasSwipeRight) GameSession.Current.MenuCursor.Play(GameSession.Current.SoundEffectVolume, 0, 0);
                OnSwipeRightEntry(selectedIndex, playerIndex);
            }
            if (input.IsInput(Inputs.MenuCancel, ControllingPlayer, out playerIndex) && Cancelable) {
                GameSession.Current.MenuCancel.Play(GameSession.Current.SoundEffectVolume, 0, 0);
                OnCancel(playerIndex);
            }
        }
Example #5
0
        public static void Draw(SpriteBatch spriteBatch, Item item)
        {
            Color color;

            switch (item.Rarity.Name) {
                case Item.RarityLevel.Type.Garbage:
                    color = Color.Gray;
                    break;
                case Item.RarityLevel.Type.Normal:
                    color = Color.White;
                    break;
                case Item.RarityLevel.Type.Magic:
                    color = Color.DarkCyan;
                    break;
                case Item.RarityLevel.Type.Rare:
                    color = Color.Yellow;
                    break;
                case Item.RarityLevel.Type.Legendary:
                    color = Color.DarkViolet;
                    break;
                case Item.RarityLevel.Type.Unique:
                    color = Color.Violet;
                    break;
                default:
                    color = Color.Red;
                    break;
            }
            Vector2 origin = new Vector2(Resolution.Right / 2, 100);

            SpriteFont lootFont = GameSession.Current.UIFontSmall;

            int width = 400;

            origin.X -= width / 2;

            int lineHeight = Convert.ToInt32(lootFont.MeasureString("W").Y * 0.8);
            int padding = 40;
            int line = 0;
            TextBlock name = new TextBlock(item.Name.ToUpper());
            List<string> nameList = name.WrappedText(lootFont, width);
            foreach (string n in nameList) {
                spriteBatch.DrawString(lootFont, n, origin + new Vector2(width / 2, line * lineHeight), color, 0.0f, new Vector2(lootFont.MeasureString(n).X, 0) / 2, 1.0f, SpriteEffects.None, 1.0f);
                line++;
            }
            line++;

            string type = (item.Rarity.Name == Item.RarityLevel.Type.Normal ? "" : item.Rarity.ToString() + " ") + item.Variety.Name;
            spriteBatch.DrawString(lootFont, type, origin + new Vector2(0, line * lineHeight), color, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 1.0f);
            spriteBatch.DrawString(lootFont, item.Variety.Slot.ToString().DeCamelCase(), origin + new Vector2(width, line * lineHeight), Color.White, 0.0f, new Vector2(lootFont.MeasureString(item.Variety.Slot.ToString().DeCamelCase()).X, 0), 1.0f, SpriteEffects.None, 1.0f);
            line += 2;

            // TODO: Condense this shit

            foreach (Item.AttributePair kvp in item.StandardAttributes) {
                string key = kvp.Key.ToString().DeCamelCase();
                string num = ((Item.Attribute.Lookup(kvp.Key).Addition ? "+" : "") + kvp.Value.ToString() + (Item.Attribute.Lookup(kvp.Key).Percentage ? "%" : ""));
                if (Item.Attribute.Lookup(kvp.Key).NonstandardListing == null) {
                    spriteBatch.DrawString(lootFont, key, origin + new Vector2(padding, line * lineHeight), Color.White);
                    spriteBatch.DrawString(lootFont, num, origin + new Vector2(width - padding, line * lineHeight), Color.White, 0.0f, new Vector2(lootFont.MeasureString(num).X, 0), 1.0f, SpriteEffects.None, 1.0f);
                }
                else {
                    string key2 = Item.Attribute.Lookup(kvp.Key).NonstandardListing.Replace("@", num);
                    spriteBatch.DrawString(lootFont, key2, origin + new Vector2(width / 2, line * lineHeight), Color.White, 0.0f, new Vector2(lootFont.MeasureString(key2).X, 0), 1.0f, SpriteEffects.None, 1.0f);
                }
                line++;
            }
            line++;

            foreach (Item.AttributePair kvp in item.NonstandardAttributes) {
                string key = kvp.Key.ToString().DeCamelCase();
                string num = ((Item.Attribute.Lookup(kvp.Key).Addition ? "+" : "") + kvp.Value.ToString() + (Item.Attribute.Lookup(kvp.Key).Percentage ? "%" : ""));
                if (Item.Attribute.Lookup(kvp.Key).NonstandardListing == null) {
                    spriteBatch.DrawString(lootFont, key, origin + new Vector2(padding, line * lineHeight), Color.White);
                    spriteBatch.DrawString(lootFont, num, origin + new Vector2(width - padding, line * lineHeight), Color.White, 0.0f, new Vector2(lootFont.MeasureString(num).X / 2, 0), 1.0f, SpriteEffects.None, 1.0f);
                }
                else {
                    string key2 = Item.Attribute.Lookup(kvp.Key).NonstandardListing.Replace("@", num);
                    spriteBatch.DrawString(lootFont, key2, origin + new Vector2(width / 2, line * lineHeight), Color.White, 0.0f, new Vector2(lootFont.MeasureString(key2).X / 2, 0), 1.0f, SpriteEffects.None, 1.0f);
                }
                line++;
            }
            if (item.NonstandardAttributes.Count > 0) line++;

            string reqLevel = "Required Level: " + item.Level;
            spriteBatch.DrawString(lootFont, reqLevel, origin + new Vector2(width / 2, line * lineHeight), Color.Gray, 0.0f, new Vector2(lootFont.MeasureString(reqLevel).X / 2, 0), 1.0f, SpriteEffects.None, 1.0f);
        }
Example #6
0
 public DialogueBox(TextBlock text, string speaker)
 {
     Text = text;
     Text.FullyTyped = false;
     Speaker = speaker;
 }
Example #7
0
 public DialogueBox(TextBlock text)
 {
     Text = text;
     Text.FullyTyped = false;
 }