FunGame-Core/Model/MixGamingQueue.cs
milimoe 310f672ed4
支持非指向性技能目标选取;删除战斗框架的全部异步;添加豁免机制和指向性扩散 (#145)
* 支持非指向性技能和指向性技能的扩散

* 添加豁免机制,优化非指向性寻路算法

* 删除战斗框架的全部异步;添加非指向性无目标阻止释放;添加直线宽度;修改扇形算法

* 添加了新的特效钩子;添加了决策点相关统计;添加伤害计算选项;开放新事件和 API
2026-01-09 09:06:49 +08:00

143 lines
4.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Milimoe.FunGame.Core.Entity;
using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Core.Model
{
/// <summary>
/// 混战游戏队列,增强版混战模式 <see cref="RoomType.Mix"/>
/// </summary>
public class MixGamingQueue : GamingQueue
{
/// <summary>
/// 死亡结算后
/// </summary>
/// <param name="death"></param>
/// <param name="killer"></param>
/// <returns></returns>
protected override void AfterDeathCalculation(Character death, Character killer)
{
if (MaxRespawnTimes != 0 && MaxScoreToWin > 0)
{
WriteLine($"\r\n=== 当前死亡竞赛比分 ===\r\n{string.Join("\r\n", _stats.OrderByDescending(kv => kv.Value.Kills)
.Select(kv => $"[ {kv.Key} ] {kv.Value.Kills} 分"))}\r\n剩余存活人数{_queue.Count}");
}
if (!_queue.Where(c => c != killer).Any())
{
// 没有其他的角色了,游戏结束
EndGameInfo(killer);
}
if (MaxScoreToWin > 0 && _stats[killer].Kills >= MaxScoreToWin)
{
EndGameInfo(killer);
return;
}
}
/// <summary>
/// 角色行动后,进行死亡竞赛幸存者检定
/// </summary>
/// <param name="character"></param>
/// <param name="type"></param>
/// <returns></returns>
protected override bool AfterCharacterAction(Character character, CharacterActionType type)
{
bool result = base.AfterCharacterAction(character, type);
if (result)
{
if (MaxRespawnTimes != 0 && MaxScoreToWin > 0 && _stats[character].Kills >= MaxScoreToWin)
{
return false;
}
}
return result;
}
/// <summary>
/// 游戏结束信息
/// </summary>
public void EndGameInfo(Character winner)
{
WriteLine("[ " + winner + " ] 是胜利者。");
foreach (Character character in _stats.OrderBy(kv => kv.Value.Kills)
.ThenByDescending(kv => kv.Value.Deaths)
.ThenBy(kv => kv.Value.Assists).Select(kv => kv.Key))
{
if (character != winner && !_eliminated.Contains(character))
{
_eliminated.Add(character);
}
}
_eliminated.Add(winner);
_queue.Clear();
_isGameEnd = true;
if (!OnGameEndEvent(winner))
{
return;
}
int top = 1;
WriteLine("");
WriteLine("=== 排名 ===");
for (int i = _eliminated.Count - 1; i >= 0; i--)
{
Character ec = _eliminated[i];
CharacterStatistics statistics = CharacterStatistics[ec];
string topCharacter = ec.ToString() +
(statistics.FirstKills > 0 ? " [ 第一滴血 ]" : "") +
(_maxContinuousKilling.TryGetValue(ec, out int kills) && kills > 1 ? $" [ {CharacterSet.GetContinuousKilling(kills)} ]" : "") +
(_earnedMoney.TryGetValue(ec, out int earned) ? $" [ 已赚取 {earned} {GameplayEquilibriumConstant.InGameCurrency} ]" : "");
if (top == 1)
{
WriteLine("冠军:" + topCharacter);
_stats[ec].Wins += 1;
_stats[ec].Top3s += 1;
}
else if (top == 2)
{
WriteLine("亚军:" + topCharacter);
_stats[ec].Loses += 1;
_stats[ec].Top3s += 1;
}
else if (top == 3)
{
WriteLine("季军:" + topCharacter);
_stats[ec].Loses += 1;
_stats[ec].Top3s += 1;
}
else
{
WriteLine($"第 {top} 名:" + topCharacter);
_stats[ec].Loses += 1;
}
_stats[ec].Plays += 1;
_stats[ec].TotalEarnedMoney += earned;
_stats[ec].LastRank = top;
top++;
}
WriteLine("");
}
/// <summary>
/// 创建一个混战游戏队列
/// </summary>
/// <param name="writer"></param>
public MixGamingQueue(Action<string>? writer = null) : base(writer)
{
}
/// <summary>
/// 创建一个混战游戏队列并初始化角色
/// </summary>
/// <param name="characters"></param>
/// <param name="writer"></param>
public MixGamingQueue(List<Character> characters, Action<string>? writer = null) : base(characters, writer)
{
}
}
}