public bool can_add_talisman(Talisman T) { bool can_add_talisman = true; if (talismans_equipped.Count >= max_talismans) { can_add_talisman = false; } for (int i = 0; i < talismans_equipped.Count; i++) { if (T.get_my_type() == talismans_equipped[i].get_my_type() && !T.stackable_talisman()) { can_add_talisman = false; } } return(can_add_talisman); }
public Talisman(int IDno, int goldVal, string myName, Talisman T) : base(IDno, goldVal, myName) { my_talisman_type = T.get_my_type(); my_talisman_prefix = T.get_my_prefix(); }
public void add_talisman(Talisman T) { talismans_equipped.Add(T); }
//This actually updates a hell of a lot more than mouse info. It's the central function for //Clicking and dragging stuff into inventory slots / equip slots public void update_mouse_info(Vector2 mousePos, Player pl, bool holdingmouse, bool clickedmouse, out bool bad_turn) { mousePosition = mousePos; is_holding_mouse = holdingmouse; is_click_mouse = clickedmouse; //On the click, snap the rectangle to the mouse spot, and then pick an icon to draw in it. if (is_click_mouse) { draggable_item_rect.X = (int)mousePosition.X - 24; draggable_item_rect.Y = (int)mousePosition.Y - 24; for (int i = 0; i < pair_list.Count; i++) { if (item_icon_rects[pair_list[i].item_rect].Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_mouse_selected_item = pair_list[i].corr_item; } } if (main_hand_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 1; } if (off_hand_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 2; } if (over_armor_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 3; } if (under_armor_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 4; } if (helmet_equip_slot.Contains((int)mousePosition.X, (int)mousePosition.Y)) { index_of_c_equipped_selected_item = 5; } if (BGElement_equipmentTab.Contains((int)mousePosition.X, (int)mousePosition.Y)) { current_tab_selected = Current_Tab.Equipment; } if (BGElement_healthTab.Contains((int)mousePosition.X, (int)mousePosition.Y)) { current_tab_selected = Current_Tab.Injuries; } if (injSummary_scroll_up_max_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { scroll_ctab_MSG(-1000); } if (injSummary_scroll_up_one_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { scroll_ctab_MSG(-1); } if (injSummary_scroll_down_one_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { scroll_ctab_MSG(1); } if (injSummary_scroll_down_max_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { scroll_ctab_MSG(1000); } if (inv_left_scroll_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { item_start_index--; if (item_start_index < 0) { item_start_index = 0; } } if (inv_right_scroll_rect.Contains((int)mousePosition.X, (int)mousePosition.Y)) { item_start_index++; if (item_start_index + number_of_items_shown >= player_inv.Count) { item_start_index = Math.Max(0, player_inv.Count - number_of_items_shown); } } } //On the hold, move the rectangle. if (is_holding_mouse) { draggable_item_rect.X = (int)mousePosition.X - 24; draggable_item_rect.Y = (int)mousePosition.Y - 24; } //On the release, try and equip the item. If it's a talisman and over another item //Try to add it to the item bool equipped_new_item = false; bool equipped_talisman = false; if (!is_holding_mouse && !is_click_mouse) { if (index_of_mouse_selected_item != -1) { if (player_inv[index_of_mouse_selected_item] is Talisman) { Talisman T = (Talisman)player_inv[index_of_mouse_selected_item]; Item attach_to = null; for (int i = 0; i < item_icon_rects.Count; i++) { if (check_overlap(item_icon_rects[i], draggable_item_rect) && i < player_inv.Count) { attach_to = player_inv[i]; } } if (check_overlap(main_hand_equip_slot, draggable_item_rect)) { attach_to = pl.show_main_hand(); } else if (check_overlap(off_hand_equip_slot, draggable_item_rect)) { attach_to = pl.show_off_hand(); } else if (check_overlap(helmet_equip_slot, draggable_item_rect)) { attach_to = pl.show_helmet(); } else if (check_overlap(over_armor_equip_slot, draggable_item_rect)) { attach_to = pl.show_over_armor(); } else if (check_overlap(under_armor_equip_slot, draggable_item_rect)) { attach_to = pl.show_under_armor(); } if (attach_to != null && (attach_to is Armor || attach_to is Scroll || attach_to is Weapon)) { if (attach_to is Armor && T.armor_talisman() && attach_to.can_add_talisman(T)) { attach_to.add_talisman(T); equipped_talisman = true; } else if ((attach_to is Weapon || attach_to is Scroll) && !T.armor_talisman() && attach_to.can_add_talisman(T)) { attach_to.add_talisman(T); equipped_talisman = true; } if (equipped_talisman) { player_inv.RemoveAt(index_of_mouse_selected_item); } } } if (check_overlap(main_hand_equip_slot, draggable_item_rect) && !equipped_new_item && !equipped_talisman) { if (player_inv[index_of_mouse_selected_item] is Weapon) { pl.equip_main_hand((Weapon)player_inv[index_of_mouse_selected_item]); equipped_new_item = true; } } if (check_overlap(off_hand_equip_slot, draggable_item_rect) && !equipped_new_item && !equipped_talisman) { if (player_inv[index_of_mouse_selected_item] is Weapon) { pl.equip_off_hand((Weapon)player_inv[index_of_mouse_selected_item]); equipped_new_item = true; } } for (int i = 0; i < armor_equip_slots.Count; i++) { if (check_overlap(armor_equip_slots[i], draggable_item_rect) && !equipped_new_item && !equipped_talisman) { if (player_inv[index_of_mouse_selected_item] is Armor) { pl.equip_armor((Armor)player_inv[index_of_mouse_selected_item]); equipped_new_item = true; } } } //spot to check if I should put it in the icobar bool done = false; for (int i = 0; i < the_icoBar.get_number_of_icons(); i++) { if (check_overlap(the_icoBar.get_ico_rects_by_slot(i), draggable_item_rect) && !done) { the_icoBar.assign_id_number_to_slot(player_inv[index_of_mouse_selected_item].get_my_IDno(), i); the_icoBar.assign_icon_to_slot(player_inv[index_of_mouse_selected_item].get_my_texture(), i); if (player_inv[index_of_mouse_selected_item] is Potion) { the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Potion, i); } else if (player_inv[index_of_mouse_selected_item] is Armor) { the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Armor, i); } else if (player_inv[index_of_mouse_selected_item] is Weapon) { the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Weapon, i); } else if (player_inv[index_of_mouse_selected_item] is Scroll) { the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Scroll, i); } the_icoBar.update_cooldown_and_quant(pl); done = true; } } } if (index_of_c_equipped_selected_item != -1) { //try to put it back in the inventory. It will go back in on any item rect slot for (int i = 0; i < item_icon_rects.Count; i++) { if (check_overlap(item_icon_rects[i], draggable_item_rect)) { //Do something depending on the slot. switch (index_of_c_equipped_selected_item) { case 1: pl.unequip(Player.Equip_Slot.Mainhand); equipped_new_item = true; break; case 2: pl.unequip(Player.Equip_Slot.Offhand); equipped_new_item = true; break; case 3: pl.unequip(Player.Equip_Slot.Overarmor); equipped_new_item = true; break; case 4: pl.unequip(Player.Equip_Slot.Underarmor); equipped_new_item = true; break; case 5: pl.unequip(Player.Equip_Slot.Helmet); equipped_new_item = true; break; } } } bool done = false; for (int i = 0; i < the_icoBar.get_number_of_icons(); i++) { if (check_overlap(the_icoBar.get_ico_rects_by_slot(i), draggable_item_rect) && !done) { switch (index_of_c_equipped_selected_item) { case 1: the_icoBar.assign_id_number_to_slot(pl.show_main_hand().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_main_hand().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Weapon, i); done = true; break; case 2: the_icoBar.assign_id_number_to_slot(pl.show_off_hand().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_off_hand().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Weapon, i); done = true; break; case 3: the_icoBar.assign_id_number_to_slot(pl.show_over_armor().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_over_armor().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Armor, i); done = true; break; case 4: the_icoBar.assign_id_number_to_slot(pl.show_under_armor().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_under_armor().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Armor, i); done = true; break; case 5: the_icoBar.assign_id_number_to_slot(pl.show_helmet().get_my_IDno(), i); the_icoBar.assign_icon_to_slot(pl.show_helmet().get_my_texture(), i); the_icoBar.assign_type_to_slot(IconBar.Type_Tracker.Armor, i); done = true; break; } the_icoBar.update_cooldown_and_quant(pl); } } } if (equipped_new_item || equipped_talisman) { update_player_info(ref pl); } index_of_mouse_selected_item = -1; index_of_c_equipped_selected_item = -1; } bad_turn = equipped_new_item; if (String.Compare(pl.my_chara_as_string(), "Halephon") == 0) { bad_turn = false; } }