Browse Source

refactor: 🎨 change EndMove

tags/v0.1.0
shangfengh 2 years ago
parent
commit
f9694c3d4a
6 changed files with 8 additions and 39 deletions
  1. +1
    -1
      docs/GameRules.md
  2. +1
    -4
      logic/GameClass/GameObj/Map/Window.cs
  3. +1
    -16
      logic/GameEngine/MoveEngine.cs
  4. +1
    -0
      logic/Gaming/ActionManager.cs
  5. +4
    -18
      logic/Gaming/AttackManager.cs
  6. +0
    -0
      logic/Gaming/CharacterManager.cs

+ 1
- 1
docs/GameRules.md View File

@@ -309,7 +309,7 @@ $$
- 不鼓励选手面向地图编程,因为移动过程中你可以受到多种干扰使得移动结果不符合你的预期;因此建议小步移动,边移动边考虑之后的行为。

### 人物
- 眩晕状态中的玩家不能再次被眩晕
- 眩晕状态中的玩家不能再次被眩晕(除非是ShowTime)

### 初始状态
- 初赛玩家出生点固定且一定为空地


+ 1
- 4
logic/GameClass/GameObj/Map/Window.cs View File

@@ -10,10 +10,9 @@ namespace GameClass.GameObj
/// </summary>
public class Window : Immovable
{
public Window(XY initPos, bool xIsWall) :
public Window(XY initPos) :
base(initPos, GameData.numOfPosGridPerCell / 2, GameObjType.Window)
{
this.xIsWall = xIsWall;
}
public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
@@ -28,8 +27,6 @@ namespace GameClass.GameObj
return false;
}

public readonly bool xIsWall;

private XY stage = new(0, 0);
public XY Stage
{


+ 1
- 16
logic/GameEngine/MoveEngine.cs View File

@@ -20,18 +20,6 @@ namespace GameEngine

private readonly ITimer gameTimer;
private readonly Action<IMoveable> EndMove;
public readonly uint[,] ProtoGameMap;
public PlaceType GetPlaceType(XY Position)
{
try
{
return (PlaceType)ProtoGameMap[Position.x / GameData.numOfPosGridPerCell, Position.y / GameData.numOfPosGridPerCell];
}
catch
{
return PlaceType.Null;
}
}

public IGameObj? CheckCollision(IMoveable obj, XY Pos)
{
@@ -52,7 +40,6 @@ namespace GameEngine
Action<IMoveable> EndMove
)
{
this.ProtoGameMap = gameMap.ProtoGameMap;
this.gameTimer = gameMap.Timer;
this.EndMove = EndMove;
this.OnCollision = OnCollision;
@@ -114,7 +101,7 @@ namespace GameEngine
if (!gameTimer.IsGaming) return;
lock (obj.ActionLock)
{
if (!obj.IsAvailableForMove) { obj.ThreadNum.Release(); return; }
if (!obj.IsAvailableForMove) { EndMove(obj); return; }
obj.IsMoving = true;
}
new Thread
@@ -152,7 +139,6 @@ namespace GameEngine
if (isEnded)
{
obj.IsMoving = false;
obj.ThreadNum.Release();
EndMove(obj);
return;
}
@@ -231,7 +217,6 @@ namespace GameEngine
} while (flag);
}
obj.IsMoving = false; // 结束移动
obj.ThreadNum.Release();
EndMove(obj);
}
}


+ 1
- 0
logic/Gaming/ActionManager.cs View File

@@ -491,6 +491,7 @@ namespace Gaming
},
EndMove: obj =>
{
obj.ThreadNum.Release();
// Debugger.Output(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount64);
}
);


+ 4
- 18
logic/Gaming/AttackManager.cs View File

@@ -47,15 +47,7 @@ namespace Gaming
if (bullet == null) return;
Debugger.Output(bullet, "Attack in " + pos.ToString());
gameMap.Add(bullet);
new Thread
(
() =>
{
bullet.ThreadNum.WaitOne();
moveEngine.MoveObj(bullet, (int)(bullet.AttackDistance * 1000 / bullet.MoveSpeed), angle, ++bullet.StateNum); // 这里时间参数除出来的单位要是ms
}
)
{ IsBackground = true }.Start();
moveEngine.MoveObj(bullet, (int)(bullet.AttackDistance * 1000 / bullet.MoveSpeed), angle, ++bullet.StateNum); // 这里时间参数除出来的单位要是ms
}

private void BombObj(Bullet bullet, GameObj objBeingShot)
@@ -203,15 +195,9 @@ namespace Gaming
{
Debugger.Output(bullet, "Attack in " + bullet.Position.ToString());
gameMap.Add(bullet);
new Thread
(
() =>
{
bullet.ThreadNum.WaitOne();
moveEngine.MoveObj(bullet, (int)(bullet.AttackDistance * 1000 / bullet.MoveSpeed), angle, ++bullet.StateNum); // 这里时间参数除出来的单位要是ms
}
)
{ IsBackground = true }.Start();

moveEngine.MoveObj(bullet, (int)(bullet.AttackDistance * 1000 / bullet.MoveSpeed), angle, ++bullet.StateNum); // 这里时间参数除出来的单位要是ms

if (bullet.CastTime > 0)
{
characterManager.SetPlayerState(player, PlayerStateType.TryingToAttack);


logic/Gaming/CharacterManager .cs → logic/Gaming/CharacterManager.cs View File


Loading…
Cancel
Save