private void OnGUI() { if (this.showText) { GUI.Label(new Rect(100f, 0f, 100f, 22f), "Treasure Chests"); if (cachedBoxes != null) { for (int i = 0; i < cachedBoxes.Length; i++) { EventItemScript es = cachedBoxes[i].itemObj.GetComponent <EventItemScript>(); GUI.Label(new Rect(100f, 22f + (float)i * 22f, 100f, 22f), es.itemLabel); } } GUI.Label(new Rect(0f, 0f, 100f, 22f), "Free Items"); if (cachedItems != null) { for (int i = 0; i < cachedItems.Length; i++) { GUI.Label(new Rect(0f, 25f + (float)i * 22f, 200f, 22f), cachedItems[i].itemLabel); } } GUI.Label(new Rect(0, Screen.height - 75f, 500f, 50f), error); GUI.Label(new Rect(0, Screen.height - 25f, 50f, 25f), randomising.ToString()); } }
private void ChangeEventItem(EventItemScript eventItem) { ItemData oldItemData = GetItemDataFromName(eventItem.name); if (oldItemData != null && locationToItemMap.TryGetValue((int)oldItemData.getItemName(), out int id)) { ItemID newItemID = (ItemID)id; //get the item data for the new item, only really need the names here ItemInfo newItemInfo = ItemFlags.GetItemInfo(newItemID); ItemData newItemData = GetNewItemData(newItemInfo); //flags the item uses to check to see if it should be active and visible to the user, important that these are //changed because if you only change the label the it will use the original items flags to check. This means that //if you change another item to what was this items original is and collect it when it comes to collecting the item //this has been changed too if won't be active as it thinks you already have it foreach (var flagBoxParent in eventItem.itemActiveFlag) { foreach (var flagBox in flagBoxParent.BOX) { if (flagBox.seet_no1 == 2) { flagBox.flag_no1 = (int)newItemData.getItemName(); flagBox.comp = COMPARISON.Equal; flagBox.flag_no2 = 0; //the whips and shields use the same flag just increment higher with each upgrade cant just use the same as other items if (newItemID == ItemID.ChainWhip || newItemID == ItemID.SilverShield || newItemID == ItemID.MobileSuperx3P) { flagBox.flag_no2 = 1; flagBox.comp = COMPARISON.LessEq; } else if (newItemID == ItemID.FlailWhip || newItemID == ItemID.AngelShield) { flagBox.flag_no2 = 2; flagBox.comp = COMPARISON.LessEq; } else if (newItemID == ItemID.Buckler) { flagBox.comp = COMPARISON.LessEq; } } } } //flags that the item sets when you collect it, important to change otherwise the original item will also be collected //when you pick up the item because by default it sets the original items flags again, also other flags can be set here //usually items that add to flags that are used as a type of counter eg.Sacred Orbs orb count eventItem.itemGetFlags = ItemFlags.GetItemGetFlags(newItemID); //name used when calling setitem eventItem.itemLabel = newItemInfo.boxName; //change the sprite to match the new item Sprite sprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData(newItemInfo.boxName)); eventItem.gameObject.GetComponent <SpriteRenderer>().sprite = sprite; } }
private IEnumerator ChangeTreasureBoxes() { List <TreasureBoxScript> oldboxes = new List <TreasureBoxScript>(); foreach (TreasureBoxScript box in FindObjectsOfType <TreasureBoxScript>()) { ItemData oldItemData = GetItemDataFromName(box.itemObj.name); if (oldItemData == null) { continue; } LocationID locationID = (LocationID)oldItemData.getItemName(); if (oldItemData != null && locationToItemMap.TryGetValue(locationID, out ItemID newItemID)) { ItemInfo newItemInfo = ItemDB.GetItemInfo(newItemID); TreasureBoxScript newBox; if (IsLocationCursed(locationID)) { GameObject obj = Instantiate(cursedChest, box.transform.position, box.transform.rotation); newBox = obj.GetComponent <TreasureBoxScript>(); newBox.curseMode = true; newBox.forceOpenFlags = box.forceOpenFlags; newBox.itemFlags = box.itemFlags; newBox.openActionFlags = box.openActionFlags; newBox.openFlags = box.openFlags; newBox.unlockFlags = box.unlockFlags; newBox.itemObj = box.itemObj; obj.SetActive(true); obj.transform.SetParent(box.transform.parent); oldboxes.Add(box); } else { newBox = box; newBox.curseMode = false; } //Change the Treasure Boxs open flags to correspond to the new item //These flags are used to so the chest stays open after you get the item foreach (L2FlagBoxParent flagBoxParent in newBox.openFlags) { foreach (L2FlagBox flagBox in flagBoxParent.BOX) { if (flagBox.seet_no1 == 2) { flagBox.flag_no1 = newItemInfo.itemFlag; flagBox.flag_no2 = 1; //the whips and shields use the same flag just increment higher with each upgrade cant just use the same as other items if (newItemID == ItemID.ChainWhip || newItemID == ItemID.SilverShield || newItemID == ItemID.MobileSuperx3P) { flagBox.flag_no2 = 2; } else if (newItemID == ItemID.FlailWhip || newItemID == ItemID.AngelShield) { flagBox.flag_no2 = 3; } } } } EventItemScript item = newBox.itemObj.GetComponent <EventItemScript>(); //Change the Event Items active flags to correspond to the new item //These flags are used to set the item inactive after you have got it foreach (L2FlagBoxParent flagBoxParent in item.itemActiveFlag) { foreach (L2FlagBox flagBox in flagBoxParent.BOX) { if (flagBox.seet_no1 == 2) { flagBox.flag_no1 = newItemInfo.itemFlag; flagBox.comp = COMPARISON.Equal; flagBox.flag_no2 = 0; //the whips and shields use the same flag just increment higher with each upgrade cant just use the same as other items if (newItemID == ItemID.ChainWhip || newItemID == ItemID.SilverShield || newItemID == ItemID.MobileSuperx3P) { flagBox.flag_no2 = 1; flagBox.comp = COMPARISON.LessEq; } else if (newItemID == ItemID.FlailWhip || newItemID == ItemID.AngelShield) { flagBox.flag_no2 = 2; flagBox.comp = COMPARISON.LessEq; } else if (newItemID == ItemID.Buckler) { flagBox.comp = COMPARISON.LessEq; } } } } //Change the Event Items get flags to correspond to the new item //These are flags that are set when the item is gotten item.itemGetFlags = CreateGetFlags(newItemID, newItemInfo); //Change the name used when calling setitem to correspond to new item item.itemLabel = newItemInfo.boxName; //Change the sprite to correspond to new item Sprite sprite; //Mantras don't have an icon so use the Mantra software icon if (newItemID >= ItemID.Heaven && newItemID <= ItemID.Night) { sprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData("Mantra")); } else { sprite = L2SystemCore.getMapIconSprite(L2SystemCore.getItemData(newItemInfo.boxName)); } item.gameObject.GetComponent <SpriteRenderer>().sprite = sprite; } } yield return(new WaitForEndOfFrame()); foreach (var box in oldboxes) { box.gameObject.SetActive(false); } }