Example #1
0
        public void changeCamera(string deviceName)
        {
            if (!InitConfigs.Instance.ReciprocalModelDic.ContainsKey(deviceName))
            {
                return;
            }
            ReciprocalModel reciprocal = InitConfigs.Instance.ReciprocalModelDic[deviceName];
            //设置当前聚焦对象,如果是组对象,取消碰撞
            GameObject obj = GameObject.Find(deviceName);

            if (InitConfigs.Instance.ReciprocalModelDic[deviceName].Reciprocal.Count > 0)
            {
                obj.GetComponent <BoxCollider>().enabled = false;
            }

            this.currentReciprocal             = reciprocal;
            this.currentReciprocal.ModelObject = obj;
            this.isWalkCamea = false;
            mouseFocus.ChangeCamera(true);

            if (reciprocal.LimitYaw != Vector2.zero)
            {
                mouseFocus.setLimit(reciprocal.LimitYaw, reciprocal.LimitPitch, reciprocal.LimitDistance);
            }
            mouseFocus.ChangeTarget(reciprocal.Model, reciprocal.Offset.x, reciprocal.Offset.y, reciprocal.Offset.z);
        }
Example #2
0
        /// <summary>
        /// 返回上级节点
        /// </summary>
        public void backSuperNode()
        {
            if (this.currentReciprocal.Reciprocal.Count > 0)
            {
                this.currentReciprocal.ModelObject.GetComponent <BoxCollider>().enabled = true;
            }

            this.currentReciprocal = null;
            backSuperNodeBtn.gameObject.SetActive(false);
            mouseFocus.ChangeCamera(false);
            this.isWalkCamea = true;
        }
Example #3
0
        void initReciprocalConfig()
        {
            reciprocalModelDic = new Dictionary <string, ReciprocalModel>();
            XmlUtil xmlUtil  = new XmlUtil(GlobalConfig.ReciprocalConfigPath, true);
            XmlNode nodeData = xmlUtil.GetChildXPathNode("data")[0];

            //Debug.Log("hello world");
            //Debug.Log(nodeData.InnerXml);
            foreach (XmlNode node in xmlUtil.GetChildNodesByName(nodeData, "交互"))
            {
                ReciprocalModel reciprocal = new ReciprocalModel();
                if (xmlUtil.GetChildNodes(node).Count != 0)
                {
                    foreach (XmlNode child in xmlUtil.GetChildNodesByName(node, "交互1"))
                    {
                        ReciprocalModel re = new ReciprocalModel();
                        setReciprocal(re, xmlUtil, child);
                        reciprocal.Reciprocal.Add(re.Model, re);
                        //reciprocalModelDic.Add(re.Model, re);
                    }
                }

                try
                {
                    setReciprocal(reciprocal, xmlUtil, node);
                }
                catch (Exception e)
                {
                    Debug.Log(e + xmlUtil.ReadAttrValue(node, "模型名"));
                }
                if (reciprocalModelDic.ContainsKey(reciprocal.Model))
                {
                    Debug.LogWarning("已存在: " + reciprocal.Model);
                }
                else
                {
                    reciprocalModelDic.Add(reciprocal.Model, reciprocal);
                }
            }
        }
Example #4
0
        private void setReciprocal(ReciprocalModel reciprocal, XmlUtil xmlUtil, XmlNode node)
        {
            reciprocal.Model = xmlUtil.ReadAttrValue(node, "模型名");
            string[] offset = xmlUtil.ReadAttrValue(node, "偏移").Split(',');
            if (offset.Length == 3)
            {
                reciprocal.Offset = new Vector3(float.Parse(offset[0]), float.Parse(offset[1]), float.Parse(offset[2]));
            }

            if (node.Attributes["范围"] != null)
            {
                string[] limit  = xmlUtil.ReadAttrValue(node, "范围").Split(',');
                float    minyaw = float.Parse(limit[0]);
                float    maxyaw = float.Parse(limit[1]);
                reciprocal.LimitYaw = new Vector2(maxyaw > minyaw ? minyaw : maxyaw, maxyaw > minyaw ? maxyaw : minyaw);
                float minpitch = float.Parse(limit[2]);
                float maxpitch = float.Parse(limit[3]);
                reciprocal.LimitPitch = new Vector2(maxpitch > minpitch ? minpitch : maxpitch, maxpitch > minpitch ? maxpitch : minpitch);
                float minDistance = float.Parse(limit[4]);
                float maxDistance = float.Parse(limit[5]);
                reciprocal.LimitDistance = new Vector2(maxDistance > minDistance ? minDistance : maxDistance, maxDistance > minDistance ? maxDistance : minDistance);
            }
        }
Example #5
0
        /// <summary>
        /// 场景中点击事件
        /// </summary>
        /// <param name="obj"></param>
        public void clickEvent(GameObject obj)
        {
            if (currentReciprocal == null)
            {
                return;
            }
            if (this.isWalkCamea)
            {
                if (!InitConfigs.Instance.ReciprocalModelDic.ContainsKey(obj.name))
                {
                    return;
                }

                ReciprocalModel reciprocal = InitConfigs.Instance.ReciprocalModelDic[obj.name];
                //设置当前聚焦对象,如果是组对象,取消碰撞
                if (InitConfigs.Instance.ReciprocalModelDic[obj.name].Reciprocal.Count > 0)
                {
                    obj.GetComponent <BoxCollider>().enabled = false;
                }

                this.currentReciprocal             = reciprocal;
                this.currentReciprocal.ModelObject = obj;

                this.isWalkCamea = false;
                //backSuperNodeBtn.gameObject.SetActive(true);
                mouseFocus.ChangeCamera(true);


                if (reciprocal.LimitYaw != Vector2.zero)
                {
                    mouseFocus.setLimit(reciprocal.LimitYaw, reciprocal.LimitPitch, reciprocal.LimitDistance);
                }
                mouseFocus.ChangeTarget(reciprocal.Model, reciprocal.Offset.x, reciprocal.Offset.y, reciprocal.Offset.z);
            }
            else
            {
                ///判断点击的物体是否是当前组对象,是组内对象则直接点击操作
                ///不是组内对象,则恢复当前组对象的碰撞,摄像机聚焦该对象,返回键时
                ///如果当前是聚焦的是组对象时,恢复组碰撞

                //PluginEventManager.FireEvent("RecordTools", TrainingOperateRequirement.conditions[TrainingManager.getTrainingOperate().states[0].requirement.formulars[0]]);

                if (obj == this.currentReciprocal.ModelObject || this.currentReciprocal.Reciprocal.ContainsKey(obj.name))
                {
                    if (TrainingComponent.waitForUserInteraction && TrainingManager.getTrainingOperateState() != null)
                    {
                        if (!TrainingManager.MouseLeftClick(obj.name))
                        {
                            clickError();
                        }
                        else
                        {
                            errorCount = 0;
                            if (currentTrainMode == TrainMode.Exam)
                            {
                                TrainingManager.gradeDetails[TrainingManager.getTrainingOperate().name].ErrorMsg = "操作正确!";
                            }
                        }
                    }
                    else if (currentTrainMode != TrainMode.Study)
                    {
                        showAlertMSG("未到交互时间");
                        Debug.LogError("未到交互时间");
                    }
                }
                else
                {
                    if (!InitConfigs.Instance.ReciprocalModelDic.ContainsKey(obj.name))
                    {
                        return;
                    }

                    if (this.currentReciprocal.Reciprocal.Count > 0)
                    {
                        this.currentReciprocal.ModelObject.GetComponent <BoxCollider>().enabled = true;
                    }

                    ReciprocalModel reciprocal = InitConfigs.Instance.ReciprocalModelDic[obj.name];
                    this.currentReciprocal             = reciprocal;
                    this.currentReciprocal.ModelObject = obj;

                    if (InitConfigs.Instance.ReciprocalModelDic[obj.name].Reciprocal.Count > 0)
                    {
                        obj.GetComponent <BoxCollider>().enabled = false;
                    }

                    if (reciprocal.LimitYaw != Vector2.zero)
                    {
                        mouseFocus.setLimit(reciprocal.LimitYaw, reciprocal.LimitPitch, reciprocal.LimitDistance);
                    }
                    mouseFocus.ChangeTarget(reciprocal.Model, reciprocal.Offset.x, reciprocal.Offset.y, reciprocal.Offset.z);
                }
            }
        }
Example #6
0
        /// <summary>
        /// 退出培训流程,返回到菜单界面
        /// </summary>
        public void backMenu()
        {
            outExamBtn.SetActive(false);
            uitool.controlPanel.SetActive(true);
            UIManager.getInstance().selectTopicUI.mask.SetActive(false);
            errorCount = 0;
            if (!(alertMSG == null || !alertMSG.gameObject.activeSelf))
            {
                ResourceManager.getInstance().getUIPool.Despawn(alertMSG.transform);
            }
            if (flowMovie.activeSelf)
            {
                flowMovie.SetActive(false);
                movieManager.OnStop();
            }
            flowOperateImage.SetActive(false);
            flowOperateMovie.SetActive(false);
            examCountDown.onStop();
            examCountDown.gameObject.SetActive(false);
            trainEndUI.gameObject.SetActive(false);
            isBackMenu = true;
            //tabStrip.tabs[(int)currentTrainMode].GetComponent<UIToggle>().value = false;
            for (int i = 0; i < coverTabs.Length; i++)
            {
                tabStrip.tabs[i].Set(false);
            }
            if (nextProcess.switchMode.activeSelf)
            {
                nextProcess.switchMode.SetActive(false);
            }
            changeCount = 0;
            uitool.setTextl(null);
            uitool.setPopText(null);
            tabStrip.restTabStrip();
            indexNumber = -1;
            uitool.setShiwaiSliderValue(Convert.ToSingle(indexNumber + 1) / Convert.ToSingle(count), indexNumber + 1, count);
            TrainingManager.ExitFlow();

            //音乐调节
            AudioManager.getInstance().SetGroundScale(1f);
            AudioManager.getInstance().AudioPlay(GlobalConfig.backgroundMusic, AudioManager.MusicNumType.groundMusic);
            AudioManager.getInstance().AudioStop(AudioManager.MusicNumType.realtimeMusic);            //返回的时候停止实时音乐

            SceneManager.LoadScene("MainUI");
            trainEndUI.gameObject.SetActive(false);
            trainStartUI.gameObject.SetActive(false);
            isShowTrainStart       = false;
            isStartTrain           = false;
            this.currentReciprocal = null;

            this.isWalkCamea = true;
            backSuperNodeBtn.gameObject.SetActive(false);
            this.isStartTrain = false;
            UIManager.getInstance().selectTopicUI.gameObject.SetActive(false);
            ScreenRaycaster raycaster = GameObject.Find("FingerGestures").GetComponent <ScreenRaycaster>();

            raycaster.Cameras    = new Camera[1];
            raycaster.Cameras[0] = GameObject.FindObjectOfType <Main>().GetComponent <Camera>();
            UIManager.getInstance().setActiveUI(UIType.MainMenu);
            examGrade.GetComponent <Camera>().depth = -50;
            CoherentUISystem.Instance.UIViews.Remove(examGrade);
        }