bool Raven_Bot::canStepBackward(Vector2D& PositionOfStep)const { static const double StepDistance = BRadius() * 2; PositionOfStep = Pos() - Facing() * StepDistance - Facing() * BRadius(); return canWalkTo(PositionOfStep); }
bool Raven_Bot::canStepRight(Vector2D& PositionOfStep)const { static const double StepDistance = BRadius() * 2; PositionOfStep = Pos() + Facing().Perp() * StepDistance + Facing().Perp() * BRadius(); return canWalkTo(PositionOfStep); }
//--------------------------- Render ------------------------------------- // //------------------------------------------------------------------------ void Raven_Bot::Render() { //when a bot is hit by a projectile this value is set to a constant user //defined value which dictates how long the bot should have a thick red //circle drawn around it (to indicate it's been hit) The circle is drawn //as long as this value is positive. (see Render) m_iNumUpdatesHitPersistant--; if (isDead() || isSpawning()) return; gdi->BluePen(); m_vecBotVBTrans = WorldTransform(m_vecBotVB, Pos(), Facing(), Facing().Perp(), Scale()); gdi->ClosedShape(m_vecBotVBTrans); //draw the head (gdi->*(m_pTeam->GetPen()))(); gdi->Circle(Pos(), 6.0 * Scale().x); //render the bot's weapon m_pWeaponSys->RenderCurrentWeapon(); //render a thick red circle if the bot gets hit by a weapon if (m_bHit) { gdi->ThickRedPen(); gdi->HollowBrush(); gdi->Circle(m_vPosition, BRadius()+1); if (m_iNumUpdatesHitPersistant <= 0) { m_bHit = false; } } gdi->TransparentText(); gdi->TextColor(0,255,0); if (UserOptions->m_bShowBotIDs) { gdi->TextAtPos(Pos().x -10, Pos().y-20, ttos(ID())); } if (UserOptions->m_bShowBotHealth) { gdi->TextAtPos(Pos().x-40, Pos().y-5, "H:"+ ttos(Health())); } if (UserOptions->m_bShowScore) { gdi->TextAtPos(Pos().x-40, Pos().y+10, "Scr:"+ ttos(Score())); } }
void Obstacle::Write(std::ostream& os)const { os << std::endl; os << EntityType() << ",";//z 写入了实体类型,位置和半径 os << Pos() << ","; os << BRadius(); }
Trigger_SoundNotify::Trigger_SoundNotify(AbstRaven_Bot* source, double range):Trigger_LimitedLifetime<AbstRaven_Bot>(FrameRate /script->GetInt("Bot_TriggerUpdateFreq")), m_pSoundSource(source) { //set position and range SetPos(m_pSoundSource->Pos()); SetBRadius(range); //create and set this trigger's region of fluence AddCircularTriggerRegion(Pos(), BRadius()); }
//similar to above. Returns true if the bot can move between the two //given positions without bumping into any walls bool Raven_Bot::canWalkBetween(Vector2D from, Vector2D to)const { return !m_pWorld->isPathObstructed(from, to, BRadius()); }
//returns true if this bot can move directly to the given position //without bumping into any walls bool Raven_Bot::canWalkTo(Vector2D pos)const { return !m_pWorld->isPathObstructed(Pos(), pos, BRadius()); }
void Obstacle::Render() { ngdi->Circle(Pos(), BRadius()); }