Пример #1
0
        public void Init()
        {
            ScaleCenter     = FindObjectOfType <AssembleController>().transform.position;
            RotaAngleCenter = FindObjectOfType <AssembleController>().transform.position;

            RotaLeftBut      = GameObject.Find("Canvas/BG/WorkAreaControl/PartPanel/Contrarotate").GetComponent <Button>();
            RotaRightBut     = GameObject.Find("Canvas/BG/WorkAreaControl/PartPanel/ClockwiseRotation").GetComponent <Button>();
            _Slider          = GameObject.Find("Canvas/BG/WorkAreaControl/SliderPlane/Slider").GetComponent <Slider>();
            _SliderText      = GameObject.Find("Canvas/BG/WorkAreaControl/SliderPlane/SliderText").GetComponent <Text>();
            _ChangeModeBtn   = GameObject.Find("Canvas/BG/WorkAreaControl/PartPanel/SwitchMode").GetComponent <Button>();
            _LastNode        = GameObject.Find("Canvas/BG/WorkAreaControl/PartPanel/Backspace").GetComponent <Button>();
            _AddWorkSpaceBtn = GameObject.Find("Canvas/BG/WorkAreaControl/PartPanel/AddWordArea").GetComponent <Button>();
            _DelWorkSpaceBtn = GameObject.Find("Canvas/BG/WorkAreaControl/PartPanel/DelWordArea").GetComponent <Button>();
            if (AssembleModel.StudyModel == EntryMode.GetAssembleModel())
            {
                _Skip = GameObject.Find("Canvas/BG/WorkAreaControl/PartPanel/Skip").GetComponent <Button>();
            }

            _UIPartsPanelClass = GameObject.Find("Canvas/BG/PartsPanel/PartsClassPanel").GetComponent <UIPartsPanelClass>();
            _UIPartsPage       = GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel").GetComponent <UIPartsPage>();

            _MainWorkSpace = GameObject.Find("Canvas/Floor/MainWorkSpace");

            PartInfo  = GameObject.Find("Canvas/BG/InfoPanel/Panel/Info").GetComponent <Text>();          //零件信息内容
            NextParts = GameObject.Find("Canvas/BG/InfoPanel/Panel/Tips").GetComponent <Text>();          //下一步该零件零件提示内容

            RotaLeftBut.onClick.AddListener(RotaLeftBtnClick);
            RotaRightBut.onClick.AddListener(RotaRightBtnClick);
            _ChangeModeBtn.onClick.AddListener(ChangeModeClick);
            _LastNode.onClick.AddListener(LastNodeClick);
            if (AssembleModel.StudyModel == EntryMode.GetAssembleModel())
            {
                _Skip.onClick.AddListener(SkipClick);
                _AddWorkSpaceBtn.onClick.AddListener(AddWorkSpace);
                _DelWorkSpaceBtn.onClick.AddListener(DelWorkSpace);
            }
            #region Test
            InstalledNodeList.Add(NodesController.Instance.GetNodeList()[0]);

            NextInstallNode = _DependencyGraph.GetNextSteps(InstalledNodeList[InstalledNodeList.Count - 1]).Cast <Node>();
            if (null != NextInstallNode && EntryMode.GetAssembleModel() == AssembleModel.StudyModel)   //学习模式文字提示
            {
                string err   = "";
                int    index = 1;
                foreach (Node node in NextInstallNode)
                {
                    node.SetInstallationState(InstallationState.NextInstalling);
                    //跳转页面
                    //_UIPartsPage.SetIndex(node);
                    index = _UIPartsPage.GetIndex(node);
                    err  += node.name + "(第" + index + "页)" + "/";
                    NextInstallNodeList.Add(node);
                }
                NextParts.text = err;
            }
            #endregion

            //菜单控件添加事件
            _Slider.onValueChanged.AddListener(SlideTheSlider);
        }
Пример #2
0
        void IManipulationHandler.OnManipulationUpdated(ManipulationEventData eventData)
        {
            if (null != gameObject.GetComponent <HandDraggable>())
            {
                if (null != gameObject.GetComponent <Node>())              //0.03
                {
                    if (1 == gameObject.GetComponent <Node>().WorkSpaceID&& InstallationState.Step1Installed == NodesCommon.Instance.GetInstallationState(gameObject.GetComponent <Node>().nodeId) && 9f >= Vector3.Distance(gameObject.transform.position, gameObject.GetComponent <Node>().EndPos))
                    {
                        if (EntryMode.GetAssembleModel() != AssembleModel.ExamModel)
                        {
                            NodesCommon.Instance.SetInstallationState(gameObject.GetComponent <Node>().nodeId, InstallationState.Installed);
                            AssembleManager.Instance.SetInstalledNodeListStatus(gameObject.GetComponent <Node>(), InstallationState.Installed);
                            Destroy(gameObject.GetComponent <HandDraggable>());
                            bool installatFlag = false;

                            gameObject.transform.position = gameObject.GetComponent <Node>().EndPos;

                            foreach (Node node in NodesController.Instance.GetNodeList())
                            {
                                if (InstallationState.NextInstalling == node.GetInstallationState() || InstallationState.Step1Installed == node.GetInstallationState())
                                {
                                    installatFlag = true;
                                    break;
                                }
                            }

                            if (false == installatFlag)            //说明这一步所有的零件都已经被安装了,那么该下一步了
                            {
                                AssembleManager.Instance.NextInstall(gameObject.GetComponent <Node>());
                            }

                            gameObject.GetComponent <Node>().PlayAnimations();
                            Destroy(GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1/Text" + gameObject.GetComponent <Node>().nodeId).gameObject);
                            Destroy(GameObject.Find("RuntimeObject/Nodes/" + gameObject.GetComponent <Node>().name + gameObject.GetComponent <Node>().nodeId));

                            Destroy(gameObject.GetComponent <BoxCollider>());
                            gameObject.AddComponent <MeshCollider>();
                            if (!gameObject.GetComponent <Node>().hasAnimation)
                            {
                                AssembleManager.Instance.Recovery();
                            }
                        }
                        else
                        {
                            bool flag = false;
                            foreach (Node no in AssembleManager.Instance.GetNextInstallNode())
                            {
                                if (gameObject.GetComponent <Node>().nodeId == no.nodeId)
                                {
                                    NodesCommon.Instance.SetInstallationState(gameObject.GetComponent <Node>().nodeId, InstallationState.Installed);
                                    AssembleManager.Instance.SetInstalledNodeListStatus(gameObject.GetComponent <Node>(), InstallationState.Installed);

                                    Destroy(gameObject.GetComponent <HandDraggable>());

                                    bool installatFlag = false;

                                    gameObject.transform.position = gameObject.GetComponent <Node>().EndPos;

                                    foreach (Node node in NodesController.Instance.GetNodeList())
                                    {
                                        if (InstallationState.NextInstalling == node.GetInstallationState() || InstallationState.Step1Installed == node.GetInstallationState())
                                        {
                                            installatFlag = true;
                                            break;
                                        }
                                    }

                                    if (false == installatFlag)            //说明这一步所有的零件都已经被安装了,那么该下一步了
                                    {
                                        AssembleManager.Instance.NextInstall(gameObject.GetComponent <Node>());
                                    }
                                    gameObject.GetComponent <Node>().PlayAnimations();
                                    Destroy(GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1/Text" + gameObject.GetComponent <Node>().nodeId).gameObject);
                                    Destroy(gameObject.GetComponent <BoxCollider>());
                                    gameObject.AddComponent <MeshCollider>();
                                    flag = true;
                                }
                            }

                            if (false == flag)
                            {
                                Destroy(gameObject.GetComponent <HandDraggable>());
                                Destroy(gameObject.GetComponent <BoxCollider>());
                                gameObject.transform.position = gameObject.GetComponent <Node>().EndPos;
                                AssembleManager.Instance.ReMoveInstalledNodeList(gameObject.GetComponent <Node>());
                                NodesCommon.Instance.SetInstallationState(gameObject.GetComponent <Node>().nodeId, InstallationState.NotInstalled);
                                AssembleManager.Instance.SetTipCanvasStatus(true);
                                AssembleManager.Instance.GetTipErrBtn().onClick.AddListener(OnMovesIEnumerator);
                                Destroy(GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1/Text" + gameObject.GetComponent <Node>().nodeId).gameObject);
                            }
                        }
                    }
                    //else if (2 == gameObject.GetComponent<Node>().WorkSpaceID && InstallationState.Step1Installed == NodesCommon.Instance.GetInstallationState(gameObject.GetComponent<Node>().nodeId) && gameObject.GetComponent<Node>().HaulingDistance >= Vector3.Distance(gameObject.transform.position, gameObject.GetComponent<Node>().WorSpaceRelativePos))
                    //{
                    //    NodesCommon.Instance.SetInstallationState(gameObject.GetComponent<Node>().nodeId, InstallationState.WorkSpaceInstalled);
                    //    gameObject.transform.position = gameObject.GetComponent<Node>().WorSpaceRelativePos;
                    //    Destroy(gameObject.GetComponent<HandDraggable>());
                    //    Destroy(gameObject.GetComponent<BoxCollider>());
                    //    gameObject.transform.parent = GameObject.Find("RuntimeObject/SecondWorkSpace").transform;
                    //     Destroy(GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1/Text" + gameObject.GetComponent<Node>().nodeId).gameObject);
                    //     Destroy(GameObject.Find("RuntimeObject/Nodes/" + gameObject.GetComponent<Node>().name + "Sec" + gameObject.GetComponent<Node>().nodeId));

                    //    bool flag = false;
                    //    foreach (Transform trans in GameObject.Find("RuntimeObject/SecondWorkSpace").transform)
                    //    {
                    //        if (InstallationState.WorkSpaceInstalled != NodesCommon.Instance.GetInstallationState(trans.gameObject.GetComponent<Node>().nodeId))
                    //        {
                    //            flag = true;
                    //            break;
                    //        }
                    //    }

                    //    if (false == flag)                 //第二工作区全部安装完毕
                    //    {
                    //        if (null == GameObject.Find("RuntimeObject/SecondWorkSpace").GetComponent<BoxCollider>())
                    //        {
                    //            GameObject.Find("RuntimeObject/SecondWorkSpace").AddComponent<BoxCollider>();
                    //        }
                    //        if (null == GameObject.Find("RuntimeObject/SecondWorkSpace").GetComponent<HandDraggable>())
                    //        {
                    //            GameObject.Find("RuntimeObject/SecondWorkSpace").AddComponent<HandDraggable>();
                    //        }
                    //        if (null == GameObject.Find("RuntimeObject/SecondWorkSpace").GetComponent<NodeManager>())
                    //        {
                    //            GameObject.Find("RuntimeObject/SecondWorkSpace").AddComponent<NodeManager>();
                    //        }
                    //    }
                    //}
                    else
                    {
                        GameObject.Find("Canvas/BG/PartsPanel/SinglePartPanel/Button 1/Text" + gameObject.GetComponent <Node>().nodeId).transform.position = gameObject.transform.position;
                    }
                }

                //if ("SecondWorkSpace" == gameObject.name && gameObject.GetComponent<Node>().HaulingDistance >= Vector3.Distance(gameObject.transform.position, GameObject.Find("Canvas/Floor/MainWorkSpace").transform.position))
                //{
                //    for (int i = 0; i < NodesCommon.Instance.GetWorkSpaceNodes(2).Count; i++)
                //    {
                //        NodesCommon.Instance.SetInstallationState(NodesCommon.Instance.GetWorkSpaceNodes(2)[i].GetComponent<Node>().nodeId, InstallationState.Installed);
                //    }
                //    gameObject.transform.position = GameObject.Find("Canvas/Floor/MainWorkSpace").transform.position;
                //    Destroy(gameObject.GetComponent<HandDraggable>());
                //    Destroy(gameObject.GetComponent<BoxCollider>());
                //    Destroy(gameObject.GetComponent<NodeManager>());
                //}
            }
        }