Esempio n. 1
0
        public void SetOP()
        {
            Vector3 v = -transform.forward;

            for (int i = 0; i < 4; i++)
            {
                m_OPs[i] = new OrientedPoint(transform.rotation * m_coll[i].center + transform.position, Quaternion.LookRotation(v, Vector3.up));
                v        = Quaternion.Euler(0, 90f, 0) * v;
            }
        }
        public static DeadEnd CreateDeadEnd(Cross _cross, int _index)
        {
            GameObject obj = new GameObject("DeadEnd");
            DeadEnd    de  = obj.AddComponent <DeadEnd>();

            OrientedPoint op = _cross.m_OPs[_index];

            de.Init(_cross, _index, op);
            obj.transform.parent = _cross.transform;
            return(de);
        }
Esempio n. 3
0
        /// <summary>
        /// Initialize the DeadEnd
        /// </summary>
        /// <param name="_comp">The Street the Dead End is connected to</param>
        /// <param name="_isStart">Is it the Start of the Street?</param>
        /// <param name="_op">The OrientedPoint of the DeadEnd</param>
        /// <returns>The new Dead End</returns>
        public DeadEnd Init(Street _comp, bool _isStart, OrientedPoint _op)
        {
            base.Init(false);
            ID      = -2;
            m_Shape = new DeadEndShape();
            SetStartConnection(new Connection(null, this, true));
            if (_isStart)
            {
                //Move the Start Point half the width of the Street | Street width is 2
                Vector3 start = _op.Position + (_op.Rotation * -Vector3.right) * 0.5f;
                //Move the Tangent 1 up above the start Point
                Vector3 tangent1 = start - _op.Rotation * Vector3.forward * 0.8f;
                //Move the End Point half the width of the Street | Street width is 2
                Vector3 end = _op.Position + (_op.Rotation * Vector3.right) * 0.5f;
                //Move the Tangent 2 up above the end Point
                Vector3 tangent2 = end - _op.Rotation * Vector3.forward * 0.8f;
                m_Spline = new Spline(
                    start, tangent1, tangent2, end, 10, this
                    );
                Connection.Combine(GetStartConnection(), _comp.GetStartConnection());
            }
            else
            {
                //Move the Start Point half the width of the Street | Street width is 2
                Vector3 start = _op.Position + (_op.Rotation * Vector3.right) * 0.5f;
                //Move the Tangent 1 up above the start Point
                Vector3 tangent1 = start + _op.Rotation * Vector3.forward * 0.8f;
                //Move the End Point half the width of the Street | Street width is 2
                Vector3 end = _op.Position + (_op.Rotation * -Vector3.right) * 0.5f;
                //Move the Tangent 2 up above the end Point
                Vector3 tangent2 = end + _op.Rotation * Vector3.forward * 0.8f;
                m_Spline = new Spline(
                    start, tangent1, tangent2, end, 10, this
                    );
                Connection.Combine(GetStartConnection(), _comp.m_EndConnection);
            }

            m_MeshFilter            = gameObject.AddComponent <MeshFilter>();
            m_MeshRenderer          = gameObject.AddComponent <MeshRenderer>();
            m_MeshRenderer.material = StreetComponentManager.Instance.DeadEndMat;
            transform.SetParent(_comp.transform);
            MeshGenerator.Extrude(this);
            return(this);
        }
Esempio n. 4
0
        public DeadEnd Init(Cross _cross, int _index, OrientedPoint _op)
        {
            base.Init(false);
            ID      = -2;
            m_Shape = new DeadEndShape();
            SetStartConnection(new Connection(null, this, true));

            Vector3 start    = _op.Position + (_op.Rotation * Vector3.right) * 0.5f;
            Vector3 tangent1 = start + _op.Rotation * Vector3.forward * 0.8f;
            Vector3 end      = _op.Position - (_op.Rotation * Vector3.right) * 0.5f;
            Vector3 tangent2 = end + _op.Rotation * Vector3.forward * 0.8f;

            m_Spline = new Spline(
                start, tangent1, tangent2, end, 10, this
                );

            m_MeshFilter            = gameObject.AddComponent <MeshFilter>();
            m_MeshRenderer          = gameObject.AddComponent <MeshRenderer>();
            m_MeshRenderer.material = StreetComponentManager.Instance.DeadEndMat;
            MeshGenerator.Extrude(this);
            Connection.Combine(GetStartConnection(), _cross.m_Connections[_index]);

            return(this);
        }