From b9751b2f076ee050fe5b685e91ae4fc4469b1015 Mon Sep 17 00:00:00 2001 From: yyl <yyl> Date: 星期一, 09 六月 2025 09:01:02 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts --- Main/Component/UI/Common/ScreenDiffuseMove.cs | 260 +++++++++++++++++++++++++-------------------------- 1 files changed, 128 insertions(+), 132 deletions(-) diff --git a/Main/Component/UI/Common/ScreenDiffuseMove.cs b/Main/Component/UI/Common/ScreenDiffuseMove.cs index 4363b7a..f412ec1 100644 --- a/Main/Component/UI/Common/ScreenDiffuseMove.cs +++ b/Main/Component/UI/Common/ScreenDiffuseMove.cs @@ -6,155 +6,151 @@ using System.Collections; using UnityEngine.UI; -namespace vnxbqy.UI + +public class ScreenDiffuseMove : MonoBehaviour { - public class ScreenDiffuseMove : MonoBehaviour + [SerializeField] DiffuseType m_MoveType = DiffuseType.MoveUp; + public DiffuseType moveType { get { return m_MoveType; } } + + [SerializeField] float m_Speed = 10f; + public float speed { + get { return m_Speed; } + set { m_Speed = value; } + } + + [SerializeField] TweenCurve m_SpeedRatioCurve; + [SerializeField] float m_Duration = 1f; + public float duration { + get { return m_Duration; } + set { m_Duration = value; } + } + + [SerializeField] float m_Delay = 0f; + public float delay { + get { return m_Delay; } + set { m_Delay = value; } + } + + [SerializeField] bool m_IsLocal = true; + public bool isLocal { + get { return m_IsLocal; } + } + + float beginTime = 0f; + float endTime = 0f; + Vector2 direction = Vector2.up; + bool disableOnEnd = true; + + public void Begin(bool _disableOnEnd = true) { + beginTime = Time.time + delay; + endTime = Time.time + delay + duration; + disableOnEnd = _disableOnEnd; - [SerializeField] DiffuseType m_MoveType = DiffuseType.MoveUp; - public DiffuseType moveType { get { return m_MoveType; } } - - [SerializeField] float m_Speed = 10f; - public float speed { - get { return m_Speed; } - set { m_Speed = value; } - } - - [SerializeField] TweenCurve m_SpeedRatioCurve; - [SerializeField] float m_Duration = 1f; - public float duration { - get { return m_Duration; } - set { m_Duration = value; } - } - - [SerializeField] float m_Delay = 0f; - public float delay { - get { return m_Delay; } - set { m_Delay = value; } - } - - [SerializeField] bool m_IsLocal = true; - public bool isLocal { - get { return m_IsLocal; } - } - - float beginTime = 0f; - float endTime = 0f; - Vector2 direction = Vector2.up; - bool disableOnEnd = true; - - public void Begin(bool _disableOnEnd = true) + switch (m_MoveType) { - beginTime = Time.time + delay; - endTime = Time.time + delay + duration; - disableOnEnd = _disableOnEnd; - - switch (m_MoveType) - { - case DiffuseType.MoveUp: - direction = Vector2.up * m_Speed; - break; - case DiffuseType.MoveDown: - direction = Vector2.down * m_Speed; - break; - case DiffuseType.MoveLeft: - direction = Vector2.left * m_Speed; - break; - case DiffuseType.MoveRight: - direction = Vector2.right * m_Speed; - break; - case DiffuseType.RelativePosition: - direction = new Vector2(this.transform.position.x, this.transform.position.y).normalized * m_Speed; - break; - case DiffuseType.ReversalRelativePosition: - direction = new Vector2(-this.transform.position.x, this.transform.position.y).normalized * m_Speed; - break; - } - - this.enabled = true; - if (!this.gameObject.activeInHierarchy) - { - this.SetActive(true); - } - + case DiffuseType.MoveUp: + direction = Vector2.up * m_Speed; + break; + case DiffuseType.MoveDown: + direction = Vector2.down * m_Speed; + break; + case DiffuseType.MoveLeft: + direction = Vector2.left * m_Speed; + break; + case DiffuseType.MoveRight: + direction = Vector2.right * m_Speed; + break; + case DiffuseType.RelativePosition: + direction = new Vector2(this.transform.position.x, this.transform.position.y).normalized * m_Speed; + break; + case DiffuseType.ReversalRelativePosition: + direction = new Vector2(-this.transform.position.x, this.transform.position.y).normalized * m_Speed; + break; } - public void Begin(Vector3 _direction, bool _disableOnEnd = true) + this.enabled = true; + if (!this.gameObject.activeInHierarchy) { - beginTime = Time.time + delay; - endTime = Time.time + delay + duration; - disableOnEnd = _disableOnEnd; - - switch (m_MoveType) - { - case DiffuseType.MoveUp: - direction = Vector2.up * m_Speed; - break; - case DiffuseType.MoveDown: - direction = Vector2.down * m_Speed; - break; - case DiffuseType.MoveLeft: - direction = Vector2.left * m_Speed; - break; - case DiffuseType.MoveRight: - direction = Vector2.right * m_Speed; - break; - case DiffuseType.RelativePosition: - direction = new Vector2(_direction.x, _direction.y).normalized * m_Speed; - break; - case DiffuseType.ReversalRelativePosition: - direction = new Vector2(_direction.x, -_direction.y).normalized * m_Speed; - break; - } - - this.enabled = true; - if (!this.gameObject.activeInHierarchy) - { - this.SetActive(true); - } + this.SetActive(true); } - private void LateUpdate() - { - if (Time.time < beginTime) - { - return; - } + } - if (Time.time < endTime) - { - var delta = direction * Time.deltaTime * m_SpeedRatioCurve.Evaluate((Time.time - beginTime) / duration); - if (isLocal) - { - this.transform.localPosition += new Vector3(delta.x, delta.y, 0); - } - else - { - this.transform.position += new Vector3(delta.x, delta.y, 0); - } - } - else - { - if (disableOnEnd) - { - this.enabled = false; - } - } + public void Begin(Vector3 _direction, bool _disableOnEnd = true) + { + beginTime = Time.time + delay; + endTime = Time.time + delay + duration; + disableOnEnd = _disableOnEnd; + + switch (m_MoveType) + { + case DiffuseType.MoveUp: + direction = Vector2.up * m_Speed; + break; + case DiffuseType.MoveDown: + direction = Vector2.down * m_Speed; + break; + case DiffuseType.MoveLeft: + direction = Vector2.left * m_Speed; + break; + case DiffuseType.MoveRight: + direction = Vector2.right * m_Speed; + break; + case DiffuseType.RelativePosition: + direction = new Vector2(_direction.x, _direction.y).normalized * m_Speed; + break; + case DiffuseType.ReversalRelativePosition: + direction = new Vector2(_direction.x, -_direction.y).normalized * m_Speed; + break; } - - public enum DiffuseType + this.enabled = true; + if (!this.gameObject.activeInHierarchy) { - MoveUp, - MoveDown, - MoveLeft, - MoveRight, - RelativePosition, - ReversalRelativePosition, + this.SetActive(true); } } + private void LateUpdate() + { + if (Time.time < beginTime) + { + return; + } + + if (Time.time < endTime) + { + var delta = direction * Time.deltaTime * m_SpeedRatioCurve.Evaluate((Time.time - beginTime) / duration); + if (isLocal) + { + this.transform.localPosition += new Vector3(delta.x, delta.y, 0); + } + else + { + this.transform.position += new Vector3(delta.x, delta.y, 0); + } + } + else + { + if (disableOnEnd) + { + this.enabled = false; + } + } + } + + + public enum DiffuseType + { + MoveUp, + MoveDown, + MoveLeft, + MoveRight, + RelativePosition, + ReversalRelativePosition, + } } -- Gitblit v1.8.0