Skip to content

Commit 5363a49

Browse files
authored
Merge branch 'dev' into dev-map
2 parents 94f7c3a + 3006964 commit 5363a49

File tree

9 files changed

+39
-11
lines changed

9 files changed

+39
-11
lines changed

CAPI/python/PyAPI/AI.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ def ShipPlay(self, api: IShipAPI) -> None:
5252

5353
def TeamPlay(self, api: ITeamAPI) -> None:
5454
assert self.__playerID == 0, "Team's playerID must be 0"
55-
api.BuildShip(shipType=THUAI7.ShipType.CivilianShip)
55+
# api.BuildShip(shipType=THUAI7.ShipType.CivilianShip)
5656
# 操作
5757
return

logic/Client/ViewModel/GeneralViewModel.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -661,13 +661,15 @@ Show the error message
661661
}
662662
});
663663

664+
int moveTime = 100;
665+
664666
MoveDownCommand = new Command(() =>
665667
{
666668
MoveMsg movemsg = new MoveMsg();
667669
movemsg.PlayerId = playerID;
668670
movemsg.TeamId = teamID;
669671
movemsg.Angle = double.Pi / 2;
670-
movemsg.TimeInMilliseconds = 50;
672+
movemsg.TimeInMilliseconds = moveTime;
671673
client.Move(movemsg);
672674
});
673675

@@ -677,7 +679,7 @@ Show the error message
677679
movemsg.PlayerId = playerID;
678680
movemsg.TeamId = teamID;
679681
movemsg.Angle = double.Pi;
680-
movemsg.TimeInMilliseconds = 50;
682+
movemsg.TimeInMilliseconds = moveTime;
681683
client.Move(movemsg);
682684
});
683685

@@ -687,7 +689,7 @@ Show the error message
687689
movemsg.PlayerId = playerID;
688690
movemsg.TeamId = teamID;
689691
movemsg.Angle = double.NegativeZero;
690-
movemsg.TimeInMilliseconds = 50;
692+
movemsg.TimeInMilliseconds = moveTime;
691693
client.Move(movemsg);
692694
});
693695

@@ -697,7 +699,7 @@ Show the error message
697699
movemsg.PlayerId = playerID;
698700
movemsg.TeamId = teamID;
699701
movemsg.Angle = double.Pi * 5 / 4;
700-
movemsg.TimeInMilliseconds = 50;
702+
movemsg.TimeInMilliseconds = moveTime;
701703
client.Move(movemsg);
702704
});
703705

@@ -707,7 +709,7 @@ Show the error message
707709
movemsg.PlayerId = playerID;
708710
movemsg.TeamId = teamID;
709711
movemsg.Angle = double.Pi * 7 / 4;
710-
movemsg.TimeInMilliseconds = 50;
712+
movemsg.TimeInMilliseconds = moveTime;
711713
client.Move(movemsg);
712714
});
713715

@@ -717,7 +719,7 @@ Show the error message
717719
movemsg.PlayerId = playerID;
718720
movemsg.TeamId = teamID;
719721
movemsg.Angle = double.Pi * 3 / 4;
720-
movemsg.TimeInMilliseconds = 50;
722+
movemsg.TimeInMilliseconds = moveTime;
721723
client.Move(movemsg);
722724
});
723725

@@ -727,7 +729,7 @@ Show the error message
727729
movemsg.PlayerId = playerID;
728730
movemsg.TeamId = teamID;
729731
movemsg.Angle = double.Pi / 4;
730-
movemsg.TimeInMilliseconds = 50;
732+
movemsg.TimeInMilliseconds = moveTime;
731733
client.Move(movemsg);
732734
});
733735
//Links = [

logic/GameClass/GameObj/Areas/Construction.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Construction(XY initPos)
77
{
88
public AtomicLong TeamID { get; } = new(long.MaxValue);
99
public InVariableRange<long> HP { get; } = new(0, GameData.CommunityHP);
10-
public override bool IsRigid => constructionType == ConstructionType.Community;
10+
public override bool IsRigid => true;
1111
public override ShapeType Shape => ShapeType.Square;
1212

1313
private readonly object lockOfConstructionType = new();

logic/GameClass/GameObj/Areas/Home.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Home(XY initPos, long id)
88
{
99
public long TeamID { get; } = id;
1010
public InVariableRange<long> HP => new(GameData.HomeHP);
11-
public override bool IsRigid => false;
11+
public override bool IsRigid => true;
1212
public override ShapeType Shape => ShapeType.Square;
1313

1414
public void BeAttacked(Bullet bullet)

logic/GameClass/GameObj/Map/Map.cs

+9
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ public Map(MapStruct mapResource)
211211
{
212212
switch (mapResource.map[i, j])
213213
{
214+
case PlaceType.Ruin:
215+
Add(new Ruin(GameData.GetCellCenterPos(i, j)));
216+
break;
217+
case PlaceType.Shadow:
218+
Add(new Shadow(GameData.GetCellCenterPos(i, j)));
219+
break;
220+
case PlaceType.Asteroid:
221+
Add(new Asteroid(GameData.GetCellCenterPos(i, j)));
222+
break;
214223
case PlaceType.Resource:
215224
Add(new Resource(GameData.GetCellCenterPos(i, j)));
216225
break;

logic/GameClass/GameObj/Ship.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ public long SetShipState(RunningStateType running, ShipStateType value = ShipSta
320320
lock (actionLock)
321321
{
322322
ShipStateType nowShipState = ShipState;
323+
Debugger.Output(this, "SetShipState from " + nowShipState + " to " + value);
323324
if (nowShipState == value) return -1;
324325
GameObj? lastObj = whatInteractingWith;
325326
switch (nowShipState)
@@ -336,6 +337,10 @@ public long SetShipState(RunningStateType running, ShipStateType value = ShipSta
336337
if (value == ShipStateType.Null || value == ShipStateType.Stunned)
337338
return ChangeShipState(running, value, gameObj);
338339
else return -1;
340+
case ShipStateType.Deceased:
341+
if (value == ShipStateType.Null)
342+
return ChangeShipState(running, value, gameObj);
343+
else return -1;
339344
default:
340345
return ChangeShipState(running, value, gameObj);
341346
}
@@ -355,11 +360,16 @@ public bool ResetShipState(long state, RunningStateType running = RunningStateTy
355360
{
356361
lock (actionLock)
357362
{
358-
if (state != stateNum) return false;
363+
if (state != stateNum)
364+
{
365+
Debugger.Output(this, "ResetShipState failed");
366+
return false;
367+
}
359368
runningState = running;
360369
whatInteractingWith = (GameObj?)obj;
361370
shipState = value;
362371
++stateNum;
372+
Debugger.Output(this, "ResetShipState succeeded" + stateNum);
363373
return true;
364374
}
365375
}
@@ -380,10 +390,12 @@ public bool StartThread(long stateNum, RunningStateType runningState)
380390
{
381391
if (StateNum == stateNum)
382392
{
393+
Debugger.Output(this, "StartThread succeeded");
383394
this.runningState = runningState;
384395
return true;
385396
}
386397
}
398+
Debugger.Output(this, "StartThread failed");
387399
return false;
388400
}
389401
public bool TryToRemoveFromGame(ShipStateType shipStateType)

logic/GameEngine/MoveEngine.cs

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ private bool LoopDo(IMovable obj, double direction, ref double deltaLen, long st
129129

130130
public void MoveObj(IMovable obj, int moveTime, double direction, long stateNum)
131131
{
132+
Debugger.Output(obj, $"Position {obj.Position}, Start moving in direction {direction}.");
132133
if (!gameTimer.IsGaming) return;
133134
lock (obj.ActionLock)
134135
{

logic/Gaming/ActionManager.cs

+2
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ public bool MoveShip(Ship shipToMove, int moveTimeInMilliseconds, double moveDir
4646
{
4747
if (moveTimeInMilliseconds < 5)
4848
{
49+
Debugger.Output("Move time is too short.");
4950
return false;
5051
}
5152
long stateNum = shipToMove.SetShipState(RunningStateType.Waiting, ShipStateType.Moving);
5253
if (stateNum == -1)
5354
{
55+
Debugger.Output("Ship is not commandable.");
5456
return false;
5557
}
5658
new Thread

logic/Gaming/Game.cs

+2
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,12 @@ public bool MoveShip(long teamID, long shipID, int moveTimeInMilliseconds, doubl
133133
Ship? ship = gameMap.FindShipInPlayerID(teamID, shipID);
134134
if (ship != null && ship.IsRemoved == false)
135135
{
136+
Debugger.Output("Trying to move: " + teamID + " " + shipID + " " + moveTimeInMilliseconds + " " + angle);
136137
return actionManager.MoveShip(ship, moveTimeInMilliseconds, angle);
137138
}
138139
else
139140
{
141+
Debugger.Output("Failed to move: " + teamID + " " + shipID + ", no ship found");
140142
return false;
141143
}
142144
}

0 commit comments

Comments
 (0)