Browse Source

build: finish the CopyInfo Of Student

tags/0.1.0
shangfengh 2 years ago
parent
commit
f0738c2534
6 changed files with 192 additions and 74 deletions
  1. +8
    -6
      dependency/proto/MessageType.proto
  2. +15
    -0
      logic/GameClass/GameObj/Character/Character.Student.cs
  3. +13
    -0
      logic/GameClass/GameObj/Character/Character.cs
  4. +6
    -5
      logic/Gaming/ActionManager.cs
  5. +1
    -1
      logic/Preparation/Utility/GameData.cs
  6. +149
    -62
      logic/Server/CopyInfo.cs

+ 8
- 6
dependency/proto/MessageType.proto View File

@@ -5,8 +5,8 @@ package protobuf;
enum BulletType enum BulletType
{ {
NULL_BULLET_TYPE = 0; NULL_BULLET_TYPE = 0;
LINE_BULLET = 1;
COMMON_BULLET = 2;
FLYING_KNIFE = 1;
COMMON_ATTACK_OF_GHOST = 2;
FAST_BULLET = 3; FAST_BULLET = 3;
ORDINARY_BULLET = 4; ORDINARY_BULLET = 4;
ATOM_BOMB = 5; ATOM_BOMB = 5;
@@ -40,9 +40,9 @@ enum ShapeType // 形状类型
enum PropType // 地图中的可拾取道具类型 enum PropType // 地图中的可拾取道具类型
{ {
NULL_PROP_TYPE = 0; NULL_PROP_TYPE = 0;
PTYPE1 = 1;
PTYPE2 = 2;
PTYPE3 = 3;
KEY3 = 1;
KEY5 = 2;
KEY6 = 3;
PTYPE4 = 4; PTYPE4 = 4;


} }
@@ -74,6 +74,8 @@ enum PlayerState
LOCKING = 13; LOCKING = 13;
RUMMAGING = 14; RUMMAGING = 14;
CLIMBING = 15; // 翻窗 CLIMBING = 15; // 翻窗
OPENING_A_CHEST =16;
USING_SPECIAL_SKILL = 17;
} }


enum TrickerBuffType // 屠夫可用的增益效果类型 enum TrickerBuffType // 屠夫可用的增益效果类型
@@ -97,7 +99,7 @@ enum PlayerType
enum StudentType enum StudentType
{ {
NULL_STUDENT_TYPE = 0; NULL_STUDENT_TYPE = 0;
STUDENTTYPE1 = 1;
ATHLETE = 1;
STUDENTTYPE2 = 2; STUDENTTYPE2 = 2;
STUDENTTYPE3 = 3; STUDENTTYPE3 = 3;
STUDENTTYPE4 = 4; STUDENTTYPE4 = 4;


+ 15
- 0
logic/GameClass/GameObj/Character/Character.Student.cs View File

@@ -81,6 +81,21 @@ namespace GameClass.GameObj
} }
} }


private int timeOfRescue = 0;
public int TimeOfRescue
{
get => timeOfRescue;
set
{
if (value > 0)
lock (gameObjLock)
timeOfRescue = (value < GameData.basicTimeOfRescue) ? value : GameData.basicTimeOfRescue;
else
lock (gameObjLock)
timeOfRescue = 0;
}
}

public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType) public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType)
{ {
this.fixSpeed = ((IStudent)Occupation).FixSpeed; this.fixSpeed = ((IStudent)Occupation).FixSpeed;


+ 13
- 0
logic/GameClass/GameObj/Character/Character.cs View File

@@ -234,6 +234,19 @@ namespace GameClass.GameObj
} }
} }


private int viewRange;
public int ViewRange
{
get => viewRange;
set
{
lock (gameObjLock)
{
viewRange = value;
}
}
}

private int timeOfOpeningOrLocking; private int timeOfOpeningOrLocking;
public int TimeOfOpeningOrLocking public int TimeOfOpeningOrLocking
{ {


+ 6
- 5
logic/Gaming/ActionManager.cs View File

@@ -209,7 +209,7 @@ namespace Gaming
return false; return false;
player.PlayerState = PlayerStateType.IsRescuing; player.PlayerState = PlayerStateType.IsRescuing;
playerRescued.PlayerState = PlayerStateType.IsRescued; playerRescued.PlayerState = PlayerStateType.IsRescued;
int rescuedDegree = 0;
player.TimeOfRescue = 0;
new Thread new Thread
( (
() => () =>
@@ -218,25 +218,26 @@ namespace Gaming
loopCondition: () => playerRescued.PlayerState == PlayerStateType.IsRescued && player.PlayerState == PlayerStateType.IsRescuing && gameMap.Timer.IsGaming && GameData.ApproachToInteract(playerRescued.Position, player.Position), loopCondition: () => playerRescued.PlayerState == PlayerStateType.IsRescued && player.PlayerState == PlayerStateType.IsRescuing && gameMap.Timer.IsGaming && GameData.ApproachToInteract(playerRescued.Position, player.Position),
loopToDo: () => loopToDo: () =>
{ {
rescuedDegree += GameData.frameDuration;
player.TimeOfRescue += GameData.frameDuration;
}, },
timeInterval: GameData.frameDuration, timeInterval: GameData.frameDuration,
finallyReturn: () => 0, finallyReturn: () => 0,
maxTotalDuration: 1000
maxTotalDuration: GameData.basicTimeOfRescue
) )

.Start(); .Start();


if (rescuedDegree >= 1000)
if (player.TimeOfRescue >= GameData.basicTimeOfRescue)
{ {
if (playerRescued.PlayerState == PlayerStateType.IsRescued) playerRescued.PlayerState = PlayerStateType.Null; if (playerRescued.PlayerState == PlayerStateType.IsRescued) playerRescued.PlayerState = PlayerStateType.Null;
if (player.PlayerState == PlayerStateType.IsRescuing) player.PlayerState = PlayerStateType.Null; if (player.PlayerState == PlayerStateType.IsRescuing) player.PlayerState = PlayerStateType.Null;

} }
else else
{ {
if (playerRescued.PlayerState == PlayerStateType.IsRescued) playerRescued.PlayerState = PlayerStateType.Null; if (playerRescued.PlayerState == PlayerStateType.IsRescued) playerRescued.PlayerState = PlayerStateType.Null;
if (player.PlayerState == PlayerStateType.IsRescuing) player.PlayerState = PlayerStateType.IsAddicted; if (player.PlayerState == PlayerStateType.IsRescuing) player.PlayerState = PlayerStateType.IsAddicted;
} }
player.TimeOfRescue = 0;
} }
) )
{ IsBackground = true }.Start(); { IsBackground = true }.Start();


+ 1
- 1
logic/Preparation/Utility/GameData.cs View File

@@ -65,7 +65,7 @@ namespace Preparation.Utility
public const int BeginGamingAddiction = 10003; public const int BeginGamingAddiction = 10003;
public const int MidGamingAddiction = 30000; public const int MidGamingAddiction = 30000;
public const int basicTreatmentDegree = 1500000; public const int basicTreatmentDegree = 1500000;
public const int basicRescueDegree = 100000;
public const int basicTimeOfRescue = 1000;


public const int basicMoveSpeed = 1260; // 基本移动速度,单位:s-1 public const int basicMoveSpeed = 1260; // 基本移动速度,单位:s-1
public const int characterMaxSpeed = 12000; // 最大速度 public const int characterMaxSpeed = 12000; // 最大速度


+ 149
- 62
logic/Server/CopyInfo.cs View File

@@ -1,21 +1,145 @@
using Protobuf; using Protobuf;
using System.Collections.Generic; using System.Collections.Generic;
using GameClass.GameObj; using GameClass.GameObj;
using System.Numerics;
using Preparation.Utility;


namespace Server namespace Server
{ {


public static class CopyInfo public static class CopyInfo
{ {
// 下面赋值为0的大概率是还没写完 2023-03-03
private static Protobuf.PlaceType ToPlaceType(Preparation.Utility.PlaceType place)
{
switch (place)
{
case Preparation.Utility.PlaceType.Window:
return Protobuf.PlaceType.Window;
case Preparation.Utility.PlaceType.EmergencyExit:
return Protobuf.PlaceType.HiddenGate;
case Preparation.Utility.PlaceType.Doorway:
return Protobuf.PlaceType.Gate;
case Preparation.Utility.PlaceType.Chest:
return Protobuf.PlaceType.Chest;
case Preparation.Utility.PlaceType.Door:
return Protobuf.PlaceType.Door;
case Preparation.Utility.PlaceType.Generator:
return Protobuf.PlaceType.Classroom;
case Preparation.Utility.PlaceType.Grass:
return Protobuf.PlaceType.Grass;
case Preparation.Utility.PlaceType.Wall:
return Protobuf.PlaceType.Wall;
case Preparation.Utility.PlaceType.Null:
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:
return Protobuf.PlaceType.Land;
default:
return Protobuf.PlaceType.NullPlaceType;
}
}

private static Protobuf.PropType ToPropType(Preparation.Utility.PropType prop)
{
switch (prop)
{
case Preparation.Utility.PropType.Key3:
return Protobuf.PropType.Key3;
case Preparation.Utility.PropType.Key5:
return Protobuf.PropType.Key5;
case Preparation.Utility.PropType.Key6:
return Protobuf.PropType.Key6;
default:
return Protobuf.PropType.NullPropType;
}
}

private static Protobuf.PlayerState ToPlayerState(Preparation.Utility.PlayerStateType playerState)
{
switch (playerState)
{
case Preparation.Utility.PlayerStateType.IsMoving:
case Preparation.Utility.PlayerStateType.Null:
return PlayerState.Idle;
case Preparation.Utility.PlayerStateType.IsAddicted:
return PlayerState.Addicted;
case Preparation.Utility.PlayerStateType.IsClimbingThroughWindows:
return PlayerState.Climbing;
case Preparation.Utility.PlayerStateType.IsDeceased:
return PlayerState.Quit;
case Preparation.Utility.PlayerStateType.IsEscaped:
return PlayerState.Graduated;
case Preparation.Utility.PlayerStateType.IsFixing:
return PlayerState.Learning;
case Preparation.Utility.PlayerStateType.IsLockingTheDoor:
return PlayerState.Locking;
case Preparation.Utility.PlayerStateType.IsOpeningTheChest:
return PlayerState.OpeningAChest;
case Preparation.Utility.PlayerStateType.IsRescued:
return PlayerState.Rescued;
case Preparation.Utility.PlayerStateType.IsRescuing:
return PlayerState.Rescuing;
case Preparation.Utility.PlayerStateType.IsStunned:
return PlayerState.Stunned;
case Preparation.Utility.PlayerStateType.IsSwinging:
return PlayerState.Swinging;
case Preparation.Utility.PlayerStateType.IsTreated:
return PlayerState.Treated;
case Preparation.Utility.PlayerStateType.IsTreating:
return PlayerState.Treating;
case Preparation.Utility.PlayerStateType.IsTryingToAttack:
return PlayerState.Attacking;
case Preparation.Utility.PlayerStateType.IsUsingSpecialSkill:
return PlayerState.UsingSpecialSkill;
default:
return PlayerState.NullStatus;
}
}

private static Protobuf.StudentBuffType ToStudentBuffType(Preparation.Utility.BuffType buffType)
{
switch (buffType)
{
case Preparation.Utility.BuffType.Null:
default:
return Protobuf.StudentBuffType.NullSbuffType;
}
}

private static Protobuf.BulletType ToBulletType(Preparation.Utility.BulletType bulletType)
{
switch (bulletType)
{
case Preparation.Utility.BulletType.FlyingKnife:
return Protobuf.BulletType.FlyingKnife;
case Preparation.Utility.BulletType.CommonAttackOfGhost:
return Protobuf.BulletType.CommonAttackOfGhost;
default:
return Protobuf.BulletType.NullBulletType;
}
}

private static Protobuf.StudentType ToStudentType(Preparation.Utility.CharacterType characterType)
{
switch (characterType)
{
case Preparation.Utility.CharacterType.Athlete:
return Protobuf.StudentType.Athlete;
default:
return Protobuf.StudentType.NullStudentType;
}
}

public static MessageOfObj? Auto(GameObj gameObj) public static MessageOfObj? Auto(GameObj gameObj)
{ {
if (gameObj.Type == Preparation.Utility.GameObjType.Character) if (gameObj.Type == Preparation.Utility.GameObjType.Character)
{ {
Character character = (Character)gameObj; Character character = (Character)gameObj;
if (character.IsGhost()) if (character.IsGhost())
return Tricker((Character)character);
else return Student((Character)character);
return Tricker((Ghost)character);
else return Student((Student)character);
} }
else if (gameObj.Type == Preparation.Utility.GameObjType.Bullet) else if (gameObj.Type == Preparation.Utility.GameObjType.Bullet)
return Bullet((Bullet)gameObj); return Bullet((Bullet)gameObj);
@@ -28,7 +152,7 @@ namespace Server
else return null; //先写着防报错 else return null; //先写着防报错
} }


private static MessageOfObj? Student(Character player)
private static MessageOfObj? Student(Student player)
{ {
MessageOfObj msg = new MessageOfObj(); MessageOfObj msg = new MessageOfObj();
if (player.IsGhost()) return null; if (player.IsGhost()) return null;
@@ -38,74 +162,37 @@ namespace Server
msg.StudentMessage.Y = player.Position.y; msg.StudentMessage.Y = player.Position.y;
msg.StudentMessage.Speed = player.MoveSpeed; msg.StudentMessage.Speed = player.MoveSpeed;
msg.StudentMessage.Determination = player.HP; msg.StudentMessage.Determination = player.HP;
msg.StudentMessage.Addiction = 0;
msg.StudentMessage.Addiction = player.GamingAddiction;

foreach (var keyValue in player.TimeUntilActiveSkillAvailable) foreach (var keyValue in player.TimeUntilActiveSkillAvailable)
msg.StudentMessage.TimeUntilSkillAvailable.Add(keyValue.Value); msg.StudentMessage.TimeUntilSkillAvailable.Add(keyValue.Value);

foreach (var Value in player.PropInventory)
msg.StudentMessage.Prop.Add(ToPropType(Value.GetPropType()));

msg.StudentMessage.Place = ToPlaceType(player.Place);
//msg.StudentMessage.StudentType; // 下面写 //msg.StudentMessage.StudentType; // 下面写
msg.StudentMessage.Guid = player.ID; msg.StudentMessage.Guid = player.ID;
// msg.StudentMessage.State = player.PlayerState;
msg.StudentMessage.PlayerId = 0;
msg.StudentMessage.ViewRange = 0;
msg.StudentMessage.Radius = 0;
msg.StudentMessage.Damage = 0;
msg.StudentMessage.DangerAlert = 0;
msg.StudentMessage.Score = 0;
msg.StudentMessage.TreatProgress = 0;
msg.StudentMessage.RescueProgress = 0;
msg.StudentMessage.State = ToPlayerState(player.PlayerState);
msg.StudentMessage.PlayerId = player.PlayerID;
msg.StudentMessage.ViewRange = player.ViewRange;
msg.StudentMessage.Radius = player.Radius;
msg.StudentMessage.DangerAlert = (player.BgmDictionary.ContainsKey(BgmType.GhostIsComing)) ? player.BgmDictionary[BgmType.GhostIsComing] : 0;
msg.StudentMessage.Score = player.Score;
msg.StudentMessage.TreatProgress = player.DegreeOfTreatment;
msg.StudentMessage.RescueProgress = player.TimeOfRescue;


foreach (KeyValuePair<Preparation.Utility.BuffType, bool> kvp in player.Buff) foreach (KeyValuePair<Preparation.Utility.BuffType, bool> kvp in player.Buff)
{ {
if (kvp.Value) if (kvp.Value)
{
switch (kvp.Key) // StudentBuffType具体内容待定
{
case Preparation.Utility.BuffType.Spear:
msg.StudentMessage.Buff.Add(StudentBuffType.NullSbuffType);
break;
case Preparation.Utility.BuffType.AddLIFE:
msg.StudentMessage.Buff.Add(StudentBuffType.NullSbuffType);
break;
case Preparation.Utility.BuffType.Shield:
msg.StudentMessage.Buff.Add(StudentBuffType.NullSbuffType);
break;
case Preparation.Utility.BuffType.AddSpeed:
msg.StudentMessage.Buff.Add(StudentBuffType.NullSbuffType);
break;
default:
break;
}
}
}

//Character的储存方式可能得改,用enum type存道具和子弹,不应该用对象
//现在懒得改了,有时间再重整一波
if (player.PropInventory == null)
msg.StudentMessage.Prop.Add(PropType.NullPropType);
else
{
switch (player.PropInventory.GetPropType())
{
case Preparation.Utility.PropType.Gem:
msg.StudentMessage.Prop.Add(PropType.NullPropType);
break;
/*case Preparation.Utility.PropType.addLIFE:
msg.StudentMessage.MessageOfHuman.Prop = Communication.Proto.PropType.AddLife;
break;
case Preparation.Utility.PropType.addSpeed:
msg.StudentMessage.MessageOfHuman.Prop = Communication.Proto.PropType.AddSpeed;
break;
case Preparation.Utility.PropType.Shield:
msg.StudentMessage.MessageOfHuman.Prop = Communication.Proto.PropType.Shield;
break;
case Preparation.Utility.PropType.Spear:
msg.StudentMessage.MessageOfHuman.Prop = Communication.Proto.PropType.Spear;
break;
default:
msg.StudentMessage.Prop = PropType.NullPropType;
break;*/
}
msg.StudentMessage.Buff.Add(ToStudentBuffType(kvp.Key));
} }


msg.StudentMessage.BulletType = ToBulletType(player.BulletOfPlayer);
msg.StudentMessage.LearningSpeed = player.FixSpeed;
msg.StudentMessage.TreatSpeed = player.TreatSpeed;
msg.StudentMessage.FacingDirection = player.FacingDirection.Angle();
msg.StudentMessage.StudentType = ToStudentType(player.CharacterType);
return msg; return msg;
} }




Loading…
Cancel
Save