|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- using Protobuf;
- using GameClass.GameObj;
- using Preparation.Utility;
- using Gaming;
-
- namespace Server
- {
-
- public static class CopyInfo
- {
- public static MessageOfObj? Auto(GameObj gameObj, int time)
- {
- switch (gameObj.Type)
- {
- case Preparation.Utility.GameObjType.Character:
- Character character = (Character)gameObj;
- if (character.IsGhost())
- return Tricker((Ghost)character);
- else return Student((Student)character);
- case Preparation.Utility.GameObjType.Bullet:
- return Bullet((Bullet)gameObj);
- case Preparation.Utility.GameObjType.Prop:
- return Prop((Prop)gameObj);
- case Preparation.Utility.GameObjType.BombedBullet:
- return BombedBullet((BombedBullet)gameObj);
- case Preparation.Utility.GameObjType.PickedProp:
- return PickedProp((PickedProp)gameObj);
- case Preparation.Utility.GameObjType.Generator:
- return Classroom((Generator)gameObj);
- case Preparation.Utility.GameObjType.Chest:
- return Chest((Chest)gameObj, time);
- case Preparation.Utility.GameObjType.Doorway:
- return Gate((Doorway)gameObj, time);
- case Preparation.Utility.GameObjType.EmergencyExit:
- if (((EmergencyExit)gameObj).CanOpen)
- return HiddenGate((EmergencyExit)gameObj);
- else return null;
- case Preparation.Utility.GameObjType.Door:
- return Door((Door)gameObj);
- default: return null;
- }
- }
- public static MessageOfObj? Auto(MessageOfNews news)
- {
- MessageOfObj objMsg = new()
- {
- NewsMessage = news
- };
- return objMsg;
- }
-
- private static MessageOfObj? Student(Student player)
- {
- if (player.IsGhost()) return null;
- MessageOfObj msg = new()
- {
- StudentMessage = new()
- {
- X = player.Position.x,
- Y = player.Position.y,
- Speed = player.MoveSpeed,
- Determination = player.HP,
- Addiction = player.GamingAddiction,
- Place = Transformation.ToPlaceType((Preparation.Utility.PlaceType)player.Place),
- Guid = player.ID,
-
- PlayerState = Transformation.ToPlayerState((PlayerStateType)player.PlayerState),
- PlayerId = player.PlayerID,
- ViewRange = player.ViewRange,
- Radius = player.Radius,
- DangerAlert = (player.BgmDictionary.ContainsKey(BgmType.GhostIsComing)) ? player.BgmDictionary[BgmType.GhostIsComing] : 0,
- Score = player.Score,
- TreatProgress = player.DegreeOfTreatment,
- RescueProgress = player.TimeOfRescue,
-
- BulletType = Transformation.ToBulletType((Preparation.Utility.BulletType)player.BulletOfPlayer),
- LearningSpeed = player.FixSpeed,
- TreatSpeed = player.TreatSpeed,
- FacingDirection = player.FacingDirection.Angle(),
- StudentType = Transformation.ToStudentType(player.CharacterType)
- }
- };
-
- foreach (var keyValue in player.TimeUntilActiveSkillAvailable)
- msg.StudentMessage.TimeUntilSkillAvailable.Add(keyValue.Value);
- for (int i = 0; i < GameData.maxNumOfSkill - player.TimeUntilActiveSkillAvailable.Count; ++i)
- msg.StudentMessage.TimeUntilSkillAvailable.Add(-1);
-
- foreach (var value in player.PropInventory)
- msg.StudentMessage.Prop.Add(Transformation.ToPropType(value.GetPropType()));
-
- foreach (KeyValuePair<Preparation.Utility.BuffType, bool> kvp in player.Buff)
- {
- if (kvp.Value)
- msg.StudentMessage.Buff.Add(Transformation.ToStudentBuffType(kvp.Key));
- }
-
- return msg;
- }
-
- private static MessageOfObj? Tricker(Character player)
- {
- if (!player.IsGhost()) return null;
- MessageOfObj msg = new()
- {
- TrickerMessage = new()
- {
- X = player.Position.x,
- Y = player.Position.y,
- Speed = player.MoveSpeed,
- Place = Transformation.ToPlaceType((Preparation.Utility.PlaceType)player.Place),
-
- TrickerType = Transformation.ToTrickerType(player.CharacterType),
- Guid = player.ID,
- Score = player.Score,
- PlayerId = player.PlayerID,
- ViewRange = player.ViewRange,
- Radius = player.Radius,
- PlayerState = Transformation.ToPlayerState((PlayerStateType)player.PlayerState),
- TrickDesire = (player.BgmDictionary.ContainsKey(BgmType.StudentIsApproaching)) ? player.BgmDictionary[BgmType.StudentIsApproaching] : 0,
- ClassVolume = (player.BgmDictionary.ContainsKey(BgmType.GeneratorIsBeingFixed)) ? player.BgmDictionary[BgmType.GeneratorIsBeingFixed] : 0,
- FacingDirection = player.FacingDirection.Angle(),
- BulletType = Transformation.ToBulletType((Preparation.Utility.BulletType)player.BulletOfPlayer)
- }
- };
-
- foreach (var keyValue in player.TimeUntilActiveSkillAvailable)
- msg.TrickerMessage.TimeUntilSkillAvailable.Add(keyValue.Value);
- for (int i = 0; i < GameData.maxNumOfSkill - player.TimeUntilActiveSkillAvailable.Count; ++i)
- msg.TrickerMessage.TimeUntilSkillAvailable.Add(-1);
-
- foreach (var value in player.PropInventory)
- msg.TrickerMessage.Prop.Add(Transformation.ToPropType(value.GetPropType()));
- foreach (KeyValuePair<Preparation.Utility.BuffType, bool> kvp in player.Buff)
- {
- if (kvp.Value)
- msg.TrickerMessage.Buff.Add(Transformation.ToTrickerBuffType(kvp.Key));
- }
-
- return msg;
- }
-
- private static MessageOfObj Bullet(Bullet bullet)
- {
- MessageOfObj msg = new()
- {
- BulletMessage = new()
- {
- Type = Transformation.ToBulletType(bullet.TypeOfBullet),
- X = bullet.Position.x,
- Y = bullet.Position.y,
- FacingDirection = bullet.FacingDirection.Angle(),
- Guid = bullet.ID,
- Team = (bullet.Parent!.IsGhost()) ? PlayerType.TrickerPlayer : PlayerType.StudentPlayer,
- Place = Transformation.ToPlaceType((Preparation.Utility.PlaceType)bullet.Place),
- BombRange = bullet.BulletBombRange,
- Speed = bullet.Speed
- }
- };
- return msg;
- }
-
- private static MessageOfObj Prop(Prop prop)
- {
- MessageOfObj msg = new()
- {
- PropMessage = new()
- {
- Type = Transformation.ToPropType(prop.GetPropType()),
- X = prop.Position.x,
- Y = prop.Position.y,
- FacingDirection = prop.FacingDirection.Angle(),
- Guid = prop.ID,
- Place = Transformation.ToPlaceType((Preparation.Utility.PlaceType)prop.Place)
- }
- };
- return msg;
- }
-
- private static MessageOfObj BombedBullet(BombedBullet bombedBullet)
- {
- MessageOfObj msg = new()
- {
- BombedBulletMessage = new()
- {
- Type = Transformation.ToBulletType(bombedBullet.bulletHasBombed.TypeOfBullet),
- X = bombedBullet.bulletHasBombed.Position.x,
- Y = bombedBullet.bulletHasBombed.Position.y,
- FacingDirection = bombedBullet.FacingDirection.Angle(),
- MappingId = bombedBullet.MappingID,
- BombRange = bombedBullet.bulletHasBombed.BulletBombRange
- }
- };
- // Debugger.Output(bombedBullet, bombedBullet.Place.ToString()+" "+bombedBullet.Position.ToString());
- return msg;
- }
-
- private static MessageOfObj PickedProp(PickedProp pickedProp)
- {
- MessageOfObj msg = new MessageOfObj(); // MessageOfObj中没有PickedProp
- /*msg.MessageOfPickedProp = new MessageOfPickedProp();
-
- msg.MessageOfPickedProp.MappingID = pickedProp.MappingID;
- msg.MessageOfPickedProp.X = pickedProp.PropHasPicked.Position.x;
- msg.MessageOfPickedProp.Y = pickedProp.PropHasPicked.Position.y;
- msg.MessageOfPickedProp.FacingDirection = pickedProp.PropHasPicked.FacingDirection;*/
- return msg;
- }
-
- private static MessageOfObj Classroom(Generator generator)
- {
- MessageOfObj msg = new()
- {
- ClassroomMessage = new()
- {
- X = generator.Position.x,
- Y = generator.Position.y,
- Progress = generator.DegreeOfRepair
- }
- };
- return msg;
- }
- private static MessageOfObj Gate(Doorway doorway, int time)
- {
- MessageOfObj msg = new()
- {
- GateMessage = new()
- {
- X = doorway.Position.x,
- Y = doorway.Position.y
- }
- };
- int progress = ((doorway.OpenStartTime > 0) ? (time - doorway.OpenStartTime) : 0) + doorway.OpenDegree;
- msg.GateMessage.Progress = (progress > GameData.degreeOfOpenedDoorway) ? GameData.degreeOfOpenedDoorway : progress;
- return msg;
- }
- private static MessageOfObj HiddenGate(EmergencyExit Exit)
- {
- MessageOfObj msg = new()
- {
- HiddenGateMessage = new()
- {
- X = Exit.Position.x,
- Y = Exit.Position.y,
- Opened = Exit.IsOpen
- }
- };
- return msg;
- }
-
- private static MessageOfObj Door(Door door)
- {
- MessageOfObj msg = new()
- {
- DoorMessage = new()
- {
- X = door.Position.x,
- Y = door.Position.y,
- Progress = door.OpenOrLockDegree,
- IsOpen = door.IsOpen
- }
- };
- return msg;
- }
- private static MessageOfObj Chest(Chest chest, int time)
- {
- MessageOfObj msg = new()
- {
- ChestMessage = new()
- {
- X = chest.Position.x,
- Y = chest.Position.y
- }
- };
- int progress = (chest.OpenStartTime > 0) ? ((time - chest.OpenStartTime) * chest.WhoOpen!.SpeedOfOpenChest) : 0;
- msg.ChestMessage.Progress = (progress > GameData.degreeOfOpenedChest) ? GameData.degreeOfOpenedChest : progress;
- return msg;
- }
- }
- }
|