超大量的更新 修复很多问题,gameplay特效初步
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RatioBar : MonoBehaviour
|
||||
{
|
||||
[Header("子Image组件")]
|
||||
public Image bar1; // 红色段
|
||||
public Image bar2; // 橘色段
|
||||
public Image bar3; // 黄色段
|
||||
public Image bar4; // 第四段
|
||||
[Header("Inspector")]
|
||||
public Image bar1; // Documentation text normalized.
|
||||
public Image bar2; // Documentation text normalized.
|
||||
public Image bar3; // Documentation text normalized.
|
||||
public Image bar4; // Documentation text normalized.
|
||||
|
||||
[Header("分割点 (0-1)")]
|
||||
[Range(0, 1)] public float ratio1 = 0.3f; // 颜色1结束位置
|
||||
[Range(0, 1)] public float ratio2 = 0.6f; // 颜色2结束位置
|
||||
[Range(0, 1)] public float ratio3 = 1.0f; // 颜色3结束位置,必须为1
|
||||
[Header("Inspector")]
|
||||
[Range(0, 1)] public float ratio1 = 0.3f; // Documentation text normalized.
|
||||
[Range(0, 1)] public float ratio2 = 0.6f; // Documentation text normalized.
|
||||
[Range(0, 1)] public float ratio3 = 1.0f; // Documentation text normalized.
|
||||
|
||||
[Header("长度控制")]
|
||||
public float totalLength = 400f; // 前三个bar的总长度
|
||||
public float bar4Length = 50f; // bar4的单独长度
|
||||
[Header("Inspector")]
|
||||
public float totalLength = 400f; // Documentation text normalized.
|
||||
public float bar4Length = 50f; // Documentation text normalized.
|
||||
|
||||
[Header("高度控制")]
|
||||
public float barHeight = 50f; // 四个bar的统一高度
|
||||
[Header("Inspector")]
|
||||
public float barHeight = 50f; // Documentation text normalized.
|
||||
|
||||
[Header("颜色设置")]
|
||||
[Header("Inspector")]
|
||||
public Color color1 = Color.red;
|
||||
public Color color2 = new Color(1f, 0.5f, 0f); // 橘色
|
||||
public Color color2 = new Color(1f, 0.5f, 0f); // Documentation text normalized.
|
||||
public Color color3 = Color.yellow;
|
||||
public Color color4 = Color.green; // 第四段颜色
|
||||
public Color color4 = Color.green; // Documentation text normalized.
|
||||
|
||||
private float lastRatio1, lastRatio2, lastRatio3, lastTotalLength, lastBar4Length, lastBarHeight;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class RatioBar : MonoBehaviour
|
||||
{
|
||||
if (bar1 == null || bar2 == null || bar3 == null || bar4 == null) return;
|
||||
|
||||
// 检查值是否改变,避免不必要的更新
|
||||
// Documentation text normalized.
|
||||
if (ratio1 == lastRatio1 && ratio2 == lastRatio2 && ratio3 == lastRatio3 && totalLength == lastTotalLength && bar4Length == lastBar4Length && barHeight == lastBarHeight) return;
|
||||
|
||||
lastRatio1 = ratio1;
|
||||
@@ -56,25 +56,25 @@ public class RatioBar : MonoBehaviour
|
||||
lastBar4Length = bar4Length;
|
||||
lastBarHeight = barHeight;
|
||||
|
||||
// 强制ratio3为1,确保三个颜色加起来正好是1
|
||||
// Documentation text normalized.
|
||||
ratio3 = 1.0f;
|
||||
|
||||
// 确保顺序
|
||||
// Documentation text normalized.
|
||||
ratio1 = Mathf.Clamp(ratio1, 0, ratio2);
|
||||
ratio2 = Mathf.Clamp(ratio2, ratio1, 1);
|
||||
|
||||
// 获取父对象的RectTransform
|
||||
// Documentation text normalized.
|
||||
RectTransform parentRect = GetComponent<RectTransform>();
|
||||
|
||||
// 设置父对象大小为totalLength + bar4Length 宽度,barHeight 高度
|
||||
// Documentation text normalized.
|
||||
parentRect.sizeDelta = new Vector2(totalLength + bar4Length, barHeight);
|
||||
|
||||
// 计算段长(基于totalLength)
|
||||
// Documentation text normalized.
|
||||
float len1 = ratio1 * totalLength;
|
||||
float len2 = (ratio2 - ratio1) * totalLength;
|
||||
float len3 = (ratio3 - ratio2) * totalLength;
|
||||
|
||||
// 设置每个bar的大小和位置
|
||||
// Documentation text normalized.
|
||||
bar1.rectTransform.sizeDelta = new Vector2(len1, barHeight);
|
||||
bar2.rectTransform.sizeDelta = new Vector2(len2, barHeight);
|
||||
bar3.rectTransform.sizeDelta = new Vector2(len3, barHeight);
|
||||
@@ -85,14 +85,14 @@ public class RatioBar : MonoBehaviour
|
||||
bar3.rectTransform.anchoredPosition = new Vector2(len1 + len2, 0);
|
||||
bar4.rectTransform.anchoredPosition = new Vector2(totalLength, 0);
|
||||
|
||||
// 设置颜色
|
||||
// Documentation text normalized.
|
||||
bar1.color = color1;
|
||||
bar2.color = color2;
|
||||
bar3.color = color3;
|
||||
bar4.color = color4;
|
||||
}
|
||||
|
||||
// 设置manaGain和damageMulti文本
|
||||
// Documentation text normalized.
|
||||
public void SetManaAndDamage(AllyHero_SO heroSO)
|
||||
{
|
||||
if (heroSO == null) return;
|
||||
@@ -100,21 +100,21 @@ public class RatioBar : MonoBehaviour
|
||||
var levelInfo = heroSO.GetEffectiveLevelForCurrentEXP();
|
||||
if (levelInfo == null) return;
|
||||
|
||||
// 设置manaGain
|
||||
// Documentation text normalized.
|
||||
if (manaGain_miss != null) manaGain_miss.text = levelInfo.manaGainOnMiss.ToString();
|
||||
if (manaGain_good != null) manaGain_good.text = levelInfo.manaGainGood.ToString();
|
||||
if (manaGain_great != null) manaGain_great.text = levelInfo.manaGainGreat.ToString();
|
||||
if (manaGain_perfect != null) manaGain_perfect.text = levelInfo.manaGainPerfect.ToString();
|
||||
|
||||
// 设置damageMulti
|
||||
// Documentation text normalized.
|
||||
if (damageMulti_miss != null) damageMulti_miss.text = "0";
|
||||
if (damageMulti_good != null) damageMulti_good.text = levelInfo.damageMultiplierGood.ToString();
|
||||
if (damageMulti_great != null) damageMulti_great.text = levelInfo.damageMultiplierGreat.ToString();
|
||||
if (damageMulti_perfect != null) damageMulti_perfect.text = levelInfo.damageMultiplierPerfect.ToString();
|
||||
|
||||
// 设置ratio
|
||||
// Documentation text normalized.
|
||||
ratio1 = levelInfo.damageMultiplierGood;
|
||||
ratio2 = levelInfo.damageMultiplierGreat;
|
||||
ratio3 = levelInfo.damageMultiplierPerfect;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class basicInfoBars : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
// 设置攻击进度条
|
||||
// Documentation text normalized.
|
||||
public void SetAttack(int value)
|
||||
{
|
||||
if (attackImage != null)
|
||||
@@ -46,7 +46,7 @@ public class basicInfoBars : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 设置最大HP进度条
|
||||
// Documentation text normalized.
|
||||
public void SetMaxHP(int value)
|
||||
{
|
||||
if (maxHP_Image != null)
|
||||
@@ -56,7 +56,7 @@ public class basicInfoBars : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 设置伤害抗性进度条
|
||||
// Documentation text normalized.
|
||||
public void SetDamageResistance(float value)
|
||||
{
|
||||
if (damageResistanceImage != null)
|
||||
@@ -66,7 +66,7 @@ public class basicInfoBars : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 设置基础法力进度条
|
||||
// Documentation text normalized.
|
||||
public void SetBasicMana(int value)
|
||||
{
|
||||
if (basicManaImage != null)
|
||||
@@ -76,7 +76,7 @@ public class basicInfoBars : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 设置分数效率进度条
|
||||
// Documentation text normalized.
|
||||
public void SetScoreEfficiency(float value)
|
||||
{
|
||||
if (scoreEffeciencyImage != null)
|
||||
@@ -86,7 +86,7 @@ public class basicInfoBars : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 设置Miss伤害进度条
|
||||
// Documentation text normalized.
|
||||
public void SetMissDamage(int value)
|
||||
{
|
||||
if (missDamageImage != null)
|
||||
@@ -96,7 +96,7 @@ public class basicInfoBars : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 设置技能数量限制进度条
|
||||
// Documentation text normalized.
|
||||
public void SetSkillAmountLimit(int value)
|
||||
{
|
||||
if (skillAmountLimitImage != null)
|
||||
|
||||
+21
-21
@@ -1,31 +1,31 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class character_detailInformation : MonoBehaviour
|
||||
{
|
||||
[Header("立绘HD")]
|
||||
[Header("Inspector")]
|
||||
public Image character_HDImage;
|
||||
public Image character_HDImage_shadow;
|
||||
[Header("so")]
|
||||
public ScriptableObject characterSO;
|
||||
[Header("基础信息文本")]
|
||||
[Header("Inspector")]
|
||||
public Text basic_infoText;
|
||||
public Text designation_name_combination;
|
||||
[Header("进度条控制器")]
|
||||
[Header("Inspector")]
|
||||
public basicInfoBars infoBars;
|
||||
[Header("等级条控制器")]
|
||||
[Header("Inspector")]
|
||||
public levelBar_controller levelBar;
|
||||
[Header("RatioBar控制器")]
|
||||
[Header("Inspector")]
|
||||
public RatioBar ratioBar;
|
||||
[Header("shutdown")]
|
||||
public Button shut_button;
|
||||
[Header("主题色渐变底图")]
|
||||
[Header("Inspector")]
|
||||
public Image mainTheme_fadeImage;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
// 添加关闭按钮监听器
|
||||
// Documentation text normalized.
|
||||
if (shut_button != null)
|
||||
{
|
||||
shut_button.onClick.AddListener(ShutDown);
|
||||
@@ -33,25 +33,25 @@ public class character_detailInformation : MonoBehaviour
|
||||
|
||||
if (characterSO is AllyHero_SO heroSO)
|
||||
{
|
||||
// 设置HD图像
|
||||
// Documentation text normalized.
|
||||
if (character_HDImage != null && heroSO.ally_hero_HD_image != null)
|
||||
{
|
||||
character_HDImage.sprite = heroSO.ally_hero_HD_image;
|
||||
}
|
||||
|
||||
// 设置HD阴影图像
|
||||
// Documentation text normalized.
|
||||
if (character_HDImage_shadow != null && heroSO.ally_hero_HD_image != null)
|
||||
{
|
||||
character_HDImage_shadow.sprite = heroSO.ally_hero_HD_image;
|
||||
}
|
||||
|
||||
// 组合称号和名字
|
||||
// Documentation text normalized.
|
||||
if (designation_name_combination != null)
|
||||
{
|
||||
designation_name_combination.text = $"{heroSO.ally_heroDesignation} {heroSO.ally_heroName}";
|
||||
}
|
||||
|
||||
// 获取当前等级数据
|
||||
// Documentation text normalized.
|
||||
var levelInfo = heroSO.GetEffectiveLevelForCurrentEXP();
|
||||
if (levelInfo != null)
|
||||
{
|
||||
@@ -63,13 +63,13 @@ public class character_detailInformation : MonoBehaviour
|
||||
float missHpLoss = levelInfo.missHpLossBase;
|
||||
int skillSlotLimited = levelInfo.skill_slot_limited;
|
||||
|
||||
// 输出到basic_infoText
|
||||
// Documentation text normalized.
|
||||
if (basic_infoText != null)
|
||||
{
|
||||
basic_infoText.text = $"{attack}\n{maxHP}\n{damageResistance * 100}%\n{maxMana}\n{scoreEfficiency * 100}%\n{skillSlotLimited}\n{missHpLoss}";
|
||||
}
|
||||
|
||||
// 交给basicInfoBars设置进度条
|
||||
// Documentation text normalized.
|
||||
if (infoBars != null)
|
||||
{
|
||||
infoBars.SetAttack(attack);
|
||||
@@ -78,27 +78,27 @@ public class character_detailInformation : MonoBehaviour
|
||||
infoBars.SetBasicMana(maxMana);
|
||||
infoBars.SetScoreEfficiency(scoreEfficiency);
|
||||
infoBars.SetSkillAmountLimit(skillSlotLimited);
|
||||
infoBars.SetMissDamage((int)missHpLoss); // 假设missDamage是int
|
||||
infoBars.SetMissDamage((int)missHpLoss); // Documentation text normalized.
|
||||
}
|
||||
|
||||
// 设置等级条
|
||||
// Documentation text normalized.
|
||||
if (levelBar != null)
|
||||
{
|
||||
levelBar.SetLevelBar(heroSO);
|
||||
}
|
||||
|
||||
// 设置RatioBar
|
||||
// Documentation text normalized.
|
||||
if (ratioBar != null)
|
||||
{
|
||||
ratioBar.SetManaAndDamage(heroSO);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置主题色渐变底图
|
||||
// Documentation text normalized.
|
||||
if (mainTheme_fadeImage != null)
|
||||
{
|
||||
Color themeColor = heroSO.ally_heroThemeColor;
|
||||
themeColor.a = 1f; // 确保透明度为1,使其可见
|
||||
themeColor.a = 1f; // Documentation text normalized.
|
||||
mainTheme_fadeImage.color = themeColor;
|
||||
}
|
||||
}
|
||||
@@ -110,9 +110,9 @@ public class character_detailInformation : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
// 关闭按钮点击事件:销毁整个prefab
|
||||
// Documentation text normalized.
|
||||
private void ShutDown()
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class levelBar_controller : MonoBehaviour
|
||||
{
|
||||
[Header("前后等级图")]
|
||||
[Header("Inspector")]
|
||||
public Image pre_levelIcon_image;
|
||||
public Image post_levelIcon_image;
|
||||
[Header("CBAS")]
|
||||
@@ -12,7 +12,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
public Sprite icon_b;
|
||||
public Sprite icon_a;
|
||||
public Sprite icon_s;
|
||||
[Header("控制fill amount")]
|
||||
[Header("Inspector")]
|
||||
public Image C_image;
|
||||
public Image B_image;
|
||||
public Image A_image;
|
||||
@@ -25,7 +25,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
// 初始化CBAS images的fillAmount为0
|
||||
// Documentation text normalized.
|
||||
/* if (C_image != null) C_image.fillAmount = 0f;
|
||||
if (B_image != null) B_image.fillAmount = 0f;
|
||||
if (A_image != null) A_image.fillAmount = 0f;
|
||||
@@ -38,7 +38,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
// 设置等级条
|
||||
// Documentation text normalized.
|
||||
public void SetLevelBar(AllyHero_SO heroSO)
|
||||
{
|
||||
if (heroSO == null || heroSO.levelStats == null || heroSO.levelStats.Count == 0) return;
|
||||
@@ -49,13 +49,13 @@ public class levelBar_controller : MonoBehaviour
|
||||
string currentLevel = GetRatingFromSO(heroSO);
|
||||
int currentIndex = GetIndex(currentLevel);
|
||||
|
||||
// 设置前等级icon
|
||||
// Documentation text normalized.
|
||||
if (pre_levelIcon_image != null)
|
||||
{
|
||||
pre_levelIcon_image.sprite = GetLevelSprite(currentLevel);
|
||||
}
|
||||
|
||||
// 设置后等级icon
|
||||
// Documentation text normalized.
|
||||
if (post_levelIcon_image != null)
|
||||
{
|
||||
if (currentIndex < 3)
|
||||
@@ -73,7 +73,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
|
||||
int currentEXP = heroSO.ally_currentEXP;
|
||||
|
||||
// 设置fill amount
|
||||
// Documentation text normalized.
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
Image img = GetImage(i);
|
||||
@@ -85,7 +85,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
}
|
||||
else if (i == currentIndex)
|
||||
{
|
||||
if (currentIndex == 3) // S级满级
|
||||
if (currentIndex == 3) // Documentation text normalized.
|
||||
{
|
||||
img.fillAmount = 1f;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
int nextRequired = heroSO.levelStats[currentIndex + 1].requiredEXP;
|
||||
if (currentEXP == nextRequired)
|
||||
{
|
||||
img.fillAmount = 0f; // 相等但非满级,设为0
|
||||
img.fillAmount = 0f; // Documentation text normalized.
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -108,7 +108,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 设置ratioText
|
||||
// Documentation text normalized.
|
||||
if (ratioText != null)
|
||||
{
|
||||
if (currentIndex < 3)
|
||||
@@ -122,23 +122,23 @@ public class levelBar_controller : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 设置remainingExpText
|
||||
// Documentation text normalized.
|
||||
if (remainingExpText != null)
|
||||
{
|
||||
if (currentIndex < 3)
|
||||
{
|
||||
int nextRequired = heroSO.levelStats[currentIndex + 1].requiredEXP;
|
||||
int remaining = nextRequired - currentEXP;
|
||||
remainingExpText.text = $"还需{remaining}经验升级";
|
||||
remainingExpText.text = $"还需{remaining}经验升级";
|
||||
}
|
||||
else
|
||||
{
|
||||
remainingExpText.text = "等级满";
|
||||
remainingExpText.text = "等级满";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取等级对应的sprite
|
||||
// Documentation text normalized.
|
||||
private Sprite GetLevelSprite(string level)
|
||||
{
|
||||
switch (level)
|
||||
@@ -151,7 +151,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 获取等级索引
|
||||
// Documentation text normalized.
|
||||
private int GetIndex(string level)
|
||||
{
|
||||
switch (level)
|
||||
@@ -164,7 +164,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 获取下一等级
|
||||
// Documentation text normalized.
|
||||
private string GetNextLevel(string level)
|
||||
{
|
||||
switch (level)
|
||||
@@ -176,7 +176,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 获取对应等级的Image
|
||||
// Documentation text normalized.
|
||||
private Image GetImage(int index)
|
||||
{
|
||||
switch (index)
|
||||
@@ -189,7 +189,7 @@ public class levelBar_controller : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 获取角色等级字符串(与loadTeam_select.cs一致)
|
||||
// Documentation text normalized.
|
||||
private string GetRatingFromSO(AllyHero_SO so)
|
||||
{
|
||||
if (so == null || so.levelStats == null || so.levelStats.Count == 0) return "C";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class loadDetailsPrefab : MonoBehaviour
|
||||
@@ -12,16 +12,16 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
[Header("Settings")]
|
||||
public float hoverDelay = 0.5f;
|
||||
|
||||
[Tooltip("ƫ�����������Ļ���ߵİٷֱ� (0.01 = 1%)")]
|
||||
[Tooltip("Documentation text normalized.")]
|
||||
public Vector2 offsetPercent = new Vector2(0f, -0.03f);
|
||||
|
||||
[Tooltip("��Сƫ������ֵ")]
|
||||
[Tooltip("Documentation text normalized.")]
|
||||
public Vector2 minOffsetPixels = new Vector2(0f, -50f);
|
||||
|
||||
private GameObject currentDetailsInstance;
|
||||
private detailsPrefabController currentController;
|
||||
private Coroutine showCoroutine;
|
||||
private bool isAbove; // �Ƿ����Ϸ���ʾ
|
||||
private bool isAbove; // Documentation text normalized.
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -37,7 +37,7 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
|
||||
if (detailsPrefab == null) return;
|
||||
|
||||
isAbove = (type == "����"); // �������Ϸ���Ӣ�����·�
|
||||
isAbove = (type == "技能"); // Documentation text normalized.
|
||||
|
||||
showCoroutine = StartCoroutine(ShowDetailsDelayed(type, name, status, description, position));
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
if (currentController.item_statusText != null)
|
||||
{
|
||||
Color statusColor;
|
||||
if (status == "���ܿ���" || status == "������ѡ��" || status == "����")
|
||||
if (status == "可装备" || status == "已装备" || status == "可用")
|
||||
{
|
||||
statusColor = currentController.availableColor;
|
||||
}
|
||||
@@ -96,36 +96,35 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
|
||||
RectTransform canvasRect = canvas.GetComponent<RectTransform>();
|
||||
|
||||
// ���㶯̬ƫ��������ֱ����һ�´�С��
|
||||
// Documentation text normalized.
|
||||
Vector2 dynamicOffset = CalculateDynamicOffset();
|
||||
Vector2 baseScreenPos = new Vector2(position.x, position.y) + dynamicOffset;
|
||||
|
||||
// ���� prefab ���ȣ���Ļ���أ����������ˮƽλ��Ϊ prefab ���ȣ�֮ǰΪһ�룩
|
||||
// Documentation text normalized.
|
||||
float prefWidthPixels = rt.rect.width * (canvas != null ? canvas.scaleFactor : 1f);
|
||||
float maxNudge = prefWidthPixels*4; // now allow up to full prefab width
|
||||
|
||||
// ����Ļ����Ϊ���������ˮƽƫ������ (-1..1)
|
||||
// Documentation text normalized.
|
||||
float screenCenterX = Screen.width * 0.5f;
|
||||
float normalized = 0f;
|
||||
if (screenCenterX > 0f)
|
||||
normalized = (position.x - screenCenterX) / screenCenterX; // -1(left) .. 0(center) .. +1(right)
|
||||
normalized = Mathf.Clamp(normalized, -1f, 1f);
|
||||
|
||||
// nudge ����Ϊ����Ļ�����ƶ�����������(normalized<0)ʱ�������ƶ� (+)���Ҳ��෴
|
||||
// Documentation text normalized.
|
||||
float nudge = -normalized * maxNudge;
|
||||
Vector2 screenPos = baseScreenPos + new Vector2(nudge, 0f);
|
||||
|
||||
Vector3 initialPos = CalculateWorldPos(screenPos, canvas, canvasRect, rt);
|
||||
|
||||
// �����ʼλ�ó������������Է�ת���·������¼��㣨������ͬ��ֱ��ࣩ
|
||||
// Documentation text normalized.
|
||||
if (IsOutOfCanvas(initialPos, rt, canvas))
|
||||
{
|
||||
isAbove = !isAbove;
|
||||
dynamicOffset = CalculateDynamicOffset();
|
||||
baseScreenPos = new Vector2(position.x, position.y) + dynamicOffset;
|
||||
|
||||
// ���¼��� nudge������ԭʼ���λ����Ȼ��Ч��
|
||||
normalized = 0f;
|
||||
// Documentation text normalized.
|
||||
if (screenCenterX > 0f)
|
||||
normalized = (position.x - screenCenterX) / screenCenterX;
|
||||
normalized = Mathf.Clamp(normalized, -1f, 1f);
|
||||
@@ -137,7 +136,7 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
|
||||
rt.position = initialPos;
|
||||
|
||||
// ���յ�����ȷ����������������ʣ�������/���±߽磩
|
||||
// Documentation text normalized.
|
||||
AdjustPositionWithinCanvas(rt, canvas);
|
||||
}
|
||||
|
||||
@@ -181,43 +180,43 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
float canvasBottom = canvasCorners[0].y;
|
||||
float canvasTop = canvasCorners[2].y;
|
||||
|
||||
// ��ʱ����λ���Ի�ȡ����
|
||||
// Documentation text normalized.
|
||||
Vector3 originalPos = rt.position;
|
||||
rt.position = pos;
|
||||
Vector3[] rtCorners = new Vector3[4];
|
||||
rt.GetWorldCorners(rtCorners);
|
||||
rt.position = originalPos;
|
||||
|
||||
// ����Ƿ���ȫ�� Canvas ��
|
||||
// Documentation text normalized.
|
||||
return rtCorners[0].x < canvasLeft || rtCorners[2].x > canvasRight ||
|
||||
rtCorners[0].y < canvasBottom || rtCorners[2].y > canvasTop;
|
||||
}
|
||||
|
||||
private Vector2 CalculateDynamicOffset()
|
||||
{
|
||||
// ��ȡ��ǰ��Ļ�ֱ���
|
||||
// Documentation text normalized.
|
||||
float screenWidth = Screen.width;
|
||||
float screenHeight = Screen.height;
|
||||
|
||||
// ������ڰٷֱȵ�ƫ��
|
||||
// Documentation text normalized.
|
||||
Vector2 percentOffset = new Vector2(
|
||||
screenWidth * offsetPercent.x,
|
||||
screenHeight * offsetPercent.y
|
||||
);
|
||||
|
||||
// ������Ϸ�����תYƫ��
|
||||
// Documentation text normalized.
|
||||
if (isAbove)
|
||||
{
|
||||
percentOffset.y = -percentOffset.y;
|
||||
}
|
||||
|
||||
// Ӧ����С����ƫ������
|
||||
// Documentation text normalized.
|
||||
Vector2 finalOffset = new Vector2(
|
||||
Mathf.Abs(percentOffset.x) > Mathf.Abs(minOffsetPixels.x) ? percentOffset.x : minOffsetPixels.x,
|
||||
Mathf.Abs(percentOffset.y) > Mathf.Abs(minOffsetPixels.y) ? percentOffset.y : minOffsetPixels.y
|
||||
);
|
||||
|
||||
// ������Ϸ���ȷ��Yƫ��Ϊ��
|
||||
// Documentation text normalized.
|
||||
if (isAbove)
|
||||
{
|
||||
finalOffset.y = Mathf.Abs(finalOffset.y);
|
||||
@@ -260,13 +259,13 @@ public class loadDetailsPrefab : MonoBehaviour
|
||||
|
||||
Vector3 adjustedPos = rt.position;
|
||||
|
||||
// ����ˮƽλ��
|
||||
// Documentation text normalized.
|
||||
if (rtCorners[2].x > canvasRight)
|
||||
adjustedPos.x -= (rtCorners[2].x - canvasRight);
|
||||
if (rtCorners[0].x < canvasLeft)
|
||||
adjustedPos.x += (canvasLeft - rtCorners[0].x);
|
||||
|
||||
// ������ֱλ��
|
||||
// Documentation text normalized.
|
||||
if (rtCorners[2].y > canvasTop)
|
||||
adjustedPos.y -= (rtCorners[2].y - canvasTop);
|
||||
if (rtCorners[0].y < canvasBottom)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -14,8 +14,8 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
|
||||
[Header("Column Layout Settings")]
|
||||
public float columnSpacing = 10f; // Spacing between items in a column
|
||||
public float columnWidth = 200f; // 宽度控制 (RectTransform width)
|
||||
public float columnPosX = 0f; // 位置控制 (RectTransform pos x)
|
||||
public float columnWidth = 200f; // Documentation text normalized.
|
||||
public float columnPosX = 0f; // Documentation text normalized.
|
||||
public TextAnchor columnChildAlignment = TextAnchor.MiddleLeft; // Alignment of children in the column
|
||||
public bool columnChildControlWidth = false; // Whether to control child width
|
||||
public bool columnChildControlHeight = false; // Whether to control child height
|
||||
@@ -44,7 +44,7 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
public bool skillCardControlMinHeight = false;
|
||||
public int skillCardMinHeight = -1; // Minimum height for skill cards (-1 to ignore)
|
||||
|
||||
// ��ǰ���ص�Ӣ��SO�����ڼ��ܿ�Ƭ����equippedSkillGroupIDs
|
||||
// Documentation text normalized.
|
||||
public AllyHero_SO currentHeroSO { get; private set; }
|
||||
|
||||
void Awake()
|
||||
@@ -81,7 +81,7 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 缓存 AllyHero_SO 数组以避免在 UI 刷新时重复调用昂贵的 Resources.LoadAll
|
||||
// Documentation text normalized.
|
||||
private static AllyHero_SO[] _cachedAllyHeroSOs;
|
||||
|
||||
// Load skill groups for a given hero SO id and instantiate skill card prefabs
|
||||
@@ -133,9 +133,8 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
currentHeroSO = found; // ���õ�ǰӢ��SO
|
||||
|
||||
// ��columnID���鼼����
|
||||
currentHeroSO = found; // Documentation text normalized.
|
||||
// Documentation text normalized.
|
||||
var groupsByColumn = new System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<SkillGroup>>();
|
||||
foreach (var g in found.skillGroups)
|
||||
{
|
||||
@@ -144,7 +143,7 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
groupsByColumn[g.columnID].Add(g);
|
||||
}
|
||||
|
||||
// ��columnID����
|
||||
// Documentation text normalized.
|
||||
var sortedColumns = groupsByColumn.Keys.ToList();
|
||||
sortedColumns.Sort();
|
||||
|
||||
@@ -154,7 +153,7 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
var columnGroups = groupsByColumn[colId];
|
||||
var columnName = columnGroups.Count > 0 ? columnGroups[0].columnName : $"Column {colId}";
|
||||
|
||||
// 如果不是以特殊字符开头(即以汉字、英文或数字开头),则加入两个空格
|
||||
// Documentation text normalized.
|
||||
string displayColumnName = columnName;
|
||||
if (!string.IsNullOrEmpty(columnName))
|
||||
{
|
||||
@@ -166,24 +165,24 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 实例化column容器
|
||||
// Documentation text normalized.
|
||||
var columnContainer = new GameObject($"Column_{colId}", typeof(RectTransform));
|
||||
columnContainer.transform.SetParent(contentParent, false);
|
||||
|
||||
// 应用RectTransform参数
|
||||
// Documentation text normalized.
|
||||
RectTransform colRt = columnContainer.GetComponent<RectTransform>();
|
||||
colRt.sizeDelta = new Vector2(columnWidth, colRt.sizeDelta.y);
|
||||
colRt.anchoredPosition = new Vector2(columnPosX, colRt.anchoredPosition.y);
|
||||
|
||||
var vlg = columnContainer.AddComponent<UnityEngine.UI.VerticalLayoutGroup>();
|
||||
vlg.spacing = columnVerticalSpacing; // ��ֱ��࣬�ɵ���
|
||||
vlg.childAlignment = TextAnchor.UpperLeft; // ���뷽ʽ
|
||||
vlg.childControlWidth = true; // ������Ԫ�ؿ���
|
||||
vlg.childControlHeight = false; // ��������Ԫ�ظ߶�
|
||||
vlg.childForceExpandWidth = false; // ��ǿ����չ����
|
||||
vlg.childForceExpandHeight = false; // ��ǿ����չ�߶�
|
||||
vlg.spacing = columnVerticalSpacing; // Documentation text normalized.
|
||||
vlg.childAlignment = TextAnchor.UpperLeft; // Documentation text normalized.
|
||||
vlg.childControlWidth = true; // Documentation text normalized.
|
||||
vlg.childControlHeight = false; // Documentation text normalized.
|
||||
vlg.childForceExpandWidth = false; // Documentation text normalized.
|
||||
vlg.childForceExpandHeight = false; // Documentation text normalized.
|
||||
|
||||
// ʵ������Ŀ����
|
||||
// Documentation text normalized.
|
||||
if (columnHeaderPrefab != null)
|
||||
{
|
||||
var headerGo = Instantiate(columnHeaderPrefab, columnContainer.transform);
|
||||
@@ -202,21 +201,21 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// ������������
|
||||
// Documentation text normalized.
|
||||
var skillsContainer = new GameObject("SkillsContainer");
|
||||
skillsContainer.transform.SetParent(columnContainer.transform, false);
|
||||
var hlg = skillsContainer.AddComponent<UnityEngine.UI.HorizontalLayoutGroup>();
|
||||
hlg.spacing = columnSpacing; // ���ü��
|
||||
hlg.childAlignment = columnChildAlignment; // ���뷽ʽ
|
||||
hlg.childControlWidth = columnChildControlWidth; // ������Ԫ�ؿ���
|
||||
hlg.childControlHeight = columnChildControlHeight; // ������Ԫ�ظ߶�
|
||||
hlg.spacing = columnSpacing; // Documentation text normalized.
|
||||
hlg.childAlignment = columnChildAlignment; // Documentation text normalized.
|
||||
hlg.childControlWidth = columnChildControlWidth; // Documentation text normalized.
|
||||
hlg.childControlHeight = columnChildControlHeight; // Documentation text normalized.
|
||||
hlg.childScaleWidth = columnChildScaleWidth;
|
||||
hlg.childScaleHeight = columnChildScaleHeight;
|
||||
hlg.childForceExpandWidth = columnChildForceExpandWidth;
|
||||
hlg.childForceExpandHeight = columnChildForceExpandHeight;
|
||||
hlg.padding = new UnityEngine.RectOffset(columnPaddingLeft, columnPaddingRight, columnPaddingTop, columnPaddingBottom); // ����padding
|
||||
hlg.padding = new UnityEngine.RectOffset(columnPaddingLeft, columnPaddingRight, columnPaddingTop, columnPaddingBottom); // Documentation text normalized.
|
||||
|
||||
// ʵ��������Ŀ�ļ��ܿ�Ƭ
|
||||
// Documentation text normalized.
|
||||
foreach (var g in columnGroups)
|
||||
{
|
||||
if (g == null) continue;
|
||||
@@ -310,3 +309,4 @@ public class loadSkillsSelect : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
#if UNITY_EDITOR
|
||||
@@ -128,7 +128,7 @@ public class loadTeam_select : MonoBehaviour
|
||||
ctrl.roleCard_bottomImage.color = ctrl.bottomImage_colors[colorIdx];
|
||||
}
|
||||
|
||||
// 每实例化 2 个卡片等待一帧,避免瞬时大量实例化导致的掉帧
|
||||
// Documentation text normalized.
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
@@ -10,7 +10,7 @@ public class roleCard_prefabController : MonoBehaviour, IDropHandler, IBeginDrag
|
||||
public Image roleCard_bottomImage;
|
||||
public int roleCard_heroID;
|
||||
[Header("SO Reference")]
|
||||
[SerializeField] public AllyHero_SO heroSO; // 自动装入对应角色的SO
|
||||
[SerializeField] public AllyHero_SO heroSO; // Documentation text normalized.
|
||||
[Header("color")]
|
||||
public Color[] bottomImage_colors = new Color[4]
|
||||
{
|
||||
@@ -69,7 +69,7 @@ public class roleCard_prefabController : MonoBehaviour, IDropHandler, IBeginDrag
|
||||
var foundSO = FindAllyHeroSOById(roleCard_heroID);
|
||||
if (foundSO != null)
|
||||
{
|
||||
heroSO = foundSO; // 自动装入对应角色的SO
|
||||
heroSO = foundSO; // Documentation text normalized.
|
||||
// keep role card showing profile / select icon, not the poster
|
||||
if (roleCard_heroProfile != null)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ public class roleCard_prefabController : MonoBehaviour, IDropHandler, IBeginDrag
|
||||
// ---------------- Drag implementation so roleCard entries can be dragged as source ----------------
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
// 如果有heroID但heroSO未设置,查找并设置heroSO
|
||||
// Documentation text normalized.
|
||||
if (roleCard_heroID > 0 && heroSO == null)
|
||||
{
|
||||
heroSO = FindAllyHeroSOById(roleCard_heroID);
|
||||
@@ -159,22 +159,22 @@ public class roleCard_prefabController : MonoBehaviour, IDropHandler, IBeginDrag
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标悬停进入:显示详细信息
|
||||
// Documentation text normalized.
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (loadDetailsPrefab.Instance == null) return;
|
||||
|
||||
if (heroSO == null) return;
|
||||
|
||||
string type = "角色";
|
||||
string name = heroSO.ally_heroName ?? "未知角色";
|
||||
string status = "可用"; // 可以根据逻辑判断
|
||||
string description = heroSO.ally_heroDescription ?? "无描述";
|
||||
string type = "角色";
|
||||
string name = heroSO.ally_heroName ?? "未知角色";
|
||||
string status = "可用"; // Documentation text normalized.
|
||||
string description = heroSO.ally_heroDescription ?? "无描述";
|
||||
|
||||
loadDetailsPrefab.Instance.ShowDetails(type, name, status, description, Input.mousePosition);
|
||||
}
|
||||
|
||||
// 鼠标悬停离开:隐藏详细信息
|
||||
// Documentation text normalized.
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (loadDetailsPrefab.Instance != null)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System.Collections.Generic;
|
||||
@@ -35,7 +35,7 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
|
||||
public GameObject skillCardPrefab; // Prefab for skill cards, should have slots_skillSlots component
|
||||
|
||||
[Header("等级图片CBAS")]
|
||||
[Header("Inspector")]
|
||||
public Sprite levelIcon_sprite_C;
|
||||
public Sprite levelIcon_sprite_B;
|
||||
public Sprite levelIcon_sprite_A;
|
||||
@@ -150,8 +150,9 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
}
|
||||
}
|
||||
|
||||
// 缓存 AllyHero_SO 数组,避免在拖放操作时多次调用昂贵的 Resources.LoadAll
|
||||
// Documentation text normalized.
|
||||
private static AllyHero_SO[] _cachedAllyHeroSOs;
|
||||
private static Dictionary<int, AllyHero_SO> _cachedHeroById;
|
||||
|
||||
// Accept drops from CharacterCardView (role items) or roleCard_prefabController
|
||||
public void OnDrop(PointerEventData eventData)
|
||||
@@ -240,7 +241,7 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
heroImage.color = new Color(heroImage.color.r, heroImage.color.g, heroImage.color.b, 1f);
|
||||
}
|
||||
|
||||
// 设置等级图标
|
||||
// Documentation text normalized.
|
||||
var levelInfo = found.GetEffectiveLevelForCurrentEXP();
|
||||
if (levelInfo != null && heroLevelImage != null)
|
||||
{
|
||||
@@ -315,7 +316,7 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
{
|
||||
int prevId = heroSlot_heroID; // remember previous id
|
||||
heroSlot_heroID = 0;
|
||||
if (heroSlot_heroName != null) heroSlot_heroName.text = "空置";
|
||||
if (heroSlot_heroName != null) heroSlot_heroName.text = "绌虹疆";
|
||||
if (heroImage != null)
|
||||
{
|
||||
// revert to default sprite if provided, otherwise keep transparent
|
||||
@@ -413,14 +414,14 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSlot(int id, string name, Sprite sprite)
|
||||
public void SetSlot(int id, string name, Sprite sprite, bool refreshSkills = true)
|
||||
{
|
||||
heroSlot_heroID = id;
|
||||
if (heroSlot_heroName != null) heroSlot_heroName.text = name ?? string.Empty;
|
||||
if (heroImage != null) heroImage.sprite = sprite;
|
||||
if (heroImage != null) heroImage.color = sprite != null ? new Color(heroImage.color.r, heroImage.color.g, heroImage.color.b, 1f) : new Color(heroImage.color.r, heroImage.color.g, heroImage.color.b, 0f);
|
||||
|
||||
// 设置等级图标
|
||||
// Documentation text normalized.
|
||||
if (id != 0)
|
||||
{
|
||||
var hero = FindHeroById(id);
|
||||
@@ -442,13 +443,18 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
}
|
||||
|
||||
// Update skill list after setting slot
|
||||
UpdateSkillList();
|
||||
if (refreshSkills)
|
||||
UpdateSkillList();
|
||||
}
|
||||
|
||||
// Update the skill list in the container
|
||||
public void UpdateSkillList()
|
||||
public void UpdateSkillList(bool playFlash = true)
|
||||
{
|
||||
if (skillContainer == null || skillCardPrefab == null) return;
|
||||
var layout = skillContainer.GetComponent<LayoutGroup>();
|
||||
bool hadLayout = layout != null && layout.enabled;
|
||||
if (hadLayout)
|
||||
layout.enabled = false;
|
||||
|
||||
// Clear existing skill cards
|
||||
foreach (Transform child in skillContainer.transform)
|
||||
@@ -456,25 +462,20 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
if (heroSlot_heroID == 0) return; // No hero, no skills
|
||||
if (heroSlot_heroID == 0)
|
||||
{
|
||||
RestoreLayoutState(layout, hadLayout);
|
||||
return; // No hero, no skills
|
||||
}
|
||||
|
||||
// Find the AllyHero_SO
|
||||
AllyHero_SO hero = null;
|
||||
try
|
||||
{
|
||||
var arr = Resources.LoadAll<AllyHero_SO>("");
|
||||
foreach (var a in arr)
|
||||
{
|
||||
if (a != null && a.ally_heroID == heroSlot_heroID)
|
||||
{
|
||||
hero = a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
AllyHero_SO hero = FindHeroById(heroSlot_heroID);
|
||||
|
||||
if (hero == null || hero.equippedSkillGroupIDs == null) return;
|
||||
if (hero == null || hero.equippedSkillGroupIDs == null)
|
||||
{
|
||||
RestoreLayoutState(layout, hadLayout);
|
||||
return;
|
||||
}
|
||||
|
||||
// Instantiate skill cards for equipped groups
|
||||
foreach (int groupId in hero.equippedSkillGroupIDs)
|
||||
@@ -509,7 +510,21 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
}
|
||||
}
|
||||
|
||||
TeamSelectorAnimController.PlaySkillsFlash(skillContainer != null ? skillContainer.transform as RectTransform : null);
|
||||
RestoreLayoutState(layout, hadLayout);
|
||||
|
||||
if (playFlash)
|
||||
TeamSelectorAnimController.PlaySkillsFlash(skillContainer != null ? skillContainer.transform as RectTransform : null);
|
||||
}
|
||||
|
||||
private void RestoreLayoutState(LayoutGroup layout, bool hadLayout)
|
||||
{
|
||||
if (!hadLayout || layout == null)
|
||||
return;
|
||||
|
||||
layout.enabled = true;
|
||||
RectTransform rt = skillContainer != null ? skillContainer.transform as RectTransform : null;
|
||||
if (rt != null)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(rt);
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
@@ -615,18 +630,35 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
seq.Append(cg.DOFade(1f, changeBlinkTime));
|
||||
}
|
||||
|
||||
// 辅助方法:根据ID查找英雄SO
|
||||
// Documentation text normalized.
|
||||
private AllyHero_SO FindHeroById(int id)
|
||||
{
|
||||
var arr = Resources.LoadAll<AllyHero_SO>("");
|
||||
foreach (var a in arr)
|
||||
{
|
||||
if (a != null && a.ally_heroID == id) return a;
|
||||
}
|
||||
EnsureHeroCache();
|
||||
if (_cachedHeroById != null && _cachedHeroById.TryGetValue(id, out var hero))
|
||||
return hero;
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取等级对应的sprite
|
||||
private static void EnsureHeroCache()
|
||||
{
|
||||
if (_cachedHeroById != null && _cachedHeroById.Count > 0)
|
||||
return;
|
||||
|
||||
if (_cachedAllyHeroSOs == null || _cachedAllyHeroSOs.Length == 0)
|
||||
_cachedAllyHeroSOs = Resources.LoadAll<AllyHero_SO>("");
|
||||
|
||||
_cachedHeroById = new Dictionary<int, AllyHero_SO>();
|
||||
if (_cachedAllyHeroSOs == null) return;
|
||||
|
||||
for (int i = 0; i < _cachedAllyHeroSOs.Length; i++)
|
||||
{
|
||||
AllyHero_SO hero = _cachedAllyHeroSOs[i];
|
||||
if (hero == null) continue;
|
||||
_cachedHeroById[hero.ally_heroID] = hero;
|
||||
}
|
||||
}
|
||||
|
||||
// Documentation text normalized.
|
||||
private Sprite GetLevelSprite(string level)
|
||||
{
|
||||
switch (level)
|
||||
@@ -645,7 +677,7 @@ public class slots_heroSlots : MonoBehaviour, IDropHandler, IBeginDragHandler, I
|
||||
}
|
||||
}
|
||||
|
||||
// 获取角色等级字符串(与loadTeam_select.cs一致)
|
||||
// Documentation text normalized.
|
||||
private string GetRatingFromSO(AllyHero_SO so)
|
||||
{
|
||||
if (so == null || so.levelStats == null || so.levelStats.Count == 0) return "C";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
#if UNITY_EDITOR
|
||||
@@ -8,7 +8,7 @@ using System.Linq;
|
||||
|
||||
public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
[Header("���ܿ�Ƭ����")]
|
||||
[Header("Inspector")]
|
||||
public Image skillCard_bottomImage;
|
||||
public Text skillCard_skillName;
|
||||
public int skillCard_skillID;
|
||||
@@ -16,7 +16,7 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
public string skillCard_skillDescription;
|
||||
public Button skillCard_button;
|
||||
|
||||
[Header("����״̬�ı䱳����ɫ")]
|
||||
[Header("Inspector")]
|
||||
[Tooltip("Color when the skill is available")]
|
||||
public Color skillColor_available = Color.white;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
// hero ID to modify the corresponding SO
|
||||
public int heroId;
|
||||
|
||||
// �Ƿ�ֻ��ģʽ������Ӣ�۲�λ�ڵļ�����ʾ��
|
||||
// Documentation text normalized.
|
||||
public bool isReadOnly = false;
|
||||
|
||||
void Start()
|
||||
@@ -51,12 +51,12 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
|
||||
private AllyHero_SO GetHeroSO()
|
||||
{
|
||||
// ����ʹ��loadSkillsSelect��currentHeroSO
|
||||
// Documentation text normalized.
|
||||
if (loadSkillsSelect.Instance != null && loadSkillsSelect.Instance.currentHeroSO != null)
|
||||
{
|
||||
return loadSkillsSelect.Instance.currentHeroSO;
|
||||
}
|
||||
// ���ã�ͨ��heroId����
|
||||
// Documentation text normalized.
|
||||
var arr = Resources.LoadAll<AllyHero_SO>("");
|
||||
foreach (var a in arr)
|
||||
{
|
||||
@@ -65,42 +65,42 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
return null;
|
||||
}
|
||||
|
||||
// ������ͳһ�л�ѡ��״̬�ķ���������ť�����¼�����
|
||||
// Documentation text normalized.
|
||||
public void ToggleSelect()
|
||||
{
|
||||
var so = GetHeroSO();
|
||||
if (so == null)
|
||||
{
|
||||
Debug.LogWarning($"slots_skillSlots.ToggleSelect: δ�ҵ� hero SO, heroId={heroId}");
|
||||
Debug.LogWarning($"slots_skillSlots.ToggleSelect: 未找到 hero SO, heroId={heroId}");
|
||||
}
|
||||
|
||||
// ����Ƿ����ѡ�����Ҫѡ����δѡ�У�
|
||||
// Documentation text normalized.
|
||||
if (!isSelected)
|
||||
{
|
||||
// ��ȡ��ǰ�ȼ��ļ��ܲ�λ����
|
||||
// Documentation text normalized.
|
||||
var levelInfo = so?.GetEffectiveLevelForCurrentEXP();
|
||||
int maxSlots = levelInfo?.skill_slot_limited ?? int.MaxValue; // ���δ���ã�Ĭ��������
|
||||
int maxSlots = levelInfo?.skill_slot_limited ?? int.MaxValue; // Documentation text normalized.
|
||||
int currentEquipped = so?.equippedSkillGroupIDs.Where(id => id != 0).Count() ?? 0;
|
||||
|
||||
if (currentEquipped >= maxSlots)
|
||||
{
|
||||
Debug.LogWarning($"slots_skillSlots.ToggleSelect: �������ܲ�λ���� ({currentEquipped}/{maxSlots}), ��ѡ��");
|
||||
return; // ���л�״̬
|
||||
Debug.LogWarning($"slots_skillSlots.ToggleSelect: 已达到技能槽位上限 ({currentEquipped}/{maxSlots}),无法选中");
|
||||
return; // Documentation text normalized.
|
||||
}
|
||||
|
||||
// ��ȡ������ĵȼ�����
|
||||
// Documentation text normalized.
|
||||
var skillGroup = so?.GetSkillGroupByID(skillCard_skillID);
|
||||
int requiredLevel = skillGroup?.thisSkill_levelLimit ?? 1;
|
||||
int currentLevel = levelInfo?.levelID ?? 0;
|
||||
|
||||
if (currentLevel < requiredLevel)
|
||||
{
|
||||
Debug.LogWarning($"slots_skillSlots.ToggleSelect: �ȼ����� ({currentLevel}/{requiredLevel}), ��ѡ������ {skillCard_skillID}");
|
||||
return; // ���л�״̬
|
||||
Debug.LogWarning($"slots_skillSlots.ToggleSelect: 等级不足 ({currentLevel}/{requiredLevel}),无法选择技能 {skillCard_skillID}");
|
||||
return; // Documentation text normalized.
|
||||
}
|
||||
}
|
||||
|
||||
// �л�״̬
|
||||
// Documentation text normalized.
|
||||
isSelected = !isSelected;
|
||||
ApplyState();
|
||||
|
||||
@@ -152,11 +152,10 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
#endif
|
||||
}
|
||||
|
||||
// �����/�Ҽ������ѡ�У����л������Ҽ�����ѡ��ʱȡ��
|
||||
// Documentation text normalized.
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (isReadOnly) return; // ֻ��ģʽ�²���������л�
|
||||
|
||||
if (isReadOnly) return; // Documentation text normalized.
|
||||
if (eventData.button == PointerEventData.InputButton.Left)
|
||||
{
|
||||
ToggleSelect();
|
||||
@@ -165,28 +164,28 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
ToggleSelect(); // �Ҽ���ѡ��ʱȡ��ѡ��
|
||||
ToggleSelect(); // Documentation text normalized.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// �����ͣ���룺��ʾ��ϸ��Ϣ
|
||||
// Documentation text normalized.
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (loadDetailsPrefab.Instance == null) return;
|
||||
|
||||
// ��ȡӢ��SO
|
||||
// Documentation text normalized.
|
||||
AllyHero_SO hero = FindHeroById(heroId);
|
||||
if (hero == null) return;
|
||||
|
||||
// ��ȡ������
|
||||
// Documentation text normalized.
|
||||
SkillGroup group = hero.GetSkillGroupByID(skillCard_skillID);
|
||||
if (group == null) return;
|
||||
|
||||
string type = "����";
|
||||
string name = group.groupName ?? "δ֪����";
|
||||
string type = "技能";
|
||||
string name = group.groupName ?? "未知技能";
|
||||
|
||||
// ��鼼�ܿ�����
|
||||
// Documentation text normalized.
|
||||
string status;
|
||||
var levelInfo = hero.GetEffectiveLevelForCurrentEXP();
|
||||
int maxSlots = levelInfo?.skill_slot_limited ?? int.MaxValue;
|
||||
@@ -197,27 +196,27 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
if (currentLevel < requiredLevel)
|
||||
{
|
||||
string levelName = GetLevelName(requiredLevel);
|
||||
status = $"��Ҫ�ȼ�{levelName}";
|
||||
status = $"需要等级{levelName}";
|
||||
}
|
||||
else if (currentEquipped >= maxSlots)
|
||||
{
|
||||
status = "�����Ѵ�����";
|
||||
status = "技能槽位已满";
|
||||
}
|
||||
else if (isSelected)
|
||||
{
|
||||
status = "������ѡ��";
|
||||
status = "已装备";
|
||||
}
|
||||
else
|
||||
{
|
||||
status = "���ܿ���";
|
||||
status = "可装备";
|
||||
}
|
||||
|
||||
string description = group.skillDescriptionsText ?? "������";
|
||||
string description = group.skillDescriptionsText ?? "无描述";
|
||||
|
||||
loadDetailsPrefab.Instance.ShowDetails(type, name, status, description, Input.mousePosition);
|
||||
}
|
||||
|
||||
// �����ͣ�뿪��������ϸ��Ϣ
|
||||
// Documentation text normalized.
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (loadDetailsPrefab.Instance != null)
|
||||
@@ -226,7 +225,7 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
}
|
||||
}
|
||||
|
||||
// ��������������ID����Ӣ��SO
|
||||
// Documentation text normalized.
|
||||
private AllyHero_SO FindHeroById(int id)
|
||||
{
|
||||
var arr = Resources.LoadAll<AllyHero_SO>("");
|
||||
@@ -237,7 +236,7 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
return null;
|
||||
}
|
||||
|
||||
// ��������������levelID��ȡ�ȼ�����
|
||||
// Documentation text normalized.
|
||||
private string GetLevelName(int levelID)
|
||||
{
|
||||
switch (levelID)
|
||||
@@ -246,7 +245,7 @@ public class slots_skillSlots : MonoBehaviour, IPointerClickHandler, IPointerEnt
|
||||
case 2: return "B";
|
||||
case 3: return "A";
|
||||
case 4: return "S";
|
||||
default: return "δ֪";
|
||||
default: return "未知";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user