Browse Source

fix: 🚑 fix a bug that a student can't be attacked

tags/0.1.0
shangfengh 2 years ago
parent
commit
e4b49a581f
5 changed files with 20 additions and 11 deletions
  1. +14
    -5
      logic/GameClass/GameObj/Character/Character.Student.cs
  2. +2
    -2
      logic/GameClass/GameObj/Character/Character.cs
  3. +2
    -2
      logic/Gaming/AttackManager.cs
  4. +1
    -1
      logic/Preparation/Utility/GameData.cs
  5. +1
    -1
      logic/cmd/gameServer.cmd

+ 14
- 5
logic/GameClass/GameObj/Character/Character.Student.cs View File

@@ -15,18 +15,26 @@ namespace GameClass.GameObj
/// <returns>人物在受到攻击后死了吗</returns>
public bool BeAttacked(Bullet bullet)
{

#if DEBUG
Debugger.Output(this, "is being shot!");
#endif
lock (beAttackedLock)
{
if (hp <= 0 || NoHp())
return false; // 原来已经死了
if (bullet.Parent.TeamID != this.TeamID)
if (bullet.Parent.IsGhost() != this.IsGhost())
{
#if DEBUG
Debugger.Output(bullet, bullet.AP.ToString());
#endif
if (TryUseShield())
{
if (bullet.HasSpear)
{
int subHp = TrySubHp(bullet.AP);
#if DEBUG
Debugger.Output(this, "is being shot! Now his hp is" + HP.ToString());
#endif
bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(subHp) + GameData.ScorePropUseSpear);
bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * subHp));
}
@@ -36,12 +44,13 @@ namespace GameClass.GameObj
else
{
int subHp = (bullet.HasSpear) ? TrySubHp(bullet.AP + GameData.ApSpearAdd) : TrySubHp(bullet.AP);
#if DEBUG
Debugger.Output(this, "is being shot with spear! Now his hp is" + HP.ToString());
#endif
bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(subHp));
bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * subHp));
}
#if DEBUG
Console.WriteLine($"PlayerID:{ID} is being shot! Now his hp is {hp}.");
#endif

if (hp <= 0)
TryActivatingLIFE(); // 如果有复活甲
}


+ 2
- 2
logic/GameClass/GameObj/Character/Character.cs View File

@@ -340,8 +340,8 @@ namespace GameClass.GameObj
}
}

public bool NoHp() => (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
&& playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued);
public bool NoHp() => (playerState == PlayerStateType.Deceased || playerState == PlayerStateType.Escaped
|| playerState == PlayerStateType.Addicted || playerState == PlayerStateType.Rescued);
public bool Commandable() => (playerState != PlayerStateType.Deceased && playerState != PlayerStateType.Escaped
&& playerState != PlayerStateType.Addicted && playerState != PlayerStateType.Rescued
&& playerState != PlayerStateType.Swinging && playerState != PlayerStateType.TryingToAttack


+ 2
- 2
logic/Gaming/AttackManager.cs View File

@@ -132,7 +132,7 @@ namespace Gaming
{
case GameObjType.Character:

if ((!((Character)objBeingShot).IsGhost()) && bullet.Parent.IsGhost())
if ((!(((Character)objBeingShot).IsGhost())) && bullet.Parent.IsGhost())
{
Student oneBeAttacked = (Student)objBeingShot;
if (oneBeAttacked.BeAttacked(bullet))
@@ -157,7 +157,7 @@ namespace Gaming
{
#if DEBUG
if (objBeingShot != null)
Debugger.Output(bullet, "bombed!" + objBeingShot.ToString());
Debugger.Output(bullet, "bombed with" + objBeingShot.ToString());
else
Debugger.Output(bullet, "bombed without objBeingShot");
#endif


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

@@ -79,7 +79,7 @@ namespace Preparation.Utility
public const int basicTreatmentDegree = 1500000;
public const int basicTimeOfRescue = 1000;

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

public const double basicConcealment = 1.0;


+ 1
- 1
logic/cmd/gameServer.cmd View File

@@ -1,6 +1,6 @@
@echo off

start cmd /k ..\Server\bin\Debug\net6.0\Server.exe --ip 0.0.0.0 --port 8888 --studentCount 2 --trickerCount 0 --gameTimeInSecond 600 --fileName test
start cmd /k ..\Server\bin\Debug\net6.0\Server.exe --ip 0.0.0.0 --port 8888 --studentCount 1 --trickerCount 1 --gameTimeInSecond 600 --fileName test

ping -n 2 127.0.0.1 > NUL



Loading…
Cancel
Save