Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #124 from BowmanChow/dev
Browse files Browse the repository at this point in the history
在移动的时候把坐标保留6位小数,防止卡墙
  • Loading branch information
Sweetnow authored May 6, 2020
2 parents 4ba0f5b + 9d1c071 commit cb37f30
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions logic/THUnity2D/GameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ public virtual void Move(double angle, double distance)
return;
lastMoveTime = DateTime.Now;
MoveStart?.Invoke(this);
XYPosition previousPosition = _position;
_position = _position + new XYPosition(distance * Math.Cos(angle), distance * Math.Sin(angle));
XYPosition previousPosition = new XYPosition(Math.Round(_position.x, 6), Math.Round(_position.y, 6));
_position = previousPosition + new XYPosition(distance * Math.Cos(angle), distance * Math.Sin(angle));
Debug(this, "Move from " + previousPosition.ToString() + " angle : " + angle + " distance : " + distance + " aim : " + _position.ToString());
OnMove?.Invoke(this, angle, distance, previousPosition);
Debug(this, "Move result poition : " + this._position.ToString());
Expand Down
2 changes: 1 addition & 1 deletion logic/THUnity2D/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ void CheckBlockAndAdjustPosition(int x, int y)

//调整位置
Debug(this, "Moving " + childrenGameObject.ID + " resultDistance : " + resultDistance);
childrenGameObject._position = previousPosition + new XYPosition(resultDistance * Math.Cos(angle), resultDistance * Math.Sin(angle));
childrenGameObject._position = previousPosition + new XYPosition(Math.Round(resultDistance * Math.Cos(angle), 6), Math.Round(resultDistance * Math.Sin(angle), 6));
this._grid[(int)previousPosition.x, (int)previousPosition.y].DeleteGameObject(childrenGameObject);
this._grid[(int)childrenGameObject.Position.x, (int)childrenGameObject.Position.y].AddGameObject(childrenGameObject);
//调整位置 End
Expand Down
2 changes: 1 addition & 1 deletion runAgent.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
communication\Agent\bin\Release\netcoreapp3.0\Communication.Agent.exe --server 127.0.0.1:20000 --port 30000 --debugLevel 0 --playercount 1 --timelimit 25
communication\Agent\bin\Release\netcoreapp3.0\Communication.Agent.exe --server 127.0.0.1:20000 --port 30000 --debugLevel 0 --playercount 2 --timelimit 25
2 changes: 1 addition & 1 deletion runServer.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logic\Logic.Server\bin\Release\netcoreapp3.0\Logic.Server.exe --port 20000 --debugLevel 1 --playerCount 1 --agentCount 1 --gameTime 600
logic\Logic.Server\bin\Release\netcoreapp3.0\Logic.Server.exe --port 20000 --debugLevel 1 --playerCount 2 --agentCount 1 --gameTime 600

0 comments on commit cb37f30

Please sign in to comment.