| @@ -18,38 +18,45 @@ message PlayerMsg | |||
| message MoveMsg | |||
| { | |||
| int64 player_id = 1; | |||
| double angle = 2; | |||
| int64 time_in_milliseconds = 3; | |||
| PlayerType player_type = 2; | |||
| double angle = 3; | |||
| int64 time_in_milliseconds = 4; | |||
| } | |||
| message PropMsg | |||
| { | |||
| int64 player_id = 1; | |||
| PropType prop_type = 2; | |||
| PlayerType player_type = 2; | |||
| PropType prop_type = 3; | |||
| } | |||
| message SendMsg | |||
| { | |||
| int64 player_id = 1; | |||
| int64 to_player_id = 2; | |||
| string message = 3; | |||
| PlayerType player_type = 2; | |||
| int64 to_player_id = 3; | |||
| PlayerType to_player_type = 4; | |||
| string message = 5; | |||
| } | |||
| message TrickMsg // 相当于攻击 | |||
| { | |||
| int64 player_id = 1; | |||
| double angle = 2; | |||
| PlayerType player_type = 2; | |||
| double angle = 3; | |||
| } | |||
| message IDMsg | |||
| { | |||
| int64 player_id = 1; | |||
| PlayerType player_type = 2; | |||
| } | |||
| message SkillMsg | |||
| { | |||
| int64 player_id = 1; | |||
| int32 skill_id = 2; | |||
| PlayerType player_type = 2; | |||
| int32 skill_id = 3; | |||
| } | |||
| // 基本继承于THUAI5,为了使发送的信息尽可能不被浪费,暂定不发这类大包。 | |||
| @@ -15,21 +15,26 @@ namespace ClientTest | |||
| playerInfo.PlayerType = PlayerType.StudentPlayer; | |||
| playerInfo.StudentType = StudentType.NullStudentType; | |||
| var call = client.AddPlayer(playerInfo); | |||
| MoveMsg moveMsg = new(); | |||
| moveMsg.PlayerId = 0; | |||
| moveMsg.PlayerType = PlayerType.StudentPlayer; | |||
| moveMsg.TimeInMilliseconds = 100; | |||
| moveMsg.Angle = 0; | |||
| while (true) | |||
| { | |||
| Console.ReadLine(); | |||
| client.Move(moveMsg); | |||
| Console.WriteLine("Move!"); | |||
| } | |||
| while (await call.ResponseStream.MoveNext()) | |||
| { | |||
| var currentGameInfo = call.ResponseStream.Current; | |||
| if (playerInfo.PlayerType == PlayerType.StudentPlayer) | |||
| { | |||
| for (int i = 0; i < currentGameInfo.StudentMessage.Count; i++) | |||
| { | |||
| Console.WriteLine($"Human is at ({currentGameInfo.StudentMessage[i].X}, {currentGameInfo.StudentMessage[i].Y})"); | |||
| } | |||
| } | |||
| if (playerInfo.PlayerType == PlayerType.TrickerPlayer) | |||
| { | |||
| for (int i = 0; i < currentGameInfo.TrickerMessage.Count; i++) | |||
| for (int i = 0; i < currentGameInfo.ObjMessage.Count; i++) | |||
| { | |||
| Console.WriteLine($"Butcher is at ({currentGameInfo.TrickerMessage[i].X}, {currentGameInfo.TrickerMessage[i].Y})"); | |||
| //Console.WriteLine($"Human is at ({currentGameInfo.StudentMessage[i].X}, {currentGameInfo.StudentMessage[i].Y})"); | |||
| } | |||
| } | |||
| } | |||
| @@ -180,17 +180,18 @@ namespace Gaming | |||
| Character? player = gameMap.FindPlayer(playerID); | |||
| if (player != null) | |||
| { | |||
| return actionManager.MovePlayer(player, moveTimeInMilliseconds, angle); | |||
| var res = actionManager.MovePlayer(player, moveTimeInMilliseconds, angle); | |||
| #if DEBUG | |||
| Console.WriteLine($"PlayerID:{playerID} move to ({player.Position.x},{player.Position.y})!"); | |||
| #endif | |||
| return res; | |||
| } | |||
| else | |||
| { | |||
| return false; | |||
| #if DEBUG | |||
| Console.WriteLine($"PlayerID:{playerID} player does not exists!"); | |||
| #endif | |||
| return false; | |||
| } | |||
| } | |||
| public bool Treat(long playerID, long playerTreatedID) | |||
| @@ -8,7 +8,26 @@ namespace Server | |||
| public static class CopyInfo | |||
| { | |||
| // 下面赋值为0的大概率是还没写完 2023-03-03 | |||
| private static MessageOfStudent Human(Character player) | |||
| /*public static MessageOfObj? Auto(GameObj gameObj) | |||
| { | |||
| if (gameObj.Type == Preparation.Utility.GameObjType.Character) | |||
| { | |||
| Character character = (Character)gameObj; | |||
| if (character.IsGhost()) | |||
| return Tri | |||
| } | |||
| else if (gameObj.Type == Preparation.Utility.GameObjType.Bullet) | |||
| return Bullet((Bullet)gameObj); | |||
| else if (gameObj.Type == Preparation.Utility.GameObjType.Prop) | |||
| return Prop((Prop)gameObj); | |||
| else if (gameObj.Type == Preparation.Utility.GameObjType.BombedBullet) | |||
| return BombedBullet((BombedBullet)gameObj); | |||
| else if (gameObj.Type == Preparation.Utility.GameObjType.PickedProp) | |||
| return PickedProp((PickedProp)gameObj); | |||
| else return null; //先写着防报错 | |||
| }*/ | |||
| private static MessageOfStudent? Student(Character player) | |||
| { | |||
| MessageOfStudent msg = new MessageOfStudent(); | |||
| if (player.IsGhost()) return null; | |||
| @@ -19,7 +38,6 @@ namespace Server | |||
| msg.Determination = player.HP; | |||
| msg.FailNum = 0; | |||
| msg.TimeUntilSkillAvailable = 0; | |||
| //msg.Place = 0; 下面写了 | |||
| msg.StudentType = StudentType.NullStudentType; // 下面写 | |||
| msg.Guid = 0; | |||
| msg.State = StudentState.NullStatus; | |||
| @@ -28,32 +46,7 @@ namespace Server | |||
| msg.PlayerId = 0; | |||
| msg.ViewRange = 0; | |||
| msg.Radius = 0; | |||
| //msg.Buff[0] = StudentBuffType.NullSbuffType; 下面写了 | |||
| /* THUAI5中的内容 | |||
| msg.BulletNum = player.BulletNum; | |||
| msg.CanMove = player.CanMove; | |||
| msg.CD = player.CD; | |||
| msg.GemNum = player.GemNum; | |||
| msg.Guid = player.ID; | |||
| msg.IsResetting = player.IsResetting; | |||
| msg.LifeNum = player.DeathCount + 1; | |||
| msg.Radius = player.Radius; | |||
| msg.TimeUntilCommonSkillAvailable = player.TimeUntilCommonSkillAvailable; | |||
| msg.TeamID = player.TeamID; | |||
| msg.PlayerID = player.PlayerID; | |||
| msg.IsInvisible = player.IsInvisible; | |||
| msg.FacingDirection = player.FacingDirection; | |||
| //应该要发队伍分数,这里先发个人分数 | |||
| msg.MessageOfHuman.Score = player.Score; | |||
| //这条暂时没啥用 | |||
| msg.MessageOfHuman.TimeUntilUltimateSkillAvailable = 0; | |||
| msg.MessageOfHuman.Vampire = player.Vampire;*/ | |||
| foreach (KeyValuePair<Preparation.Utility.BuffType, bool> kvp in player.Buff) | |||
| { | |||
| @@ -78,19 +71,24 @@ namespace Server | |||
| } | |||
| } | |||
| } | |||
| /*switch (player.Place) | |||
| switch (player.Place) | |||
| { | |||
| case Preparation.Utility.PlaceType.Land: | |||
| msg.Place = PlaceType.Land; | |||
| case Preparation.Utility.PlaceType.EmergencyExit: | |||
| msg.Place = PlaceType.HiddenGate; | |||
| break; | |||
| case Preparation.Utility.PlaceType.Grass1: | |||
| msg.Place = PlaceType.Grass; | |||
| case Preparation.Utility.PlaceType.Doorway: | |||
| msg.Place = PlaceType.Gate; | |||
| break; | |||
| case Preparation.Utility.PlaceType.Grass2: | |||
| case Preparation.Utility.PlaceType.Grass: | |||
| msg.Place = PlaceType.Grass; | |||
| break; | |||
| case Preparation.Utility.PlaceType.Grass3: | |||
| msg.Place = PlaceType.Grass; | |||
| case Preparation.Utility.PlaceType.BirthPoint1: | |||
| case Preparation.Utility.PlaceType.BirthPoint2: | |||
| case Preparation.Utility.PlaceType.BirthPoint3: | |||
| case Preparation.Utility.PlaceType.BirthPoint4: | |||
| case Preparation.Utility.PlaceType.BirthPoint5: | |||
| case Preparation.Utility.PlaceType.Null: | |||
| msg.Place = PlaceType.Land; | |||
| break; | |||
| // case Preparation.Utility.PlaceType.Invisible: | |||
| // msg.MessageOfHuman.Place = Communication.Proto.PlaceType.Invisible; | |||
| @@ -98,36 +96,36 @@ namespace Server | |||
| default: | |||
| msg.Place = PlaceType.NullPlaceType; | |||
| break; | |||
| }*/ | |||
| } | |||
| //Character的储存方式可能得改,用enum type存道具和子弹,不应该用对象 | |||
| //现在懒得改了,有时间再重整一波 | |||
| /*if (player.PropInventory == null) | |||
| msg.Prop = PropType.NullPropType; | |||
| if (player.PropInventory == null) | |||
| msg.Prop.Add(PropType.NullPropType); | |||
| else | |||
| { | |||
| switch (player.PropInventory.GetPropType()) | |||
| { | |||
| case Preparation.Utility.PropType.Gem: | |||
| msg.Prop = PropType.NullPropType; | |||
| break; | |||
| case Preparation.Utility.PropType.addLIFE: | |||
| msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddLife; | |||
| break; | |||
| case Preparation.Utility.PropType.addSpeed: | |||
| msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddSpeed; | |||
| break; | |||
| case Preparation.Utility.PropType.Shield: | |||
| msg.MessageOfHuman.Prop = Communication.Proto.PropType.Shield; | |||
| break; | |||
| case Preparation.Utility.PropType.Spear: | |||
| msg.MessageOfHuman.Prop = Communication.Proto.PropType.Spear; | |||
| break; | |||
| default: | |||
| msg.Prop = PropType.NullPropType; | |||
| msg.Prop.Add(PropType.NullPropType); | |||
| break; | |||
| /*case Preparation.Utility.PropType.addLIFE: | |||
| msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddLife; | |||
| break; | |||
| case Preparation.Utility.PropType.addSpeed: | |||
| msg.MessageOfHuman.Prop = Communication.Proto.PropType.AddSpeed; | |||
| break; | |||
| case Preparation.Utility.PropType.Shield: | |||
| msg.MessageOfHuman.Prop = Communication.Proto.PropType.Shield; | |||
| break; | |||
| case Preparation.Utility.PropType.Spear: | |||
| msg.MessageOfHuman.Prop = Communication.Proto.PropType.Spear; | |||
| break; | |||
| default: | |||
| msg.Prop = PropType.NullPropType; | |||
| break;*/ | |||
| } | |||
| }*/ | |||
| } | |||
| /*switch (player.PassiveSkillType) 需要对接一下,proto里似乎没有这个 | |||
| { | |||
| case Preparation.Utility.PassiveSkillType.RecoverAfterBattle: | |||
| @@ -114,6 +114,7 @@ namespace Server | |||
| public void ReportGame() | |||
| { | |||
| //currentGameInfo = null; | |||
| var gameObjList = game.GetGameObj(); | |||
| foreach (var kvp in semaDict) | |||
| { | |||
| @@ -191,8 +192,9 @@ namespace Server | |||
| { | |||
| Game.PlayerInitInfo playerInitInfo = new(GetBirthPointIdx(request.PlayerType, request.PlayerId), PlayerTypeToTeamID(request.PlayerType), request.PlayerId, characterType); | |||
| long newPlayerID = game.AddPlayer(playerInitInfo); | |||
| //if (newPlayerID == GameObj.invalidID) | |||
| //return; | |||
| if (newPlayerID == GameObj.invalidID) | |||
| return; | |||
| communicationToGameID[PlayerTypeToTeamID(request.PlayerType), request.PlayerId] = newPlayerID; | |||
| // 内容待修改 | |||
| var temp = (new SemaphoreSlim(0, 1), new SemaphoreSlim(0, 1)); | |||
| bool start = false; | |||
| @@ -238,7 +240,8 @@ namespace Server | |||
| public override Task<MoveRes> Move(MoveMsg request, ServerCallContext context) | |||
| { | |||
| Console.WriteLine($"Move ID: {request.PlayerId}, TimeInMilliseconds: {request.TimeInMilliseconds}"); | |||
| game.MovePlayer(request.PlayerId, (int)request.TimeInMilliseconds, request.Angle); | |||
| var gameID = communicationToGameID[PlayerTypeToTeamID(request.PlayerType), request.PlayerId]; | |||
| game.MovePlayer(gameID, (int)request.TimeInMilliseconds, request.Angle); | |||
| // 之后game.MovePlayer可能改为bool类型 | |||
| MoveRes moveRes = new(); | |||
| moveRes.ActSuccess = true; | |||
| @@ -257,13 +260,11 @@ namespace Server | |||
| { | |||
| return base.SendMessage(request, context); | |||
| } | |||
| public override Task<BoolRes> UseProp(IDMsg request, ServerCallContext context) | |||
| public override Task<BoolRes> UseProp(PropMsg request, ServerCallContext context) | |||
| { | |||
| return base.UseProp(request, context); | |||
| } | |||
| public override Task<BoolRes> UseSkill(IDMsg request, ServerCallContext context) | |||
| public override Task<BoolRes> UseSkill(SkillMsg request, ServerCallContext context) | |||
| { | |||
| return base.UseSkill(request, context); | |||
| } | |||
| @@ -272,13 +273,13 @@ namespace Server | |||
| { | |||
| return base.Graduate(request, context); | |||
| } | |||
| public override Task<BoolRes> StartHealMate(IDMsg request, ServerCallContext context) | |||
| public override Task<BoolRes> StartRescueMate(IDMsg request, ServerCallContext context) | |||
| { | |||
| return base.StartHealMate(request, context); | |||
| return base.StartRescueMate(request, context); | |||
| } | |||
| public override Task<BoolRes> StartHelpMate(IDMsg request, ServerCallContext context) | |||
| public override Task<BoolRes> StartTreatMate(IDMsg request, ServerCallContext context) | |||
| { | |||
| return base.StartHelpMate(request, context); | |||
| return base.StartTreatMate(request, context); | |||
| } | |||
| public override Task<BoolRes> StartLearning(IDMsg request, ServerCallContext context) | |||
| { | |||