mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-02 20:26:03 +08:00
fix: battle offfield role & battle end
This commit is contained in:
@@ -39,7 +39,7 @@ public class CommandGrid : ICommand
|
||||
return;
|
||||
}
|
||||
|
||||
await inst.GetComponent<GridFightAvatarComponent>().AddAvatar(roleId, tier);
|
||||
await inst.GetComponent<GridFightRoleComponent>().AddAvatar(roleId, tier);
|
||||
await arg.SendMsg(I18NManager.Translate("Game.Command.Grid.AddedRole"));
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,16 @@ public class BattleInstance(PlayerInstance player, LineupInfo lineup, List<Stage
|
||||
public BattleGridFightOptions? GridFightOptions { get; set; }
|
||||
public bool IsTournRogue { get; set; }
|
||||
|
||||
public delegate ValueTask OnBattleEndDelegate(BattleInstance battle, PVEBattleResultCsReq req);
|
||||
|
||||
public event OnBattleEndDelegate? OnBattleEnd;
|
||||
|
||||
public async ValueTask TriggerOnBattleEnd()
|
||||
{
|
||||
if (OnBattleEnd != null)
|
||||
await OnBattleEnd(this, BattleResult!);
|
||||
}
|
||||
|
||||
public ItemList GetDropItemList()
|
||||
{
|
||||
if (BattleEndStatus != BattleEndStatus.BattleEndWin) return new ItemList();
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using EggLink.DanhengServer.Data;
|
||||
using EggLink.DanhengServer.Database.Avatar;
|
||||
using EggLink.DanhengServer.Database.Lineup;
|
||||
using EggLink.DanhengServer.GameServer.Game.GridFight;
|
||||
using EggLink.DanhengServer.GameServer.Game.GridFight.Component;
|
||||
using EggLink.DanhengServer.GameServer.Game.Player;
|
||||
using EggLink.DanhengServer.Proto;
|
||||
using EggLink.DanhengServer.Util;
|
||||
using LineupInfo = EggLink.DanhengServer.Database.Lineup.LineupInfo;
|
||||
|
||||
namespace EggLink.DanhengServer.GameServer.Game.Battle.Custom;
|
||||
|
||||
@@ -12,21 +14,28 @@ public class BattleGridFightOptions(GridFightGameSectionInfo curSection, GridFig
|
||||
{
|
||||
public GridFightGameEncounterInfo Encounter { get; set; } = curSection.Encounters.RandomElement();
|
||||
public GridFightInstance Inst { get; set; } = inst;
|
||||
public GridFightAvatarComponent AvatarComponent { get; set; } = inst.GetComponent<GridFightAvatarComponent>();
|
||||
public GridFightRoleComponent AvatarComponent { get; set; } = inst.GetComponent<GridFightRoleComponent>();
|
||||
public GridFightBasicComponent BasicComponent { get; set; } = inst.GetComponent<GridFightBasicComponent>();
|
||||
public GridFightGameSectionInfo CurSection { get; set; } = curSection;
|
||||
public PlayerInstance Player { get; set; } = player;
|
||||
|
||||
public void HandleProto(SceneBattleInfo proto, BattleInstance battle)
|
||||
{
|
||||
var avatars = AvatarComponent.GetForegroundAvatarInfos();
|
||||
var avatars = AvatarComponent.GetForegroundAvatarInfos(4 + BasicComponent.GetFieldCount());
|
||||
|
||||
var tempLineup = new LineupInfo
|
||||
{
|
||||
BaseAvatars = avatars.Select(y => new LineupAvatarInfo
|
||||
{
|
||||
BaseAvatarId = y.BaseAvatarId
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
var formatted = avatars.Select(x =>
|
||||
x.ToBattleProto(
|
||||
new PlayerDataCollection(Player.Data, Player.InventoryManager!.Data,
|
||||
Player.LineupManager!.GetCurLineup()!), AvatarType.AvatarGridFightType)).ToList();
|
||||
new PlayerDataCollection(Player.Data, Player.InventoryManager!.Data, tempLineup), AvatarType.AvatarGridFightType)).ToList();
|
||||
|
||||
proto.BattleAvatarList.Add(formatted);
|
||||
proto.BattleAvatarList.Add(formatted.Take(4));
|
||||
|
||||
foreach (var wave in Encounter.MonsterWaves)
|
||||
{
|
||||
@@ -58,7 +67,7 @@ public class BattleGridFightOptions(GridFightGameSectionInfo curSection, GridFig
|
||||
{
|
||||
GridGameAvatarList =
|
||||
{
|
||||
AvatarComponent.Data.Roles.Where(x => x.Pos <= 4).Select(x => x.ToBattleInfo())
|
||||
AvatarComponent.Data.Roles.Where(x => x.Pos <= 4 + BasicComponent.GetFieldCount()).Select(x => x.ToBattleInfo())
|
||||
},
|
||||
BattleWaveId = 1,
|
||||
GridFightCurLevel = BasicComponent.Data.CurLevel,
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace EggLink.DanhengServer.GameServer.Game.GridFight.Component;
|
||||
|
||||
public class GridFightBasicComponent(GridFightInstance inst) : BaseGridFightComponent(inst)
|
||||
{
|
||||
public const uint MaxHp = 100;
|
||||
|
||||
public GridFightBasicInfoPb Data { get; set; } = new()
|
||||
{
|
||||
CurHp = 100,
|
||||
@@ -34,6 +36,18 @@ public class GridFightBasicComponent(GridFightInstance inst) : BaseGridFightComp
|
||||
return Retcode.RetSucc;
|
||||
}
|
||||
|
||||
public async ValueTask<Retcode> UpdateLineupHp(int changeNum, bool sendPacket = true, GridFightSrc src = GridFightSrc.KGridFightSrcBattleEnd)
|
||||
{
|
||||
Data.CurHp = (uint)Math.Min(Math.Max(Data.CurHp + changeNum, 0), MaxHp);
|
||||
|
||||
if (sendPacket)
|
||||
{
|
||||
await Inst.Player.SendPacket(new PacketGridFightSyncUpdateResultScNotify(new GridFightLineupHpSyncData(src, Data)));
|
||||
}
|
||||
|
||||
return Retcode.RetSucc;
|
||||
}
|
||||
|
||||
public async ValueTask<Retcode> BuyLevelExp(bool sendPacket = true)
|
||||
{
|
||||
if (!GameData.GridFightPlayerLevelData.TryGetValue(Data.CurLevel, out var levelConf) || levelConf.LevelUpExp == 0)
|
||||
@@ -43,12 +57,35 @@ public class GridFightBasicComponent(GridFightInstance inst) : BaseGridFightComp
|
||||
if (await UpdateGoldNum((int)-Data.BuyLevelCost, false) != Retcode.RetSucc)
|
||||
return Retcode.RetGridFightCoinNotEnough;
|
||||
|
||||
Data.LevelExp += 1;
|
||||
return await AddLevelExp(1, sendPacket);
|
||||
}
|
||||
|
||||
public async ValueTask<Retcode> AddLevelExp(uint exp, bool sendPacket = true)
|
||||
{
|
||||
var upperLevels = GameData.GridFightPlayerLevelData.Values.Where(x => x.PlayerLevel >= Data.CurLevel)
|
||||
.OrderBy(x => x.PlayerLevel).ToList();
|
||||
|
||||
if (upperLevels.Count == 1) // 1 contain cur level
|
||||
return Retcode.RetGridFightGameplayLevelMax; // already max level
|
||||
|
||||
Data.LevelExp += exp;
|
||||
|
||||
// LEVEL UP
|
||||
if (Data.LevelExp >= levelConf.LevelUpExp)
|
||||
var costExp = 0;
|
||||
var targetLevel = Data.CurLevel;
|
||||
|
||||
foreach (var level in upperLevels)
|
||||
{
|
||||
await UpgradeLevel(1, false);
|
||||
if (level.LevelUpExp + costExp > Data.LevelExp)
|
||||
break;
|
||||
|
||||
costExp += (int)level.LevelUpExp;
|
||||
targetLevel = level.PlayerLevel + 1;
|
||||
}
|
||||
|
||||
if (targetLevel > Data.CurLevel)
|
||||
{
|
||||
await UpgradeLevel(targetLevel - Data.CurLevel, false);
|
||||
}
|
||||
|
||||
if (sendPacket)
|
||||
@@ -68,8 +105,17 @@ public class GridFightBasicComponent(GridFightInstance inst) : BaseGridFightComp
|
||||
if (!GameData.GridFightPlayerLevelData.TryGetValue(level + Data.CurLevel, out var levelConf))
|
||||
return Retcode.RetGridFightGameplayLevelMax;
|
||||
|
||||
// adjust exp and other stats
|
||||
for (var i = Data.CurLevel; i < level + Data.CurLevel; i++)
|
||||
{
|
||||
if (!GameData.GridFightPlayerLevelData.TryGetValue(i, out var curLevelConf))
|
||||
break;
|
||||
|
||||
Data.LevelExp -= curLevelConf.LevelUpExp;
|
||||
}
|
||||
|
||||
Data.CurLevel += level;
|
||||
Data.LevelExp = 0;
|
||||
|
||||
Data.BuyLevelCost = (uint)Math.Ceiling(Data.CurLevel / 2f);
|
||||
Data.CurOnGroundAvatarCount = levelConf.AvatarMaxNumber;
|
||||
|
||||
@@ -105,6 +151,7 @@ public class GridFightBasicComponent(GridFightInstance inst) : BaseGridFightComp
|
||||
GridFightLineupHp = Data.CurHp,
|
||||
GridFightCurGold = Data.CurGold,
|
||||
GridFightMaxGold = 2000,
|
||||
GridFightComboWinNum = Data.ComboNum,
|
||||
OCMGMEHECBB = new OPIBBPCHFII
|
||||
{
|
||||
IJDIAOMINLB = new BHJALAPDBLH()
|
||||
|
||||
@@ -14,6 +14,7 @@ public class GridFightLevelComponent : BaseGridFightComponent
|
||||
private uint _curSectionId = 1;
|
||||
public Dictionary<uint, List<GridFightGameSectionInfo>> Sections { get; } = [];
|
||||
public GridFightGameSectionInfo CurrentSection => Sections[_curChapterId][(int)(_curSectionId - 1)];
|
||||
public List<GridFightRoleDamageSttInfo> RoleDamageSttInfos { get; } = [];
|
||||
|
||||
public GridFightLevelComponent(GridFightInstance inst) : base(inst)
|
||||
{
|
||||
@@ -38,6 +39,51 @@ public class GridFightLevelComponent : BaseGridFightComponent
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask<(Retcode, GridFightRoleDamageSttInfo?)> AddRoleDamageStt(uint roleId, double damage, bool sendPacket = true)
|
||||
{
|
||||
var roleComp = Inst.GetComponent<GridFightRoleComponent>();
|
||||
|
||||
var role = roleComp.Data.Roles.OrderBy(x => x.Pos).FirstOrDefault(x => x.RoleId == roleId);
|
||||
if (role == null)
|
||||
return (Retcode.RetGridFightRoleNotExist, null);
|
||||
|
||||
var info = RoleDamageSttInfos.FirstOrDefault(x => x.RoleId == roleId && x.Tier == role.Tier);
|
||||
GridFightRoleDamageSttInfo res;
|
||||
if (info == null)
|
||||
{
|
||||
res = info = new GridFightRoleDamageSttInfo
|
||||
{
|
||||
RoleId = roleId,
|
||||
Tier = role.Tier,
|
||||
TotalDamage = damage,
|
||||
IsTrialAvatar = false,
|
||||
IsUpgrade = false
|
||||
};
|
||||
|
||||
RoleDamageSttInfos.Add(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = new GridFightRoleDamageSttInfo
|
||||
{
|
||||
RoleId = info.RoleId,
|
||||
IsTrialAvatar = info.IsTrialAvatar,
|
||||
IsUpgrade = info.IsUpgrade,
|
||||
Tier = info.Tier,
|
||||
TotalDamage = damage
|
||||
};
|
||||
|
||||
info.TotalDamage += damage;
|
||||
}
|
||||
|
||||
if (sendPacket)
|
||||
{
|
||||
await Inst.Player.SendPacket(new PacketGridFightSyncUpdateResultScNotify(new GridFightRoleDamageSttSyncData(GridFightSrc.KGridFightSrcBattleEnd, this)));
|
||||
}
|
||||
|
||||
return (Retcode.RetSucc, res);
|
||||
}
|
||||
|
||||
public async ValueTask<List<BaseGridFightSyncData>> EnterNextSection(bool sendPacket = true)
|
||||
{
|
||||
// if last section of chapter
|
||||
@@ -123,10 +169,40 @@ public class GridFightLevelComponent : BaseGridFightComponent
|
||||
},
|
||||
LevelSttInfo = new GridFightLevelSttInfo
|
||||
{
|
||||
GridFightDamageSttInfo = ToDamageSttInfo()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public GridFightDamageSttInfo ToDamageSttInfo()
|
||||
{
|
||||
return new GridFightDamageSttInfo
|
||||
{
|
||||
RoleDamageSttList = { RoleDamageSttInfos.Select(x => x.ToProto()) }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class GridFightRoleDamageSttInfo
|
||||
{
|
||||
public uint RoleId { get; set; }
|
||||
public uint Tier { get; set; }
|
||||
public double TotalDamage { get; set; }
|
||||
public bool IsTrialAvatar { get; set; }
|
||||
public bool IsUpgrade { get; set; }
|
||||
|
||||
public GridFightRoleDamageStt ToProto()
|
||||
{
|
||||
return new GridFightRoleDamageStt
|
||||
{
|
||||
RoleBasicId = RoleId,
|
||||
Tier = Tier,
|
||||
IsTrialAvatar = IsTrialAvatar,
|
||||
IsUpgrade = IsUpgrade,
|
||||
TotalDamage = TotalDamage
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class GridFightGameSectionInfo
|
||||
|
||||
@@ -7,7 +7,7 @@ using EggLink.DanhengServer.Proto.ServerSide;
|
||||
|
||||
namespace EggLink.DanhengServer.GameServer.Game.GridFight.Component;
|
||||
|
||||
public class GridFightAvatarComponent(GridFightInstance inst) : BaseGridFightComponent(inst)
|
||||
public class GridFightRoleComponent(GridFightInstance inst) : BaseGridFightComponent(inst)
|
||||
{
|
||||
public GridFightAvatarInfoPb Data { get; set; } = new();
|
||||
|
||||
@@ -75,9 +75,9 @@ public class GridFightAvatarComponent(GridFightInstance inst) : BaseGridFightCom
|
||||
return syncs;
|
||||
}
|
||||
|
||||
public List<BaseAvatarInfo> GetForegroundAvatarInfos()
|
||||
public List<BaseAvatarInfo> GetForegroundAvatarInfos(uint maxAvatarNum)
|
||||
{
|
||||
var foreground = Data.Roles.Where(x => x.Pos <= 4).ToList();
|
||||
var foreground = Data.Roles.Where(x => x.Pos <= maxAvatarNum).OrderBy(x => x.Pos).ToList();
|
||||
List<BaseAvatarInfo> res = [];
|
||||
|
||||
foreach (var role in foreground)
|
||||
@@ -52,7 +52,7 @@ public class GridFightShopComponent(GridFightInstance inst) : BaseGridFightCompo
|
||||
|
||||
// GIVE ITEMS
|
||||
List<BaseGridFightSyncData> syncs = [];
|
||||
var avatarComp = Inst.GetComponent<GridFightAvatarComponent>();
|
||||
var avatarComp = Inst.GetComponent<GridFightRoleComponent>();
|
||||
foreach (var item in targetGoods)
|
||||
{
|
||||
if (item.ItemTypeCase == GridFightShopItemPb.ItemTypeOneofCase.RoleItem)
|
||||
@@ -69,6 +69,9 @@ public class GridFightShopComponent(GridFightInstance inst) : BaseGridFightCompo
|
||||
foreach (var index in indexes)
|
||||
{
|
||||
Data.ShopItems.RemoveAt((int)index);
|
||||
|
||||
// add new item
|
||||
AddGoods(1, curLevel);
|
||||
}
|
||||
|
||||
if (sendPacket)
|
||||
@@ -82,6 +85,47 @@ public class GridFightShopComponent(GridFightInstance inst) : BaseGridFightCompo
|
||||
return Retcode.RetSucc;
|
||||
}
|
||||
|
||||
public void AddGoods(uint num, uint curLevel)
|
||||
{
|
||||
var rules = GameData.GridFightPlayerLevelData.GetValueOrDefault(curLevel)?.RarityWeights ??
|
||||
[100, 0, 0, 0, 0];
|
||||
List<uint> usedIds = Data.ShopItems.Select(x => x.RoleItem.RoleId).ToList();
|
||||
// generate items
|
||||
for (var i = 0; i < num; i++)
|
||||
{
|
||||
// select rarity
|
||||
var rand = (uint)Random.Shared.Next(1, 101);
|
||||
var targetRarity = 0;
|
||||
for (var j = 0; j < 5; j++)
|
||||
{
|
||||
if (rand <= rules[j])
|
||||
{
|
||||
targetRarity = j + 1;
|
||||
break;
|
||||
}
|
||||
rand -= rules[j];
|
||||
}
|
||||
|
||||
// get item pool
|
||||
var pool = GameData.GridFightRoleBasicInfoData.Values
|
||||
.Where(x => !usedIds.Contains(x.ID) && x.IsInPool && x.Rarity == targetRarity).ToList();
|
||||
|
||||
var target = pool.RandomElement();
|
||||
usedIds.Add(target.ID);
|
||||
|
||||
var tier = 1u;
|
||||
Data.ShopItems.Add(new GridFightShopItemPb
|
||||
{
|
||||
Rarity = target.Rarity,
|
||||
RoleItem = new GridFightShopRoleItemPb
|
||||
{
|
||||
RoleId = target.ID,
|
||||
Tier = tier
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask<Retcode> RefreshShop(bool isEnterSection, bool sendPacket = true)
|
||||
{
|
||||
if (!isEnterSection)
|
||||
@@ -113,46 +157,9 @@ public class GridFightShopComponent(GridFightInstance inst) : BaseGridFightCompo
|
||||
|
||||
// refresh
|
||||
var curLevel = Inst.GetComponent<GridFightBasicComponent>().Data.CurLevel;
|
||||
var rules = GameData.GridFightPlayerLevelData.GetValueOrDefault(curLevel)?.RarityWeights ??
|
||||
[100, 0, 0, 0, 0];
|
||||
|
||||
Data.ShopItems.Clear();
|
||||
|
||||
List<uint> usedIds = [];
|
||||
// generate items
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
// select rarity
|
||||
var rand = (uint)Random.Shared.Next(1, 101);
|
||||
var targetRarity = 0;
|
||||
for (var j = 0; j < 5; j++)
|
||||
{
|
||||
if (rand <= rules[j])
|
||||
{
|
||||
targetRarity = j + 1;
|
||||
break;
|
||||
}
|
||||
rand -= rules[j];
|
||||
}
|
||||
|
||||
// get item pool
|
||||
var pool = GameData.GridFightRoleBasicInfoData.Values
|
||||
.Where(x => !usedIds.Contains(x.ID) && x.IsInPool && x.Rarity == targetRarity).ToList();
|
||||
|
||||
var target = pool.RandomElement();
|
||||
usedIds.Add(target.ID);
|
||||
|
||||
var tier = 1u;
|
||||
Data.ShopItems.Add(new GridFightShopItemPb
|
||||
{
|
||||
Rarity = target.Rarity,
|
||||
RoleItem = new GridFightShopRoleItemPb
|
||||
{
|
||||
RoleId = target.ID,
|
||||
Tier = tier
|
||||
}
|
||||
});
|
||||
}
|
||||
AddGoods(5, curLevel);
|
||||
|
||||
if (sendPacket)
|
||||
{
|
||||
|
||||
@@ -21,19 +21,63 @@ public class GridFightInstance(PlayerInstance player, uint season, uint division
|
||||
return Player.BattleManager!.StartGridFightBattle(this);
|
||||
}
|
||||
|
||||
public async ValueTask EndBattle(BattleInstance battle)
|
||||
public async ValueTask EndBattle(BattleInstance battle, PVEBattleResultCsReq req)
|
||||
{
|
||||
if (battle.BattleEndStatus != BattleEndStatus.BattleEndWin) return;
|
||||
if (battle.BattleEndStatus == BattleEndStatus.BattleEndQuit) return;
|
||||
|
||||
List<BaseGridFightSyncData> syncs = [];
|
||||
|
||||
await Player.SendPacket(new PacketGridFightEndBattleStageNotify(this));
|
||||
|
||||
var basicComp = GetComponent<GridFightBasicComponent>();
|
||||
await basicComp.UpdateGoldNum(5, false, GridFightSrc.KGridFightSrcNone);
|
||||
var levelComp = GetComponent<GridFightLevelComponent>();
|
||||
var prevData = basicComp.Data.Clone();
|
||||
|
||||
var expNum = 5u;
|
||||
var baseCoin = 3u;
|
||||
var interestCoin = basicComp.Data.CurGold / 10;
|
||||
|
||||
if (battle.BattleEndStatus == BattleEndStatus.BattleEndWin)
|
||||
{
|
||||
basicComp.Data.ComboNum++;
|
||||
}
|
||||
else
|
||||
{
|
||||
basicComp.Data.ComboNum = 0;
|
||||
|
||||
// cost hp
|
||||
await basicComp.UpdateLineupHp(-5, false);
|
||||
}
|
||||
|
||||
var comboCoin = basicComp.Data.ComboNum switch
|
||||
{
|
||||
>= 5 => 3u,
|
||||
2 or 3 or 4 => 2u,
|
||||
0 => 0u,
|
||||
_ => 1u
|
||||
};
|
||||
|
||||
await basicComp.UpdateGoldNum((int)(baseCoin + interestCoin + comboCoin), false, GridFightSrc.KGridFightSrcNone);
|
||||
await basicComp.AddLevelExp(expNum, false);
|
||||
|
||||
List<GridFightRoleDamageSttInfo> sttList = [];
|
||||
foreach (var roleBattleStt in req.Stt.GridFightBattleStt.RoleBattleStt)
|
||||
{
|
||||
var res = await levelComp.AddRoleDamageStt(roleBattleStt.RoleBasicId, roleBattleStt.Damage, false);
|
||||
if (res.Item2 != null)
|
||||
sttList.Add(res.Item2);
|
||||
}
|
||||
|
||||
var curData = basicComp.Data.Clone();
|
||||
await Player.SendPacket(new PacketGridFightEndBattleStageNotify(this, expNum, prevData, curData,
|
||||
sttList, battle.BattleEndStatus == BattleEndStatus.BattleEndWin, baseCoin, interestCoin,
|
||||
comboCoin));
|
||||
|
||||
|
||||
syncs.Add(new GridFightGoldSyncData(GridFightSrc.KGridFightSrcBattleEnd, basicComp.Data));
|
||||
syncs.AddRange(await GetComponent<GridFightLevelComponent>().EnterNextSection(false));
|
||||
syncs.Add(new GridFightPlayerLevelSyncData(GridFightSrc.KGridFightSrcBattleEnd, basicComp.Data));
|
||||
syncs.Add(new GridFightLineupHpSyncData(GridFightSrc.KGridFightSrcBattleEnd, basicComp.Data));
|
||||
syncs.Add(new GridFightComboNumSyncData(GridFightSrc.KGridFightSrcBattleEnd, basicComp.Data));
|
||||
syncs.Add(new GridFightRoleDamageSttSyncData(GridFightSrc.KGridFightSrcBattleEnd, levelComp));
|
||||
syncs.AddRange(await levelComp.EnterNextSection(false));
|
||||
|
||||
await Player.SendPacket(new PacketGridFightSyncUpdateResultScNotify(syncs));
|
||||
}
|
||||
@@ -43,9 +87,9 @@ public class GridFightInstance(PlayerInstance player, uint season, uint division
|
||||
Components.Add(new GridFightBasicComponent(this));
|
||||
Components.Add(new GridFightShopComponent(this));
|
||||
Components.Add(new GridFightLevelComponent(this));
|
||||
Components.Add(new GridFightAvatarComponent(this));
|
||||
Components.Add(new GridFightRoleComponent(this));
|
||||
|
||||
_ = GetComponent<GridFightAvatarComponent>().AddAvatar(1414, 3, false); // TODO test
|
||||
_ = GetComponent<GridFightRoleComponent>().AddAvatar(1414, 3, false); // TODO test
|
||||
_ = GetComponent<GridFightShopComponent>().RefreshShop(true, false);
|
||||
}
|
||||
|
||||
|
||||
15
GameServer/Game/GridFight/Sync/GridFightComboNumSyncData.cs
Normal file
15
GameServer/Game/GridFight/Sync/GridFightComboNumSyncData.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using EggLink.DanhengServer.Proto;
|
||||
using EggLink.DanhengServer.Proto.ServerSide;
|
||||
|
||||
namespace EggLink.DanhengServer.GameServer.Game.GridFight.Sync;
|
||||
|
||||
public class GridFightComboNumSyncData(GridFightSrc src, GridFightBasicInfoPb info) : BaseGridFightSyncData(src)
|
||||
{
|
||||
public override GridFightSyncData ToProto()
|
||||
{
|
||||
return new GridFightSyncData
|
||||
{
|
||||
GridFightComboWinNum = info.ComboNum
|
||||
};
|
||||
}
|
||||
}
|
||||
18
GameServer/Game/GridFight/Sync/GridFightLineupHpSyncData.cs
Normal file
18
GameServer/Game/GridFight/Sync/GridFightLineupHpSyncData.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using EggLink.DanhengServer.Proto;
|
||||
using EggLink.DanhengServer.Proto.ServerSide;
|
||||
|
||||
namespace EggLink.DanhengServer.GameServer.Game.GridFight.Sync;
|
||||
|
||||
public class GridFightLineupHpSyncData(GridFightSrc src, GridFightBasicInfoPb info) : BaseGridFightSyncData(src)
|
||||
{
|
||||
public override GridFightSyncData ToProto()
|
||||
{
|
||||
return new GridFightSyncData
|
||||
{
|
||||
GridFightLineupHp = new GridFightLineupHpSyncInfo
|
||||
{
|
||||
GridFightLineupHp = info.CurHp
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using EggLink.DanhengServer.GameServer.Game.GridFight.Component;
|
||||
using EggLink.DanhengServer.Proto;
|
||||
|
||||
namespace EggLink.DanhengServer.GameServer.Game.GridFight.Sync;
|
||||
|
||||
public class GridFightRoleDamageSttSyncData(GridFightSrc src, GridFightLevelComponent comp) : BaseGridFightSyncData(src)
|
||||
{
|
||||
public override GridFightSyncData ToProto()
|
||||
{
|
||||
return new GridFightSyncData
|
||||
{
|
||||
GridFightDamageSttInfo = comp.ToDamageSttInfo()
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class HandlerGridFightRecycleRoleCsReq : Handler
|
||||
return;
|
||||
}
|
||||
|
||||
var roleComp = gridFight.GetComponent<GridFightAvatarComponent>();
|
||||
var roleComp = gridFight.GetComponent<GridFightRoleComponent>();
|
||||
await roleComp.SellAvatar(req.UniqueId);
|
||||
|
||||
await connection.SendPacket(CmdIds.GridFightRecycleRoleScRsp);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class HandlerGridFightUpdatePosCsReq : Handler
|
||||
}
|
||||
|
||||
var gridFight = connection.Player.GridFightManager.GridFightInstance;
|
||||
await gridFight.GetComponent<GridFightAvatarComponent>().UpdatePos(req.GridFightPosInfoList.ToList());
|
||||
await gridFight.GetComponent<GridFightRoleComponent>().UpdatePos(req.GridFightPosInfoList.ToList());
|
||||
|
||||
await connection.SendPacket(
|
||||
new PacketGridFightUpdatePosScRsp(Retcode.RetSucc, req.GridFightPosInfoList));
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
using EggLink.DanhengServer.Data;
|
||||
using EggLink.DanhengServer.GameServer.Game.GridFight;
|
||||
using EggLink.DanhengServer.GameServer.Game.GridFight.Component;
|
||||
using EggLink.DanhengServer.Kcp;
|
||||
using EggLink.DanhengServer.Proto;
|
||||
using EggLink.DanhengServer.Proto.ServerSide;
|
||||
|
||||
namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.GridFight;
|
||||
|
||||
public class PacketGridFightEndBattleStageNotify : BasePacket
|
||||
{
|
||||
public PacketGridFightEndBattleStageNotify(GridFightInstance inst) : base(CmdIds.GridFightEndBattleStageNotify)
|
||||
public PacketGridFightEndBattleStageNotify(GridFightInstance inst, uint expAddNum, GridFightBasicInfoPb prev,
|
||||
GridFightBasicInfoPb cur, List<GridFightRoleDamageSttInfo> stt, bool win, uint baseCoin, uint interestCoin,
|
||||
uint comboCoin) : base(CmdIds.GridFightEndBattleStageNotify)
|
||||
{
|
||||
var levelComp = inst.GetComponent<GridFightLevelComponent>();
|
||||
var curSec = levelComp.CurrentSection;
|
||||
@@ -17,12 +21,34 @@ public class PacketGridFightEndBattleStageNotify : BasePacket
|
||||
SectionId = curSec.SectionId,
|
||||
RouteId = curSec.Excel.ID,
|
||||
ChapterId = curSec.ChapterId,
|
||||
GridFightDamageSttInfo = new GridFightDamageSttInfo(),
|
||||
EMLLKALLOPL = new HEHHADKPDOC
|
||||
GridFightDamageSttInfo = new GridFightDamageSttInfo
|
||||
{
|
||||
CGECGAAJLJM = new(),
|
||||
NMMJMPNGIGD = new()
|
||||
}
|
||||
RoleDamageSttList = { stt.Select(x => x.ToProto()) }
|
||||
},
|
||||
GridFightLevelUpdateInfo = new GridFightLevelUpdateInfo
|
||||
{
|
||||
PrevLevelInfo = new GridFightLevelDisplayInfo
|
||||
{
|
||||
Level = prev.CurLevel,
|
||||
MaxExp = GameData.GridFightPlayerLevelData[prev.CurLevel].LevelUpExp,
|
||||
Exp = prev.LevelExp
|
||||
},
|
||||
CurLevelInfo = new GridFightLevelDisplayInfo
|
||||
{
|
||||
Level = cur.CurLevel,
|
||||
MaxExp = GameData.GridFightPlayerLevelData[cur.CurLevel].LevelUpExp,
|
||||
Exp = cur.LevelExp
|
||||
},
|
||||
AddExpNum = expAddNum
|
||||
},
|
||||
AddExpNum = expAddNum,
|
||||
GridFightCurComboNum = cur.ComboNum,
|
||||
GridFightChallengeWin = win,
|
||||
GridFightCoinBaseNum = baseCoin,
|
||||
GridFightCoinInterestNum = interestCoin,
|
||||
GridFightCoinComboNum = comboCoin,
|
||||
GridFightCurLineupHp = cur.CurHp,
|
||||
GridFightMaxLineupHp = GridFightBasicComponent.MaxHp
|
||||
};
|
||||
|
||||
SetData(proto);
|
||||
|
||||
@@ -33,19 +33,20 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
"U2hvcEl0ZW1zGAQgAygLMhQuR3JpZEZpZ2h0U2hvcEl0ZW1QYiKKAQoTR3Jp",
|
||||
"ZEZpZ2h0R2FtZUluZm9QYhIQCghVbmlxdWVJZBgBIAEoDRISCgpEaXZpc2lv",
|
||||
"bklkGAIgASgNEhIKCklzT3ZlckxvY2sYAyABKAgSDgoGU2Vhc29uGAQgASgN",
|
||||
"EikKCkNvbXBvbmVudHMYBSADKAsyFS5HcmlkRmlnaHRDb21wb25lbnRQYiKQ",
|
||||
"EikKCkNvbXBvbmVudHMYBSADKAsyFS5HcmlkRmlnaHRDb21wb25lbnRQYiKi",
|
||||
"AQoUR3JpZEZpZ2h0QmFzaWNJbmZvUGISDwoHQ3VyR29sZBgBIAEoDRIQCghD",
|
||||
"dXJMZXZlbBgCIAEoDRIQCghMZXZlbEV4cBgDIAEoDRIUCgxCdXlMZXZlbENv",
|
||||
"c3QYBCABKA0SDQoFQ3VySHAYBSABKA0SHgoWQ3VyT25Hcm91bmRBdmF0YXJD",
|
||||
"b3VudBgGIAEoDSJSChNHcmlkRmlnaHRSb2xlSW5mb1BiEg4KBlJvbGVJZBgB",
|
||||
"IAEoDRIMCgRUaWVyGAIgASgNEgsKA1BvcxgDIAEoDRIQCghVbmlxdWVJZBgE",
|
||||
"IAEoDSJRChVHcmlkRmlnaHRBdmF0YXJJbmZvUGISIwoFUm9sZXMYASADKAsy",
|
||||
"FC5HcmlkRmlnaHRSb2xlSW5mb1BiEhMKC0N1clVuaXF1ZUlkGAIgASgNIqsB",
|
||||
"ChRHcmlkRmlnaHRDb21wb25lbnRQYhIoCghTaG9wSW5mbxgBIAEoCzIULkdy",
|
||||
"aWRGaWdodFNob3BJbmZvUGJIABIqCglCYXNpY0luZm8YAiABKAsyFS5Hcmlk",
|
||||
"RmlnaHRCYXNpY0luZm9QYkgAEiwKCkF2YXRhckluZm8YAyABKAsyFi5Hcmlk",
|
||||
"RmlnaHRBdmF0YXJJbmZvUGJIAEIPCg1Db21wb25lbnRUeXBlQimqAiZFZ2dM",
|
||||
"aW5rLkRhbmhlbmdTZXJ2ZXIuUHJvdG8uU2VydmVyU2lkZWIGcHJvdG8z"));
|
||||
"b3VudBgGIAEoDRIQCghDb21ib051bRgHIAEoDSJSChNHcmlkRmlnaHRSb2xl",
|
||||
"SW5mb1BiEg4KBlJvbGVJZBgBIAEoDRIMCgRUaWVyGAIgASgNEgsKA1BvcxgD",
|
||||
"IAEoDRIQCghVbmlxdWVJZBgEIAEoDSJRChVHcmlkRmlnaHRBdmF0YXJJbmZv",
|
||||
"UGISIwoFUm9sZXMYASADKAsyFC5HcmlkRmlnaHRSb2xlSW5mb1BiEhMKC0N1",
|
||||
"clVuaXF1ZUlkGAIgASgNIqsBChRHcmlkRmlnaHRDb21wb25lbnRQYhIoCghT",
|
||||
"aG9wSW5mbxgBIAEoCzIULkdyaWRGaWdodFNob3BJbmZvUGJIABIqCglCYXNp",
|
||||
"Y0luZm8YAiABKAsyFS5HcmlkRmlnaHRCYXNpY0luZm9QYkgAEiwKCkF2YXRh",
|
||||
"ckluZm8YAyABKAsyFi5HcmlkRmlnaHRBdmF0YXJJbmZvUGJIAEIPCg1Db21w",
|
||||
"b25lbnRUeXBlQimqAiZFZ2dMaW5rLkRhbmhlbmdTZXJ2ZXIuUHJvdG8uU2Vy",
|
||||
"dmVyU2lkZWIGcHJvdG8z"));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
@@ -53,7 +54,7 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::EggLink.DanhengServer.Proto.ServerSide.GridFightShopItemPb), global::EggLink.DanhengServer.Proto.ServerSide.GridFightShopItemPb.Parser, new[]{ "RoleItem", "Rarity" }, new[]{ "ItemType" }, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::EggLink.DanhengServer.Proto.ServerSide.GridFightShopInfoPb), global::EggLink.DanhengServer.Proto.ServerSide.GridFightShopInfoPb.Parser, new[]{ "ShopLocked", "FreeRefreshCount", "RefreshCost", "ShopItems" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::EggLink.DanhengServer.Proto.ServerSide.GridFightGameInfoPb), global::EggLink.DanhengServer.Proto.ServerSide.GridFightGameInfoPb.Parser, new[]{ "UniqueId", "DivisionId", "IsOverLock", "Season", "Components" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::EggLink.DanhengServer.Proto.ServerSide.GridFightBasicInfoPb), global::EggLink.DanhengServer.Proto.ServerSide.GridFightBasicInfoPb.Parser, new[]{ "CurGold", "CurLevel", "LevelExp", "BuyLevelCost", "CurHp", "CurOnGroundAvatarCount" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::EggLink.DanhengServer.Proto.ServerSide.GridFightBasicInfoPb), global::EggLink.DanhengServer.Proto.ServerSide.GridFightBasicInfoPb.Parser, new[]{ "CurGold", "CurLevel", "LevelExp", "BuyLevelCost", "CurHp", "CurOnGroundAvatarCount", "ComboNum" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::EggLink.DanhengServer.Proto.ServerSide.GridFightRoleInfoPb), global::EggLink.DanhengServer.Proto.ServerSide.GridFightRoleInfoPb.Parser, new[]{ "RoleId", "Tier", "Pos", "UniqueId" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::EggLink.DanhengServer.Proto.ServerSide.GridFightAvatarInfoPb), global::EggLink.DanhengServer.Proto.ServerSide.GridFightAvatarInfoPb.Parser, new[]{ "Roles", "CurUniqueId" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::EggLink.DanhengServer.Proto.ServerSide.GridFightComponentPb), global::EggLink.DanhengServer.Proto.ServerSide.GridFightComponentPb.Parser, new[]{ "ShopInfo", "BasicInfo", "AvatarInfo" }, new[]{ "ComponentType" }, null, null, null)
|
||||
@@ -1218,6 +1219,7 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
buyLevelCost_ = other.buyLevelCost_;
|
||||
curHp_ = other.curHp_;
|
||||
curOnGroundAvatarCount_ = other.curOnGroundAvatarCount_;
|
||||
comboNum_ = other.comboNum_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -1299,6 +1301,18 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "ComboNum" field.</summary>
|
||||
public const int ComboNumFieldNumber = 7;
|
||||
private uint comboNum_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public uint ComboNum {
|
||||
get { return comboNum_; }
|
||||
set {
|
||||
comboNum_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
@@ -1320,6 +1334,7 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
if (BuyLevelCost != other.BuyLevelCost) return false;
|
||||
if (CurHp != other.CurHp) return false;
|
||||
if (CurOnGroundAvatarCount != other.CurOnGroundAvatarCount) return false;
|
||||
if (ComboNum != other.ComboNum) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -1333,6 +1348,7 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
if (BuyLevelCost != 0) hash ^= BuyLevelCost.GetHashCode();
|
||||
if (CurHp != 0) hash ^= CurHp.GetHashCode();
|
||||
if (CurOnGroundAvatarCount != 0) hash ^= CurOnGroundAvatarCount.GetHashCode();
|
||||
if (ComboNum != 0) hash ^= ComboNum.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
@@ -1375,6 +1391,10 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
output.WriteRawTag(48);
|
||||
output.WriteUInt32(CurOnGroundAvatarCount);
|
||||
}
|
||||
if (ComboNum != 0) {
|
||||
output.WriteRawTag(56);
|
||||
output.WriteUInt32(ComboNum);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
@@ -1409,6 +1429,10 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
output.WriteRawTag(48);
|
||||
output.WriteUInt32(CurOnGroundAvatarCount);
|
||||
}
|
||||
if (ComboNum != 0) {
|
||||
output.WriteRawTag(56);
|
||||
output.WriteUInt32(ComboNum);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
@@ -1437,6 +1461,9 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
if (CurOnGroundAvatarCount != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeUInt32Size(CurOnGroundAvatarCount);
|
||||
}
|
||||
if (ComboNum != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeUInt32Size(ComboNum);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
@@ -1467,6 +1494,9 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
if (other.CurOnGroundAvatarCount != 0) {
|
||||
CurOnGroundAvatarCount = other.CurOnGroundAvatarCount;
|
||||
}
|
||||
if (other.ComboNum != 0) {
|
||||
ComboNum = other.ComboNum;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
@@ -1506,6 +1536,10 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
CurOnGroundAvatarCount = input.ReadUInt32();
|
||||
break;
|
||||
}
|
||||
case 56: {
|
||||
ComboNum = input.ReadUInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1545,6 +1579,10 @@ namespace EggLink.DanhengServer.Proto.ServerSide {
|
||||
CurOnGroundAvatarCount = input.ReadUInt32();
|
||||
break;
|
||||
}
|
||||
case 56: {
|
||||
ComboNum = input.ReadUInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ message GridFightBasicInfoPb {
|
||||
uint32 BuyLevelCost = 4;
|
||||
uint32 CurHp = 5;
|
||||
uint32 CurOnGroundAvatarCount = 6;
|
||||
uint32 ComboNum = 7;
|
||||
}
|
||||
|
||||
message GridFightRoleInfoPb {
|
||||
|
||||
Reference in New Issue
Block a user