예제 #1
0
    public void StopNavAgent(HistoryManController man)
    {
        LocationHistoryPath_M path_m = man.GetComponent <LocationHistoryPath_M>();

        if (path_m == null)
        {
            Log.Error("PathFindingManager.StopNavAgent path_m == null");
            return;
        }
        if (path_m.navAgentFollow)//有跟谁人员
        {
            man.EnableRenderer();

            var target = man.gameObject;
            path_m.navAgentFollow.gameObject.SetActive(false);

            var uiFollowTarget      = UGUIFollowTarget.CreateTitleTag(target, new Vector3(0, 0.1f, 0));
            UGUIFollowTarget follow = man.followUI.GetComponent <UGUIFollowTarget>();
            follow.Target = uiFollowTarget;

            CameraSceneManager.Instance.FocusTarget(target.transform);

            target.HighlightOn();

            path_m.enableMoveByController = true;

            path_m.heightOffset = 0.85f;

            LocationHistoryManager.Instance.isSetPersonHeightByRay = false;//还是false

            man.followTarget = this.transform;
            man.ResetTitleTag();
            man.followTitle = man.titleTag;
        }
    }
예제 #2
0
 /// <summary>
 /// 添加历史轨迹路线
 /// </summary>
 public void Add(LocationHistoryPath_M path)
 {
     if (!Items.Contains(path))
     {
         Items.Add(path);
     }
 }
예제 #3
0
    public void StartNavAgent(HistoryManController man)
    {
        Log.Info("PathFindingManager.StartNavAgent");
        if (man == null)
        {
            Log.Error("PathFindingManager.StartNavAgent man == null");
            return;
        }
        LocationHistoryPath_M path_m = man.GetComponent <LocationHistoryPath_M>();

        if (path_m == null)
        {
            Log.Error("PathFindingManager.StartNavAgent path_m == null");
            return;
        }
        if (path_m.navAgentFollow)//有跟谁人员
        {
            path_m.navAgentFollow.MaxDistance = MaxDistance;
            path_m.navAgentFollow.enableJump  = enableJump;

            if (ShowOriginalPersonWhenEditor)
            {
#if UNITY_EDITOR
                man.gameObject.SetTransparent(0.5f);
#else
                //man.DisableRenderer();
                man.DestroyRenderer();
#endif
            }
            else
            {
                //man.DisableRenderer();
                man.DestroyRenderer();//直接删除不需要再出现了
            }


            var target = path_m.navAgentFollow.gameObject;
            target.SetActive(true);

            var uiFollowTarget      = UGUIFollowTarget.CreateTitleTag(target, new Vector3(0, 0.1f, 0));
            UGUIFollowTarget follow = man.followUI.GetComponent <UGUIFollowTarget>();
            follow.Target = uiFollowTarget;

            CameraSceneManager.Instance.FocusTarget(target.transform);

            target.HighlightOn();

            path_m.enableMoveByController = false;

            path_m.heightOffset = 0.55f;

            LocationHistoryManager.Instance.isSetPersonHeightByRay = false;

            man.followTarget = target.transform;
            man.followTitle  = uiFollowTarget.transform;
            man.ChangeTitleTag(uiFollowTarget);
        }
        //AroundAlignCamera.
    }
예제 #4
0
 private void EnableArcReactor_Trail(GameObject obj)
 {
     if (ArcManager.Instance)
     {
         var parent = obj.transform;
         LocationHistoryPath_M path_m = obj.GetComponent <LocationHistoryPath_M>();
         if (path_m != null && path_m.navAgentFollow)
         {
             parent = path_m.navAgentFollow.transform;
         }
         ArcManager.Instance.EnableTrail(parent);
     }
 }
    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);
            }
        }
    }
    public LocationHistoryPath_M ShowLocationHistoryPath_M(PathInfo pathInfo)
    {
        var        personnelT = pathInfo.personnelT;
        GameObject o          = CreatePersonObject(personnelT);

        if (pathInfo.posList.Count > 0)
        {
            o.transform.position = pathInfo.posList[0].Vec;
        }
        LocationHistoryPath_M path = o.AddComponent <LocationHistoryPath_M>();

        o.name = personnelT.Name + "(" + personnelT.Tag.Code + ")";
        path.Init(pathInfo);
        o.SetActive(true);

        SetNavAgent(path);
        return(path);
    }
    Position firstPoint = null;//第一个点的位置 自动移动进度条到该点

    /// <summary>
    /// 显示某个标签的历史数据
    /// </summary>
    /// <param name="code"></param>
    public void ShowHistoryData()
    {
        if (isLoadDataSuccessed)
        {
            return;
        }
        //LocationManager.Instance.ClearHistoryPaths();
        //string code = "0002";

        List <HistoryPersonUIItem> historyPersonUIItems = personsGrid.GetComponentsInChildren <HistoryPersonUIItem>().ToList();

        DateTime end   = GetEndTime();
        DateTime start = GetStartTime();
        List <List <Position> > psList = new List <List <Position> >();

        personnel_Points = new Dictionary <Personnel, List <Position> >();
        //List<Position> ps = new List<Position>();
        List <LocationHistoryPath_M> paths = new List <LocationHistoryPath_M>();

        progressbarLoadValue = 0;

        List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode);

        Loom.StartSingleThread(() =>
        {
            firstPoint = null;
            foreach (Personnel p in currentPersonnels)
            {
                List <Position> ps = GetHistoryData(p.Id, topoNodeIds, start, end, 1440f);
                psList.Add(ps);
                if (personnel_Points.ContainsKey(p))
                {
                    personnel_Points[p] = ps;
                }
                else
                {
                    personnel_Points.Add(p, ps);
                }
                if (ps != null && ps.Count > 0)
                {
                    Position fps = ps[0];
                    if (firstPoint == null)
                    {
                        firstPoint = fps;
                    }
                    else
                    {
                        if (fps.Time < firstPoint.Time)
                        {
                            firstPoint = fps;
                        }
                    }
                }
            }
            Debug.Log("StartSingleThread1");
            Loom.DispatchToMainThread(() =>
            {
                ProgressbarLoad.Instance.Show(1);
                ProgressbarLoad.Instance.Hide();
                int k = 0;
                foreach (Personnel p in personnel_Points.Keys)
                {
                    List <Position> ps = personnel_Points[p];
                    Debug.LogError("点数:" + ps.Count);
                    if (ps.Count < 2)
                    {
                        continue;
                    }
                    var posInfoList = new PositionInfoList();
                    for (int i = 0; i < ps.Count; i++)
                    {
                        var posInfo = new PositionInfo(ps[i], start);
                        posInfoList.Add(posInfo);
                    }

                    Color colorT             = colors[k % colors.Count];
                    HistoryPersonUIItem item = historyPersonUIItems.Find((i) => i.personnel.Id == p.Id);
                    if (item != null)
                    {
                        colorT = item.color;
                    }

                    PathInfo pathInfo   = new PathInfo();
                    pathInfo.personnelT = p;
                    pathInfo.color      = colorT;
                    pathInfo.posList    = posInfoList;
                    pathInfo.timeLength = timeLength;

                    LocationHistoryPath_M histoyObj = LocationHistoryManager.Instance.ShowLocationHistoryPath_M(pathInfo);
                    //histoyObj.InitData(timeLength, timelist);
                    HistoryManController historyManController = histoyObj.gameObject.AddComponent <HistoryManController>();
                    histoyObj.historyManController            = historyManController;
                    historyManController.Init(colorT, histoyObj);
                    PersonAnimationController personAnimationController = histoyObj.gameObject.GetComponent <PersonAnimationController>();
                    personAnimationController.DoMove();
                    Debug.Log("StartSingleThread2");
                    k++;
                }
            });

            //Debug.Log("StartSingleThread3");
            Loom.DispatchToMainThread(() =>
            {
                isLoadDataSuccessed = true;
                //timeStart = Time.time;
                timeSum = 0;
                Debug.Log("StartSingleThread3");
                if (firstPoint != null)
                {
                    DateTime t = LocationManager.GetTimestampToDateTime(firstPoint.Time);
                    Debug.Log(firstPoint.Time);
                    timeSum = t.Hour * 3600 + t.Minute * 60 + t.Second - slider.ValueMin * 3600;
                    Debug.Log(timeSum);
                }
            });
        });
    }
 /// <summary>
 /// 添加历史轨迹路线
 /// </summary>
 public void AddHistoryPath_M(LocationHistoryPath_M path)
 {
     PathList.Add(path);
 }
예제 #9
0
    public void SetNavAgent(LocationHistoryPathBase o)
    {
        Log.Error("PathFindingManager", "SetNavAgent");
        if (SystemSettingHelper.locationSetting.EnableNavMesh == false)
        {
            return;                                                            //不启用NavMesh
        }
        if (o == null)
        {
            return;
        }
        if (useNavAgent)
        {
            var agent = o.gameObject.AddComponent <NavAgentController>();//往原来物体上加NavAgentController来控制物体移动
            o.navAgent = agent;
        }
        else if (useFollowNavAgent)
        {
            //if (FollowAgent)
            {
                if (o.navAgentFollow == null)
                {
                    if (o == null)
                    {
                        Log.Error("PathFindingManager.SetNavAgent", "o == null");
                        return;
                    }
                    if (o.personnel == null)
                    {
                        Log.Error("PathFindingManager.SetNavAgent", "o.personnel == null");
                        return;
                    }

                    var prefab = TargetPrefabs[o.personnel.TargetType];
                    var obj    = GameObject.Instantiate <GameObject>(prefab, o.transform.position, Quaternion.identity, o.CreatePathParent());
                    //创建一个Agent跟随,这里要直接设置position,因为不设置的话,NavAgent必须在NavMesh上面初始化。
                    var agent = obj.AddMissingComponent <NavAgentFollowPerson>();

                    agent.name             = o.gameObject.name + "(Nav)";
                    agent.gameObject.layer = o.gameObject.layer;
                    agent.gameObject.tag   = o.gameObject.tag;

                    //agent.transform.position = o.transform.position;
                    //agent.transform.parent = o.CreatePathParent();
                    o.navAgentFollow = agent;
                    agent.SetFollowTarget(o.transform);

                    agent.gameObject.SetActive(false);

                    if (o is LocationHistoryPath_M)
                    {
                        LocationHistoryPath_M path = o as LocationHistoryPath_M;
                        if (path.historyPathDrawing != null)
                        {
                            path.historyPathDrawing.target = agent.transform;//绘图目标修改
                        }
                    }
                }
            }
        }
        else
        {
            //不使用NavMesh
        }
    }