mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 08:09:02 +00:00
行动顺序表初始化优化,现在需要单独初始化队列
This commit is contained in:
parent
ed222e3e1b
commit
7f2b6466e2
@ -576,19 +576,22 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
if (effect.DurativeWithoutDuration || (effect.Durative && effect.Duration > 0) || effect.DurationTurn > 0)
|
if (effect.DurativeWithoutDuration || (effect.Durative && effect.Duration > 0) || effect.DurationTurn > 0)
|
||||||
{
|
{
|
||||||
// 先从角色身上移除特效类型
|
// 先从角色身上移除特效类型
|
||||||
if (target.CharacterEffectTypes.TryGetValue(effect, out List<EffectType>? types) && types != null)
|
if (isEnemy != effect.IsDebuff)
|
||||||
{
|
{
|
||||||
RemoveEffectTypesByDispel(types, isEnemy);
|
if (target.CharacterEffectTypes.TryGetValue(effect, out List<EffectType>? types) && types != null)
|
||||||
if (types.Count == 0)
|
{
|
||||||
|
RemoveEffectTypesByDispel(types, isEnemy);
|
||||||
|
if (types.Count == 0)
|
||||||
|
{
|
||||||
|
target.CharacterEffectTypes.Remove(effect);
|
||||||
|
removeEffectTypes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
target.CharacterEffectTypes.Remove(effect);
|
|
||||||
removeEffectTypes = true;
|
removeEffectTypes = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
removeEffectTypes = true;
|
|
||||||
}
|
|
||||||
// 友方移除控制状态
|
// 友方移除控制状态
|
||||||
if (!isEnemy && effect.IsDebuff)
|
if (!isEnemy && effect.IsDebuff)
|
||||||
{
|
{
|
||||||
@ -1022,6 +1025,11 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
builder.Append($"({dispels})");
|
builder.Append($"({dispels})");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsBeingTemporaryDispelled)
|
||||||
|
{
|
||||||
|
builder.Append("(已被临时驱散)");
|
||||||
|
}
|
||||||
|
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,8 +22,8 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
characters ??= [];
|
characters ??= [];
|
||||||
return type switch
|
return type switch
|
||||||
{
|
{
|
||||||
RoomType.Team => new TeamGamingQueue(writer),
|
RoomType.Team => new TeamGamingQueue(characters, writer),
|
||||||
_ => new MixGamingQueue(writer)
|
_ => new MixGamingQueue(characters, writer)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与本次游戏的所有角色列表
|
/// 参与本次游戏的所有角色列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Character> AllCharacter => _allCharacter;
|
public List<Character> AllCharacters => _allCharacters;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原始的角色字典
|
/// 原始的角色字典
|
||||||
@ -124,7 +124,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与本次游戏的所有角色列表
|
/// 参与本次游戏的所有角色列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly List<Character> _allCharacter = [];
|
protected readonly List<Character> _allCharacters = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原始的角色字典
|
/// 原始的角色字典
|
||||||
@ -249,7 +249,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新建一个基础回合制游戏队列并初始化
|
/// 新建一个基础回合制游戏队列并初始化角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="characters">参与本次游戏的角色列表</param>
|
/// <param name="characters">参与本次游戏的角色列表</param>
|
||||||
/// <param name="writer">用于文本输出</param>
|
/// <param name="writer">用于文本输出</param>
|
||||||
@ -260,7 +260,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
WriteLine = writer;
|
WriteLine = writer;
|
||||||
}
|
}
|
||||||
WriteLine ??= new Action<string>(Console.WriteLine);
|
WriteLine ??= new Action<string>(Console.WriteLine);
|
||||||
InitCharacterQueue(characters);
|
InitCharacters(characters);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -268,16 +268,16 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
#region 队列框架
|
#region 队列框架
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化基础回合制游戏队列
|
/// 初始化角色表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="characters"></param>
|
/// <param name="characters"></param>
|
||||||
public void InitCharacterQueue(List<Character> characters)
|
public void InitCharacters(List<Character> characters)
|
||||||
{
|
{
|
||||||
// 保存原始的角色信息。用于复活时还原状态
|
// 保存原始的角色信息。用于复活时还原状态
|
||||||
foreach (Character character in characters)
|
foreach (Character character in characters)
|
||||||
{
|
{
|
||||||
// 添加角色引用到所有角色列表
|
// 添加角色引用到所有角色列表
|
||||||
_allCharacter.Add(character);
|
_allCharacters.Add(character);
|
||||||
// 复制原始角色对象
|
// 复制原始角色对象
|
||||||
Character original = character.Copy();
|
Character original = character.Copy();
|
||||||
original.Guid = Guid.NewGuid();
|
original.Guid = Guid.NewGuid();
|
||||||
@ -289,6 +289,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
List<Character> deadCharacters = [.. characters.Where(c => c.HP <= 0)];
|
List<Character> deadCharacters = [.. characters.Where(c => c.HP <= 0)];
|
||||||
foreach (Character death in deadCharacters)
|
foreach (Character death in deadCharacters)
|
||||||
{
|
{
|
||||||
|
_eliminated.Add(death);
|
||||||
if (MaxRespawnTimes != 0 || (MaxRespawnTimes != -1 && _respawnTimes.TryGetValue(death, out int times) && times < MaxRespawnTimes))
|
if (MaxRespawnTimes != 0 || (MaxRespawnTimes != -1 && _respawnTimes.TryGetValue(death, out int times) && times < MaxRespawnTimes))
|
||||||
{
|
{
|
||||||
// 进入复活倒计时
|
// 进入复活倒计时
|
||||||
@ -297,9 +298,15 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
WriteLine($"[ {death} ] 进入复活倒计时:{respawnTime:0.##} {GameplayEquilibriumConstant.InGameTime}!");
|
WriteLine($"[ {death} ] 进入复活倒计时:{respawnTime:0.##} {GameplayEquilibriumConstant.InGameTime}!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化行动顺序表
|
||||||
|
/// </summary>
|
||||||
|
public void InitActionQueue()
|
||||||
|
{
|
||||||
// 初始排序:按速度排序
|
// 初始排序:按速度排序
|
||||||
List<IGrouping<double, Character>> groupedBySpeed = [.. characters
|
List<IGrouping<double, Character>> groupedBySpeed = [.. _allCharacters
|
||||||
.Where(c => c.HP > 0)
|
.Where(c => c.HP > 0)
|
||||||
.GroupBy(c => c.SPD)
|
.GroupBy(c => c.SPD)
|
||||||
.OrderByDescending(g => g.Key)];
|
.OrderByDescending(g => g.Key)];
|
||||||
@ -313,7 +320,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
// 如果只有一个角色,直接加入队列
|
// 如果只有一个角色,直接加入队列
|
||||||
Character character = group.First();
|
Character character = group.First();
|
||||||
AddCharacter(character, Calculation.Round2Digits(_queue.Count * 0.1), false);
|
AddCharacter(character, Calculation.Round2Digits(_queue.Count * 0.1), false);
|
||||||
_assistDetail.Add(character, new AssistDetail(character, characters.Where(c => c != character)));
|
_assistDetail.Add(character, new AssistDetail(character, _allCharacters.Where(c => c != character)));
|
||||||
_stats.Add(character, new());
|
_stats.Add(character, new());
|
||||||
// 初始化技能
|
// 初始化技能
|
||||||
foreach (Skill skill in character.Skills)
|
foreach (Skill skill in character.Skills)
|
||||||
@ -367,7 +374,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
if (selectedCharacter != null)
|
if (selectedCharacter != null)
|
||||||
{
|
{
|
||||||
AddCharacter(selectedCharacter, Calculation.Round2Digits(_queue.Count * 0.1), false);
|
AddCharacter(selectedCharacter, Calculation.Round2Digits(_queue.Count * 0.1), false);
|
||||||
_assistDetail.Add(selectedCharacter, new AssistDetail(selectedCharacter, characters.Where(c => c != selectedCharacter)));
|
_assistDetail.Add(selectedCharacter, new AssistDetail(selectedCharacter, _allCharacters.Where(c => c != selectedCharacter)));
|
||||||
_stats.Add(selectedCharacter, new());
|
_stats.Add(selectedCharacter, new());
|
||||||
// 初始化技能
|
// 初始化技能
|
||||||
foreach (Skill skill in selectedCharacter.Skills)
|
foreach (Skill skill in selectedCharacter.Skills)
|
||||||
@ -471,7 +478,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
{
|
{
|
||||||
FirstKiller = null;
|
FirstKiller = null;
|
||||||
CustomData.Clear();
|
CustomData.Clear();
|
||||||
_allCharacter.Clear();
|
_allCharacters.Clear();
|
||||||
_original.Clear();
|
_original.Clear();
|
||||||
_queue.Clear();
|
_queue.Clear();
|
||||||
_hardnessTimes.Clear();
|
_hardnessTimes.Clear();
|
||||||
@ -733,7 +740,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
List<Character> teammates = [.. allTeammates.Where(_queue.Contains)];
|
List<Character> teammates = [.. allTeammates.Where(_queue.Contains)];
|
||||||
|
|
||||||
// 敌人列表
|
// 敌人列表
|
||||||
List<Character> allEnemys = [.. _allCharacter.Where(c => c != character && !teammates.Contains(c))];
|
List<Character> allEnemys = [.. _allCharacters.Where(c => c != character && !teammates.Contains(c))];
|
||||||
List<Character> enemys = [.. allEnemys.Where(c => _queue.Contains(c) && !c.IsUnselectable)];
|
List<Character> enemys = [.. allEnemys.Where(c => _queue.Contains(c) && !c.IsUnselectable)];
|
||||||
|
|
||||||
// 技能列表
|
// 技能列表
|
||||||
|
|||||||
@ -111,7 +111,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建一个混战游戏队列并初始化行动顺序表
|
/// 创建一个混战游戏队列并初始化角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="characters"></param>
|
/// <param name="characters"></param>
|
||||||
/// <param name="writer"></param>
|
/// <param name="writer"></param>
|
||||||
|
|||||||
@ -288,7 +288,7 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建一个团队游戏队列并初始化行动顺序表
|
/// 创建一个团队游戏队列并初始化角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="characters"></param>
|
/// <param name="characters"></param>
|
||||||
/// <param name="writer"></param>
|
/// <param name="writer"></param>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user