mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 00:06:02 +00:00
在 GamingQueue 模块中添加地图相关
This commit is contained in:
parent
d0f6cb6c2e
commit
9693accdd1
@ -194,9 +194,9 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
public int CanSelectTargetCount { get; set; } = 1;
|
public int CanSelectTargetCount { get; set; } = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可选取的作用范围
|
/// 可选取的作用范围 [ 单位:格 ]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double CanSelectTargetRange { get; set; } = 0;
|
public int CanSelectTargetRange { get; set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 普通攻击没有魔法消耗
|
/// 普通攻击没有魔法消耗
|
||||||
|
|||||||
@ -68,7 +68,6 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否是主动技能 [ 此项为高优先级 ]
|
/// 是否是主动技能 [ 此项为高优先级 ]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[InitRequired]
|
|
||||||
public bool IsActive => SkillType != SkillType.Passive;
|
public bool IsActive => SkillType != SkillType.Passive;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -84,15 +83,19 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否是爆发技 [ 此项为高优先级 ]
|
/// 是否是爆发技 [ 此项为高优先级 ]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[InitRequired]
|
|
||||||
public bool IsSuperSkill => SkillType == SkillType.SuperSkill;
|
public bool IsSuperSkill => SkillType == SkillType.SuperSkill;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否属于魔法 [ <see cref="IsActive"/> 必须为 true ],反之为战技
|
/// 是否属于魔法 [ <see cref="IsActive"/> 必须为 true ],反之为战技
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[InitRequired]
|
|
||||||
public bool IsMagic => SkillType == SkillType.Magic;
|
public bool IsMagic => SkillType == SkillType.Magic;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 施法距离 [ 单位:格 ]
|
||||||
|
/// </summary>
|
||||||
|
[InitOptional]
|
||||||
|
public int CastRange { get; set; } = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可选取自身
|
/// 可选取自身
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -124,9 +127,9 @@ namespace Milimoe.FunGame.Core.Entity
|
|||||||
public virtual int CanSelectTargetCount { get; set; } = 1;
|
public virtual int CanSelectTargetCount { get; set; } = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可选取的作用范围
|
/// 可选取的作用范围 [ 单位:格 ]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual double CanSelectTargetRange { get; set; } = 0;
|
public virtual int CanSelectTargetRange { get; set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 选取角色的条件
|
/// 选取角色的条件
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
using Milimoe.FunGame.Core.Model;
|
using Milimoe.FunGame.Core.Model;
|
||||||
|
|
||||||
@ -60,6 +61,11 @@ namespace Milimoe.FunGame.Core.Interface.Base
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int TotalRound { get; }
|
public int TotalRound { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用的地图
|
||||||
|
/// </summary>
|
||||||
|
public GameMap? Map { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示队列信息
|
/// 显示队列信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Api.Utility;
|
||||||
|
using Milimoe.FunGame.Core.Entity;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Core.Interface.Entity
|
namespace Milimoe.FunGame.Core.Interface.Entity
|
||||||
{
|
{
|
||||||
@ -57,9 +58,9 @@ namespace Milimoe.FunGame.Core.Interface.Entity
|
|||||||
public int CanSelectTargetCount { get; }
|
public int CanSelectTargetCount { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可选取的作用范围
|
/// 可选取的作用范围 [ 单位:格 ]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double CanSelectTargetRange { get; }
|
public int CanSelectTargetRange { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 实际魔法消耗 [ 魔法 ]
|
/// 实际魔法消耗 [ 魔法 ]
|
||||||
|
|||||||
@ -41,6 +41,9 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
|
|||||||
case nameof(Skill.Level):
|
case nameof(Skill.Level):
|
||||||
result.Level = reader.GetInt32();
|
result.Level = reader.GetInt32();
|
||||||
break;
|
break;
|
||||||
|
case nameof(Skill.CastRange):
|
||||||
|
result.CastRange = reader.GetInt32();
|
||||||
|
break;
|
||||||
case nameof(Skill.CanSelectSelf):
|
case nameof(Skill.CanSelectSelf):
|
||||||
result.CanSelectSelf = reader.GetBoolean();
|
result.CanSelectSelf = reader.GetBoolean();
|
||||||
break;
|
break;
|
||||||
@ -125,6 +128,7 @@ namespace Milimoe.FunGame.Core.Library.Common.JsonConverter
|
|||||||
if (value.GeneralDescription.Length > 0) writer.WriteString(nameof(Skill.GeneralDescription), value.GeneralDescription);
|
if (value.GeneralDescription.Length > 0) writer.WriteString(nameof(Skill.GeneralDescription), value.GeneralDescription);
|
||||||
if (value.Slogan.Length > 0) writer.WriteString(nameof(Skill.Slogan), value.Slogan);
|
if (value.Slogan.Length > 0) writer.WriteString(nameof(Skill.Slogan), value.Slogan);
|
||||||
if (value.Level > 0) writer.WriteNumber(nameof(Skill.Level), value.Level);
|
if (value.Level > 0) writer.WriteNumber(nameof(Skill.Level), value.Level);
|
||||||
|
writer.WriteNumber(nameof(Skill.CastRange), value.CastRange);
|
||||||
if (value.CanSelectSelf) writer.WriteBoolean(nameof(Skill.CanSelectSelf), value.CanSelectSelf);
|
if (value.CanSelectSelf) writer.WriteBoolean(nameof(Skill.CanSelectSelf), value.CanSelectSelf);
|
||||||
if (!value.CanSelectEnemy) writer.WriteBoolean(nameof(Skill.CanSelectEnemy), value.CanSelectEnemy);
|
if (!value.CanSelectEnemy) writer.WriteBoolean(nameof(Skill.CanSelectEnemy), value.CanSelectEnemy);
|
||||||
if (value.CanSelectTeammate) writer.WriteBoolean(nameof(Skill.CanSelectTeammate), value.CanSelectTeammate);
|
if (value.CanSelectTeammate) writer.WriteBoolean(nameof(Skill.CanSelectTeammate), value.CanSelectTeammate);
|
||||||
|
|||||||
@ -740,6 +740,7 @@ namespace Milimoe.FunGame.Core.Library.Constant
|
|||||||
public enum CharacterActionType
|
public enum CharacterActionType
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
Move,
|
||||||
NormalAttack,
|
NormalAttack,
|
||||||
PreCastSkill,
|
PreCastSkill,
|
||||||
CastSkill,
|
CastSkill,
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using Milimoe.FunGame.Core.Entity;
|
using Milimoe.FunGame.Core.Entity;
|
||||||
using Milimoe.FunGame.Core.Interface.Base;
|
using Milimoe.FunGame.Core.Interface.Base;
|
||||||
using Milimoe.FunGame.Core.Interface.Entity;
|
using Milimoe.FunGame.Core.Interface.Entity;
|
||||||
|
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||||
using Milimoe.FunGame.Core.Library.Constant;
|
using Milimoe.FunGame.Core.Library.Constant;
|
||||||
|
|
||||||
namespace Milimoe.FunGame.Core.Model
|
namespace Milimoe.FunGame.Core.Model
|
||||||
@ -122,6 +123,11 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<Character, int> EarnedMoney => _earnedMoney;
|
public Dictionary<Character, int> EarnedMoney => _earnedMoney;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用的地图
|
||||||
|
/// </summary>
|
||||||
|
public GameMap? Map => _map;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 保护变量
|
#region 保护变量
|
||||||
@ -241,6 +247,11 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected bool _isInRound = false;
|
protected bool _isInRound = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用的地图
|
||||||
|
/// </summary>
|
||||||
|
protected GameMap? _map = null;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 构造函数
|
#region 构造函数
|
||||||
@ -249,13 +260,18 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
/// 新建一个基础回合制游戏队列
|
/// 新建一个基础回合制游戏队列
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="writer">用于文本输出</param>
|
/// <param name="writer">用于文本输出</param>
|
||||||
public GamingQueue(Action<string>? writer = null)
|
/// <param name="map">游戏地图</param>
|
||||||
|
public GamingQueue(Action<string>? writer = null, GameMap? map = null)
|
||||||
{
|
{
|
||||||
if (writer != null)
|
if (writer != null)
|
||||||
{
|
{
|
||||||
WriteLine = writer;
|
WriteLine = writer;
|
||||||
}
|
}
|
||||||
WriteLine ??= new Action<string>(Console.WriteLine);
|
WriteLine ??= new Action<string>(Console.WriteLine);
|
||||||
|
if (map != null)
|
||||||
|
{
|
||||||
|
LoadGameMap(map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -263,18 +279,36 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="characters">参与本次游戏的角色列表</param>
|
/// <param name="characters">参与本次游戏的角色列表</param>
|
||||||
/// <param name="writer">用于文本输出</param>
|
/// <param name="writer">用于文本输出</param>
|
||||||
public GamingQueue(List<Character> characters, Action<string>? writer = null)
|
/// <param name="map">游戏地图</param>
|
||||||
|
public GamingQueue(List<Character> characters, Action<string>? writer = null, GameMap? map = null)
|
||||||
{
|
{
|
||||||
if (writer != null)
|
if (writer != null)
|
||||||
{
|
{
|
||||||
WriteLine = writer;
|
WriteLine = writer;
|
||||||
}
|
}
|
||||||
WriteLine ??= new Action<string>(Console.WriteLine);
|
WriteLine ??= new Action<string>(Console.WriteLine);
|
||||||
|
if (map != null)
|
||||||
|
{
|
||||||
|
LoadGameMap(map);
|
||||||
|
}
|
||||||
InitCharacters(characters);
|
InitCharacters(characters);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 战棋地图(#TODO)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载地图
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="map"></param>
|
||||||
|
public void LoadGameMap(GameMap map)
|
||||||
|
{
|
||||||
|
_map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 队列框架
|
#region 队列框架
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -800,6 +834,10 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
effect.AlterSelectListBeforeAction(character, enemys, teammates, skills, continuousKillingTemp, earnedMoneyTemp);
|
effect.AlterSelectListBeforeAction(character, enemys, teammates, skills, continuousKillingTemp, earnedMoneyTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 这里筛掉重复角色
|
||||||
|
enemys = [.. enemys.Distinct()];
|
||||||
|
teammates = [.. teammates.Distinct()];
|
||||||
|
|
||||||
// 作出了什么行动
|
// 作出了什么行动
|
||||||
CharacterActionType type = CharacterActionType.None;
|
CharacterActionType type = CharacterActionType.None;
|
||||||
|
|
||||||
@ -1209,6 +1247,13 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
WriteLine($"[ {character} ] 结束了回合!");
|
WriteLine($"[ {character} ] 结束了回合!");
|
||||||
await OnCharacterDoNothingAsync(character);
|
await OnCharacterDoNothingAsync(character);
|
||||||
}
|
}
|
||||||
|
else if (type == CharacterActionType.Move)
|
||||||
|
{
|
||||||
|
baseTime = 3;
|
||||||
|
decided = true;
|
||||||
|
WriteLine($"[ {character} ] 进行了移动,并结束了回合!");
|
||||||
|
await OnCharacterMoveAsync(character);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decided = true;
|
decided = true;
|
||||||
@ -3498,6 +3543,21 @@ namespace Milimoe.FunGame.Core.Model
|
|||||||
await (CharacterGiveUp?.Invoke(this, actor) ?? Task.CompletedTask);
|
await (CharacterGiveUp?.Invoke(this, actor) ?? Task.CompletedTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public delegate Task CharacterMoveEventHandler(GamingQueue queue, Character actor);
|
||||||
|
/// <summary>
|
||||||
|
/// 角色移动事件
|
||||||
|
/// </summary>
|
||||||
|
public event CharacterMoveEventHandler? CharacterMove;
|
||||||
|
/// <summary>
|
||||||
|
/// 角色移动事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="actor"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected async Task OnCharacterMoveAsync(Character actor)
|
||||||
|
{
|
||||||
|
await (CharacterMove?.Invoke(this, actor) ?? Task.CompletedTask);
|
||||||
|
}
|
||||||
|
|
||||||
public delegate Task<bool> GameEndEventHandler(GamingQueue queue, Character winner);
|
public delegate Task<bool> GameEndEventHandler(GamingQueue queue, Character winner);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 游戏结束事件
|
/// 游戏结束事件
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user