C#-控件不能从一个事例标签转移到另一个事例



所以我正试图使用case switch为我的游戏编写一个护送命令。基本上,我有很多其他命令,但我从来没有做过让目标用户跟随会话用户的命令。基本上,使用该命令的人会键入:escorts username,这会让另一个用户站在使用该命令人的前面。或者在他们身后。任何帮助都将是惊人的。

#region Escorts User
case "escorting":
{
#region Generate Instances / Sessions / Vars
if (!RoleplayManager.ParamsMet(Params, 1))
{
Session.SendWhisper("Invalid syntax: :stun x");
return true;
}
string Target = Convert.ToString(Params[1]);
GameClient TargetSession = null;
RoomUser Actor = null;
RoomUser Targ = null;
TargetSession = RoleplayManager.GenerateSession(Target);
if (TargetSession == null)
{
Session.SendWhisper("The user was not found in this room!");
return true;
}
if (TargetSession.JobManager() == null)
{
Session.SendWhisper("The user was not found in this room!");
return true;
}
if (TargetSession.JobManager().GetRoomUser() == null)
{
Session.SendWhisper("The user was not found in this room!");
return true;
}
if (TargetSession.JobManager().GetRoomUser().RoomId != Session.JobManager().GetRoomUser().RoomId)
{
Session.SendWhisper("The user was not found in this room!");
return true;
}
Targ = TargetSession.JobManager().GetRoomUser();
Actor = Session.JobManager().GetRoomUser();
int MyJobId = Session.GetRoleplay().JobId;
int MyJobRank = Session.GetRoleplay().JobRank;
Vector2D Pos1 = new Vector2D(Actor.X, Actor.Y);
Vector2D Pos2 = new Vector2D(Targ.X, Targ.Y);
#endregion
#region Police Conditions
if (Params.Length == 1)
{
Session.SendWhisper("Opa, você esqueceu de inserir um nome de usuário!");
return true;
}
GameClient TargetClient = Plus.GetGame().GetClientManager().GetClientByUserName(Params[1]);
if (TargetClient == null)
{
Session.SendWhisper("Ocorreu um erro ao tentar encontrar esse usuário, talvez ele esteja offline.");
return true;
}
RoomUser RoomUser = Session.JobManager().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Session.JobManager().UserName);

if (!JobManager.validJob(Session.GetRoleplay().JobId, Session.GetRoleplay().JobRank) && Session.GetRoleplay().inCR == false)
{
Session.SendWhisper("Your job cannot do this!", false, 34);
return true;
}
bool isclose = false;
if (!Session.GetRoleplay().JobHasRights("police")
&& !Session.GetRoleplay().JobHasRights("gov")
&& !Session.GetRoleplay().JobHasRights("swat")
&& !Session.GetRoleplay().JobHasRights("service")
&& RoleplayManager.CR == false)
{
Session.SendWhisper("Your job cannot do this!");
return true;
}
if (!Session.GetRoleplay().Working && RoleplayManager.CR == false)
{
Session.SendWhisper("You must be working to do this!");
return true;
}
if (Session.GetRoleplay().Dead)
{
Session.SendWhisper("You cannot do this while you are dead!");
return true;
}
if (Session.GetRoleplay().Jailed)
{
Session.SendWhisper("You cannot do this while you are in jail!");
return true;
}
if (Targ.Frozen)
{
Session.SendWhisper("This user is already stunned!");
return true;
}
if (Session.JobManager().CurrentRoom.RoomData.Description.Contains("NOCOP"))
{
Session.SendWhisper("Can't do this in 'NOCOP' rooms.");
return true;
}
if (JobManager.validJob(Session.GetRoleplay().JobId, Session.GetRoleplay().JobRank))
{

if (Session.JobManager().CurrentRoom.RoomData.Description.Contains("WESTERN") && Session.GetRoleplay().JobHasRights("police"))
{
Session.SendWhisper("Can't do this in 'WESTERN' rooms.");
return true;
}
if (!Session.JobManager().CurrentRoom.RoomData.Description.Contains("WESTERN") && Session.GetRoleplay().JobHasRights("western"))
{
Session.SendWhisper("Can only do this in 'WESTERN' rooms.");
return true;
}
}
#endregion
#region Execute
Point ClientPos = new Point(RoomUser.X, RoomUser.Y);

double Distance = RoleplayManager.Distance(Pos1, Pos2);
if (Distance <= 1)
{
if (Session.GetRoleplay().Cop == true && Session.GetRoleplay().inCR == true)
{
RoleplayManager.Shout(Session, "*Fires their stun-gun at " + TargetSession.JobManager().UserName + "*");
TargetSession.GetRoleplay().EffectSeconds = 10;
TargetSession.GetRoleplay().StunnedSeconds = 10;
Targ.ApplyEffect(590);
Targ.CanWalk = true;
Targ.Frozen = false;
Targ.ClearMovement();
LevelManager.AddLevelEXP(Session, 30);
Session.GetRoleplay().SaveQuickStat("currentxp", +30);
return true;
}
}
else
{
Session.SendWhisper("Você deve se aproximar desse cidadão para escoltá-lo!");
return true;
}
}
#endregion
#endregion

错误表明每个案例块不能通过另一个案例块。

这意味着每个案例的结尾都必须有一个回车或换行。

请记住,当多个案例不包含代码时,您可能会将它们分组为一个(从技术上讲,这是失败的(。

有关详细信息,请参阅MSDN。

您的switch语句非常庞大,可能需要进行一些重构。

最新更新