/// <summary> /// Updates a stack of items to increase the quantity or creates item drop /// </summary> public ItemDrop itemStackSpawn(ItemInfo item, ushort quantity, short positionX, short positionY, short range, Player p) { //Too many items? if (_items.Count == maxItems) { Log.write(TLog.Warning, "Item count full."); return(null); } else if (item == null) { Log.write(TLog.Error, "Attempted to spawn invalid item."); return(null); } ItemDrop id = null; //Returns an ItemDrop object if there is another of the same item within the range id = getItemInRange(item, positionX, positionY, range); //If another item exist add to its quantity rather than placing another item if (id != null) { id.quantity += (short)quantity; Helpers.Object_ItemDropUpdate(Players, id.id, (ushort)id.quantity); } else { //Add new item if none nearby exists itemSpawn(item, quantity, positionX, positionY, p); } return(id); }
public ItemTracker(ItemDrop item) { ItemName = GetItemName(item); OriginalStackSize = item.m_itemData.m_shared.m_maxStackSize; OriginalWeight = item.m_itemData.m_shared.m_weight; if (item.m_itemData.m_shared.m_maxStackSize > 1) { ItemStackSizeConfig = ItemStacksPlugin.config.Bind(ItemStacksPlugin.NAME + ".ItemStackSize", ItemName + "_stack_size", 0, new ConfigDescription( "Set above 0 to use this value instead of the stack size multiplier\n" + $"Game default: {OriginalStackSize}", null, new ConfigurationManagerAttributes { IsAdvanced = true } ) ); } ItemWeightConfig = ItemStacksPlugin.config.Bind(ItemStacksPlugin.NAME + ".ItemWeight", ItemName + "_weight", 0f, new ConfigDescription( "Set above 0 to use this value instead of the weight multiplier\n" + $"Game default: {OriginalWeight}", null, new ConfigurationManagerAttributes { IsAdvanced = true } ) ); }
// Token: 0x060006BA RID: 1722 RVA: 0x00037D2C File Offset: 0x00035F2C private bool AddItem(string name, int stack, float durability, Vector2i pos, bool equiped, int quality, int variant, long crafterID, string crafterName) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(name); if (itemPrefab == null) { ZLog.Log("Failed to find item prefab " + name); return(false); } ZNetView.m_forceDisableInit = true; GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(itemPrefab); ZNetView.m_forceDisableInit = false; ItemDrop component = gameObject.GetComponent <ItemDrop>(); if (component == null) { ZLog.Log("Missing itemdrop in " + name); UnityEngine.Object.Destroy(gameObject); return(false); } component.m_itemData.m_stack = Mathf.Min(stack, component.m_itemData.m_shared.m_maxStackSize); component.m_itemData.m_durability = durability; component.m_itemData.m_equiped = equiped; component.m_itemData.m_quality = quality; component.m_itemData.m_variant = variant; component.m_itemData.m_crafterID = crafterID; component.m_itemData.m_crafterName = crafterName; this.AddItem(component.m_itemData, component.m_itemData.m_stack, pos.x, pos.y); UnityEngine.Object.Destroy(gameObject); return(true); }
static void Postfix(ItemDrop __instance) { string name = __instance.m_itemData.m_dropPrefab.name; if (customMeshes.ContainsKey(name)) { Dbgl($"got item name: {name}"); MeshFilter[] mfs = __instance.m_itemData.m_dropPrefab.GetComponentsInChildren <MeshFilter>(true); foreach (MeshFilter mf in mfs) { string parent = mf.transform.parent.gameObject.name; Dbgl($"got item name: {name}, obj: {parent}, mf: {mf.name}"); if (name == GetPrefabName(parent) && customMeshes[name].ContainsKey(mf.name) && customMeshes[name][mf.name].ContainsKey(mf.name)) { Dbgl($"replacing item mesh {mf.name}"); mf.mesh = customMeshes[name][mf.name][mf.name].mesh; } else if (customMeshes[name].ContainsKey(parent) && customMeshes[name][parent].ContainsKey(mf.name)) { Dbgl($"replacing attached mesh {mf.name}"); mf.mesh = customMeshes[name][parent][mf.name].mesh; } } } }
public static bool SetupRequirement( InventoryGui __instance, Transform elementRoot, ItemDrop item, int amount, Player player) { var icon = elementRoot.transform.Find("res_icon").GetComponent <Image>(); var nameText = elementRoot.transform.Find("res_name").GetComponent <Text>(); var amountText = elementRoot.transform.Find("res_amount").GetComponent <Text>(); var tooltip = elementRoot.GetComponent <UITooltip>(); if (item != null) { icon.gameObject.SetActive(true); nameText.gameObject.SetActive(true); amountText.gameObject.SetActive(true); if (item.m_itemData.IsMagicCraftingMaterial()) { var rarity = item.m_itemData.GetCraftingMaterialRarity(); icon.sprite = item.m_itemData.m_shared.m_icons[EpicLoot.GetRarityIconIndex(rarity)]; } else { icon.sprite = item.m_itemData.GetIcon(); } icon.color = Color.white; var bgIconTransform = icon.transform.parent.Find("bgIcon"); if (item.m_itemData.UseMagicBackground()) { if (bgIconTransform == null) { bgIconTransform = Object.Instantiate(icon, icon.transform.parent, true).transform; bgIconTransform.name = "bgIcon"; bgIconTransform.SetSiblingIndex(icon.transform.GetSiblingIndex()); } bgIconTransform.gameObject.SetActive(true); var bgIcon = bgIconTransform.GetComponent <Image>(); bgIcon.sprite = EpicLoot.GetMagicItemBgSprite(); bgIcon.color = item.m_itemData.GetRarityColor(); } else if (bgIconTransform != null) { bgIconTransform.gameObject.SetActive(false); } tooltip.m_text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); nameText.text = Localization.instance.Localize(item.m_itemData.m_shared.m_name); if (amount <= 0) { InventoryGui.HideRequirement(elementRoot); return(false); } amountText.text = amount.ToString(); amountText.color = Color.white; } return(true); }
public override void Register() { // Configure item drop // ItemDrop is a component on GameObjects which determines info about the item when it's picked up in the inventory ItemDrop item = Prefab.GetComponent <ItemDrop>(); item.m_itemData.m_shared.m_name = "Magic Armor"; item.m_itemData.m_shared.m_description = "Godlike armor with a twist"; item.m_itemData.m_shared.m_armor = 999; // create status effect var burning = ScriptableObject.CreateInstance <SE_Burning>(); // load damages field var burnDamageField = AccessTools.Field(typeof(SE_Burning), "m_damage"); var burnDamage = (HitData.DamageTypes)burnDamageField.GetValue(burning); // edit fire damage burnDamage.m_fire = 1; // save damages field burnDamageField.SetValue(burning, burnDamage); // set item status effect item.m_itemData.m_shared.m_equipStatusEffect = burning; }
private UserAction EventManager(ActionType type, List <HungerGameProfile> users, HungerGameProfile profile, ItemDrop drops, UserAction activity) { switch (type) { case ActionType.Loot: { return(_loot.LootEvent(profile, drops, activity)); } case ActionType.Attack: { activity.Action = ActionType.Attack; return(_attack.AttackEvent(users, profile, activity)); } case ActionType.Idle: { activity.Action = ActionType.Idle; return(activity); } case ActionType.Meet: { activity.Action = ActionType.Meet; return(activity); } case ActionType.Hack: { activity.Action = ActionType.Hack; return(_hack.HackEvent(profile, drops, activity)); } case ActionType.Die: { activity.Action = ActionType.Die; _die.DieEvent(profile); return(activity); } case ActionType.Sleep: { activity.Action = ActionType.Sleep; _sleep.SleepEvent(profile); return(activity); } case ActionType.Eat: { activity.Action = ActionType.Eat; _eat.EatEvent(profile); return(activity); } default: activity.Action = ActionType.Idle; return(activity); } }
public static void TeleportOres(ref ItemDrop __instance) { if (QualityOfLife.EnableTeleportOres.Value) { __instance.m_itemData.m_shared.m_teleportable = true; } }
public override void Register() { // Configure item drop ItemDrop item = Prefab.GetComponent <ItemDrop>(); item.m_itemData.m_shared.m_itemType = ItemDrop.ItemData.ItemType.Material; item.m_itemData.m_shared.m_name = "Bronze Repair Kit"; item.m_itemData.m_shared.m_description = "Repair kit with sharpening stone that can repair up to Bronze quality tools.\n\nRestores " + Whetstone.repairAmount.Value.ToString("P0").Replace(" ", "") + " durability to your equipped tool or weapon."; item.m_itemData.m_dropPrefab = Prefab; item.m_itemData.m_shared.m_weight = 2.5f; item.m_itemData.m_shared.m_maxStackSize = 10; item.m_itemData.m_shared.m_variants = 1; item.m_itemData.m_shared.m_teleportable = true; var LoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Paths.PluginPath, "Whetstone", "whetstone.assets")); if (LoadedAssetBundle == null) { Whetstone.logger.LogWarning("Failed to load AssetBundle!"); return; } Texture2D icon = LoadedAssetBundle.LoadAsset <Texture2D>("repairkitbronze-sprite.png"); if (icon != null) { Sprite sprite = Sprite.Create(icon, new Rect(0f, 0f, icon.width, icon.height), Vector2.zero); //m_icons[0] is the actual sprite itself. item.m_itemData.m_shared.m_icons[0] = sprite; } LoadedAssetBundle?.Unload(false); }
void ItemDrop() { if (_ItemCount == 0) { int _RandNum = Random.Range(0, 3); //노말등급 초기화 if (_RandNum >= 0 && _RandNum < 3) { GameObject _DropNode = null; _DropNode = (GameObject)Instantiate(Resources.Load("Prefabs/Item/DropNode")); _DropNode.transform.position = this.transform.position; Item _ItemValue = cDataBaseManager.GetInstance._ItemList[_RandNum]; ItemDrop a_RefItemInfo = _DropNode.GetComponent <ItemDrop>(); if (a_RefItemInfo != null) { a_RefItemInfo.SetItem(_ItemValue); if (_ItemValue._Type == ItemType.Spear || _ItemValue._Type == ItemType.Sword) { a_RefItemInfo.transform.Rotate(new Vector3(0, 0, 90)); } else { a_RefItemInfo._ButtonF.transform.rotation = Quaternion.identity; } } // 동적으로 텍스쳐 이미지 바꾸기 SpriteRenderer a_RefRender = _DropNode.GetComponent <SpriteRenderer>(); a_RefRender.sprite = _ItemValue._ItemIcon; } _ItemCount += 1; _isOpen = true; _ButtonF.SetActive(false); _Renderer.sprite = Resources.Load <Sprite>("Itemp/BasicTresureOpened"); } }
public CustomItem(GameObject itemPrefab, bool fixReference) { ItemPrefab = itemPrefab; ItemDrop = itemPrefab.GetComponent <ItemDrop>(); FixReference = fixReference; }
void DropItem() { ItemDrop drop = gameObject.GetComponent <ItemDrop>(); drop.DropExp(5); drop.DropPotion(); }
IEnumerator Start() { item_dropped = (GameObject)Resources.Load("Other/prefabs/Item"); Global_ItemDrop = this; Items_t = new GameObject().transform; Items_t.name = "DroppedItems"; Items_t.position = Vector2.zero; Items_t.eulerAngles = Vector3.zero; itT = Items_t; while (Grid_creator.instance == null || !Grid_creator.instance.Loaded) { yield return(new WaitForSeconds(Time.deltaTime * 3)); } for (int i = 0; i < 10; i++) { Vector2 pos = new Vector2(Random.Range(-400f, 400f), Random.Range(-400f, 400f)); while (!Grid_creator.instance.NodeFromWorldPoint(pos).walkable) { pos = new Vector2(Random.Range(-400f, 400f), Random.Range(-400f, 400f)); } DropItem(pos); } }
public static bool Prefix(ItemStand __instance) { if (!__instance.HaveAttachment()) { return(false); } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(__instance.m_nview.GetZDO().GetString("item")); if (itemPrefab != null) { GameObject gameObject = Object.Instantiate(itemPrefab, __instance.m_dropSpawnPoint.position, __instance.m_dropSpawnPoint.rotation); ItemDrop itemDrop = gameObject.GetComponent <ItemDrop>(); ItemDrop.LoadFromZDO(itemDrop.m_itemData, __instance.m_nview.GetZDO()); itemDrop.m_itemData = new ExtendedItemData( itemDrop.m_itemData, itemDrop.m_itemData.m_stack, itemDrop.m_itemData.m_durability, new Vector2i(), false, itemDrop.m_itemData.m_quality, itemDrop.m_itemData.m_variant, itemDrop.m_itemData.m_crafterID, itemDrop.m_itemData.m_crafterName); gameObject.GetComponent <Rigidbody>().velocity = Vector3.up * 4f; __instance.m_effects.Create(__instance.m_dropSpawnPoint.position, Quaternion.identity); } __instance.m_nview.GetZDO().Set("item", ""); __instance.m_nview.InvokeRPC(ZNetView.Everybody, "SetVisualItem", "", 0); return(false); }
public override void Register() { ItemDrop item = Prefab.GetComponent <ItemDrop>(); // info item.m_itemData.m_shared.m_name = "Spiritine, the Primordial Impaler"; item.m_itemData.m_shared.m_description = "Even the old ones have forgotten."; // general item.m_itemData.m_shared.m_itemType = ItemDrop.ItemData.ItemType.OneHandedWeapon; item.m_itemData.m_dropPrefab = Prefab; item.m_itemData.m_shared.m_maxStackSize = 1; item.m_itemData.m_shared.m_maxQuality = 1; item.m_itemData.m_shared.m_maxDurability = 500; item.m_itemData.m_shared.m_equipDuration = 0.2f; item.m_itemData.m_shared.m_variants = 1; // combat item.m_itemData.m_shared.m_timedBlockBonus = 1; item.m_itemData.m_shared.m_deflectionForce = 1; item.m_itemData.m_shared.m_attackForce = 12; // damage item.m_itemData.m_shared.m_damages.m_pierce = 75; item.m_itemData.m_shared.m_damages.m_spirit = 75; // attack item.m_itemData.m_shared.m_attack.m_attackStamina = 20; // attack secondary item.m_itemData.m_shared.m_secondaryAttack.m_speedFactor = 0.2f; item.m_itemData.m_shared.m_secondaryAttack.m_speedFactorRotation = 0.2f; item.m_itemData.m_shared.m_secondaryAttack.m_damageMultiplier = 0.75f; item.m_itemData.m_shared.m_secondaryAttack.m_forceMultiplier = 10; item.m_itemData.m_shared.m_secondaryAttack.m_staggerMultiplier = 6; item.m_itemData.m_shared.m_secondaryAttack.m_lowerDamagePerHit = false; }
public static bool Prefix(InventoryGui __instance, Player player) { // if it's not a rune, do the normal flow var data = __instance.m_craftRecipe?.m_item?.m_itemData?.GetRuneData(); if (data == null) { RunicPower.StopCraftingAll(false); return(true); } // if the player does not have the requeriments, do the normal flow var qualityLevel = 1; if (!player.HaveRequirements(__instance.m_craftRecipe, discover: false, qualityLevel) && !player.NoCostCheat()) { RunicPower.StopCraftingAll(false); return(true); } // getting hte spell inventory var inv = SpellsBar.invBarGrid.m_inventory; // if there is not an 'empty' slot, do the normal flow if (!inv.HaveEmptySlot()) { RunicPower.StopCraftingAll(false); return(true); } var craftItem = __instance.m_craftRecipe.m_item; GameObject go = Object.Instantiate(craftItem.gameObject); ItemDrop item = go.GetComponent <ItemDrop>(); item.m_itemData.m_stack = __instance.m_craftRecipe.m_amount; item.m_itemData.m_quality = qualityLevel; item.m_itemData.m_variant = __instance.m_craftVariant; item.m_itemData.m_durability = item.m_itemData.GetMaxDurability(); item.m_itemData.m_crafterID = player.GetPlayerID(); item.m_itemData.m_crafterName = player.GetPlayerName(); var crafted = inv.AddItem(item.m_itemData); if (crafted) { if (!player.NoCostCheat()) { player.ConsumeResources(__instance.m_craftRecipe.m_resources, qualityLevel); } __instance.UpdateCraftingPanel(); } // displaying some effects CraftingStation currentCraftingStation = Player.m_localPlayer.GetCurrentCraftingStation(); var effs = (currentCraftingStation != null) ? currentCraftingStation.m_craftItemDoneEffects : __instance.m_craftItemDoneEffects; effs.Create(player.transform.position, Quaternion.identity); Game.instance.GetPlayerProfile().m_playerStats.m_crafts++; Gogan.LogEvent("Game", "Crafted", __instance.m_craftRecipe.m_item.m_itemData.m_shared.m_name, qualityLevel); return(false); }
public Item SpawnItem(Vector3 position, Transform parent) { var roll = Random.Range(0, weightSum); var tally = 0; ItemDrop drop = default(ItemDrop); foreach (var d in drops) { tally += d.weight; if (roll < tally) { drop = d; break; } } //this shouldn't trigger but just in case if (drop.item == null) { Debug.LogError("Random Item Weight Tally Broke"); drop = drops[Random.Range(0, drops.Count)]; } var item = Instantiate(drop.item, position, Quaternion.identity, parent); if (item.stackOf != "") { item.startStack = drop.stack.Random(); } return(item); }
public static bool IsValid(this ItemDrop self) { try { var tokenName = self.TokenName(); if (tokenName[0] != Language.TokenFirstChar) { throw new Exception($"Item name first char should be $ for token lookup ! (current item name : {tokenName})"); } var hasIcon = self.m_itemData.m_shared.m_icons.Length > 0; if (!hasIcon) { throw new Exception($"ItemDrop should have atleast one icon !"); } return(true); } catch (Exception e) { Log.LogError(e); return(false); } }
static void Postfix(Container __instance, ZNetView ___m_nview) { if (!isOn.Value || !__instance.IsOwner()) { return; } Vector3 position = __instance.transform.position + Vector3.up; foreach (Collider collider in Physics.OverlapSphere(position, ContainerRange(__instance), LayerMask.GetMask(new string[] { "item" }))) { if (collider?.attachedRigidbody) { ItemDrop item = collider.attachedRigidbody.GetComponent <ItemDrop>(); //Dbgl($"nearby item name: {item.m_itemData.m_dropPrefab.name}"); if (item?.GetComponent <ZNetView>()?.IsValid() != true) { continue; } if (DisallowItem(__instance, item.m_itemData)) { continue; } Dbgl($"auto storing {item.m_itemData.m_dropPrefab.name} from ground"); while (item.m_itemData.m_stack > 1 && __instance.GetInventory().CanAddItem(item.m_itemData, 1)) { item.m_itemData.m_stack--; Traverse.Create(item).Method("Save").GetValue(); ItemDrop.ItemData newItem = item.m_itemData.Clone(); newItem.m_stack = 1; __instance.GetInventory().AddItem(newItem); typeof(Container).GetMethod("Save", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { }); typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance.GetInventory(), new object[] { }); } if (item.m_itemData.m_stack == 1 && __instance.GetInventory().CanAddItem(item.m_itemData, 1)) { ItemDrop.ItemData newItem = item.m_itemData.Clone(); item.m_itemData.m_stack = 0; Traverse.Create(item).Method("Save").GetValue(); if (___m_nview.GetZDO() == null) { DestroyImmediate(item.gameObject); } else { ZNetScene.instance.Destroy(item.gameObject); } __instance.GetInventory().AddItem(newItem); typeof(Container).GetMethod("Save", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { }); typeof(Inventory).GetMethod("Changed", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance.GetInventory(), new object[] { }); } } } }
void Start() { if (GetComponent<ItemDrop>()) gameItemDrop = GetComponent<ItemDrop>(); else gameItemDrop = gameObject.AddComponent<ItemDrop>(); }
private static void Postfix(ref ItemDrop __instance) { if (!Configuration.Current.Items.IsEnabled) { return; // if items config not enabled, continue with original method } if (Configuration.Current.Items.droppedItemOnGroundDurationInSeconds.Equals(defaultSpawnTimeSeconds)) { return; // if set to default, continue with original method } if (!(bool)(UnityEngine.Object)__instance.m_nview || !__instance.m_nview.IsValid()) { return; } if (!__instance.m_nview.IsOwner()) { return; } // Get a DateTime value that is the current server time + item drop duration modifier DateTime serverTimeWithTimeChange = ZNet.instance.GetTime().AddSeconds(Configuration.Current.Items.droppedItemOnGroundDurationInSeconds - defaultSpawnTimeSeconds); // Re-set spawn time of item to the configured percentage of the original duration __instance.m_nview.GetZDO().Set("SpawnTime", serverTimeWithTimeChange.Ticks); }
static void Prefix(Player __instance) { if (!modEnabled.Value || !Player.m_localPlayer || backpackInventory == null || __instance.GetPlayerID() != Player.m_localPlayer.GetPlayerID() || backpackInventory.NrOfItems() == 0) { return; } if (dropInventoryOnDeath.Value) { if (createTombStone.Value) { GameObject gameObject = Instantiate(__instance.m_tombstone, __instance.GetCenterPoint() + Vector3.forward, __instance.transform.rotation); gameObject.GetComponent <Container>().GetInventory().MoveInventoryToGrave(backpackInventory); TombStone component = gameObject.GetComponent <TombStone>(); PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); component.Setup(playerProfile.GetName(), playerProfile.GetPlayerID()); } else { List <ItemDrop.ItemData> allItems = backpackInventory.GetAllItems(); foreach (ItemDrop.ItemData item in allItems) { Vector3 position = __instance.transform.position + Vector3.up * 0.5f + UnityEngine.Random.insideUnitSphere * 0.3f; Quaternion rotation = Quaternion.Euler(0f, UnityEngine.Random.Range(0, 360), 0f); ItemDrop.DropItem(item, 0, position, rotation); backpackInventory.RemoveAll(); } } } }
public void Modify(DropModificationContext context) { EpicLootItemConfiguration config = GetConfig(context.Template); if (config is null) { #if DEBUG Log.LogDebug("Found no config for drop template."); #endif return; } ItemDrop itemDrop = context.ItemDrop; if (itemDrop is null) { return; } #if DEBUG Log.LogDebug("Adding magic modifiers."); #endif var magicItemData = ItemRoller.Roll( itemDrop.m_itemData, context.Drop.transform.position, config); if (magicItemData is not null) { itemDrop.m_itemData = magicItemData; } }
// Token: 0x060006FC RID: 1788 RVA: 0x00039768 File Offset: 0x00037968 private bool DrawPrefabMesh(ItemDrop prefab) { if (prefab == null) { return(false); } bool result = false; Gizmos.color = Color.yellow; foreach (MeshFilter meshFilter in prefab.gameObject.GetComponentsInChildren <MeshFilter>()) { if (meshFilter && meshFilter.sharedMesh) { Vector3 position = prefab.transform.position; Quaternion lhs = Quaternion.Inverse(prefab.transform.rotation); Vector3 point = meshFilter.transform.position - position; Vector3 position2 = base.transform.position + base.transform.rotation * point; Quaternion rhs = lhs * meshFilter.transform.rotation; Quaternion rotation = base.transform.rotation * rhs; Gizmos.DrawMesh(meshFilter.sharedMesh, position2, rotation, meshFilter.transform.lossyScale); result = true; } } return(result); }
public CookingRecipe(ItemDrop fromItemDrop, ItemDrop toItemDrop, float cookingTime, string cookingStationName) { this.fromItemDrop = fromItemDrop; this.toItemDrop = toItemDrop; this.cookingTime = cookingTime; this.cookingStationName = cookingStationName; }
public virtual void Die() { this.isDead = true; if (gameObject.tag.Equals("Player")) { gameObject.GetComponent <MeshRenderer>().enabled = false; var renderers = gameObject.GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer mr in renderers) { mr.enabled = false; } gameObject.GetComponent <BoxCollider>().enabled = false; gameObject.GetComponent <Rigidbody>().isKinematic = true; StartCoroutine(LoadGameOver()); //SceneManager.LoadScene(SceneManager.GetActiveScene().name); } //Drop Item Or Key ItemDrop dropper = gameObject.GetComponent <ItemDrop>(); if (dropper) { if (HoldingKey) { //Debug.Log("I Should Drop A Key"); //Drop Key dropper.DropKey(this.gameObject.transform); } else { //Drop Item dropper.DropItem(this.gameObject.transform); } } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player" || collision.gameObject.tag == "Ice") { if (collision.gameObject.tag == "Ice") { statusCounter.score += enemyScorePoint; } ItemDrop script = GetComponent <ItemDrop>(); if (script != null) // 敵がitemを保持しているとき { script.Drop(); //そのアイテムを落とす } if (collision.transform.position.x > transform.position.x) { damagedEnemy.blowAwayDirection = -1; } else { damagedEnemy.blowAwayDirection = 1; } Instantiate(damaged, transform.position, Quaternion.identity); Destroy(gameObject); } }
private void DocItems() { if (Generated) { return; } Jotunn.Logger.LogInfo("Documenting items"); AddHeader(1, "Item list"); AddText("All of the items currently in the game, with English localizations applied"); AddText("This file is automatically generated from Valheim using the JotunnDoc mod found on our GitHub."); AddTableHeader("Prefab", "Name", "Type", "Description"); foreach (GameObject obj in ObjectDB.instance.m_items) { ItemDrop item = obj.GetComponent <ItemDrop>(); ItemDrop.ItemData.SharedData shared = item.m_itemData.m_shared; AddTableRow( obj.name, JotunnDoc.Localize(shared.m_name), shared.m_itemType.ToString(), JotunnDoc.Localize(shared.m_description)); } Save(); }
//아이템 드랍 void ItemDrop() { int _RandNum = Random.Range(0, 6); // 0 ~ 6 랜덤값 초기화 if (_RandNum >= 0 && _RandNum < 6) { GameObject _DropNode = null; _DropNode = (GameObject)Instantiate(Resources.Load("Prefabs/Item/DropNode")); _DropNode.transform.position = this.transform.position; Item _ItemValue = cDataBaseManager.GetInstance._ItemList[_RandNum]; ItemDrop a_RefItemInfo = _DropNode.GetComponent <ItemDrop>(); if (a_RefItemInfo != null) { a_RefItemInfo.SetItem(_ItemValue); a_RefItemInfo.transform.Rotate(new Vector3(0, 0, 90)); //a_RefItemInfo.StartItem(); } // 동적으로 텍스쳐 이미지 바꾸기 SpriteRenderer a_RefRender = _DropNode.GetComponent <SpriteRenderer>(); a_RefRender.sprite = _ItemValue._ItemIcon; _ItemCount = 1; } }
// Token: 0x0600036F RID: 879 RVA: 0x0001E0B8 File Offset: 0x0001C2B8 private ItemDrop FindClosestConsumableItem(float maxRange) { if (MonsterAI.m_itemMask == 0) { MonsterAI.m_itemMask = LayerMask.GetMask(new string[] { "item" }); } Collider[] array = Physics.OverlapSphere(base.transform.position, maxRange, MonsterAI.m_itemMask); ItemDrop itemDrop = null; float num = 999999f; foreach (Collider collider in array) { if (collider.attachedRigidbody) { ItemDrop component = collider.attachedRigidbody.GetComponent <ItemDrop>(); if (!(component == null) && component.GetComponent <ZNetView>().IsValid() && this.CanConsume(component.m_itemData)) { float num2 = Vector3.Distance(component.transform.position, base.transform.position); if (itemDrop == null || num2 < num) { itemDrop = component; num = num2; } } } } if (itemDrop && base.HavePath(itemDrop.transform.position)) { return(itemDrop); } return(null); }
// Implementation of assets via using manual recipe creation and prefab cache's private void RecipeEvilSword(ItemDrop itemDrop) { // Create and add a recipe for the copied item Recipe recipe = ScriptableObject.CreateInstance <Recipe>(); recipe.name = "Recipe_EvilSword"; recipe.m_item = itemDrop; recipe.m_craftingStation = PrefabManager.Cache.GetPrefab <CraftingStation>("piece_workbench"); recipe.m_resources = new Piece.Requirement[] { new Piece.Requirement() { m_resItem = PrefabManager.Cache.GetPrefab <ItemDrop>("Stone"), m_amount = 1 }, new Piece.Requirement() { m_resItem = PrefabManager.Cache.GetPrefab <ItemDrop>("CustomWood"), m_amount = 1 } }; CustomRecipe CR = new CustomRecipe(recipe, false, false); ItemManager.Instance.AddRecipe(CR); }
public static void setWeapon(Weapon weapon){ //if(weapon.name.Equals("Iron Axe")); weaponName = weapon.name; if(w == null){ w = Instantiate(Resources.Load<GameObject>("Prefabs/Inventory/Weapons/" + weapon.name)) as GameObject; w.transform.position = weaponTransform.position; w.transform.parent = weaponTransform; cs.setFRZ(weapon.FRZ); weaponRotated = false; }else{ item = w.GetComponent<ItemDrop> (); cs.setFRZ(-item.FRZ); Destroy(w); w = Instantiate(Resources.Load<GameObject>("Prefabs/Inventory/Weapons/" + weapon.name)) as GameObject; w.transform.position = weaponTransform.position; w.transform.parent = weaponTransform; cs.setFRZ(weapon.FRZ); weaponRotated = false; } //w.transform.rotation = Quaternion.Euler(new Vector3(0, 180, 0)); }
void Start() { gameItemDrop = gameObject.AddComponent<ItemDrop>(); }
public static void removeShield(Item i){ if(s != null){ item = s.GetComponent<ItemDrop> (); if(i.id == item.id){ cs.setDEF(-item.DEF); Destroy (s); } shieldRotated = false; } }
public static void setShield(Shield shield){ shieldName = shield.name; if(s == null){ s = Instantiate(Resources.Load<GameObject>("Prefabs/Inventory/Shields/" + shield.name)) as GameObject; s.transform.position = shieldTransform.position; s.transform.parent = shieldTransform; cs.setDEF(shield.DEF); shieldRotated = false; }else{ item = s.GetComponent<ItemDrop> (); cs.setDEF(-item.DEF); Destroy(s); s = Instantiate(Resources.Load<GameObject>("Prefabs/Inventory/Shields/" + shield.name)) as GameObject; s.transform.position = shieldTransform.position; s.transform.parent = shieldTransform; cs.setDEF(shield.DEF); shieldRotated = false; } //s.transform.rotation = Quaternion.Euler(new Vector3(20, 160, 0)); }
public static ItemDrop[] Remove(int index, ItemDrop[] list) { ArrayList tmp = new ArrayList(); foreach(ItemDrop str in list) tmp.Add(str); tmp.RemoveAt(index); return tmp.ToArray(typeof(ItemDrop)) as ItemDrop[]; }
public static void removeWeapon(Item i){ if(w != null){ item = w.GetComponent<ItemDrop> (); if(item.id == i.id){ cs.setFRZ(-item.FRZ); Destroy (w); } weaponRotated = false; } }
public static ItemDrop[] Add(ItemDrop n, ItemDrop[] list) { ArrayList tmp = new ArrayList(); foreach(ItemDrop str in list) tmp.Add(str); tmp.Add(n); return tmp.ToArray(typeof(ItemDrop)) as ItemDrop[]; }
public void SetCarriedItems(ItemDrop[] carriedItems) => this.carriedItems = carriedItems;