public static PlayerCustomizationEntry GetCustomizationEntry(PlayerMobile player, CustomizationType customization) { PlayerCustomizationEntry customizationEntry = null; if (player == null) { return(customizationEntry); } if (player.m_PlayerEnhancementAccountEntry == null) { return(customizationEntry); } foreach (PlayerCustomizationEntry entry in player.m_PlayerEnhancementAccountEntry.m_CustomizationEntries) { if (entry.m_CustomizationType == customization) { customizationEntry = entry; break; } } return(customizationEntry); }
public PlayerCustomizationConfirmationGump(PlayerMobile player, int pageNumber, CustomizationType customizationType) : base(10, 10) { if (player == null || customizationType == null) { return; } m_Player = player; m_PageNumber = pageNumber; m_CustomizationType = customizationType; PlayerCustomizationDetail customizationDetail = PlayerCustomization.GetCustomizationDetail(customizationType); PlayerCustomizationEntry customizationEntry = PlayerEnhancementPersistance.GetCustomizationEntry(m_Player, customizationType); if (customizationEntry == null || customizationDetail == null) { return; } Closable = true; Disposable = true; Dragable = true; Resizable = false; AddBackground(8, 8, 484, 228, 9200); AddBackground(19, 43, 459, 66, 3000); int textHue = 2036; int boldTextHue = 149; int iStartY = 43; AddLabel(167, 17, boldTextHue, "Unlock Player Customization"); AddItem(25 + customizationDetail.m_IconOffsetX, iStartY + 13 + customizationDetail.m_IconOffsetY, customizationDetail.m_IconItemId, customizationDetail.m_IconHue); //Icon AddLabel(260 - (customizationDetail.m_Name.Length * 3), iStartY + 3, 149, customizationDetail.m_Name); if (customizationDetail.m_Description != null) { for (int a = 0; a < customizationDetail.m_Description.Length; a++) { AddLabel(260 - (customizationDetail.m_Description[a].Length * 3), iStartY + ((a + 1) * 20), textHue, customizationDetail.m_Description[a]); } } //AddLabel(260 - (customizationDetail.m_Description[0].Length * 3), iStartY + 20, textHue, customizationDetail.m_Description[0]); //AddLabel(260 - (customizationDetail.m_Description[1].Length * 3), iStartY + 40, textHue, customizationDetail.m_Description[1]); AddLabel(37, 119, textHue, "This will unlock this Player Customization for all characters on this "); AddLabel(29, 139, textHue, "account and will withdraw the following amount of gold from your bank"); AddItem(185, 163, 3823); AddLabel(230, 167, textHue, Utility.CreateCurrencyString(customizationDetail.m_Cost)); AddLabel(112, 199, textHue, "Confirm"); AddButton(73, 195, 2152, 2154, 1, GumpButtonType.Reply, 0); AddLabel(376, 197, textHue, "Cancel"); AddButton(337, 193, 2474, 2472, 2, GumpButtonType.Reply, 0); }
public static bool IsCustomizationEntryActive(Mobile mobile, CustomizationType customization) { if (mobile == null) { return(false); } if (!(mobile is PlayerMobile)) { return(false); } PlayerMobile player = mobile as PlayerMobile; PlayerCustomizationEntry customizationEntry = null; if (player == null) { return(false); } if (player.m_PlayerEnhancementAccountEntry == null) { return(false); } foreach (PlayerCustomizationEntry entry in player.m_PlayerEnhancementAccountEntry.m_CustomizationEntries) { if (entry.m_CustomizationType == customization) { customizationEntry = entry; break; } } if (customizationEntry != null) { if (customizationEntry.m_Active) { return(true); } } return(false); }
public override void OnResponse(NetState sender, RelayInfo info) { PlayerMobile player = sender.Mobile as PlayerMobile; if (player == null) { return; } if (player.Deleted) { return; } if (m_CustomizationType == null) { return; } PlayerCustomizationDetail customizationDetail = PlayerCustomization.GetCustomizationDetail(m_CustomizationType); PlayerCustomizationEntry customizationEntry = PlayerEnhancementPersistance.GetCustomizationEntry(player, m_CustomizationType); if (customizationEntry == null || customizationDetail == null) { return; } //Confirm if (info.ButtonID == 1) { int bankBalance = Banker.GetBalance(player); if (bankBalance >= customizationDetail.m_Cost) { Banker.Withdraw(player, customizationDetail.m_Cost); player.SendMessage("You unlock the player customization: " + customizationDetail.m_Name + "."); PlayerCustomization.OnUnlockCustomization(player, m_CustomizationType); customizationEntry.m_Unlocked = true; customizationEntry.m_Active = true; player.PlaySound(0x5C9); player.FixedParticles(0x375A, 10, 15, 5012, 0, 0, EffectLayer.Waist); player.CloseGump(typeof(PlayerCustomizationConfirmationGump)); player.SendGump(new PlayerCustomizationGump(player, m_PageNumber)); return; } else { player.SendMessage("You do not have the neccesary funds in your bank account to purchase that player customization."); } player.CloseGump(typeof(PlayerCustomizationConfirmationGump)); player.SendGump(new PlayerCustomizationConfirmationGump(player, m_PageNumber, m_CustomizationType)); return; } //Cancel if (info.ButtonID == 2) { player.CloseGump(typeof(PlayerCustomizationGump)); player.SendGump(new PlayerCustomizationGump(player, m_PageNumber)); return; } player.CloseGump(typeof(PlayerCustomizationGump)); player.SendGump(new PlayerCustomizationGump(player, m_PageNumber)); }
public override void OnResponse(NetState sender, RelayInfo info) { PlayerMobile player = sender.Mobile as PlayerMobile; if (player == null) { return; } if (player.Deleted) { return; } //Previous if (info.ButtonID == 1) { if (m_PageNumber > 1) { m_PageNumber--; player.SendSound(0x055); player.CloseGump(typeof(PlayerCustomizationGump)); player.SendGump(new PlayerCustomizationGump(player, m_PageNumber)); return; } } //Next if (info.ButtonID == 2) { if (m_PageNumber < m_TotalPages) { m_PageNumber++; player.SendSound(0x055); player.CloseGump(typeof(PlayerCustomizationGump)); player.SendGump(new PlayerCustomizationGump(player, m_PageNumber)); return; } } //Entries if (info.ButtonID > 2) { int index = info.ButtonID - 3; if (index >= m_CustomizationsOnPage.Count || index < 0) { return; } CustomizationType customizationType = m_CustomizationsOnPage[index]; PlayerCustomizationDetail customizationDetail = PlayerCustomization.GetCustomizationDetail(customizationType); PlayerCustomizationEntry customizationEntry = PlayerEnhancementPersistance.GetCustomizationEntry(player, customizationType); if (customizationType == null || customizationEntry == null || customizationDetail == null) { return; } bool selectable = customizationDetail.m_Selectable; if (customizationEntry.m_Unlocked) { if (customizationEntry.m_Active) { if (selectable) { customizationEntry.m_Active = false; player.SendMessage("You disable the player customization: " + customizationDetail.m_Name); } else { player.SendMessage("That customization may not be disabled."); } } else { customizationEntry.m_Active = true; player.SendMessage("You enable the player customization: " + customizationDetail.m_Name); } player.CloseGump(typeof(PlayerCustomizationGump)); player.SendGump(new PlayerCustomizationGump(player, m_PageNumber)); return; } else { player.CloseGump(typeof(PlayerCustomizationGump)); player.SendGump(new PlayerCustomizationConfirmationGump(player, m_PageNumber, customizationType)); return; } } player.CloseGump(typeof(PlayerEnhancementGump)); player.SendGump(new PlayerEnhancementGump(player)); return; }
public PlayerCustomizationGump(Mobile from, int pageNumber) : base(10, 10) { PlayerMobile player = from as PlayerMobile; if (player == null) { return; } m_Player = player; m_PageNumber = pageNumber; Closable = true; Disposable = true; Dragable = true; Resizable = false; AddImage(0, 44, 202); AddImage(44, 0, 201); AddImage(0, 0, 206); AddImage(0, 468, 204); AddImage(590, 1, 207); AddImage(590, 468, 205); AddImage(44, 468, 233); AddImage(590, 45, 203); AddImageTiled(44, 44, 546, 424, 200); AddImage(0, 152, 202); AddImage(163, 0, 201); AddImage(166, 468, 233); AddImage(590, 152, 203); //---------------------- int textHue = 2036; int boldHue = 149; AddLabel(277, 20, 2615, "Customizations"); int totalCustomizations = Enum.GetNames(typeof(CustomizationType)).Length; int customizationsPerPage = 5; m_TotalPages = (int)(Math.Ceiling((double)totalCustomizations / (double)customizationsPerPage)); if (m_TotalPages == 0) { m_TotalPages = 1; } if (m_PageNumber < 1) { m_PageNumber = 1; } if (m_PageNumber > m_TotalPages) { m_PageNumber = m_TotalPages; } int indexStart = (m_PageNumber - 1) * customizationsPerPage; int indexEnd; if (indexStart + customizationsPerPage <= totalCustomizations) { indexEnd = indexStart + customizationsPerPage; } else { indexEnd = totalCustomizations; } if (indexEnd > totalCustomizations) { indexEnd = totalCustomizations; } var iStartY = 50; var iSpacingY = 75; int iCount = 0; //Entry for (int a = indexStart; a < indexEnd; a++) { CustomizationType customizationType = (CustomizationType)a; PlayerCustomizationDetail customizationDetail = PlayerCustomization.GetCustomizationDetail(customizationType); PlayerCustomizationEntry customizationEntry = PlayerEnhancementPersistance.GetCustomizationEntry(player, customizationType); if (customizationType == null || customizationDetail == null || customizationEntry == null) { return; } m_CustomizationsOnPage.Add(customizationType); bool unlocked = false; bool activated = false; AddBackground(25, iStartY, 459, 66, 3000); AddItem(25 + customizationDetail.m_IconOffsetX, iStartY + 13 + customizationDetail.m_IconOffsetY, customizationDetail.m_IconItemId, customizationDetail.m_IconHue); //Icon AddLabel(260 - (customizationDetail.m_Name.Length * 3), iStartY + 3, 149, customizationDetail.m_Name); if (customizationDetail.m_Description != null) { for (int b = 0; b < customizationDetail.m_Description.Length; b++) { AddLabel(260 - (customizationDetail.m_Description[b].Length * 3), iStartY + ((b + 1) * 20), textHue, customizationDetail.m_Description[b]); } } //AddLabel(260 - (customizationDetail.m_Description[0].Length * 3), iStartY + 20, textHue, customizationDetail.m_Description[0]); //AddLabel(260 - (customizationDetail.m_Description[1].Length * 3), iStartY + 40, textHue, customizationDetail.m_Description[1]); if (customizationEntry.m_Unlocked) { if (customizationEntry.m_Active) { AddButton(496, iStartY + 16, 2154, 2151, 3 + iCount, GumpButtonType.Reply, 0); AddLabel(533, iStartY + 20, textHue, "Active"); } else { AddButton(496, iStartY + 16, 2151, 2154, 3 + iCount, GumpButtonType.Reply, 0); AddLabel(533, iStartY + 20, textHue, "Disabled"); } } else { AddItem(488, iStartY + 5, 3823); AddLabel(535, iStartY + 9, textHue, Utility.CreateCurrencyString(customizationDetail.m_Cost)); AddButton(496, iStartY + 34, 9720, 9723, 3 + iCount, GumpButtonType.Reply, 0); AddLabel(535, iStartY + 38, textHue, "Unlock"); } iStartY += iSpacingY; iCount++; } //Navigation if (m_PageNumber > 1) { AddButton(50, 465, 4014, 4016, 1, GumpButtonType.Reply, 0); AddLabel(85, 465, textHue, @"Previous Page"); } if (m_PageNumber < m_TotalPages) { AddButton(485, 465, 4005, 4007, 2, GumpButtonType.Reply, 0); AddLabel(520, 465, textHue, @"Next Page"); } }