Exemple #1
0
    /// <summary>
    /// 开启闪烁
    /// </summary>
    /// <param name="flashColor"></param>
    /// <param name="frequency">Flashing frequency (times per second)</param>
    public void FlashingOn(Color flashColor, float frequency)
    {
        bool isbool = MonitorRangeManager.IsBelongtoCurrentDep(depNode);

        if (isbool)
        {
            SetRendererEnable(true);
        }
        Highlighter h          = gameObject.AddMissingComponent <Highlighter>();
        Color       colorStart = flashColor;
        Color       colorEnd   = new Color(colorStart.r, colorStart.g, colorStart.b, 0);

        h.FlashingOn(colorStart, colorEnd, frequency);
    }
    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);
            }
        }
    }
    /// <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);
                }
            }
        }
    }
    public void CreateArea()
    {
        DepNode parentDep = FactoryDepManager.currentDep;//当前区域,要在当前区域下创建子区域(告警区域)

        if (parentDep == null)
        {
            Log.Error("RangeEditWindow.CreateArea", "depnodeT == null");
            return;
        }
        if (parentDep.TopoNode == null)
        {
            Log.Error("RangeEditWindow.CreateArea", "depnodeT.TopoNode == null");
            return;
        }

        if (parentDep.TopoNode.Type == AreaTypes.范围 ||
            parentDep.TopoNode.Type == AreaTypes.分组 ||
            parentDep.TopoNode.Type == AreaTypes.CAD ||
            parentDep.TopoNode.Type == AreaTypes.大楼 ||
            parentDep.TopoNode.Type == AreaTypes.机房
            )
        {
            UGUIMessageBox.Show("不能在该区域类型下创建子区域,类型:" + parentDep.TopoNode.Type + ",请切换到楼层或者厂区。");
            return;
        }

        Log.Info("RangeEditWindow.CreateArea", string.Format("type:{0},name:{1}", parentDep.TopoNode.Type, parentDep.TopoNode.Name));

        PhysicalTopology p = CreateDefaultArea();

        TransformM tm        = parentDep.TopoNode.Transfrom;
        Vector3    centerPos = Vector3.zero;

        if (tm != null)
        {
            Log.Info("RangeEditWindow.CreateArea", string.Format("SX:{0},SY:{1},SZ:{2}", tm.SX, tm.SY, tm.SZ));
            centerPos = new Vector3((float)(tm.SX / 2f), (float)(tm.SY / 2), (float)(tm.SZ / 2));//父物体的尺寸的一半也就是父物体的中心
        }

        //if(RoomFactory.Instance.FactoryType==FactoryTypeEnum.BaoXin)
        //{
        //    pos2D = new Vector3(LocationManager.Instance.axisZero.x,pos2D.y, LocationManager.Instance.axisZero.z);
        //}

        //Vector3 buildPos = Vector3.zero;
        //buildPos = -LocationManager.GetRealSizeVector(pos2D);

        p.ParentId = parentDep.TopoNode.Id;

        //判断是否是楼层或楼层以下级别的,是的话,设置IsRelative="true"
        bool b = MonitorRangeManager.IsBelongtoFloor(parentDep);

        Log.Info("RangeEditWindow.CreateArea", string.Format("IsBelongtoFloor:{0}", b));
        if (b)//如果是楼层及楼层以下级别就设置成相对的
        {
            p.IsRelative           = true;
            p.Transfrom.IsRelative = true;
        }
        else
        {
            p.IsRelative           = false;
            p.Transfrom.IsRelative = false;
            //pos2D = new Vector3((float)tm.X, (float)tm.Y, (float)tm.Z);
            centerPos = Vector3.zero;
            GetRealPos(parentDep, ref centerPos);
        }
        //Vector3 pos = parentDep.monitorRangeObject.transform.position;
        Vector3 realpos = centerPos;

        if (parentDep.TopoNode.Type == AreaTypes.楼层)//宝信项目坐标系偏移,应该也是兼容其他项目的
        {
            realpos.x += parentDep.TopoNode.InitBound.MinX;
            realpos.z += parentDep.TopoNode.InitBound.MinY;
        }

        SetAreaTransform(p, realpos);

        Loom.StartSingleThread(() =>
        {
            Log.Info("RangeEditWindow.CreateArea", string.Format("realpos:{0}", realpos));
            PhysicalTopology newArea = CommunicationObject.Instance.AddMonitorRange(p);//发送信息给服务端
            Loom.DispatchToMainThread(() =>
            {
                try
                {
                    if (newArea != null && newArea.Transfrom != null)
                    {
                        var newT = newArea.Transfrom;
                        Log.Info("RangeEditWindow.CreateArea", string.Format("newPos:({0},{1},{2})", newT.X, newT.Y, newT.Z));

                        RangeNode parentRangeNode = parentDep.monitorRangeObject.rangeNode;//区域的根节点
                        RangeNode newNode         = parentRangeNode.NewNode();

                        MonitorRangeManager.Instance.CreateRangesByRootNode(newArea, newNode);
                        MonitorRangeObject monitorRangeObject = newNode.rangeObject;
                        monitorRangeObject.SetIsNewAdd(true);
                        monitorRangeObject.SetEditEnable(true);
                        monitorRangeObject.SetRendererEnable(true);
                        //monitorRangeObject.SetSelectedUI(true);
                        newNode.rangeObject.gameObject.layer = LayerMask.NameToLayer(Layers.Range);
                        EditorObjectSelection.Instance.ClearSelection(false);
                        EditorObjectSelection.Instance.SetSelectedObjects(new List <GameObject>()
                        {
                            monitorRangeObject.gameObject
                        }, false);
                        //if (depnodeT.ChildNodes == null)
                        //{
                        //    //depnodeT.ChildNodes.Add()
                        RangeController rangeController = RoomFactory.Instance.AddRange(parentDep, newArea);
                        //}
                        Debug.LogError("CreateArea:成功!");
                        rangeController.monitorRangeObject = monitorRangeObject;
                        Show(monitorRangeObject);
                        MonitorRangeManager.Instance.AddRangeToList(monitorRangeObject);
                        //PersonnelTreeManage.Instance.areaDivideTree.RefreshShowAreaDivideTree();
                        PersonnelTreeManage.Instance.areaDivideTree.AddAreaChild(parentDep.TopoNode, newArea);
                        //monitorRangeObject.Focus();
                    }
                    else//else要有
                    {
                        UGUIMessageBox.Show("服务端创建子区域失败!");
                    }
                }
                catch (Exception e)
                {
                    Log.Error("RangeEditWindow.CreateArea", "" + e);
                }
            });
        });
    }
Exemple #5
0
 /// <summary>
 /// 计算区域在XZ平面,到位置点最短距离的点的坐标
 /// </summary>
 /// <param name="point">位置点</param>
 /// <param name="verts">区域底面顶点集合(顺,逆时针都可以)</param>
 /// <returns></returns>
 public Vector2 PointForPointToPolygon(Vector2 point)
 {
     return(MonitorRangeManager.PointForPointToPolygon(point, XZpointList));
 }