Skip to content

Commit

Permalink
更改第一次摆位之后球队信息没有更新BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
jun0315 committed Jul 19, 2019
1 parent 932cb2b commit fde8e10
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
16 changes: 16 additions & 0 deletions Assets/Scripts/General/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ public class PlacementInfo
public Robot[] Robots = new Robot[Const.RobotsPerTeam];
public Ball Ball = new Ball();

public void PlacementInfoFromMatchInfo(MatchInfo matchInfo,Side side)
{
Ball = matchInfo.Ball;
if(side == Side.Blue)
{
Robots = (Robot[])matchInfo.BlueRobots.Clone();
}
else if(side == Side.Yellow)
{
Robots = (Robot[])matchInfo.YellowRobots.Clone();
}
else
{
Debug.Log("flase");
}
}
public void Normalize()
{
// TODO 保证不会出界、不会重叠
Expand Down
11 changes: 9 additions & 2 deletions Assets/Scripts/Scene/Play/PlayMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ void UpdatePlacementToScene(JudgeResult judgeResult)
currentMatchInfo.UpdateFrom(blueInfo.Robots, Side.Blue);
//先进行第一次摆位判罚
GlobalMatchInfo.Referee.JudgeAutoPlacement(currentMatchInfo, judgeResult, Side.Blue);
//判罚后将蓝方信息更新
blueInfo.PlacementInfoFromMatchInfo(currentMatchInfo, Side.Blue);
// 黄方后摆位
yellowInfo = StrategyManager.Yellow.GetPlacement(currentMatchInfo.GetSide(Side.Yellow));
// 黄方策略认为自己是蓝方,所以返回数据之后需要转换
Expand All @@ -582,7 +584,8 @@ void UpdatePlacementToScene(JudgeResult judgeResult)

//进行第二次裁判判罚
GlobalMatchInfo.Referee.JudgeAutoPlacement(currentMatchInfo, judgeResult, Side.Yellow);

//判罚后对黄方信息更新
yellowInfo.PlacementInfoFromMatchInfo(currentMatchInfo, Side.Yellow);
break;
}
case Side.Yellow:
Expand All @@ -594,14 +597,18 @@ void UpdatePlacementToScene(JudgeResult judgeResult)
// 将黄方返回的数据同步到currMi
currentMatchInfo.UpdateFrom(yellowInfo.Robots, Side.Yellow);
//进行第一次摆位判罚
GlobalMatchInfo.Referee.JudgeAutoPlacement(currentMatchInfo, judgeResult, Side.Blue);
GlobalMatchInfo.Referee.JudgeAutoPlacement(currentMatchInfo, judgeResult, Side.Yellow);
//判罚之后将黄方信息更新
yellowInfo.PlacementInfoFromMatchInfo(currentMatchInfo,Side.Yellow);
// 蓝方后摆位
blueInfo = StrategyManager.Blue.GetPlacement(currentMatchInfo.GetSide(Side.Blue));

// 从两方数据拼接MatchInfo,球的数据取决于judgeResult
currentMatchInfo = new MatchInfo(blueInfo, yellowInfo, judgeResult.Actor);
//进行第二次裁判判罚
GlobalMatchInfo.Referee.JudgeAutoPlacement(currentMatchInfo, judgeResult, Side.Blue);
//判罚之后将蓝方信息更新
blueInfo.PlacementInfoFromMatchInfo(currentMatchInfo, Side.Blue);
}

break;
Expand Down

0 comments on commit fde8e10

Please sign in to comment.