private void HandIdle(GameObject arg1, int arg2) { if (_handIndex != arg2) { return; } KGUI_BackPackMark equ = arg1.GetComponent <KGUI_BackPackMark>(); if (equ == null) { return; } if (!_isHandOnBag) { //SetObjectFrontUI(true); equ.ObjectFrontUI.OnReset(); //释放时,离开背包的 _handIndex = -1; return; } _handIndex = -1; //不支持组合删除 if (!equ.IsFeaturesObjectEquals()) { equ.ObjectFrontUI.OnReset(); return; } if (!equ.IsCanPutInBag()) { equ.ObjectFrontUI.OnReset(); return; } DestroyEquipment(equ); //KGUI_BackPackMark[] equs; //equs = arg1.GetComponentsInChildren<KGUI_BackPackMark>(); ////在背包里边松手 //if (equs != null) //{ // for (int i = 0; i < equs.Length; i++) // { // //不满足条件 跳过 // if (!equs[i].IsCanPutInBag()) continue; // //调用删除 // DestroyEquipment(equs[i]); // } // equs = null; //} }
/// <summary> /// 删除仪器 /// </summary> /// <param name="name"></param> public void DestroyEquipment(KGUI_BackPackMark mark) { mark.OnDestroyForBag(); KGUI_BackpackItem backpackItem; if (_dicBackpackItems.TryGetValue(mark.TagName, out backpackItem)) { //删除物体 Destroy(mark.Target); } }
/// <summary> /// 抓取背包创建 /// </summary> /// <param name="itemData"></param> /// <param name="handIndex"></param> /// <returns></returns> public GameObject CreatEquipment(KGUI_BackpackItem item, int handIndex) { KGUI_Backpack_ItemData itemData = item.dataConfig; var itemObject = Resources.Load <GameObject>(universalPath + itemData.ItemPath); var go = Instantiate(itemObject) as GameObject; go.transform.position = new Vector3(go.transform.position.x, go.transform.position.y, -16.3f); KGUI_BackPackMark mark = go.GetComponent <KGUI_BackPackMark>() ?? go.AddComponent <KGUI_BackPackMark>(); if (mark != null) { //仪器背包创建调用 mark.OnCreateForBag(item, itemData.Name, handIndex); } //KinectTransfer.SetObjectGrab(go, handIndex); MOperateManager.SetObjectGrab(go, itemData.zValue, handIndex); this._handIndex = handIndex; #region 注释 //========================== //Vector3 screenDevice = KinectTransfer.GetScreenHandPos(handIndex); //Vector3 worldDevice = //========================== //go.transform.DOScale(Vector3.one * 15, 0.1f); //层改变成UI层,然后离开时,在转化为其他层 //设置抓取信息,不管相机如何移动,抓取的物体始终在屏幕坐标中。 //Vector3 position; ////屏幕坐标 //Vector3 screenPoint = KinectTransfer.GetMCKinectPositionStatus(out position, handIndex); //screenPoint.z = itemData.zValue; //float z = /*KinectConfig.mainCamera*/Camera.main.ScreenToWorldPoint(screenPoint).z; //go.transform.position = new Vector3(go.transform.position.x, go.transform.position.y, 0.8f); //go.transform.position = new Vector3(go.transform.position.x, go.transform.position.y,0); #endregion SetObjectFrontUI(false); return(go); }
/// <summary> /// 从资源中生成仪器 /// </summary> /// <returns>The equipment.</returns> /// <param name="item">Item.</param> /// <param name="ItemPath">Item path.</param> public GameObject GenerateEquipment(KGUI_BackpackItem item, string ItemPath) { var itemObject = Resources.Load <GameObject>(universalPath + ItemPath); var go = Instantiate(itemObject) as GameObject; KGUI_BackPackMark mark = go.GetComponent <KGUI_BackPackMark>() ?? go.AddComponent <KGUI_BackPackMark>(); if (mark != null) { //仪器背包创建调用 mark.OnCreateForBag(item, item.dataConfig.Name, 0); } return(go); }
private void HandIdle(GameObject arg1, int arg2) { if (_handIndex != arg2) { return; } KGUI_BackPackMark equ = arg1.GetComponent <KGUI_BackPackMark>(); if (equ == null) { return; } if (!_isHandOnBag) { //SetObjectFrontUI(true); equ.ObjectFrontUI.OnReset(); //释放时,离开背包的 _handIndex = -1; return; } _handIndex = -1; //不支持组合删除 if (!equ.IsFeaturesObjectEquals()) { equ.ObjectFrontUI.OnReset(); return; } if (!equ.IsCanPutInBag()) { equ.ObjectFrontUI.OnReset(); return; } DestroyEquipment(equ); }
private void OnEnter(int arg0) { //获取到如果抓取的物体不能放回背包,则不做任何处理 var grabObject = MOperateManager.GetObjectGrab(arg0); if (grabObject != null) { KGUI_BackPackMark equ = grabObject.GetComponent <KGUI_BackPackMark>(); if (equ == null) { return; } if (!equ.IsFeaturesObjectEquals()) { return; } } OpenBag(arg0); SetObjectFrontUI(false); }
/// <summary> /// 抓取背包创建 /// </summary> /// <param name="itemData"></param> /// <param name="handIndex"></param> /// <returns></returns> public GameObject CreatEquipment(KGUI_BackpackItem item, int handIndex) { KGUI_Backpack_ItemData itemData = item.dataConfig; var go = GenerateEquipment(item, itemData.ItemPath); go.transform.position = new Vector3(go.transform.position.x, go.transform.position.y, -16.3f); KGUI_BackPackMark mark = go.GetComponent <KGUI_BackPackMark>() ?? go.AddComponent <KGUI_BackPackMark>(); if (mark != null) { //仪器背包创建调用 mark.OnCreateForBag(item, itemData.Name, handIndex); } //KinectTransfer.SetObjectGrab(go, handIndex); MOperateManager.SetObjectGrab(go, handIndex, itemData.zValue); this._handIndex = handIndex; SetObjectFrontUI(false); return(go); }