Ejemplo n.º 1
0
 public void Init(RoadInfo road)
 {
     point1.Init(road.RoadCheckPoints[0]);
     point2.Init(road.RoadCheckPoints[1]);
     point3.Init(road.RoadCheckPoints[2]);
     point4.Init(road.RoadCheckPoints[3]);
 }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        RoadInfo check = other.GetComponent <RoadInfo>();

        if (check != null && !check.isEntrance())
        {
            setTurnRadius(check.getTurnRadiusDir());
            velocity = transform.InverseTransformDirection(carBody.velocity);
            this.transform.rotation = Quaternion.Euler(0, 0, check.getExitAngle());
            this.transform.position = check.getExitPos();
            velocity.x = Truncate(velocity.x, 2);
            velocity.y = 0;
        }
        if (check != null)
        {
            float speedLimit = check.getSpeedLimit();
            if (velocity.x != speedLimit)
            {
                float newAcc   = (speedLimit - velocity.x) > 0 ? 3 : -3;
                float timeStop = (speedLimit - velocity.x) / newAcc;
                if (varSACoroutine != null)
                {
                    StopCoroutine(varSACoroutine);
                }
                setAcceleration(newAcc);
                varSACoroutine = StopAcceleration(timeStop);
                StartCoroutine(varSACoroutine);
            }
        }
    }
Ejemplo n.º 3
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (tabControl1.SelectedIndex == 2)
     {
         lbxRoad.Items.Clear();
         string   No    = (lbxArea.SelectedItem as SomeData).Value;
         RoadInfo vRoad = new RoadInfo(APConfig.Conn);
         vRoad.Conditions  = " 1=1 ";
         vRoad.Conditions += " AND " + vRoad.getCondition(RoadInfo.ncConditions.AreaNo.ToString(), No);
         if (!string.IsNullOrEmpty(txtRoad.Text))
         {
             vRoad.Conditions += " AND " + vRoad.getCondition(RoadInfo.ncConditions.Name.ToString(), txtRoad.Text);
         }
         vRoad.load();
         List <SomeData> data = new List <SomeData>();
         while (!vRoad.IsEof)
         {
             lbxRoad.Items.Add(vRoad.ROD_NAME);
             vRoad.next();
         }
     }
     else if (tabControl1.SelectedIndex == 3)
     {
         RoadSearch();
     }
 }
Ejemplo n.º 4
0
    private RoadInfo[,] MakeMoveGuideMap(int[,] movableMap, Vector3 GoalPos, BlockCode[,] codeMap)
    {
        RoadInfo[,] moveGuideMap = new RoadInfo[movableMap.GetLength(0), movableMap.GetLength(1)];

        //initialize
        for (int i = 0; i < movableMap.GetLength(0); i++)
        {
            for (int j = 0; j < movableMap.GetLength(1); j++)
            {
                moveGuideMap [i, j].count     = 1000;
                moveGuideMap [i, j].isExist   = movableMap [i, j];
                moveGuideMap [i, j].direction = -1;
                moveGuideMap [i, j].visited   = false;
                moveGuideMap [i, j].blockcode = codeMap [i, j];
            }
        }

        int goalXpos = Mathf.RoundToInt(GoalPos.x);
        int goalYpos = Mathf.RoundToInt(GoalPos.y);

        if (IsAccessible(goalXpos, goalYpos, moveGuideMap) == true)
        {
            moveGuideMap [goalXpos, goalYpos].count     = 0;
            moveGuideMap [goalXpos, goalYpos].direction = 0;
            FindRoadAlg(goalXpos, goalYpos, moveGuideMap);
        }

        return(moveGuideMap);
    }
Ejemplo n.º 5
0
    public void setTargets(RoadInfo firstTarg, RoadInfo[] roads)
    {
        roadTargets = roads;
        float temp = firstTarg.getSpeedLimit() * scale;

        valSlider.value = temp;
        valText.text    = temp.ToString();
    }
Ejemplo n.º 6
0
 private void Pool()
 {
     if (player.transform.position.z < pool.ElementAt(PoolingIndex).Road.transform.position.z)
     {
         RoadInfo info = pool.Dequeue();
         info.Road.transform.position = pool.Last().Locator.transform.position;
         pool.Enqueue(info);
     }
 }
Ejemplo n.º 7
0
        public void Awake()
        {
            RoadInfo json = StreamingAssetAccessor.FromJson <RoadInfo>("Json/Roads/" + roadInfo.name + ".json");

            if (roadInfo != null)
            {
                TRACKS.Add(roadInfo.name, roadInfo);
            }
        }
Ejemplo n.º 8
0
    private void OnTriggerExit2D(Collider2D other)
    {
        RoadInfo check = other.GetComponent <RoadInfo>();

        if (check != null && check.isEntrance())
        {
            setTurnRadius(check.getTurnRadiusDir());
        }
    }
Ejemplo n.º 9
0
    void UpdateDoor(RoadInfo info)
    {
        try
        {
            int childCount = DoorArea.transform.childCount;
            for (int i = 0; i < childCount; i++)
            {
                switch (DungeonGenerator.Instance.CurrentDungeon)
                {
                case StateDef.DungeonType.cove:
                case StateDef.DungeonType.crypts:
                    DoorArea.transform.GetChild(i).GetComponent <UITexture>().mainTexture = (Texture)ResMgr.Instance.LoadAssetFromResource(GetDungeonPath() + string.Format(CommonDefine.DungeonDoor, DungeonGenerator.Instance.CurrentDungeon.ToString()));
                    break;

                default:
                    Debug.logger.LogError("Dungeon", "没有这个类型的门");
                    break;
                }
                RoomInfo neibour = info.GetNeibourRoom(DungeonGenerator.Instance.CurrentDir);

                if (neibour == null)
                {
                    Debug.logger.LogError("Neibour", "road neibour room " + info.NeighbourRooms.Count);
                }

                if (info.BuildDir == DungeonGenerator.Instance.CurrentDir)
                {
                    //如果是跟所造路同方向,那么进门处的坐标就是当前路的起始坐标
                    if (i == 0)
                    {
                        DoorArea.transform.GetChild(i).GetComponent <DoorView>().Init(info.X, info.Y);
                    }
                    else if (i == 1)
                    {
                        DoorArea.transform.GetChild(i).GetComponent <DoorView>().Init(neibour.X, neibour.Y);
                    }
                }
                else
                {
                    //如果是跟所造路反方向,那么进门处的坐标就是当前路的出口坐标
                    if (i == 0)
                    {
                        DoorArea.transform.GetChild(i).GetComponent <DoorView>().Init(neibour.X, neibour.Y);
                    }
                    else if (i == 1)
                    {
                        DoorArea.transform.GetChild(i).GetComponent <DoorView>().Init(info.X, info.Y);
                    }
                }
            }
        }
        catch (System.Exception ex)
        {
            Debug.logger.Log(ex.Message);
        }
    }
Ejemplo n.º 10
0
    //
    // Inheritance Methods
    //

    protected override void OnComponentRegistrationFinished()
    {
        base.OnComponentRegistrationFinished();

        networkLayerName = "Network"; //-

        roads = new RoadInfo[maxRoadCount];
        for (int i = 0; i < maxRoadCount; i++)
        {
            var road = new RoadInfo
            {
                mapLayer  = null,
                uiElement = Instantiate(roadTogglePrefab, roadsList, false),
            };

            road.uiElement.toggle.onValueChanged.AddListener((isOn) => OnRoadToggleChanged(road, isOn));
            road.uiElement.button.onClick.AddListener(() => RemoveRoad(road));
            ResetRoadUI(road.uiElement);

            roads[i] = road;
        }

        // Get Components
        dataLayers  = ComponentManager.Instance.Get <DataLayers>();
        siteBrowser = ComponentManager.Instance.Get <SiteBrowser>();

        // UI Listeners - Main Panel
        layerDropdown.onValueChanged.AddListener(OnSelectedLayerChanged);
        startSingleButton.onValueChanged.AddListener(OnToggleStartSingle);
        startMultiButton.onValueChanged.AddListener(OnToggleStartMulti);
        clearButton.onClick.AddListener(OnClearClicked);
        showRoadsToggle.onValueChanged.AddListener(OnToggleShowRoads);
        showIsochronToggle.onValueChanged.AddListener(OnToggleShowIsochrons);
        showStartPtToggle.onValueChanged.AddListener(OnToggleShowStartPts);
        editSpeedToggle.onValueChanged.AddListener(OnEditSpeedToggleChanged);
        newRoadButton.onClick.AddListener(OnNewRoadClick);
#if !UNITY_WEBGL
        networkDisruptionAnalysisToggle.onValueChanged.AddListener(OnNetworkDisruptionAnalysisToggleChanged);
#endif
        traveTimeSlider.onValueChanged.AddListener(OnTravelTimeSliderChanged);

        // UI Listeners - New Road Panel
        finishNewRoadButton.onClick.AddListener(OnFinishNewRoadClick);
        highwayButton.onValueChanged.AddListener((isOn) => OnRoadClassificationChange(highwayButton));
        primaryButton.onValueChanged.AddListener((isOn) => OnRoadClassificationChange(primaryButton));
        secondaryButton.onValueChanged.AddListener((isOn) => OnRoadClassificationChange(secondaryButton));
        otherButton.onValueChanged.AddListener((isOn) => OnRoadClassificationChange(otherButton));
        createRoadToggle.onValueChanged.AddListener(OnCreateRoadChanged);
        removeRoadToggle.onValueChanged.AddListener(OnRemoveRoadChanged);

#if !UNITY_WEBGL
        // Initialize notification title and message
        NDAAnalysisCompletedNotification.Init("Network Data Analysis", "Analysis Completed!");
        NDASetupCompletedNotification.Init("Network Data Analysis", "Setup Completed!");
#endif
    }
Ejemplo n.º 11
0
    void SwitchRoad(sc_character _char, RoadInfo targetRoad)
    {
        int     originSort = _char.GetNowSortOrder();
        Vector3 tmpVec;

        tmpVec   = _char.transform.position;
        tmpVec.z = targetRoad.zValue;
        _char.transform.position = tmpVec;
        _char.SetSortingOrder(originSort % 10 + targetRoad.spriteSort, false);
    }
Ejemplo n.º 12
0
 public void hoverGroup(RoadInfo caller)
 {
     for (int x = 0; x < groupMembers.Length; x++)
     {
         if (groupMembers[x] != null && groupMembers[x] != caller)
         {
             groupMembers[x].hoverGroup(this);
             groupMembers[x].hovering = true;
         }
     }
 }
Ejemplo n.º 13
0
        public RoadInfo GetRoadStatus(string roadId)
        {
            var    roadInfo       = new RoadInfo();
            var    httpClient     = _httpServiceRepository.GetHttpClient();
            string query          = _httpServiceRepository.GetQueryString($"Road/{roadId}");
            string responseString = string.Empty;

            try
            {
                HttpResponseMessage response = httpClient.GetAsync(query).Result;

                if (response.IsSuccessStatusCode)
                {
                    responseString = response.Content.ReadAsStringAsync().Result;
                    var successStatus = JsonConvert.DeserializeObject <SuccessStatus[]>(responseString);

                    if (successStatus != null && successStatus.Length > 0)
                    {
                        roadInfo.DisplayName               = successStatus[0].DisplayName;
                        roadInfo.StatusSeverity            = successStatus[0].StatusSeverity;
                        roadInfo.StatusSeverityDescription = successStatus[0].StatusSeverityDescription;
                    }
                    roadInfo.Valid = true;
                }
                else
                {
                    responseString = response.Content.ReadAsStringAsync().Result;
                    var failureStatus = JsonConvert.DeserializeObject <FailureStatus>(responseString);
                    if (failureStatus != null)
                    {
                        roadInfo.FailureMessage = $"{roadId} is not a valid road";
                    }

                    roadInfo.Valid = false;
                }
            }
            catch (Exception ex)
            {
                roadInfo.Valid = false;

                //value in 'responseString' will be available when there is deserializatoin error due to unexpected response from server
                //eg: for invalid authentication keys
                if (!string.IsNullOrEmpty(responseString))
                {
                    roadInfo.FailureMessage = responseString;
                }
                else
                {
                    roadInfo.FailureMessage = ex.Message + '\n' + ex.StackTrace;
                }
            }

            return(roadInfo);
        }
Ejemplo n.º 14
0
    /// <summary>
    /// 在指定的x,y和dir下创建一条路
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <param name="dir"></param>
    /// <returns>成功返回true,失败返回false</returns>
    private RoadInfo MakeRoad(int x, int y, CommonDefine.MoveDirection dir)
    {
        RoadInfo road = new RoadInfo();

        road.X        = x;
        road.Y        = y;
        road.BuildDir = dir;

        m_roads.Add(road);
        return(road);
    }
Ejemplo n.º 15
0
 public void RefreshRoad(RoadInfo info)
 {
     m_currentRoad = info;
     UpdateBackground();
     UpdateRoom();
     UpdateMiddle();
     UpdateWall(info);
     UpdateDoor(info);
     UpdateCheckPoints(info);
     ResetPositions();
 }
Ejemplo n.º 16
0
    public void AddNeibourRoads(RoadInfo road)
    {
        if (m_neibourRoads.Count == 0)
        {
            m_neibourRoads.Add(road);
            return;
        }

        foreach (RoadInfo r in m_neibourRoads)
        {
            //方向相同,坐标一样,表示已经存在
            if (r.X == road.X && r.Y == road.Y && r.BuildDir == road.BuildDir)
            {
                return;
            }

            //方向相反,坐标经过转换如果也一样,表示已存在
            if (Mathf.Abs(r.BuildDir - road.BuildDir) == 2)
            {
                int tmpX = -1;
                int tmpY = -1;
                switch (r.BuildDir)
                {
                case CommonDefine.MoveDirection.East:
                    tmpX = r.X + 1;
                    tmpY = r.Y;
                    break;

                case CommonDefine.MoveDirection.North:
                    tmpX = r.X;
                    tmpY = r.Y + 1;
                    break;

                case CommonDefine.MoveDirection.South:
                    tmpX = r.X;
                    tmpY = r.Y - 1;
                    break;

                case CommonDefine.MoveDirection.West:
                    tmpX = r.X - 1;
                    tmpY = r.Y;
                    break;
                }

                if (tmpX == road.X && tmpY == road.Y)
                {
                    return;
                }
            }
        }

        m_neibourRoads.Add(road);
    }
Ejemplo n.º 17
0
        private void MoveAction(int obj)
        {
            List <int> routeList = new List <int>();//记录下经过的路径

            routeList.Add(CurrentPlayer.Location.Index);

            Random ran  = new Random();
            int    step = ran.Next(1, 7);

            //执行Move
            int roadIndex = CurrentPlayer.RoadIndex;
            int direction = CurrentPlayer.Direction;
            var location  = CurrentPlayer.Location;

            for (int i = 0; i < step; i++)
            {
                Location tempLocation  = null;
                int      tempDirection = direction;
                int      tempRoadIndex = roadIndex;

                //同一条线路往前走
                RoadInfo sameRoad = location.RoadInfos.First(p => p.RoadIndex == roadIndex);
                tempLocation = direction == 1 ? sameRoad.ForwardLocation : sameRoad.BackwardLocation;
                //三岔路时,随机走(必须是三岔路,即另一条路的两个方向都必须是有路的)
                if (tempLocation == null)
                {
                    tempDirection = ran.Next(2) == 0 ? -1 : 1;
                    RoadInfo otherRoad = location.RoadInfos.First(p => p.RoadIndex != roadIndex);
                    tempRoadIndex = otherRoad.RoadIndex;
                    tempLocation  = tempDirection == 1 ? otherRoad.ForwardLocation : otherRoad.BackwardLocation;
                    //死胡同时
                    if (tempLocation == null)
                    {
                        tempRoadIndex = roadIndex;
                        tempDirection = -direction;
                        tempLocation  = tempDirection == 1 ? sameRoad.ForwardLocation : sameRoad.BackwardLocation;
                    }
                }

                direction = tempDirection;
                location  = tempLocation;
                roadIndex = tempRoadIndex;

                routeList.Add(location.Index);
            }

            CurrentPlayer.RoadIndex = roadIndex;
            CurrentPlayer.Direction = direction;
            CurrentPlayer.Location  = location;

            //UI动画
            MoveEvent?.Invoke(routeList);
        }
Ejemplo n.º 18
0
    RoadInfo CreateRoadInfoForVehicle(Vehicle vehicle)
    {
        var   info     = new RoadInfo();
        float distance = 0f;
        var   vehiclePathEnumerator = vehicle.path.GetEnumerator();

        while (vehiclePathEnumerator.Current != vehicle.intermediateTarget.Current)
        {
            vehiclePathEnumerator.MoveNext();
        }

        float position = vehicle.distanceOnCurrentRoadSegment;

        var currentNode = this;

        do
        {
            var nearestInFront =
                currentNode.FindNearestVehicleInFront(position, vehiclePathEnumerator.Current);

            position = 0;

            if (nearestInFront == null)
            {
                distance += currentNode.consequent.Find(c => c.node == vehiclePathEnumerator.Current).path.length;
                if (vehiclePathEnumerator.Current.isRedLightOn)
                {
                    info.distanceToNearestObstacle = distance - vehicle.distanceOnCurrentRoadSegment;
                    info.nearestObstacleVelocity   = 0;
                    break;
                }

                currentNode = vehiclePathEnumerator.Current;
            }
            else
            {
                distance += nearestInFront.distanceOnCurrentRoadSegment;
                info.distanceToNearestObstacle = distance - vehicle.distanceOnCurrentRoadSegment;
                info.nearestObstacleVelocity   = nearestInFront.velocity;
                break;
            }
        } while (vehiclePathEnumerator.MoveNext());

        if (info.distanceToNearestObstacle == float.MaxValue)
        {
            info.distanceToNearestObstacle = distance;
            info.nearestObstacleVelocity   = 0;
        }

        return(info);
    }
Ejemplo n.º 19
0
    public List <RoadInfo> getGroupMembers(RoadInfo caller)
    {
        List <RoadInfo> temp = new List <RoadInfo>();

        temp.Add(this);
        for (int x = 0; x < groupMembers.Length; x++)
        {
            if (groupMembers[x] != null && groupMembers[x] != caller)
            {
                temp.Add(groupMembers[x]);
                temp.AddRange(groupMembers[x].getGroupMembers(this));
                groupMembers[x].selectRoad();
            }
        }
        return(temp);
    }
Ejemplo n.º 20
0
        public async Task <ApiResult> Create(string location, string state)
        {
            RoadInfo road = new RoadInfo
            {
                Location    = location,
                ReportTime  = DateTime.Now,
                State       = state,
                CounselorId = Convert.ToInt32(this.User.FindFirst("Id").Value)
            };
            bool b = await _iRoadInfoService.CreateAsync(road);

            if (!b)
            {
                return(ApiResultHelper.Error("添加失败"));
            }
            return(ApiResultHelper.Success(road));
        }
Ejemplo n.º 21
0
 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabControl1.SelectedIndex == 1 && lbxCity.Items.Count > 0)
     {
         lbxArea.DataSource = null;
         string   No    = (lbxCity.SelectedItem as SomeData).Value;
         AreaInfo vArea = new AreaInfo(APConfig.Conn);
         vArea.Conditions = vArea.getCondition(AreaInfo.ncConditions.CityNo.ToString(), No);
         vArea.load();
         List <SomeData> data = new List <SomeData>();
         while (!vArea.IsEof)
         {
             data.Add(new SomeData()
             {
                 Value = vArea.ARA_NO, Text = vArea.ARA_NAME
             });
             vArea.next();
         }
         lbxArea.DisplayMember = "Text";
         lbxArea.DataSource    = data;
     }
     else if (tabControl1.SelectedIndex == 2 && lbxArea.Items.Count > 0)
     {
         lbxRoad.Items.Clear();
         string   No    = (lbxArea.SelectedItem as SomeData).Value;
         RoadInfo vRoad = new RoadInfo(APConfig.Conn);
         vRoad.Conditions  = " 1=1 ";
         vRoad.Conditions += " AND " + vRoad.getCondition(RoadInfo.ncConditions.AreaNo.ToString(), No);
         if (!string.IsNullOrEmpty(txtRoad.Text))
         {
             vRoad.Conditions += " AND " + vRoad.getCondition(RoadInfo.ncConditions.Name.ToString(), txtRoad.Text);
         }
         vRoad.load();
         List <SomeData> data = new List <SomeData>();
         while (!vRoad.IsEof)
         {
             lbxRoad.Items.Add(vRoad.ROD_NAME);
             vRoad.next();
         }
     }
     else if (tabControl1.SelectedIndex == 3)
     {
         RoadSearch();
     }
 }
Ejemplo n.º 22
0
    /// <summary>
    /// 离开此房间,去往下一个房间
    /// </summary>
    /// <param name="targetRoom"></param>
    public void OutRoom(RoomInfo targetRoom)
    {
        //在路上时不能操纵去哪个房间
        if (!IsInRoom)
        {
            return;
        }

        //只能去隔壁房间,不能一下子去很远的房子
        RoomInfo curRoom  = GetRoomByXY(CurrentX, CurrentY);
        int      distance = Mathf.Abs(targetRoom.X - curRoom.X) + Mathf.Abs(targetRoom.Y - curRoom.Y);

        if (distance != 1)
        {
            return;
        }

        //判断去的房间的方向,从而取得去的路
        IsInRoom = false;
        if (targetRoom.X > CurrentX)
        {
            CurrentDir = CommonDefine.MoveDirection.East;
        }
        else if (targetRoom.Y > CurrentY)
        {
            CurrentDir = CommonDefine.MoveDirection.North;
        }
        else if (targetRoom.X < CurrentX)
        {
            CurrentDir = CommonDefine.MoveDirection.West;
        }
        else if (targetRoom.Y < CurrentY)
        {
            CurrentDir = CommonDefine.MoveDirection.South;
        }
        else
        {
            CurrentDir = CommonDefine.MoveDirection.None;
        }

        RoadInfo currentRoad = GetRoadByXYAndDir(CurrentX, CurrentY, CurrentDir);

        //通知更新UI
        OnPropertyChanged <RoadInfo>(ROOMOUT, currentRoad);
    }
Ejemplo n.º 23
0
    /// <summary>
    /// 递归创建随机地图
    /// </summary>
    /// <param name="previousX"></param>
    /// <param name="previousY"></param>
    /// <returns></returns>
    private bool CreateMap(int previousX, int previousY)
    {
        for (int i = 0; i < 30; i++)
        {
            if (CheckCreateMapFinished())
            {
                return(true);
            }
            CommonDefine.MoveDirection dir = (CommonDefine.MoveDirection)(Random.Range(0, 100) % 4);
            int tmpX = previousX;
            int tmpY = previousY;
            switch (dir)
            {
            case CommonDefine.MoveDirection.East:
                tmpX += 1;
                break;

            case CommonDefine.MoveDirection.South:
                tmpY -= 1;
                break;

            case CommonDefine.MoveDirection.West:
                tmpX -= 1;
                break;

            case CommonDefine.MoveDirection.North:
                tmpY += 1;
                break;
            }

            if (TryMakeRoom(tmpX, tmpY))
            {
                RoomInfo prevRoom = GetRoomByXY(previousX, previousY);
                RoadInfo road     = MakeRoad(previousX, previousY, dir);
                prevRoom.AddNeibourRoads(road);
                road.AddNeibourRoom(prevRoom);
                RoomInfo curRoom = MakeRoom(tmpX, tmpY);
                curRoom.AddNeibourRoads(road);
                road.AddNeibourRoom(curRoom);
                CreateMap(tmpX, tmpY);
            }
        }

        return(false);
    }
Ejemplo n.º 24
0
        protected override void OnUpdate()
        {
            if (Parameters.RoadNetworkDescription == null)
            {
                return;
            }
            var geometryList = new NativeList <Geometry>(Allocator.TempJob);
//            var roads = RoadNetworkDescription.AllRoads.Values.Where(r => r.junction == "-1").ToArray();
            var roads     = Parameters.RoadNetworkDescription.AllRoads.ToArray();
            var roadInfos = new NativeArray <RoadInfo>(roads.Length, Allocator.TempJob);

            for (var i = 0; i < roads.Length; i++)
            {
                var road  = roads[i];
                var start = geometryList.Length;
                foreach (var geometry in road.geometry)
                {
                    geometryList.Add(geometry);
                }

                roadInfos[i] = new RoadInfo
                {
                    GeometryStartIndex = start,
                    GeometryCount      = road.geometry.Count,
                    Name = new NativeString512(road.roadId)
                };
            }

            using (var entityCommandBuffer = new EntityCommandBuffer(Allocator.TempJob))
            {
                new CreateLanesJob
                {
                    CommandBuffer     = entityCommandBuffer.ToConcurrent(),
                    Geometries        = geometryList,
                    RoadLaneArchetype = RoadLaneArchetype,
                    SplitScheme       = Parameters.SplitScheme,
                    Roads             = roadInfos
                }.Schedule(roads.Length, 1).Complete();
                entityCommandBuffer.Playback(this.EntityManager);
            }
            geometryList.Dispose();
            roadInfos.Dispose();
        }
Ejemplo n.º 25
0
        public void TestMethod1()
        {
            string   name = "road1";
            RoadInfo ri   = new RoadInfo(name);

            Assert.IsTrue(ri.RoadName == name);

            Assert.IsTrue(ri.NextRoadNameList.Count == 0);
            Assert.IsTrue(ri.PointList.Count == 0);

            ri.AddPoint(new GPSPoint(1.1, 2.1));
            ri.AddPoint(new GPSPoint(1.2, 2.2));

            Assert.IsTrue(ri.PointList.Count == 2);

            ri.AddNextRoadName("road2");
            ri.AddNextRoadName("road3");

            Assert.IsTrue(ri.NextRoadNameList.Count == 2);
        }
Ejemplo n.º 26
0
    void UpdateWall(RoadInfo info)
    {
        int childCount = WallArea.transform.childCount;

        for (int i = 0; i < childCount; i++)
        {
            switch (DungeonGenerator.Instance.CurrentDungeon)
            {
            case StateDef.DungeonType.cove:
            case StateDef.DungeonType.crypts:
                WallArea.transform.GetChild(i).GetComponent <UITexture>().mainTexture = (Texture)ResMgr.Instance.LoadAssetFromResource(GetDungeonPath() + string.Format(CommonDefine.DungeonWall, DungeonGenerator.Instance.CurrentDungeon.ToString(),
                                                                                                                                                                        DungeonGenerator.Instance.CurrentDir == info.BuildDir ? info.WallIDs[i].ToString("d2") : info.WallIDs[info.WallIDs.Count - 1 - i].ToString("d2")));
                break;

            default:
                Debug.logger.LogError("Dungeon", "没有这个类型的Wall " + i.ToString());
                break;
            }
        }
    }
Ejemplo n.º 27
0
    void UpdateCheckPoints(RoadInfo info)
    {
        int childCount = CheckPointArea.transform.childCount;

        for (int i = 0; i < childCount; i++)
        {
            DungeonPoint point = DungeonGenerator.Instance.CurrentDir == info.BuildDir ? info.RoadCheckPoints[i]
                : info.RoadCheckPoints[info.RoadCheckPoints.Count - 1 - i];
            if (point.CheckPointType != CommonDefine.CheckPointType.None)
            {
                CheckPointArea.transform.GetChild(i).GetComponent <UITexture>().mainTexture = (Texture)ResMgr.Instance.LoadAssetFromResource(point.DrawTexture());
                CheckPointArea.transform.GetChild(i).GetComponent <CheckPointView>().UpdateDungeonPoint(point);
            }
            else
            {
                CheckPointArea.transform.GetChild(i).GetComponent <UITexture>().mainTexture = null;
                CheckPointArea.transform.GetChild(i).GetComponent <CheckPointView>().UpdateDungeonPoint(null);
            }
        }
    }
Ejemplo n.º 28
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.Unicode;

            var config = ConfigurationFactory.ParseString(File.ReadAllText("akkaconfig.hocon"));

            using (ActorSystem system = ActorSystem.Create("TrafficControlSystem", config))
            {
                var roadInfo            = new RoadInfo("A2", 10, 100, 5);
                var trafficControlProps = Props.Create <TrafficControlActor>(roadInfo)
                                          .WithRouter(new RoundRobinPool(3));
                var trafficControlActor = system.ActorOf(trafficControlProps, "traffic-control");

                var entryCamActor1 = system.ActorOf <EntryCamActor>("entrycam1");
                var entryCamActor2 = system.ActorOf <EntryCamActor>("entrycam2");
                var entryCamActor3 = system.ActorOf <EntryCamActor>("entrycam3");

                var exitCamActor1 = system.ActorOf <ExitCamActor>("exitcam1");
                var exitCamActor2 = system.ActorOf <ExitCamActor>("exitcam2");
                var exitCamActor3 = system.ActorOf <ExitCamActor>("exitcam3");

                var cjcaActor = system.ActorOf <CJCAActor>("cjcaactor");
                //var cjcaActor = system.ActorOf<PersistentCJCAActor>("cjcaactor");

                var simulationProps = Props.Create <SimulationActor>().WithRouter(new BroadcastPool(3));
                var simulationActor = system.ActorOf(simulationProps);

                Console.WriteLine("Actorsystem and actor created. Press any key to start simulation\n");
                Console.ReadKey(true);

                simulationActor.Tell(new StartSimulation(15));

                Console.ReadKey(true);
                system.Terminate();

                System.Console.WriteLine("Stopped. Press any key to exit.");
                Console.ReadKey(true);
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 货柜信息
        /// </summary>
        public BoxRpt BoxInfo(int box)
        {
            BoxRpt boxRpt = new BoxRpt();

            //机器设备状态
            BoxStatus boxStatus = base.QueryBoxStatus(box);

            boxRpt.BoxStatus += string.Format("机器设备状态:\r\n{0}\r\n", boxStatus.ToString());
            //制冷压缩机/风机/照明/除雾/广告灯/工控机等设备状态
            EquipmentsStatus equipmentsStatus = base.QueryEquipmentsStatus(box);

            boxRpt.BoxStatus += string.Format("制冷压缩机/风机/照明/除雾/广告灯/工控机等设备状态:\r\n{0}\r\n", equipmentsStatus.ToString());

            //制冷压缩机/照明/除雾/广告灯/工控机等设备控制策略参数
            EquipmentInfo equipmentAll = base.QueryEquipmentAll(box);

            boxRpt.BoxSetup += equipmentAll.ToString();

            //货道信息
            RoadModelCollection roadModelCollection = JMBoxConfigUtil.GetRoadsConfig(box);

            foreach (RoadModel road in roadModelCollection.RoadList)
            {
                RoadInfo roadInfo = base.QueryRoadInfo(box, road.Floor, road.Num);

                RoadRpt roadRpt = new RoadRpt();
                roadRpt.Floor    = road.Floor;
                roadRpt.Num      = road.Num;
                roadRpt.IsOK     = roadInfo.IsOK;
                roadRpt.ErrorMsg = roadInfo.ErrorMsg;
                roadRpt.Price    = roadInfo.Price;

                boxRpt.RoadCollection.RoadList.Add(roadRpt);
            }
            boxRpt.RoadCollection.FloorCount = roadModelCollection.FloorCount;

            return(boxRpt);
        }
Ejemplo n.º 30
0
    private void RemoveRoad(RoadInfo road)
    {
        activeRoadLayers.Remove(road.mapLayer);

        // Delete the map layer
        toolLayers.Remove(road.mapLayer);
        Destroy(road.mapLayer);
        road.mapLayer = null;

        ResetRoadUI(road.uiElement);

        roadCount--;

        if (roadCount == 0)
        {
            SetAction(Action.None);
        }
        else
        {
            // Reorder UI elements
            int index = road.uiElement.transform.GetSiblingIndex();
            if (index < roadCount)
            {
                // Move deleted road UI element to last position
                int lastIndex = roads.Length - 1;
                road.uiElement.transform.SetSiblingIndex(lastIndex);

                // Swap road with last one
                var temp = roads[lastIndex];
                roads[lastIndex] = roads[index];
                roads[index]     = temp;
            }
        }

        createRoadToggle.interactable = true;

        UpdateReachabilityGrid();
    }
 public void AddRoad(int roadID, int phaseNo, int curGreen, int curRed, double avgArriVehicle_min, double avgDepartureRate_min,double avgQueue, double avgWaitingRate)
 {
     RoadInfo newRoadInfo = new RoadInfo(roadID, phaseNo, curGreen, curRed, avgArriVehicle_min,avgDepartureRate_min,avgQueue, avgWaitingRate);
     this.roadInfoList.Add(newRoadInfo);
 }