Exemple #1
0
        public void sell_item(Player pl)
        {
            int item_gold_value = items_to_sell[selected_item_index].get_my_gold_value();
            int sale_value      = (int)Math.Max(item_gold_value * .93, item_gold_value - 500);

            if (items_to_sell[selected_item_index] is Potion)
            {
                Potion p  = (Potion)items_to_sell[selected_item_index];
                Potion p2 = new Potion(p.get_my_IDno(), p.get_my_gold_value(), p.get_my_name(), p);
                p2.set_quantity(1);
                p.adjust_quantity(-1);
                if (p.get_my_quantity() == 0)
                {
                    items_to_sell.RemoveAt(selected_item_index);
                }

                bool stacked = false;
                for (int i = 0; i < sold_items.Count; i++)
                {
                    if (sold_items[i] is Potion)
                    {
                        Potion p3 = (Potion)sold_items[i];
                        if (p3.get_my_IDno() == p2.get_my_IDno())
                        {
                            stacked = true;
                            p3.adjust_quantity(1);
                        }
                    }
                }

                if (!stacked)
                {
                    sold_items.Add(p2);
                }
            }
            else
            {
                sold_items.Add(items_to_sell[selected_item_index]);
                items_to_sell.RemoveAt(selected_item_index);
            }
            pl.add_gold(sale_value);
        }
Exemple #2
0
        public void draw_my_text(ref SpriteBatch sBatch)
        {
            Vector2 prompt_position = new Vector2(my_grey_foreground.X + 5, my_grey_foreground.Y + 5);
            string  prompt_prompt   = "Apply " + p.get_my_name() + ":";

            sBatch.DrawString(text_font, prompt_prompt, prompt_position, my_text_color);

            Vector2 cancel_position = new Vector2(cancel_zone.X + (cancel_zone.Width - text_font.MeasureString(cancel_prompt).X) / 2, cancel_zone.Y + 5);

            sBatch.DrawString(text_font, cancel_prompt, cancel_position, my_text_color);

            Vector2 ingest_position = new Vector2(ingest_zone.X + (ingest_zone.Width - text_font.MeasureString(ingest_prompt).X) / 2, ingest_zone.Y + 5);

            sBatch.DrawString(text_font, ingest_prompt, ingest_position, my_text_color);

            if (p.get_type() == Potion.Potion_Type.Repair)
            {
                Vector2 over_prompt_position  = new Vector2(over_armor_tab.X + 2, over_armor_tab.Y);
                Vector2 under_prompt_position = new Vector2(under_armor_tab.X + 2, under_armor_tab.Y);
                sBatch.DrawString(text_font, over_tab_prompt, over_prompt_position, my_orange_color);
                sBatch.DrawString(text_font, under_tab_prompt, under_prompt_position, my_m_yellow_color);
            }

            if (player_oa != null)
            {
                draw_armor_integrity_ratio(sBatch, player_oa, my_orange_color, true);
            }

            if (player_ua != null)
            {
                draw_armor_integrity_ratio(sBatch, player_ua, my_m_yellow_color, false);
            }

            if (player_hlm != null)
            {
                draw_armor_integrity_ratio(sBatch, player_hlm, my_orange_color, true);
            }
        }
Exemple #3
0
        public void buy_item(Player pl)
        {
            int item_gold_value;

            switch (im_shopping_for)
            {
            case Shopping_Mode.Sell:
                sell_item(pl);
                break;

            case Shopping_Mode.Scrolls:
                item_gold_value = scrolls_in_stock[selected_item_index].get_my_gold_value();
                if (pl.get_my_gold() >= item_gold_value)
                {
                    pl.pay_gold(item_gold_value);
                    pl.acquire_item(scrolls_in_stock[selected_item_index]);
                    scrolls_in_stock.RemoveAt(selected_item_index);
                }
                break;

            default:
                item_gold_value = current_list[selected_item_index].get_my_gold_value();
                int buyback_value = (int)Math.Max(item_gold_value * .93, item_gold_value - 500);

                if (im_shopping_for == Shopping_Mode.Buyback)
                {
                    item_gold_value = buyback_value;
                }

                if (pl.get_my_gold() >= item_gold_value)
                {
                    pl.pay_gold(item_gold_value);
                    if (current_list[selected_item_index] is Potion)
                    {
                        Potion p = (Potion)current_list[selected_item_index];
                        p.adjust_quantity(-1);
                        Potion p2 = new Potion(p.get_my_IDno(), p.get_my_gold_value(), p.get_my_name(), p);
                        p2.set_quantity(1);
                        pl.acquire_potion(p2);

                        if (p.get_my_quantity() == 0)
                        {
                            current_list.RemoveAt(selected_item_index);
                        }
                    }
                    else
                    {
                        pl.acquire_item(current_list[selected_item_index]);
                        current_list.RemoveAt(selected_item_index);
                    }
                }
                break;
            }
            player_gold = pl.get_my_gold();
            scroll_menu(0);
        }