void ddAddFkButtonHandle::invokeStart(hdMouseEvent &event, hdDrawingView *view) { if(getOwner()->ms_classInfo.IsKindOf(&ddTableFigure::ms_classInfo)) { ddRelationshipFigure *fkConnection = new ddRelationshipFigure(); //Check figure available positions for diagrams, add at least needed to allow initialization of the class int i, start; start = fkConnection->displayBox().CountPositions(); for(i = start; i < (view->getIdx() + 1); i++) { fkConnection->AddPosForNewDiagram(); } fkConnection->setStartTerminal(new ddRelationshipTerminal(fkConnection, false)); fkConnection->setEndTerminal(new ddRelationshipTerminal(fkConnection, true)); hdConnectionCreationTool *conn = new hdConnectionCreationTool(view, fkConnection); view->setTool(conn); // Simulate button down to start connection of foreign key wxMouseEvent e(wxEVT_LEFT_DOWN); e.m_x = event.GetPosition().x; e.m_y = event.GetPosition().y; e.SetEventObject(view); hdMouseEvent evento(e, view); conn->mouseDown(evento); ddTableFigure *table = (ddTableFigure *) getOwner(); table->setSelectFkDestMode(true); view->notifyChanged(); } }
//Evento Juego: Solicitud de comenzar void Servidor::on_evento_juego_solicitudcomenzar(const CL_NetGameEvent &e, UsuarioServidor *usuario) { CL_String nombre = e.get_argument(0); cl_log_event("eventos", "Cliente solicito comenzar juego"); CL_String mensaje= "Se conecto " + usuario->nombre_usuario; mundo->AgregarCadenaChat(mensaje); int id_nuevo = mundo->tanques.size(); enviaratodosEx(CL_NetGameEvent("Juego-Msj",mensaje),id_nuevo); //Enviar a todos que se conecto alquien CL_Vec2f pospawn = mundo->agregarTanque(id_nuevo,DEFAULT,nombre,false,false); //agrega el usuario //Devuelve el id_actual usuario->enviar_evento(CL_NetGameEvent("Juego-Comenzar",pospawn.x,pospawn.y,id_nuevo, nombre, mundo->getActualSubID())); //envia el SpawnPoint al usuario //enviaratodosEx(CL_NetGameEvent("Juego-AgregarTanque",pospawn.x,pospawn.y,id_nuevo, nombre), id_nuevo); //envia el SpawnPoint al usuario //Envia los tanques creados std::list<Tanque *>::iterator it; for(it=mundo->tanques.begin(); it != mundo->tanques.end(); ++it) { CL_NetGameEvent evento("Juego-JugadorConectado",(*it)->getID(),(*it)->getPos().x,(*it)->getPos().y //Envia al usuario todos los tanques ,(*it)->getanguloCuerpo(),(*it)->getAnguloTorreta()); evento.add_argument((*it)->getNombre()); //usuario->enviar_evento(evento); //actuales enviaratodos(evento); } mundo->quitarTodosPowerup(); //enviaratodosEx(CL_NetGameEvent("Juego-JugadorConectado",usuario->id,pospawn.x,pospawn.y,(*final)->getanguloCuerpo() //Envia a todos el nuevo tanque // ,(*final)->getAnguloTorreta()),usuario->id); }
/** LLamado al finalizar la partida. Se marca el juego como terminado y se le notifica a todos los participantes */ error Modelo::finalizar() { //Enviar un evento a todos avisando que termino. if (this->jugando != DISPAROS) return -ERROR_JUEGO_NO_COMENZADO; for (int i = 0; i < max_jugadores; i++) { if (this->jugadores[i] != NULL) { Evento evento(0, i, 0, 0, EVENTO_END); this->eventos[i].push(evento); } } this->jugando = FINALIZADO; return ERROR_NO_ERROR; }
/** Comienza la fase de tiros */ error Modelo::empezar() { if (this->jugando != SETUP) return -ERROR_JUEGO_EN_PROGRESO; for (int i = 0; i < max_jugadores; i++) { if (this->jugadores[i] != NULL) { Evento evento(0, i, 0, 0, EVENTO_START); this->eventos[i].push(evento); } } this->jugando = DISPAROS; return ERROR_NO_ERROR; }
/** Concretar el tiro efectivamente, solo tiene exito si ya trascurrió el eta. y e impacta con algo.*/ int Modelo::tocar(int s_id, int t_id) { if (this->jugando != DISPAROS) return -ERROR_JUEGO_NO_COMENZADO; if (this->jugadores[s_id] == NULL) return -ERROR_JUGADOR_INEXISTENTE; if (this->jugadores[t_id] == NULL) return -ERROR_JUGADOR_INEXISTENTE; int retorno = -ERROR_ETA_NO_TRANSCURRIDO; if (this->tiros[s_id].es_posible_tocar()) { int x = this->tiros[s_id].x; int y = this->tiros[s_id].y; bool murio = false; retorno = this->jugadores[t_id]->tocar(s_id, x, y, &murio); if (retorno == EMBARCACION_RESULTADO_TOCADO || retorno == EMBARCACION_RESULTADO_HUNDIDO || retorno == EMBARCACION_RESULTADO_HUNDIDO_M || retorno == EMBARCACION_RESULTADO_AGUA || retorno == EMBARCACION_RESULTADO_AGUA_H ) { this->tiros[s_id].estado = TIRO_LIBRE; Evento evento(s_id, t_id, x, y, retorno); //Evento para el tirado this->eventos[t_id].push(evento); //Evento para el tirador this->eventos[s_id].push(evento); if(murio){ this->cantidad_jugadores--; if(this->cantidad_jugadores == 1){ printf("Dale viejo!\n"); this->finalizar(); } } } if (retorno == EMBARCACION_RESULTADO_HUNDIDO) { this->jugadores[s_id]->agregar_puntaje(PUNTAJE_HUNDIDO); } else if (retorno == EMBARCACION_RESULTADO_HUNDIDO_M) { this->jugadores[s_id]->agregar_puntaje(PUNTAJE_HUNDIDO+PUNTAJE_MISMO_JUGADOR); } else if (retorno == EMBARCACION_RESULTADO_TOCADO) { this->jugadores[s_id]->agregar_puntaje(PUNTAJE_TOCADO); } else if (retorno == EMBARCACION_RESULTADO_AGUA_H) { this->jugadores[s_id]->agregar_puntaje(PUNTAJE_MAGALLANES); } } return retorno; }
void Juego::evento4(SDL_Event* Event4) { if(Event4->type == SDL_QUIT) { ejecutando = false; //hace que termine el while que esta ejecutando el juego } if(Event4->type == SDL_KEYDOWN) { switch(Event4->key.keysym.sym) { case SDLK_m : state = MENU; while(SDL_PollEvent(&Event)) { evento(&Event);//funcion que recibe el evento que esta realizando } } } }