// Use this for initialization void Start() { if (craftSystem != null) { craftInventory = craftSystem.GetComponent<Inventory>(); cS = craftSystem.GetComponent<CraftSystem>(); } }
public void OnPointerDown(PointerEventData data) { if (craftSystem == null) { craftSystem = transform.parent.GetComponent<CraftSystem>(); resultScript = transform.parent.GetChild(3).GetComponent<CraftResultSlot>(); } if (resultScript.temp < (craftSystem.possibleItems.Count - 1)) resultScript.temp++; else resultScript.temp = 0; }
//Inventory inventory; // Use this for initialization void Start() { //inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>(); craftSystem = transform.parent.GetComponent<CraftSystem>(); itemGameObject = (GameObject)Instantiate(Resources.Load("Prefabs/Item") as GameObject); itemGameObject.transform.SetParent(this.gameObject.transform); itemGameObject.GetComponent<RectTransform>().localPosition = Vector3.zero; itemGameObject.GetComponent<DragItem>().enabled = false; itemGameObject.SetActive(false); itemGameObject.transform.GetChild(1).GetComponent<Text>().enabled = true; itemGameObject.transform.GetChild(1).GetComponent<RectTransform>().localPosition = new Vector2(GameObject.FindGameObjectWithTag("MainInventory").GetComponent<Inventory>().positionNumberX, GameObject.FindGameObjectWithTag("MainInventory").GetComponent<Inventory>().positionNumberY); }
void OnEnable() { cS = target as CraftSystem; finalSlotPositionX = serializedObject.FindProperty("finalSlotPositionX"); finalSlotPositionY = serializedObject.FindProperty("finalSlotPositionY"); leftArrowPositionX = serializedObject.FindProperty("leftArrowPositionX"); leftArrowPositionY = serializedObject.FindProperty("leftArrowPositionY"); rightArrowPositionX = serializedObject.FindProperty("rightArrowPositionX"); rightArrowPositionY = serializedObject.FindProperty("rightArrowPositionY"); leftArrowRotation = serializedObject.FindProperty("leftArrowRotation"); rightArrowRotation = serializedObject.FindProperty("rightArrowRotation"); cS.setImages(); }
void Start() { /* if (HPMANACanvas != null) { hpText = HPMANACanvas.transform.GetChild(1).GetChild(0).GetComponent<Text>(); manaText = HPMANACanvas.transform.GetChild(2).GetComponentInChildren<Text>(); hpImage = HPMANACanvas.transform.GetChild(1).GetComponent<Image>(); manaImage = HPMANACanvas.transform.GetChild(2).GetComponent<Image>(); UpdateHPBar(); UpdateManaBar(); } */ if (inputManagerDatabase == null) inputManagerDatabase = (InputManager)Resources.Load("InputManager"); if (craftSystem != null) cS = craftSystem.GetComponent<CraftSystem>(); if (GameObject.FindGameObjectWithTag("Tooltip") != null) toolTip = GameObject.FindGameObjectWithTag("Tooltip").GetComponent<Tooltip>(); if (inventory != null) mainInventory = inventory.GetComponent<Inventory>(); if (characterSystem != null) characterSystemInventory = characterSystem.GetComponent<Inventory>(); if (craftSystem != null) craftSystemInventory = craftSystem.GetComponent<Inventory>(); }
void Start() { //if (HPMANACanvas != null) //{ // hpText = HPMANACanvas.transform.GetChild(1).GetChild(0).GetComponent<Text>(); // manaText = HPMANACanvas.transform.GetChild(2).GetChild(0).GetComponent<Text>(); // hpImage = HPMANACanvas.transform.GetChild(1).GetComponent<Image>(); // manaImage = HPMANACanvas.transform.GetChild(1).GetComponent<Image>(); // UpdateHPBar(); // UpdateManaBar(); //} if (inputManagerDatabase == null) inputManagerDatabase = (InputManager)Resources.Load("InputManager"); if (craftSystem != null) cS = craftSystem.GetComponent<CraftSystem>(); GameObject canvas = GameObject.FindGameObjectWithTag("Canvas"); if (canvas.transform.Find("Panel - Inventory(Clone)") != null) inventory = canvas.transform.Find("Panel - Inventory(Clone)").gameObject; if (canvas.transform.Find("Panel - EquipmentSystem(Clone)") != null) characterSystem = canvas.transform.Find("Panel - EquipmentSystem(Clone)").gameObject; if (GameObject.FindGameObjectWithTag("Tooltip") != null) toolTip = GameObject.FindGameObjectWithTag("Tooltip").GetComponent<Tooltip>(); if (inventory != null) mainInventory = inventory.GetComponent<Inventory>(); if (characterSystem != null) characterSystemInventory = characterSystem.GetComponent<Inventory>(); if (craftSystem != null) craftSystemInventory = craftSystem.GetComponent<Inventory>(); }
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue) { int magery = from.Skills.Magery.BaseFixedPoint; if (magery >= 800) { int[] propertyCounts; int minIntensity; int maxIntensity; if (magery >= 1000) { if (magery >= 1200) { propertyCounts = m_LegendPropertyCounts; } else if (magery >= 1100) { propertyCounts = m_ElderPropertyCounts; } else { propertyCounts = m_GrandPropertyCounts; } minIntensity = 55; maxIntensity = 75; } else if (magery >= 900) { propertyCounts = m_MasterPropertyCounts; minIntensity = 25; maxIntensity = 45; } else { propertyCounts = m_AdeptPropertyCounts; minIntensity = 0; maxIntensity = 15; } int propertyCount = propertyCounts[Utility.Random(propertyCounts.Length)]; GuaranteedSpellbookImprovementTalisman talisman = from.FindItemOnLayer(Layer.Talisman) as GuaranteedSpellbookImprovementTalisman; if (talisman != null && talisman.Charges > 0) { propertyCount++; talisman.Charges--; from.SendLocalizedMessage(1157210); // Your talisman magically improves your spellbook. if (talisman.Charges <= 0) { from.SendLocalizedMessage(1157211); // Your talisman has been destroyed. talisman.Delete(); } } BaseRunicTool.ApplyAttributesTo(this, true, 0, propertyCount, minIntensity, maxIntensity); } if (makersMark) { Crafter = from; } m_Quality = (BookQuality)(quality - 1); return(quality); }
public static SmallTailorBOD CreateRandomFor(Mobile m) { SmallBulkEntry[] entries; bool useMaterials; if (useMaterials = Utility.RandomBool()) { entries = SmallBulkEntry.TailorLeather; } else { entries = SmallBulkEntry.TailorCloth; } if (entries.Length > 0) { double theirSkill = m.Skills[SkillName.Tailoring].Base; int amountMax; if (theirSkill >= 70.1) { amountMax = Utility.RandomList(10, 15, 20, 20); } else if (theirSkill >= 50.1) { amountMax = Utility.RandomList(10, 15, 15, 20); } else { amountMax = Utility.RandomList(10, 10, 15, 20); } BulkMaterialType material = BulkMaterialType.None; if (useMaterials && theirSkill >= 70.1) { for (int i = 0; i < 20; ++i) { BulkMaterialType check = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances); double skillReq = 0.0; switch (check) { case BulkMaterialType.DullCopper: skillReq = 65.0; break; case BulkMaterialType.Bronze: skillReq = 80.0; break; case BulkMaterialType.Gold: skillReq = 85.0; break; case BulkMaterialType.Agapite: skillReq = 90.0; break; case BulkMaterialType.Verite: skillReq = 95.0; break; case BulkMaterialType.Valorite: skillReq = 100.0; break; case BulkMaterialType.Spined: skillReq = 65.0; break; case BulkMaterialType.Horned: skillReq = 80.0; break; case BulkMaterialType.Barbed: skillReq = 99.0; break; } if (theirSkill >= skillReq) { material = check; break; } } } double excChance = 0.0; if (theirSkill >= 70.1) { excChance = (theirSkill + 80.0) / 200.0; } bool reqExceptional = (excChance > Utility.RandomDouble()); SmallBulkEntry entry = null; CraftSystem system = DefTailoring.CraftSystem; for (int i = 0; i < 150; ++i) { SmallBulkEntry check = entries[Utility.Random(entries.Length)]; CraftItem item = system.CraftItems.SearchFor(check.Type); if (item != null) { bool allRequiredSkills = true; double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { if (reqExceptional) { chance = item.GetExceptionalChance(system, chance, m); } if (chance > 0.0) { entry = check; break; } } } } if (entry != null) { return(new SmallTailorBOD(entry, material, amountMax, reqExceptional)); } } return(null); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue) { PlayerConstructed = true; Type resourceType = typeRes; if (resourceType == null) { resourceType = craftItem.Resources.GetAt(0).ItemType; } if (!craftItem.ForceNonExceptional) { Resource = CraftResources.GetFromType(resourceType); } CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } if (1 < craftItem.Resources.Count) { resourceType = craftItem.Resources.GetAt(1).ItemType; if (resourceType == typeof(StarSapphire)) { GemType = GemType.StarSapphire; } else if (resourceType == typeof(Emerald)) { GemType = GemType.Emerald; } else if (resourceType == typeof(Sapphire)) { GemType = GemType.Sapphire; } else if (resourceType == typeof(Ruby)) { GemType = GemType.Ruby; } else if (resourceType == typeof(Citrine)) { GemType = GemType.Citrine; } else if (resourceType == typeof(Amethyst)) { GemType = GemType.Amethyst; } else if (resourceType == typeof(Tourmaline)) { GemType = GemType.Tourmaline; } else if (resourceType == typeof(Amber)) { GemType = GemType.Amber; } else if (resourceType == typeof(Diamond)) { GemType = GemType.Diamond; } } #region Mondain's Legacy m_Quality = (ItemQuality)quality; if (makersMark) { m_Crafter = from; } #endregion return(1); }
public static SmallSmithBOD CreateRandomFor(Mobile m) { SmallBulkEntry[] entries; bool useMaterials; if (useMaterials = Utility.RandomBool()) { entries = SmallBulkEntry.BlacksmithArmor; } else { entries = SmallBulkEntry.BlacksmithWeapons; } if (entries.Length > 0) { double theirSkill = m.Skills[SkillName.Blacksmith].Base; int amountMax; if (theirSkill >= 70.1) { amountMax = Utility.RandomList(10, 15, 20, 20); } else if (theirSkill >= 50.1) { amountMax = Utility.RandomList(10, 15, 15, 20); } else { amountMax = Utility.RandomList(10, 10, 15, 20); } BulkMaterialType material = BulkMaterialType.None; if (useMaterials && theirSkill >= 70.1) { for (int i = 0; i < 20; ++i) { BulkMaterialType check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances); double skillReq = 0.0; switch (check) { case BulkMaterialType.DullCopper: skillReq = 65.0; break; case BulkMaterialType.ShadowIron: skillReq = 70.0; break; case BulkMaterialType.Copper: skillReq = 75.0; break; case BulkMaterialType.Bronze: skillReq = 80.0; break; case BulkMaterialType.Gold: skillReq = 85.0; break; case BulkMaterialType.Agapite: skillReq = 90.0; break; case BulkMaterialType.Verite: skillReq = 95.0; break; case BulkMaterialType.Valorite: skillReq = 100.0; break; case BulkMaterialType.Spined: skillReq = 65.0; break; case BulkMaterialType.Horned: skillReq = 80.0; break; case BulkMaterialType.Barbed: skillReq = 99.0; break; } if (theirSkill >= skillReq) { material = check; break; } } } double excChance = 0.0; if (theirSkill >= 70.1) { excChance = (theirSkill + 80.0) / 200.0; } bool reqExceptional = (excChance > Utility.RandomDouble()); CraftSystem system = DefBlacksmithy.CraftSystem; List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>(); for (int i = 0; i < entries.Length; ++i) { CraftItem item = system.CraftItems.SearchFor(entries[i].Type); if (item != null) { bool allRequiredSkills = true; double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { if (reqExceptional) { chance = item.GetExceptionalChance(system, chance, m); } if (chance > 0.0) { validEntries.Add(entries[i]); } } } } if (validEntries.Count > 0) { SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)]; return(new SmallSmithBOD(entry, material, amountMax, reqExceptional)); } } return(null); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue) { Quality = (ItemQuality)quality; return(quality); }
public bool OnCraft(bool exceptional, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { Exceptional = exceptional; if (makersMark) { Crafter = from; } PlayerConstructed = true; Type resourceType = typeRes; if (resourceType == null) { resourceType = craftItem.Ressources.GetAt(0).ItemType; } Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } if (1 < craftItem.Ressources.Count) { resourceType = craftItem.Ressources.GetAt(1).ItemType; if (resourceType == typeof(StarSapphire)) { GemType = GemType.StarSapphire; } else if (resourceType == typeof(Emerald)) { GemType = GemType.Emerald; } else if (resourceType == typeof(Sapphire)) { GemType = GemType.Sapphire; } else if (resourceType == typeof(Ruby)) { GemType = GemType.Ruby; } else if (resourceType == typeof(Citrine)) { GemType = GemType.Citrine; } else if (resourceType == typeof(Amethyst)) { GemType = GemType.Amethyst; } else if (resourceType == typeof(Tourmaline)) { GemType = GemType.Tourmaline; } else if (resourceType == typeof(Amber)) { GemType = GemType.Amber; } else if (resourceType == typeof(Diamond)) { GemType = GemType.Diamond; } } return(exceptional); }
public static SmallCarpentryBOD CreateRandomFor(Mobile m) { SmallBulkEntry[] entries; bool useMaterials = Utility.RandomBool(); double theirSkill = BulkOrderSystem.GetBODSkill(m, SkillName.Carpentry); entries = SmallBulkEntry.CarpentrySmalls; if (entries.Length > 0) { int amountMax; if (theirSkill >= 70.1) { amountMax = Utility.RandomList(10, 15, 20, 20); } else if (theirSkill >= 50.1) { amountMax = Utility.RandomList(10, 15, 15, 20); } else { amountMax = Utility.RandomList(10, 10, 15, 20); } BulkMaterialType material = BulkMaterialType.None; if (useMaterials && theirSkill >= 70.1) { for (int i = 0; i < 20; ++i) { BulkMaterialType check = GetRandomMaterial(BulkMaterialType.OakWood, m_CarpentryMaterialChances); double skillReq = GetRequiredSkill(check); if (theirSkill >= skillReq) { material = check; break; } } } double excChance = 0.0; if (theirSkill >= 70.1) { excChance = (theirSkill + 80.0) / 200.0; } bool reqExceptional = (excChance > Utility.RandomDouble()); CraftSystem system = DefCarpentry.CraftSystem; List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>(); for (int i = 0; i < entries.Length; ++i) { CraftItem item = system.CraftItems.SearchFor(entries[i].Type); if (item != null) { bool allRequiredSkills = true; double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { if (reqExceptional) { chance = item.GetExceptionalChance(system, chance, m); } if (chance > 0.0) { validEntries.Add(entries[i]); } } } } if (validEntries.Count > 0) { SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)]; return(new SmallCarpentryBOD(entry, material, amountMax, reqExceptional)); } } return(null); }
public static SmallTailorBOD CreateRandomFor(Mobile m) { SmallBulkEntry[] entries; bool useMaterials = Utility.RandomBool(); double theirSkill = m.Skills[SkillName.Tailoring].Base; if (useMaterials = Utility.RandomBool() && theirSkill >= 6.2) // Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill. { entries = SmallBulkEntry.TailorLeather; } else { entries = SmallBulkEntry.TailorCloth; } if (entries.Length > 0) { int amountMax; if (theirSkill >= 70.1) { amountMax = Utility.RandomList(10, 15, 20, 20); } else if (theirSkill >= 50.1) { amountMax = Utility.RandomList(10, 15, 15, 20); } else { amountMax = Utility.RandomList(10, 10, 15, 20); } BulkMaterialType material = BulkMaterialType.None; if (useMaterials && theirSkill >= 70.1) { for (int i = 0; i < 20; ++i) { BulkMaterialType check = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances); double skillReq = 0.0; switch (check) { //daat99 OWLTR start - custom resources case BulkMaterialType.DullCopper: skillReq = 52.0; break; case BulkMaterialType.ShadowIron: skillReq = 56.0; break; case BulkMaterialType.Copper: skillReq = 60.0; break; case BulkMaterialType.Bronze: skillReq = 64.0; break; case BulkMaterialType.Gold: skillReq = 68.0; break; case BulkMaterialType.Agapite: skillReq = 72.0; break; case BulkMaterialType.Verite: skillReq = 76.0; break; case BulkMaterialType.Valorite: skillReq = 80.0; break; case BulkMaterialType.Blaze: skillReq = 84.0; break; case BulkMaterialType.Ice: skillReq = 88.0; break; case BulkMaterialType.Toxic: skillReq = 92.0; break; case BulkMaterialType.Electrum: skillReq = 96.0; break; case BulkMaterialType.Platinum: skillReq = 100.0; break; case BulkMaterialType.Spined: skillReq = 64.0; break; case BulkMaterialType.Horned: skillReq = 68.0; break; case BulkMaterialType.Barbed: skillReq = 72.0; break; case BulkMaterialType.Polar: skillReq = 76.0; break; case BulkMaterialType.Synthetic: skillReq = 80.0; break; case BulkMaterialType.BlazeL: skillReq = 84.0; break; case BulkMaterialType.Daemonic: skillReq = 88.0; break; case BulkMaterialType.Shadow: skillReq = 92.0; break; case BulkMaterialType.Frost: skillReq = 96.0; break; case BulkMaterialType.Ethereal: skillReq = 100.0; break; case BulkMaterialType.Heartwood: skillReq = 60.0; break; case BulkMaterialType.Bloodwood: skillReq = 64.0; break; case BulkMaterialType.Frostwood: skillReq = 68.0; break; case BulkMaterialType.OakWood: skillReq = 72.0; break; case BulkMaterialType.AshWood: skillReq = 76.0; break; case BulkMaterialType.YewWood: skillReq = 80.0; break; case BulkMaterialType.Ebony: skillReq = 84.0; break; case BulkMaterialType.Bamboo: skillReq = 88.0; break; case BulkMaterialType.PurpleHeart: skillReq = 92.0; break; case BulkMaterialType.Redwood: skillReq = 96.0; break; case BulkMaterialType.Petrified: skillReq = 100.0; break; //daat99 OWLTR end - custom resources } if (theirSkill >= skillReq) { material = check; break; } } } double excChance = 0.0; if (theirSkill >= 70.1) { excChance = (theirSkill + 80.0) / 200.0; } bool reqExceptional = (excChance > Utility.RandomDouble()); CraftSystem system = DefTailoring.CraftSystem; List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>(); for (int i = 0; i < entries.Length; ++i) { CraftItem item = system.CraftItems.SearchFor(entries[i].Type); if (item != null) { bool allRequiredSkills = true; double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { if (reqExceptional) { chance = item.GetExceptionalChance(system, chance, m); } if (chance > 0.0) { validEntries.Add(entries[i]); } } } } if (validEntries.Count > 0) { SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)]; return(new SmallTailorBOD(entry, material, amountMax, reqExceptional)); } } return(null); }
public void OnEndDrag(PointerEventData data) { if (data.button == PointerEventData.InputButton.Left) { canvasGroup.blocksRaycasts = true; Transform newSlot = null; if (data.pointerEnter != null) { newSlot = data.pointerEnter.transform; } if (newSlot != null) { //getting the items from the slots, GameObjects and RectTransform GameObject firstItemGameObject = this.gameObject; GameObject secondItemGameObject = newSlot.parent.gameObject; RectTransform firstItemRectTransform = this.gameObject.GetComponent <RectTransform>(); RectTransform secondItemRectTransform = newSlot.parent.GetComponent <RectTransform>(); Item firstItem = rectTransform.GetComponent <ItemOnObject>().item; Item secondItem = new Item(); if (newSlot.parent.GetComponent <ItemOnObject>() != null) { secondItem = newSlot.parent.GetComponent <ItemOnObject>().item; } //get some informations about the two items bool sameItem = firstItem.itemName == secondItem.itemName; bool sameItemRerferenced = firstItem.Equals(secondItem); bool secondItemStack = false; bool firstItemStack = false; if (sameItem) { firstItemStack = firstItem.itemValue < firstItem.maxStack; secondItemStack = secondItem.itemValue < secondItem.maxStack; } GameObject Inventory = secondItemRectTransform.parent.gameObject; if (Inventory.tag == "Slot") { Inventory = secondItemRectTransform.parent.parent.parent.gameObject; } if (Inventory.tag.Equals("Slot")) { Inventory = Inventory.transform.parent.parent.gameObject; } //dragging in an Inventory if (Inventory.GetComponent <Hotbar>() == null && Inventory.GetComponent <EquipmentSystem>() == null && Inventory.GetComponent <CraftSystem>() == null) { //you cannot attach items to the resultslot of the craftsystem if (newSlot.transform.parent.tag == "ResultSlot" || newSlot.transform.tag == "ResultSlot" || newSlot.transform.parent.parent.tag == "ResultSlot") { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } else { int newSlotChildCount = newSlot.transform.parent.childCount; bool isOnSlot = newSlot.transform.parent.GetChild(0).tag == "ItemIcon"; //dragging on a slot where allready is an item on if (newSlotChildCount != 0 && isOnSlot) { //check if the items fits into the other item bool fitsIntoStack = false; if (sameItem) { fitsIntoStack = (firstItem.itemValue + secondItem.itemValue) <= firstItem.maxStack; } //if the item is stackable checking if the firstitemstack and seconditemstack is not full and check if they are the same items if (inventory.stackable && sameItem && firstItemStack && secondItemStack) { //if the item does not fit into the other item if (fitsIntoStack && !sameItemRerferenced) { secondItem.itemValue = firstItem.itemValue + secondItem.itemValue; secondItemGameObject.transform.SetParent(newSlot.parent.parent); Destroy(firstItemGameObject); secondItemRectTransform.localPosition = Vector3.zero; if (secondItemGameObject.GetComponent <ConsumeItem>().duplication != null) { GameObject dup = secondItemGameObject.GetComponent <ConsumeItem>().duplication; dup.GetComponent <ItemOnObject>().item.itemValue = secondItem.itemValue; dup.GetComponent <SplitItem>().inv.stackableSettings(); dup.transform.parent.parent.parent.GetComponent <Inventory>().updateItemList(); } } else { //creates the rest of the item int rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { firstItem.itemValue = firstItem.maxStack; secondItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; } } } //if does not fit else { //creates the rest of the item int rest = 0; if (sameItem) { rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; } //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { secondItem.itemValue = firstItem.maxStack; firstItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; } //if they are different items or the stack is full, they get swapped else if (!fitsIntoStack && rest == 0) { //if you are dragging an item from equipmentsystem to the inventory and try to swap it with the same itemtype if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null && firstItem.itemType == secondItem.itemType) { newSlot.transform.parent.parent.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); oldSlot.transform.parent.parent.GetComponent <Inventory>().EquiptItem(secondItem); firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; if (secondItemGameObject.GetComponent <ConsumeItem>().duplication != null) { Destroy(secondItemGameObject.GetComponent <ConsumeItem>().duplication); } } //if you are dragging an item from the equipmentsystem to the inventory and they are not from the same itemtype they do not get swapped. else if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null && firstItem.itemType != secondItem.itemType) { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } //swapping for the rest of the inventorys else if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null) { firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; } } } } //empty slot else { if (newSlot.tag != "Slot" && newSlot.tag != "ItemIcon") { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } else { firstItemGameObject.transform.SetParent(newSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; if (newSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null && oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null) { oldSlot.transform.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); } } } } } //dragging into a Hotbar if (Inventory.GetComponent <Hotbar>() != null) { int newSlotChildCount = newSlot.transform.parent.childCount; bool isOnSlot = newSlot.transform.parent.GetChild(0).tag == "ItemIcon"; //dragging on a slot where allready is an item on if (newSlotChildCount != 0 && isOnSlot) { //check if the items fits into the other item bool fitsIntoStack = false; if (sameItem) { fitsIntoStack = (firstItem.itemValue + secondItem.itemValue) <= firstItem.maxStack; } //if the item is stackable checking if the firstitemstack and seconditemstack is not full and check if they are the same items if (inventory.stackable && sameItem && firstItemStack && secondItemStack) { //if the item does not fit into the other item if (fitsIntoStack && !sameItemRerferenced) { secondItem.itemValue = firstItem.itemValue + secondItem.itemValue; secondItemGameObject.transform.SetParent(newSlot.parent.parent); Destroy(firstItemGameObject); secondItemRectTransform.localPosition = Vector3.zero; if (secondItemGameObject.GetComponent <ConsumeItem>().duplication != null) { GameObject dup = secondItemGameObject.GetComponent <ConsumeItem>().duplication; dup.GetComponent <ItemOnObject>().item.itemValue = secondItem.itemValue; Inventory.GetComponent <Inventory>().stackableSettings(); dup.transform.parent.parent.parent.GetComponent <Inventory>().updateItemList(); } } else { //creates the rest of the item int rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { firstItem.itemValue = firstItem.maxStack; secondItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; createDuplication(this.gameObject); secondItemGameObject.GetComponent <ConsumeItem>().duplication.GetComponent <ItemOnObject>().item = secondItem; secondItemGameObject.GetComponent <SplitItem>().inv.stackableSettings(); } } } //if does not fit else { //creates the rest of the item int rest = 0; if (sameItem) { rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; } bool fromEquip = oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null; //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { secondItem.itemValue = firstItem.maxStack; firstItem.itemValue = rest; createDuplication(this.gameObject); firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; } //if they are different items or the stack is full, they get swapped else if (!fitsIntoStack && rest == 0) { if (!fromEquip) { firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; if (oldSlot.transform.parent.parent.gameObject.Equals(GameObject.FindGameObjectWithTag("MainInventory"))) { Destroy(secondItemGameObject.GetComponent <ConsumeItem>().duplication); createDuplication(firstItemGameObject); } else { createDuplication(firstItemGameObject); } } else { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } } } } //empty slot else { if (newSlot.tag != "Slot" && newSlot.tag != "ItemIcon") { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } else { firstItemGameObject.transform.SetParent(newSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; if (newSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null && oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null) { oldSlot.transform.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); } createDuplication(firstItemGameObject); } } } //dragging into a equipmentsystem/charactersystem if (Inventory.GetComponent <EquipmentSystem>() != null) { ItemType[] itemTypeOfSlots = GameObject.FindGameObjectWithTag("EquipmentSystem").GetComponent <EquipmentSystem>().itemTypeOfSlots; int newSlotChildCount = newSlot.transform.parent.childCount; bool isOnSlot = newSlot.transform.parent.GetChild(0).tag == "ItemIcon"; bool sameItemType = firstItem.itemType == secondItem.itemType; bool fromHot = oldSlot.transform.parent.parent.GetComponent <Hotbar>() != null; //dragging on a slot where allready is an item on if (newSlotChildCount != 0 && isOnSlot) { //items getting swapped if they are the same itemtype if (sameItemType && !sameItemRerferenced) // { Transform temp1 = secondItemGameObject.transform.parent.parent.parent; Transform temp2 = oldSlot.transform.parent.parent; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; if (!temp1.Equals(temp2)) { if (firstItem.itemType == ItemType.UFPS_Weapon) { Inventory.GetComponent <Inventory>().UnEquipItem1(secondItem); Inventory.GetComponent <Inventory>().EquiptItem(firstItem); } else { Inventory.GetComponent <Inventory>().EquiptItem(firstItem); if (secondItem.itemType != ItemType.Backpack) { Inventory.GetComponent <Inventory>().UnEquipItem1(secondItem); } } } if (fromHot) { createDuplication(secondItemGameObject); } } //if they are not from the same Itemtype the dragged one getting placed back else { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; if (fromHot) { createDuplication(firstItemGameObject); } } } //if the slot is empty else { for (int i = 0; i < newSlot.parent.childCount; i++) { if (newSlot.Equals(newSlot.parent.GetChild(i))) { //checking if it is the right slot for the item if (itemTypeOfSlots[i] == transform.GetComponent <ItemOnObject>().item.itemType) { transform.SetParent(newSlot); rectTransform.localPosition = Vector3.zero; if (!oldSlot.transform.parent.parent.Equals(newSlot.transform.parent.parent)) { Inventory.GetComponent <Inventory>().EquiptItem(firstItem); } } //else it get back to the old slot else { transform.SetParent(oldSlot.transform); rectTransform.localPosition = Vector3.zero; if (fromHot) { createDuplication(firstItemGameObject); } } } } } } if (Inventory.GetComponent <CraftSystem>() != null) { CraftSystem cS = Inventory.GetComponent <CraftSystem>(); int newSlotChildCount = newSlot.transform.parent.childCount; bool isOnSlot = newSlot.transform.parent.GetChild(0).tag == "ItemIcon"; //dragging on a slot where allready is an item on if (newSlotChildCount != 0 && isOnSlot) { //check if the items fits into the other item bool fitsIntoStack = false; if (sameItem) { fitsIntoStack = (firstItem.itemValue + secondItem.itemValue) <= firstItem.maxStack; } //if the item is stackable checking if the firstitemstack and seconditemstack is not full and check if they are the same items if (inventory.stackable && sameItem && firstItemStack && secondItemStack) { //if the item does not fit into the other item if (fitsIntoStack && !sameItemRerferenced) { secondItem.itemValue = firstItem.itemValue + secondItem.itemValue; secondItemGameObject.transform.SetParent(newSlot.parent.parent); Destroy(firstItemGameObject); secondItemRectTransform.localPosition = Vector3.zero; if (secondItemGameObject.GetComponent <ConsumeItem>().duplication != null) { GameObject dup = secondItemGameObject.GetComponent <ConsumeItem>().duplication; dup.GetComponent <ItemOnObject>().item.itemValue = secondItem.itemValue; dup.GetComponent <SplitItem>().inv.stackableSettings(); dup.transform.parent.parent.parent.GetComponent <Inventory>().updateItemList(); } cS.ListWithItem(); } else { //creates the rest of the item int rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { firstItem.itemValue = firstItem.maxStack; secondItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; cS.ListWithItem(); } } } //if does not fit else { //creates the rest of the item int rest = 0; if (sameItem) { rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; } //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { secondItem.itemValue = firstItem.maxStack; firstItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; cS.ListWithItem(); } //if they are different items or the stack is full, they get swapped else if (!fitsIntoStack && rest == 0) { //if you are dragging an item from equipmentsystem to the inventory and try to swap it with the same itemtype if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null && firstItem.itemType == secondItem.itemType) { firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; oldSlot.transform.parent.parent.GetComponent <Inventory>().EquiptItem(secondItem); newSlot.transform.parent.parent.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); } //if you are dragging an item from the equipmentsystem to the inventory and they are not from the same itemtype they do not get swapped. else if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null && firstItem.itemType != secondItem.itemType) { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } //swapping for the rest of the inventorys else if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null) { firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; } } } } else { if (newSlot.tag != "Slot" && newSlot.tag != "ItemIcon") { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } else { firstItemGameObject.transform.SetParent(newSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; if (newSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null && oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null) { oldSlot.transform.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); } } } } } else { GameObject dropItem = (GameObject)Instantiate(GetComponent <ItemOnObject>().item.itemModel); dropItem.AddComponent <PickUpItem>(); dropItem.GetComponent <PickUpItem>().item = this.gameObject.GetComponent <ItemOnObject>().item; dropItem.transform.localPosition = GameObject.FindGameObjectWithTag("PlayerI").transform.localPosition; inventory.OnUpdateItemList(); if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null) { inventory.GetComponent <Inventory>().UnEquipItem1(dropItem.GetComponent <PickUpItem>().item); } Destroy(this.gameObject); } } inventory.OnUpdateItemList(); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { PlayerConstructed = true; Type resourceType = typeRes; if (resourceType == null) { resourceType = craftItem.Resources.GetAt(0).ItemType; } if (!craftItem.ForceNonExceptional) { Resource = CraftResources.GetFromType(resourceType); } CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } //daat99 OWLTR start - runic jewels if (Core.AOS && tool is BaseRunicTool && OWLTROptionsManager.IsEnabled(OWLTROptionsManager.OPTIONS_ENUM.RECIPE_CRAFT)) { ((BaseRunicTool)tool).ApplyAttributesTo(this); } //daat99 OWLTR end - reunic jewels if (1 < craftItem.Resources.Count) { resourceType = craftItem.Resources.GetAt(1).ItemType; if (resourceType == typeof(StarSapphire)) { GemType = GemType.StarSapphire; } else if (resourceType == typeof(Emerald)) { GemType = GemType.Emerald; } else if (resourceType == typeof(Sapphire)) { GemType = GemType.Sapphire; } else if (resourceType == typeof(Ruby)) { GemType = GemType.Ruby; } else if (resourceType == typeof(Citrine)) { GemType = GemType.Citrine; } else if (resourceType == typeof(Amethyst)) { GemType = GemType.Amethyst; } else if (resourceType == typeof(Tourmaline)) { GemType = GemType.Tourmaline; } else if (resourceType == typeof(Amber)) { GemType = GemType.Amber; } else if (resourceType == typeof(Diamond)) { GemType = GemType.Diamond; } } #region Mondain's Legacy m_Quality = (ItemQuality)quality; if (makersMark) { m_Crafter = from; } #endregion return(1); }
public static SmallFletcherBOD CreateRandomFor(Mobile m) { SmallBulkEntry[] entries; bool useMaterials; if (useMaterials = Utility.RandomBool()) { entries = SmallBulkEntry.FletcherAllBow; } else { entries = SmallBulkEntry.FletcherAllBow; } if (entries.Length > 0) { double theirSkill = m.Skills[SkillName.Fletching].Base; int amountMax; if (theirSkill >= 70.1) { amountMax = Utility.RandomList(10, 15, 20, 20); } else if (theirSkill >= 50.1) { amountMax = Utility.RandomList(10, 15, 15, 20); } else { amountMax = Utility.RandomList(10, 10, 15, 20); } BulkMaterialType material = BulkMaterialType.None; if (useMaterials && theirSkill >= 70.1) { for (int i = 0; i < 20; ++i) { BulkMaterialType check = GetRandomMaterial(BulkMaterialType.OakWood, m_FletchingMaterialChances); double skillReq = 0.0; switch (check) { case BulkMaterialType.DullCopper: skillReq = 52.0; break; case BulkMaterialType.ShadowIron: skillReq = 56.0; break; case BulkMaterialType.Copper: skillReq = 60.0; break; case BulkMaterialType.Bronze: skillReq = 64.0; break; case BulkMaterialType.Gold: skillReq = 68.0; break; case BulkMaterialType.Agapite: skillReq = 72.0; break; case BulkMaterialType.Verite: skillReq = 76.0; break; case BulkMaterialType.Valorite: skillReq = 80.0; break; case BulkMaterialType.Blaze: skillReq = 84.0; break; case BulkMaterialType.Ice: skillReq = 88.0; break; case BulkMaterialType.Toxic: skillReq = 92.0; break; case BulkMaterialType.Electrum: skillReq = 96.0; break; case BulkMaterialType.Platinum: skillReq = 100.0; break; case BulkMaterialType.Spined: skillReq = 64.0; break; case BulkMaterialType.Horned: skillReq = 68.0; break; case BulkMaterialType.Barbed: skillReq = 72.0; break; case BulkMaterialType.Polar: skillReq = 76.0; break; case BulkMaterialType.Synthetic: skillReq = 80.0; break; case BulkMaterialType.BlazeL: skillReq = 84.0; break; case BulkMaterialType.Daemonic: skillReq = 88.0; break; case BulkMaterialType.Shadow: skillReq = 92.0; break; case BulkMaterialType.Frost: skillReq = 96.0; break; case BulkMaterialType.Ethereal: skillReq = 100.0; break; case BulkMaterialType.OakWood: skillReq = 60.0; break; case BulkMaterialType.AshWood: skillReq = 64.0; break; case BulkMaterialType.YewWood: skillReq = 68.0; break; case BulkMaterialType.Heartwood: skillReq = 72.0; break; case BulkMaterialType.Bloodwood: skillReq = 76.0; break; case BulkMaterialType.Frostwood: skillReq = 80.0; break; case BulkMaterialType.Ebony: skillReq = 84.0; break; case BulkMaterialType.Bamboo: skillReq = 88.0; break; case BulkMaterialType.PurpleHeart: skillReq = 92.0; break; case BulkMaterialType.Redwood: skillReq = 96.0; break; case BulkMaterialType.Petrified: skillReq = 100.0; break; } if (theirSkill >= skillReq) { material = check; break; } } } double excChance = 0.0; if (theirSkill >= 70.1) { excChance = (theirSkill + 80.0) / 200.0; } bool reqExceptional = (excChance > Utility.RandomDouble()); SmallBulkEntry entry = null; CraftSystem system = DefBowFletching.CraftSystem; for (int i = 0; i < 150; ++i) { SmallBulkEntry check = entries[Utility.Random(entries.Length)]; CraftItem item = system.CraftItems.SearchFor(check.Type); if (item != null) { bool allRequiredSkills = true; double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { if (reqExceptional) { chance = item.GetExceptionalChance(system, chance, m); } if (chance > 0.0) { entry = check; break; } } } } if (entry != null) { return(new SmallFletcherBOD(entry, material, amountMax, reqExceptional)); } } return(null); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { if (Core.ML) { Quality = (CraftQuality)quality; Type resourceType = typeRes; if (resourceType == null) { resourceType = craftItem.Resources.GetAt(0).ItemType; } Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Resource = DefaultResource; } if (makersMark) { Crafter = from; } } if (from.CheckSkill(SkillName.Tinkering, -5.0, 15.0)) { from.SendLocalizedMessage(500636); // Your tinker skill was sufficient to make the item lockable. Key key = new Key(KeyType.Copper, Key.RandomValue()); KeyValue = key.KeyValue; DropItem(key); double tinkering = from.Skills[SkillName.Tinkering].Value; int level = (int)(tinkering * 0.8); RequiredSkill = level - 4; LockLevel = level - 14; MaxLockLevel = level + 35; if (LockLevel == 0) { LockLevel = -1; } else if (LockLevel > 95) { LockLevel = 95; } if (RequiredSkill > 95) { RequiredSkill = 95; } if (MaxLockLevel > 95) { MaxLockLevel = 95; } } else { from.SendLocalizedMessage(500637); // Your tinker skill was insufficient to make the item lockable. } return(quality); }
public bool OnCraft(bool exceptional, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { CraftInit(from); return(false); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue) { UsesRemaining = 1; Hue = 1150; return(quality); }
public static void DoCraft(Mobile from, CraftSystem system, Type typeRes, BaseTool tool, CraftItem craftItem, PlantPigment pigments) { CraftContext context = system.GetContext(from); if (context != null) { context.OnMade(craftItem); } bool allRequiredSkills = true; double chance = craftItem.GetSuccessChance(from, typeRes, system, true, ref allRequiredSkills); if (chance > 0.0) { chance += craftItem.GetTalismanBonus(from, system); } if (allRequiredSkills) { pigments.Consume(); if (chance < Utility.RandomDouble()) { from.SendGump(new CraftGump(from, system, tool, 1044043)); // You failed to create the item, and some of your materials are lost. } else { from.Backpack.ConsumeTotal(typeof(ColorFixative), 1); bool toolBroken = false; tool.UsesRemaining--; if (tool.UsesRemaining < 1) { toolBroken = true; } if (toolBroken) { tool.Delete(); from.SendLocalizedMessage(1044038); // You have worn out your tool! from.SendLocalizedMessage(1044154); // You create the item. } else { // You create the item. from.SendGump(new CraftGump(from, system, tool, 1044154)); } from.AddToBackpack(new NaturalDye(pigments.PlantHue)); } } else { // You don't have the required skills to attempt this item. from.SendGump(new CraftGump(from, system, tool, 1044153)); } }
public override int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue) { return(base.OnCraft(quality, makersMark, from, craftSystem, null, tool, craftItem, resHue)); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { CraftInit(from); return(1); }
public void OnPointerDown(PointerEventData data) { if (this.gameObject.transform.parent.parent.parent.GetComponent <EquipmentSystem>() == null) { bool gearable = false; Inventory inventory = transform.parent.parent.parent.GetComponent <Inventory>(); if (eS != null) { itemTypeOfSlot = eS.itemTypeOfSlots; } if (data.button == PointerEventData.InputButton.Left && DoubleClick() && item.itemType == ItemType.Consumable) // if we doubleClick with the mouse's left button { //item from craft system to inventory if (transform.parent.GetComponent <CraftResultSlot>() != null) { bool check = inv.GetComponent <Inventory>().checkIfItemAllreadyExist(item.itemID, item.itemValue); if (!check) { for (int j = 0; j < inv.transform.GetChild(1).transform.childCount; j++) { if (inv.transform.GetChild(1).transform.GetChild(j).childCount != 0) { //if the item we're crafting has a slot filled in the main inventory and there are some places if (item.itemID.Equals(inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemID) && inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemValue != inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.maxStack) { //filling the remaining places before adding the rest through the normal add if (inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemValue + item.itemValue > inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.maxStack) { item.itemValue -= (inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.maxStack - inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemValue); inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.itemValue = inv.transform.GetChild(1).transform.GetChild(j).GetChild(0).GetComponent <ItemOnObject>().item.maxStack; } } } } //normal add numberOfItems = item.itemValue / item.maxStack; for (int i = 0; i < numberOfItems; i++) { inv.GetComponent <Inventory>().addItemToInventory(item.itemID, item.maxStack); inv.GetComponent <Inventory>().stackableSettings(); } if (item.itemValue % item.maxStack != 0) { inv.GetComponent <Inventory>().addItemToInventory(item.itemID, item.itemValue % item.maxStack); inv.GetComponent <Inventory>().stackableSettings(); } } CraftSystem cS = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().craftSystem.GetComponent <CraftSystem>(); cS.deleteItems(item); CraftResultSlot result = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().craftSystem.transform.GetChild(3).GetComponent <CraftResultSlot>(); tooltip.deactivateTooltip(); gearable = true; inv.GetComponent <Inventory>().updateItemList(); } else { bool stop = false; if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount == 0) { stop = true; if (eS.transform.GetChild(1).GetChild(i).parent.parent.GetComponent <EquipmentSystem>() != null && this.gameObject.transform.parent.parent.parent.GetComponent <EquipmentSystem>() != null) { } else { inventory.EquiptItem(item); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.updateItemList(); gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } break; } } } if (!stop) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount != 0) { GameObject otherItemFromCharacterSystem = eS.transform.GetChild(1).GetChild(i).GetChild(0).gameObject; Item otherSlotItem = otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item; if (item.itemType == ItemType.UFPS_Weapon) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); inventory.EquiptItem(item); } else { inventory.EquiptItem(item); if (item.itemType != ItemType.Backpack) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); } } if (this == null) { GameObject dropItem = (GameObject)Instantiate(otherSlotItem.itemModel); dropItem.AddComponent <PickUpItem>(); dropItem.GetComponent <PickUpItem>().item = otherSlotItem; dropItem.transform.localPosition = GameObject.FindGameObjectWithTag("Player").transform.localPosition; inventory.OnUpdateItemList(); } else { otherItemFromCharacterSystem.transform.SetParent(this.transform.parent); otherItemFromCharacterSystem.GetComponent <RectTransform>().localPosition = Vector3.zero; if (this.gameObject.transform.parent.parent.parent.GetComponent <Hotbar>() != null) { createDuplication(otherItemFromCharacterSystem); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; } gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.OnUpdateItemList(); break; } } } } } } if (!gearable && item.itemType != ItemType.UFPS_Ammo && item.itemType != ItemType.UFPS_Grenade) { Item itemFromDup = null; if (duplication != null) { itemFromDup = duplication.GetComponent <ItemOnObject>().item; } inventory.ConsumeItem(item); item.itemValue--; if (itemFromDup != null) { duplication.GetComponent <ItemOnObject>().item.itemValue--; if (itemFromDup.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(duplication.gameObject); } } if (item.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(this.gameObject); } } } } }
public RepairSkillInfo(CraftSystem system, Type nearbyType, TextDefinition notNearbyMessage, TextDefinition name) : this(system, new Type[] { nearbyType }, notNearbyMessage, name) { }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { Type resourceType = typeRes; if (resourceType == null) { resourceType = craftItem.Resources.GetAt(0).ItemType; } Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } if (1 < craftItem.Resources.Count) { resourceType = craftItem.Resources.GetAt(1).ItemType; if (resourceType == typeof(StarSapphire)) { GemType = GemType.StarSapphire; } else if (resourceType == typeof(Emerald)) { GemType = GemType.Emerald; } else if (resourceType == typeof(Sapphire)) { GemType = GemType.Sapphire; } else if (resourceType == typeof(Ruby)) { GemType = GemType.Ruby; } else if (resourceType == typeof(Citrine)) { GemType = GemType.Citrine; } else if (resourceType == typeof(Amethyst)) { GemType = GemType.Amethyst; } else if (resourceType == typeof(Tourmaline)) { GemType = GemType.Tourmaline; } else if (resourceType == typeof(Amber)) { GemType = GemType.Amber; } else if (resourceType == typeof(Diamond)) { GemType = GemType.Diamond; } } return(1); }
public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { int magery = from.Skills.Magery.BaseFixedPoint; if (magery >= 800) { int[] propertyCounts; int minIntensity; int maxIntensity; if (magery >= 1000) { if (magery >= 1200) { propertyCounts = m_LegendPropertyCounts; } else if (magery >= 1100) { propertyCounts = m_ElderPropertyCounts; } else { propertyCounts = m_GrandPropertyCounts; } minIntensity = 55; maxIntensity = 75; } else if (magery >= 900) { propertyCounts = m_MasterPropertyCounts; minIntensity = 25; maxIntensity = 45; } else { propertyCounts = m_AdeptPropertyCounts; minIntensity = 0; maxIntensity = 15; } int propertyCount = propertyCounts[Utility.Random(propertyCounts.Length)]; BaseRunicTool.ApplyAttributesTo(this, true, 0, propertyCount, minIntensity, maxIntensity); } if (makersMark) { Crafter = from; } m_Quality = (BookQuality)(quality - 1); return(quality); }
public void OnEndDrag(PointerEventData data) { if (data.button == PointerEventData.InputButton.Left) { canvasGroup.blocksRaycasts = true; Transform newSlot = null; if (data.pointerEnter != null) { newSlot = data.pointerEnter.transform; } if (newSlot != null) { //getting the items from the slots, GameObjects and RectTransform GameObject firstItemGameObject = this.gameObject; GameObject secondItemGameObject = newSlot.parent.gameObject; RectTransform firstItemRectTransform = this.gameObject.GetComponent <RectTransform>(); RectTransform secondItemRectTransform = newSlot.parent.GetComponent <RectTransform>(); Item firstItem = rectTransform.GetComponent <ItemOnObject>().item; Item secondItem = new Item(); if (newSlot.parent.GetComponent <ItemOnObject>() != null) { secondItem = newSlot.parent.GetComponent <ItemOnObject>().item; } //get some informations about the two items bool sameItem = firstItem.itemName == secondItem.itemName; bool sameItemRerferenced = firstItem.Equals(secondItem); bool secondItemStack = false; bool firstItemStack = false; if (sameItem) { firstItemStack = firstItem.itemValue < firstItem.maxStack; secondItemStack = secondItem.itemValue < secondItem.maxStack; } GameObject Inventory = secondItemRectTransform.parent.gameObject; if (Inventory.tag == "Slot") { Inventory = secondItemRectTransform.parent.parent.parent.gameObject; } if (Inventory.tag.Equals("Slot")) { Inventory = Inventory.transform.parent.parent.gameObject; } //dragging in an Inventory if (Inventory.GetComponent <Hotbar>() == null && Inventory.GetComponent <EquipmentSystem>() == null && Inventory.GetComponent <CraftSystem>() == null) { //you cannot attach items to the resultslot of the craftsystem if (newSlot.transform.parent.tag == "ResultSlot" || newSlot.transform.tag == "ResultSlot" || newSlot.transform.parent.parent.tag == "ResultSlot") { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } else { int newSlotChildCount = newSlot.transform.parent.childCount; bool isOnSlot = newSlot.transform.parent.GetChild(0).tag == "ItemIcon"; //dragging on a slot where allready is an item on if (newSlotChildCount != 0 && isOnSlot) { //check if the items fits into the other item bool fitsIntoStack = false; if (sameItem) { fitsIntoStack = (firstItem.itemValue + secondItem.itemValue) <= firstItem.maxStack; } //if the item is stackable checking if the firstitemstack and seconditemstack is not full and check if they are the same items if (inventory.stackable && sameItem && firstItemStack && secondItemStack) { //if the item does not fit into the other item if (fitsIntoStack && !sameItemRerferenced) { secondItem.itemValue = firstItem.itemValue + secondItem.itemValue; secondItemGameObject.transform.SetParent(newSlot.parent.parent); Destroy(firstItemGameObject); secondItemRectTransform.localPosition = Vector3.zero; if (secondItemGameObject.GetComponent <ConsumeItem>().duplication != null) { GameObject dup = secondItemGameObject.GetComponent <ConsumeItem>().duplication; dup.GetComponent <ItemOnObject>().item.itemValue = secondItem.itemValue; dup.GetComponent <SplitItem>().inv.stackableSettings(); dup.transform.parent.parent.parent.GetComponent <Inventory>().updateItemList(); } } else { //creates the rest of the item int rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { firstItem.itemValue = firstItem.maxStack; secondItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; } } } //if does not fit else { //creates the rest of the item int rest = 0; if (sameItem) { rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; } //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { secondItem.itemValue = firstItem.maxStack; firstItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; } //if they are different items or the stack is full, they get swapped else if (!fitsIntoStack && rest == 0) { //if you are dragging an item from equipmentsystem to the inventory and try to swap it with the same itemtype if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null && firstItem.itemType == secondItem.itemType) { newSlot.transform.parent.parent.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); oldSlot.transform.parent.parent.GetComponent <Inventory>().EquiptItem(secondItem); firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; if (secondItemGameObject.GetComponent <ConsumeItem>().duplication != null) { Destroy(secondItemGameObject.GetComponent <ConsumeItem>().duplication); } } //if you are dragging an item from the equipmentsystem to the inventory and they are not from the same itemtype they do not get swapped. else if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null && firstItem.itemType != secondItem.itemType) { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } //swapping for the rest of the inventorys else if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null) { firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; } } } } //empty slot else { if (newSlot.tag != "Slot" && newSlot.tag != "ItemIcon") { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } else { firstItemGameObject.transform.SetParent(newSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; if (newSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null && oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null) { oldSlot.transform.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); } } } } } //dragging into a Hotbar if (Inventory.GetComponent <Hotbar>() != null) { int newSlotChildCount = newSlot.transform.parent.childCount; bool isOnSlot = newSlot.transform.parent.GetChild(0).tag == "ItemIcon"; //dragging on a slot where allready is an item on if (newSlotChildCount != 0 && isOnSlot) { //check if the items fits into the other item bool fitsIntoStack = false; if (sameItem) { fitsIntoStack = (firstItem.itemValue + secondItem.itemValue) <= firstItem.maxStack; } //if the item is stackable checking if the firstitemstack and seconditemstack is not full and check if they are the same items if (inventory.stackable && sameItem && firstItemStack && secondItemStack) { //if the item does not fit into the other item if (fitsIntoStack && !sameItemRerferenced) { secondItem.itemValue = firstItem.itemValue + secondItem.itemValue; secondItemGameObject.transform.SetParent(newSlot.parent.parent); Destroy(firstItemGameObject); secondItemRectTransform.localPosition = Vector3.zero; if (secondItemGameObject.GetComponent <ConsumeItem>().duplication != null) { GameObject dup = secondItemGameObject.GetComponent <ConsumeItem>().duplication; dup.GetComponent <ItemOnObject>().item.itemValue = secondItem.itemValue; Inventory.GetComponent <Inventory>().stackableSettings(); dup.transform.parent.parent.parent.GetComponent <Inventory>().updateItemList(); } } else { //creates the rest of the item int rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { firstItem.itemValue = firstItem.maxStack; secondItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; createDuplication(this.gameObject); secondItemGameObject.GetComponent <ConsumeItem>().duplication.GetComponent <ItemOnObject>().item = secondItem; secondItemGameObject.GetComponent <SplitItem>().inv.stackableSettings(); } } } //if does not fit else { //creates the rest of the item int rest = 0; if (sameItem) { rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; } bool fromEquip = oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null; //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { secondItem.itemValue = firstItem.maxStack; firstItem.itemValue = rest; createDuplication(this.gameObject); firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; } //if they are different items or the stack is full, they get swapped else if (!fitsIntoStack && rest == 0) { if (!fromEquip) { firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; if (oldSlot.transform.parent.parent.gameObject.Equals(GameObject.FindGameObjectWithTag("MainInventory"))) { Destroy(secondItemGameObject.GetComponent <ConsumeItem>().duplication); createDuplication(firstItemGameObject); } else { createDuplication(firstItemGameObject); } } else { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } } } } //empty slot else { if (newSlot.tag != "Slot" && newSlot.tag != "ItemIcon") { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } else { firstItemGameObject.transform.SetParent(newSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; if (newSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null && oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null) { oldSlot.transform.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); } createDuplication(firstItemGameObject); } } } //dragging into a equipmentsystem/charactersystem if (Inventory.GetComponent <EquipmentSystem>() != null) { ItemType[] itemTypeOfSlots = GameObject.FindGameObjectWithTag("EquipmentSystem").GetComponent <EquipmentSystem>().itemTypeOfSlots; int newSlotChildCount = newSlot.transform.parent.childCount; bool isOnSlot = newSlot.transform.parent.GetChild(0).tag == "ItemIcon"; bool sameItemType = firstItem.itemType == secondItem.itemType; bool fromHot = oldSlot.transform.parent.parent.GetComponent <Hotbar>() != null; //dragging on a slot where allready is an item on if (newSlotChildCount != 0 && isOnSlot) { //items getting swapped if they are the same itemtype if (sameItemType && !sameItemRerferenced) // { Transform temp1 = secondItemGameObject.transform.parent.parent.parent; Transform temp2 = oldSlot.transform.parent.parent; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; if (!temp1.Equals(temp2)) { if (firstItem.itemType == ItemType.UFPS_Weapon) { Inventory.GetComponent <Inventory>().UnEquipItem1(secondItem); Inventory.GetComponent <Inventory>().EquiptItem(firstItem); } else { Inventory.GetComponent <Inventory>().EquiptItem(firstItem); if (secondItem.itemType != ItemType.Backpack) { Inventory.GetComponent <Inventory>().UnEquipItem1(secondItem); } } } if (fromHot) { createDuplication(secondItemGameObject); } } //if they are not from the same Itemtype the dragged one getting placed back else { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; if (fromHot) { createDuplication(firstItemGameObject); } } } //if the slot is empty else { for (int i = 0; i < newSlot.parent.childCount; i++) { if (newSlot.Equals(newSlot.parent.GetChild(i))) { //checking if it is the right slot for the item if (itemTypeOfSlots[i] == transform.GetComponent <ItemOnObject>().item.itemType) { transform.SetParent(newSlot); rectTransform.localPosition = Vector3.zero; if (!oldSlot.transform.parent.parent.Equals(newSlot.transform.parent.parent)) { Inventory.GetComponent <Inventory>().EquiptItem(firstItem); } } //else it get back to the old slot else { transform.SetParent(oldSlot.transform); rectTransform.localPosition = Vector3.zero; if (fromHot) { createDuplication(firstItemGameObject); } } } } } } if (Inventory.GetComponent <CraftSystem>() != null) { CraftSystem cS = Inventory.GetComponent <CraftSystem>(); int newSlotChildCount = newSlot.transform.parent.childCount; bool isOnSlot = newSlot.transform.parent.GetChild(0).tag == "ItemIcon"; //dragging on a slot where allready is an item on if (newSlotChildCount != 0 && isOnSlot) { //check if the items fits into the other item bool fitsIntoStack = false; if (sameItem) { fitsIntoStack = (firstItem.itemValue + secondItem.itemValue) <= firstItem.maxStack; } //if the item is stackable checking if the firstitemstack and seconditemstack is not full and check if they are the same items if (inventory.stackable && sameItem && firstItemStack && secondItemStack) { //if the item does not fit into the other item if (fitsIntoStack && !sameItemRerferenced) { secondItem.itemValue = firstItem.itemValue + secondItem.itemValue; secondItemGameObject.transform.SetParent(newSlot.parent.parent); Destroy(firstItemGameObject); secondItemRectTransform.localPosition = Vector3.zero; if (secondItemGameObject.GetComponent <ConsumeItem>().duplication != null) { GameObject dup = secondItemGameObject.GetComponent <ConsumeItem>().duplication; dup.GetComponent <ItemOnObject>().item.itemValue = secondItem.itemValue; dup.GetComponent <SplitItem>().inv.stackableSettings(); dup.transform.parent.parent.parent.GetComponent <Inventory>().updateItemList(); } cS.ListWithItem(); } else { //creates the rest of the item int rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { firstItem.itemValue = firstItem.maxStack; secondItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; cS.ListWithItem(); } } } //if does not fit else { //creates the rest of the item int rest = 0; if (sameItem) { rest = (firstItem.itemValue + secondItem.itemValue) % firstItem.maxStack; } //fill up the other stack and adds the rest to the other stack if (!fitsIntoStack && rest > 0) { secondItem.itemValue = firstItem.maxStack; firstItem.itemValue = rest; firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; secondItemRectTransform.localPosition = Vector3.zero; cS.ListWithItem(); } //if they are different items or the stack is full, they get swapped else if (!fitsIntoStack && rest == 0) { //if you are dragging an item from equipmentsystem to the inventory and try to swap it with the same itemtype if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null && firstItem.itemType == secondItem.itemType) { firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; oldSlot.transform.parent.parent.GetComponent <Inventory>().EquiptItem(secondItem); newSlot.transform.parent.parent.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); } //if you are dragging an item from the equipmentsystem to the inventory and they are not from the same itemtype they do not get swapped. else if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null && firstItem.itemType != secondItem.itemType) { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } //swapping for the rest of the inventorys else if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null) { firstItemGameObject.transform.SetParent(secondItemGameObject.transform.parent); secondItemGameObject.transform.SetParent(oldSlot.transform); secondItemRectTransform.localPosition = Vector3.zero; firstItemRectTransform.localPosition = Vector3.zero; } } } } else { if (newSlot.tag != "Slot" && newSlot.tag != "ItemIcon") { firstItemGameObject.transform.SetParent(oldSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; } else { firstItemGameObject.transform.SetParent(newSlot.transform); firstItemRectTransform.localPosition = Vector3.zero; if (newSlot.transform.parent.parent.GetComponent <EquipmentSystem>() == null && oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null) { oldSlot.transform.parent.parent.GetComponent <Inventory>().UnEquipItem1(firstItem); } } } } } else { // position of the dropped item (i.e. gameObject) Vector3 mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition); mouse.z = 0; // position of the player Vector3 characPos = _player.transform.position; print("Mouse --> " + mouse); print("Characterpos --> " + characPos); float DistMaxtTest = Mathf.Abs(mouse.y - characPos.y); float distMax = Vector2.Distance(mouse, characPos); print(distMax + " = " + DistMaxtTest); PlanetGenerator scriptGen = GameObject.FindGameObjectWithTag("FrontGround").transform.parent.GetComponent <PlanetGenerator>(); UnityEngine.Tilemaps.Tilemap world = GameObject.FindGameObjectWithTag("FrontGround").GetComponent <UnityEngine.Tilemaps.Tilemap>(); // when dropping the item GameObject dropItem = (GameObject)Instantiate(GetComponent <ItemOnObject>().item.itemModel); dropItem.AddComponent <PickUpItem>(); dropItem.GetComponent <PickUpItem>().item = this.gameObject.GetComponent <ItemOnObject>().item; if (dropItem.GetComponent <PickUpItem>().item.itemType == ItemType.FireWeapon1) { if (_player.GetComponent <Animator>().GetBool("SwapToGun")) { GameObject.FindGameObjectWithTag("Hotbar").transform.GetChild(0).GetComponent <cursor>().UnequipWeapon(); } } if (dropItem.GetComponent <PickUpItem>().item.itemType == ItemType.FireWeapon2) { if (_player.GetComponent <Animator>().GetBool("SwapToSub")) { GameObject.FindGameObjectWithTag("Hotbar").transform.GetChild(0).GetComponent <cursor>().UnequipWeapon(); } } if (dropItem.GetComponent <PickUpItem>().item.itemType == ItemType.MeleeWeapon) { if (_player.GetComponent <Animator>().GetBool("SwapToKnife")) { GameObject.FindGameObjectWithTag("Hotbar").transform.GetChild(0).GetComponent <cursor>().UnequipWeapon(); } } if (distMax > 3f) { if (mouse.x - characPos.x < 0) { mouse.x = characPos.x - 3f; } else if (mouse.x - characPos.x > 0) { mouse.x = characPos.x + 3f; } } while (_database.getItemByID(scriptGen.planet.savedMapMatrix[world.WorldToCell(mouse).x, world.WorldToCell(mouse).y]).itemID > 0) { mouse.y += 1; } dropItem.transform.position = mouse; // dropItem.tag = "DroppedObject"; inventory.OnUpdateItemList(); if (oldSlot.transform.parent.parent.GetComponent <EquipmentSystem>() != null) { inventory.GetComponent <Inventory>().UnEquipItem1(dropItem.GetComponent <PickUpItem>().item); } Destroy(this.gameObject); } } inventory.OnUpdateItemList(); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue) { Timer.DelayCall(() => SendTarget(from)); return(quality); }
public static SmallCookingBOD CreateRandomFor(Mobile m) { SmallBulkEntry[] entries; double theirSkill = BulkOrderSystem.GetBODSkill(m, SkillName.Cooking); bool nonexceptional = false; if (0.20 > Utility.RandomDouble()) { nonexceptional = true; entries = SmallBulkEntry.CookingSmallsRegular; } else { entries = SmallBulkEntry.CookingSmalls; } if (entries.Length > 0) { int amountMax; if (theirSkill >= 70.1) { amountMax = Utility.RandomList(10, 15, 20, 20); } else if (theirSkill >= 50.1) { amountMax = Utility.RandomList(10, 15, 15, 20); } else { amountMax = Utility.RandomList(10, 10, 15, 20); } double excChance = 0.0; if (theirSkill >= 70.1) { excChance = (theirSkill + 80.0) / 200.0; } bool reqExceptional = !nonexceptional && excChance > Utility.RandomDouble(); CraftSystem system = DefCooking.CraftSystem; List <SmallBulkEntry> validEntries = new List <SmallBulkEntry>(); for (int i = 0; i < entries.Length; ++i) { CraftItem item = system.CraftItems.SearchFor(entries[i].Type); if (item != null) { bool allRequiredSkills = true; double chance = item.GetSuccessChance(m, null, system, false, ref allRequiredSkills); if (allRequiredSkills && chance >= 0.0) { if (chance > 0.0) { validEntries.Add(entries[i]); } } } } if (validEntries.Count > 0) { SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)]; return(new SmallCookingBOD(entry, amountMax, reqExceptional)); } } return(null); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { Type resourceType = typeRes; if (resourceType == null) { resourceType = craftItem.Ressources.GetAt(0).ItemType; } Resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } if (1 < craftItem.Ressources.Count) { resourceType = craftItem.Ressources.GetAt(1).ItemType; if (resourceType == typeof(StarSapphire)) { GemType = GemType.StarSapphire; } else if (resourceType == typeof(Emerald)) { GemType = GemType.Emerald; } else if (resourceType == typeof(Sapphire)) { GemType = GemType.Sapphire; } else if (resourceType == typeof(Ruby)) { GemType = GemType.Ruby; } else if (resourceType == typeof(Citrine)) { GemType = GemType.Citrine; } else if (resourceType == typeof(Amethyst)) { GemType = GemType.Amethyst; } else if (resourceType == typeof(Tourmaline)) { GemType = GemType.Tourmaline; } else if (resourceType == typeof(Amber)) { GemType = GemType.Amber; } else if (resourceType == typeof(Diamond)) { GemType = GemType.Diamond; } } // Genova: suporte ao UO:ML. #region Mondain's Legacy m_Quality = (ArmorQuality)quality; if (makersMark) { m_Crafter = from; } #endregion return(quality); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue) { Quality = (ItemQuality)quality; if (makersMark) { Crafter = from; } if (!craftItem.ForceNonExceptional) { if (typeRes == null) { typeRes = craftItem.Resources.GetAt(0).ItemType; } Resource = CraftResources.GetFromType(typeRes); } if (from.CheckSkill(SkillName.Tinkering, -5.0, 15.0)) { from.SendLocalizedMessage(500636); // Your tinker skill was sufficient to make the item lockable. Key key = new Key(KeyType.Copper, Key.RandomValue()); KeyValue = key.KeyValue; DropItem(key); double tinkering = from.Skills[SkillName.Tinkering].Value; int level = (int)(tinkering * 0.8); RequiredSkill = level - 4; LockLevel = level - 14; MaxLockLevel = level + 35; if (LockLevel == 0) { LockLevel = -1; } else if (LockLevel > 95) { LockLevel = 95; } if (RequiredSkill > 95) { RequiredSkill = 95; } if (MaxLockLevel > 95) { MaxLockLevel = 95; } } else { from.SendLocalizedMessage(500637); // Your tinker skill was insufficient to make the item lockable. } return(quality); }
public override int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { Quality = (ArmorQuality)quality; if (makersMark) { Crafter = from; } Type resourceType = typeRes; if (resourceType == null) { resourceType = craftItem.Ressources.GetAt(0).ItemType; } Resource = CraftResources.GetFromType(resourceType); PlayerConstructed = true; CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } if (Core.AOS && tool is BaseRunicTool) { ((BaseRunicTool)tool).ApplyAttributesTo(this); } switch (Resource) { case CraftResource.AshWood: ArmorAttributes.LowerStatReq += 20; break; case CraftResource.YewWood: Attributes.RegenHits += 1; break; case CraftResource.Heartwood: switch (Utility.Random(7)) { case 0: Attributes.BonusDex += 2; break; case 1: Attributes.BonusStr += 2; break; case 2: Attributes.ReflectPhysical += 5; break; case 3: Attributes.SpellChanneling = 1; Attributes.CastSpeed = -1; break; case 4: ArmorAttributes.SelfRepair += 2; break; case 5: PhysicalBonus += 5; break; case 6: ColdBonus += 3; break; } break; case CraftResource.Bloodwood: Attributes.RegenHits += 2; Attributes.Luck += 40; break; case CraftResource.Frostwood: Attributes.SpellChanneling = 1; Attributes.CastSpeed = -1; break; } return(quality); }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, ITool tool, CraftItem craftItem, int resHue) { Amount = 5; return(1); }
public void OnPointerDown(PointerEventData data) { if (this.gameObject.transform.parent.parent.parent.GetComponent <EquipmentSystem>() == null) { bool gearable = false; Inventory inventory = transform.parent.parent.parent.GetComponent <Inventory>(); if (eS != null) { itemTypeOfSlot = eS.itemTypeOfSlots; } if (data.button == PointerEventData.InputButton.Right) { //item from craft system to inventory if (transform.parent.GetComponent <CraftResultSlot>() != null) { var playerInv = playerInventory.inventory.GetComponent <Inventory>(); bool check = inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue); if (!check) { playerInv.addItemToInventory(item.itemID, item.itemValue); playerInv.stackableSettings(); } CraftSystem cS = playerInventory.craftSystem.GetComponent <CraftSystem>(); cS.deleteItems(item); CraftResultSlot result = playerInventory.craftSystem.transform.GetChild(3).GetComponent <CraftResultSlot>(); result.temp = 0; tooltip.deactivateTooltip(); gearable = true; GameObject.FindGameObjectWithTag("MainInventory").GetComponent <Inventory>().updateItemList(); } else { bool stop = false; if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount == 0) { stop = true; if (eS.transform.GetChild(1).GetChild(i).parent.parent.GetComponent <EquipmentSystem>() != null && this.gameObject.transform.parent.parent.parent.GetComponent <EquipmentSystem>() != null) { } else { inventory.EquiptItem(item); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.updateItemList(); gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } break; } } } if (!stop) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount != 0) { GameObject otherItemFromCharacterSystem = eS.transform.GetChild(1).GetChild(i).GetChild(0).gameObject; Item otherSlotItem = otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item; if (item.itemType == ItemType.UFPS_Weapon) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); inventory.EquiptItem(item); } else { inventory.EquiptItem(item); if (item.itemType != ItemType.Backpack) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); } } if (this == null) { GameObject dropItem = (GameObject)Instantiate(otherSlotItem.itemModel); dropItem.AddComponent <PickUpItem>(); dropItem.GetComponent <PickUpItem>().item = otherSlotItem; dropItem.transform.localPosition = player.transform.localPosition; inventory.OnUpdateItemList(); } else { otherItemFromCharacterSystem.transform.SetParent(this.transform.parent); otherItemFromCharacterSystem.GetComponent <RectTransform>().localPosition = Vector3.zero; if (this.gameObject.transform.parent.parent.parent.GetComponent <Hotbar>() != null) { createDuplication(otherItemFromCharacterSystem); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; } gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.OnUpdateItemList(); break; } } } } } } if (!gearable && item.itemType != ItemType.UFPS_Ammo && item.itemType != ItemType.UFPS_Grenade) { Item itemFromDup = null; if (duplication != null) { itemFromDup = duplication.GetComponent <ItemOnObject>().item; } inventory.ConsumeItem(item); item.itemValue--; if (itemFromDup != null) { duplication.GetComponent <ItemOnObject>().item.itemValue--; if (itemFromDup.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(duplication.gameObject); } } if (item.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(this.gameObject); } } } } }
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, IBaseTool tool, CraftItem craftItem, int resHue) { if (from.CheckSkill(SkillName.Tinkering, -5.0, 15.0)) { from.SendLocalizedMessage(500636); // Your tinker skill was sufficient to make the item lockable. Key key = new Key(KeyType.Copper, Key.RandomValue()); KeyValue = key.KeyValue; DropItem(key); double tinkering = from.Skills[SkillName.Tinkering].Value; int level = (int)(tinkering * 0.8); RequiredSkill = level - 4; LockLevel = level - 14; MaxLockLevel = level + 35; if (LockLevel == 0) { LockLevel = -1; } else if (LockLevel > 95) { LockLevel = 95; } if (RequiredSkill > 95) { RequiredSkill = 95; } if (MaxLockLevel > 95) { MaxLockLevel = 95; } // A tinker trapped box should not explode until it is armed with a key Armed = false; } else { from.SendLocalizedMessage(500637); // Your tinker skill was insufficient to make the item lockable. } // The lockable containers never took material color into account, so this fixes it Type resourceType = typeRes; if (resourceType == null) { resourceType = craftItem.Resources.GetAt(0).ItemType; } var resource = CraftResources.GetFromType(resourceType); CraftContext context = craftSystem.GetContext(from); if (context != null && context.DoNotColor) { Hue = 0; } else { Hue = CraftResources.GetHue(resource); } return(1); }