bool StartMatchChallenge(
string steamId, // 玩家SteamID(字符串格式)
int timeLimit, // 时间限制(秒,最少10秒)
int requiredScore, // 要求分数(最少1分)
int gridSize, // 网格大小(5-15,推荐7-10)
int itemTypeCount, // 物品类型数量(3-10,推荐4-8)
bool allowRetry, // 失败后是否允许重试一次
string rewardDescription, // 奖励描述文字
Action<bool> callback // 回调函数:true=成功,false=失败
)
// 在其他插件中调用
[PluginReference]
private Plugin XMMatchGame;
// 发起挑战
void SendMatchChallenge(BasePlayer player)
{
var success = XMMatchGame?.Call<bool>("StartMatchChallenge",
player.UserIDString, // 玩家SteamID
60, // 60秒时限
100, // 要求100分
7, // 7x7网格
6, // 6种物品
true, // 允许重试
"完成挑战即可获得豪华大礼包!", // 描述
(bool isPassed) => // 回调处理
{
if (isPassed)
{
// 挑战成功,执行奖励逻辑
Puts($"{player.displayName} 完成了消消乐挑战!");
GiveReward(player);
}
else
{
// 挑战失败
Puts($"{player.displayName} 挑战失败!");
player.ChatMessage("很遗憾,挑战失败了!");
}
}
);
if (!success.HasValue || !success.Value)
{
player.ChatMessage("无法发起挑战,请稍后再试!");
}
}
void OnMatchGameStart(BasePlayer player, bool isChallengeMode)
void OnMatchGameStart(BasePlayer player, bool isChallengeMode)
{
var mode = isChallengeMode ? "挑战模式" : "关卡模式";
Puts($"{player.displayName} 开始了消消乐游戏 [{mode}]");
}
void OnMatchGameSuccess(BasePlayer player, int score, bool isChallengeMode)
void OnMatchGameSuccess(BasePlayer player, int score, bool isChallengeMode)
{
var mode = isChallengeMode ? "挑战" : "关卡";
Puts($"{player.displayName} 成功完成了消消乐{mode}!得分:{score}");
// 可以发放额外奖励
if (score >= 500)
{
player.ChatMessage("恭喜!获得高分成就奖励!");
}
}
void OnMatchGameFailed(BasePlayer player, int score, bool isChallengeMode)
void OnMatchGameFailed(BasePlayer player, int score, bool isChallengeMode)
{
var mode = isChallengeMode ? "挑战" : "关卡";
Puts($"{player.displayName} 在消消乐{mode}中失败了。得分:{score}");
// 可以给予鼓励或安慰奖
if (score >= 80)
{
player.ChatMessage("虽然失败了,但表现不错!这是安慰奖~");
}
}