private IEnumerator BtnStateManagerIEnumerator()               //协程的具体实现
        {
            int flag = 0;                                              //闪烁提示的标记
            InstallationState installationState;                       //声明一个安装状态的变量

            while (true)
            {
                if (AssembleModel.StudyModel == EntryMode.GetAssembleModel() || AssembleModel.ExamModel == EntryMode.GetAssembleModel()) //需要管按钮的状态
                {
                    if (null == UIPartBtnNode || null == AssembleManager.Instance || null == NodesCommon.Instance)                       //按钮上没有被绑定的零件
                    {
                        continue;
                    }

                    installationState = NodesCommon.Instance.GetInstallationState(UIPartBtnNode.nodeId);   //获取按钮上被绑定的零件的状态

                    if (InstallationState.Installed == installationState)
                    {
                        AssembleManager.Instance.DisButton(gameObject);
                    }
                    else if (InstallationState.NotInstalled == installationState)
                    {
                        AssembleManager.Instance.AbleButton(gameObject);
                    }
                    else if (InstallationState.NextInstalling == installationState)
                    {
                        if (AssembleModel.StudyModel == EntryMode.GetAssembleModel())                      //学习模式提示待安装的按钮的状态
                        {
                            if (flag == 0)
                            {
                                AssembleManager.Instance.AbleButton(gameObject);
                                flag = 1;
                                yield return(new WaitForSeconds(0.6f));
                            }
                            else
                            {
                                AssembleManager.Instance.DisButton(gameObject);
                                flag = 0;
                                yield return(new WaitForSeconds(0.6f));
                            }
                        }
                    }
                    else if (InstallationState.Step1Installed == installationState)
                    {
                        AssembleManager.Instance.DisButton(gameObject);
                    }
                    else
                    {
                    }
                }
                yield return(0);
            }
        }
Ejemplo n.º 2
0
 private void StartScence()
 {
     EntryMode.SetAssembleModel(AssembleModel.DemonstrationModel);
     SceneManager.LoadScene(0);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 零件按钮点击事件
        /// </summary>
        private void BtnClick(GameObject go)
        {
            Node node;                                  //被点击的零件
            IEnumerable <Node> NextInstallNode = AssembleManager.Instance.GetNextInstallNode();
            GameObject         gameobj;                 //克隆一份,作为安装的零件
            GameObject         gameOb;                  //克隆一份作为提示
            GameObject         gameObSec;               //克隆一份作为第二工作区提示
            GameObject         Txt;                     //克隆一份文本

            Transform[] trans;

            if (EntryMode.GetAssembleModel() != AssembleModel.ExamModel)         //学习模式
            {
                for (int i = 0; i < BtnList.Count; i++)
                {
                    if (BtnList[i].name == go.name)
                    {
                        node = m_ItemsList[(m_PageIndex - 1) * Page_Count + i];

                        if (InstallationState.Step1Installed == NodesCommon.Instance.GetInstallationState(node.nodeId) || InstallationState.Installed == NodesCommon.Instance.GetInstallationState(node.nodeId))
                        {
                            continue;
                        }

                        if (true == NodesCommon.Instance.IsPartInstallating())        //如果有零件正在安装
                        {
                            //此处要给提示
                            ErrorInfo.text = "错误信息提示:请装完前面一个从零件架上取下的零件,再从零件架上抓取!";
                            continue;
                        }

                        if (null != NextInstallNode)
                        {
                            foreach (Node nd in NextInstallNode)
                            {
                                if (nd.nodeId == node.nodeId && InstallationState.NextInstalling == node.GetInstallationState())
                                {
                                    gameobj                      = Instantiate(node.gameObject, node.gameObject.transform, true);
                                    gameobj.name                 = node.name;
                                    gameobj.transform.parent     = GameObject.Find("RuntimeObject/Nodes").transform;
                                    gameobj.transform.localScale = node.LocalSize * AssembleManager.Instance.GetScale();
                                    gameobj.transform.RotateAround(AssembleManager.Instance.GetRotaAngleCenter(), Vector3.up, AssembleManager.Instance.GetRotaAngle());

                                    gameOb      = Instantiate(node.gameObject, node.gameObject.transform, true);
                                    gameOb.name = node.name + node.nodeId;

                                    gameOb.transform.parent   = GameObject.Find("RuntimeObject/Nodes").transform;
                                    gameOb.transform.position = node.EndPos;
                                    gameOb.transform.rotation = gameobj.transform.rotation;
                                    if (null != gameOb.GetComponent <MeshRenderer>())
                                    {
                                        gameOb.GetComponent <MeshRenderer>().sharedMaterial = GlobalVar.HideLightMate;
                                    }
                                    else
                                    {
                                        trans = gameOb.GetComponentsInChildren <Transform>();
                                        foreach (Transform tran in trans)
                                        {
                                            if (null != tran.gameObject.GetComponent <MeshRenderer>())
                                            {
                                                tran.gameObject.GetComponent <MeshRenderer>().sharedMaterial = GlobalVar.HideLightMate;
                                            }
                                        }
                                    }
                                    gameOb.transform.localScale = node.LocalSize * AssembleManager.Instance.GetScale();

                                    gameObSec                    = Instantiate(node.gameObject, node.gameObject.transform, true);
                                    gameObSec.name               = node.name + "Sec" + node.nodeId;
                                    gameObSec.transform.parent   = GameObject.Find("RuntimeObject/Nodes").transform;
                                    gameObSec.transform.position = node.WorSpaceRelativePos;
                                    if (null != gameObSec.GetComponent <MeshRenderer>())
                                    {
                                        gameObSec.GetComponent <MeshRenderer>().sharedMaterial = GlobalVar.HideLightMate;
                                    }
                                    else
                                    {
                                        trans = gameObSec.GetComponentsInChildren <Transform>();
                                        foreach (Transform tran in trans)
                                        {
                                            if (null != tran.gameObject.GetComponent <MeshRenderer>())
                                            {
                                                tran.gameObject.GetComponent <MeshRenderer>().sharedMaterial = GlobalVar.HideLightMate;
                                            }
                                        }
                                    }
                                    gameObSec.transform.localScale = node.LocalSize * AssembleManager.Instance.GetScale();
                                    gameObSec.transform.Rotate(Vector3.up, -AssembleManager.Instance.GetRotaAngle(), Space.Self);

                                    gameobj.AddComponent <NodeManager>();
                                    gameobj.AddComponent <BoxCollider>();
                                    if (null == gameobj.GetComponent <MeshFilter>())
                                    {
                                        gameobj.GetComponent <BoxCollider>().size /= 10;
                                    }
                                    //gameobj.GetComponent<BoxCollider>().size = GetBoxColliderSize(gameobj);
                                    gameobj.AddComponent <HandDraggable>();
                                    gameobj.GetComponent <HandDraggable>().RotationMode = HandDraggable.RotationModeEnum.LockObjectRotation;

                                    StartCoroutine(OnMovesIEnumerator(gameobj, gameobj.transform.position));
                                    PartInfo.text = "被选中的零件信息:" + gameobj.GetComponent <Node>().note;
                                    if (gameobj.name == "测试箱脚垫")
                                    {
                                        PartInfo.text = "被选中的零件信息:" + "\n" + "名称:优力胶" + "\n" + "颜色:黄色" + "\n" + "大小:50*30" + "\n" + "孔位:M8沉头孔";
                                    }
                                    if (null != AssembleManager.Instance.GetNextInstallNode())
                                    {
                                        string tips  = "";
                                        int    index = 1;
                                        foreach (Node no in AssembleManager.Instance.GetNextInstallNode())
                                        {
                                            if (InstallationState.NextInstalling == no.GetInstallationState())
                                            {
                                                index = GetIndex(no);
                                                tips += no.name + "(第" + index + "页)" + "/";
                                            }
                                        }
                                        NextParts.text = "下一步应该安装的零件:" + tips;
                                    }

                                    Txt      = Instantiate(GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1/Text"), GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1").transform, true);
                                    Txt.name = "Text" + node.nodeId;
                                    Txt.transform.position         = node.gameObject.transform.position;
                                    Txt.GetComponent <Text>().text = node.gameObject.name;

                                    if (null != gameobj.GetComponent <Node>())
                                    {
                                        if (null != gameobj.GetComponent <HandDraggable>())
                                        {
                                            NodesCommon.Instance.SetInstallationState(node.GetComponent <Node>().nodeId, InstallationState.Step1Installed);
                                            AssembleManager.Instance.AddInstalledNodeList(gameobj.GetComponent <Node>());
                                            AssembleManager.Instance.SetInstalledNodeListStatus(gameobj.GetComponent <Node>(), InstallationState.Step1Installed);

                                            AssembleManager.Instance.AutoScaleAndRota(gameobj.GetComponent <Node>());
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        else
                        {
                            Debug.LogError("当前可安装列表为空!");
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < BtnList.Count; i++)
                {
                    if (BtnList[i].name == go.name)
                    {
                        node = m_ItemsList[(m_PageIndex - 1) * Page_Count + i];

                        if (InstallationState.Step1Installed == NodesCommon.Instance.GetInstallationState(node.nodeId) || InstallationState.Installed == NodesCommon.Instance.GetInstallationState(node.nodeId))
                        {
                            continue;
                        }

                        if (true == NodesCommon.Instance.IsPartInstallating())        //如果有零件正在安装
                        {
                            continue;
                        }

                        gameobj                      = Instantiate(node.gameObject, node.gameObject.transform, true);
                        gameobj.name                 = node.name;
                        gameobj.transform.parent     = GameObject.Find("RuntimeObject/Nodes").transform;
                        gameobj.transform.localScale = node.LocalSize * AssembleManager.Instance.GetScale();
                        gameobj.transform.RotateAround(AssembleManager.Instance.GetRotaAngleCenter(), Vector3.up, AssembleManager.Instance.GetRotaAngle());

                        gameobj.AddComponent <NodeManager>();
                        gameobj.AddComponent <BoxCollider>();
                        if (null == gameobj.gameObject.GetComponent <MeshFilter>())
                        {
                            gameobj.GetComponent <BoxCollider>().size /= 10;
                        }
                        //gameobj.GetComponent<BoxCollider>().size = GetBoxColliderSize(gameobj);
                        gameobj.AddComponent <HandDraggable>();
                        gameobj.GetComponent <HandDraggable>().RotationMode = HandDraggable.RotationModeEnum.LockObjectRotation;

                        StartCoroutine(OnMovesIEnumerator(gameobj, gameobj.transform.position));         //从零件架上飞出

                        Txt      = Instantiate(GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1/Text"), GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1").transform, true);
                        Txt.name = "Text" + node.nodeId;
                        Txt.transform.position         = node.gameObject.transform.position;
                        Txt.GetComponent <Text>().text = node.gameObject.name;

                        if (null != gameobj.GetComponent <Node>())
                        {
                            if (null != gameobj.GetComponent <HandDraggable>())
                            {
                                NodesCommon.Instance.SetInstallationState(node.GetComponent <Node>().nodeId, InstallationState.Step1Installed);
                                AssembleManager.Instance.AddInstalledNodeList(gameobj.GetComponent <Node>());
                                AssembleManager.Instance.SetInstalledNodeListStatus(gameobj.GetComponent <Node>(), InstallationState.Step1Installed);
                            }
                        }
                        break;
                    }
                }
            }
        }