void Hero::render() { CAnimatedMeshSceneNode::render(); video::SMaterial debug_mat; debug_mat.Lighting = false; debug_mat.AntiAliasing=0; gRender->setMaterial(debug_mat); gRender->setTransform(ETS_WORLD, IdentityMatrix); gRender->draw3DBox(getTransformedBoundingBox(), video::SColor(255,0,255,0)); gRender->draw3DBox(getAttackArea(), video::SColor(255,255,0,0)); }
bool CON_EnemyCanAttack::onEvaluate(const BTInputParam& input) const { const BlackBoard& inputData = input.getRealData<BlackBoard>(); auto self = inputData.self; auto area = self->getAttackArea(); area.x += self->getPositionX(); area.y += self->getPositionY(); // 寻找可攻击目标; GameObject *foundObject = nullptr; OBJECTS->callObjects([&](int id, GameObject *object, GameObjectView *view) -> bool { if (object && !object->shouldClean() && object->group() != self->group()) // 对象不销毁,非同组; { if (area.containsPoint(object->getPosition())) { foundObject = object; return false; // 寻找第一个可攻击目标; } } return true; }); if (foundObject) { self->setAttackTarget(foundObject); return true; } else { return false; } return false; }