📄 robot.h
字号:
/*--------------------------------------------------------------------------
Robot.h header file
----------------------------------------------------------------------------*/
/*
* Robot.h 声明了用户必须实现的事件处理函数和执行函数函数,
* 用户可以根据需要在相应的函数中加入代码来控制机器人的运作。
* 该文件中声明的一系列结构和函数提供了用户编程需要的基本信息。
*/
#include "Body.h"
#include "Gun.h"
#include "Radar.h"
#include "Event.h"
#include "Map.h"
#ifndef _Include_Robot
#define _Include_Robot
/////////////////////////////////////////////////////////////
//战斗地图
extern struct Map map;
//在事件处理函数被调用前相应的事件信息被放到这些结构中,
//当相应的事件处理函数执行时可以用到这些结构中的信息。
extern struct ScannedRobotEvent scannedRobotEvent;
extern struct BulletHitEvent bulletHitEvent;
extern struct HitByBulletEvent hitByBulletEvent;
extern struct HitRobotEvent hitRobotEvent;
extern struct HitWallEvent hitWallEvent;
extern struct RobotDeathEvent robotDeathEvent;
extern struct BeginEvent beginEvent;
extern struct FinishEvent finishEvent;
extern struct OvertimeEvent overtimeEvent;
/////////////////////////////////////////////////////////////
/*
* 执行函数,每个执行周期被调用一次
*/
void work(void);
//////////////////////////////////////////////////////////////
//事件处理函数,相应事件发生时被触发
/*
* 当雷达扫描到敌人时触发
*/
void onScannedRobot(void);
/*
* 当打中某个敌人时触发
*/
void onBulletHit(void);
/*
* 当被敌人打中时触发
*/
void onHitByBullet(void);
/*
* 当撞到其它敌人时触发
*/
void onHitRobot(void);
/*
* 当撞到墙时触发
*/
void onHitWall(void);
/*
* 当某个敌人死时触发
*/
void onRobotDeath(void);
/*
* 当开始一轮新的战斗时触发
*/
void onBegin(void);
/*
* 当一轮战斗结束时触发
*/
void onFinish(void);
/*
* 当机器人执行操作超时时触发
*/
void onOvertime(void);
///////////////////////////////////////////////////////////////////////
/**
* 在控制台输出信息
*/
void println(char * s);
/**
* 得到当前输出
*/
char * getOutput(void);
///////////////////////////////////////////////////////////////////////
// 这些函数返回一些关于机器人当前状态的信息
/*
* 得到当前时间
*/
long getTime(void);
/*
* 得到当前的比赛轮数
*/
int getCurrentRound(void);
/*
* 得到总的比赛轮数
*/
int getTotalRounds(void);
/*
* 得到剩余能量
*/
double getEnergy(void);
/*
* 得到当前的比赛得分
*/
double getScore(void);
/*
* 得到当前敌人总数
*/
int getOthers(void);
////////////////////////////////////////////////////////////////////
// 这些函数由系统调用,设置一些关于机器人当前状态的信息,
// 用户对这些函数的调用是无效的
/*
* 设置当前时间
*/
void setTime(long t);
/*
* 设置当前的比赛轮数
*/
void setCurrentRound(int r);
/*
* 设置总的比赛轮数
*/
void setTotalRounds(int t);
/*
* 设置剩余能量
*/
void setEnergy(double e);
/*
* 设置当前的比赛得分
*/
void setScore(double s);
/*
* 设置当前敌人总数
*/
void setOthers(int o);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -