//-------------------------------------------------------------------------------------------------- /// Draw the axis labels //-------------------------------------------------------------------------------------------------- void OverlayNavigationCube::renderAxisLabels(OpenGLContext* oglContext, bool software, const MatrixState& matrixState) { // Multiply with 1.08 will slightly pull the labels away from the corresponding arrow head Vec3f xPos(1.08f, 0, 0); Vec3f yPos(0, 1.08f, 0); Vec3f zPos(0, 0, 1.08f); DrawableText drawableText; drawableText.setFont(m_font.p()); drawableText.setCheckPosVisible(false); drawableText.setDrawBorder(false); drawableText.setDrawBackground(false); drawableText.setVerticalAlignment(TextDrawer::CENTER); drawableText.setTextColor(m_textColor); if (!m_xLabel.isEmpty()) drawableText.addText(m_xLabel, xPos); if (!m_yLabel.isEmpty()) drawableText.addText(m_yLabel, yPos); if (!m_zLabel.isEmpty()) drawableText.addText(m_zLabel, zPos); // Do the actual rendering // ----------------------------------------------- if (software) { drawableText.renderSoftware(oglContext, matrixState); } else { ref<ShaderProgram> textShader = oglContext->resourceManager()->getLinkedTextShaderProgram(oglContext); drawableText.render(oglContext, textShader.p(), matrixState); } }
void PrimitiveMeshHelper::WireAxis(float size) { DrawCmdData<Vertex> cmd; cmd.draw_mode = kDrawLines; VertexList &vert_list = cmd.vertex_list; //vertex list 생성 vec3 xPos(size, 0, 0); vec3 yPos(0, size, 0); vec3 zPos(0, 0, size); vec3 zero(0, 0, 0); sora::vec4ub red(255, 0, 0, 255); sora::vec4ub green(0, 255, 0, 255); sora::vec4ub blue(0, 0, 255, 255); { // x axis - r Vertex x_zero_vert; x_zero_vert.color = red; x_zero_vert.pos = zero; vert_list.push_back(x_zero_vert); Vertex x_one_vert; x_one_vert.color = red; x_one_vert.pos = xPos; vert_list.push_back(x_one_vert); } { //y axis - g Vertex zero_vert; zero_vert.color = green; zero_vert.pos = zero; vert_list.push_back(zero_vert); Vertex y_vert; y_vert.color = green; y_vert.pos = yPos; vert_list.push_back(y_vert); } { //z axis - b Vertex zero_vert; zero_vert.color = blue; zero_vert.pos = zero; vert_list.push_back(zero_vert); Vertex z_vert; z_vert.color = blue; z_vert.pos = zPos; vert_list.push_back(z_vert); } this->cmd_list_->push_back(cmd); }
//[sky] 召唤士兵(每个士兵都是一个独立的个体不同以召唤兽或者宠物) int SceneArchitecture::summonSoldiers(DWORD id, Cmd::petType type, WORD num, DWORD sid, const char * name, DWORD anpcid,zPos pos,BYTE dir) { zNpcB *base = npcbm.get(id); zNpcB *abase = NULL; if (anpcid>0) abase = npcbm.get(anpcid); if (NULL == base) return false; t_NpcDefine define; define.id = base->id; strncpy(define.name,base->name,MAX_NAMESIZE-1); if (pos.x != 0 && pos.y !=0) define.pos = pos; else define.pos = getPos(); define.num = 1; define.interval = 5; define.initstate = zSceneEntry::SceneEntry_Normal; define.width = 6; define.height = 6; define.pos -= zPos(define.width/2,define.height/2); define.scriptID = sid; scene->initRegion(define.region,define.pos,define.width,define.height); int NewNum = 0; SceneNpc * newPet = NULL; for( int i=0; i< num; i++ ) { newPet = scene->summonOneNpc<SceneNpc>(define,pos,base,dupIndex,0,abase,dir,this); if (newPet) { //sky 设置召唤出来的士兵的阵营和召唤者一样 newPet->BattCampID = this->BattCampID; if (name&&(0!=strncmp(name,"",MAX_NAMESIZE))) strncpy(newPet->name,name,MAX_NAMESIZE-1); SceneNpcManager::getMe().addSpecialNpc(newPet); newPet->aif = newPet->aif | AIF_ACTIVE_MODE; newPet->setDir(dir); newPet->setSpeedRate( 2.0 ); NewNum++; } } return NewNum; }
/** * \brief 召唤一个boss * 脚本中可定义多个boss,召唤时选择一个,以便从不同的位置出生,增加随机性 * * \return 召唤是否成功 */ bool Rush::summonBoss() { zNpcB *base = npcbm.get(bossID); if (NULL == base) { //Xlogger->debug("召唤攻城boss时,未找到该怪物 id=%d",bossID); return false; } int index = randBetween(0,bossVector.size()-1); t_NpcDefine define; define.id = base->id; strncpy(define.name,base->name,sizeof(define.name)); define.pos = bossVector[index].pos; define.num = bossVector[index].num; define.interval = 0x0fffffff;//这个时间一定要长 如果短于rush的cleartime,就会提前delete boss,clear时间到的时候就会coredump define.initstate = zSceneEntry::SceneEntry_Normal; define.width = bossVector[index].region*2; define.height = bossVector[index].region*2; define.pos -= zPos(bossVector[index].region,bossVector[index].region); define.scriptID = bossVector[index].script; Scene * scene = SceneManager::getInstance().getSceneByName(mapName); if (!scene) { Xlogger->debug("召唤攻城boss时,未找到该地图 name=%s",mapName); return false; } scene->initRegion(define.region,define.pos,define.width,define.height); boss = scene->summonOneNpc<SceneNpc>(define,bossVector[index].pos,base,0); //summonCount++; if (!boss) { Xlogger->debug("召唤攻城boss失败 id=%d",base->id); return false; } //SceneNpcManager::getMe().addSpecialNpc(boss); boss->isRushNpc = true; summonTime = SceneTimeTick::currentTime; return true; }
zPos RpgPlayerBag::getZPosByBagId(int bagId) { int x = bagId % ((int)_width); int y = bagId / _width; return zPos(x,y); }
void Mirror::printPos() const { post("/MirrorPos: %f, %f, %f", xPos(), yPos(), zPos()); }
bool Rush::summonPet() { if (!boss) return false; if (!canSummon) return false; int die = randBetween(0,100); for (DWORD index=0; index<servantVector.size(); index++) { if (servantVector[index].rate<die) continue; zNpcB *base = npcbm.get(servantVector[index].id); if (NULL == base) { Xlogger->debug("召唤 %s 的宠物时,未找到该怪物 id=%d",boss->name,servantVector[index].id); return false; } t_NpcDefine define; define.id = base->id; strncpy(define.name,base->name,sizeof(define.name)); zPos pos(boss->getPos()); pos -= zPos(summon_servant_region*2,summon_servant_region*2); define.pos = pos; define.num = servantVector[index].num; define.interval = 0x0fffffff; define.initstate = zSceneEntry::SceneEntry_Normal; define.width = summon_servant_region*4; define.height = summon_servant_region*4; //define.pos -= zPos(summon_servant_region,summon_servant_region); Scene * scene = SceneManager::getInstance().getSceneByName(mapName); if (!scene) { Xlogger->debug("召唤 %s 的仆人时,未找到该地图 name=%s",boss->name,mapName); return false; } scene->initRegion(define.region,define.pos,define.width,define.height); ScenePet * servant; int count = 0; for (int i=0; i<servantVector[index].num; i++) { servant = scene->summonOneNpc<ScenePet>(define,pos,base,0); if (servant) { servant->isRushNpc = true; servants.push_back(servant); servant->setMaster(boss); boss->totems.push_back(servant); count++; } } summonTime = SceneTimeTick::currentTime; summonTime.addDelay(servantVector[index].interval*1000); Xlogger->debug("%s summonPet:summon %u 次,servant %u 个",rushName,count,servants.size()); } return true; }
/** * \brief 处理进入阶段的事件 * 恢复、召唤、开关、说话等动作在阶段开始时发生 * 这些动作是瞬间的,如果阶段持续时间不为0,则在余下的时间内boss做普通攻击 * */ void Rush::enterNextPhase() { if (!end && curPhase<phaseVector.size()-1) { curPhase++; Xlogger->debug("%s : 阶段%d",rushName,curPhase); setPhaseTime(phaseVector[curPhase].lasttime*1000); if (strcmp(phaseVector[curPhase].say,"")) Channel::sendNine(boss,phaseVector[curPhase].say); //按照脚本来动作 if (boss->AIC->isActive() && phaseVector[curPhase].action!=RUSH_SUMMON_PET && phaseVector[curPhase].action!=RUSH_SUMMON_RUSH && phaseVector[curPhase].action!=RUSH_END) return; switch (phaseVector[curPhase].action) { case RUSH_RELIVE: break; case RUSH_MOVETO: { t_NpcAIDefine d(NPC_AI_PATROL,phaseVector[curPhase].pos,phaseVector[curPhase].region,phaseVector[curPhase].region,phaseVector[curPhase].lasttime); boss->AIC->setAI(d); } break; case RUSH_ATTACK: { t_NpcAIDefine d(NPC_AI_ATTACK,phaseVector[curPhase].pos,phaseVector[curPhase].region,phaseVector[curPhase].region,phaseVector[curPhase].lasttime); boss->AIC->setAI(d); } break; case RUSH_RECOVER: { boss->hp = boss->getMaxHP(); //boss->AIC->setNormalAI(); } break; case RUSH_SUMMON: { summonServant(); //boss->AIC->setNormalAI(); } break; case RUSH_BROADCAST: { Channel::sendCountryInfo(countryID,Cmd::CHAT_TYPE_GM,phaseVector[curPhase].say); } break; case RUSH_SUMMON_RUSH: { zNpcB *base = npcbm.get(phaseVector[curPhase].x); if (base) { t_NpcDefine define; zPos pos = phaseVector[curPhase].pos; define.id = base->id; strncpy(define.name,base->name,MAX_NAMESIZE-1); define.pos = phaseVector[curPhase].pos; define.num = 1; define.interval = 0x0fffffff; define.initstate = zSceneEntry::SceneEntry_Normal; define.width = phaseVector[curPhase].region; define.height = phaseVector[curPhase].region; define.pos -= zPos(phaseVector[curPhase].region/2,phaseVector[curPhase].region/2); define.scriptID = phaseVector[curPhase].z; Scene * scene = SceneManager::getInstance().getSceneByName(mapName); if (!scene) { Xlogger->debug("召唤攻城servant时,未找到该地图 name=%s",mapName); return; } scene->initRegion(define.region,define.pos,define.width,define.height); for (DWORD i=0; i<phaseVector[curPhase].y; i++) { SceneNpc * servant = scene->summonOneNpc<SceneNpc>(define,zPos(0,0),base,0,0,0); //summonCount++; if (servant) { servant->aif |= AIF_ACTIVE_MODE; servant->isRushNpc = true; servants.push_back(servant); #ifdef _DEBUG Xlogger->debug("[怪物攻城]%s (%u,%u)",servant->name,servant->getPos().x,servant->getPos().y); #endif } } } //boss->AIC->setNormalAI(); } break; case RUSH_SUMMON_PET: { summonPet(); } break; case RUSH_SUMMON_ON: { canSummon = true; //boss->AIC->setNormalAI(); } break; case RUSH_SUMMON_OFF: { canSummon = false; //boss->AIC->setNormalAI(); } break; case RUSH_CLEAR: { //boss->AIC->setNormalAI(); } break; case RUSH_END: { setPhaseTime(clearDelay*1000); //boss->AIC->setNormalAI(); } break; default: break; } } #if 0 else Xlogger->debug("%s : 攻城结束",rushName); #endif }