📄 baseagent.cpp
字号:
{
// AfxMessageBox("Infomation is error 0");
}
y=msg.ParseInteger();
if (msg.HasErrorOccured())
{
// AfxMessageBox("Infomation is error 1");
}
angle=msg.ParseDouble();
if(msg.HasErrorOccured())
{
// AfxMessageBox("Information is error 2");
}
// fprintf(fp,"m_iSide=%d\n",m_iSide);
switch (name.GetAt(0))
{
// it is a player
case 'P':
case 'p':
name.SetPosition(7);
// read the teamname
if (name.ParseString(teamname))
{
// ist it my team ?
if (teamname.Compare(_T(name)) == 0)
team = OWN_TEAM;
else
team = OTHER_TEAM;
// read player number
iNum = name.ParseInteger();
if (msg.HasErrorOccured())
{
// AfxMessageBox("Information error 3");
}
}
switch(iNum)
{
case 1://左方一号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][0].position.x=x;
r[0][0].position.y=y;
r[0][0].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)//如果是从右向左进攻,那么左方队员坐标就存入op里面
{
op.position1.x=x;
op.position1.y=y;
}
break;
case 2://左方二号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][1].position.x=x;
r[0][1].position.y=y;
r[0][1].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position2.x=x;
op.position2.y=y;
}
break;
case 3://左方三号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][2].position.x=x;
r[0][2].position.y=y;
r[0][2].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position3.x=x;
op.position3.y=y;
}
break;
case 4://左方四号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][3].position.x=x;
r[0][3].position.y=y;
r[0][3].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position4.x=x;
op.position4.y=y;
}
break;
case 5://左方五号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][4].position.x=x;
r[0][4].position.y=y;
r[0][4].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position5.x=x;
op.position5.y=y;
}
break;
case 6://左方六号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][5].position.x=x;
r[0][5].position.y=y;
r[0][5].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position6.x=x;
op.position6.y=y;
}
break;
case 7://左方七号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][6].position.x=x;
r[0][6].position.y=y;
r[0][6].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position7.x=x;
op.position7.y=y;
}
break;
case 8://左方八号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][7].position.x=x;
r[0][7].position.y=y;
r[0][7].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position8.x=x;
op.position8.y=y;
}
break;
case 9://左方九号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][8].position.x=x;
r[0][8].position.y=y;
r[0][8].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position9.x=x;
op.position9.y=y;
}
break;
case 10://左方十号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][9].position.x=x;
r[0][9].position.y=y;
r[0][9].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position10.x=x;
op.position10.y=y;
}
break;
case 11://左方十一号队员的坐标
if(m_iSide==LEFT_TO_RIGHT)
{
r[0][10].position.x=x;
r[0][10].position.y=y;
r[0][10].angle=(int)angle;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
op.position11.x=x;
op.position11.y=y;
}
break;
//下面的是从右向左进攻的队员的坐标处理
case 12:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position1.x=x;
op.position1.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)//右方一号队员坐标
{
r[0][0].position.x=x;
r[0][0].position.y=y;
r[0][0].angle=(int)angle;
}
break;
case 13:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position2.x=x;
op.position2.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][1].position.x=x;
r[0][1].position.y=y;
r[0][1].angle=(int)angle;
}
break;
case 14:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position3.x=x;
op.position3.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][2].position.x=x;
r[0][2].position.y=y;
r[0][2].angle=(int)angle;
}
break;
case 15:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position4.x=x;
op.position4.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][3].position.x=x;
r[0][3].position.y=y;
r[0][3].angle=(int)angle;
}
break;
case 16:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position5.x=x;
op.position5.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][4].position.x=x;
r[0][4].position.y=y;
r[0][4].angle=(int)angle;
}
break;
case 17:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position6.x=x;
op.position6.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][5].position.x=x;
r[0][5].position.y=y;
r[0][5].angle=(int)angle;
}
break;
case 18:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position7.x=x;
op.position7.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][6].position.x=x;
r[0][6].position.y=y;
r[0][6].angle=(int)angle;
}
break;
case 19:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position8.x=x;
op.position8.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][7].position.x=x;
r[0][7].position.y=y;
r[0][7].angle=(int)angle;
}
break;
case 20:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position9.x=x;
op.position9.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][8].position.x=x;
r[0][8].position.y=y;
r[0][8].angle=(int)angle;
}
break;
case 21:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position10.x=x;
op.position10.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][9].position.x=x;
r[0][9].position.y=y;
r[0][9].angle=(int)angle;
}
break;
case 22:
if(m_iSide==LEFT_TO_RIGHT)
{
op.position11.x=x;
op.position11.y=y;
}
else if(m_iSide==RIGHT_TO_LEFT)
{
r[0][10].position.x=x;
r[0][10].position.y=y;
r[0][10].angle=(int)angle;
}
break;
}
break;
case 'b':
case 'B':
// theball.angle=angle;
theball.position.x=x;
theball.position.y=y;
break;
case 'c':
case 'C':
name.SetPosition(7);
// read the teamname
if (name.ParseString(teamname))
{
// ist it my team ?
// read player number
iNum = name.ParseInteger();
if (msg.HasErrorOccured())
{
// AfxMessageBox("Information error 3");
}
}
}
return TRUE;
}
void CBaseAgent::SendCommand()
{
CString msg;
if(m_iSide==LEFT_TO_RIGHT)
{
msg.Format("((player left 1) %d %d) ((player left 2) %d %d) ((player left 3) %d %d) ((player left 4) %d %d) ((player left 5) %d %d) ((player left 6) %d %d) ((player left 7) %d %d) ((player left 8) %d %d) ((player left 9) %d %d) ((player left 10) %d %d) ((player left 11) %d %d)",
thePlannerL->command[2],thePlannerL->command[3],
thePlannerL->command[5],thePlannerL->command[6],
thePlannerL->command[8],thePlannerL->command[9],
thePlannerL->command[11],thePlannerL->command[12],
thePlannerL->command[14],thePlannerL->command[15],
thePlannerL->command[17],thePlannerL->command[18],
thePlannerL->command[20],thePlannerL->command[21],
thePlannerL->command[23],thePlannerL->command[24],
thePlannerL->command[26],thePlannerL->command[27],
thePlannerL->command[29],thePlannerL->command[30],
thePlannerL->command[32],thePlannerL->command[33]);
}
else if(m_iSide==RIGHT_TO_LEFT)
{
msg.Format("((player right 1) %d %d) ((player right 2) %d %d) ((player right 3) %d %d) ((player right 4) %d %d) ((player right 5) %d %d) ((player right 6) %d %d) ((player right 7) %d %d) ((player right 8) %d %d) ((player right 9) %d %d) ((player right 10) %d %d) ((player right 11) %d %d)",
thePlannerR->command[2],thePlannerR->command[3],
thePlannerR->command[5],thePlannerR->command[6],
thePlannerR->command[8],thePlannerR->command[9],
thePlannerR->command[11],thePlannerR->command[12],
thePlannerR->command[14],thePlannerR->command[15],
thePlannerR->command[17],thePlannerR->command[18],
thePlannerR->command[20],thePlannerR->command[21],
thePlannerR->command[23],thePlannerR->command[24],
thePlannerR->command[26],thePlannerR->command[27],
thePlannerR->command[29],thePlannerR->command[30],
thePlannerR->command[32],thePlannerR->command[33]);
}
SendMsg(msg);
}
void CBaseAgent::writetofile()
{
/*
fprintf(fp,"ball.x=%d,ball.y=%d\n",theball.position.x,theball.position.y);
fprintf(fp,"num1.x=%d,num1.y=%d,num1.angle=%d\n",r[0][0].position.x,r[0][0].position.y,r[0][0].angle);
fprintf(fp,"num2.x=%d,num2.y=%d,num2.angle=%d\n",r[0][1].position.x,r[0][1].position.y,r[0][1].angle);
fprintf(fp,"num3.x=%d,num3.y=%d,num3.angle=%d\n",r[0][2].position.x,r[0][2].position.y,r[0][2].angle);
fprintf(fp,"op1.x=%d,op1.y=%d\n",op.position1.x,op.position1.y);
fprintf(fp,"op2.x=%d,op2.y=%d\n",op.position2.x,op.position2.y);
fprintf(fp,"op3.x=%d,op3.y=%d\n",op.position3.x,op.position3.y);
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -