604 lines
27 KiB
C#
604 lines
27 KiB
C#
using CG.UTility;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function 部件拆装-一键拆装控制
|
|
*******************************************************************************/
|
|
namespace ZXK.GYJQR
|
|
{
|
|
public class AllSplitCtrl : MonoBehaviour
|
|
{
|
|
private CameraAroundCtrl _camCtrl;
|
|
[SerializeField]//机械主体的腰部盖子
|
|
private GameObject[] _yaobuGaizi;
|
|
//选中后要拖拽的物体
|
|
private GameObject _selectMoveGeo = null;
|
|
private GameObject _selectPlaceGeo = null;
|
|
private Vector3 _intervalDis;//初次点击时鼠标垫和物体点位置差
|
|
|
|
private Vector3 _selectMoveInitPos;//跟随物体初次位置
|
|
|
|
private string _curShowModelName;
|
|
|
|
[SerializeField]//模拟控制柜门位置,所有物体飞入飞出走门
|
|
private Transform[] _kzgMidPointArray = null;
|
|
|
|
//每个主物体选中的部分
|
|
private Dictionary<string, string> _selectGeoInfo = new Dictionary<string, string>();
|
|
//拖拽物体默认位置
|
|
private Dictionary<GameObject, Vector3> _toolsArray = new Dictionary<GameObject, Vector3>();
|
|
//放置物体默认位置
|
|
private Dictionary<GameObject, Vector3> _placesArray = new Dictionary<GameObject, Vector3>();
|
|
|
|
public void EnterYJCJ()
|
|
{
|
|
PopUpMng.PopToast("鼠标左键按住零件拖拽,可进行设备的拼装", -1, CG.Framework.UIGroup.Main);
|
|
_camCtrl = Camera.main.GetComponent<CameraAroundCtrl>();
|
|
transform.GetChild(0).gameObject.SetActive(false);
|
|
transform.GetChild(1).gameObject.SetActive(false);
|
|
gameObject.SetActive(true);
|
|
_curShowModelName = GameManager.Instance._DataBJCJHandler._ShowPartsName.Value;
|
|
transform.Find(_curShowModelName).gameObject.SetActive(true);
|
|
|
|
GameManager.Instance._DataBJCJHandler._CurYJCJhandler.OnValueChanged += OnSelectInfoChanged;
|
|
GameManager.Instance._DataBJCJHandler.OnYJCJCombinateChanged += OnCombinateChanged;
|
|
HidePlaceGeo();
|
|
BJCJ_INFO itemInfo = GameManager.Instance._DataBJCJHandler._YJCJDataArray[_curShowModelName][0];
|
|
GameObject geo = UtilitiesMng.GetGeoByName(transform.Find(_curShowModelName), itemInfo.itemGeo);
|
|
if (geo)
|
|
{
|
|
ActivateGeo(geo);
|
|
GameManager.Instance._DataBJCJHandler.AddYJCJCombinate(itemInfo);
|
|
}
|
|
|
|
for (int i = 0; i < _yaobuGaizi.Length; i++)
|
|
{//一键拆解开始腰部盖子隐藏
|
|
_yaobuGaizi[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
public void EnterYJPZ()
|
|
{
|
|
PopUpMng.PopToast("鼠标左键按住零件拖拽,可进行设备的拼装", -1, CG.Framework.UIGroup.Main);
|
|
gameObject.SetActive(true);
|
|
AutoComb();
|
|
}
|
|
private void Update()
|
|
{
|
|
if (!PopUpMng._TriAble) return;
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit[] rayHits;
|
|
rayHits = Physics.RaycastAll(ray);
|
|
if (rayHits != null && rayHits.Length > 0)
|
|
{
|
|
GameObject clickedFirstObject = rayHits[0].collider.gameObject;
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
if (_camCtrl) _camCtrl._STRForbid = true;
|
|
//选中的跟随鼠标物体取消触发器,便于发现安放位置
|
|
if (clickedFirstObject.name.Contains("_tool"))
|
|
{
|
|
_selectMoveGeo = clickedFirstObject;
|
|
_selectMoveInitPos = _selectMoveGeo.transform.position;
|
|
foreach (Collider collid in _selectMoveGeo.GetComponentsInChildren<Collider>())
|
|
{
|
|
collid.enabled = false;
|
|
}
|
|
|
|
Vector3 screenPosition = Camera.main.WorldToScreenPoint(_selectMoveGeo.transform.position);
|
|
Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z));
|
|
_intervalDis = worldPos - _selectMoveGeo.transform.position;
|
|
|
|
WDebug.Log($"选中的模型:{_selectMoveGeo.name}");
|
|
}
|
|
|
|
// 获取并处理模型信息
|
|
string itemGeoName = clickedFirstObject.name;
|
|
if (itemGeoName.Contains("_tool")) itemGeoName = itemGeoName.Replace("_tool", "");
|
|
BJCJ_INFO curbjrzInfo = GameManager.Instance._DataBJCJHandler.GetYJCJInfoByPartName(itemGeoName);
|
|
GameManager.Instance._DataBJCJHandler._CurYJCJhandler.SetValue(_curShowModelName, curbjrzInfo);
|
|
}
|
|
|
|
if (_selectMoveGeo != null)
|
|
{//找到拖拽物体对应的放置位置
|
|
int indexSplit = _selectMoveGeo.name.IndexOf("_");
|
|
string placeGeoName = _selectMoveGeo.name.Substring(0, indexSplit);
|
|
GameObject selectTempGeo = null;
|
|
for (int i = 0; i < rayHits.Length; i++)
|
|
{
|
|
if (rayHits[i].transform.name.Equals(placeGeoName))
|
|
{
|
|
selectTempGeo = rayHits[i].transform.gameObject;
|
|
break;
|
|
}
|
|
}
|
|
if (selectTempGeo)
|
|
{
|
|
WDebug.Log($"放置的模型:{selectTempGeo.name}");
|
|
_selectPlaceGeo = selectTempGeo;
|
|
_selectPlaceGeo.GetComponent<OutLineRender>().OutLineColor = Color.yellow;
|
|
_selectPlaceGeo.GetComponent<OutLineRender>().enabled = true;
|
|
_selectPlaceGeo.GetComponent<OutLineRender>().UpdateOutLine();
|
|
ActivateGeo(_selectPlaceGeo);
|
|
_selectMoveGeo.SetActive(false);
|
|
_selectMoveGeo.transform.position = _selectMoveInitPos;
|
|
}
|
|
else
|
|
{
|
|
if (_selectMoveGeo)
|
|
{
|
|
_selectMoveGeo.SetActive(true);
|
|
}
|
|
if (_selectPlaceGeo)
|
|
{
|
|
foreach (Transform itemchildren in _selectPlaceGeo.transform)
|
|
{
|
|
itemchildren.gameObject.SetActive(false);
|
|
}
|
|
_selectPlaceGeo.GetComponent<OutLineRender>().enabled = false;
|
|
_selectPlaceGeo = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (_selectMoveGeo)
|
|
{
|
|
_selectMoveGeo.SetActive(true);
|
|
}
|
|
if (_selectPlaceGeo)
|
|
{
|
|
foreach (Transform itemchildren in _selectPlaceGeo.transform)
|
|
{
|
|
itemchildren.gameObject.SetActive(false);
|
|
}
|
|
_selectPlaceGeo.GetComponent<OutLineRender>().enabled = false;
|
|
_selectPlaceGeo = null;
|
|
}
|
|
}
|
|
if (Input.GetMouseButton(0))
|
|
{
|
|
if (_selectMoveGeo)
|
|
{
|
|
Vector3 screenPosition = Camera.main.WorldToScreenPoint(_selectMoveGeo.transform.position);
|
|
Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPosition.z));
|
|
_selectMoveGeo.transform.position = worldPos - _intervalDis;
|
|
}
|
|
}
|
|
if (Input.GetMouseButtonUp(0))
|
|
{
|
|
if (_camCtrl) _camCtrl._STRForbid = false;
|
|
if (_selectMoveGeo != null && _selectPlaceGeo != null)
|
|
{
|
|
WDebug.Log("放置物体位置" + _selectPlaceGeo.name);
|
|
ActivateGeo(_selectPlaceGeo);
|
|
|
|
_selectPlaceGeo.GetComponent<OutLineRender>().OutLineColor = Color.red;
|
|
_selectPlaceGeo.GetComponent<OutLineRender>().UpdateOutLine();
|
|
foreach (var item in GameManager.Instance._DataBJCJHandler._YJCJDataArray[_curShowModelName])
|
|
{
|
|
if (item.itemGeo.Equals(_selectPlaceGeo.name))
|
|
{
|
|
BJCJ_INFO curbjrzInfo = item;
|
|
GameManager.Instance._DataBJCJHandler._CurYJCJhandler.SetValue(_curShowModelName, curbjrzInfo);
|
|
GameManager.Instance._DataBJCJHandler.AddYJCJCombinate(curbjrzInfo);
|
|
break;
|
|
}
|
|
}
|
|
|
|
_selectMoveGeo.SetActive(false);
|
|
_selectMoveGeo.transform.position = _selectMoveInitPos;
|
|
_selectMoveGeo = null;
|
|
_selectPlaceGeo = null;
|
|
}
|
|
|
|
if (_selectMoveGeo)
|
|
{
|
|
WDebug.Log("回到初始位置");
|
|
GameObject temp = _selectMoveGeo;
|
|
foreach (Collider collid in _selectMoveGeo.GetComponentsInChildren<Collider>())
|
|
{
|
|
collid.enabled = true;
|
|
}
|
|
_selectMoveGeo = null;
|
|
temp.transform.DOMove(_selectMoveInitPos, 0.1f);
|
|
}
|
|
|
|
if (_selectPlaceGeo)
|
|
{
|
|
_selectPlaceGeo.GetComponent<OutLineRender>().enabled = false;
|
|
_selectPlaceGeo = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void End()
|
|
{
|
|
GameManager.Instance._DataBJCJHandler._CurYJCJhandler.OnValueChanged -= OnSelectInfoChanged;
|
|
GameManager.Instance._DataBJCJHandler._CurYJCJhandler.SetDefault();
|
|
GameManager.Instance._DataBJCJHandler.OnYJCJCombinateChanged -= OnCombinateChanged;
|
|
gameObject.SetActive(false);
|
|
DOTween.KillAll();
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
GameManager.Instance._DataBJCJHandler.ClearYJCJCombinate();
|
|
End();
|
|
}
|
|
/// <summary>
|
|
/// 每次进入初始化一遍场景内容
|
|
/// </summary>
|
|
private void HidePlaceGeo()
|
|
{
|
|
foreach (var itemkeyvalue in GameManager.Instance._DataBJCJHandler._YJCJDataArray)
|
|
{
|
|
List<BJCJ_INFO> item = itemkeyvalue.Value;
|
|
string itemKey = itemkeyvalue.Key;
|
|
if (!itemKey.Equals(_curShowModelName)) continue;
|
|
List<GameObject> moveGeos = new List<GameObject>();
|
|
for (int i = 0; i < item.Count; i++)
|
|
{
|
|
if (string.IsNullOrEmpty(item[i].itemGeo)) continue;
|
|
//隐藏放置物体
|
|
GameObject selectPlaceGeo = UtilitiesMng.GetGeoByName(transform.Find(itemKey), item[i].itemGeo);
|
|
if (selectPlaceGeo)
|
|
{
|
|
//所有物体不泛光
|
|
selectPlaceGeo.GetComponent<OutLineRender>().enabled = false;
|
|
//所有位置触发器关闭
|
|
foreach (Collider collid in selectPlaceGeo.GetComponentsInChildren<Collider>())
|
|
{
|
|
collid.enabled = false;
|
|
}
|
|
//隐藏子物体,模拟透明状态
|
|
foreach (Transform itemchildren in selectPlaceGeo.transform)
|
|
{
|
|
itemchildren.gameObject.SetActive(false);
|
|
}
|
|
if (!_placesArray.ContainsKey(selectPlaceGeo))
|
|
{
|
|
_placesArray.Add(selectPlaceGeo, selectPlaceGeo.transform.position);
|
|
}
|
|
}
|
|
//显示拖拽物体
|
|
GameObject selectMoveGeo = UtilitiesMng.GetGeoByName(transform.Find(itemKey), item[i].itemGeo + "_tool", true);
|
|
if (selectMoveGeo)
|
|
{
|
|
moveGeos.Add(selectMoveGeo);
|
|
selectMoveGeo.SetActive(true);
|
|
if (!_toolsArray.ContainsKey(selectMoveGeo))
|
|
{
|
|
_toolsArray.Add(selectMoveGeo, selectMoveGeo.transform.position);
|
|
}
|
|
selectMoveGeo.transform.position = _placesArray[selectPlaceGeo];// Vector3.zero;
|
|
//所有物体不泛光
|
|
selectMoveGeo.GetComponent<OutLineRender>().enabled = false;
|
|
//所有位置触发器关闭
|
|
foreach (Collider collid in selectMoveGeo.GetComponentsInChildren<Collider>())
|
|
{
|
|
collid.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
//机械臂拆解过程
|
|
if (_curShowModelName.Equals(ConstCtrl.BJCZ_MAINMODEL1_NAME))
|
|
{
|
|
for (int i = 0; i < moveGeos.Count; i++)
|
|
{
|
|
Vector3 tagPos = _toolsArray[moveGeos[i]];
|
|
Transform curTran = moveGeos[i].transform;
|
|
curTran.DOMove(tagPos, 2.0f).SetEase(Ease.OutCubic)
|
|
.OnComplete(() =>
|
|
{
|
|
//所有位置触发器打开
|
|
foreach (Collider collid in curTran.GetComponentsInChildren<Collider>())
|
|
{
|
|
collid.enabled = true;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
else if (_curShowModelName.Equals(ConstCtrl.BJCZ_MAINMODEL2_NAME))
|
|
{//控制柜物体拆解过程
|
|
for (int i = 0; i < moveGeos.Count; i++)
|
|
{
|
|
Vector3 tagPos = _toolsArray[moveGeos[i]];
|
|
Transform curTran = moveGeos[i].transform;
|
|
Vector3 midPoint = Vector3.zero;
|
|
for (int a = 0; a < _kzgMidPointArray.Length; a++)
|
|
{
|
|
if(moveGeos[i].name.Equals(_kzgMidPointArray[a].name.Replace("_midPoint", "_tool")))
|
|
{
|
|
midPoint = _kzgMidPointArray[a].position;
|
|
}
|
|
}
|
|
curTran.DOPath(new Vector3[3] { curTran.position, midPoint, tagPos }, 3.0f, PathType.CatmullRom)
|
|
.OnComplete(() =>
|
|
{
|
|
//所有位置触发器打开
|
|
foreach (Collider collid in curTran.GetComponentsInChildren<Collider>())
|
|
{
|
|
collid.enabled = true;
|
|
}
|
|
})
|
|
.SetId("hide");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 选择某个物体
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
private void OnSelectInfoChanged(Dictionary<string, BJCJ_INFO> obj)
|
|
{
|
|
Show(obj[_curShowModelName].itemGeo);
|
|
}
|
|
private void Show(string partName)
|
|
{
|
|
SelectGeo(_curShowModelName, partName);
|
|
WDebug.Log($"显示模型信息:{partName}");
|
|
}
|
|
/// <summary>
|
|
/// 高亮显示选中物体
|
|
/// </summary>
|
|
/// <param name="showsName"></param>
|
|
/// <param name="curGeoInfo"></param>
|
|
private void SelectGeo(string showsName, string itemGeo)
|
|
{
|
|
foreach (var item in _selectGeoInfo)
|
|
{
|
|
GameObject preItemGeo = UtilitiesMng.GetGeoByName(transform.Find(item.Key), item.Value);
|
|
GameObject preItemToolGeo = UtilitiesMng.GetGeoByName(transform.Find(item.Key), item.Value + "_tool");
|
|
if (preItemGeo)
|
|
preItemGeo.GetComponent<OutLineRender>().enabled = false;
|
|
if (preItemToolGeo)
|
|
preItemToolGeo.GetComponent<OutLineRender>().enabled = false;
|
|
}
|
|
GameObject curItemGeo = UtilitiesMng.GetGeoByName(transform.Find(showsName), itemGeo);
|
|
GameObject curItemToolGeo = UtilitiesMng.GetGeoByName(transform.Find(showsName), itemGeo + "_tool");
|
|
if (curItemGeo)
|
|
curItemGeo.GetComponent<OutLineRender>().enabled = true;
|
|
if (curItemToolGeo)
|
|
curItemToolGeo.GetComponent<OutLineRender>().enabled = true;
|
|
if (_selectGeoInfo.ContainsKey(showsName))
|
|
{
|
|
_selectGeoInfo[showsName] = itemGeo;
|
|
}
|
|
else
|
|
{
|
|
_selectGeoInfo.Add(showsName, itemGeo);
|
|
}
|
|
}
|
|
|
|
private void OnCombinateChanged(BJCJ_INFO info)
|
|
{
|
|
if (_curShowModelName.Equals(ConstCtrl.BJCZ_MAINMODEL1_NAME))
|
|
{
|
|
if (info.itemGeo.Equals("腰部"))
|
|
{
|
|
for (int i = 0; i < _yaobuGaizi.Length; i++)
|
|
{//一键拼装开始腰部盖子显示
|
|
_yaobuGaizi[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
if (info.itemGeo.Equals("同步带"))
|
|
{
|
|
for (int i = 0; i < _yaobuGaizi.Length; i++)
|
|
{//一键拼装开始腰部盖子显示
|
|
_yaobuGaizi[i].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
NextComGeo();
|
|
}
|
|
/// <summary>
|
|
/// 下一个可以拼和物体
|
|
/// </summary>
|
|
private void NextComGeo()
|
|
{
|
|
List<string> nextPartName = ComItemCheck();
|
|
for (int i = 0; i < GameManager.Instance._DataBJCJHandler._YJCJDataArray[_curShowModelName].Count; i++)
|
|
{
|
|
BJCJ_INFO item = GameManager.Instance._DataBJCJHandler._YJCJDataArray[_curShowModelName][i];
|
|
if (nextPartName.Contains(item.partName))
|
|
{
|
|
BJCJ_INFO nextItem = item;
|
|
GameObject geo = UtilitiesMng.GetGeoByName(transform.Find(_curShowModelName), nextItem.itemGeo);
|
|
if (geo)
|
|
{
|
|
foreach (Collider collid in geo.GetComponentsInChildren<Collider>())
|
|
{
|
|
collid.enabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 准备拼合,物体激活
|
|
/// </summary>
|
|
/// <param name="geo"></param>
|
|
private void ActivateGeo(GameObject geo)
|
|
{
|
|
foreach (Transform itemchildren in geo.transform)
|
|
{
|
|
itemchildren.gameObject.SetActive(true);
|
|
}
|
|
foreach (Collider collid in geo.GetComponentsInChildren<Collider>())
|
|
{
|
|
collid.enabled = true;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 自动将剩余拼合
|
|
/// </summary>
|
|
private void AutoComb()
|
|
{
|
|
List<BJCJ_INFO> noCombGeoName = new List<BJCJ_INFO>();
|
|
for (int i = 0; i < GameManager.Instance._DataBJCJHandler._YJCJDataArray[_curShowModelName].Count; i++)
|
|
{
|
|
BJCJ_INFO item = GameManager.Instance._DataBJCJHandler._YJCJDataArray[_curShowModelName][i];
|
|
if (!GameManager.Instance._DataBJCJHandler.GetYJCJCombinate()[_curShowModelName].Contains(item) &&
|
|
!noCombGeoName.Contains(item))
|
|
{
|
|
noCombGeoName.Add(item);
|
|
}
|
|
}
|
|
for (int i = 0; i < noCombGeoName.Count; i++)
|
|
{
|
|
BJCJ_INFO curModel = noCombGeoName[i];
|
|
GameObject toolGeo= UtilitiesMng.GetGeoByName(transform.Find(_curShowModelName), curModel.itemGeo+"_tool");
|
|
GameObject placeGeo = UtilitiesMng.GetGeoByName(transform.Find(_curShowModelName), curModel.itemGeo);
|
|
if (_curShowModelName.Equals(ConstCtrl.BJCZ_MAINMODEL1_NAME))
|
|
{
|
|
toolGeo.transform.DOMove(placeGeo.transform.position, 2.0f).SetEase(Ease.InCubic)
|
|
.OnComplete(() =>
|
|
{
|
|
if (placeGeo.Equals("腰部"))
|
|
{
|
|
for (int i = 0; i < _yaobuGaizi.Length; i++)
|
|
{//一键拼装开始腰部盖子显示
|
|
_yaobuGaizi[i].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
toolGeo.SetActive(false);
|
|
ActivateGeo(placeGeo);
|
|
foreach (var item in _toolsArray)
|
|
{
|
|
if (item.Key == toolGeo)
|
|
{
|
|
toolGeo.transform.position = item.Value;
|
|
}
|
|
}
|
|
GameManager.Instance._DataBJCJHandler.AddYJCJCombinate(curModel);
|
|
});
|
|
}
|
|
else if (_curShowModelName.Equals(ConstCtrl.BJCZ_MAINMODEL2_NAME))
|
|
{
|
|
Vector3 midPoint = Vector3.zero;
|
|
for (int a = 0; a < _kzgMidPointArray.Length; a++)
|
|
{
|
|
if (toolGeo.name.Equals(_kzgMidPointArray[a].name.Replace("_midPoint", "_tool")))
|
|
{
|
|
midPoint = _kzgMidPointArray[a].position;
|
|
}
|
|
}
|
|
toolGeo.transform.DOPath(new Vector3[3] { toolGeo.transform.position, midPoint, placeGeo.transform.position }, 3.0f, PathType.CatmullRom)
|
|
.OnComplete(() =>
|
|
{
|
|
toolGeo.SetActive(false);
|
|
ActivateGeo(placeGeo);
|
|
foreach (var item in _toolsArray)
|
|
{
|
|
if (item.Key == toolGeo)
|
|
{
|
|
toolGeo.transform.position = item.Value;
|
|
}
|
|
}
|
|
GameManager.Instance._DataBJCJHandler.AddYJCJCombinate(curModel);
|
|
})
|
|
.SetId("active");
|
|
}
|
|
}
|
|
}
|
|
private List<string> ComItemCheck()
|
|
{
|
|
//下一步可拼装物体
|
|
List<string> nextPartName = new List<string>();
|
|
if (_curShowModelName.Equals(ConstCtrl.BJCZ_MAINMODEL1_NAME))
|
|
{
|
|
string[] items1 = new string[] { "基座", "连接线缆", "腰部", "减速器", "皮带张紧螺丝", "驱动电机", "同步轮", "同步带", "臂部", "腕部", "法兰盘" };
|
|
foreach (var item in GameManager.Instance._DataBJCJHandler.GetYJCJCombinate())
|
|
{
|
|
if (GameManager.Instance._DataBJCJHandler.GetYJCJCombinate().ContainsKey(ConstCtrl.BJCZ_MAINMODEL1_NAME))
|
|
{
|
|
List<BJCJ_INFO> itemArray = GameManager.Instance._DataBJCJHandler.GetYJCJCombinate()[ConstCtrl.BJCZ_MAINMODEL1_NAME];
|
|
nextPartName.Add("连接线缆");
|
|
string comedfinish = itemArray[itemArray.Count - 1].partName;
|
|
for (int i = 0; i < itemArray.Count; i++)
|
|
{
|
|
string itemPartName = itemArray[i].partName;
|
|
if (itemPartName.Equals("连接线缆"))
|
|
{
|
|
nextPartName.Remove("连接线缆");
|
|
break;
|
|
}
|
|
}
|
|
if (comedfinish.Equals("连接线缆"))
|
|
{
|
|
comedfinish = itemArray[itemArray.Count - 2].partName;
|
|
}
|
|
if (comedfinish.Equals("基座"))
|
|
{
|
|
nextPartName.Add("腰部");
|
|
}
|
|
else if (comedfinish.Equals("腰部"))
|
|
{
|
|
nextPartName.Add("减速器");
|
|
nextPartName.Add("皮带张紧螺丝");
|
|
nextPartName.Add("臂部");
|
|
}
|
|
else
|
|
{
|
|
if (comedfinish.Equals("同步轮"))
|
|
{
|
|
nextPartName.Add("同步带");
|
|
}
|
|
else if (comedfinish.Equals("驱动电机"))
|
|
{
|
|
nextPartName.Add("同步轮");
|
|
nextPartName.Add("减速器");
|
|
}
|
|
else if (comedfinish.Equals("皮带张紧螺丝"))
|
|
{
|
|
nextPartName.Add("驱动电机");
|
|
nextPartName.Add("减速器");
|
|
}
|
|
|
|
if (comedfinish.Equals("减速器"))
|
|
{
|
|
BJCJ_INFO temp1 = GameManager.Instance._DataBJCJHandler.GetYJCJInfoByPartName("驱动电机");
|
|
BJCJ_INFO temp2 = GameManager.Instance._DataBJCJHandler.GetYJCJInfoByPartName("皮带张紧螺丝");
|
|
if (itemArray.Contains(temp1))
|
|
{
|
|
nextPartName.Add("同步轮");
|
|
}
|
|
else if (itemArray.Contains(temp2))
|
|
{
|
|
nextPartName.Add("驱动电机");
|
|
}
|
|
else
|
|
{
|
|
nextPartName.Add("皮带张紧螺丝");
|
|
}
|
|
}
|
|
|
|
|
|
if (comedfinish.Equals("腕部"))
|
|
{
|
|
nextPartName.Add("法兰盘");
|
|
}
|
|
else if (comedfinish.Equals("臂部"))
|
|
{
|
|
nextPartName.Add("腕部");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if(_curShowModelName.Equals(ConstCtrl.BJCZ_MAINMODEL2_NAME))
|
|
{
|
|
string[] items1 = new string[] { "箱体", "主计算机", "电源模块", "主电源", "接触器接口板", "电源分配板", "I/O模块", "电容", "安全控制板", "轴计算机板", "伺服驱动器" };
|
|
for (int i = 0; i < items1.Length; i++)
|
|
{
|
|
nextPartName.Add(items1[i]);
|
|
}
|
|
}
|
|
return nextPartName;
|
|
}
|
|
}
|
|
} |