Пример #1
0
        public void SetRoute(ushort segmentId, string routePrefix, string route, string oldRouteStr = null)
        {
            RouteContainer routeContainer = null;

            if (!String.IsNullOrEmpty(route))
            {
                if (m_routeDict.ContainsKey(segmentId))
                {
                    routeContainer = m_routeDict[segmentId];
                    routeContainer.m_routePrefix = routePrefix;
                    routeContainer.m_route       = route;
                }
                else
                {
                    routeContainer = new RouteContainer(segmentId, routePrefix, route);
                }

                m_routeDict[segmentId] = routeContainer;

                if (routeContainer.m_shieldObject == null)
                {
                    routeContainer.m_shieldObject = new GameObject(segmentId + "shield");
                    routeContainer.m_shieldObject.AddComponent <MeshRenderer>();
                    routeContainer.m_shieldMesh = routeContainer.m_shieldObject.AddComponent <MeshFilter>();
                    GameObject numTextObject = new GameObject(segmentId + "text");
                    numTextObject.transform.parent = routeContainer.m_shieldObject.transform;
                    numTextObject.AddComponent <MeshRenderer>();
                    numTextObject.GetComponent <MeshRenderer>().sortingOrder = 1001;

                    routeContainer.m_numMesh = numTextObject.AddComponent <TextMesh>();
                }


                string routeStr = routePrefix + '/' + route;
                if (!m_usedRoutes.ContainsKey(routeStr))
                {
                    m_usedRoutes[routeStr] = 0;
                }
                m_usedRoutes[routeStr] += 1;

                if (oldRouteStr != null)
                {
                    DecrementRoadRouteCounter(oldRouteStr);
                }
            }
            else
            {
                GameObject.Destroy(m_routeDict[segmentId].m_shieldObject);
                m_routeDict.Remove(segmentId);
            }

            if (oldRouteStr != null)
            {
                DecrementRoadRouteCounter(oldRouteStr);
            }

            EventBusManager.Instance().Publish("forceupdateroutes", null);
        }
Пример #2
0
 public void DeleteSign(SignContainer container)
 {
     GameObject.Destroy(container.m_signObj);
     m_signList.Remove(container);
     EventBusManager.Instance().Publish("forceUpdateSigns", null);
 }
Пример #3
0
        public void SetSign(Vector3 position, float angle, string routePrefix, string route, string destination, string signType)
        {
            SignContainer signContainer = new SignContainer(position, angle, routePrefix, route, destination);

            signContainer.m_exitNum = signType;
            string       signPropType = signContainer.m_exitNum == null ? "hwysign" : signContainer.m_exitNum;
            SignPropInfo config       = SignPropConfig.signPropInfoDict[signPropType];
            int          numSignObjs  = config.isDoubleGantry ? 2 : 1;

            if (routePrefix != null)
            {
                signContainer.m_shieldObject = new GameObject(position + "shield");
                signContainer.m_shieldObject.AddComponent <MeshRenderer>();
                signContainer.m_shieldMesh = signContainer.m_shieldObject.AddComponent <MeshFilter>();
                GameObject numTextObject = new GameObject(position + "text");
                numTextObject.transform.parent = signContainer.m_shieldObject.transform;
                numTextObject.AddComponent <MeshRenderer>();
                numTextObject.GetComponent <MeshRenderer>().sortingOrder = 1001;
                signContainer.m_numMesh = numTextObject.AddComponent <TextMesh>();
            }


            signContainer.m_signObj = new GameObject(position + "sign");
            signContainer.m_signObj.AddComponent <MeshRenderer>();
            signContainer.m_sign = signContainer.m_signObj.AddComponent <MeshFilter>();

            signContainer.m_destinationMeshObject = new GameObject[numSignObjs];
            signContainer.m_destinationMesh       = new TextMesh[numSignObjs];

            //Todo: move the route info back to the renderingManager( or move the rendering position here?? )
            signContainer.m_sign.transform.position = position;
            signContainer.m_sign.transform.Rotate(0, -1 * Mathf.Rad2Deg * signContainer.angle, 0);

            for (int i = 0; i < numSignObjs; i++)
            {
                signContainer.m_destinationMeshObject[i] = new GameObject(position + i.ToString() + "destText");
                signContainer.m_destinationMesh[i]       = signContainer.m_destinationMeshObject[i].AddComponent <TextMesh>();

                signContainer.m_destinationMesh[i].transform.position = position;
                signContainer.m_destinationMesh[i].transform.parent   = signContainer.m_sign.transform;

                signContainer.m_destinationMesh[i].transform.position = position;
                signContainer.m_destinationMesh[i].transform.Rotate(0, (-1 * Mathf.Rad2Deg * signContainer.angle) + 270 + config.angleOffset, 0);
            }

            if (routePrefix != null)
            {
                signContainer.m_shieldMesh.transform.position = position;

                //TODO: Bind the elevation of the mesh to the text z offset
                signContainer.m_shieldMesh.transform.position  += (Vector3.up * (0.5f));
                signContainer.m_shieldMesh.transform.localScale = new Vector3(0.18f, 0.18f, 0.18f);

                signContainer.m_numMesh.transform.position = position;
                signContainer.m_numMesh.transform.position = signContainer.m_shieldObject.GetComponent <Renderer>().bounds.center;

                signContainer.m_shieldMesh.transform.parent = signContainer.m_sign.transform;
                signContainer.m_shieldMesh.transform.Rotate(0, (-1 * Mathf.Rad2Deg * signContainer.angle) + 270 + config.angleOffset, 0);

                signContainer.m_shieldMesh.transform.localPosition += new Vector3(0.2f, 6.6f, -5.6f);

                signContainer.m_numMesh.transform.parent = signContainer.m_shieldObject.transform;
            }
            m_signList.Add(signContainer);
            EventBusManager.Instance().Publish("forceUpdateSigns", null);
        }