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