Exemplo n.º 1
0
        public List <Item> retrieve_random_consumables(Player pl, int number)
        {
            PotionDC[]      raw_potion_data      = cManager.Load <PotionDC[]>("XmlData/Items/potions");
            List <PotionDC> selected_potion_data = new List <PotionDC>();

            List <Item> fetched_list = new List <Item>();

            int tiers_available = 0;
            int playerGold      = pl.get_my_gold();

            if (playerGold < 1500)
            {
                tiers_available = 1;
            }
            else
            {
                tiers_available = 2;
            }

            string pl_chclass = pl.my_class_as_string();

            for (int i = 0; i < raw_potion_data.Count(); i++)
            {
                string[] available_for = raw_potion_data[i].ValidClasses.Split(' ');
                bool     valid_class   = false;
                for (int cl = 0; cl < available_for.Count(); cl++)
                {
                    if (String.Compare(pl_chclass, available_for[cl]) == 0)
                    {
                        valid_class = true;
                    }
                }

                if (valid_class && (raw_potion_data[i].ItemTier == tiers_available ||
                                    raw_potion_data[i].ItemTier == tiers_available - 1) &&
                    (raw_potion_data[i].Cost <= playerGold ||
                     raw_potion_data[i].Cost == 500))
                {
                    selected_potion_data.Add(raw_potion_data[i]);
                }
            }

            while ((fetched_list.Count) < number && selected_potion_data.Count > 0)
            {
                int  selected_p_index = rGen.Next(selected_potion_data.Count);
                bool duplicate_type   = false;
                //Check to see if it's a duplicate type first.
                for (int j = 0; j < fetched_list.Count; j++)
                {
                    if (fetched_list[j] is Potion)
                    {
                        Potion p       = (Potion)fetched_list[j];
                        string rpdType = selected_potion_data[selected_p_index].PotionType;
                        switch (p.get_type())
                        {
                        case Potion.Potion_Type.Health:
                            duplicate_type = String.Compare(rpdType, "Health") == 0;
                            break;

                        case Potion.Potion_Type.Repair:
                            duplicate_type = String.Compare(rpdType, "Repair") == 0;
                            break;
                        }
                    }
                }
                //If it is not a duplicate type, add the potion intialized from the data
                //to fectched item list.
                //regardless, the potion is removed from selected raw data.
                if (!duplicate_type)
                {
                    fetched_list.Add(process_pDC(selected_potion_data[selected_p_index]));
                }

                selected_potion_data.RemoveAt(selected_p_index);
            }

            //Raw potion data 0 should be minor Health Potion. it's the first one
            //in the list. This guarantees that if no other health potion is present you
            //At least get a minor one. Toss the player a bone.
            bool health_potion_present = false;

            for (int i = 0; i < fetched_list.Count; i++)
            {
                if (fetched_list[i] is Potion)
                {
                    Potion p = (Potion)fetched_list[i];
                    if (p.get_type() == Potion.Potion_Type.Health)
                    {
                        health_potion_present = true;
                    }
                }
            }

            if (!health_potion_present)
            {
                int    MPID = raw_potion_data[0].IDNumber;
                int    MPC  = raw_potion_data[0].Cost;
                string MPN  = raw_potion_data[0].Name;
                int    MPP  = raw_potion_data[0].PotionPotency;
                fetched_list.Add(new Potion(MPID, MPC, MPN, Potion.Potion_Type.Health, MPP));
            }

            bool bonus_quan = false;

            while (!bonus_quan)
            {
                int item_index = rGen.Next(fetched_list.Count);
                if (fetched_list[item_index] is Potion)
                {
                    Potion p = (Potion)fetched_list[item_index];
                    p.adjust_quantity(1);
                    bonus_quan = true;
                }
            }

            return(fetched_list);
        }
Exemplo n.º 2
0
 public void clear_potion()
 {
     p = null;
 }
Exemplo n.º 3
0
        public void init_necessary_textures(Player pl)
        {
            cManager.Unload();

            List <Item> player_inv = pl.retrieve_inventory();

            for (int i = 0; i < player_inv.Count; i++)
            {
                if (player_inv[i] != null)
                {
                    string texture_loc = "Icons/";
                    if (player_inv[i] is Armor)
                    {
                        texture_loc += "Armors/";
                    }
                    if (player_inv[i] is Weapon)
                    {
                        texture_loc += "Weapons/";
                    }
                    if (player_inv[i] is Potion)
                    {
                        texture_loc += "Consumables/";
                    }
                    if (player_inv[i] is Scroll || player_inv[i] is Talisman)
                    {
                        texture_loc += "Scrolls/";
                    }

                    texture_loc += player_inv[i].get_my_texture_name();
                    Texture2D current_texture = cManager.Load <Texture2D>(texture_loc);
                    player_inv[i].set_texture(current_texture);
                    //Set the empty texture for the potion if it is one.
                    if (player_inv[i] is Potion)
                    {
                        Potion pt = (Potion)player_inv[i];
                        string empty_textureloc = "Icons/Consumables/" + pt.get_my_empty_texture_name();
                        pt.set_empty_texture(cManager.Load <Texture2D>(empty_textureloc));
                    }

                    if (the_icoBar.item_is_on_bar(player_inv[i].get_my_IDno()))
                    {
                        the_icoBar.init_item_texture_by_id_number(player_inv[i].get_my_IDno(), current_texture);
                    }
                }
            }

            if (pl.show_main_hand() != null)
            {
                Texture2D current_texture = cManager.Load <Texture2D>("Icons/Weapons/" + pl.show_main_hand().get_my_texture_name());
                pl.show_main_hand().set_texture(current_texture);
                the_icoBar.init_item_texture_by_id_number(pl.show_main_hand().get_my_IDno(), current_texture);
            }
            if (pl.show_off_hand() != null)
            {
                Texture2D current_texture = cManager.Load <Texture2D>("Icons/Weapons/" + pl.show_off_hand().get_my_texture_name());
                pl.show_off_hand().set_texture(current_texture);
                the_icoBar.init_item_texture_by_id_number(pl.show_off_hand().get_my_IDno(), current_texture);
            }
            if (pl.show_over_armor() != null)
            {
                Texture2D current_texture = cManager.Load <Texture2D>("Icons/Armors/" + pl.show_over_armor().get_my_texture_name());
                pl.show_over_armor().set_texture(current_texture);
                the_icoBar.init_item_texture_by_id_number(pl.show_over_armor().get_my_IDno(), current_texture);
            }
            if (pl.show_under_armor() != null)
            {
                Texture2D current_texture = cManager.Load <Texture2D>("Icons/Armors/" + pl.show_under_armor().get_my_texture_name());
                pl.show_under_armor().set_texture(current_texture);
                the_icoBar.init_item_texture_by_id_number(pl.show_under_armor().get_my_IDno(), current_texture);
            }
            if (pl.show_helmet() != null)
            {
                Texture2D current_texture = cManager.Load <Texture2D>("Icons/Armors/" + pl.show_helmet().get_my_texture_name());
                pl.show_helmet().set_texture(current_texture);
                the_icoBar.init_item_texture_by_id_number(pl.show_helmet().get_my_IDno(), current_texture);
            }

            player_name = pl.my_chara_as_string();
            switch (player_name)
            {
            case "Falsael":
                character_portrait = cManager.Load <Texture2D>("Player/Portraits/falsael_fine");
                break;

            default:
                character_portrait = null;
                break;
            }
        }
Exemplo n.º 4
0
 public void current_potion(Potion pt)
 {
     p = pt;
 }