public EditFormacionForm(FormacionListForm listForm, Formacion formacion, Repositorio repositorio) { InitializeComponent(); this.listForm = listForm; this.attrs = new FormacionAttr(formacion, repositorio); this.formacion = formacion; }
public async Task <IActionResult> Edit(int id, [Bind("Id,Profesion,CentroEstudios,FechaInicio,FechaFinalizacion")] Formacion formacion) { if (id != formacion.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(formacion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FormacionExists(formacion.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(formacion)); }
private void materialRaisedButton1_Click(object sender, EventArgs e) { Formacion formacion = new Formacion(); this.mainForm.EmbedForm(new CreateFormacionForm(this, formacion), tabPage); this.Visible = false; }
public FormacionAttr(Formacion formacion, Repositorio repositorio) { InitializeComponent(); pFormacion = formacion; validables.Add(new Validator <Formacion>(pFormacion, ReglaConcreta <Formacion> .dePresencia(unaFormacion => unaFormacion.Nombre), errorNombreLbl, bindingSourceFormacion)); validables.Add(new Validator <Formacion>(pFormacion, ReglaConcreta <Formacion> .dePositivo(unaFormacion => unaFormacion.KilometrosMantenimiento), errorDistanciaLbl, bindingSourceFormacion)); validables.Add(new Validator <Formacion>(pFormacion, ReglaConcreta <Formacion> .dePositivo(unaFormacion => unaFormacion.DuracionMantenimiento), errorTiempoManteLbl, bindingSourceFormacion)); validables.Add(new Validator <Formacion>(pFormacion, new ReglaConcreta <Formacion>(unaFormacion => unaFormacion.TiposCoche.Keys.Count > 0, "Debe tener por lo menos un tipo de coche"), errorCochesLbl)); cochesListados = AgrupacionCoche.From(formacion.TiposCoche); var modelos = repositorio.Listar <Coche>(); modeloCbo.Items.AddRange(modelos.ToArray()); validablesParaLista.Add(new Validator <AgrupacionCoche>(pCocheEditando, ReglaConcreta <AgrupacionCoche> .dePositivo(unaAgrupacionCoche => unaAgrupacionCoche.Cantidad), errorCantidadLbl)); validablesParaLista.Add(new Validator <AgrupacionCoche>(pCocheEditando, new ReglaCompuesta <AgrupacionCoche>(new List <Regla <AgrupacionCoche> > { new ReglaConcreta <AgrupacionCoche>(unaAgrupacion => unaAgrupacion.Coche != null, "Este campo es requerido"), new ReglaConcreta <AgrupacionCoche>(unaAgrupacion => cochesListados.TrueForAll(otraAgrupacion => !unaAgrupacion.Coche.Equals(otraAgrupacion.Coche)), "No se puede usar el mismo tipo\n de coche dos veces") }), errorModeloLbl)); bindingSourceFormacion.DataSource = pFormacion; bindingSourceCocheEditando.DataSource = pCocheEditando; this.dibujarListado(); distanciaManteField.IsNumeric = true; tiempoEnManteField.IsNumeric = true; cantidadCocheField.IsNumeric = true; }
public IHttpActionResult AddFormacion(Formacion formacion) { formacion.Id = Guid.NewGuid(); _context.Formaciones.Add(formacion); _context.SaveChanges(); return(Ok(formacion)); }
public async Task <bool> DeleteFormacion(Formacion formacion) { string sql = "DELETE FROM dbo.Formacion WHERE Formacion.IdFormacion = '" + formacion.IdFormacion + "'"; var result = await _dataAccess.SaveData <Formacion>(sql, formacion); return(result == 1); }
public async Task <bool> UpdateFormacion(Formacion formacion) { string sql = "UPDATE dbo.Formacion SET IdCurriculum = '" + formacion.IdCurriculum + "', Titulo = '" + formacion.Titulo + "', FechaInicio = '" + formacion.FechaInicio + "', FechaFin = '" + formacion.FechaFin + "', Centro = '" + formacion.Centro + "', Descripcion = '" + formacion.Descripcion + "' " + "WHERE IdFormacion = '" + formacion.IdFormacion + "'"; var result = await _dataAccess.SaveData <Formacion>(sql, formacion); return(result == 1); }
public void addFormacion(Formacion formacion) { using (var repositorio = new Repositorio()) { repositorio.GuardarOActualizar(formacion); } this.dibujarRenglones(); }
public void OnformacionEdit(int formacionId) { using (var repositorio = new Repositorio()) { Formacion formacion = repositorio.Obtener <Formacion>(formacionId); this.mainForm.EmbedForm(new EditFormacionForm(this, formacion, repositorio), tabPage); this.Visible = false; } }
public RenglonDeFormacion(Formacion formacion, Del handleEdit, Del handleRemove) { InitializeComponent(); this.nombreLbl.Text = formacion.Nombre; this.mantenimientoEntreLbl.Text = formacion.KilometrosMantenimiento.ToString() + " Km"; this.duracionMantenimientoLbl.Text = formacion.DuracionMantenimiento.ToString() + " Min"; this.id = formacion.Id; this.handleEdit = handleEdit; this.handleRemove = handleRemove; }
public CreateFormacionForm(FormacionListForm listForm, Formacion formacion) { InitializeComponent(); using (var repositorio = new Repositorio()) { this.attrs = new FormacionAttr(formacion, repositorio); } this.formacion = formacion; this.listForm = listForm; }
public async Task <IActionResult> Create([Bind("Id,Nombre")] Formacion formacion) { if (ModelState.IsValid) { _context.Add(formacion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(formacion)); }
public async Task <IActionResult> Create([Bind("Id,Profesion,CentroEstudios,FechaInicio,FechaFinalizacion")] Formacion formacion) { if (ModelState.IsValid) { _context.Add(formacion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(formacion)); }
private void onformacionRemove(int id) { if (MaterialMessageBoxConfirmation.Show("Confirmación", "¿Está seguro que desea eliminar la formación?") == DialogResult.Yes) { using (var repositorio = new Repositorio()) { Formacion formacion = repositorio.Obtener <Formacion>(id); repositorio.Eliminar(formacion); } this.dibujarRenglones(); } }
/// <summary> /// Método para dilatar la espera entre enemigos si se trata de una formación /// </summary> /// <param name="enemigo"></param> /// <returns></returns> private float CalcularPausaEntreEnemigos(GameObject enemigo) { Formacion formacion = enemigo.GetComponent <Formacion>(); if (formacion != null) //Es una formacion { float espera = pausaEntreEnemigos + formacion.CorreccionInstanciamiento; //Las formaciones son mas grandes, hay que dejar que pase un poco mas de tiempo return(espera); } else { return(pausaEntreEnemigos); } }
/// <summary> /// Método para calcular la zona de despliegue /// </summary> /// <param name="enemigo"></param> /// <returns></returns> private float CalcularCoordenadaX(GameObject enemigo) { //Las formaciones son mayores por lo que hay que reducir la zona de despliege Formacion formacion = enemigo.GetComponent <Formacion>(); if (formacion != null) //Es una formacion { return(UnityEngine.Random.Range(-zonaDespliegeEnemigos.x + formacion.CorreccionEjeX, zonaDespliegeEnemigos.x - formacion.CorreccionEjeX)); } else { return(UnityEngine.Random.Range(-zonaDespliegeEnemigos.x, zonaDespliegeEnemigos.x)); } }
public async Task <bool> AddFormacion(Formacion formacion) { string sql = "INSERT INTO dbo.Formacion (IdFormacion," + " IdCurriculum, Titulo)" + " VALUES ('" + formacion.IdFormacion + "', '" + formacion.IdCurriculum + "', '" + formacion.Titulo + "')"; var result = await _dataAccess.SaveData <Formacion>(sql, formacion); return(result == 1); }
protected void Update() { //INPUT MANAGEMENT //CAMERA INPUT HERE (AROUND THE MAP) if (!mouseOverUI) { if (mouseBehav == MOUSE_ACTION.SELECT) { if (Input.GetMouseButton(0)) { if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajePlayer character = hit.collider.gameObject.GetComponent <PersonajePlayer>(); if (!selectedUnits.Contains(character)) { character.selected = true; characterWithFocus = character; selectedUnits.Add(character); ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } else { character.selected = false; if (character == characterWithFocus) { characterWithFocus = null; ui.showDebugInfo(false); } selectedUnits.Remove(character); } } ui.actualizeUserButtons(allPossibleActions()); } else { foreach (PersonajePlayer person in selectedUnits) { person.selected = false; } selectedUnits.Clear(); RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajePlayer character = hit.collider.gameObject.GetComponent <PersonajePlayer>(); character.selected = true; characterWithFocus = character; selectedUnits.Add(character); ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } else { if (characterWithFocus != null) { characterWithFocus = null; ui.showDebugInfo(false); } } ui.actualizeUserButtons(allPossibleActions()); } } } else if (mouseBehav == MOUSE_ACTION.MOVE) { if (selectedUnits.Count > 0) { if (Input.GetMouseButton(0)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajeBase personajeObjetivo = hit.collider.gameObject.GetComponent <PersonajeBase>(); foreach (PersonajeBase person in selectedUnits) { if (person.currentFormacion != null && person.currentFormacion.lider != person) { formaciones.Remove(person.currentFormacion); person.currentFormacion.disband(); } PursueSD pursueSD = new PursueSD(); pursueSD.target = personajeObjetivo; /*person.fake.posicion = hit.point; * person.fake.moveTo(hit.point); * person.fake.innerDetector = person.innerDetector;*/ person.newTask(pursueSD); } } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 10)) { foreach (PersonajeBase person in selectedUnits) { if (person.currentFormacion != null && person.currentFormacion.lider != person) { formaciones.Remove(person.currentFormacion); person.currentFormacion.disband(); } PursueSD pursueSD = new PursueSD(); pursueSD.target = person.fakeMovement; person.fakeMovement.posicion = hit.point; person.fakeMovement.moveTo(hit.point); // mover los fakes para debuggeo person.fakeMovement.innerDetector = person.innerDetector; person.newTask(pursueSD); } } } } } else if (mouseBehav == MOUSE_ACTION.FORM_T || mouseBehav == MOUSE_ACTION.FORM_S || mouseBehav == MOUSE_ACTION.FORM_R) { if (selectedUnits.Count > 0) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { // PARA FORMACIONES foreach (PersonajeBase person in selectedUnits) { if (person.currentFormacion != null) { formaciones.Add(person.currentFormacion); person.currentFormacion.disband(); } } //Asignamos el lider que clicamos PersonajeBase lider = hit.collider.gameObject.GetComponent <PersonajeBase>(); Formacion formacion = null; switch (mouseBehav) { case MOUSE_ACTION.FORM_T: formacion = new FormacionTriangulo(lider); break; case MOUSE_ACTION.FORM_S: formacion = new FormacionCuadrado(lider); break; case MOUSE_ACTION.FORM_R: formacion = new FormacionPorRoles(lider); break; } foreach (PersonajeBase person in selectedUnits) { person.currentFormacion = formacion; if (person != lider) { formacion.addMiembro(person); } } formacion.formacionASusPuestos(); formaciones.Add(formacion); //PARA FLOCKING /*PersonajeBase lider = hit.collider.gameObject.GetComponent<PersonajeBase>(); * foreach (PersonajeBase person in selectedUnits) * { * if (person!= lider) * { * FlockingSD flocking = new FlockingSD(1,1,1); * flocking.target = lider; * person.newTask(flocking); * } * }*/ } } } } else if (mouseBehav == MOUSE_ACTION.ROUTE_SET) { if (selectedUnits.Count > 0) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 11)) { setRouteOnUnits(); pathToSet.Clear(); setMouseBehaviour(0); ui.selectMouseOption(0); /*foreach (PersonajeBase person in selectedUnits) * { * if (person.currentFormacion != null) * { * formationManager.removeFormacion(person.currentFormacion); * person.currentFormacion.disband(); * } * }*/ } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 10)) { if (pathToSet.Count == 0) { foreach (PersonajeBase unit in selectedUnits) { foreach (Transform routeElem in unit.routeMarks) { Destroy(routeElem.gameObject); } } } pathToSet.Add(hit.point); foreach (PersonajeBase unit in selectedUnits) { GameObject routeMark = Instantiate(routeMarkPrefab, unit.routeMarks); routeMark.transform.position = new Vector3(hit.point.x, 0.05f, hit.point.z); if (pathToSet.Count > 1) { GameObject routeLine = Instantiate(routeLinePrefab, unit.routeMarks); routeLine.GetComponent <FlechaDeRutaDelegate>().setRouteDirection(pathToSet[pathToSet.Count - 2], pathToSet[pathToSet.Count - 1]); } } } } } } } }
internal static string SentidoServicio(Formacion formacion) { string servicio = formacion.Servicio.Nombre; return(servicio); }
public IHttpActionResult UpdateFormacion(Formacion formacion) { _context.Entry(formacion).State = EntityState.Modified; _context.SaveChanges(); return(Ok(formacion)); }
public bool applyTo(Formacion formacion) { this.pFormacion.TiposCoche = AgrupacionCoche.ToDictionary(cochesListados); validables.ForEach(validable => validable.mostrarError()); return(validables.TrueForAll(validable => validable.esValido())); }
protected new void Update() { if (!iaControlled) { if (!mouseOverUI) { if (mouseBehav == MOUSE_ACTION_FINAL.SELECT) { if (Input.GetMouseButton(0)) { if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajePlayer character = hit.collider.gameObject.GetComponent <PersonajePlayer>(); if (!selectedUnits.Contains(character)) { character.selected = true; characterWithFocus = character; selectedUnits.Add(character); ui.showDebugInfo(true); (ui as UIManagerFinal).actualizeAgentDebugInfo(characterWithFocus); } else { character.selected = false; if (character == characterWithFocus) { characterWithFocus = null; ui.showDebugInfo(false); } selectedUnits.Remove(character); } } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 13)) { PersonajeNPC character = hit.collider.gameObject.GetComponent <PersonajeNPC>(); if (character != characterWithFocus) { characterWithFocus = character; ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } } } else { foreach (PersonajePlayer person in selectedUnits) { person.selected = false; } selectedUnits.Clear(); RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajePlayer character = hit.collider.gameObject.GetComponent <PersonajePlayer>(); character.selected = true; characterWithFocus = character; selectedUnits.Add(character); ui.showDebugInfo(true); (ui as UIManagerFinal).actualizeAgentDebugInfo(characterWithFocus); } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 13)) { PersonajeNPC character = hit.collider.gameObject.GetComponent <PersonajeNPC>(); if (character != characterWithFocus) { characterWithFocus = character; ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } } else { if (characterWithFocus != null) { characterWithFocus = null; ui.showDebugInfo(false); } } } ui.actualizeUserButtons(allPossibleActions()); } } else if (mouseBehav == MOUSE_ACTION_FINAL.MOVE) { if (selectedUnits.Count > 0) { if (Input.GetMouseButton(0)) { RaycastHit hit; /*if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 9)) * { * return; * } * else */ if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 13)) { PersonajeBase enemigo = hit.collider.GetComponent <PersonajeBase>(); foreach (PersonajeBase person in selectedUnits) { AccionCompuesta ac = TacticalModule.createAttackingAction(person, enemigo); if (person.currentFormacion != null) { Formacion formation = person.currentFormacion; if (person.currentFormacion.lider == person) { formation.disbandGrid(); for (int i = 0; i < formation.getMiembros.Length; i++) { if (formation.getMiembros[i] != null) { AccionCompuesta attackMachaka = TacticalModule.createAttackingAction(formation.getMiembros[i], enemigo); formation.getMiembros[i].accion = attackMachaka; formation.getMiembros[i].accion.doit(); } } formaciones.Remove(formation); } else { formation.removeMiembro(person); person.currentFormacion = null; person.accion = ac; person.accion.doit(); } } else { person.accion = ac; person.accion.doit(); } } } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 14)) { Vector2 baseToGo = positionToGrid(hit.collider.transform.parent.position); foreach (PersonajeBase person in selectedUnits) { ActionGo gotobase = new ActionGo(person, TacticalModule.getUnitPointOnBaseStatic(person, baseToGo, gm.getAllies()), null); if (person.currentFormacion != null) { Formacion formation = person.currentFormacion; if (person.currentFormacion.lider == person) { formation.disbandGrid(); for (int i = 0; i < formation.getMiembros.Length; i++) { if (formation.getMiembros[i] != null) { ActionGo gotobaseMachakas = new ActionGo(formation.getMiembros[i], TacticalModule.getUnitPointOnBaseStatic(formation.getMiembros[i], baseToGo, gm.getAllies()), null); formation.getMiembros[i].accion = gotobaseMachakas; formation.getMiembros[i].accion.doit(); } } formaciones.Remove(formation); } else { formation.removeMiembro(person); person.currentFormacion = null; person.accion = gotobase; person.accion.doit(); } } else { person.accion = gotobase; person.accion.doit(); } } } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 10)) { foreach (PersonajeBase person in selectedUnits) { Vector2 posicionDestino = positionToGrid(hit.point); Vector2 posicionOrigen = positionToGrid(person.posicion); ActionGo moverse = new ActionGo(person, posicionDestino, null); if (person.currentFormacion != null) { Formacion formation = person.currentFormacion; if (person.currentFormacion.lider != person) { formation.removeMiembro(person); person.currentFormacion = null; } person.accion = moverse; person.accion.doit(); } else { person.accion = moverse; person.accion.doit(); } } } } } } else if (mouseBehav == MOUSE_ACTION_FINAL.FORM_T || mouseBehav == MOUSE_ACTION_FINAL.FORM_S || mouseBehav == MOUSE_ACTION_FINAL.FORM_R) { if (selectedUnits.Count > 0) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { // PARA FORMACIONES foreach (PersonajeBase person in selectedUnits) { if (person.currentFormacion != null) { formaciones.Remove(person.currentFormacion); person.currentFormacion.disbandGrid(); } } //Asignamos el lider que clicamos PersonajeBase lider = hit.collider.gameObject.GetComponent <PersonajeBase>(); Formacion formacion = null; switch (mouseBehav) { case MOUSE_ACTION_FINAL.FORM_T: formacion = new FormacionTriangulo(lider); break; case MOUSE_ACTION_FINAL.FORM_S: formacion = new FormacionCuadrado(lider); break; case MOUSE_ACTION_FINAL.FORM_R: formacion = new FormacionPorRoles(lider); break; } foreach (PersonajeBase person in selectedUnits) { person.currentFormacion = formacion; formacion.addMiembro(person); } lider.currentFormacion = formacion; formacion.formacionASusPuestosAccion(); //formacion.formacionASusPuestos(); formaciones.Add(formacion); } } } } else if (mouseBehav == MOUSE_ACTION_FINAL.ROUTE_SET) { if (selectedUnits.Count > 0) { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 11)) { foreach (PersonajeBase person in selectedUnits) { if (person.currentFormacion != null) { formaciones.Remove(person.currentFormacion); person.currentFormacion.disbandGrid(); } } setRouteOnUnits(); pathToSet.Clear(); setMouseBehaviour(0); ui.selectMouseOption(0); } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 10)) { if (pathToSet.Count == 0) { foreach (PersonajeBase unit in selectedUnits) { foreach (Transform routeElem in unit.routeMarks) { Destroy(routeElem.gameObject); } } } pathToSet.Add(hit.point); foreach (PersonajeBase unit in selectedUnits) { GameObject routeMark = Instantiate(routeMarkPrefab, unit.routeMarks); routeMark.transform.position = new Vector3(hit.point.x, 0.05f, hit.point.z); if (pathToSet.Count > 1) { GameObject routeLine = Instantiate(routeLinePrefab, unit.routeMarks); routeLine.GetComponent <FlechaDeRutaDelegate>().setRouteDirection(pathToSet[pathToSet.Count - 2], pathToSet[pathToSet.Count - 1]); } } } } } } } } else { if (Input.GetMouseButton(0)) { if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajePlayer character = hit.collider.gameObject.GetComponent <PersonajePlayer>(); if (!selectedUnits.Contains(character)) { character.selected = true; characterWithFocus = character; selectedUnits.Add(character); ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } else { character.selected = false; if (character == characterWithFocus) { characterWithFocus = null; ui.showDebugInfo(false); } selectedUnits.Remove(character); } } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 13)) { PersonajeNPC character = hit.collider.gameObject.GetComponent <PersonajeNPC>(); if (character != characterWithFocus) { characterWithFocus = character; ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } } } else { foreach (PersonajePlayer person in selectedUnits) { person.selected = false; } selectedUnits.Clear(); RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajePlayer character = hit.collider.gameObject.GetComponent <PersonajePlayer>(); character.selected = true; characterWithFocus = character; selectedUnits.Add(character); ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 13)) { PersonajeNPC character = hit.collider.gameObject.GetComponent <PersonajeNPC>(); if (character != characterWithFocus) { characterWithFocus = character; ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } } else { if (characterWithFocus != null) { characterWithFocus = null; ui.showDebugInfo(false); } } } } } }
protected new void Update() { if (!mouseOverUI) { if (mouseBehav == MOUSE_ACTION_FORMATION.SELECT) { if (Input.GetMouseButton(0)) { if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajePlayer character = hit.collider.gameObject.GetComponent <PersonajePlayer>(); if (!selectedUnits.Contains(character)) { character.selected = true; characterWithFocus = character; selectedUnits.Add(character); ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } else { character.selected = false; if (character == characterWithFocus) { characterWithFocus = null; ui.showDebugInfo(false); } selectedUnits.Remove(character); } } } else { foreach (PersonajePlayer person in selectedUnits) { person.selected = false; } selectedUnits.Clear(); RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajePlayer character = hit.collider.gameObject.GetComponent <PersonajePlayer>(); character.selected = true; characterWithFocus = character; selectedUnits.Add(character); ui.showDebugInfo(true); ui.actualizeAgentDebugInfo(character); } else { if (characterWithFocus != null) { characterWithFocus = null; ui.showDebugInfo(false); } } } } } else if (mouseBehav == MOUSE_ACTION_FORMATION.MOVE) { if (selectedUnits.Count > 0) { if (Input.GetMouseButton(0)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { PersonajeBase personajeObjetivo = hit.collider.gameObject.GetComponent <PersonajeBase>(); foreach (PersonajeBase person in selectedUnits) { if (person.currentFormacion != null) { formaciones.Remove(person.currentFormacion); person.currentFormacion.disband(); } PursueSD pursueSD = new PursueSD(); pursueSD.target = personajeObjetivo; /*person.fake.posicion = hit.point; * person.fake.moveTo(hit.point); * person.fake.innerDetector = person.innerDetector;*/ person.newTask(pursueSD); } } else if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 10)) { foreach (PersonajeBase person in selectedUnits) { if (person.currentFormacion != null && person.currentFormacion.lider != person) { formaciones.Add(person.currentFormacion); person.currentFormacion.disband(); } //person.setAction(new AgentActionMove(new Vector2(hit.point.x, hit.point.z), person.innerDetector, person.outterDetector)); PursueSD pursueSD = new PursueSD(); pursueSD.target = person.fakeMovement; person.fakeMovement.posicion = hit.point; person.fakeMovement.moveTo(hit.point); // mover los fakes para debuggeo person.fakeMovement.innerDetector = person.innerDetector; person.newTask(pursueSD); } } } } } else { if (Input.GetMouseButton(0)) { RaycastHit hit; if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 10000f, 1 << 8)) { foreach (PersonajeBase person in selectedUnits) { if (person.currentFormacion != null) { formaciones.Remove(person.currentFormacion); person.currentFormacion.disband(); } } //Asignamos el lider que clicamos PersonajeBase lider = hit.collider.gameObject.GetComponent <PersonajeBase>(); Formacion formacion = null; if (mouseBehav == MOUSE_ACTION_FORMATION.TRIANGLE_FORMATION) { formacion = new FormacionTriangulo(lider); } else if (mouseBehav == MOUSE_ACTION_FORMATION.SQUARE_FORMATION) { formacion = new FormacionCuadrado(lider); } else if (mouseBehav == MOUSE_ACTION_FORMATION.ROLE_FORMATION) { formacion = new FormacionPorRoles(lider); } foreach (PersonajeBase person in selectedUnits) { person.currentFormacion = formacion; if (person != lider) { formacion.addMiembro(person); } } formacion.formacionASusPuestos(); formaciones.Add(formacion); } } } } }
private RenglonDeFormacion renglonDe(Formacion formacion) { return(new RenglonDeFormacion(formacion, this.OnformacionEdit, this.onformacionRemove)); }