public XwingEnemigo(TGCVector3 posicionInicial, Xwing target, float velocidadInicial, CoordenadaEsferica direccionInicial) { posicion = posicionInicial; velocidadGeneral = velocidadInicial; //Por defecto, se encuentra mirando hacia el z+ this.coordenadaEsferica = direccionInicial; nave = new TgcSceneLoader().loadSceneFromFile(VariablesGlobales.mediaDir + "XWing\\X-Wing-TgcScene.xml");//@ésta deberia ser nuestra nave, no la enemiga! nave.Meshes.ForEach(mesh => { mesh.AutoTransformEnable = false; mesh.Transform = TGCMatrix.Scaling(scale) * TGCMatrix.RotationYawPitchRoll(coordenadaEsferica.GetRotation().Y, coordenadaEsferica.GetRotation().X, coordenadaEsferica.GetRotation().Z) * TGCMatrix.Translation(posicion); //Shader if (VariablesGlobales.SHADERS) { Effect shader = VariablesGlobales.shaderManager.AskForEffect(ShaderManager.MESH_TYPE.SHADOW); if (shader != null) { nave.Meshes.ForEach(m => m.Effect = shader); } VariablesGlobales.shaderManager.AddObject(this); } }); this.target = target; //Calcula inicialmente en que direccion esta el xwing principal vectorDistancia = CommonHelper.SumarVectores(target.GetPosition(), -posicion); coordenadaAXwing = new CoordenadaEsferica(vectorDistancia.X, vectorDistancia.Y, vectorDistancia.Z); }
private void Disparar() { VariablesGlobales.managerElementosTemporales.AgregarElemento( new Misil(posicion, coordenadaAXwing, coordenadaAXwing.GetRotation(), "Misil\\misil_xwing_enemigo-TgcScene.xml", Misil.OrigenMisil.ENEMIGO)); VariablesGlobales.managerSonido.ReproducirSonido(SoundManager.SONIDOS.DISPARO_MISIL_ENEMIGO); }
private void Moverse() { posicion = CommonHelper.MoverPosicionEnDireccionCoordenadaEsferica(posicion, coordenadaEsferica, velocidadGeneral, VariablesGlobales.elapsedTime); nave.Meshes.ForEach(mesh => { mesh.Transform = TGCMatrix.Scaling(scale) * TGCMatrix.RotationYawPitchRoll(coordenadaEsferica.GetRotation().Y, coordenadaEsferica.GetRotation().X, coordenadaEsferica.GetRotation().Z) * TGCMatrix.Translation(posicion); }); }
public void Update() { DistanciaAXwing = target.GetPosition() - posicion - origenDeDisparos; float distanciaLength = DistanciaAXwing.Length(); isVisible = TGCVector3.Dot(-DistanciaAXwing, target.coordenadaDireccionCartesiana) > 0 && distanciaLength < distanciaMinimaAVisible; tiempoDesdeUltimoDisparo += VariablesGlobales.elapsedTime; if (tiempoDesdeUltimoDisparo > tiempoEntreDisparos) { tiempoDesdeUltimoDisparo = 0f; if (this.vida > 0 && distanciaLength < distanciaMinimaATarget) { isActive = true; CoordenadaEsferica direccionXwing = new CoordenadaEsferica(DistanciaAXwing.X, DistanciaAXwing.Y, DistanciaAXwing.Z); VariablesGlobales.managerElementosTemporales.AgregarElemento(new Misil( posicion + origenDeDisparos, direccionXwing, direccionXwing.GetRotation() , "Misil\\misil_torreta.xml", Misil.OrigenMisil.ENEMIGO)); } else { isActive = false; } } }