From 108997fd934885b21c7cc7af3fcde171d5c3cca9 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期日, 31 八月 2025 13:20:24 +0800
Subject: [PATCH] 50 【主界面】核心主体 - 卡牌
---
Main/System/Main/HeroFightingCardCell.cs.meta | 11 ++
Main/System/Main/AutoFightModel.cs | 16 +++
Main/System/Main/HeroFightingCardCell.cs | 138 ++++++++++++++++++++++++++++++++++
Main/System/Main/HomeWin.cs | 45 +++++++++--
Main/System/Main/MainWin.cs | 1
Main/System/Team/TeamBase.cs | 9 ++
Main/System/HeroUI/HeroHeadBaseCell.cs | 14 ---
7 files changed, 209 insertions(+), 25 deletions(-)
diff --git a/Main/System/HeroUI/HeroHeadBaseCell.cs b/Main/System/HeroUI/HeroHeadBaseCell.cs
index bdad82b..235971a 100644
--- a/Main/System/HeroUI/HeroHeadBaseCell.cs
+++ b/Main/System/HeroUI/HeroHeadBaseCell.cs
@@ -137,7 +137,7 @@
}
// 姝﹀皢灏忓ご鍍忥紝锛堣亴涓氬拰鍚嶇О涓嶅啀姝ょ鐞嗭紝鍚勪釜鐣岄潰鎺掔増涓嶅悓锛�
- public void Init(int heroID, int skinID = 0, int star = 0, int awakelv = 0, int lv = 0, UnityAction onclick = null)
+ public void Init(int heroID, int skinID, int star = 0, int awakelv = 0, int lv = 0, UnityAction onclick = null)
{
clickBtn.AddListener(onclick);
var heroConfig = HeroConfig.Get(heroID);
@@ -161,17 +161,7 @@
{
heroIcon.overrideSprite = sprite;
}
- for (int i = 0; i < 5; i++)
- {
- if (i < star)
- {
- starsImg[i].SetSprite("star");
- }
- else
- {
- starsImg[i].SetSprite("star0");
- }
- }
+
if (star == 0)
{
diff --git a/Main/System/Main/AutoFightModel.cs b/Main/System/Main/AutoFightModel.cs
index c0b1c8d..77d3471 100644
--- a/Main/System/Main/AutoFightModel.cs
+++ b/Main/System/Main/AutoFightModel.cs
@@ -210,7 +210,7 @@
}
public int fightingHeroSkinID; //褰撳墠鎴樻枟鐨勮嫳闆勭毊鑲D
- public string heroGuid;
+ public string heroGuid; //鎴樻枟涓殑姝﹀皢
public event Action<bool> OnFightEvent; //鏄惁鎴樻枟閫氱煡
@@ -225,11 +225,21 @@
if (!string.IsNullOrEmpty(guid))
return;
-
+ //鍙�氱煡鐜╁姝﹀皢鐨勬垬鏂�
if (teamHero.NPCID != 0)
return;
+
fightingHeroSkinID = teamHero.SkinID;
- heroGuid = teamHero.guid;
+ //鎴樻枟鏃舵病鏈塆UID 锛岄�氳繃heroid鏌ユ壘
+ var hero = TeamManager.Instance.GetTeam(TeamType.Story).GetHeroByHeroID(teamHero.heroId);
+ if (hero != null)
+ {
+ heroGuid = hero.guid;
+ }
+ else
+ {
+ heroGuid = "";
+ }
OnFightEvent?.Invoke(true);
}
diff --git a/Main/System/Main/HeroFightingCardCell.cs b/Main/System/Main/HeroFightingCardCell.cs
new file mode 100644
index 0000000..090d8d5
--- /dev/null
+++ b/Main/System/Main/HeroFightingCardCell.cs
@@ -0,0 +1,138 @@
+锘縰sing UnityEngine;
+using UnityEngine.UI;
+using System.Collections.Generic;
+
+//涓荤晫闈㈠崱鐗�
+public class HeroFightingCardCell : MonoBehaviour
+{
+
+ [SerializeField] Button clickHeroBtn;
+ [SerializeField] Image qualityBG;
+ [SerializeField] Image heroIcon;
+ [SerializeField] Text lvText;
+ [SerializeField] Image countryImg;
+ [SerializeField] Transform starRect;
+ [SerializeField] List<Image> starsImg;
+ [SerializeField] UIEffectPlayer fightEffect;
+ [SerializeField] FillTween cdTween;
+
+ [SerializeField] Button clickEmptyBtn;
+
+
+ void OnEnable()
+ {
+ AutoFightModel.Instance.OnFightEvent += OnSkillCast;
+ }
+
+ void OnDisable()
+ {
+ AutoFightModel.Instance.OnFightEvent -= OnSkillCast;
+ }
+
+ string guid;
+ public void Display(int index)
+ {
+ var team = TeamManager.Instance.GetTeam(TeamType.Story);
+ var teamHero = team.GetServerHeroByIndex(index);
+ guid = teamHero != null ? teamHero.guid : "";
+ if (guid == "")
+ {
+ clickHeroBtn.SetActive(false);
+ clickEmptyBtn.SetActive(true);
+ clickEmptyBtn.AddListener(ClickEmpty);
+ return;
+ }
+ else
+ {
+ clickHeroBtn.SetActive(true);
+ clickEmptyBtn.SetActive(false);
+ }
+
+ var hero = HeroManager.Instance.GetHero(guid);
+ var heroID = hero.heroId;
+ var star = hero.heroStar;
+ clickHeroBtn.AddListener(ClickHero);
+ var heroConfig = HeroConfig.Get(heroID);
+ qualityBG.SetSprite("heroheadBG" + heroConfig.Quality);
+
+ var sprite = UILoader.LoadSprite("HeroHead", HeroSkinConfig.Get(hero.SkinID).RectangleIcon);
+ if (sprite == null)
+ {
+ // 鍐呯綉鏈厤缃椂
+ heroIcon.SetSprite("herohead_big_default");
+ }
+ else
+ {
+ heroIcon.overrideSprite = sprite;
+ }
+
+ if (star == 0)
+ {
+ starRect.SetActive(false);
+ }
+ else
+ {
+ starRect.SetActive(true);
+ for (int i = 0; i < starsImg.Count; i++)
+ {
+ if ((star - 1) % starsImg.Count >= i)
+ {
+ starsImg[i].SetActive(true);
+ starsImg[i].SetSprite("herostar" + (((star - 1) / starsImg.Count) + 1) * starsImg.Count);
+ }
+ else
+ {
+ starsImg[i].SetActive(false);
+ }
+ }
+ }
+
+ countryImg.SetSprite(HeroUIManager.Instance.GetCountryIconName(heroConfig.Country));
+ lvText.text = hero.heroLevel == 0 ? "" : Language.Get("L1094") + hero.heroLevel;
+
+ RefreshFightIng(false);
+
+ }
+
+
+ void ClickHero()
+ {
+ HeroUIManager.Instance.selectHeroListJob = 0;
+ HeroUIManager.Instance.selectHeroListCountry = 0;
+ HeroUIManager.Instance.SortHeroList();
+ HeroUIManager.Instance.selectHeroGuid = guid;
+ UIManager.Instance.OpenWindow<HeroTrainWin>();
+ }
+
+ void ClickEmpty()
+ {
+ UIManager.Instance.OpenWindow<HeroCallWin>();
+ }
+ void OnSkillCast(bool isfighting)
+ {
+
+ if (isfighting && !string.IsNullOrEmpty(guid) && guid == AutoFightModel.Instance.heroGuid)
+ {
+ RefreshFightIng(true);
+ }
+
+ }
+
+ void RefreshFightIng(bool isfighting)
+ {
+ if (isfighting)
+ {
+ fightEffect.Play();
+ cdTween.SetStartState();
+ cdTween.Play();
+ }
+ else
+ {
+ fightEffect.Stop();
+ cdTween.Stop();
+ cdTween.SetEndState();
+ }
+ }
+
+}
+
diff --git a/Main/System/Main/HeroFightingCardCell.cs.meta b/Main/System/Main/HeroFightingCardCell.cs.meta
new file mode 100644
index 0000000..3ad999b
--- /dev/null
+++ b/Main/System/Main/HeroFightingCardCell.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 93cc1bf4351d0e74497c2aee0a0bdb90
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Main/System/Main/HomeWin.cs b/Main/System/Main/HomeWin.cs
index eefb2ad..08fd8b7 100644
--- a/Main/System/Main/HomeWin.cs
+++ b/Main/System/Main/HomeWin.cs
@@ -12,6 +12,7 @@
//缁忛獙鍖�
[SerializeField] Text playerLevelText;
[SerializeField] SmoothSlider expSlider;
+ [SerializeField] Button officialUpBtn;
//浠诲姟鍖�
[SerializeField] Button taskButton; //寮曞鎴栬�呴鍙栦换鍔″鍔�
@@ -27,15 +28,15 @@
[SerializeField] Button changeHeroPosBtn;
- //绛夌骇
- [SerializeField] Button officialUpBtn;
+ //鍗$墝
+ [SerializeField] HeroFightingCardCell[] heroFightingCardCells;
//搴曢儴鍔熻兘
[SerializeField] Button autoBtn;
[SerializeField] Image autoCloseImg;
[SerializeField] UIEffectPlayer autoOpenEffect;
- [SerializeField] Button blessLVBtn;
+ [SerializeField] Button blessLVBtn;
[SerializeField] Text blessLVText;
//鍏朵粬鍔熻兘鍏ュ彛
@@ -97,7 +98,7 @@
UIManager.Instance.OpenWindow<BlessLVWin>();
});
- officialUpBtn.AddListener(()=>
+ officialUpBtn.AddListener(() =>
{
if (RealmConfig.GetKeys().Count <= PlayerDatas.Instance.baseData.realmLevel)
return;
@@ -115,6 +116,8 @@
RefreshRecharge();
ShowBlessLV();
DisplayAutoFight();
+ DisplayCard(TeamType.Story);
+
}
protected override void OnPreOpen()
@@ -123,6 +126,8 @@
TaskManager.Instance.OnTaskUpdate += UpdateTask;
BlessLVManager.Instance.OnBlessLVUpdateEvent += ShowBlessLV;
AutoFightModel.Instance.ChangeAutoEvent += DisplayAutoFight;
+ TeamManager.Instance.OnTeamChange += DisplayCard;
+ UIManager.Instance.OnCloseWindow += OnCloseWindow;
Display();
// var battleWin = UIManager.Instance.OpenWindow<BattleWin>();
// battleWin.SetBattleField(BattleManager.Instance.storyBattleField);
@@ -136,6 +141,8 @@
TaskManager.Instance.OnTaskUpdate -= UpdateTask;
BlessLVManager.Instance.OnBlessLVUpdateEvent -= ShowBlessLV;
AutoFightModel.Instance.ChangeAutoEvent -= DisplayAutoFight;
+ TeamManager.Instance.OnTeamChange -= DisplayCard;
+ UIManager.Instance.OnCloseWindow -= OnCloseWindow;
// 鍏抽棴鐨勬椂鍊欐妸鎴樻枟鐣岄潰涔熺粰鍏充簡 铏界劧鏄湪澶栭潰寮�鐨�
UIManager.Instance.CloseWindow<BattleWin>();
@@ -158,7 +165,7 @@
}
void RefreshRecharge()
- {
+ {
monthCardBtn.SetActive(!InvestModel.Instance.IsInvested(InvestModel.monthCardType));
}
@@ -181,7 +188,7 @@
autoOpenEffect.Stop();
}
}
-
+
/// <summary>
/// 鏇存柊鐜╁淇℃伅
/// </summary>
@@ -201,7 +208,7 @@
void UpdateTask()
- {
+ {
var task = TaskManager.Instance.mainTask;
if (task.TaskID == 0)
{
@@ -213,9 +220,9 @@
var taskConfig = TaskConfig.Get(task.TaskID);
taskText.text = taskConfig.TaskDescribe;
taskNumText.text = string.Format("({0}/{1})", task.CurValue, taskConfig.NeedValue);
- taskNumText.color = task.CurValue >= taskConfig.NeedValue ? UIHelper.GetUIColor(TextColType.NavyYellow) : UIHelper.GetUIColor(TextColType.Red);
+ taskNumText.color = task.CurValue >= taskConfig.NeedValue ? UIHelper.GetUIColor(TextColType.NavyYellow) : UIHelper.GetUIColor(TextColType.Red);
if (TaskManager.Instance.GetMainTaskState() == 2)
- {
+ {
taskEffect.Play();
}
else
@@ -242,4 +249,24 @@
//鏍规嵁浠诲姟绫诲瀷寮曞
}
}
+
+ void DisplayCard(TeamType teamType)
+ {
+ if (teamType != TeamType.Story)
+ return;
+ //鏄剧ず鍗$墝
+ for (int i = 0; i < heroFightingCardCells.Length; i++)
+ {
+ heroFightingCardCells[i].Display(i);
+ }
+ }
+
+ private void OnCloseWindow(UIBase closeUI)
+ {
+ //鍏朵粬姝﹀皢鍔熻兘浜х敓鏁版嵁鍙樺寲锛岄渶瑕佸埛鏂版灏嗗垪琛�
+ if (closeUI is HeroTrainWin)
+ {
+ DisplayCard(TeamType.Story);
+ }
+ }
}
\ No newline at end of file
diff --git a/Main/System/Main/MainWin.cs b/Main/System/Main/MainWin.cs
index 1423613..f7efbb8 100644
--- a/Main/System/Main/MainWin.cs
+++ b/Main/System/Main/MainWin.cs
@@ -262,7 +262,6 @@
{
if (isfighting)
{
- // fightEffect.playDelayTime = 50;
fightEffect.Play();
cdTween.SetStartState();
cdTween.Play(()=>
diff --git a/Main/System/Team/TeamBase.cs b/Main/System/Team/TeamBase.cs
index fec20d5..c782953 100644
--- a/Main/System/Team/TeamBase.cs
+++ b/Main/System/Team/TeamBase.cs
@@ -239,6 +239,15 @@
return false;
}
+ public TeamHero GetServerHeroByIndex(int index)
+ {
+ if (index < 0 || index >= serverHeroes.Length)
+ {
+ return null;
+ }
+ return serverHeroes[index];
+ }
+
public TeamHero GetNextServerHero(string guid)
{
if (string.IsNullOrEmpty(guid))
--
Gitblit v1.8.0