bool CUNIT::MoveTwice(const float3* pos1, const float3* pos2){ assert(ai->cb->GetUnitDef(myid) != NULL); if (!ai->cb->GetUnitDef(myid)->canmove) return false; const CCommandQueue* mycommands = ai->cb->GetCurrentUnitCommands(myid); if(mycommands->empty()) { Move(*pos1); MoveShift(*pos2); } else { const Command* c = &mycommands->front(); if(c->id != CMD_MOVE) { // The unit have some other orders, so give it new ones //assert(false); // For testing only Move(*pos1); MoveShift(*pos2); return true; } // The unit have a move order. Test if its the same as the ones in the list. if(c->params[0] != pos1->x || c->params[1] != pos1->y || c->params[2] != pos1->z) { // The unit have a diffrent move order. Give it new ones Move(*pos1); MoveShift(*pos2); return true; } // The first move order is ok, test if the next one is ok //return true; if(mycommands->size() == 1) { // It didnt have more orders. Add move nr.2 MoveShift(*pos2); return true; } // Get the next order. c = &mycommands->at(1); //c = &mycommands->back(); if(c->id != CMD_MOVE || c->params[0] != pos2->x || c->params[1] != pos2->y || c->params[2] != pos2->z) { // The unit have a diffrent stage two move order. Give it new ones. Move(*pos1); MoveShift(*pos2); return true; } // Both orders was in the queue. return true; } /* Command* c = MakePosCommand(CMD_MOVE, &pos); if(c->id != 0){ c->options|=SHIFT_KEY; ai->cb->GiveOrder(myid, c); return true; }*/ return true; }
void CameraControl::OnExcute(float sec) { float move_speed = m_move_speed; // 前后移动 float len = sec * move_speed * m_fDirection; if (len != 0) { // 前后平移 MoveFront(-len); } // 上下移动 float len1 = sec * move_speed * m_fUpDirection; if (len1 != 0) { MoveUp(len1); } // 左右平移 float delta = sec * move_speed * m_fShiftDirection; if (delta != 0) { MoveShift(delta); } }