From 38ed075c317a29496dc10db2ea01d6b674a390d2 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 31 七月 2025 23:47:50 +0800
Subject: [PATCH] 0312 武将布阵逻辑
---
Main/Component/UI/Common/DragItem.cs | 62 +++--
Main/Component/UI/Common/DragContainer.cs | 4
Main/System/HeroUI/HeroPosWin.cs | 37 ++
Main/Component/UI/Common/BoundedDrag.cs | 501 ++++++++++++++++++++++++---------------------
Main/System/HeroUI/HeroScenePosCell.cs | 22 ++
Main/Config/PartialConfigs/PlayerPropertyConfig.cs | 8
6 files changed, 357 insertions(+), 277 deletions(-)
diff --git a/Main/Component/UI/Common/BoundedDrag.cs b/Main/Component/UI/Common/BoundedDrag.cs
index b926f29..69f4a8e 100644
--- a/Main/Component/UI/Common/BoundedDrag.cs
+++ b/Main/Component/UI/Common/BoundedDrag.cs
@@ -10,241 +10,270 @@
using System;
- public class BoundedDrag : MonoBehaviour, IEndDragHandler, IBeginDragHandler, IDragHandler
- {
-
- [SerializeField]
- RectTransform m_Target;
- public RectTransform target {
- get { return m_Target; }
- set {
- m_Target = value;
- }
- }
-
- public RectTransform rectTransform { get { return this.transform as RectTransform; } }
-
- [SerializeField]
- ScaleRange m_ScaleRange;
- public ScaleRange scaleRange {
- get { return m_ScaleRange; }
- set { m_ScaleRange = value; }
- }
-
- [SerializeField]
- float m_DefaultScale;
- public float defaultScale { get { return m_DefaultScale; } }
-
- [SerializeField]
- float m_DestScale = 1f;
- public float destScale {
- get { return m_DestScale; }
- set { m_DestScale = Mathf.Clamp(value, scaleRange.min, scaleRange.max); }
- }
-
- float refScale = 0f;
-
- public float currentScale {
- get {
- return target.localScale.x;
- }
- set {
- target.localScale = Vector3.one * Mathf.Clamp(value, scaleRange.min, scaleRange.max);
- }
- }
-
- [SerializeField]
- MoveArea m_MoveArea;
- public MoveArea moveArea {
- get { return m_MoveArea; }
- set { m_MoveArea = value; }
- }
-
- [SerializeField]
- Vector2 m_DestPosition = Vector2.zero;
- public Vector2 destPosition {
- get { return m_DestPosition; }
- set { m_DestPosition = new Vector2(Mathf.Clamp(value.x, moveArea.Left * destScale, moveArea.Right * destScale), Mathf.Clamp(value.y, moveArea.Bottom * destScale, moveArea.Top * destScale)); }
- }
-
- Vector3 refPosition = Vector3.zero;
-
- public Vector2 currentPosition {
- get { return target.anchoredPosition; }
- set { target.anchoredPosition = value; }
- }
-
- Vector2 startTouchPosition01;
- Vector2 startGroundPosition;
-
- Vector2 lastTouchPosition01;
- Vector2 curTouchPosition01;
- Vector2 lastTouchPosition02;
- Vector2 curTouchPosition02;
-
- [SerializeField]
- Action m_OnBeginDrag;
- public Action onBeginDrag {
- get { return m_OnBeginDrag; }
- }
-
- bool m_Actionable = true;
- public bool actionable {
- get { return m_Actionable; }
- set { m_Actionable = value; }
- }
-
- private void OnEnable()
- {
- destPosition = currentPosition = Vector3.zero;
- }
-
- public void OnBeginDrag(PointerEventData eventData)
- {
-
-#if UNITY_EDITOR || UNITY_STANDALONE
- if (Input.GetKey(KeyCode.LeftControl) && eventData.button == PointerEventData.InputButton.Left)
- {
- TwoFingerHandleBegin();
- }
- else if (eventData.button == PointerEventData.InputButton.Left)
- {
- OneFingerHandleBegin(eventData);
- }
-#else
- if (Input.touchCount == 2) {
- TwoFingerHandleBegin();
- }
- if (Input.touchCount == 1) {
- OneFingerHandleBegin(eventData);
- }
-#endif
- onBeginDrag?.Invoke();
- }
-
- public void OnDrag(PointerEventData eventData)
- {
-#if UNITY_EDITOR || UNITY_STANDALONE
- if (Input.GetKey(KeyCode.LeftControl) && eventData.button == PointerEventData.InputButton.Left)
- {
- TwoFingerHandle();
- }
- else if (eventData.button == PointerEventData.InputButton.Left)
- {
- OneFingerHandle(eventData);
- }
-#else
- if (Input.touchCount == 2) {
- TwoFingerHandle();
- }
- if (Input.touchCount == 1) {
- OneFingerHandle(eventData);
- }
-#endif
- }
-
- public void OnEndDrag(PointerEventData eventData)
- {
- }
-
- void LateUpdate()
- {
- if (!actionable)
- {
- return;
- }
-
- if (Mathf.Abs(currentScale - destScale) > 0.01f)
- {
- float newScale = Mathf.SmoothDamp(currentScale, destScale, ref refScale, 0.15f);
- currentScale = newScale;
- }
-
- if (Vector2.Distance(currentPosition, destPosition) > 0.1f)
- {
- Vector2 newPosition = Vector3.SmoothDamp(currentPosition, destPosition, ref refPosition, 0.15f);
- currentPosition = newPosition;
- }
- }
-
- private void OneFingerHandleBegin(PointerEventData eventData)
- {
- startTouchPosition01 = Vector2.zero;
- RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position, eventData.pressEventCamera, out startTouchPosition01);
- startGroundPosition = currentPosition;
-
- }
-
- private void OneFingerHandle(PointerEventData eventData)
- {
- Vector2 localMouse;
- if (RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position, eventData.pressEventCamera, out localMouse))
- {
- var pointerDelta = localMouse - startTouchPosition01;
- destPosition = startGroundPosition + pointerDelta;
- }
- }
-
- private void TwoFingerHandle()
- {
- // 鏂逛究PC璋冭瘯閫昏緫
-#if UNITY_EDITOR || UNITY_STANDALONE
- curTouchPosition01 = new Vector2(Screen.width / 2, Screen.height / 2);
- curTouchPosition02 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
-#else
- Touch touchFirst = Input.touches[0];
- Touch touchSecond = Input.touches[1];
- curTouchPosition01 = touchFirst.position;
- curTouchPosition02 = touchSecond.position;
-#endif
-
- float lastLength = Vector2.Distance(lastTouchPosition01, lastTouchPosition02);
- float curLength = Vector2.Distance(curTouchPosition01, curTouchPosition02);
- destScale *= curLength / Mathf.Clamp(lastLength, 1, float.MaxValue);
-
- lastTouchPosition01 = curTouchPosition01;
- lastTouchPosition02 = curTouchPosition02;
- }
-
- private void TwoFingerHandleBegin()
- {
- // 鏂逛究PC璋冭瘯閫昏緫
-#if UNITY_EDITOR || UNITY_STANDALONE
- curTouchPosition01 = new Vector2(Screen.width / 2, Screen.height / 2);
- curTouchPosition02 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
-#else
- Touch touchFirst = Input.touches[0];
- Touch touchSecond = Input.touches[1];
- curTouchPosition01 = touchFirst.position;
- curTouchPosition02 = touchSecond.position;
-#endif
-
- lastTouchPosition01 = curTouchPosition01;
- lastTouchPosition02 = curTouchPosition02;
- }
-
- [Serializable]
- public struct ScaleRange
- {
- public float min;
- public float max;
- }
-
- [Serializable]
- public struct MoveArea
- {
- public float Left;
- public float Right;
- public float Top;
- public float Bottom;
-
- public MoveArea(float _left, float _right, float _top, float _bottom)
- {
- this.Left = _left;
- this.Right = _right;
- this.Top = _top;
- this.Bottom = _bottom;
- }
-
+/// <summary>
+/// 瀹炵幇鎷栨嫿鍜岀缉鏀惧姛鑳界殑缁勪欢锛屾敮鎸佸崟鎸囨嫋鎷藉拰鍙屾寚缂╂斁銆�
+/// </summary>
+public class BoundedDrag : MonoBehaviour, IEndDragHandler, IBeginDragHandler, IDragHandler
+{
+ [SerializeField]
+ RectTransform m_Target; // 鎷栨嫿鐨勭洰鏍囧璞�
+ public RectTransform target {
+ get { return m_Target; }
+ set {
+ m_Target = value;
}
}
+
+ public RectTransform rectTransform { get { return this.transform as RectTransform; } }
+
+ [SerializeField]
+ ScaleRange m_ScaleRange; // 缂╂斁鑼冨洿
+ public ScaleRange scaleRange {
+ get { return m_ScaleRange; }
+ set { m_ScaleRange = value; }
+ }
+
+ [SerializeField]
+ float m_DefaultScale; // 榛樿缂╂斁鍊�
+ public float defaultScale { get { return m_DefaultScale; } }
+
+ [SerializeField]
+ float m_DestScale = 1f; // 鐩爣缂╂斁鍊�
+ public float destScale {
+ get { return m_DestScale; }
+ set { m_DestScale = Mathf.Clamp(value, scaleRange.min, scaleRange.max); }
+ }
+
+ float refScale = 0f; // 鐢ㄤ簬骞虫粦缂╂斁鐨勫弬鑰冨��
+
+ public float currentScale {
+ get {
+ return target.localScale.x;
+ }
+ set {
+ target.localScale = Vector3.one * Mathf.Clamp(value, scaleRange.min, scaleRange.max);
+ }
+ }
+
+ [SerializeField]
+ MoveArea m_MoveArea; // 鎷栨嫿鐨勮竟鐣屽尯鍩�
+ public MoveArea moveArea {
+ get { return m_MoveArea; }
+ set { m_MoveArea = value; }
+ }
+
+ [SerializeField]
+ Vector2 m_DestPosition = Vector2.zero; // 鐩爣浣嶇疆
+ public Vector2 destPosition {
+ get { return m_DestPosition; }
+ set { m_DestPosition = new Vector2(Mathf.Clamp(value.x, moveArea.Left * destScale, moveArea.Right * destScale), Mathf.Clamp(value.y, moveArea.Bottom * destScale, moveArea.Top * destScale)); }
+ }
+
+ Vector3 refPosition = Vector3.zero; // 鐢ㄤ簬骞虫粦绉诲姩鐨勫弬鑰冨��
+
+ public Vector2 currentPosition {
+ get { return target.anchoredPosition; }
+ set { target.anchoredPosition = value; }
+ }
+
+ Vector2 startTouchPosition01; // 鍗曟寚鎷栨嫿鐨勮捣濮嬭Е鎽镐綅缃�
+ Vector2 startGroundPosition; // 鍗曟寚鎷栨嫿鐨勮捣濮嬪湴闈綅缃�
+
+ Vector2 lastTouchPosition01; // 鍙屾寚缂╂斁鐨勪笂涓�甯цЕ鎽镐綅缃�1
+ Vector2 curTouchPosition01; // 鍙屾寚缂╂斁鐨勫綋鍓嶅抚瑙︽懜浣嶇疆1
+ Vector2 lastTouchPosition02; // 鍙屾寚缂╂斁鐨勪笂涓�甯цЕ鎽镐綅缃�2
+ Vector2 curTouchPosition02; // 鍙屾寚缂╂斁鐨勫綋鍓嶅抚瑙︽懜浣嶇疆2
+
+ [SerializeField]
+ Action m_OnBeginDrag; // 鎷栨嫿寮�濮嬩簨浠�
+ public Action onBeginDrag {
+ get { return m_OnBeginDrag; }
+ }
+
+ bool m_Actionable = true; // 鏄惁鍙搷浣�
+ public bool actionable {
+ get { return m_Actionable; }
+ set { m_Actionable = value; }
+ }
+
+ private void OnEnable()
+ {
+ destPosition = currentPosition = Vector3.zero; // 鍒濆鍖栦綅缃�
+ }
+
+ /// <summary>
+ /// 鎷栨嫿寮�濮嬩簨浠跺鐞�
+ /// </summary>
+ public void OnBeginDrag(PointerEventData eventData)
+ {
+#if UNITY_EDITOR || UNITY_STANDALONE
+ if (Input.GetKey(KeyCode.LeftControl) && eventData.button == PointerEventData.InputButton.Left)
+ {
+ TwoFingerHandleBegin(); // 鍙屾寚缂╂斁寮�濮�
+ }
+ else if (eventData.button == PointerEventData.InputButton.Left)
+ {
+ OneFingerHandleBegin(eventData); // 鍗曟寚鎷栨嫿寮�濮�
+ }
+#else
+ if (Input.touchCount == 2) {
+ TwoFingerHandleBegin();
+ }
+ if (Input.touchCount == 1) {
+ OneFingerHandleBegin(eventData);
+ }
+#endif
+ onBeginDrag?.Invoke(); // 瑙﹀彂鎷栨嫿寮�濮嬩簨浠�
+ }
+
+ /// <summary>
+ /// 鎷栨嫿杩囩▼涓殑浜嬩欢澶勭悊
+ /// </summary>
+ public void OnDrag(PointerEventData eventData)
+ {
+#if UNITY_EDITOR || UNITY_STANDALONE
+ if (Input.GetKey(KeyCode.LeftControl) && eventData.button == PointerEventData.InputButton.Left)
+ {
+ TwoFingerHandle(); // 鍙屾寚缂╂斁
+ }
+ else if (eventData.button == PointerEventData.InputButton.Left)
+ {
+ OneFingerHandle(eventData); // 鍗曟寚鎷栨嫿
+ }
+#else
+ if (Input.touchCount == 2) {
+ TwoFingerHandle();
+ }
+ if (Input.touchCount == 1) {
+ OneFingerHandle(eventData);
+ }
+#endif
+ }
+
+ /// <summary>
+ /// 鎷栨嫿缁撴潫浜嬩欢澶勭悊
+ /// </summary>
+ public void OnEndDrag(PointerEventData eventData)
+ {
+ }
+
+ /// <summary>
+ /// 姣忓抚鏇存柊锛屽钩婊戝鐞嗙缉鏀惧拰浣嶇疆
+ /// </summary>
+ void LateUpdate()
+ {
+ if (!actionable)
+ {
+ return;
+ }
+
+ if (Mathf.Abs(currentScale - destScale) > 0.01f)
+ {
+ float newScale = Mathf.SmoothDamp(currentScale, destScale, ref refScale, 0.15f);
+ currentScale = newScale;
+ }
+
+ if (Vector2.Distance(currentPosition, destPosition) > 0.1f)
+ {
+ Vector2 newPosition = Vector3.SmoothDamp(currentPosition, destPosition, ref refPosition, 0.15f);
+ currentPosition = newPosition;
+ }
+ }
+
+ /// <summary>
+ /// 鍗曟寚鎷栨嫿寮�濮�
+ /// </summary>
+ private void OneFingerHandleBegin(PointerEventData eventData)
+ {
+ startTouchPosition01 = Vector2.zero;
+ RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position, eventData.pressEventCamera, out startTouchPosition01);
+ startGroundPosition = currentPosition;
+ }
+
+ /// <summary>
+ /// 鍗曟寚鎷栨嫿澶勭悊
+ /// </summary>
+ private void OneFingerHandle(PointerEventData eventData)
+ {
+ Vector2 localMouse;
+ if (RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.position, eventData.pressEventCamera, out localMouse))
+ {
+ var pointerDelta = localMouse - startTouchPosition01;
+ destPosition = startGroundPosition + pointerDelta;
+ }
+ }
+
+ /// <summary>
+ /// 鍙屾寚缂╂斁澶勭悊
+ /// </summary>
+ private void TwoFingerHandle()
+ {
+ // 鏂逛究PC璋冭瘯閫昏緫
+#if UNITY_EDITOR || UNITY_STANDALONE
+ curTouchPosition01 = new Vector2(Screen.width / 2, Screen.height / 2);
+ curTouchPosition02 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
+#else
+ Touch touchFirst = Input.touches[0];
+ Touch touchSecond = Input.touches[1];
+ curTouchPosition01 = touchFirst.position;
+ curTouchPosition02 = touchSecond.position;
+#endif
+
+ float lastLength = Vector2.Distance(lastTouchPosition01, lastTouchPosition02);
+ float curLength = Vector2.Distance(curTouchPosition01, curTouchPosition02);
+ destScale *= curLength / Mathf.Clamp(lastLength, 1, float.MaxValue);
+
+ lastTouchPosition01 = curTouchPosition01;
+ lastTouchPosition02 = curTouchPosition02;
+ }
+
+ /// <summary>
+ /// 鍙屾寚缂╂斁寮�濮�
+ /// </summary>
+ private void TwoFingerHandleBegin()
+ {
+ // 鏂逛究PC璋冭瘯閫昏緫
+#if UNITY_EDITOR || UNITY_STANDALONE
+ curTouchPosition01 = new Vector2(Screen.width / 2, Screen.height / 2);
+ curTouchPosition02 = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
+#else
+ Touch touchFirst = Input.touches[0];
+ Touch touchSecond = Input.touches[1];
+ curTouchPosition01 = touchFirst.position;
+ curTouchPosition02 = touchSecond.position;
+#endif
+
+ lastTouchPosition01 = curTouchPosition01;
+ lastTouchPosition02 = curTouchPosition02;
+ }
+
+ /// <summary>
+ /// 缂╂斁鑼冨洿缁撴瀯浣�
+ /// </summary>
+ [Serializable]
+ public struct ScaleRange
+ {
+ public float min; // 鏈�灏忕缉鏀惧��
+ public float max; // 鏈�澶х缉鏀惧��
+ }
+
+ /// <summary>
+ /// 鎷栨嫿鍖哄煙缁撴瀯浣�
+ /// </summary>
+ [Serializable]
+ public struct MoveArea
+ {
+ public float Left; // 宸﹁竟鐣�
+ public float Right; // 鍙宠竟鐣�
+ public float Top; // 涓婅竟鐣�
+ public float Bottom; // 涓嬭竟鐣�
+
+ public MoveArea(float _left, float _right, float _top, float _bottom)
+ {
+ this.Left = _left;
+ this.Right = _right;
+ this.Top = _top;
+ this.Bottom = _bottom;
+ }
+ }
+}
diff --git a/Main/Component/UI/Common/DragContainer.cs b/Main/Component/UI/Common/DragContainer.cs
index d10b95d..cbe655e 100644
--- a/Main/Component/UI/Common/DragContainer.cs
+++ b/Main/Component/UI/Common/DragContainer.cs
@@ -3,13 +3,13 @@
// [ Date ]: Monday, July 31, 2017
//--------------------------------------------------------
using UnityEngine;
-using System.Collections;
-
+//DragContainer鎸傝浇鍦ㄦ湁灏勭嚎妫�娴嬬殑鐗╀綋涓婏紝鎸囧悜涓荤墿浠�
public class DragContainer : MonoBehaviour
{
public int pos;
+ public Transform mainTransform; // 涓昏妭鐐� Transform
}
diff --git a/Main/Component/UI/Common/DragItem.cs b/Main/Component/UI/Common/DragItem.cs
index 7cfee77..7ba9652 100644
--- a/Main/Component/UI/Common/DragItem.cs
+++ b/Main/Component/UI/Common/DragItem.cs
@@ -13,6 +13,8 @@
/// </summary>
public class DragItem:MonoBehaviour,ICanvasRaycastFilter,IBeginDragHandler,IDragHandler,IEndDragHandler
{
+ [SerializeField] public Canvas parentCanvas;
+ [SerializeField] public Canvas canvas;
// 鎷栨嫿鍖哄煙闄愬埗
[SerializeField]
RectTransform m_Area;
@@ -26,12 +28,13 @@
private set { m_RaycastTarget = value; }
}
- [SerializeField] public int pos;
+ [NonSerialized] public int pos;
- private Vector3 orgScale;
+ private DragContainer lastTransform;
// 褰撳墠瀵硅薄鐨凴ectTransform缁勪欢
- public RectTransform rectTransform { get { return this.transform as RectTransform; } }
+ RectTransform rectTransform { get { return this.transform as RectTransform; } }
+
/// <summary>
/// 寮�濮嬫嫋鎷芥椂璋冪敤
@@ -40,8 +43,10 @@
{
raycastTarget = false;
this.transform.position = UIUtility.ClampWorldPosition(area, eventData);
- orgScale = rectTransform.localScale;
- rectTransform.localScale = orgScale * 1.2f;
+ rectTransform.localScale = Vector3.one * 1.2f;
+
+ canvas.sortingLayerID = parentCanvas.sortingLayerID;
+ canvas.sortingOrder = parentCanvas.sortingOrder + pos + 10;
}
/// <summary>
@@ -51,21 +56,23 @@
this.transform.position = UIUtility.ClampWorldPosition(area,eventData);
// 妫�娴嬫槸鍚﹁繘鍏ョ洰鏍囧尯鍩�
- if (eventData.pointerEnter != null) {
- var target = eventData.pointerEnter.transform;
- if (target != null) {
- // 杩涘叆鐩爣鍖哄煙锛屾斁澶� 1.2 鍊�
- target.localScale = Vector3.one * 1.2f;
+ if (eventData.pointerEnter != null)
+ {
+ if (lastTransform != null && lastTransform != eventData.pointerEnter.GetComponent<DragContainer>())
+ {
+ lastTransform.mainTransform.localScale = Vector3.one;
+ lastTransform = null;
}
- } else {
- // 绂诲紑鐩爣鍖哄煙锛屾仮澶嶅ぇ灏�
- if (eventData.pointerPress != null) {
- var target = eventData.pointerPress.transform;
- if (target != null) {
- target.localScale = Vector3.one;
- }
+ var target = eventData.pointerEnter.GetComponent<DragContainer>();
+ // 杈撳嚭缁勪欢璺緞
+ if (target != null)
+ {
+ lastTransform = target;
+ // 杩涘叆鐩爣鍖哄煙锛屾斁澶� 1.2 鍊�
+ lastTransform.mainTransform.localScale = Vector3.one * 1.2f;
}
}
+ rectTransform.localScale = Vector3.one * 1.2f;
}
/// <summary>
@@ -73,10 +80,17 @@
/// </summary>
public Action<int, int> onEndDragEvent;
- public void OnEndDrag(PointerEventData eventData) {
+ public void OnEndDrag(PointerEventData eventData)
+ {
raycastTarget = true;
- rectTransform.localScale = orgScale;
+ rectTransform.localScale = Vector3.one;
+ if (lastTransform != null)
+ {
+ lastTransform.mainTransform.localScale = Vector3.one;
+ lastTransform = null;
+ }
+
if (eventData.pointerEnter == null)
{
onEndDragEvent?.Invoke(pos, -1);
@@ -84,16 +98,14 @@
}
var container = eventData.pointerEnter.GetComponent<DragContainer>();
- if(container == null) {
+ if (container == null)
+ {
onEndDragEvent?.Invoke(pos, -1);
return;
}
-
- // var contain = UIUtility.RectTransformContain(eventData.pointerEnter.transform as RectTransform,rectTransform);
- // if(contain) {
- // rectTransform.position = eventData.pointerEnter.transform.position;
- // }
onEndDragEvent?.Invoke(pos, container.pos);
+ canvas.sortingLayerID = parentCanvas.sortingLayerID;
+ canvas.sortingOrder = parentCanvas.sortingOrder + pos + 1;
}
/// <summary>
diff --git a/Main/Config/PartialConfigs/PlayerPropertyConfig.cs b/Main/Config/PartialConfigs/PlayerPropertyConfig.cs
index 2ba9d12..179c143 100644
--- a/Main/Config/PartialConfigs/PlayerPropertyConfig.cs
+++ b/Main/Config/PartialConfigs/PlayerPropertyConfig.cs
@@ -84,20 +84,20 @@
return string.Empty;
}
- if (config.Name.Contains("%s"))
+ if (config.ShowName.Contains("%s"))
{
if (id == 52)
{
- return Regex.Replace(config.Name, "%s", (value * 0.0001f).ToString("f2"));
+ return Regex.Replace(config.ShowName, "%s", (value * 0.0001f).ToString("f2"));
}
else
{
- return Regex.Replace(config.Name, "%s", value.ToString());
+ return Regex.Replace(config.ShowName, "%s", value.ToString());
}
}
else
{
- return string.Format("{0} +{1}", config.Name, GetValueDescription(id, value));
+ return string.Format("{0} +{1}", config.ShowName, GetValueDescription(id, value));
}
}
diff --git a/Main/System/HeroUI/HeroPosWin.cs b/Main/System/HeroUI/HeroPosWin.cs
index 473db70..8656678 100644
--- a/Main/System/HeroUI/HeroPosWin.cs
+++ b/Main/System/HeroUI/HeroPosWin.cs
@@ -93,6 +93,7 @@
RefreshOnTeamCountry();
RefreshOnTeamBtn();
RefreshTeamHero();
+ RefreshFlyHead();
if (HeroUIManager.Instance.heroOnTeamSortList.Count == 0)
{
@@ -109,9 +110,17 @@
fiterManager.Display(0, 0, 0, SelectJobCountry);
+
+ fightPowerText.text = "1234k";
+ }
+
+ void RefreshFlyHead()
+ {
+ var flyCanvas = flyAlphaTween.GetComponent<Canvas>();
+ flyCanvas.sortingLayerID = canvas.sortingLayerID;
+ flyCanvas.sortingOrder = canvas.sortingOrder + 9;
flyAlphaTween.alpha = 0;
flyHead.transform.localScale = Vector3.zero;
- fightPowerText.text = "1234k";
}
void SelectJobCountry(int job, int country)
@@ -197,6 +206,7 @@
}
}
+
}
//绠$悊甯冮樀鍏ュ彛鎸夐挳锛氬绔炴妧鍦烘槸鍚︽牴鎹姛鑳芥樉闅愶紝閫氬ぉ濉斿拰涓荤嚎鍙湁杩涙敾鏂瑰竷闃甸粯璁や笉鏄剧ず
@@ -240,12 +250,19 @@
sceneHero[i].Display(teamHero.guid, i);
//鎸塻cenePosImgs 椤哄簭鎺掑簭瀵瑰簲浣嶇疆
sceneHero[i].transform.position = scenePosImgs[i].transform.position;
-
+ sceneHero[i].transform.localScale = Vector3.one;
}
}
+ RefreshPosScale();
+ }
-
+ void RefreshPosScale()
+ {
+ for (int i = 0; i < scenePosImgs.Count; i++)
+ {
+ scenePosImgs[i].transform.localScale = Vector3.one;
+ }
}
/// <summary>
@@ -269,9 +286,12 @@
sceneHero[i].Display(teamHero.guid, i, flyFrom >= 0);
//鎸塻cenePosImgs 椤哄簭鎺掑簭瀵瑰簲浣嶇疆
sceneHero[i].transform.position = scenePosImgs[i].transform.position;
+ sceneHero[i].transform.localScale = Vector3.one;
}
}
+ RefreshPosScale();
+ heroListScroller.m_Scorller.RefreshActiveCellViews();
//琛ㄧ幇椋炲叆锛岃繛缁偣鍑讳笉鍚屽ご鍍忚Е鍙戠殑璇濆垯閲嶇疆
if (flyFrom > -1)
@@ -296,6 +316,7 @@
sequence.Append(flyHead.transform.DOMove(targetPos, HeroUIManager.clickFlyPosTime).SetEase(Ease.OutQuad))
.Join(flyHead.transform.DOScale(new Vector3(0.5f, 0.5f, 0.5f), HeroUIManager.clickFlyPosTime).SetEase(Ease.OutQuad))
.Join(flyAlphaTween.DOFade(0f, HeroUIManager.clickFlyPosTime).SetEase(Ease.OutQuad));
+ sequence.onComplete = () => { flyHead.transform.localScale = Vector3.zero; };
}
}
@@ -308,13 +329,9 @@
{
team.AddHero(HeroManager.Instance.GetHero(guidList[i]), i);
}
- List<int> posList = new List<int>();
- for (int i = 0; i < guidList.Count; i++)
- {
- posList.Add(i);
- }
- TeamChangeEvent(posList, -1, Vector3.zero);
- heroListScroller.m_Scorller.RefreshActiveCellViews();
+
+ TeamChangeEvent(new List<int>() { 0, 1, 2, 3, 4, 5 }, -1, Vector3.zero);
+
}
void SaveTeam()
diff --git a/Main/System/HeroUI/HeroScenePosCell.cs b/Main/System/HeroUI/HeroScenePosCell.cs
index 2cc5cd1..9846fdc 100644
--- a/Main/System/HeroUI/HeroScenePosCell.cs
+++ b/Main/System/HeroUI/HeroScenePosCell.cs
@@ -20,6 +20,7 @@
[SerializeField] DragItem dragObj;
[SerializeField] Transform objForfly; //鐐瑰嚮椋炲叆鐨勬椂鍊欑殑鏄鹃殣鎺у埗
+
public void Display(string guid, int index, bool isFly = false)
{
var hero = HeroManager.Instance.GetHero(guid);
@@ -46,7 +47,11 @@
suggestForm.SetActive(false);
}
+ dragObj.pos = index;
+ dragObj.onEndDragEvent -= SwitchPos;
dragObj.onEndDragEvent += SwitchPos;
+ dragObj.canvas.sortingLayerID = dragObj.parentCanvas.sortingLayerID;
+ dragObj.canvas.sortingOrder = dragObj.parentCanvas.sortingOrder + index + 1;
heroBtn.AddListener(() =>
{
@@ -72,6 +77,23 @@
void SwitchPos(int pos1, int pos2)
{
Debug.Log("浜ゆ崲浣嶇疆:" + pos1 + " " + pos2);
+ var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
+ if (pos2 == -1)
+ {
+ //涓嬮樀
+ team.RemoveHero(pos1);
+ HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos1 }, -1, Vector3.zero);
+ }
+ else if (pos1 == pos2)
+ {
+ HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos1 }, -1, Vector3.zero);
+ }
+ else
+ {
+ //閫氱煡鍒锋柊
+ team.SwapPosition(pos1, pos2);
+ HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos1, pos2 }, -1, Vector3.zero);
+ }
}
async UniTask DelayShow()
--
Gitblit v1.8.0