Browse Source

feat: 🎨 Add spectator mode

Add spectator mode
tags/0.1.0
Shawqeem 2 years ago
parent
commit
29e00c1ac3
3 changed files with 83 additions and 65 deletions
  1. +0
    -1
      installer/Installer/Model.cs
  2. +82
    -63
      logic/Client/MainWindow.xaml.cs
  3. +1
    -1
      logic/Client/Properties/launchSettings.json

+ 0
- 1
installer/Installer/Model.cs View File

@@ -1061,7 +1061,6 @@ namespace WebConnect
{ {
string tarfile; //要上传的文件路径 string tarfile; //要上传的文件路径
string content; string content;
string filedest; //文件目的地
client.DefaultRequestHeaders.Authorization = new("Bearer", logintoken); client.DefaultRequestHeaders.Authorization = new("Bearer", logintoken);
Console.WriteLine("请输入要上传的文件完整路径:"); Console.WriteLine("请输入要上传的文件完整路径:");
tarfile = Console.ReadLine(); tarfile = Console.ReadLine();


+ 82
- 63
logic/Client/MainWindow.xaml.cs View File

@@ -106,6 +106,17 @@ namespace Client
} }
_ = Parser.Default.ParseArguments<ArgumentOptions>(args).WithParsed(o => _ = Parser.Default.ParseArguments<ArgumentOptions>(args).WithParsed(o =>
{ options = o; }); { options = o; });
if ((args.Length == 3 || args.Length == 4) && options != null && Convert.ToInt64(options.PlayerID) > 2023)
{
spectatorMode = true;
string[] comInfo = new string[3];
comInfo[0] = options.Ip;
comInfo[1] = options.Port;
comInfo[2] = options.PlayerID;
ConnectToServer(comInfo);
OnReceive();
return;
}
if (options == null || options.cl == false) if (options == null || options.cl == false)
{ {
OnReceive(); OnReceive();
@@ -160,7 +171,7 @@ namespace Client
{ {
if (!isPlaybackMode) if (!isPlaybackMode)
{ {
if (comInfo.Length != 5)
if (!spectatorMode && comInfo.Length != 5 || spectatorMode && comInfo.Length != 3)
throw new Exception("注册信息有误!"); throw new Exception("注册信息有误!");
playerID = Convert.ToInt64(comInfo[2]); playerID = Convert.ToInt64(comInfo[2]);
Connect.Background = Brushes.Gray; Connect.Background = Brushes.Gray;
@@ -171,66 +182,69 @@ namespace Client
client = new AvailableService.AvailableServiceClient(channel); client = new AvailableService.AvailableServiceClient(channel);
PlayerMsg playerMsg = new PlayerMsg(); PlayerMsg playerMsg = new PlayerMsg();
playerMsg.PlayerId = playerID; playerMsg.PlayerId = playerID;
playerType = Convert.ToInt64(comInfo[3]) switch
{
0 => PlayerType.NullPlayerType,
1 => PlayerType.StudentPlayer,
2 => PlayerType.TrickerPlayer,
};
playerMsg.PlayerType = playerType;
if (Convert.ToInt64(comInfo[3]) == 1)
{
humanOrButcher = true;
}
else if (Convert.ToInt64(comInfo[3]) == 2)
if (!spectatorMode)
{ {
humanOrButcher = false;
}
if (playerType == PlayerType.StudentPlayer)
{
switch (Convert.ToInt64(comInfo[4]))
playerType = Convert.ToInt64(comInfo[3]) switch
{ {
case 1:
playerMsg.StudentType = StudentType.Athlete;
break;
case 2:
playerMsg.StudentType = StudentType.Teacher;
break;
case 3:
playerMsg.StudentType = StudentType.StraightAStudent;
break;
case 4:
playerMsg.StudentType = StudentType.Robot;
break;
case 5:
playerMsg.StudentType = StudentType.TechOtaku;
break;
case 0:
default:
playerMsg.StudentType = StudentType.NullStudentType;
break;
0 => PlayerType.NullPlayerType,
1 => PlayerType.StudentPlayer,
2 => PlayerType.TrickerPlayer,
};
playerMsg.PlayerType = playerType;
if (Convert.ToInt64(comInfo[3]) == 1)
{
humanOrButcher = true;
} }
}
else if (playerType == PlayerType.TrickerPlayer)
{
switch (Convert.ToInt64(comInfo[4]))
else if (Convert.ToInt64(comInfo[3]) == 2)
{ {
case 1:
playerMsg.TrickerType = TrickerType.Assassin;
break;
case 2:
playerMsg.TrickerType = TrickerType.Klee;
break;
case 3:
playerMsg.TrickerType = TrickerType.ANoisyPerson;
break;
case 4:
playerMsg.TrickerType = TrickerType._4;
break;
case 0:
default:
playerMsg.TrickerType = TrickerType.NullTrickerType;
break;
humanOrButcher = false;
}
if (playerType == PlayerType.StudentPlayer)
{
switch (Convert.ToInt64(comInfo[4]))
{
case 1:
playerMsg.StudentType = StudentType.Athlete;
break;
case 2:
playerMsg.StudentType = StudentType.Teacher;
break;
case 3:
playerMsg.StudentType = StudentType.StraightAStudent;
break;
case 4:
playerMsg.StudentType = StudentType.Robot;
break;
case 5:
playerMsg.StudentType = StudentType.TechOtaku;
break;
case 0:
default:
playerMsg.StudentType = StudentType.NullStudentType;
break;
}
}
else if (playerType == PlayerType.TrickerPlayer)
{
switch (Convert.ToInt64(comInfo[4]))
{
case 1:
playerMsg.TrickerType = TrickerType.Assassin;
break;
case 2:
playerMsg.TrickerType = TrickerType.Klee;
break;
case 3:
playerMsg.TrickerType = TrickerType.ANoisyPerson;
break;
case 4:
playerMsg.TrickerType = TrickerType._4;
break;
case 0:
default:
playerMsg.TrickerType = TrickerType.NullTrickerType;
break;
}
} }
} }
responseStream = client.AddPlayer(playerMsg); responseStream = client.AddPlayer(playerMsg);
@@ -554,8 +568,8 @@ namespace Client
{ {
if (msg.PlayerState == PlayerState.Quit) if (msg.PlayerState == PlayerState.Quit)
return false; return false;
//if (playerID >= 2022 || teamID >= 2022)
// return true;
if (spectatorMode)
return true;
if (humanOrButcher && human != null) if (humanOrButcher && human != null)
{ {
if (human.Guid == msg.Guid) // 自己能看见自己 if (human.Guid == msg.Guid) // 自己能看见自己
@@ -580,8 +594,8 @@ namespace Client


private bool CanSee(MessageOfTricker msg) private bool CanSee(MessageOfTricker msg)
{ {
// if (playerID >= 2022 || teamID >= 2022)
// return true;
if (spectatorMode)
return true;
if (!humanOrButcher && butcher != null) if (!humanOrButcher && butcher != null)
{ {
if (butcher.Guid == msg.Guid) // 自己能看见自己 if (butcher.Guid == msg.Guid) // 自己能看见自己
@@ -606,6 +620,8 @@ namespace Client


private bool CanSee(MessageOfProp msg) private bool CanSee(MessageOfProp msg)
{ {
if (spectatorMode)
return true;
if (msg.Place == Protobuf.PlaceType.Land) if (msg.Place == Protobuf.PlaceType.Land)
return true; return true;
if (humanOrButcher && human != null) if (humanOrButcher && human != null)
@@ -623,6 +639,8 @@ namespace Client


private bool CanSee(MessageOfBullet msg) private bool CanSee(MessageOfBullet msg)
{ {
if (spectatorMode)
return true;
if (msg.Place == Protobuf.PlaceType.Land) if (msg.Place == Protobuf.PlaceType.Land)
return true; return true;
if (humanOrButcher && human != null) if (humanOrButcher && human != null)
@@ -769,7 +787,7 @@ namespace Client
HorizontalAlignment = HorizontalAlignment.Left, HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top, VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth / 2, data.X * unitHeight / 1000.0 - unitHeight / 2, 0, 0), Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth / 2, data.X * unitHeight / 1000.0 - unitHeight / 2, 0, 0),
Fill = Brushes.Red,
//Fill = Brushes.Red,
}; };
switch (data.Type) switch (data.Type)
{ {
@@ -845,7 +863,7 @@ namespace Client
}; };
if (deg == 100) if (deg == 100)
{ {
icon.Text = "🌟";
icon.Text = "A+";
} }
UpperLayerOfMap.Children.Add(icon); UpperLayerOfMap.Children.Add(icon);
} }
@@ -1343,6 +1361,7 @@ namespace Client
private string[] comInfo = new string[5]; private string[] comInfo = new string[5];
ArgumentOptions? options = null; ArgumentOptions? options = null;
bool gateOpened = false; bool gateOpened = false;
bool spectatorMode = false;
double coolTime0 = -1, coolTime1 = -1, coolTime2 = -1; double coolTime0 = -1, coolTime1 = -1, coolTime2 = -1;
const double radiusTimes = 1.0 * Preparation.Utility.GameData.characterRadius / Preparation.Utility.GameData.numOfPosGridPerCell; const double radiusTimes = 1.0 * Preparation.Utility.GameData.characterRadius / Preparation.Utility.GameData.numOfPosGridPerCell;
} }


+ 1
- 1
logic/Client/Properties/launchSettings.json View File

@@ -2,7 +2,7 @@
"profiles": { "profiles": {
"Client": { "Client": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": " --cl --port 8888 --characterID 0 --type 1 --occupation 1"
"commandLineArgs": " --cl --port 8888 --characterID 3000"
} }
} }
} }

Loading…
Cancel
Save