yyl
2025-08-29 dbb4ea01211573e782666e45eb859c96859b2cd6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using UnityEngine;
 
public partial class TeamHero
{
    public int heroId;
 
    public HeroCountry Country;
    public int SkinID;
    public HeroSkinConfig skinConfig;
    public string guid;
 
    public float modelScale = 1f;
 
    public int level = 0;
 
    public string name;
 
    public TeamBase teamBase
    {
        get; private set;
    }
    public int positionNum; //注意服务端的1号位是1,客户端在使用时是0,通信和策划沟通用1
 
 
 
    //  战场数据
    public int ObjID = 0;// 战斗单位唯一ID
 
    public int NPCID = 0;// 战斗NPCID,不同的实例ID对应的NPCID可能一样
 
 
    //  服务器来的构造
    public TeamHero(HB424_tagSCTurnFightInit.tagSCTurnFightObj fightObj, TeamBase _teamBase)
    {
        //  判断一下是npc还是玩家
        heroId = (int)fightObj.HeroID;
 
        // B4 24 回合战斗初始化 #tagSCTurnFightInit 
        // 封包中的 HeroID、SkinID 字段不再是玩家阵容独有,NPC阵容也可能有值,一般是关联武将的NPC有值
        // 如果 HeroID、SkinID 不为空,则可认为是关联武将的NPC,外观相关默认通过HeroID读取武将相关,如名称
        // 皮肤 SkinID 不为空时,则模型默认使用该皮肤
        // 如果 HeroID、SkinID 为空, NPCID不为空,则走原NPC默认规则
 
        //  补充 skinid跟heroid要么同时没有 要么同时有 如果这三个id都没有的话 那就是配置严重错误 无法弥补
 
        if (fightObj.SkinID > 0 && fightObj.HeroID > 0)
        {
            // 走玩家逻辑
            var heroConfig = HeroConfig.Get(heroId);
            if (null == heroConfig)
            {
                Debug.LogError("hero config is null, heroId : " + heroId);
                return;
            }
            Country = (HeroCountry)heroConfig.Country;
            SkinID = (int)fightObj.SkinID;
            modelScale = 1f;
            name = heroConfig.Name;
 
        }
        else if (fightObj.NPCID > 0)
        {
            //走NPC的逻辑
            NPCConfig npcConfig = NPCConfig.Get((int)fightObj.NPCID);
            Country = (HeroCountry)npcConfig.Country;
            SkinID = npcConfig.SkinID;
            modelScale = npcConfig.ModelScale;
            name = npcConfig.NPCName;
            
        }
        else
        {
            throw new System.Exception("hero id and skin id are both invalid, npc id is invalid too (all <= 0)");
        }
 
        level = (int)fightObj.LV;
 
        skinConfig = HeroSkinConfig.Get(SkinID);
        teamBase = _teamBase;
 
        ObjID = (int)fightObj.ObjID;
        NPCID = (int)fightObj.NPCID;
 
        // HPEx * 1亿 + HP
 
        curHp = (long)fightObj.HPEx * (long)Constants.ExpPointValue + (long)fightObj.HP;
        maxHp = (long)fightObj.MaxHPEx * (long)Constants.ExpPointValue + (long)fightObj.MaxHP;
        rage = (int)fightObj.AngreXP;
 
        positionNum = fightObj.PosNum - 1;
 
        //  【重要】战斗构成里没有卡牌的guid
        guid = string.Empty;
 
        Update();
    }
 
    private static int DecreasingObjID = 0;
 
    //  布阵时的构造
    public TeamHero(HeroInfo heroInfo, int posNum, TeamBase _teamBase)
    {
        heroId = heroInfo.itemHero.config.ID;
        SkinID = heroInfo.SkinID;
        skinConfig = heroInfo.skinConfig;
        Country = heroInfo.heroCountry;
 
        teamBase = _teamBase;
 
        ObjID = --DecreasingObjID;
        NPCID = 0;
 
        curHp = heroInfo.hp;
        maxHp = heroInfo.hp;
        rage = 0;
 
        positionNum = posNum;
 
        //  【重要】布阵里的要guid
        guid = heroInfo.itemHero.guid;
 
        Update();
    }
 
    public void OnSwapPosition(TeamHero teamHero)
    {
        teamBase.SwapPosition(positionNum, teamHero.positionNum);
 
        Update();
    }
 
    public void Update()
    {
 
    }
 
 
    //  最终属性 当前属性应该是要在这一层的
 
    public int GetPower()
    {
        // 计算战斗力YYL TODO
        return 0;
    }    
}