Browse Source

style: 🎨 improve the keyboard control to pick/throw/use props

improve the keyboard control to pick/throw/use props
tags/0.1.0
Shawqeem 2 years ago
parent
commit
1b10e4f8cf
4 changed files with 283 additions and 233 deletions
  1. +272
    -227
      logic/Client/MainWindow.xaml.cs
  2. +2
    -2
      logic/Server/ArgumentOption.cs
  3. +3
    -1
      logic/Server/GameServer.cs
  4. +6
    -3
      logic/cmd/gameServer.cmd

+ 272
- 227
logic/Client/MainWindow.xaml.cs View File

@@ -927,232 +927,230 @@ namespace Client
{
if (!isPlaybackMode)
{
if(Keyboard.Modifiers == ModifierKeys.Control)
{
switch (e.Key)
{
case Key.D1:
PropMsg msgP1 = new()
{
PlayerId = playerID,
PropType = PropType.AddSpeed,
};
client.PickProp(msgP1);
break;
case Key.D2:
PropMsg msgP2 = new()
{
PlayerId = playerID,
PropType = PropType.AddLifeOrAp,
};
client.PickProp(msgP2);
break;
case Key.D3:
PropMsg msgP3 = new()
{
PlayerId = playerID,
PropType = PropType.AddHpOrAp,
};
client.PickProp(msgP3);
break;
case Key.D4:
PropMsg msgP4 = new()
{
PlayerId = playerID,
PropType = PropType.ShieldOrSpear,
};
client.PickProp(msgP4);
break;
case Key.D5:
PropMsg msgP5 = new()
{
PlayerId = playerID,
PropType = PropType.Key3,
};
client.PickProp(msgP5);
break;
case Key.D6:
PropMsg msgP6 = new()
{
PlayerId = playerID,
PropType = PropType.Key5,
};
client.PickProp(msgP6);
break;
case Key.D7:
PropMsg msgP7 = new()
{
PlayerId = playerID,
PropType = PropType.Key6,
};
client.PickProp(msgP7);
break;
default:
break;
}
}
else if (Keyboard.Modifiers == ModifierKeys.Alt)
{
switch (e.Key)
{
case Key.D1:
PropMsg msgP1 = new()
{
PlayerId = playerID,
PropType = PropType.AddSpeed,
};
client.UseProp(msgP1);
break;
case Key.D2:
PropMsg msgP2 = new()
{
PlayerId = playerID,
PropType = PropType.AddLifeOrAp,
};
client.UseProp(msgP2);
break;
case Key.D3:
PropMsg msgP3 = new()
{
PlayerId = playerID,
PropType = PropType.AddHpOrAp,
};
client.UseProp(msgP3);
break;
case Key.D4:
PropMsg msgP4 = new()
{
PlayerId = playerID,
PropType = PropType.ShieldOrSpear,
};
client.UseProp(msgP4);
break;
case Key.D5:
PropMsg msgP5 = new()
{
PlayerId = playerID,
PropType = PropType.Key3,
};
client.UseProp(msgP5);
break;
case Key.D6:
PropMsg msgP6 = new()
{
PlayerId = playerID,
PropType = PropType.Key5,
};
client.UseProp(msgP6);
break;
case Key.D7:
PropMsg msgP7 = new()
{
PlayerId = playerID,
PropType = PropType.Key6,
};
client.UseProp(msgP7);
break;
default:
break;
}
}
else if(Keyboard.Modifiers == ModifierKeys.Shift)
{
switch (e.Key)
{
case Key.D1:
PropMsg msgP1 = new()
{
PlayerId = playerID,
PropType = PropType.AddSpeed,
};
client.ThrowProp(msgP1);
break;
case Key.D2:
PropMsg msgP2 = new()
{
PlayerId = playerID,
PropType = PropType.AddLifeOrAp,
};
client.ThrowProp(msgP2);
break;
case Key.D3:
PropMsg msgP3 = new()
{
PlayerId = playerID,
PropType = PropType.AddHpOrAp,
};
client.ThrowProp(msgP3);
break;
case Key.D4:
PropMsg msgP4 = new()
{
PlayerId = playerID,
PropType = PropType.ShieldOrSpear,
};
client.ThrowProp(msgP4);
break;
case Key.D5:
PropMsg msgP5 = new()
{
PlayerId = playerID,
PropType = PropType.Key3,
};
client.ThrowProp(msgP5);
break;
case Key.D6:
PropMsg msgP6 = new()
{
PlayerId = playerID,
PropType = PropType.Key5,
};
client.ThrowProp(msgP6);
break;
case Key.D7:
PropMsg msgP7 = new()
{
PlayerId = playerID,
PropType = PropType.Key6,
};
client.ThrowProp(msgP7);
break;
default:
break;
}
}
else if (Keyboard.Modifiers == ModifierKeys.Windows)
{
switch (e.Key)
{
case Key.D0:
SkillMsg msgS0 = new()
{
PlayerId = playerID,
SkillId = 0,
};
client.UseSkill(msgS0);
break;
case Key.D1:
SkillMsg msgS1 = new()
{
PlayerId = playerID,
SkillId = 1,
};
client.UseSkill(msgS1);
break;
case Key.D2:
SkillMsg msgS2 = new()
{
PlayerId = playerID,
SkillId = 2,
};
client.UseSkill(msgS2);
break;
default:
break;
}
}
else
{
//if(Keyboard.Modifiers == ModifierKeys.Control)
//{
// switch (e.Key)
// {
// case Key.D1:
// PropMsg msgP1 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddSpeed,
// };
// client.PickProp(msgP1);
// break;
// case Key.D2:
// PropMsg msgP2 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddLifeOrAp,
// };
// client.PickProp(msgP2);
// break;
// case Key.D3:
// PropMsg msgP3 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddHpOrAp,
// };
// client.PickProp(msgP3);
// break;
// case Key.D4:
// PropMsg msgP4 = new()
// {
// PlayerId = playerID,
// PropType = PropType.ShieldOrSpear,
// };
// client.PickProp(msgP4);
// break;
// case Key.D5:
// PropMsg msgP5 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key3,
// };
// client.PickProp(msgP5);
// break;
// case Key.D6:
// PropMsg msgP6 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key5,
// };
// client.PickProp(msgP6);
// break;
// case Key.D7:
// PropMsg msgP7 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key6,
// };
// client.PickProp(msgP7);
// break;
// default:
// break;
// }
//}
//else if (Keyboard.Modifiers == ModifierKeys.Alt)
//{
// switch (e.Key)
// {
// case Key.D1:
// PropMsg msgP1 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddSpeed,
// };
// client.UseProp(msgP1);
// break;
// case Key.D2:
// PropMsg msgP2 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddLifeOrAp,
// };
// client.UseProp(msgP2);
// break;
// case Key.D3:
// PropMsg msgP3 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddHpOrAp,
// };
// client.UseProp(msgP3);
// break;
// case Key.D4:
// PropMsg msgP4 = new()
// {
// PlayerId = playerID,
// PropType = PropType.ShieldOrSpear,
// };
// client.UseProp(msgP4);
// break;
// case Key.D5:
// PropMsg msgP5 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key3,
// };
// client.UseProp(msgP5);
// break;
// case Key.D6:
// PropMsg msgP6 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key5,
// };
// client.UseProp(msgP6);
// break;
// case Key.D7:
// PropMsg msgP7 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key6,
// };
// client.UseProp(msgP7);
// break;
// default:
// break;
// }
//}
//else if(Keyboard.Modifiers == ModifierKeys.Shift)
//{
// switch (e.Key)
// {
// case Key.D1:
// PropMsg msgP1 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddSpeed,
// };
// client.ThrowProp(msgP1);
// break;
// case Key.D2:
// PropMsg msgP2 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddLifeOrAp,
// };
// client.ThrowProp(msgP2);
// break;
// case Key.D3:
// PropMsg msgP3 = new()
// {
// PlayerId = playerID,
// PropType = PropType.AddHpOrAp,
// };
// client.ThrowProp(msgP3);
// break;
// case Key.D4:
// PropMsg msgP4 = new()
// {
// PlayerId = playerID,
// PropType = PropType.ShieldOrSpear,
// };
// client.ThrowProp(msgP4);
// break;
// case Key.D5:
// PropMsg msgP5 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key3,
// };
// client.ThrowProp(msgP5);
// break;
// case Key.D6:
// PropMsg msgP6 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key5,
// };
// client.ThrowProp(msgP6);
// break;
// case Key.D7:
// PropMsg msgP7 = new()
// {
// PlayerId = playerID,
// PropType = PropType.Key6,
// };
// client.ThrowProp(msgP7);
// break;
// default:
// break;
// }
//}
//else if (Keyboard.Modifiers == ModifierKeys.Windows)
//{
// switch (e.Key)
// {
// case Key.D0:
// SkillMsg msgS0 = new()
// {
// PlayerId = playerID,
// SkillId = 0,
// };
// client.UseSkill(msgS0);
// break;
// case Key.D1:
// SkillMsg msgS1 = new()
// {
// PlayerId = playerID,
// SkillId = 1,
// };
// client.UseSkill(msgS1);
// break;
// case Key.D2:
// SkillMsg msgS2 = new()
// {
// PlayerId = playerID,
// SkillId = 2,
// };
// client.UseSkill(msgS2);
// break;
// default:
// break;
// }
//}
switch (e.Key)
{
case Key.W:
@@ -1273,9 +1271,56 @@ namespace Client
};
client.EndAllAction(msgE);
break;
case Key.F:
PropMsg msgF = new()
{
PlayerId = playerID,
PropType= PropType.NullPropType,
};
client.PickProp(msgF);
break;
case Key.C:
PropMsg msgC = new()
{
PlayerId = playerID,
PropType = PropType.NullPropType,
};
client.ThrowProp(msgC);
break;
case Key.V:
PropMsg msgV = new()
{
PlayerId = playerID,
PropType = PropType.NullPropType,
};
client.UseProp(msgV);
break;
case Key.B:
SkillMsg msgB = new()
{
PlayerId = playerID,
SkillId = 0,
};
client.UseSkill(msgB);
break;
case Key.N:
SkillMsg msgN = new()
{
PlayerId = playerID,
SkillId = 1,
};
client.UseSkill(msgN);
break;
case Key.M:
SkillMsg msgM = new()
{
PlayerId = playerID,
SkillId = 2,
};
client.UseSkill(msgM);
break;
default:
break;
}
}
}
}


+ 2
- 2
logic/Server/ArgumentOption.cs View File

@@ -15,14 +15,14 @@ namespace Server
[Option('p', "port", Required = true, HelpText = "Server listening port")]
public ushort ServerPort { get; set; } = 10086;

[Option('n', "playerNum", Required = false, HelpText = "The number of teams, 1 by defualt")]
[Option('n', "playerNum", Required = false, HelpText = "The number of players, 1 by defualt")]
public ushort playerNum { get; set; } = 1;

[Option('t', "teamCount", Required = false, HelpText = "The number of teams, 1 by defualt")]
public ushort TeamCount { get; set; } = 1;

[Option('c', "playerCount", Required = false, HelpText = "The number of players per team, 1 by default")]
public ushort PlayerCountPerTeam { get; set; } = 1;
public ushort PlayerCountPerTeam { get; set; } = 4;

[Option('g', "gameTimeInSecond", Required = false, HelpText = "The time of the game in second, 10 minutes by default")]
public uint GameTimeInSecond { get; set; } = 10 * 60;


+ 3
- 1
logic/Server/GameServer.cs View File

@@ -20,7 +20,8 @@ namespace Server
protected readonly ArgumentOptions options;
private HttpSender? httpSender;
private object gameLock = new();
private int playerNum => options.playerNum; // 注意修改
private int playerNum = 0;
private int PlayerNum => playerNum; // 注意修改
private MessageToClient currentGameInfo = new();
private MessageOfObj currentMapMsg = new();
private object newsLock = new();
@@ -560,6 +561,7 @@ namespace Server
public GameServer(ArgumentOptions options)
{
this.options = options;
this.playerNum = options.playerNum;
//if (options.mapResource == DefaultArgumentOptions.MapResource)
// this.game = new Game(MapInfo.defaultMap, options.TeamCount);
//else


+ 6
- 3
logic/cmd/gameServer.cmd View File

@@ -1,8 +1,11 @@
@echo off

start cmd /k ..\Server\bin\Debug\net6.0\Server.exe --port 8888 --teamCount 2 --playerCount 2 --gameTimeInSecond 600 --fileName test
start cmd /k ..\Server\bin\Debug\net6.0\Server.exe --port 8888 --teamCount 2 --playerNum 2 --gameTimeInSecond 600 --fileName test

ping -n 4 127.0.0.1 > NUL
ping -n 2 127.0.0.1 > NUL

start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --cl --port=8888 --characterID=4 --type=2 --occupation=1
start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --cl --port=8888 --characterID=0 --type=1 --occupation=1

ping -n 2 127.0.0.1 > NUL

start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --cl --port=8888 --characterID=1 --type=1 --occupation=1

Loading…
Cancel
Save