//清除 public void Clear() { if (CurrentItemCollector != null) { CurrentItemCollector.Clear(); } CurrentSticker = null; }
void Awake() { networkViewer = this.gameObject.GetComponent<NetworkView> (); character = this.gameObject.GetComponent<CharacterSystem> (); itemManager = (ItemManager)GameObject.FindObjectOfType (typeof(ItemManager)); if (this.transform.GetComponentsInChildren (typeof(ItemSticker)).Length > 0) { var items = this.transform.GetComponentsInChildren (typeof(ItemSticker)); itemStickers = new ItemSticker[items.Length]; for (int i=0; i<items.Length; i++) { itemStickers [i] = items [i].GetComponent<ItemSticker> (); itemStickers [i].ItemIndex = -1; } } PlayerView pv = gameObject.GetComponent<PlayerView> (); if (pv && FPSItemView == null) { FPSItemView = pv.FPScamera.FPSItemView.GetComponent<ItemSticker> (); } int shortkey = 0; for (int i=0; i< StarterItems.Length; i++) { if (StarterItems [i].item != null) { AddItemByIdemData (StarterItems [i].item, StarterItems [i].Num, -1,shortkey); shortkey++; } } if (Items.Count > 0 && Items [0] != null) EquipItemByCollector (Items [0]); }
public void RemoveStickerItem(ItemSticker sticker) { UpdateCount+=1; if (sticker != null) { sticker.ItemIndex = -1; var items = sticker.transform.GetComponentsInChildren (typeof(ItemEquipment)); for (int i= 0; i< items.Length; i++) Destroy (items [i].gameObject); } }
public void AttachItem(ItemSticker sticker, ItemEquipment item) { UpdateCount+=1; if (sticker != null && item != null) { RemoveEquipItem (sticker); Quaternion rotationTemp = sticker.transform.rotation; rotationTemp.eulerAngles += sticker.RotationOffset; GameObject newitem = (GameObject)GameObject.Instantiate (item.gameObject, sticker.transform.position, rotationTemp); newitem.transform.parent = sticker.gameObject.transform; if (sticker.equipType == EquipType.Weapon) { TDEquipment = newitem.GetComponent<ItemEquipment> (); } } }