public BuildSubRes SearchFor(Type type) { for (int i = 0; i < List.Count; i++) { BuildSubRes buildSubRes = ( BuildSubRes )List[i]; if (buildSubRes.ItemType == type) { return(buildSubRes); } } return(null); }
public void CreateResList(bool opt) { BuildSubResCol res = (opt ? m_BuildSystem.BuildSubRes2 : m_BuildSystem.BuildSubRes); for (int i = 0; i < res.Count; ++i) { int index = i % 10; BuildSubRes subResource = res.GetAt(i); if (index == 0) { if (i > 0) { AddButton(485, 260, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1); } AddPage((i / 10) + 1); if (i > 0) { AddButton(455, 260, 4014, 4015, 0, GumpButtonType.Page, i / 10); } BuildContext context = m_BuildSystem.GetContext(m_From); AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0); AddHtmlLocalized(255, 263, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false); } AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0); if (subResource.NameNumber > 0) { AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, LabelColor, false, false); } else { AddLabel(255, 60 + (index * 20), LabelHue, subResource.NameString); } } }
public static void BeginTarget(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool) { BuildContext context = buildSystem.GetContext(from); if (context == null) { return; } int lastRes = context.LastResourceIndex; BuildSubResCol subRes = buildSystem.BuildSubRes; if (lastRes >= 0 && lastRes < subRes.Count) { BuildSubRes res = subRes.GetAt(lastRes); if (LokaiSkillUtilities.XMLGetSkills(from)[buildSystem.MainLokaiSkill].Value < res.RequiredLokaiSkill) { from.SendGump(new BuildGump(from, buildSystem, tool, res.Message)); } else { BuildResource resource = BuildResources.GetFromType(res.ItemType); if (resource != BuildResource.None) { from.Target = new InternalTarget(buildSystem, tool, res.ItemType, resource); from.SendLocalizedMessage(1061004); // Target an item to enhance with the properties of your selected material. } else { from.SendGump(new BuildGump(from, buildSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties. } } } else { from.SendGump(new BuildGump(from, buildSystem, tool, 1061010)); // You must select a special material in order to enhance an item with its properties. } }
public void Add(BuildSubRes buildSubRes) { List.Add(buildSubRes); }
public bool ConsumeRes(Mobile from, Type typeRes, BuildSystem buildSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure) { Container ourPack = from.Backpack; if (ourPack == null) { return(false); } if (m_NeedHeat && !Find(from, m_HeatSources)) { message = 1044487; // You must be near a fire source to cook. return(false); } if (m_NeedOven && !Find(from, m_Ovens)) { message = 1044493; // You must be near an oven to bake that. return(false); } if (m_NeedMill && !Find(from, m_Mills)) { message = 1044491; // You must be near a flour mill to do that. return(false); } if (m_NeedWoodworker && !Find(from, m_WoodworkersBench)) { message = "You must be near a woodworker's bench to do that."; return(false); } if (m_NeedCooper && !Find(from, m_CoopersBench)) { message = "You must be near a cooper's bench to do that."; return(false); } if (m_NeedForeman && !Find(from, typeof(Foreman), 3)) { message = "You must be near a foreman to do that."; return(false); } if (m_arBuildRes.Count == 0) { message = "Resource count is 0?"; return(false); } Type[][] types = new Type[m_arBuildRes.Count][]; int[] amounts = new int[m_arBuildRes.Count]; maxAmount = int.MaxValue; BuildSubResCol resCol = (m_UseSubRes2 ? buildSystem.BuildSubRes2 : buildSystem.BuildSubRes); for (int i = 0; i < types.Length; ++i) { BuildRes buildRes = m_arBuildRes.GetAt(i); Type baseType = buildRes.ItemType; // Resource Mutation if ((baseType == resCol.ResType) && (typeRes != null)) { baseType = typeRes; BuildSubRes subResource = resCol.SearchFor(baseType); if (subResource != null && LokaiSkillUtilities.XMLGetSkills(from)[buildSystem.MainLokaiSkill].Base < subResource.RequiredLokaiSkill) { message = subResource.Message; return(false); } } // ****************** for (int j = 0; types[i] == null && j < m_TypesTable.Length; ++j) { if (m_TypesTable[j][0] == baseType) { types[i] = m_TypesTable[j]; } } if (types[i] == null) { types[i] = new Type[] { baseType } } ; amounts[i] = buildRes.Amount; // For stackable items that can be built more than one at a time if (UseAllRes) { int tempAmount = ourPack.GetAmount(types[i]); tempAmount /= amounts[i]; if (tempAmount < maxAmount) { maxAmount = tempAmount; if (maxAmount == 0) { BuildRes res = m_arBuildRes.GetAt(i); if (res.MessageNumber > 0) { message = res.MessageNumber; } else if (!String.IsNullOrEmpty(res.MessageString)) { message = res.MessageString; } else { message = 502925; // You don't have the resources required to make that item. } return(false); } } } // **************************** if (isFailure && !buildSystem.ConsumeOnFailure(from, types[i][0], this)) { amounts[i] = 0; } } // We adjust the amount of each resource to consume the max possible if (UseAllRes) { for (int i = 0; i < amounts.Length; ++i) { amounts[i] *= maxAmount; } } else { maxAmount = -1; } int index = 0; // Consume ALL if (consumeType == ConsumeType.All) { m_ResHue = 0; m_ResAmount = 0; m_System = buildSystem; if (IsQuantityType(types)) { index = ConsumeQuantity(ourPack, types, amounts); } else { index = ourPack.ConsumeTotalGrouped(types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping)); } resHue = m_ResHue; } // Consume Half ( for use all resource build type ) else if (consumeType == ConsumeType.Half) { for (int i = 0; i < amounts.Length; i++) { amounts[i] /= 2; if (amounts[i] < 1) { amounts[i] = 1; } } m_ResHue = 0; m_ResAmount = 0; m_System = buildSystem; if (IsQuantityType(types)) { index = ConsumeQuantity(ourPack, types, amounts); } else { index = ourPack.ConsumeTotalGrouped(types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping)); } resHue = m_ResHue; } else // ConstumeType.None ( it's basicaly used to know if the builder has enough resource before starting the process ) { index = -1; if (IsQuantityType(types)) { for (int i = 0; i < types.Length; i++) { if (GetQuantity(ourPack, types[i]) < amounts[i]) { index = i; break; } } } else { for (int i = 0; i < types.Length; i++) { if (ourPack.GetBestGroupAmount(types[i], true, new CheckItemGroup(CheckHueGrouping)) < amounts[i]) { index = i; break; } } } } if (index == -1) { return(true); } else { BuildRes res = m_arBuildRes.GetAt(index); if (res.MessageNumber > 0) { message = res.MessageNumber; } else if (res.MessageString != null && res.MessageString != String.Empty) { message = res.MessageString; } else { message = 502925; // You don't have the resources required to make that item. } return(false); } }
public override void OnResponse(NetState sender, RelayInfo info) { if (info.ButtonID <= 0) { return; // Canceled } int buttonID = info.ButtonID - 1; int type = buttonID % 7; int index = buttonID / 7; BuildSystem system = m_BuildSystem; BuildGroupCol groups = system.BuildGroups; BuildContext context = system.GetContext(m_From); switch (type) { case 0: // Show group { if (context == null) { break; } if (index >= 0 && index < groups.Count) { context.LastGroupIndex = index; m_From.SendGump(new BuildGump(m_From, system, m_Tool, null)); } break; } case 1: // Create item { if (context == null) { break; } int groupIndex = context.LastGroupIndex; if (groupIndex >= 0 && groupIndex < groups.Count) { BuildGroup group = groups.GetAt(groupIndex); if (index >= 0 && index < group.BuildItems.Count) { BuildItem(group.BuildItems.GetAt(index)); } } break; } case 2: // Item details { if (context == null) { break; } int groupIndex = context.LastGroupIndex; if (groupIndex >= 0 && groupIndex < groups.Count) { BuildGroup group = groups.GetAt(groupIndex); if (index >= 0 && index < group.BuildItems.Count) { m_From.SendGump(new BuildGumpItem(m_From, system, group.BuildItems.GetAt(index), m_Tool)); } } break; } case 3: // Create item (last 10) { if (context == null) { break; } ArrayList lastTen = context.Items; if (index >= 0 && index < lastTen.Count) { BuildItem((BuildItem)lastTen[index]); } break; } case 4: // Item details (last 10) { if (context == null) { break; } ArrayList lastTen = context.Items; if (index >= 0 && index < lastTen.Count) { m_From.SendGump(new BuildGumpItem(m_From, system, (BuildItem)lastTen[index], m_Tool)); } break; } case 5: // Resource selected { if (m_Page == BuildPage.PickResource && index >= 0 && index < system.BuildSubRes.Count) { int groupIndex = (context == null ? -1 : context.LastGroupIndex); BuildSubRes res = system.BuildSubRes.GetAt(index); if (LokaiSkillUtilities.XMLGetSkills(m_From)[system.MainLokaiSkill].Base < res.RequiredLokaiSkill) { m_From.SendGump(new BuildGump(m_From, system, m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex = index; } m_From.SendGump(new BuildGump(m_From, system, m_Tool, null)); } } else if (m_Page == BuildPage.PickResource2 && index >= 0 && index < system.BuildSubRes2.Count) { int groupIndex = (context == null ? -1 : context.LastGroupIndex); BuildSubRes res = system.BuildSubRes2.GetAt(index); if (LokaiSkillUtilities.XMLGetSkills(m_From)[system.MainLokaiSkill].Base < res.RequiredLokaiSkill) { m_From.SendGump(new BuildGump(m_From, system, m_Tool, res.Message)); } else { if (context != null) { context.LastResourceIndex2 = index; } m_From.SendGump(new BuildGump(m_From, system, m_Tool, null)); } } break; } case 6: // Misc. buttons { switch (index) { case 0: // Resource selection { if (system.BuildSubRes.Init) { m_From.SendGump(new BuildGump(m_From, system, m_Tool, null, BuildPage.PickResource)); } break; } case 1: // Smelt item { if (system.Resmelt) { Resmelt.Do(m_From, system, m_Tool); } break; } case 2: // Make last { if (context == null) { break; } BuildItem item = context.LastMade; if (item != null) { BuildItem(item); } else { m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, 1044165, m_Page)); // You haven't made anything yet. } break; } case 3: // Last 10 { if (context == null) { break; } context.LastGroupIndex = 501; m_From.SendGump(new BuildGump(m_From, system, m_Tool, null)); break; } case 4: // Toggle use resource hue { if (context == null) { break; } context.DoNotColor = !context.DoNotColor; m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, null, m_Page)); break; } case 5: // Repair item { if (system.Repair) { Repair.Do(m_From, system, m_Tool); } break; } case 6: // Toggle mark option { if (context == null || !system.MarkOption) { break; } switch (context.MarkOption) { case BuildMarkOption.MarkItem: context.MarkOption = BuildMarkOption.DoNotMark; break; case BuildMarkOption.DoNotMark: context.MarkOption = BuildMarkOption.PromptForMark; break; case BuildMarkOption.PromptForMark: context.MarkOption = BuildMarkOption.MarkItem; break; } m_From.SendGump(new BuildGump(m_From, m_BuildSystem, m_Tool, null, m_Page)); break; } case 7: // Resource selection 2 { if (system.BuildSubRes2.Init) { m_From.SendGump(new BuildGump(m_From, system, m_Tool, null, BuildPage.PickResource2)); } break; } case 8: // Enhance item { if (system.CanEnhance) { Enhance.BeginTarget(m_From, system, m_Tool); } break; } } break; } } }
private BuildGump(Mobile from, BuildSystem buildSystem, BaseBuildingTool tool, object notice, BuildPage page) : base(40, 40) { m_From = from; m_BuildSystem = buildSystem; m_Tool = tool; m_Page = page; BuildContext context = buildSystem.GetContext(from); from.CloseGump(typeof(BuildGump)); from.CloseGump(typeof(BuildGumpItem)); AddPage(0); AddBackground(0, 0, 530, 437, 5054); AddImageTiled(10, 10, 510, 22, 2624); AddImageTiled(10, 292, 150, 45, 2624); AddImageTiled(165, 292, 355, 45, 2624); AddImageTiled(10, 342, 510, 85, 2624); AddImageTiled(10, 37, 200, 250, 2624); AddImageTiled(215, 37, 305, 250, 2624); AddAlphaRegion(10, 10, 510, 417); if (buildSystem.GumpTitleNumber > 0) { AddHtmlLocalized(10, 12, 510, 20, buildSystem.GumpTitleNumber, LabelColor, false, false); } else { AddHtml(10, 12, 510, 20, MakeTitle(buildSystem.GumpTitleString), false, false); } AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false); // <CENTER>CATEGORIES</CENTER> AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER> AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER> AddButton(15, 402, 4017, 4019, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(50, 405, 150, 18, 1011441, LabelColor, false, false); // EXIT AddButton(270, 402, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 405, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST // Mark option if (buildSystem.MarkOption) { AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM } // **************************************** // Resmelt option if (buildSystem.Resmelt) { AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0); AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM } // **************************************** // Repair option if (buildSystem.Repair) { AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM } // **************************************** // Enhance option if (buildSystem.CanEnhance) { AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0); AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM } // **************************************** if (notice is int && (int)notice > 0) { AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false); } else if (notice is string) { AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false); } // If the system has more than one resource if (buildSystem.BuildSubRes.Init) { string nameString = buildSystem.BuildSubRes.NameString; int nameNumber = buildSystem.BuildSubRes.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex); Type resourceType = buildSystem.BuildSubRes.ResType; if (resIndex > -1) { BuildSubRes subResource = buildSystem.BuildSubRes.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { AddLabel(50, 362, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount)); } } // **************************************** // For dragon scales if (buildSystem.BuildSubRes2.Init) { string nameString = buildSystem.BuildSubRes2.NameString; int nameNumber = buildSystem.BuildSubRes2.NameNumber; int resIndex = (context == null ? -1 : context.LastResourceIndex2); Type resourceType = buildSystem.BuildSubRes.ResType; if (resIndex > -1) { BuildSubRes subResource = buildSystem.BuildSubRes2.GetAt(resIndex); nameString = subResource.NameString; nameNumber = subResource.NameNumber; resourceType = subResource.ItemType; } int resourceCount = 0; if (from.Backpack != null) { Item[] items = from.Backpack.FindItemsByType(resourceType, true); for (int i = 0; i < items.Length; ++i) { resourceCount += items[i].Amount; } } AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0); if (nameNumber > 0) { AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false); } else { AddLabel(50, 385, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount)); } } // **************************************** CreateGroupList(); if (page == BuildPage.PickResource) { CreateResList(false); } else if (page == BuildPage.PickResource2) { CreateResList(true); } else if (context != null && context.LastGroupIndex > -1) { CreateItemList(context.LastGroupIndex); } }
public void AddSubRes2(Type type, string name, double reqLokaiSkill, object message) { BuildSubRes buildSubRes = new BuildSubRes(type, name, reqLokaiSkill, message); m_BuildSubRes2.Add(buildSubRes); }
public void AddSubRes2(Type type, int name, double reqLokaiSkill, int genericName, object message) { BuildSubRes buildSubRes = new BuildSubRes(type, name, reqLokaiSkill, genericName, message); m_BuildSubRes2.Add(buildSubRes); }
public void DrawRessource() { bool retainedColor = false; BuildContext context = m_BuildSystem.GetContext(m_From); BuildSubResCol res = (m_BuildItem.UseSubRes2 ? m_BuildSystem.BuildSubRes2 : m_BuildSystem.BuildSubRes); int resIndex = -1; if (context != null) { resIndex = (m_BuildItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex); } bool cropScroll = (m_BuildItem.Ressources.Count > 1) && m_BuildItem.Ressources.GetAt(m_BuildItem.Ressources.Count - 1).ItemType == typeofBlankScroll && typeofSpellScroll.IsAssignableFrom(m_BuildItem.ItemType); for (int i = 0; i < m_BuildItem.Ressources.Count - (cropScroll ? 1 : 0) && i < 4; i++) { Type type; string nameString; int nameNumber; BuildRes buildResource = m_BuildItem.Ressources.GetAt(i); type = buildResource.ItemType; nameString = buildResource.NameString; nameNumber = buildResource.NameNumber; // Resource Mutation if (type == res.ResType && resIndex > -1) { BuildSubRes subResource = res.GetAt(resIndex); type = subResource.ItemType; nameString = subResource.NameString; nameNumber = subResource.GenericNameNumber; if (nameNumber <= 0) { nameNumber = subResource.NameNumber; } } // ****************** if (!retainedColor && m_BuildItem.RetainsColorFrom(m_BuildSystem, type)) { retainedColor = true; AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044152, LabelColor, false, false); // * The item retains the color of this material AddLabel(500, 219 + (i * 20), LabelHue, "*"); } if (nameNumber > 0) { AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false); } else { AddLabel(170, 219 + (i * 20), LabelHue, nameString); } AddLabel(430, 219 + (i * 20), LabelHue, buildResource.Amount.ToString()); } if (m_BuildItem.NameNumber == 1041267) // runebook { AddHtmlLocalized(170, 219 + (m_BuildItem.Ressources.Count * 20), 310, 18, 1044447, LabelColor, false, false); AddLabel(430, 219 + (m_BuildItem.Ressources.Count * 20), LabelHue, "1"); } if (cropScroll) { AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044379, LabelColor, false, false); // Inscribing scrolls also requires a blank scroll and mana. } }