public void UseItem(Item item) { if (canUse) { currentItem.Activate(this); canUse = false; } }
public void React(Player player) { if (Empty) { return; } Item.Activate(player); }
private void UseItem(int index) { Item item = GameSession.Instance.playerInventory.GetItemAt(index); if (item) { item.Activate(); } }
} // Gets called when a character somehow gets an item (eg picks up) public virtual void ActivateItem() { // Get the active item from the inventory. Item activeItem = this.inventory.GetActiveItem(); // Check there is an active item to Activate() if (activeItem == null) { return; } // Activate() the item. activeItem.Activate(this); }
public void UseItem(int slotId) { if (slotId < 0 || slotId > items.Count - 1) { return; } Item item = items[slotId]; if (item == null || item.itemType == Item.ItemTypes.Quest) { return; } items[slotId] = null; item.Activate(); }
public ActionResult ChangeStatus(int id, bool isActive, CartIndexSearchCriteria criteria) { Item entity = ItemService.Obj.GetById(id); if (isActive) { entity.Activate(); } else { entity.Deactivate(); } ItemService.Obj.Update(entity); return(Json(GetCartIndexModel(criteria, "Success"))); }
// Update is called once per frame void Update() { if (trapped || dummy) { return; } if (Input.GetKey(KeyCode.D)) { t.position += new Vector3(0.2f, 0.0f, 0.0f); } if (Input.GetKey(KeyCode.S)) { t.position += new Vector3(0.0f, -0.2f, 0.0f); } if (Input.GetKey(KeyCode.A)) { t.position += new Vector3(-0.2f, 0.0f, 0.0f); } if (Input.GetKey(KeyCode.W)) { t.position += new Vector3(0.0f, 0.2f, 0.0f); } if (Input.GetKeyDown(KeyCode.L)) { if (held_item == null && item_list.Count > 0) { held_item = item_list [0]; item_list.Remove(held_item); held_item.Picked_Up(); held_item.holder = gameObject; Debug.Log("Picked up item: " + held_item.name); } else if (held_item != null) { held_item.Activate(); held_item = null; } } if (Input.GetKeyDown(KeyCode.P) && held_item != null) { held_item.Drop(); held_item = null; } }
public void UseItem(int slotId) { // Invalid Slot if (slotId < 0 || slotId > items.Count - 1) { return; } Item item = items[slotId]; // Couldn't find the item, or it was a quest item -- can't use if (item == null || item.itemType == Item.ItemTypes.Quest) { return; } items[slotId] = null; item.Activate(); }
private void ActivateSelectedItem(CharacterDetails character) { if (_selectedItem.Activate(character)) { GD.Print($"{_selectedItem.Name} used successfully on {character.Name}"); _inventory.Items[_selectedItem]--; if (_inventory.Items[_selectedItem] == 0) { _inventory.Items.Remove(_selectedItem); _selectedItem = null; _selectedItemId = _selectedItemId == 0 ? 0 : _selectedItemId - 1; } _itemsList.PopulateItems(_selectedItemId); } else { GD.Print($"{_selectedItem.Name} could not be used on {character.Name}"); } }
public static void BuyItem(Item item) { Item boughtItem = null; if (Inventory.Where(x => x.data.ID == item.data.ID).Count() > 0) { boughtItem = Inventory.Where(x => x.data.ID == item.data.ID).ElementAt(0); boughtItem.data.amount++; } else { boughtItem = Instantiate(item, Instance.inventoryParent);; boughtItem.Activate(); Inventory.Add(boughtItem); } if (item.type != Item.ItemType.Fish || item.type != Item.ItemType.None) { Instance.WearItem(boughtItem); } AddGold(-boughtItem.data.value); Notification.Instance.Display(string.Format(GameData.ActiveLanguage.shop_you_have_bought, boughtItem.name), boughtItem.icon, 3f, Notification.NotificationType.GoodNews); }
}//end PlusSameItemCount(int _id) //장비착용 public void AddEquit(Item _item, GameObject _ob) { if (mountingItem == _item && mountingOb == _ob) { mountingItem.UnActivate(); if (CraftSlots.activateItem != null) { CraftSlots.activateItem.UnActivate(); } mountingItem = null; mountingOb = null; CraftSlots.activateItem = new Item();; CraftSlots.instance.ClearCraftSlot(); CraftSlots.instance.CloseCraftSlot(); } else { mountingItem = _item; mountingOb = _ob; mountingItem.Activate(); CraftSlots.instance.OpenCraftSlot(); } if (!mountingOb) { mountText.SetActive(false); } else { mountText.SetActive(true); mountText.transform.SetParent(mountingOb.transform); mountText.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0); } }
public void ReleaseItem() { containedItem.Activate(); }
public static void ActivateSelectedItem() { SelectedWeapon.Activate(); }
private void ActivateItem(Item item) { item.Activate(); }
void SetCurrentItem(Item currentItem, Boolean reset = false) { if (CurrentItem != null) CurrentItem.Activate(); CurrentItem = currentItem; if (reset) CurrentItem.SetIsChecked(true); CurrentItem.Activate(false); }
public void AddItem(Item item) { Items.Add(item); item.Activate(); CalcEncumberance(); }
void Update() { if (unconscious) { return; } // gain power of time power += Time.deltaTime * POWER_RECHARGE_RATE; if (power > POWER_MAX) { power = POWER_MAX; } // detect melee if (Input.GetButtonDown("Joy" + PID + "_MeleeAttack") || Input.GetKeyDown(KeyCode.J)) { meleeAttack(); Audio.clip = melee_sound; Audio.Play(); } // detect range attack if ((Input.GetButtonDown("Joy" + PID + "_RangedAttack") && !Input.GetButton("Joy" + PID + "_MeleeAttack")) || Input.GetKeyDown(KeyCode.K)) { rangeAttack(); Audio.clip = ranged_sound; Audio.Play(); } // proto super if (Input.GetButtonDown("Joy" + PID + "_RangedAttack") && Input.GetButton("Joy" + PID + "_MeleeAttack")) { //rangeAttackUltra(); //Audio.clip = ranged_sound; //Audio.Play (); } if (Input.GetButtonDown("Joy" + PID + "_UltimateAttack")) { //ultimateAttack(); } if (Input.GetButtonDown("Joy" + PID + "_Item") || Input.GetKeyDown(KeyCode.L)) { GetComponent <Score_Counter> ().progress_portal(); if (held_item == null && item_list.Count > 0) { GetComponent <Animator>().SetTrigger("Pickup"); held_item = item_list [0]; item_list.Remove(held_item); held_item.Picked_Up(); held_item.holder = gameObject; GetComponent <AudioSource> ().clip = pickup_item_sound; GetComponent <AudioSource> ().Play(); //Debug.Log ("Picked up item: " + held_item.name); } else if (held_item != null) { held_item.Activate(); // increment item used counter PlayerStats.getStats(PID).itemsUsed++; } } if (Input.GetButtonDown("Joy" + PID + "_Drop") && held_item != null) { held_item.Drop(); held_item = null; } //if (PID.Equals("1")) print(rb.velocity); //debugger(); }
public bool CraftingParts() { //장착하고 있는 기본 무기 확인 if (inventory == null || inventory.mountingItem == null) { return(false); } string[] ids = new string[3]; //슬롯아이템 등록 for (int i = 0; i < 3; ++i) { if (cratfSlot[i].item != null && cratfSlot[i].item.GetComponent <Item>() != null) { ids[i] = cratfSlot[i].item.GetComponent <Item>().id; previousSlot[i] = ids[i]; } else { ids[i] = ""; previousSlot[i] = ids[i]; } } List <CraftData> currentCraftdataList = ItemManager.instance.LookForDataByBaseID(inventory.mountingItem.id); if (currentCraftdataList == null) { return(false); } foreach (CraftData data in currentCraftdataList) { string check = ItemManager.instance.FindResultIDWithParts(data, ids[0], ids[1], ids[2]); if (check != "") { Item craftresult = ItemManager.instance.CreateItemWithID(check); if (activateItem.isActivate != true) { inventory.mountingItem.UnActivate(); activateItem = craftresult; activateItem.Activate(); return(true); } else { if (activateItem.id == craftresult.id) { return(false); } activateItem.UnActivate(); activateItem.Activate(); return(true); } //end else } // if } //end foreach return(false); }
public void UseItem(Vector3 pos, Item item, BlockFace blockFace, Vector3 clickPos, Player player) { Block clicked = this.GetBlock(pos); Block replace = clicked.GetSideBlock(blockFace); if (clicked.Y > 255 || clicked.Y < 0 || clicked.ID == BlockFactory.AIR) { return; } PlayerInteractEventArgs playerInteractEvent = new PlayerInteractEventArgs(player, item, clicked, blockFace); if (player.IsAdventure) { playerInteractEvent.IsCancel = true; } if (Server.ServerConfig.SpawnProtection > 0 || player.Op) { //TODO } PlayerEvents.OnPlayerInteract(playerInteractEvent); if (playerInteractEvent.IsCancel) { return; } clicked.Update(World.BLOCK_UPDATE_TOUCH); if (!player.Sneaking && clicked.CanBeActivated && clicked.Activate(player, item)) { return; } if (!player.Sneaking && item.CanBeActivate && item.Activate(player, this, clicked, blockFace, clickPos)) { if (item.Count <= 0) { return; } } if (!item.CanBePlace) { return; } Block hand = item.Block; hand.Position = replace.Position; if (clicked.CanBeReplaced) { replace = clicked; hand.Position = replace.Position; } //TODO : near by entity check //TODO : check can place on BlockPlaceEventArgs blockPlaceEvent = new BlockPlaceEventArgs(player, hand, replace, clicked, item); //TODO : check spawn protection BlockEvents.OnBlockPlace(blockPlaceEvent); if (blockPlaceEvent.IsCancel) { return; } hand.Place(clicked, replace, blockFace, clickPos, player, item); LevelSoundEventPacket pk = new LevelSoundEventPacket(); pk.Position = (Vector3)hand.Position; pk.Sound = LevelSoundEventPacket.SOUND_PLACE; pk.ExtraData = hand.RuntimeId; pk.Pitch = 1; player.SendPacket(pk); //TODO : near players }
public void UseItem(Vector3 pos, Item item, BlockFace blockFace, Vector3 clickPos, Player player) { Block clicked = this.GetBlock(pos); Block replace = clicked.GetSideBlock(blockFace); if (clicked.Y > 255 || clicked.Y < 0 || clicked.ID == BlockIDs.AIR) { return; } PlayerInteractEventArgs args = new PlayerInteractEventArgs(player, item, clicked, blockFace); if (player.IsAdventure) { args.IsCancel = true; } /*if (Server.ServerConfig.SpawnProtection > 0 || player.Op) * { * //TODO * }*/ Server.Instance.Event.Player.OnPlayerInteract(this, args); if (args.IsCancel) { return; } clicked.OnTouchUpdate(); if (!player.Sneaking && clicked.CanBeActivated && clicked.Activate(player, item)) { return; } if (!player.Sneaking && item.Activate(player, this, clicked, blockFace, clickPos)) { if (item.Count <= 0) { return; } } Block hand = item.Block; if (hand.ID == BlockIDs.AIR) { return; } hand.Damage = item.Damage; hand.SetPosition(replace.GetPosition()); if (clicked.CanBeReplaced) { replace = clicked; hand.SetPosition(replace.GetPosition()); } //TODO : near by entity check //TODO : check can place on BlockPlaceEventArgs args1 = new BlockPlaceEventArgs(player, hand, replace, clicked, item); //TODO : check spawn protection Server.Instance.Event.Block.OnBlockPlace(this, args1); if (args1.IsCancel) { this.SendBlocks(Server.Instance.GetOnlinePlayers(), new Vector3[] { hand.ToVector3() }); return; } hand.Place(clicked, replace, blockFace, clickPos, player, item); LevelSoundEventPacket pk = new LevelSoundEventPacket { Position = hand.ToVector3(), Sound = LevelSoundEventPacket.SOUND_PLACE, ExtraData = hand.RuntimeId }; Server.Instance.BroadcastSendPacket(pk); //TODO : near players }