private bool IsInView(BuildingBox item)
    {
        if (item == null)
        {
            return(false);
        }
        if (AllUseIsInViewEx)//测试用
        {
            return(IsInViewEx(item));
        }

        bool inView = IsInView(item.transform.position, Camera.main, minView, maxView);

        return(inView);
    }
    private void LoadBuildingOfPerson(HistoryManController controller)
    {
        LocationHistoryPath_M path_m = controller.GetComponent <LocationHistoryPath_M>();
        DepNode depnodeNow           = MonitorRangeManager.GetDepNodeBuild(path_m.depnode);

        if (depnodeNow != null)
        {
            BuildingBox box = depnodeNow.GetComponent <BuildingBox>();
            if (box)
            {
                box.LoadBuilding((nNode) => {
                    FactoryDepManager.Instance.SetAllColliderIgnoreRaycastOP(true);
                }, false);
            }
        }
    }
    private void ReplaceBuildingObject(GameObject obj, SceneAssetInfo info, string sceneName, GameObject selectedObj, string nameAfter)
    {
        if (selectedObj != null)
        {
            var path = AssetDatabase.GetAssetPath(selectedObj);
            info.ModelPath = path;
            GameObject newObj = GameObject.Instantiate(selectedObj);
            newObj.name = sceneName + nameAfter;
            newObj.transform.position = obj.transform.position;
            newObj.transform.parent   = obj.transform.parent;

            var buildingControllers = obj.GetComponentsInChildren <BuildingController>();
            if (buildingControllers.Length == 1)
            {
                var buildingControllersNew = CopyBuildingComponents(obj, newObj, true);//拷贝大楼控制脚本
                CopyFloorControllers(obj, newObj, buildingControllersNew[0]);
                CreateBuildingBox(newObj, info);
            }
            else if (buildingControllers.Length > 1)//D1-D5,J6J11的情况
            {
                foreach (var buildingController in buildingControllers)
                {
                    var newController = newObj.transform.FindChildByName(buildingController.name);
                    if (newController == null)
                    {
                        Debug.LogError("newController == null :" + buildingController.name);
                        continue;
                    }
                    var buildingControllersNew = CopyBuildingComponents(buildingController.gameObject, newController.gameObject, true);//拷贝大楼控制脚本
                    CopyFloorControllers(buildingController.gameObject, newController.gameObject, buildingControllersNew[0]);
                    BuildingBox box = CreateBuildingBox(newController.gameObject, info);
                    box.IsPart = true;
                }
            }
            else
            {
                Debug.LogError("没有BuildingController:" + obj);
            }

            obj.SetActive(false);
            SelectObject(newObj);
        }
        else
        {
            Debug.LogError("selectedObj == null");
        }
    }
    private BuildingController InitBuildingController(GameObject rootObj)
    {
        Transform          controllerObject = rootObj.transform;
        BuildingController controller       = null;
        //if (buildingController == null)//2019_05_22_cww:这个不需要,不然快速卸载->加载时,后续的的物体无法替换进去。正常操作的话倒是不影响。
        {
            controller = controllerObject.GetComponent <BuildingController>();
            if (controller == null)//D1-D4,物体下面有子物体
            {
                controllerObject = controllerObject.FindChildByName(gameObject.name);
                if (controllerObject == null)
                {
                    Debug.LogError("controllerObject == null:" + gameObject.name);
                }
                else
                {
                    controller = controllerObject.GetComponent <BuildingController>();
                }
            }
            if (controller != null)
            {
                BuildingBox boxInAsset = controller.GetComponent <BuildingBox>();
                if (boxInAsset)
                {
                    GameObject.DestroyImmediate(boxInAsset);//有时候不小心把BuildingBox也打包进去了。
                    Debug.LogWarning(" Have BuildingBox In AssetBundle !!!!");
                }

                controller.buildingBox     = this;
                controller.ParentNode      = parentDepNode;
                controller.AfterOpenFloor += BuildingController_AfterOpenFloor;//展开楼层时加载设备
                controller.SetIsLoaded();
#if UNITY_EDITOR
                history.Add(controller);
#endif
            }
            else
            {
                Debug.LogError("buildingController == null :" + controllerObject);
            }
        }
        //else{

        //}

        return(controller);
    }
    void Start()
    {
        //Setting = SystemSettingHelper.assetLoadSetting;
        ShowVertexs();

        buildingBox = GameObject.FindObjectsOfType <BuildingBox>();

        if (J1 == null)
        {
            J1 = buildingBox.ToList().Find(i => i.SceneName == "J1");//J1特殊处理
        }
        if (J1)
        {
            var building = J1.GetComponent <BuildingController>();
            J1_F2 = building.ChildNodes[1] as FloorController;
        }
    }
Exemple #6
0
        private async Task LoadBuildings()
        {
            BuildingBox.ClearValue(ItemsControl.ItemsSourceProperty);
            BuildingBox.DisplayMemberPath = "Name";
            BuildingBox.SelectedValuePath = "BuildingID";
            BuildingBox.ItemsSource       = await roomCore.GetAssignedBuildingsForConferenceAsync(UserCredentials.Conference.ConferenceId);

            if (RoomBox.SelectedIndex >= 0)
            {
                lastSelectedRoom = (RoomDTO)RoomBox.SelectedItem;
            }
            RoomBox.ClearValue(ItemsControl.ItemsSourceProperty);
            if (lastSelectedRoom != null)
            {
                BuildingBox.SelectedValue = lastSelectedRoom.BuildingID;
            }
        }
    private void GetHitInfos()
    {
        hitBoxList.Clear();
        hitObjects.Clear();
        var hitInfos = Physics.RaycastAll(Camera.main.transform.position, Camera.main.transform.forward);

        foreach (var item in hitInfos)
        {
            BuildingBox box = item.transform.GetComponent <BuildingBox>();
            //if (!hitBoxList.Contains(box))
            //{
            //    hitBoxList.Add(box);
            //}
            if (box != null)
            {
                hitBoxList.Add(box);
            }
            hitObjects.Add(item.transform);
        }
    }
    private bool IsInViewEx(BuildingBox item)
    {
        if (item == null)
        {
            return(false);
        }

        bool inView = false;
        var  points = item.GetTestPoints();

        foreach (var point in points)
        {
            var r = IsInView(point, Camera.main, minView, maxView);
            if (r)
            {
                inView = true;
                break;
            }
        }
        return(inView);
    }
    private void SetBuildingState(GameObject person, bool isEnter)
    {
        Debug.Log("DoorAccessItem.SetBuildingState isEnter:" + isEnter);
        if (doorBuilding == null)
        {
            doorBuilding = transform.GetComponentInParent <BuildingController>();
        }
        DevSubsystemManage manager = DevSubsystemManage.Instance;

        if (doorBuilding == null || manager == null)
        {
            return;
        }
        if (isEnter)//进入门的范围
        {
            BuildingBox box = doorBuilding.GetComponent <BuildingBox>();
            if (box != null)
            {
                box.LoadBuilding(dep =>
                {
                    LoadBuildingDev(doorBuilding);
                });
            }
            else
            {
                LoadBuildingDev(doorBuilding);
            }
        }
        else//离开门的范围
        {
            var isExist = manager.IsBuildingExist(doorBuilding);
            if (!isExist)
            {
                DevSubsystemManage.Instance.SetTriggerBuilding(doorBuilding, false);
                //doorBuilding.ShowBuildingDev(false);
                RoamManage.Instance.SetLight(false);
            }
        }
    }
    /// <summary>
    /// 计算历史轨迹人员的所在区域
    /// </summary>
    public void ShowArea()
    {
        //List<Position> ps = MultHistoryPlayUI.Instance.GetPositionsByPersonnel(personnel);

        List <Position> ps = LocationHistoryUITool.GetPositionsByPersonnel(personnel);

        if (ps != null)
        {
            if (currentPointIndex < ps.Count && currentPointIndex > -1)
            {
                Position p          = ps[currentPointIndex];
                DepNode  depnodeT   = RoomFactory.Instance.GetDepNodeById((int)p.TopoNodeId);
                DepNode  depnodePri = MonitorRangeManager.GetDepNodeBuild(depnode);
                DepNode  depnodeNow = MonitorRangeManager.GetDepNodeBuild(depnodeT);

                if (depnodeNow != null && depnodePri != depnodeNow && LocationHistoryManager.Instance.CurrentFocusController == historyManController)
                {
                    BuildingBox box = depnodeNow.GetComponent <BuildingBox>();
                    if (box)
                    {
                        box.LoadBuilding((nNode) =>
                        {
                            FactoryDepManager.Instance.SetAllColliderIgnoreRaycastOP(true);
                        }, false);
                        //LocationManager.Instance.TransparentPark();
                        //return;
                    }
                }

                depnode = depnodeT;
                if (depnode)
                {
                    LocationHistoryUITool.SetItemArea(personnel, depnode.NodeName);
                }
            }
        }
    }
Exemple #11
0
    public void Detect(/*UnitBox uBox*//*, UnitBox euBox*/)//유닛 탐지
    {
        if (this != null)
        {
            Collider[] hitCollider = Physics.OverlapSphere(this.transform.position, 6.0f); //탐지

            if (this.tag == "PlayerU" && m_UnitCommend != 0)
            {
                foreach (Collider hit in hitCollider)
                {
                    if (hit.tag == "EnemyU")
                    {
                        if (hit.gameObject.GetComponent <UnitBox>().m_sUnit.Hp >= 0)
                        {
                            m_enemy  = hit.gameObject.GetComponent <UnitBox>(); //탐지 한 적개체를 타겟으로 지정
                            m_fDists = Vector3.Distance(this.transform.position, m_enemy.transform.position);
                            if (m_fDists > this.m_sUnit.Range)
                            {
                                this.TargetPosition = m_enemy.transform.position;//적유닛의 위치로이동
                                DetectCheck         = 0;
                            }
                            if (m_fDists <= this.m_sUnit.Range + 0.2)          //사거리 안으로 이동시
                            {
                                this.TargetPosition = this.transform.position; //현재위치에 멈춤
                                DetectCheck         = 1;
                            }
                        }
                    }
                }
            }

            //Collider[] hitZombieCollider = Physics.OverlapSphere(this.transform.position, 100.0f);
            if (this.tag == "EnemyU")
            {
                foreach (Collider hit in hitCollider)
                {
                    if (hit.tag == "PlayerU")
                    {
                        //Debug.Log("탐지");
                        m_enemy  = hit.gameObject.GetComponent <UnitBox>(); //탐지 한 적개체를 타겟으로 지정
                        m_fDists = Vector3.Distance(this.transform.position, m_enemy.transform.position);
                        if (m_fDists > this.m_sUnit.Range)
                        {
                            this.TargetPosition = m_enemy.transform.position; //적유닛의 위치로이동
                                                                              //Debug.Log("too far");
                            animator.SetBool("walking", true);
                            animator.SetBool("Attacking", false);
                            DetectCheck = 0;
                        }
                        if (m_fDists <= this.m_sUnit.Range + 0.2)          //사거리 안으로 이동시
                        {
                            this.TargetPosition = this.transform.position; //현재위치에 멈춤
                                                                           //Attack();
                                                                           //StartCoroutine("Attack");
                            DetectCheck = 1;
                        }
                    }
                    else if (hit.tag == "PlayerB")
                    {
                        m_TargetofZombie = hit.gameObject.GetComponent <BuildingBox>();
                        m_fDists         = Vector3.Distance(this.transform.position, m_TargetofZombie.transform.position);
                        if (m_fDists > this.m_sUnit.Range)
                        {
                            this.TargetPosition = m_TargetofZombie.transform.position;
                            animator.SetBool("walking", true);
                            animator.SetBool("Attacking", false);
                        }
                        if (m_fDists <= this.m_sUnit.Range + 1)
                        {
                            this.TargetPosition = this.transform.position;
                            DetectCheck         = 2;
                        }
                    }
                    if (hit.tag == "Center")
                    {
                        m_enemys_target = hit.gameObject.GetComponent <Center>();
                        m_fDists        = Vector3.Distance(this.transform.position, m_enemys_target.transform.position);
                        if (m_fDists > this.m_sUnit.Range)
                        {
                            this.TargetPosition = m_enemys_target.transform.position;
                            animator.SetBool("walking", true);
                            animator.SetBool("Attacking", false);
                            //ZombieDeCheck = 0;
                        }
                        if (m_fDists <= this.m_sUnit.Range + 2)
                        {
                            this.TargetPosition = this.transform.position;
                            //ZombieDeCheck = 1;
                            DetectCheck = 3;
                        }
                    }
                }
            }
        }
    }