Esempio n. 1
0
            public LevelSegmentPath Copy()
            {
                LevelSegmentPath newPath = new LevelSegmentPath(segment);

                newPath.name        = name;
                newPath.localPoints = new SplinePoint[localPoints.Length];
                localPoints.CopyTo(newPath.localPoints, 0);
                newPath.spline = new Spline(spline.type, spline.sampleRate);
                newPath.Transform();
                return(newPath);
            }
Esempio n. 2
0
 //Migrate Custom paths made with the old system to the new
 public void OnAfterDeserialize()
 {
     if (oldCustomPaths != null && customPaths.Length == 0)
     {
         customPaths = new LevelSegmentPath[oldCustomPaths.Length];
         for (int i = 0; i < customPaths.Length; i++)
         {
             customPaths[i] = new LevelSegmentPath(oldCustomPaths[i]);
         }
         oldCustomPaths = null;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Create a custom path for the segment. Points will automatically be generated based on the segment type and axis.
        /// </summary>
        /// <param name="name">Name of the path</param>
        public void AddCustomPath(string name)
        {
            LevelSegmentPath path = new LevelSegmentPath(this);

            path.name = name;
            SplinePoint[] points = new SplinePoint[2];
            Vector3       pos    = Vector3.zero;

            switch (type)
            {
            case Type.Extruded:
                switch (axis)
                {
                case Axis.X:
                    pos       = -Vector3.right * bounds.size.x * 0.5f;
                    points[0] = new SplinePoint(pos, pos - Vector3.right * bounds.size.x / 3f, Vector3.up, 1f, Color.white);
                    pos       = Vector3.right * bounds.size.x * 0.5f;
                    points[1] = new SplinePoint(pos, pos - Vector3.right * bounds.size.x / 3f, Vector3.up, 1f, Color.white);
                    break;

                case Axis.Y:
                    pos       = -Vector3.up * bounds.size.y * 0.5f;
                    points[0] = new SplinePoint(pos, pos - Vector3.up * bounds.size.y / 3f, -Vector3.forward, 1f, Color.white);
                    pos       = Vector3.up * bounds.size.y * 0.5f;
                    points[1] = new SplinePoint(pos, pos - Vector3.up * bounds.size.y / 3f, -Vector3.forward, 1f, Color.white);
                    break;

                case Axis.Z:
                    pos       = -Vector3.forward * bounds.size.z * 0.5f;
                    points[0] = new SplinePoint(pos, pos - Vector3.forward * bounds.size.z / 3f, Vector3.up, 1f, Color.white);
                    pos       = Vector3.forward * bounds.size.z * 0.5f;
                    points[1] = new SplinePoint(pos, pos - Vector3.forward * bounds.size.z / 3f, Vector3.up, 1f, Color.white);
                    break;
                }
                break;

            case Type.Custom:
                float distance = Vector3.Distance(transform.InverseTransformPoint(customEntrance.position), transform.InverseTransformPoint(customExit.position));
                pos       = transform.InverseTransformPoint(customEntrance.position);
                points[0] = new SplinePoint(pos, pos - transform.InverseTransformDirection(customEntrance.forward) * distance / 3f, transform.InverseTransformDirection(customEntrance.up), 1f, Color.white);
                pos       = transform.InverseTransformPoint(customExit.position);
                points[1] = new SplinePoint(pos, pos - transform.InverseTransformDirection(customExit.forward) * distance / 3f, transform.InverseTransformDirection(customExit.up), 1f, Color.white);
                break;
            }
            path.localPoints = points;
            ArrayUtility.Add(ref customPaths, path);
        }