diff options
| author | chai <chaifix@163.com> | 2020-10-24 17:30:07 +0800 | 
|---|---|---|
| committer | chai <chaifix@163.com> | 2020-10-24 17:30:07 +0800 | 
| commit | 65ed53a40f990e895305ff17a5e48e3cd6b8785b (patch) | |
| tree | 3333c6a9b19fa5602fd8827e582273f602452bec /Assets/Art/Vfx/GrabSquaresEffect/Scripts | |
| parent | 56a9b3bf4edc56e9c1dd502a469a7a0167751215 (diff) | |
*物理系统
Diffstat (limited to 'Assets/Art/Vfx/GrabSquaresEffect/Scripts')
4 files changed, 0 insertions, 156 deletions
| diff --git a/Assets/Art/Vfx/GrabSquaresEffect/Scripts/MoveableLineRenderer.cs b/Assets/Art/Vfx/GrabSquaresEffect/Scripts/MoveableLineRenderer.cs deleted file mode 100644 index dc2d723d..00000000 --- a/Assets/Art/Vfx/GrabSquaresEffect/Scripts/MoveableLineRenderer.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System.Linq; -using UnityEngine; - -namespace Assets.MoveableLineRenderer.Scripts -{ -    internal sealed class MoveableLineRenderer : MonoBehaviour -    { -        public GameObject LineRendererPrefab; -        public float MinVertexDistance = 1f; -        public float LifeTime = 0.3f; -        public float Scale = 1.0f; -        public float Speed = 1f; -        public float Height = 1f; -        public float Gravity; - -        private LineRenderer _lineRenderer; -        private Point[] _points; -        private int _pointsCount; - -        private void Start() -        { -            _lineRenderer = Instantiate(LineRendererPrefab).GetComponent<LineRenderer>(); -            _lineRenderer.enabled = true; -            _lineRenderer.transform.parent = transform; - -            _points = new Point[100]; -        } - -        private void Update() -        { -            RemoveOutdatedPoints(); - -            if (_pointsCount == 0) -            { -                _points[_pointsCount++] = new Point(transform.position); -                _points[_pointsCount++] = new Point(transform.position); -            } - -            bool needAdd = false; - -            var sqrDistance = (_points[1].Position - transform.position).sqrMagnitude; -            if (sqrDistance > MinVertexDistance * MinVertexDistance) -            { -                if (sqrDistance > MinVertexDistance * MinVertexDistance) -                    needAdd = true; -            } - -            if (needAdd) -            { -                if (_pointsCount == _points.Length) -                    System.Array.Resize(ref _points, _points.Length + 50); - -                InsertPoint(); -            } - -            ApplyTurbulence(); - -            _lineRenderer.positionCount = _pointsCount; - -            //todo -            _lineRenderer.SetPositions(_points.Where(t => t != null).Select(t => t.Position).ToArray()); -        } - -        private void InsertPoint() -        { -            for (int i = _pointsCount; i > 0; i--) -                _points[i] = _points[i - 1]; - -            _points[0] = new Point(transform.position); - -            _pointsCount++; -        } - -        private void RemoveOutdatedPoints() -        { -            if (_pointsCount == 0) -                return; - -            for (int i = _pointsCount - 1; i >= 0; i--) -            { -                var point = _points[i]; -                if (point == null || point.TimeAlive >= LifeTime) -                { -                    _points[i] = null; -                    _pointsCount--; -                } -            } -        } - -        private void ApplyTurbulence() -        { -            for (int i = _pointsCount - 1; i >= 0; i--) -            { -                if (_points[i] == null) -                    continue; - -                var sTime = Time.timeSinceLevelLoad * Speed; - -                var pointPosition = _points[i].Position; - -                float xCoord = pointPosition.x * Scale + sTime; -                float yCoord = pointPosition.y * Scale + sTime; -                float zCoord = pointPosition.z * Scale + sTime; - -                _points[i].Position.x += (Mathf.PerlinNoise(yCoord, zCoord) - 0.5f) * Height; -                _points[i].Position.y += (Mathf.PerlinNoise(xCoord, zCoord) - 0.5f) * Height - Gravity; -                _points[i].Position.z += (Mathf.PerlinNoise(xCoord, yCoord) - 0.5f) * Height; -            } -        } -    } -} diff --git a/Assets/Art/Vfx/GrabSquaresEffect/Scripts/MoveableLineRenderer.cs.meta b/Assets/Art/Vfx/GrabSquaresEffect/Scripts/MoveableLineRenderer.cs.meta deleted file mode 100644 index d826e5a9..00000000 --- a/Assets/Art/Vfx/GrabSquaresEffect/Scripts/MoveableLineRenderer.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 8e72c6b7bfb8dfe4a801d6dc2eff8a8a -timeCreated: 1497604732 -licenseType: Free -MonoImporter: -  serializedVersion: 2 -  defaultReferences: [] -  executionOrder: 0 -  icon: {instanceID: 0} -  userData:  -  assetBundleName:  -  assetBundleVariant:  diff --git a/Assets/Art/Vfx/GrabSquaresEffect/Scripts/Point.cs b/Assets/Art/Vfx/GrabSquaresEffect/Scripts/Point.cs deleted file mode 100644 index b3932cc6..00000000 --- a/Assets/Art/Vfx/GrabSquaresEffect/Scripts/Point.cs +++ /dev/null @@ -1,21 +0,0 @@ -using UnityEngine; - -namespace Assets.MoveableLineRenderer.Scripts -{ -    internal sealed class Point -    { -        public Vector3 Position; -        private readonly float _timeCreated; - -        public Point(Vector3 position) -        { -            Position = position; -            _timeCreated = Time.time; -        } - -        public float TimeAlive -        { -            get { return Time.time - _timeCreated; } -        } -    } -}
\ No newline at end of file diff --git a/Assets/Art/Vfx/GrabSquaresEffect/Scripts/Point.cs.meta b/Assets/Art/Vfx/GrabSquaresEffect/Scripts/Point.cs.meta deleted file mode 100644 index 64ed36d9..00000000 --- a/Assets/Art/Vfx/GrabSquaresEffect/Scripts/Point.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: fe1075647a49def42b1b080b474500cf -timeCreated: 1497629757 -licenseType: Free -MonoImporter: -  serializedVersion: 2 -  defaultReferences: [] -  executionOrder: 0 -  icon: {instanceID: 0} -  userData:  -  assetBundleName:  -  assetBundleVariant:  | 
