public void DropItem() { if (character && Backpack) { ItemBackpack backpack = null; if(Network.isClient || Network.isServer){ GameObject deadbody = (GameObject)Network.Instantiate (Backpack.gameObject, this.transform.position, Quaternion.identity, 2); backpack = deadbody.GetComponent<ItemBackpack> (); }else{ GameObject deadbody = (GameObject)GameObject.Instantiate (Backpack.gameObject, this.transform.position, Quaternion.identity); backpack = deadbody.GetComponent<ItemBackpack> (); } if (backpack) { foreach (var item in character.inventory.Items) { if (character != null) { ItemData itemClone = character.inventory.itemManager.CloneItemData (item.Item); if (itemClone != null) { ItemCollector itemCol = new ItemCollector (); itemCol.Item = itemClone; itemCol.Num = item.Num; itemCol.NumTag = item.NumTag; itemCol.Active = true; backpack.AddItem (itemCol); } } } } } }
// add element to raw void AddItemToRaw(ItemCollector item) { GameObject obj = (GameObject)GameObject.Instantiate(Item.gameObject, Vector3.zero, Quaternion.identity); GUIItemCollector guiitem = obj.GetComponent <GUIItemCollector>(); if (guiitem) { guiitem.Item = item; guiitem.currentInventory = null; guiitem.Type = "Ground"; if (item.Item.ImageSprite) { guiitem.Icon.sprite = item.Item.ImageSprite; } guiitem.Num.text = item.Num.ToString(); guiitem.Name.text = item.Item.ItemName; } obj.transform.SetParent(Canvas.gameObject.transform); RectTransform rect = obj.GetComponent <RectTransform>(); rect.anchoredPosition = new Vector2(((rect.sizeDelta.x + Spacing) * numItem) + Spacing, -(((rect.sizeDelta.y + Spacing) * numRaw) + Spacing)); rect.localScale = Item.gameObject.transform.localScale; numItem++; if (numItem >= Size) { numItem = 0; numRaw += 1; } Canvas.sizeDelta = new Vector2(Canvas.sizeDelta.x, (Item.sizeDelta.y + Spacing) * (numRaw + 1)); }
void Select(Vector3 position) { GUIItemCollector guiItem = this.GetComponent <GUIItemCollector> (); if (guiItem) { Item = guiItem.Item; } if (Item != null) { if (TooltipUsing.Instance) { TooltipUsing.Instance.ShowTooltip(Item, position, Type); } else { Debug.Log(TooltipUsing.Instance); } } if (TooltipDetails.Instance) { TooltipDetails.Instance.HideTooltip(); } }
public override void ShowTooltip(ItemCollector itemCol, Vector3 pos) { if (itemCol == null || itemCol.Item == null || MouseLock.MouseLocked) { return; } // update GUI elements with name and description of ItemCollector if (Header) { Header.text = itemCol.Item.ItemName; } if (Content) { Content.text = itemCol.Item.Description; } if (TooltipUsing.Instance.gameObject.activeSelf) { hover = false; } base.ShowTooltip(itemCol, pos); }
// Start is called before the first frame update void Start() { worldSettings = FindObjectOfType <WorldSettings>(); controller = GetComponent <CharacterController>(); worldSettings = FindObjectOfType <WorldSettings>(); anim = GetComponent <Animator>(); raycast = GetComponent <RaycastController>(); if (raycast != null) { int inventoryLayerMask = 1 << LayerMask.NameToLayer("Enemy"); raycast.AddLayerMask(inventoryLayerMask); } equipper = GetComponent <ItemEquipper>(); attack = GetComponent <PlayerAttack>(); treeController = GetComponent <TreeController>(); cameraAdjuster = GetComponent <CameraAdjuster>(); playerStatistics = GetComponent <PlayerStatistics>(); itemCollector = GetComponent <ItemCollector>(); totalSwingTime = GetSwimgTimeByAnimator(anim); reticleMissColor = reticle.color; }
private void OnConsume() { var item = EquippedItem as ConsumableItem; if (item.Consumptions > 0) { if (consumeSFX) { AudioSource.PlayClipAtPoint(consumeSFX, transform.position); } item.Consume(); PlayerStatistics playerStatistics = GetComponent <PlayerStatistics>(); playerStatistics.ChangePlayerHealth(item.Properties.HealthOnConsume); playerStatistics.ChangePlayerHunger(item.Properties.HungerOnConsume); playerStatistics.ChangePlayerRadiation(item.Properties.RadiationOnConsume); if (item.Consumptions == 0) { RemoveEquipment(); ItemCollector itemCollector = GetComponent <ItemCollector>(); itemCollector.RemoveFromInventory(item); } } }
public override void ShowTooltip(TooltipTrigger trigger, Vector3 pos) { GUIItemCollector guiItem = trigger.GetComponent <GUIItemCollector>(); if (guiItem == null) { return; } ItemCollector itemCol = guiItem.Item; if (itemCol == null || itemCol.Item == null || MouseLock.MouseLocked) { return; } if (Header) { Header.text = itemCol.Item.ItemName; } if (Content) { Content.text = itemCol.Item.Description; } if (TooltipUsing.Instance.gameObject.activeSelf) { TooltipUsing.Instance.StopHover(); } base.ShowTooltip(trigger, pos); }
void AddItemToRaw(ItemCollector item) { // adding item collector to GUI object GameObject obj = (GameObject)GameObject.Instantiate (Item.gameObject, Vector3.zero, Quaternion.identity); DragItem drag = obj.GetComponent<DragItem> (); if (drag) { drag.Item = item; if (item.Item.ImageSprite) drag.Icon.sprite = item.Item.ImageSprite; drag.Num.text = item.Num.ToString (); } obj.transform.SetParent (Canvas.gameObject.transform); RectTransform rect = obj.GetComponent<RectTransform> (); rect.anchoredPosition = new Vector2 (((rect.sizeDelta.x + Spacing) * numItem) + Spacing, -(((rect.sizeDelta.y + Spacing) * numRaw) + Spacing)); rect.localScale = Item.gameObject.transform.localScale; numItem++; if (numItem >= Size) { numItem = 0; numRaw += 1; } Canvas.sizeDelta = new Vector2 (Canvas.sizeDelta.x, (Item.sizeDelta.y + Spacing) * (numRaw + 1)); }
public void PutItem(int id) { ItemCollector item = SkinController.skinController.getByID(id); switch (item.type) { case ItemType.Body: BodySpriteCollector body = (BodySpriteCollector) item; if (body.back == null) Back.sprite = null; else Back.sprite = body.back.sprite; Body.sprite = body.body.sprite; LeftEye.sprite = body.leftEye.sprite; RightEye.sprite = body.rightEye.sprite; LeftHand.sprite = body.leftArm.sprite; RightHand.sprite = body.rightArm.sprite; LeftLeg.sprite = body.leftLeg.sprite; RightLeg.sprite = body.rightLeg.sprite; break; case ItemType.Head: SingleSpriteCollector head = (SingleSpriteCollector) item; Head.sprite = head.sprite.sprite; break; case ItemType.Weapon: SingleSpriteCollector weapon = (SingleSpriteCollector) item; Weapon.sprite = weapon.sprite.sprite; break; } }
public void AddItemByIdemData(ItemData item, int num, int numtag,int shortcut) { UpdateCount+=1; if (itemManager != null) { if (item != null && num > 0) { ItemData itemdata = itemManager.CloneItemData (item); if (itemdata != null) { ItemCollector itemc = new ItemCollector (); itemc.Index = itemManager.GetIndexByID (itemdata.ItemID); itemc.Item = itemdata; itemc.NumTag = numtag; itemc.Shortcut = shortcut; for (int i=0; i<Items.Count; i++) { if (Items [i].Item != null && Items [i].Item.ItemID == itemdata.ItemID && itemdata.Stack) { Items [i].Num += num; return; } } itemc.Num += num; Items.Add (itemc); if (itemc.Index == -1) { Debug.Log (itemdata.name + " Is not registered in Item Manager! this item will not save"); } } } } }
public void SetCollectorSlot(ItemCollector collector) { CollectorSlot = collector; if (collector.NumTag != -1) { Ammo = collector.NumTag; } }
void Start() { itemCollector = GetComponent <ItemCollector>(); foreach (ItemType type in items) { itemCollector.AddToInventory(ItemRegistry.Instantiate(type)); } }
public virtual void ShowTooltip(ItemCollector itemCol, Vector3 pos) { if (itemCol == null || MouseLock.MouseLocked) { return; } transform.position = pos; gameObject.SetActive(true); }
void Awake() { characterEnabler = GetComponent <CharacterEnabler>(); itemCollector = GetComponent <ItemCollector>(); itemCollector.AllItemsWereCollected += AllItemsWereCollected; healthManager = GetComponent <HealthManager>(); healthManager.HealthReachedZero += HealthReachedZero; }
public IEnumerator Trading(ItemCollector item, DropStockArea stock) { while (trading) { yield return(new WaitForEndOfFrame()); } Debug.Log("Trade " + item.Item.ItemName + " to " + number); stock.Trade(number); Cancel(); }
public void OnPointerClick(PointerEventData eventData) { DragItem dragitem = this.GetComponent<DragItem> (); if (dragitem) Item = dragitem.Item; pointerPosition = new Vector3 (eventData.position.x, eventData.position.y - 18f, 0f); StartHover (pointerPosition); if(eventData.pointerDrag!=this.gameObject) StopHover(); }
/// <summary> /// Repeater 取值(将控件数据放入具有类型为 T 的数据结构中) /// 通过 ItemIndex 匹配输入的 Data 的 Index /// </summary> /// <typeparam name="T"></typeparam> /// <param name="data"></param> public void SynTo <T>(List <T> data, Action <ItemCollector <T> > collect) where T : class, new() { for (int i = 0; i < _Repeater.Items.Count; i++) { ItemCollector <T> collector = new ItemCollector <T>(_Repeater.Items[i], data[i]); if (collect != null) { collect(collector); } } }
public void LateUpdate() { if (guiItem == null || UnitZ.playerManager == null || UnitZ.playerManager.PlayingCharacter == null || UnitZ.playerManager.PlayingCharacter.inventory == null) { return; } // Get actual item data to the shortcut by matching a shortcut index with items in inventory. ItemCollector item = UnitZ.playerManager.PlayingCharacter.inventory.GetItemCollectorByShortCutIndex(ShortcutIndex); guiItem.SetItemCollector(item); }
internal static T[] CreateListFromArrayCollection <T, Allocator>(ref ItemCollector <T, Allocator> collector, int startIdx) where Allocator : IArrayAllocator <T> { if (startIdx + collector.Count == 0) { return(Array.Empty <T>()); } var result = new T[startIdx + collector.Count]; collector.CopyTo(result, startIdx); return(result); }
public void StartTrade(ItemCollector item, DropStockArea stock) { if (item == null || stock == null || Number == null) { return; } Number.text = item.Num.ToString(); trading = true; this.gameObject.SetActive(true); StartCoroutine(Trading(item, stock)); }
// Draw item icon void DrawItemBox(ItemSlot itemslot, Vector2 position) { if (itemslot != null) { ItemCollector item = character.itemManager.Items[itemslot.Index]; GUI.Box(new Rect(10 + position.x, 10 + position.y, 50, 50), ""); GUI.DrawTexture(new Rect(10 + position.x, 10 + position.y, 50, 50), item.Icon); GUI.skin.label.fontSize = 13; GUI.skin.label.alignment = TextAnchor.UpperLeft; GUI.Label(new Rect(14 + position.x, 14 + position.y, 30, 30), itemslot.Num.ToString()); } }
// Start is called before the first frame update void Start() { // Initializes basic variables List <GlobalTree> trees = new List <GlobalTree>(); reach = GetComponent <PlayerController>().GetReach(); colliderParent = GameObject.FindGameObjectWithTag("TreeColliderParent"); treesWithCollider = new List <GlobalTree>(); itemCollector = GetComponent <ItemCollector>(); // Initializing mapping of tree type to the respective stripped tree type. treePrototypeMapping = new List <Tuple <int, int> >(); // Maps broadleaf tree to stripped broadleaf. treePrototypeMapping.Add(new Tuple <int, int>(0, 1)); treePrototypeMapping.Add(new Tuple <int, int>(2, 3)); treePrototypeMapping.Add(new Tuple <int, int>(4, 5)); // Gets number of sticks available for the trees int initialSticksAmount = treeColliderPrefab.GetComponent <ItemSource>().totalItems; // Does initialization work for all the trees in the map. // Loops through all terrain pieces. for (int terrainIdx = 0; terrainIdx < Terrain.activeTerrains.Length; terrainIdx++) { Terrain terrain = Terrain.activeTerrains[terrainIdx]; // Loops through all trees on terrain piece. for (int treeIdx = 0; treeIdx < terrain.terrainData.treeInstanceCount; treeIdx++) { bool hasSticks = true; // Determines if the tree has sticks based on whether it is stripped or not. foreach (Tuple <int, int> tup in treePrototypeMapping) { if (tup.Item2 == terrain.terrainData.treeInstances[treeIdx].prototypeIndex) { hasSticks = false; } } // Creates trees, and determines whether they have sticks based on type. trees.Add(new GlobalTree(terrain.terrainData.treeInstances[treeIdx], terrain.GetPosition(), terrain.terrainData.size, terrainIdx, treeIdx, hasSticks ? initialSticksAmount : 0)); } } // Initializes proximity list. More optimized tree searching. if (trees.Count > 0) { closeTrees = new ProximityList(trees, 10); } }
public override void ShowTooltip(TooltipTrigger trigger, Vector3 pos) { GUIItemCollector guiItem = trigger.GetComponent <GUIItemCollector>(); if (guiItem == null) { return; } Item = guiItem.Item; onpress = false; base.ShowTooltip(trigger, pos); }
public void ShowTooltip(ItemCollector itemCol, Vector3 pos) { if (itemCol == null) return; Item = itemCol; if (Header) Header.text = itemCol.Item.ItemName; if (Content) Content.text = itemCol.Item.Description; transform.position = pos; gameObject.SetActive (true); }
public void SetupCollector() { //if (UnitZ.playerManager.PlayingCharacter == null) //return; if (CurrentSticker != null) { CurrentItemCollector = UnitZ.playerManager.PlayingCharacter.inventory.GetItemCollectorByEquipIndex(CurrentSticker.Index); if (guiItem != null) { guiItem.Item = CurrentItemCollector; } } }
public void OnPointerEnter(PointerEventData eventData) { // show TooltipDetails when mouse is over it GUIItemCollector guiItem = this.GetComponent <GUIItemCollector> (); if (guiItem) { Item = guiItem.Item; } if (TooltipDetails.Instance) { StartCoroutine(TooltipDetails.Instance.OnHover(eventData, Item)); } }
// Start is called before the first frame update void Start() { if (GlobalVariables.local) { enabled = false; } else { col = gameObject.GetComponent <ItemCollector>(); if (isServer) { col.calcDrop(); } } }
/// <summary> /// 获取列表类型为 T 的记录 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collect"></param> /// <returns></returns> public List <T> Collect <T>(Func <int, ItemCollector <T>, bool> collect) where T : class, new() { List <T> data = new List <T>(); for (int i = 0; i < _Repeater.Items.Count; i++) { T itemData = Activator.CreateInstance <T>(); var c = new ItemCollector <T>(_Repeater.Items[i], itemData); if (collect(i, c)) { data.Add(itemData); } } return(data); }
/// <summary> /// Repeater 取值(将控件数据放入通用类型的数据结构中) /// 单行数据使用 Dictionary(string, object) 存储 /// 例如:("Quantity", 1) ("Name", "ABC") /// </summary> /// <typeparam name="T"></typeparam> /// <param name="row"></param> /// <param name="data"></param> /// <returns></returns> public List <Dictionary <string, object> > Collect(Func <int, ItemCollector, bool> collect) { List <Dictionary <string, object> > data = new List <Dictionary <string, object> >(); for (int i = 0; i < _Repeater.Items.Count; i++) { Dictionary <string, object> itemData = new Dictionary <string, object>(); var c = new ItemCollector(_Repeater.Items[i], itemData); if (collect(i, c)) { data.Add(itemData); } } return(data); }
void Start() { big = star = fire = null; bricksLayer = LayerMask.NameToLayer("Obstacles"); enemyLayer = LayerMask.NameToLayer("Enemies"); runningEnemyLayer = LayerMask.NameToLayer("RunningEnemies"); _motion = GetComponent <MarioMovement>(); _collector = GetComponent <ItemCollector>(); _collector.OnItemCollision += pickItem; _marioCollider = GetComponent <BoxCollider2D>(); _currentY = transform.position.y; _audio = gameObject.AddComponent <AudioSource>(); _animator = GetComponent <Animator>(); }
public virtual void ShowTooltip(ItemCollector itemCol, Vector3 pos, string type) { if (itemCol == null) { return; } if (panelsManager) { panelsManager.DisableAllPanels(); panelsManager.OpenPanelByName(type); } Item = itemCol; transform.position = pos; gameObject.SetActive(true); }
public void OnDrop(PointerEventData data) { if (UnitZ.playerManager == null || UnitZ.playerManager.PlayingCharacter == null || guiItem == null || data == null) { return; } ItemCollector itemDrag = GetItemDrop(data); // shortcut can be swap with another shortcut. if it dropped on eachother if (itemDrag != null) { UnitZ.playerManager.PlayingCharacter.inventory.SwarpShortcut(itemDrag, guiItem.Item); itemDrag.Shortcut = ShortcutIndex; guiItem.SetItemCollector(itemDrag); } }
private static bool Prefix( // ReSharper disable InconsistentNaming // ReSharper disable SuggestBaseTypeForParameter ItemCollector __instance, Collider other, int ___maxNumberOfItems, Collider ___collectorCollider) // ReSharper restore SuggestBaseTypeForParameter // ReSharper restore InconsistentNaming { if (!___collectorCollider.enabled || ___maxNumberOfItems != 0 && __instance.collectedItems.Count >= ___maxNumberOfItems || !Helper.ObjectIsOnLayer(other.transform.gameObject, __instance.collectMask)) { //Skip collection return(false); } var itemNet = __instance.GetComponentInParent <ItemNet>(); if (itemNet == null || itemNet.itemCollector == null) { // this is not an item net, continue with collection algorithm return(true); } var item = other.transform.GetComponentInParent <PickupItem_Networked>(); if (item == null) { // invalid item, continue with collection algorithm return(true); } if (ShouldBeFilteredOut(item, itemNet.itemCollector.ObjectIndex)) { //Skip collection return(false); } // Continue with collection algorithm return(true); }
private void AddStackedItemButton(ItemCollector itemCollector, ItemType type, int quantity, int offset) { GameObject btn = Instantiate(itemButtonPrefab, itemsDisplay.transform); btn.transform.position -= new Vector3(0.0f, offset * buttonOffset, 0.0f); btn.GetComponentInChildren <Text>().text = type.ToString() + "(" + quantity.ToString() + ")"; if (ItemRegistry.GetItemPropsForType(type).Equipable) { btn.GetComponent <Button>().interactable = true; EquipItemAction btnClick = btn.GetComponent <EquipItemAction>(); btnClick.SetItem(itemCollector.GetFirstItemOfType(type)); btnClick.SetItemEquipper(itemEquipper); } else { btn.GetComponent <Button>().interactable = false; } }
void CmdDropItem(string itemdata) { if (DropSplit) { // spawn all item to ground ItemManager item = (ItemManager)GameObject.FindObjectOfType(typeof(ItemManager)); string[] data = itemdata.Split("|"[0]); if (data.Length >= 4) { string[] indexList = data[0].Split(","[0]); string[] numList = data[1].Split(","[0]); string[] numtagList = data[2].Split(","[0]); string[] shortcutList = data[3].Split(","[0]); for (int i = 0; i < indexList.Length; i++) { if (indexList[i] != "") { ItemCollector itemCol = new ItemCollector(); itemCol.Item = item.GetItemDataByID(indexList[i]); if (itemCol.Item != null) { int.TryParse(numList[i], out itemCol.Num); int.TryParse(numtagList[i], out itemCol.NumTag); int.TryParse(shortcutList[i], out itemCol.Shortcut); itemCol.Active = true; UnitZ.gameNetwork.RequestSpawnItem(itemCol.Item.gameObject, itemCol.NumTag, itemCol.Num, this.transform.position, Quaternion.identity); } } } } } else { // spawn backpack included with all item if (Backpack) { UnitZ.gameNetwork.RequestSpawnBackpack(Backpack.gameObject, itemdata, this.transform.position, Quaternion.identity); } } }
public void AddItemByIndex(int index, int num, int numtag) { UpdateCount+=1; if (itemManager != null) { var itemdata = itemManager.GetItem (index); if (itemdata != null && num > 0) { ItemCollector itemc = new ItemCollector (); itemc.Index = index; itemc.Item = itemdata; itemc.NumTag = numtag; for (int i=0; i<Items.Count; i++) { if (Items [i].Index == index && itemdata.Stack) { Items [i].Num += num; return; } } itemc.Num += num; Items.Add (itemc); } } }
void GetItem(string itemdatatext) { ItemManager item = (ItemManager)GameObject.FindObjectOfType (typeof(ItemManager)); if (item) { Debug.Log ("Get itemlist : " + itemdatatext); string[] data = itemdatatext.Split ("|" [0]); string[] indexList = data [0].Split ("," [0]); string[] numList = data [1].Split ("," [0]); string[] numtagList = data [2].Split ("," [0]); for (int i=0; i<indexList.Length; i++) { if (indexList [i] != "") { ItemCollector itemCol = new ItemCollector (); itemCol.Item = item.GetItemDataByID (indexList [i]); int.TryParse(numList [i],out itemCol.Num); int.TryParse(numtagList [i],out itemCol.NumTag); itemCol.Active = true; AddItem (itemCol); } } } }
protected override void Start() { base.Start(); _inventory = transform.root.gameObject.GetComponentInChildren<ItemCollector>(); inventorySkin = Resources.Load("Fonts/InventorySkin", typeof(GUISkin)) as GUISkin; tooltipRect = new Rect(Screen.width / 2 + ItemCollector.SPACE, Screen.height / 2 - ItemCollector.TOOLTIPHEIGHT, ItemCollector.TOOLTIPWIDTH, ItemCollector.TOOLTIPHEIGHT); swapTooltipRect = new Rect(Screen.width / 2 + ItemCollector.SPACE, Screen.height / 2 + ItemCollector.SPACE, ItemCollector.TOOLTIPWIDTH, ItemCollector.TOOLTIPHEIGHT); breakButtonRect = new Rect(swapTooltipRect.xMax, swapTooltipRect.yMin, swapTooltipRect.width, swapTooltipRect.height); }
public void AttachFPSItemViewAndCollector(FPSItemEquipment item, ItemCollector itemcollector) { UpdateCount+=1; if (item != null && FPSItemView != null) { RemoveEquipItem (FPSItemView); Quaternion rotationTemp = FPSItemView.transform.rotation; rotationTemp.eulerAngles += FPSItemView.RotationOffset; GameObject newitem = (GameObject)GameObject.Instantiate (item.gameObject, FPSItemView.transform.position, rotationTemp); newitem.transform.parent = FPSItemView.gameObject.transform; FPSEquipment = newitem.GetComponent<FPSItemEquipment> (); collectorAttachedTemp = itemcollector; SaveDataToItemCollector ((FPSWeaponEquipment)FPSEquipment.GetComponent<FPSWeaponEquipment> (), itemcollector); } }
public void DeleteShortcut(ItemCollector itemCollector ,int shortcut) { if (itemManager != null) { foreach(ItemCollector item in Items){ if (item != null) { if(itemCollector != item){ if(item.Shortcut == shortcut){ item.Shortcut=-1; } } if(itemCollector == item){ item.Shortcut = shortcut; } } } } }
public override bool CanPickup(ItemCollector ic) { return ic.gameObject.transform.root.GetComponentInChildren<PlayerController>().Life < PlayerController.MAX_LIFE; }
public override void Pickup(ItemCollector ic) { ic.gameObject.transform.root.GetComponentInChildren<PlayerController>().AddLife(health); }
public void DropItemByCollector(ItemCollector item, int num) { UpdateCount+=1; if (RemoveItemByCollector (item, num)) { GameObject droped = null; if (Network.isServer || Network.isClient) { droped = (GameObject)Network.Instantiate (item.Item.gameObject, this.transform.position, item.Item.gameObject.transform.rotation, 2); ItemData data = (ItemData)droped.GetComponent<ItemData> (); data.NumTag = item.NumTag; } else { droped = (GameObject)GameObject.Instantiate (item.Item.gameObject, this.transform.position, item.Item.gameObject.transform.rotation); ItemData data = (ItemData)droped.GetComponent<ItemData> (); data.NumTag = item.NumTag; } } }
public override bool CanPickup(ItemCollector ic) { return ic.CanPickup(); }
public void EquipItemByCollector(ItemCollector item) { Debug.Log("Equip Item "+item.Index); UpdateCount+=1; if (item.Index != -1 && item.Num > 0) { if (itemManager != null) { var itemdata = itemManager.GetItem (item.Index); if (itemdata != null) { EquipItem (itemdata.ItemEquip, item.Index); if (itemdata.ItemFPS) { AttachFPSItemViewAndCollector (itemdata.ItemFPS, item); } character.UpdateAnimationState (); } } } }
public void SetCollectorSlot(ItemCollector collector) { CollectorSlot = collector; if (collector.NumTag != -1) Ammo = collector.NumTag; }
public bool RemoveItemByCollector(ItemCollector itemcollector, int num) { UpdateCount+=1; ItemData itemdata = itemcollector.Item; if (itemManager != null) { if (itemdata != null && num > 0) { //Debug.Log ("Removing " + itemdata + " > " + num); for (int i=0; i<Items.Count; i++) { if (Items [i] != null && Items [i] == itemcollector) { if (Items [i].Num <= 0) { Debug.Log (Items [i].Item.ItemName + " Is no more"); return false; } if (Items [i].Num < num) { if (Items [i].Num > 0) { Items [i].Num -= Items [i].Num; } } else { Items [i].Num -= num; } if (Items [i].Num <= 0) { if (collectorAttachedTemp == itemcollector) { RemoveEquipItemByIndex (Items [i].Index); Debug.Log ("Remove " + collectorAttachedTemp + " Num " + Items [i].Num + "/" + itemcollector.Num); } Items.Remove (itemcollector); } return true; } } } } return false; }
public void SaveDataToItemCollector(FPSWeaponEquipment fpsprefab, ItemCollector item) { if (fpsprefab != null) { fpsprefab.SetCollectorSlot (item); } }
public void CopyCollector(ItemCollector item,ItemCollector source) { item.Active = source.Active; item.Index = source.Index; item.Item = source.Item; item.Num = source.Num; item.NumTag = source.NumTag; item.Shortcut = source.Shortcut; }
public void AddItem(ItemCollector item) { if (item.Active){ Items.Add (item); } }
public void SetItemsFromText(string itemdatatext) { ItemManager item = (ItemManager)GameObject.FindObjectOfType (typeof(ItemManager)); if (item) { string[] data = itemdatatext.Split ("|" [0]); //Debug.Log ("Get itemlist : " + itemdatatext + data.Length); if (data.Length >= 4) { RemoveAllItem (); string[] indexList = data [0].Split ("," [0]); string[] numList = data [1].Split ("," [0]); string[] numtagList = data [2].Split ("," [0]); string[] shortcutList = data [3].Split ("," [0]); for (int i=0; i<indexList.Length; i++) { if (indexList [i] != "") { ItemCollector itemCol = new ItemCollector (); itemCol.Item = item.GetItemDataByID (indexList [i]); if (itemCol.Item != null) { //Debug.Log ("Item " + itemCol.Item.name + " x " + itemCol.Num); int.TryParse (numList [i], out itemCol.Num); int.TryParse (numtagList [i], out itemCol.NumTag); int.TryParse (shortcutList [i], out itemCol.Shortcut); itemCol.Active = true; AddItemByIdemData (itemCol.Item, itemCol.Num, itemCol.NumTag,itemCol.Shortcut); } } } } } }
public void SwarpCollector(ItemCollector item1,ItemCollector item2) { Debug.Log("Swap"); ItemCollector tmp = new ItemCollector(); CopyCollector(tmp,item1); CopyCollector(item1,item2); CopyCollector(item2,tmp); UpdateCount+=1; }
public override void Pickup(ItemCollector ic) { ic.Pickup(item); }
public void SetItemCollector(ItemCollector item) { Item = item; }