hch
2025-08-31 108997fd934885b21c7cc7af3fcde171d5c3cca9
50 【主界面】核心主体 - 卡牌
5个文件已修改
2个文件已添加
220 ■■■■■ 已修改文件
Main/System/HeroUI/HeroHeadBaseCell.cs 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/AutoFightModel.cs 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/HeroFightingCardCell.cs 138 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/HeroFightingCardCell.cs.meta 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/HomeWin.cs 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Main/MainWin.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Main/System/Team/TeamBase.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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)
        {
Main/System/Main/AutoFightModel.cs
@@ -210,7 +210,7 @@
    }
    public int fightingHeroSkinID;  //当前战斗的英雄皮肤ID
    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;
        //战斗时没有GUID ,通过heroid查找
        var hero = TeamManager.Instance.GetTeam(TeamType.Story).GetHeroByHeroID(teamHero.heroId);
        if (hero != null)
        {
            heroGuid = hero.guid;
        }
        else
        {
            heroGuid = "";
        }
        OnFightEvent?.Invoke(true);
    }
Main/System/Main/HeroFightingCardCell.cs
New file
@@ -0,0 +1,138 @@
using 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();
        }
    }
}
Main/System/Main/HeroFightingCardCell.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 93cc1bf4351d0e74497c2aee0a0bdb90
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Main/System/Main/HomeWin.cs
@@ -12,6 +12,7 @@
    //经验区
    [SerializeField] Text playerLevelText;
    [SerializeField] SmoothSlider expSlider;
    [SerializeField] Button officialUpBtn;
    //任务区
    [SerializeField] Button taskButton; //引导或者领取任务奖励
@@ -27,9 +28,9 @@
    [SerializeField] Button changeHeroPosBtn;
    //等级
    [SerializeField] Button officialUpBtn;
    //卡牌
    [SerializeField] HeroFightingCardCell[] heroFightingCardCells;
    //底部功能
    [SerializeField] Button autoBtn;
@@ -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>();
@@ -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);
        }
    }
}
Main/System/Main/MainWin.cs
@@ -262,7 +262,6 @@
    {
        if (isfighting)
        {
            // fightEffect.playDelayTime = 50;
            fightEffect.Play();
            cdTween.SetStartState();
            cdTween.Play(()=>
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))